annotate Small_CPU/Inc/externalInterface.h @ 859:d32901746950 Evo_2_23

Improvment battery charger visualization: In the previous version the green flash (charge complete) was shown even battery had not reached 100% charge. Root cause was that the pin signaling the end of charge could be raised for other reasons then a full battery. The new version will show the green flash only in case the battery is rated as full. In addition the graph visualization has been updated to continously progress. In the previous version it only progressed in case the charge value changed. Especially at charging start the charger is doing some battery evaluation which does not increase the charge state. In such a case the graph seemed to be frozen.
author Ideenmodellierer
date Tue, 07 May 2024 21:20:33 +0200
parents 061174d88af9
children f72613a152dd
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 ------------------------------------------------------------------*/
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
31 #include "configuration.h"
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
32 #include "data_central.h"
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
33 #include "data_exchange.h"
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
34
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
35 #define MAX_ADC_CHANNEL (3u) /* number of channels to be read */
781
01b3eb9d55c3 Update real multiplexer implementation:
Ideenmodellierer
parents: 779
diff changeset
36 #define MAX_MUX_CHANNEL (4u) /* number of channels provided by the UART multiplexer */
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
37 #define EXTERNAL_ADC_NO_DATA 0xFF
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
38
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
39 #define EXT33V_CONTROL_PIN GPIO_PIN_7 /* PortC */
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
40
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
41 #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
42
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
43 #define COMMON_SENSOR_STATE_INIT (0x0u) /* All individual state definitions shall start with a INIT state = 0 */
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
44 #define COMMON_SENSOR_STATE_INVALID (0xFFu) /* All individual state definitions shall not use 0xFF for operation control */
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
45
839
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
46
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
47 enum /* Definitions for supported UART protocols */
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
48 {
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
49 EXT_INTERFACE_UART_OFF = 0,
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
50 EXT_INTERFACE_UART_CO2,
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
51 EXT_INTERFACE_UART_SENTINEL,
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
52 EXT_INTERFACE_UART_O2
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
53 };
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
54
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 798
diff changeset
55
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
56 typedef enum
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
57 {
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
58 DETECTION_OFF = 0, /* no detection requested */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
59 DETECTION_INIT, /* prepare external interface for operation if not already activated */
731
2a801cfe23ab Improvment sensor Autodetection:
Ideenmodellierer
parents: 729
diff changeset
60 DETECTION_START,
2a801cfe23ab Improvment sensor Autodetection:
Ideenmodellierer
parents: 729
diff changeset
61 DETECTION_ANALOG1, /* check ADC channels for connected sensors */
2a801cfe23ab Improvment sensor Autodetection:
Ideenmodellierer
parents: 729
diff changeset
62 DETECTION_ANALOG2,
779
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 742
diff changeset
63 DETECTION_UARTMUX, /* check if a uart multiplexer is present */
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 742
diff changeset
64 DETECTION_DIGO2_0, /* check UART channel for connected DigO2 sensor */
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 742
diff changeset
65 DETECTION_DIGO2_1,
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 742
diff changeset
66 DETECTION_DIGO2_2,
781
01b3eb9d55c3 Update real multiplexer implementation:
Ideenmodellierer
parents: 779
diff changeset
67 DETECTION_DIGO2_3,
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
68 #ifdef ENABLE_CO2_SUPPORT
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
69 DETECTION_CO2_0, /* check UART channel for connected CO2 sensor */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
70 DETECTION_CO2_1,
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
71 DETECTION_CO2_2,
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
72 DETECTION_CO2_3,
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
73 #endif
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
74 #ifdef ENABLE_SENTINEL_MODE
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
75 DETECTION_SENTINEL, /* check UART channel for connected Sentinel */
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
76 DETECTION_SENTINEL2,
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 738
diff changeset
77 #endif
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
78 DETECTION_DONE
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
79 } externalInterfaceAutoDetect_t;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
80
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
81
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
82
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
83
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
84 void externalInterface_Init(void);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
85 void externalInterface_InitPower33(void);
738
30717de00f3a Added data init function for external interface:
Ideenmodellierer
parents: 731
diff changeset
86 void externalInterface_InitDatastruct(void);
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
87 uint8_t externalInterface_StartConversion(uint8_t channel);
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
88 uint8_t externalInterface_ReadAndSwitch();
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
89 float externalInterface_CalculateADCValue(uint8_t channel);
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
90 float getExternalInterfaceChannel(uint8_t channel);
691
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
91 uint8_t setExternalInterfaceChannel(uint8_t channel, float value);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
92 void externalInterface_SwitchPower33(uint8_t state);
691
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
93 void externalInterface_SwitchADC(uint8_t state);
704
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 691
diff changeset
94 void externalInterface_SwitchUART(uint8_t protocol);
691
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
95 uint8_t externalInterface_isEnabledPower33(void);
52d68cf9994c Improvment external interface usage:
Ideenmodellierer
parents: 662
diff changeset
96 uint8_t externalInterface_isEnabledADC(void);
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
97 uint8_t externalInterface_GetUARTProtocol(void);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
98 void externalInterface_HandleUART(void);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
99 void externalInterface_SetCO2Scale(float CO2Scale);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
100 float externalInterface_GetCO2Scale(void);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
101 void externalInterface_SetCO2Value(uint16_t CO2_ppm);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
102 void externalInterface_SetCO2SignalStrength(uint16_t LED_qa);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
103 uint16_t externalInterface_GetCO2Value(void);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
104 uint16_t externalInterface_GetCO2SignalStrength(void);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
105 void externalInterface_SetCO2State(uint16_t state);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
106 uint16_t externalInterface_GetCO2State(void);
779
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 742
diff changeset
107 uint8_t externalInterface_GetSensorData(uint8_t sensorId, uint8_t* pDataStruct);
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 781
diff changeset
108 void externalInterface_SetSensorData(uint8_t sensorId, uint8_t* pDataStruct);
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
109 void externalInface_SetSensorMap(uint8_t* pMap);
731
2a801cfe23ab Improvment sensor Autodetection:
Ideenmodellierer
parents: 729
diff changeset
110 uint8_t* externalInterface_GetSensorMapPointer(uint8_t finalMap);
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 714
diff changeset
111 void externalInterface_AutodetectSensor(void);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 554
diff changeset
112 void externalInterface_ExecuteCmd(uint16_t Cmd);
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
113
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
114 uint8_t externalInterface_GetActiveUartSensor(void);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
115 void externalInterface_SetSensorState(uint8_t sensorIdx, uint8_t state);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
116 uint8_t externalInterface_GetSensorState(uint8_t sensorIdx);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
117
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
118
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 786
diff changeset
119
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents:
diff changeset
120 #endif /* EXTERNAL_INTERFACE_H */