IoT Supervisor 0.0
|
The configuration state machine starts and maintains the system configuration. More...
Data Structures | |
struct | cfg_t |
This struct is a storage type for flash memory. More... | |
Macros | |
#define | C_FLASH_CONF (0x1E00) |
#define | pFLASH_CONF ((uint8_t code*)C_FLASH_CONF) |
#define | C_PW_DEFAULT (0xDEFA) |
#define | C_FOUND_PROG_END (0x12A9) |
#define | C_CFG_HEADER_LEN (sizeof(ex_cfg_header)) |
#define | C_CFG_DATA_LEN (sizeof(cfg_t)) |
#define | C_CFG_C_CRC_LEN (2) |
#define | C_CFG_P_CRC_LEN (2) |
#define | C_CFG_DATA_END (C_CFG_HEADER_LEN + C_CFG_DATA_LEN) |
#define | C_CFG_C_CRC_END (C_CFG_DATA_END + C_CFG_C_CRC_LEN) |
#define | C_CFG_P_CRC_END (C_CFG_C_CRC_END + C_CFG_P_CRC_LEN) |
#define | C_CMD_COMMIT 0x5FAF |
#define | C_CMD_CANCEL 0x0000 |
#define | C_SID_MIN 1 |
#define | C_SID_MAX 247 |
Enumerations | |
enum | VerifSt_t { eVS_Norm = 0 , eVS_Cfg , eVS_Prog , eVS_Setup } |
enum | CfgSM_t { eCFG_Idle = 0 , eCFG_Load , eCFG_Cache , eCFG_Commit , eCFG_Erase , eCFG_Write } |
Functions | |
bool | ccfg_check (void) |
bool | dcfg_check () |
void | cfg_load () |
void | cfg_write (void) |
void | CFGsm () |
Variables | |
code const uint8_t | ex_cfg_header [] |
code const cfg_t | default_cfg |
CfgSM_t | cfgSmS = eCFG_Load |
bool | pw_flag = false |
bool | dir_tx = false |
bool | run_petitmodbus = false |
uint16_t | pw |
cfg_t | cfg |
uint8_t | cfg_write_idx = 0 |
uint16_t | calc_cfg_crc = 0xFFFF |
uint16_t | calc_prog_crc = 0xFFFF |
The configuration state machine starts and maintains the system configuration.
#define C_CFG_C_CRC_END (C_CFG_DATA_END + C_CFG_C_CRC_LEN) |
End of configuration CRC offset in configuration page.
Definition at line 448 of file IoT Supervisor_main.c.
#define C_CFG_C_CRC_LEN (2) |
configuration CRC length (16 bits)
Definition at line 438 of file IoT Supervisor_main.c.
#define C_CFG_DATA_END (C_CFG_HEADER_LEN + C_CFG_DATA_LEN) |
End of configuration data offset in configuration page.
Definition at line 444 of file IoT Supervisor_main.c.
#define C_CFG_DATA_LEN (sizeof(cfg_t)) |
Configuration data length
The password is stored in two bytes.
Definition at line 436 of file IoT Supervisor_main.c.
#define C_CFG_HEADER_LEN (sizeof(ex_cfg_header)) |
Configuration header length
Definition at line 417 of file IoT Supervisor_main.c.
#define C_CFG_P_CRC_END (C_CFG_C_CRC_END + C_CFG_P_CRC_LEN) |
End of program CRC offset in configuration page. Total configuration length.
Definition at line 453 of file IoT Supervisor_main.c.
#define C_CFG_P_CRC_LEN (2) |
program CRC length (16 bits)
Definition at line 440 of file IoT Supervisor_main.c.
#define C_CMD_CANCEL 0x0000 |
Definition at line 29 of file IoT_Supervisor.h.
#define C_CMD_COMMIT 0x5FAF |
Definition at line 28 of file IoT_Supervisor.h.
#define C_FLASH_CONF (0x1E00) |
Configuration page start address in program memory (code memory).
Definition at line 382 of file IoT Supervisor_main.c.
#define C_FOUND_PROG_END (0x12A9) |
Definition at line 398 of file IoT Supervisor_main.c.
#define C_PW_DEFAULT (0xDEFA) |
The default password used to enter configuration cache or configuration page erase and write.
Definition at line 389 of file IoT Supervisor_main.c.
#define C_SID_MAX 247 |
Definition at line 31 of file IoT_Supervisor.h.
#define C_SID_MIN 1 |
Definition at line 30 of file IoT_Supervisor.h.
#define pFLASH_CONF ((uint8_t code*)C_FLASH_CONF) |
Pointer to the flash config
Definition at line 384 of file IoT Supervisor_main.c.
enum CfgSM_t |
Configuration Memory State Machine _ Type
Configuration Memory State Machine _ Type
Definition at line 122 of file IoT_Supervisor.h.
enum VerifSt_t |
Verification Status _ Type
Verification Status _ Type
Definition at line 103 of file IoT_Supervisor.h.
bool ccfg_check | ( | void | ) |
This function performs the code memory configuration checks. It first checks if the values from memory are in-range and then checks if the CRC against the value stored in code memory.
Definition at line 472 of file IoT Supervisor_main.c.
void cfg_load | ( | ) |
This function performs the tasks in the configuration load state in the configuration state machine. This includes loading the configuration from code memory and checking the CRC of program memory.
The verification status is set based on greater than logic. If code memory lacks the correct configuration header, the verification status is "Setup." If the program memory CRC does not match what is stored in the configuration, the verification status is "Program [invalid]." If code memory is invalid or deemed corrupted by an incorrect CRC, the verification status is "Configuration [invalid]."
Definition at line 602 of file IoT Supervisor_main.c.
void cfg_write | ( | void | ) |
This function writes the data memory configuration into code memory. It also calculates the CRC so that later reads can determine the integrity of the configuration data.
Definition at line 663 of file IoT Supervisor_main.c.
void CFGsm | ( | ) |
This function implements the configuration state machine which controls various parts of the supervisor's behavior. It controls the modbus sid, modbus baud rate, watchdog timer, and configuration memory password.
The configuration state machine locks the modbus master out of reading or writing the configuration memory if the state machine is not put into either cache or commit state.
Caches or commits can be escaped from if the modbus user does not want to write data to code memory.
Definition at line 711 of file IoT Supervisor_main.c.
bool dcfg_check | ( | ) |
This function checks the configuration stored in data memory. It does not perform a CRC.
Definition at line 561 of file IoT Supervisor_main.c.
uint16_t calc_cfg_crc = 0xFFFF |
Definition at line 462 of file IoT Supervisor_main.c.
uint16_t calc_prog_crc = 0xFFFF |
Definition at line 463 of file IoT Supervisor_main.c.
cfg_t cfg |
entered password, not necessarily the correct password
Definition at line 460 of file IoT Supervisor_main.c.
uint8_t cfg_write_idx = 0 |
Definition at line 461 of file IoT Supervisor_main.c.
Definition at line 455 of file IoT Supervisor_main.c.
code const cfg_t default_cfg |
Stores the default configuration data.
Definition at line 424 of file IoT Supervisor_main.c.
bool dir_tx = false |
Definition at line 457 of file IoT Supervisor_main.c.
code const uint8_t ex_cfg_header[] |
Stores the header of the configuration page in FLASH
This is the expected configuration header.
Definition at line 408 of file IoT Supervisor_main.c.
uint16_t pw |
Definition at line 459 of file IoT Supervisor_main.c.
bool pw_flag = false |
Definition at line 456 of file IoT Supervisor_main.c.
bool run_petitmodbus = false |
Definition at line 458 of file IoT Supervisor_main.c.