Programmable Clock with RTOS 0.0.1
Implementaiton of a programmable clock using RTOS with STM32GO microcontroller.
|
Clock driver source file. More...
Data Structures | |
struct | StateNode |
Struct for store function for each state of event machine. More... | |
Functions | |
static MACHINE_State | state_serialMsgAlarm (APP_MsgTypeDef *receivedMessage) |
(State) Function executed when Serial Alarm message has been received | |
static MACHINE_State | state_serialMsgDate (APP_MsgTypeDef *receivedMessage) |
(State) Function executed when Serial Date message has been received | |
static MACHINE_State | state_serialMsgTime (APP_MsgTypeDef *receivedMessage) |
(State) Function executed when Serial Time message has been received | |
static MACHINE_State | state_clockMsgPrint (APP_MsgTypeDef *receivedMessage) |
(State) Function executed when Clock Date message has been received | |
static MACHINE_State | Clock_EventMachine (APP_MsgTypeDef *receivedMessage) |
Process message according to its type. | |
static void | Clock_Update_DateAndTime (TimerHandle_t pxTimer) |
Function executed every second to print data in LCD. | |
void | Clock_Init (void) |
Use once to Initialize the clock. | |
void | Clock_Task (void) |
Run periodically. It allows to configure the clock. | |
void | HAL_RTC_AlarmAEventCallback (RTC_HandleTypeDef *hrtc) |
Callback interruption of the ALARM. | |
Clock driver source file.
Find here source for interfaces and private functions which allows to initialize and set the clock
|
static |
Process message according to its type.
< Macro defined for testing purposes. Use in private members
receivedMessage | Message readed from clockQueue which allows to move between states inside machine |
Returns | the next state that will be executed |
The state machine is builded with pointers to functions stored inside a struct (StateNode) which represent a state of the machine
For improve the code reading, an array of StateNode (stateMachine) stores all the nodes (states of the machine)
Every time this function is executed, it calls a process according to the received message's type
< Total states in event machine
void Clock_Init | ( | void | ) |
Use once to Initialize the clock.
Initializes RTC peripheral using 32.768kHz external clock Sets time and date to 12:00:00 JAN 1 1999
< Value for RTC async prediv
< Value for RTC sync prediv
< Initial RTC hour
< Initial RTC minutes
< Initial RTC seconds
< Initial RTC subseconds
< Initial RTC day
< Initial RTC year 2 last digit
< Initial RTC year 2 first dig
< ID for timer used to update display
void Clock_Task | ( | void | ) |
Run periodically. It allows to configure the clock.
Verifies if clockQueue has elements to read, if it's true passes the received message(s) to eventmachine for processing data according to its type
< The maximum amount of time
< Statement is true
< Statement is false
< The maximum amount of time
|
static |
Function executed every second to print data in LCD.
< Macro defined for testing purposes. Use in private members
pxTimer | Timer handler |
Sends a message every second to clockQueue indicating data must be printed in LCD
void HAL_RTC_AlarmAEventCallback | ( | RTC_HandleTypeDef * | hrtc | ) |
Callback interruption of the ALARM.
This interruption activates it when the alarm has been setted, when it happens it will desactivated the alarm and will send us to the case of displaying the ALARM. Also, the timer for displaying each second will stop
hrtc | A pointer to the RTC structure |
< Alarm active
< The maximum amount of time
< The maximum amount of time
|
static |
(State) Function executed when Clock Date message has been received
receivedMessage | Message received from clockQueue |
Returns | the next state that will be executed |
Sends a message to display queue indicating data must be printed in LCD Due to event machine implementation, the parameter must be passed but specified as UNUSED
|
static |
(State) Function executed when Serial Alarm message has been received
receivedMessage | Message received from clockQueue |
Returns | the next state that will be executed |
Sets the RTC with received alarm with interrupt
Sends message to clockQueue everytime a type alarm message has been received
< Alarm active
< The maximum amount of time
< Alarm inactive
< Statement is true
< The maximum amount of time
|
static |
(State) Function executed when Serial Date message has been received
receivedMessage | Message received from clockQueue |
Returns | the next state that will be executed |
Sets the RTC with received date Sends message to clockQueue everytime a type date message has been received
< Alarm active
< The maximum amount of time
< Alarm inactive
< Statement is true
|
static |
(State) Function executed when Serial Time message has been received
receivedMessage | Message received from clockQueue |
Returns | the next state that will be executed |
Sets the RTC with received time Sends message to clockQueue everytime a time date message has been received
< Alarm active
< The maximum amount of time
< Alarm inactive
< Statement is true