Mercurial > public > ostc4
comparison Small_CPU/Inc/uart.h @ 798:e9eba334b942
Migrated CO2 protocol implementation to new format:
The previous implementation was a monolithic protocol implementation which was not usable together with the multiplexer. The new implementation moves the CO2 implementation into a separate C file and decoubles the upper layer external interface, which is not able to handle DiveO2 and CO2 sensors in parallel without restriction to port assignments.
author | Ideenmodellierer |
---|---|
date | Mon, 07 Aug 2023 20:29:44 +0200 |
parents | bb37d4f3e50e |
children | ad96f99ebc78 |
comparison
equal
deleted
inserted
replaced
797:acf6614dc396 | 798:e9eba334b942 |
---|---|
23 #endif | 23 #endif |
24 | 24 |
25 #include "stm32f4xx_hal.h" | 25 #include "stm32f4xx_hal.h" |
26 | 26 |
27 | 27 |
28 #define BUFFER_NODATA (7u) /* The read function needs a byte which indecated that no data for processing is available.*/ | 28 #define BUFFER_NODATA (7u) /* The read function needs a byte which indicated that no data for processing is available.*/ |
29 /* This byte shall never appear in a normal data steam */ | 29 /* This byte shall never appear in a normal data steam */ |
30 | |
31 typedef enum | |
32 { | |
33 UART_CO2_INIT = 0, | |
34 UART_CO2_SETUP, /* collecting data needed to be read out of the sensor once at startup */ | |
35 UART_CO2_OPERATING, /* normal operation */ | |
36 } uartCO2Status_t; | |
37 | |
38 typedef enum | |
39 { | |
40 RX_Ready= 0, /* Initial state */ | |
41 RX_DetectStart, /* validate start byte */ | |
42 RX_SelectData, /* Data contained in this frame */ | |
43 RX_Data0, /* Process incoming data */ | |
44 RX_Data1, | |
45 RX_Data2, | |
46 RX_Data3, | |
47 RX_Data4, | |
48 RX_Data5, | |
49 RX_Data6, | |
50 RX_Data7, | |
51 RX_Data8, | |
52 RX_Data9, | |
53 RX_Data10, | |
54 RX_Data11, | |
55 RX_Data12, | |
56 RX_DataComplete | |
57 } receiveState_t; | |
58 | |
59 | |
60 typedef enum | |
61 { | |
62 CO2CMD_MODE_POLL, /* Set operation mode of sensor to polling => only send data if requested */ | |
63 CO2CMD_MODE_STREAM, /* Set operation mode of sensor to streaming => send data every two seconds */ | |
64 CO2CMD_CALIBRATE, /* Calibrate sensor */ | |
65 CO2CMD_GETSCALE, /* Get scaling factor */ | |
66 CO2CMD_GETDATA /* Read sensor data */ | |
67 } co2SensorCmd_t; | |
68 | 30 |
69 void MX_USART1_UART_Init(void); | 31 void MX_USART1_UART_Init(void); |
70 void MX_USART1_UART_DeInit(void); | 32 void MX_USART1_UART_DeInit(void); |
71 void MX_USART1_DMA_Init(void); | 33 void MX_USART1_DMA_Init(void); |
72 uint8_t UART_ButtonAdjust(uint8_t *array); | 34 uint8_t UART_ButtonAdjust(uint8_t *array); |
83 void UART_setTargetChannel(uint8_t channel); | 45 void UART_setTargetChannel(uint8_t channel); |
84 void UART_MUX_SelectAddress(uint8_t muxAddress); | 46 void UART_MUX_SelectAddress(uint8_t muxAddress); |
85 void UART_SendCmdString(uint8_t *cmdString); | 47 void UART_SendCmdString(uint8_t *cmdString); |
86 void UART_ReadData(uint8_t sensorType); | 48 void UART_ReadData(uint8_t sensorType); |
87 void UART_FlushRxBuffer(void); | 49 void UART_FlushRxBuffer(void); |
88 | 50 void UART_ChangeBaudrate(uint32_t newBaudrate); |
89 | 51 |
90 void StringToInt(char *pstr, uint32_t *puInt32); | 52 void StringToInt(char *pstr, uint32_t *puInt32); |
91 void StringToUInt64(char *pstr, uint64_t *puint64); | 53 void StringToUInt64(char *pstr, uint64_t *puint64); |
92 | 54 |
93 #ifdef __cplusplus | 55 #ifdef __cplusplus |