Programmable Clock with RTOS 0.0.1
Implementaiton of a programmable clock using RTOS with STM32GO microcontroller.
Loading...
Searching...
No Matches
app_serial.h File Reference

Message processing implementation More...

Go to the source code of this file.

Macros

#define STATIC   static
 
#define JANUARY   1u
 
#define FEBRUARY   2u
 
#define MARCH   3u
 
#define APRIL   4u
 
#define MAY   5u
 
#define JUNE   6u
 
#define JULY   7u
 
#define AUGUST   8u
 
#define SEPTEMBER   9u
 
#define OCTOBER   10u
 
#define NOVEMBER   11u
 
#define DECEMBER   12u
 
#define NUM_0   0u
 
#define NUM_1   1u
 
#define NUM_4   4u
 
#define NUM_5   5u
 
#define NUM_100   100u
 
#define SINGLE_FRAME_ELEMENT   0u
 
#define TIME_HOUR_ELEMENT   1u
 
#define TIME_MIN_ELEMENT   2u
 
#define TIME_SEC_ELEMENT   3u
 
#define DATE_DAY_ELEMENT   1u
 
#define DATE_MON_ELEMENT   2u
 
#define DATE_MSB_YEAR_ELEMENT   3u
 
#define DATE_LSB_YEAR_ELEMENT   4u
 
#define ALARM_HOUR_ELEMENT   1u
 
#define ALARM_MIN_ELEMENT   2u
 
#define DATA_OK   0x55u
 
#define DATA_ERROR   0xAAu
 
#define MAX_HOUR_HEX   23u
 
#define MAX_MIN_HEX   59u
 
#define MAX_SEC_HEX   59u
 
#define DAYS_IN_FERUARY_HEX   28u
 
#define DAYS_IN_LEAP_YEAR_FERUARY_HEX   29u
 
#define MIN_DAY_HEX   01u
 
#define MAX_DAYS_HEX_30   30u
 
#define MAX_DAYS_HEX_31   31u
 
#define MIN_YEAR_HEX   1901u
 
#define MAX_YEAR_HEX   2099u
 
#define TRUE   1u
 
#define MESSAGE   1u
 
#define TICKS   0u
 
#define VAL_EXTFILTERSNBR   0u
 
#define VAL_STDFILTERSNDR   1u
 
#define VAL_NOMINALPRESCALER   8u
 
#define VAL_NOMINALSYNCJUMPWIDTH   1u
 
#define VAL_NOMINALTIMESEG1   11u
 
#define VAL_NOMINALTIMESEG2   4u
 
#define VAL_IDENTIFIER   0x122u
 
#define VAL_FILTERINDEX   0u
 
#define VAL_FILTERID1   0x111u
 
#define VAL_FILTERID2   0x7FFu
 
#define VAL_BUFFERINDEXES   0u
 

Enumerations

enum  MACHINE_SERIAL {
  SERIAL_TIME , SERIAL_DATE , SERIAL_ALARM , SERIAL_OK ,
  SERIAL_ERROR , SERIAL_IDLE
}
 Enum with states for state machines. More...
 

Functions

void Serial_Init (void)
 Initialize of CAN port
 
void Serial_Task (void)
 Call of the serial state machine
 

Detailed Description

Message processing implementation

Contains the defines to initialize the CAN port with the apropiate parameters, and other defines needed in the aplication.

Enumeration Type Documentation

◆ MACHINE_SERIAL

Enum with states for state machines.

Enumerator
SERIAL_TIME 

Clock machine state for set alarm

SERIAL_DATE 

Clock machine state for set date

SERIAL_ALARM 

Clock machine state for set time

SERIAL_OK 

Clock machine state for set print

SERIAL_ERROR 

Clock machine state for set print

SERIAL_IDLE 

Clock machine state idle

Function Documentation

◆ Serial_Init()

void Serial_Init ( void )
extern

Initialize of CAN port

Is the function to initialize all the required to start working with the CAN port and the messages reception processing

Note
Declaration of the options to configure the FDCAN1 module to transmit to the CAN bus at 100Kbps and sample point of 75%, the frequency with which the CAN module is powered is fCAN = fHSI / CANHandler.Init.ClockDivider / CANHandler.Init.NominalPrescaler fCAN = 32MHz / 1 / 8 = 4MHz The number of time quantas required is Ntq = fCAN / CANbaudrate Ntq = 4MHz / 250Kbps = 16 The sample point percentage is Sp = ( CANHandler.Init.NominalTimeSeg1 + 1 / Ntq ) * 100 Sp = ( ( 11 + 1 ) / 16 ) * 100 = 75%

< Value for ExtFiltersNbr

< Value for StdFiltersNbr

< Value for NominalPrescaler

< Value for NominalSyncJumpWidth

< Value for NominalTimeSeg1

< Value for NominalTimeSeg2

< Value for Identifier

< Value for FilterIndex

< Value for FilterID1

< Value for FilterID2

< Value for BufferIndexes

◆ Serial_Task()

void Serial_Task ( void )
extern

Call of the serial state machine

This function calls the serial state machine every 10ms with the help of queues, therefore it won't be execute all the time

< Single frame element recieved

< True in a comparison