798
+ − 1 /**
+ − 2 ******************************************************************************
+ − 3 * @file uartProtocol_Co2.h
+ − 4 * @author heinrichs weikamp gmbh
+ − 5 * @version V0.0.1
+ − 6 * @date 31-Jul-2023
+ − 7 * @brief Interface functionality to handle external, UART based CO2 sensors
+ − 8 *
+ − 9 @verbatim
+ − 10 ==============================================================================
+ − 11 ##### How to use #####
+ − 12 ==============================================================================
+ − 13 @endverbatim
+ − 14 ******************************************************************************
+ − 15 * @attention
+ − 16 *
+ − 17 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
+ − 18 *
+ − 19 ******************************************************************************
+ − 20 */
+ − 21
+ − 22 /* Define to prevent recursive inclusion -------------------------------------*/
+ − 23 #ifndef UART_PROTOCOL_CO2_H
+ − 24 #define UART_PROTOCOL_CO2_H
+ − 25
+ − 26 #ifdef __cplusplus
+ − 27 extern "C" {
+ − 28 #endif
+ − 29
+ − 30 /* Includes ------------------------------------------------------------------*/
+ − 31 #include "configuration.h"
+ − 32 #include "stm32f4xx_hal.h"
+ − 33
+ − 34 typedef enum
+ − 35 {
+ − 36 UART_CO2_INIT = 0, /* Default Status for every sensor type */
+ − 37 UART_CO2_IDLE, /* sensor detected and no communication pending */
+ − 38 UART_CO2_ERROR,
+ − 39 UART_CO2_SETUP = 10, /* collecting data needed to be read out of the sensor once at startup */
+ − 40 UART_CO2_OPERATING, /* normal operation */
+ − 41 UART_CO2_CALIBRATE /* request calibration */
+ − 42 } uartCO2Status_t;
+ − 43
+ − 44 typedef enum
+ − 45 {
842
+ − 46 CO2RX_Ready= 0, /* Initial state */
+ − 47 CO2RX_DetectStart, /* validate start byte */
+ − 48 CO2RX_SelectData, /* Data contained in this frame */
+ − 49 CO2RX_Data0, /* Process incoming data */
+ − 50 CO2RX_Data1,
+ − 51 CO2RX_Data2,
+ − 52 CO2RX_Data3,
+ − 53 CO2RX_Data4,
+ − 54 CO2RX_Data5,
+ − 55 CO2RX_Data6,
+ − 56 CO2RX_Data7,
+ − 57 CO2RX_Data8,
+ − 58 CO2RX_Data9,
+ − 59 CO2RX_Data10,
+ − 60 CO2RX_Data11,
+ − 61 CO2RX_Data12,
+ − 62 CO2RX_DataComplete
+ − 63 } receiveStateCO2_t;
798
+ − 64
+ − 65
+ − 66 typedef enum
+ − 67 {
+ − 68 CO2CMD_MODE_POLL, /* Set operation mode of sensor to polling => only send data if requested */
+ − 69 CO2CMD_MODE_STREAM, /* Set operation mode of sensor to streaming => send data every two seconds */
+ − 70 CO2CMD_CALIBRATE, /* Calibrate sensor */
+ − 71 CO2CMD_GETSCALE, /* Get scaling factor */
+ − 72 CO2CMD_GETDATA /* Read sensor data */
+ − 73 } co2SensorCmd_t;
+ − 74
+ − 75
+ − 76 void uartCo2_Control(void);
+ − 77 void uartCo2_ProcessData(uint8_t data);
+ − 78 void uartCo2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength);
+ − 79 uint8_t uartCo2_isSensorConnected();
+ − 80
+ − 81 #endif /* UART_PROTOCOL_CO2_H */