annotate Small_CPU/Inc/externalInterface.h @ 729:d646a0f724a7

Added auto detection functionality for sensors connected to the external interface: O2 sensors may be connected to the analog input as well as to the UART. The GUI visualization provides three slots for ppo2 display. Beside detection of sensor kind the task of the function is to place the available sensor in this three slots. CO2 has its own communication slot outside the ppo2 channel. The result of the automatic detection is communicated via the sensor map.
author Ideenmodellierer
date Sat, 14 Jan 2023 20:46:17 +0100
parents 045ff7800501
children 2a801cfe23ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
1 /**
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
2 ******************************************************************************
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
3 * @file externalInterface.h
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
5 * @version V0.0.1
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
6 * @date 07-Nov-2020
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
7 * @brief Interface functionality to proceed external analog signal via i2c connection
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
8 *
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
9 @verbatim
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
10 ==============================================================================
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
11 ##### How to use #####
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
12 ==============================================================================
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
13 @endverbatim
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
14 ******************************************************************************
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
15 * @attention
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
16 *
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
17 * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
18 *
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
19 ******************************************************************************
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
20 */
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
21
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
22 /* Define to prevent recursive inclusion -------------------------------------*/
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
23 #ifndef EXTERNAL_INTERFACE_H
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
24 #define EXTERNAL_INTERFACE_H
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
25
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
26 #ifdef __cplusplus
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
27 extern "C" {
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
28 #endif
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
29
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
30 /* Includes ------------------------------------------------------------------*/
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
31
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
32 #define MAX_ADC_CHANNEL (3u) /* number of channels to be read */
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
33 #define EXTERNAL_ADC_NO_DATA 0xFF
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
34
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
35 #define EXT33V_CONTROL_PIN GPIO_PIN_7 /* PortC */
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
36
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
37 #define MIN_ADC_VOLTAGE_MV (5.0f) /* miminal voltage to rate an ADC channel as active */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
38
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
39
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
40 typedef enum
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
41 {
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
42 DETECTION_OFF = 0, /* no detection requested */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
43 DETECTION_INIT, /* prepare external interface for operation if not already activated */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
44 DETECTION_ANALOG, /* check ADC channels for connected sensors */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
45 DETECTION_DIGO2, /* check UART channel for connected DigO2 sensor */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
46 DETECTION_CO2, /* check UART channel for connected CO2 sensor */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
47 DETECTION_DONE
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
48 } externalInterfaceAutoDetect_t;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
49
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
50
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
51
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
52
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
53 void externalInterface_Init(void);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
54 void externalInterface_InitPower33(void);
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
55 uint8_t externalInterface_StartConversion(uint8_t channel);
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
56 uint8_t externalInterface_ReadAndSwitch();
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
57 float externalInterface_CalculateADCValue(uint8_t channel);
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
58 float getExternalInterfaceChannel(uint8_t channel);
691
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
59 uint8_t setExternalInterfaceChannel(uint8_t channel, float value);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
60 void externalInterface_SwitchPower33(uint8_t state);
691
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
61 void externalInterface_SwitchADC(uint8_t state);
704
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 691
diff changeset
62 void externalInterface_SwitchUART(uint8_t protocol);
691
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
63 uint8_t externalInterface_isEnabledPower33(void);
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
64 uint8_t externalInterface_isEnabledADC(void);
704
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 691
diff changeset
65 uint8_t externalInterface_GetUARTProtocol();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
66
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
67 void externalInterface_SetCO2Value(uint16_t CO2_ppm);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
68 void externalInterface_SetCO2SignalStrength(uint16_t LED_qa);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
69 uint16_t externalInterface_GetCO2Value(void);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
70 uint16_t externalInterface_GetCO2SignalStrength(void);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
71 void externalInterface_SetCO2State(uint16_t state);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
72 uint16_t externalInterface_GetCO2State(void);
714
045ff7800501 Added customizable data area for specific sensor data:
Ideenmodellierer
parents: 704
diff changeset
73 uint8_t externalInterface_GetSensorData(uint8_t* pDataStruct);
045ff7800501 Added customizable data area for specific sensor data:
Ideenmodellierer
parents: 704
diff changeset
74 void externalInterface_SetSensorData(uint8_t dataId, uint8_t* pDataStruct);
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
75 void externalInface_SetSensorMap(uint8_t* pMap);
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
76 uint8_t* externalInterface_GetSensorMapPointer(void);
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
77 void externalInterface_AutodetectSensor(void);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
78 void externalInterface_ExecuteCmd(uint16_t Cmd);
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
79
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
80 #endif /* EXTERNAL_INTERFACE_H */