|
LCM — CH32V003 Light Control Module
Light Control Module, I2C slave
|
#include "lcm_module.h"#include "lcm_relay.h"#include "lcm_i2c.h"#include "lcm_led.h"#include "user_data.h"#include "event_log.h"#include "ch32v00x_conf.h"Go to the source code of this file.
Functions | |
| static void | LCM_SetSuccess (void) |
| static void | LCM_SetError (uint8_t err) |
| void | LCM_Module_SetError (uint8_t err) |
| static uint8_t | LCM_UserDataErrorCode (UserData_Status st) |
| static void | LCM_SetUserDataError (UserData_Status st) |
| static void | LCM_SetUserDataCommitError (UserData_Status st) |
| static void | LCM_ApplyFactoryDefaults (void) |
| static uint8_t | LCM_UpdateRelayGpio (void) |
| static uint8_t | LCM_NvmWriteConfig (void) |
| static void | LCM_LoadConfig (void) |
| static void | LCM_ApplyGroupOn (uint8_t group_sel) |
| static void | LCM_ApplyGroupOff (uint8_t group_sel) |
| void | LCM_Module_ExecuteSingleByte (uint8_t cmd) |
| void | LCM_Module_ExecuteTwoByte (uint8_t cmd, uint8_t param) |
| void | LCM_Module_ReportUserDataStatus (UserData_Status st) |
| uint8_t | LCM_Module_GetI2cAddr (void) |
| uint8_t | LCM_Module_GetRelayState (void) |
| const uint8_t * | LCM_Module_GetGroupMasks (void) |
| void | LCM_Module_Init (void) |
| void | LCM_Module_Poll (void) |
Variables | |
| static uint8_t | s_i2c_addr |
| static uint8_t | s_relay_state |
| static uint8_t | s_group_mask [LCM_GROUP_COUNT] |
| static volatile uint8_t | s_error_code |
| static volatile uint8_t | s_nvm_dirty |
| static volatile uint8_t | s_reset_requested |
| static volatile uint8_t | s_factory_reset |
|
static |
Definition at line 123 of file lcm_module.c.
References LCM_GROUP_COUNT, LCM_I2C_ADDR_FACTORY, s_group_mask, and s_i2c_addr.
Referenced by LCM_LoadConfig().
|
static |
Definition at line 262 of file lcm_module.c.
References LCM_GROUP_COUNT, LCM_SetSuccess(), LCM_UpdateRelayGpio(), s_group_mask, and s_relay_state.
Referenced by LCM_Module_ExecuteSingleByte(), and LCM_Module_ExecuteTwoByte().
|
static |
Definition at line 236 of file lcm_module.c.
References LCM_GROUP_COUNT, LCM_SetSuccess(), LCM_UpdateRelayGpio(), s_group_mask, and s_relay_state.
Referenced by LCM_Module_ExecuteSingleByte(), and LCM_Module_ExecuteTwoByte().
|
static |
Definition at line 191 of file lcm_module.c.
References LCM_ApplyFactoryDefaults(), LCM_GROUP_COUNT, LCM_NVM_MAGIC, LCM_NVM_OFF_GROUP_BASE, LCM_NVM_OFF_I2C_ADDR, LCM_NVM_OFF_MAGIC, LCM_SetUserDataError(), s_group_mask, s_i2c_addr, USER_DATA_OK, and UserData_ReadByte().
Referenced by LCM_Module_Init().
| void LCM_Module_ExecuteSingleByte | ( | uint8_t | cmd | ) |
Definition at line 302 of file lcm_module.c.
References LCM_ApplyGroupOff(), LCM_ApplyGroupOn(), LCM_ERR_UNKNOWN_CMD, LCM_GET_ERROR, LCM_GET_ID, LCM_GROUP_0_OFF, LCM_GROUP_0_ON, LCM_GROUP_1_OFF, LCM_GROUP_1_ON, LCM_GROUP_2_OFF, LCM_GROUP_2_ON, LCM_GROUP_3_OFF, LCM_GROUP_3_ON, LCM_I2C_ArmRead(), LCM_ID, LCM_LAMP_0_OFF, LCM_LAMP_7_OFF, LCM_LAMP_7_ON, LCM_LAMP_ALL_OFF, LCM_LAMP_ALL_ON, LCM_Led_ErrorOff(), LCM_RESET, LCM_SetError(), LCM_SetSuccess(), LCM_UpdateRelayGpio(), s_error_code, s_factory_reset, s_relay_state, and s_reset_requested.
Referenced by LCM_I2C_OnRxData().
| void LCM_Module_ExecuteTwoByte | ( | uint8_t | cmd, |
| uint8_t | param ) |
Definition at line 389 of file lcm_module.c.
References LCM_ApplyGroupOff(), LCM_ApplyGroupOn(), LCM_ERR_BAD_PARAM, LCM_GROUP_0_SET, LCM_GROUP_1_SET, LCM_GROUP_2_SET, LCM_GROUP_3_SET, LCM_GROUP_OFF, LCM_GROUP_ON, LCM_I2C_ADDR_FACTORY, LCM_I2C_ArmRead(), LCM_LAMP_OFF, LCM_LAMP_ON, LCM_Led_ErrorOff(), LCM_NvmWriteConfig(), LCM_SET_ADDR, LCM_SetError(), LCM_SetSuccess(), LCM_UpdateRelayGpio(), s_error_code, s_group_mask, s_i2c_addr, s_relay_state, and s_reset_requested.
Referenced by LCM_I2C_OnRxData().
| const uint8_t * LCM_Module_GetGroupMasks | ( | void | ) |
| uint8_t LCM_Module_GetI2cAddr | ( | void | ) |
| uint8_t LCM_Module_GetRelayState | ( | void | ) |
| void LCM_Module_Init | ( | void | ) |
Definition at line 483 of file lcm_module.c.
References LCM_ERR_NONE, LCM_I2C_Init(), LCM_Led_Init(), LCM_LoadConfig(), LCM_Relay_Apply(), LCM_Relay_Init(), LCM_SetError(), s_error_code, s_factory_reset, s_i2c_addr, s_nvm_dirty, s_relay_state, and s_reset_requested.
Referenced by main().
| void LCM_Module_Poll | ( | void | ) |
Definition at line 521 of file lcm_module.c.
References EventLog_Process(), EventLog_PushNvm(), EventLog_PushSystem(), LCM_GROUP_COUNT, LCM_I2C_ADDR_FACTORY, LCM_Led_Poll(), LCM_NVM_MAGIC, LCM_NVM_OFF_GROUP_BASE, LCM_NVM_OFF_I2C_ADDR, LCM_NVM_OFF_MAGIC, LCM_NVM_SIZE, LCM_SetUserDataCommitError(), LCM_SetUserDataError(), s_factory_reset, s_group_mask, s_i2c_addr, s_nvm_dirty, s_reset_requested, USER_DATA_OK, UserData_Commit(), and UserData_Write().
Referenced by main().
| void LCM_Module_ReportUserDataStatus | ( | UserData_Status | st | ) |
Definition at line 452 of file lcm_module.c.
References LCM_SetUserDataError(), and USER_DATA_OK.
Referenced by main().
| void LCM_Module_SetError | ( | uint8_t | err | ) |
Definition at line 64 of file lcm_module.c.
References LCM_SetError().
|
static |
Definition at line 161 of file lcm_module.c.
References LCM_GROUP_COUNT, LCM_NVM_MAGIC, LCM_NVM_OFF_GROUP_BASE, LCM_NVM_OFF_I2C_ADDR, LCM_NVM_OFF_MAGIC, LCM_NVM_SIZE, LCM_SetUserDataError(), s_group_mask, s_i2c_addr, s_nvm_dirty, USER_DATA_OK, and UserData_Write().
Referenced by LCM_Module_ExecuteTwoByte().
|
static |
Definition at line 55 of file lcm_module.c.
References EventLog_PushLcmError(), LCM_ERR_NONE, LCM_Led_ErrorOn(), and s_error_code.
Referenced by LCM_Module_ExecuteSingleByte(), LCM_Module_ExecuteTwoByte(), LCM_Module_Init(), LCM_Module_SetError(), LCM_SetUserDataCommitError(), LCM_SetUserDataError(), and LCM_UpdateRelayGpio().
|
static |
Definition at line 43 of file lcm_module.c.
References LCM_ERR_NONE, and s_error_code.
Referenced by LCM_ApplyGroupOff(), LCM_ApplyGroupOn(), LCM_Module_ExecuteSingleByte(), and LCM_Module_ExecuteTwoByte().
|
static |
Definition at line 108 of file lcm_module.c.
References EventLog_PushNvm(), LCM_ERR_USER_DATA_COMMIT, LCM_SetError(), LCM_UserDataErrorCode(), and USER_DATA_ERR_FLASH.
Referenced by LCM_Module_Poll().
|
static |
Definition at line 95 of file lcm_module.c.
References EventLog_PushNvm(), LCM_SetError(), LCM_UserDataErrorCode(), and USER_DATA_OK.
Referenced by LCM_LoadConfig(), LCM_Module_Poll(), LCM_Module_ReportUserDataStatus(), and LCM_NvmWriteConfig().
|
static |
Definition at line 140 of file lcm_module.c.
References LCM_ERR_NONE, LCM_Relay_Apply(), LCM_SetError(), and s_relay_state.
Referenced by LCM_ApplyGroupOff(), LCM_ApplyGroupOn(), LCM_Module_ExecuteSingleByte(), and LCM_Module_ExecuteTwoByte().
|
static |
Definition at line 74 of file lcm_module.c.
References LCM_ERR_USER_DATA_BUSY, LCM_ERR_USER_DATA_FLASH, LCM_ERR_USER_DATA_PARAM, LCM_ERR_USER_DATA_RANGE, USER_DATA_ERR_BUSY, USER_DATA_ERR_FLASH, USER_DATA_ERR_PARAM, and USER_DATA_ERR_RANGE.
Referenced by LCM_SetUserDataCommitError(), and LCM_SetUserDataError().
|
static |
Definition at line 30 of file lcm_module.c.
Referenced by LCM_Module_ExecuteSingleByte(), LCM_Module_ExecuteTwoByte(), LCM_Module_Init(), LCM_SetError(), and LCM_SetSuccess().
|
static |
Definition at line 35 of file lcm_module.c.
Referenced by LCM_Module_ExecuteSingleByte(), LCM_Module_Init(), and LCM_Module_Poll().
|
static |
Definition at line 27 of file lcm_module.c.
Referenced by LCM_ApplyFactoryDefaults(), LCM_ApplyGroupOff(), LCM_ApplyGroupOn(), LCM_LoadConfig(), LCM_Module_ExecuteTwoByte(), LCM_Module_GetGroupMasks(), LCM_Module_Poll(), and LCM_NvmWriteConfig().
|
static |
Definition at line 25 of file lcm_module.c.
Referenced by LCM_ApplyFactoryDefaults(), LCM_LoadConfig(), LCM_Module_ExecuteTwoByte(), LCM_Module_GetI2cAddr(), LCM_Module_Init(), LCM_Module_Poll(), and LCM_NvmWriteConfig().
|
static |
Definition at line 33 of file lcm_module.c.
Referenced by LCM_Module_Init(), LCM_Module_Poll(), and LCM_NvmWriteConfig().
|
static |
Definition at line 26 of file lcm_module.c.
Referenced by LCM_ApplyGroupOff(), LCM_ApplyGroupOn(), LCM_Module_ExecuteSingleByte(), LCM_Module_ExecuteTwoByte(), LCM_Module_GetRelayState(), LCM_Module_Init(), and LCM_UpdateRelayGpio().
|
static |
Definition at line 34 of file lcm_module.c.
Referenced by LCM_Module_ExecuteSingleByte(), LCM_Module_ExecuteTwoByte(), LCM_Module_Init(), and LCM_Module_Poll().