diff Small_CPU/Inc/uart.h @ 794:bb37d4f3e50e

Restructure UART based sensor handling: In the previous version every UART sensor instance had its own protocol handling instance (requests, timeout, errors). With the introduction of the multiplexer these functionalities had to be harmonized. E.g. only one errorhandling which is applied to all sensors. In the new structure the sensor communication is split into one function which takes care for the control needs of a sensor and one function which handles the incoming data. The functions behalf the same independend if the sensor are connected to multiplexer or directly to the OSTC. Second big change in the external sensor concepts is that the data processing is no longer focussed at the three existing ADC channels. Every external sensor (up to 3 ADC and 4 UART) sensor has its own instance. If the ADC slots are not in use then they may be used for visiualization of UART sensors by creating a mirror instance but this is no longer a must.
author Ideenmodellierer
date Mon, 31 Jul 2023 19:46:29 +0200
parents 0b5f45448eb6
children e9eba334b942
line wrap: on
line diff
--- a/Small_CPU/Inc/uart.h	Thu Jul 27 21:52:19 2023 +0200
+++ b/Small_CPU/Inc/uart.h	Mon Jul 31 19:46:29 2023 +0200
@@ -25,6 +25,16 @@
 #include "stm32f4xx_hal.h"
 
 
+#define BUFFER_NODATA			(7u)		/* The read function needs a byte which indecated that no data for processing is available.*/
+											/* This byte shall never appear in a normal data steam */
+
+ typedef enum
+ {
+ 	UART_CO2_INIT = 0,
+	UART_CO2_SETUP,			/* collecting data needed to be read out of the sensor once at startup */
+ 	UART_CO2_OPERATING,		/* normal operation */
+ } uartCO2Status_t;
+
  typedef enum
  {
  	RX_Ready= 0,					/* Initial state */
@@ -46,39 +56,15 @@
 	RX_DataComplete
  } receiveState_t;
 
- typedef enum
- {
- 	UART_O2_INIT = 0,
- 	UART_O2_CHECK,			/* send blink command and check if sensor answers */
- 	UART_O2_REQ_INFO,		/* request information about available internal sensors of sensor */
-	UART_O2_REQ_ID,			/* request ID of sensor */
- 	UART_O2_IDLE,			/* sensor detected and no communication pending */
- 	UART_O2_REQ_O2,			/* O2 value has been requested and is in receiption progress */
-	UART_O2_REQ_RAW,		/* Request O2 and extended raw data */
- 	UART_O2_ERROR			/* Error state which could not be resolved => only exit via de-/activation cycle */
- } uartO2Status_t;
 
-
- typedef enum
-  {
-	O2RX_IDLE = 0,			/* no reception pending */
-	O2RX_CONFIRM,			/* check the command echo */
-	O2RX_GETNR,				/* extract the sensor number */
-	O2RX_GETO2,				/* extract the ppo2 */
-	O2RX_GETTEMP,			/* extract the temperature */
-	O2RX_GETSTATUS,			/* extract the sensor status */
-	O2RX_GETTYPE,			/* extract the sensor type (should be 8) */
-	O2RX_GETCHANNEL,		/* extract the number of sensor channels (should be 1) */
-	O2RX_GETVERSION,		/* extract the sensor version */
-	O2RX_GETSUBSENSORS,		/* extract the available measures (O2, temperature, humidity etc) */
-	O2RX_GETDPHI,			/* extract phase shift */
-	O2RX_INTENSITY,			/* extract intensity of signal */
-	O2RX_AMBIENTLIGHT,		/* extract the intensity of the ambient light */
-	O2RX_PRESSURE,			/* extract pressor within the sensor housing */
-	O2RX_HUMIDITY			/* extract humidity within the sensor housing */
-  } uartO2RxState_t;
-
-
+typedef enum
+{
+	CO2CMD_MODE_POLL,		/* Set operation mode of sensor to polling => only send data if requested */
+	CO2CMD_MODE_STREAM,		/* Set operation mode of sensor to streaming => send data every two seconds */
+	CO2CMD_CALIBRATE,		/* Calibrate sensor */
+	CO2CMD_GETSCALE,		/* Get scaling factor */
+	CO2CMD_GETDATA			/* Read sensor data */
+} co2SensorCmd_t;
 
 void MX_USART1_UART_Init(void);
 void MX_USART1_UART_DeInit(void);
@@ -87,19 +73,22 @@
 void UART_StartDMA_Receiption(void);
 #ifdef ENABLE_CO2_SUPPORT
 void UART_HandleCO2Data(void);
+void DigitalCO2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength);
 #endif
 #ifdef ENABLE_SENTINEL_MODE
 void UART_HandleSentinelData(void);
 #endif
-void UART_HandleDigitalO2(void);
-void UART_MapDigO2_Channel(uint8_t channel, uint8_t muxAddress);
-void UART_SetDigO2_Channel(uint8_t channel);
-uint8_t UART_isDigO2Connected();
 uint8_t UART_isCO2Connected();
 uint8_t UART_isSentinelConnected();
 void UART_setTargetChannel(uint8_t channel);
+void  UART_MUX_SelectAddress(uint8_t muxAddress);
+void UART_SendCmdString(uint8_t *cmdString);
+void UART_ReadData(uint8_t sensorType);
+void UART_FlushRxBuffer(void);
 
 
+void StringToInt(char *pstr, uint32_t *puInt32);
+void StringToUInt64(char *pstr, uint64_t *puint64);
 
 #ifdef __cplusplus
 }