Advertisement

LarryA

image

Biography has not been added

LarryA

's contributions
Articles
Comments
    • Having programmed many years in both C and C++ and currently working in C for embedded systems, I have implemented a lot of what is being shown here. The exception for me is that I don't create an include file for the private functions as I declare them directly in the .c source file. I typically have a struct for the configuration items which are read from and stored in EEPROM and another struct for dynamic variables such as state values, real time values like temperature, etc. The dynamic variables are never accessable from outside the code file they are used in to prevent possible corruption by outside processes, they are typically accessed thru a functional interface like ABC_GetValue() and ABC_SetValue. If I am creating code for a process I also have a specific function naming and usage process also, for example for a temperature control system: TC_Initialize() - reads configuration (if used), sets initial dynamic values. initializes ports/hardware for use. TC_Process() - Runs the process, usually some kind of state machine but can be anything. TC_Start() - Starts controlling the temperature. TC_Stop() - Stops the control process. TC_UpdateSetpoint(uint16_t value) - Change setpoint. uint16_t TC_GetSetpoint(); - Read the setpoint back Great topic, looking forward to more!