LCM — CH32V003 Light Control Module
Light Control Module, I2C slave
Loading...
Searching...
No Matches
event_log.c File Reference
#include "event_log.h"
#include "lcm_module.h"
#include "ch32v00x_conf.h"
#include "core_riscv.h"
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  EventLog_Rec
 

Macros

#define EVENT_LOG_BAUD   115200U
 
#define EVENT_LOG_LINE_SIZE   96U
 
#define EVENT_LOG_RING_SIZE   48U
 

Enumerations

enum  EventLog_Id {
  EVT_LCM_ERR = 0 , EVT_NVM , EVT_SYS , EVT_I2C_CMD ,
  EVT_I2C_READ
}
 

Functions

static void EventLog_UartPutChar (char ch)
 
static void EventLog_UartWrite (const char *s)
 
static void EventLog_UartInit (void)
 
static void EventLog_PushRaw (uint8_t id, uint8_t a, uint8_t b, uint8_t c)
 
static const char * EventLog_LcmErrName (uint8_t code)
 
static const char * EventLog_UserDataName (uint8_t st)
 
static void EventLog_FormatRecord (const EventLog_Rec *rec)
 
void EventLog_Init (void)
 
void EventLog_Process (void)
 
void EventLog_Printf (const char *fmt,...)
 
void EventLog_BootBanner (void)
 
void EventLog_UserDataInit (UserData_Status st)
 
void EventLog_LcmConfig (uint8_t i2c_addr, const uint8_t group_mask[4], uint8_t relay_state)
 
void EventLog_PushI2cCmd (uint8_t cmd, uint8_t param, uint8_t has_param)
 
void EventLog_PushI2cReadArm (uint8_t cmd)
 
void EventLog_PushLcmError (uint8_t lcm_err_code)
 
void EventLog_PushNvm (uint8_t tag, uint8_t status)
 
void EventLog_PushSystem (uint8_t tag)
 

Variables

static volatile uint8_t s_ring_head
 
static volatile uint8_t s_ring_tail
 
static EventLog_Rec s_ring [EVENT_LOG_RING_SIZE]
 
static uint32_t s_seq
 
static char s_line [EVENT_LOG_LINE_SIZE]
 

Macro Definition Documentation

◆ EVENT_LOG_BAUD

#define EVENT_LOG_BAUD   115200U

Definition at line 16 of file event_log.c.

Referenced by EventLog_BootBanner(), and EventLog_UartInit().

◆ EVENT_LOG_LINE_SIZE

#define EVENT_LOG_LINE_SIZE   96U

Definition at line 17 of file event_log.c.

◆ EVENT_LOG_RING_SIZE

#define EVENT_LOG_RING_SIZE   48U

Definition at line 18 of file event_log.c.

Referenced by EventLog_Process(), and EventLog_PushRaw().

Enumeration Type Documentation

◆ EventLog_Id

Enumerator
EVT_LCM_ERR 
EVT_NVM 
EVT_SYS 
EVT_I2C_CMD 
EVT_I2C_READ 

Definition at line 28 of file event_log.c.

Function Documentation

◆ EventLog_BootBanner()

void EventLog_BootBanner ( void )

Definition at line 396 of file event_log.c.

References EVENT_LOG_BAUD, EventLog_Printf(), and LCM_ID.

Referenced by main().

◆ EventLog_FormatRecord()

◆ EventLog_Init()

void EventLog_Init ( void )

Definition at line 335 of file event_log.c.

References EventLog_UartInit(), s_ring_head, s_ring_tail, and s_seq.

Referenced by main().

◆ EventLog_LcmConfig()

void EventLog_LcmConfig ( uint8_t i2c_addr,
const uint8_t group_mask[4],
uint8_t relay_state )

Definition at line 414 of file event_log.c.

References EventLog_Printf(), and s_seq.

Referenced by main().

◆ EventLog_LcmErrName()

◆ EventLog_Printf()

void EventLog_Printf ( const char * fmt,
... )

Definition at line 381 of file event_log.c.

References EventLog_UartWrite(), and s_line.

Referenced by EventLog_BootBanner(), EventLog_LcmConfig(), and EventLog_UserDataInit().

◆ EventLog_Process()

void EventLog_Process ( void )

Definition at line 356 of file event_log.c.

References EVENT_LOG_RING_SIZE, EventLog_FormatRecord(), s_ring, s_ring_head, and s_ring_tail.

Referenced by LCM_Module_Poll(), and main().

◆ EventLog_PushI2cCmd()

void EventLog_PushI2cCmd ( uint8_t cmd,
uint8_t param,
uint8_t has_param )

Definition at line 425 of file event_log.c.

References EventLog_PushRaw(), and EVT_I2C_CMD.

Referenced by LCM_I2C_OnRxData().

◆ EventLog_PushI2cReadArm()

void EventLog_PushI2cReadArm ( uint8_t cmd)

Definition at line 430 of file event_log.c.

References EventLog_PushRaw(), and EVT_I2C_READ.

Referenced by LCM_I2C_OnRxData().

◆ EventLog_PushLcmError()

void EventLog_PushLcmError ( uint8_t lcm_err_code)

Definition at line 435 of file event_log.c.

References EventLog_PushRaw(), and EVT_LCM_ERR.

Referenced by LCM_SetError().

◆ EventLog_PushNvm()

void EventLog_PushNvm ( uint8_t tag,
uint8_t status )

Definition at line 440 of file event_log.c.

References EventLog_PushRaw(), and EVT_NVM.

Referenced by LCM_Module_Poll(), LCM_SetUserDataCommitError(), and LCM_SetUserDataError().

◆ EventLog_PushRaw()

static void EventLog_PushRaw ( uint8_t id,
uint8_t a,
uint8_t b,
uint8_t c )
static

◆ EventLog_PushSystem()

void EventLog_PushSystem ( uint8_t tag)

Definition at line 445 of file event_log.c.

References EventLog_PushRaw(), and EVT_SYS.

Referenced by LCM_Module_Poll(), and main().

◆ EventLog_UartInit()

static void EventLog_UartInit ( void )
static

Definition at line 112 of file event_log.c.

References EVENT_LOG_BAUD.

Referenced by EventLog_Init().

◆ EventLog_UartPutChar()

static void EventLog_UartPutChar ( char ch)
static

Definition at line 81 of file event_log.c.

Referenced by EventLog_UartWrite().

◆ EventLog_UartWrite()

static void EventLog_UartWrite ( const char * s)
static

Definition at line 93 of file event_log.c.

References EventLog_UartPutChar().

Referenced by EventLog_FormatRecord(), and EventLog_Printf().

◆ EventLog_UserDataInit()

void EventLog_UserDataInit ( UserData_Status st)

Definition at line 404 of file event_log.c.

References EventLog_Printf(), EventLog_UserDataName(), s_seq, and USER_DATA_OK.

Referenced by main().

◆ EventLog_UserDataName()

static const char * EventLog_UserDataName ( uint8_t st)
static

Variable Documentation

◆ s_line

char s_line[EVENT_LOG_LINE_SIZE]
static

Definition at line 63 of file event_log.c.

Referenced by EventLog_FormatRecord(), and EventLog_Printf().

◆ s_ring

Definition at line 61 of file event_log.c.

Referenced by EventLog_Process(), and EventLog_PushRaw().

◆ s_ring_head

volatile uint8_t s_ring_head
static

Definition at line 59 of file event_log.c.

Referenced by EventLog_Init(), EventLog_Process(), and EventLog_PushRaw().

◆ s_ring_tail

volatile uint8_t s_ring_tail
static

Definition at line 60 of file event_log.c.

Referenced by EventLog_Init(), EventLog_Process(), and EventLog_PushRaw().

◆ s_seq

uint32_t s_seq
static