-
Notifications
You must be signed in to change notification settings - Fork 4
/
relay.h
executable file
·175 lines (153 loc) · 7.63 KB
/
relay.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
Licensed under the EUPL V.1.1, Lizenziert unter EUPL V.1.1
*/
/*
* relay.h
*
* Created on: Jul 16, 2010
* Author: epics
*/
#ifndef RELAY_H_
#define RELAY_H_
extern volatile uint8_t relayThresholdEnable_flag;
extern volatile uint8_t relayThresholdCurrentState;
extern volatile uint8_t relayThresholdNewState;
extern volatile int8_t relayThresholdExternHighChannel;
extern volatile int8_t relayThresholdExternLowChannel;
extern volatile uint8_t relayThresholdInputChannelMask; /*mask of channels of atmel ADC to get values from*/
extern volatile uint8_t relayThresholdExtThresholdsMask; /*mask of ext channels of atmel ADC to get threshold values from*/
extern volatile uint8_t relayThresholdOutputPin; /*pin on PORTA to switch value for relay*/
extern volatile uint8_t relayThresholdLedPin;
extern volatile uint8_t relayThresholdReportCurrentStatusEnable_flag;
extern volatile uint8_t relayThresholds_valid[16];
extern volatile uint8_t relayThresholdAllThresholdsValid;
extern volatile uint8_t relayThresholdRelayValue;
extern volatile uint8_t relayThresholdRelaySetValue;
extern volatile uint8_t relayThresholdOutOfBoundsLock_flag;
extern volatile uint8_t relayThresholdsInBoundsPolarity;
extern volatile uint8_t relayThresholdsOutOfBoundsPolarity;
extern volatile uint8_t relayThresholdsUndefinedIndifferentPolarity;
extern volatile uint8_t relayThresholdsExternalPolarityPinPos;
extern volatile uint8_t relayThresholdsExternalPolarityPort;
extern volatile uint8_t relayThresholdsExternalPolarity;
extern volatile uint8_t relayThresholdInvertPolarity_flag;
extern volatile uint8_t relayThresholdOutOfBoundsStateLock_flag;
extern volatile uint8_t relayThresholdUseIndividualThresholds;
extern volatile uint16_t relayThresholdHigh[8]; /*the maximum gas pressure*/
extern volatile uint16_t relayThresholdLow[8]; /*the minimum gas pressure*/
enum relayThresholdEnum
{
relayThreshold_LOW=0,
relayThreshold_HIGH,
relayThreshold_MAXIMUM_INDEX
};
enum relayThresholdInputSourceEnum
{
relayThresholdInputSource_RADC=0,
relayThresholdInputSource_OWI_MDC_PRESSURE_1,
relayThresholdInputSource_OWI_MDC_PRESSURE_2,
relayThresholdInputSource_MAXIMUM_INDEX
};
extern const char* const relayThresholdStateStrings[] PROGMEM;
enum relayThresholdStates
{
relayThresholdState_INIT,
relayThresholdState_IDLE,
relayThresholdState_INBETWEEN_BOUNDS,
relayThresholdState_OUT_OF_BOUNDS,
relayThresholdState_UNDEFINED,
relayThresholdState_MAXIMUM_NUMBER
};
extern const char* const relayThresholdCommandKeywords[] PROGMEM;
enum relayThresholdCommandKeyNumber
{
relayThresholdCommandKeyNumber_CURRENT_STATE = 0,
relayThresholdCommandKeyNumber_CURRENT_VALUES,
relayThresholdCommandKeyNumber_THR_HIGH,
relayThresholdCommandKeyNumber_THR_LOW,
relayThresholdCommandKeyNumber_ENABLE,
relayThresholdCommandKeyNumber_INPUT_CHANNEL_MASK,
relayThresholdCommandKeyNumber_OUTPUT_PIN,
relayThresholdCommandKeyNumber_LED_PIN,
relayThresholdCommandKeyNumber_REPORT_STATE_ENABLE,
relayThresholdCommandKeyNumber_RELAY_VALUE,
relayThresholdCommandKeyNumber_THRESHOLDS,
relayThresholdCommandKeyNumber_STATUS,
relayThresholdCommandKeyNumber_OUT_OF_BOUNDS_LOCK,
relayThresholdCommandKeyNumber_IN_BOUNDS_POLARITY,
relayThresholdCommandKeyNumber_OUT_OF_BOUNDS_POLARITY,
relayThresholdCommandKeyNumber_INVERT_POLARITY_LOGIC,
relayThresholdCommandKeyNumber_EXTERNAL_IN_BOUNDS_POLARITY,
relayThresholdCommandKeyNumber_EXTERNAL_IN_BOUNDS_PIN_POS,
relayThresholdCommandKeyNumber_EXTERNAL_IN_BOUNDS_PORT,
relayThresholdCommandKeyNumber_POLARITY,
relayThresholdCommandKeyNumber_POLARITY_REINIT,
relayThresholdCommandKeyNumber_REINIT,
relayThresholdCommandKeyNumber_VALIDATE_THRESHOLDS,
relayThresholdCommandKeyNumber_INPUT_CHANNEL_MASK_ADD,
relayThresholdCommandKeyNumber_INPUT_CHANNEL_MASK_DEL,
relayThresholdCommandKeyNumber_EXTERN_THR_HIGH_CHANNEL,
relayThresholdCommandKeyNumber_EXTERN_THR_LOW_CHANNEL,
relayThresholdCommandKeyNumber_USE_INDIVIDUAL_THRESHOLDS,
relayThresholdCommandKeyNumber_EXTERN_THRESHOLD_CHANNEL_MASK,
relayThresholdCommandKeyNumber_MAXIMUM_NUMBER
};
void relayThreshold(struct uartStruct *ptr_uartStruct);
void relayThresholdMiscSubCommands(struct uartStruct *ptr_uartStruct, int16_t index );
uint8_t relayThresholdInit(void);
uint8_t relayThresholdInBoundPolarityInit(void);
void relayThresholdDetermineStateAndTriggerRelay(uint8_t index);
uint8_t relayThresholdDetermineState( uint8_t currentState, uint32_t currentValue, uint32_t high, uint32_t low );
uint8_t relayThresholdDetermineNewRelaySetValue( uint8_t newState );
void relayThresholdsReportCurrentStatus(void);
uint32_t relayThresholdsGetCurrentValue(uint8_t channel);
uint8_t relayThresholdGetExternHighChannel(void);
uint8_t relayThresholdSetExternHighChannel(int8_t value);
uint8_t relayThresholdGetExternHighChannel(void);
uint8_t relayThresholdSetExternHighChannel(int8_t);
uint8_t relayThresholdGetExternLowChannel(void);
uint8_t relayThresholdSetExternLowChannel(int8_t value);
uint8_t relayThresholdGetUseIndividualThresholds(void);
uint8_t relayThresholdSetUseIndividualThresholds(uint8_t value);
uint8_t relayThresholdSetExternThresholdChannel(int8_t channel, volatile int8_t *threshold );
uint8_t relayThresholdsSetLowThreshold(uint16_t value, int8_t channel);
uint8_t relayThresholdsSetHighThreshold(uint16_t value, int8_t channel);
uint8_t relayThresholdsSetEnableFlag(uint8_t value);
uint8_t relayThresholdsSetInputChannelMask(uint8_t value);
uint8_t relayThresholdsAddChannelToInputChannelMask(uint8_t value);
uint8_t relayThresholdsDeleteChannelFromInputChannelMask(uint8_t value);
uint8_t relayThresholdsSetOutputPin(uint8_t value);
uint8_t relayThresholdsSetLedPin(uint8_t value);
uint8_t relayThresholdsSetReportCurrentStatusEnableFlag(uint8_t value);
uint8_t relayThresholdsSetRelayValue(uint8_t value);
uint8_t relayThresholdsSetRelaySetValue(uint8_t value);
uint8_t relayThresholdsSetOutOfBoundsLockFlag(uint8_t value);
uint8_t relayThresholdsSetExternalPolarityPinPos(uint8_t value);
uint8_t relayThresholdsSetInvertPolarityFlag(uint8_t value);
uint8_t relayThresholdsSetExternalPolarityPort(uint8_t value);
uint8_t relayThresholdsSetAllRelevantThresholdsValid(uint8_t value);
uint8_t relayThresholdsCheckAllRelevantThresholdsValid(void);
uint8_t relayThresholdsGetAllThresholdsValid(void);
uint32_t relayThresholdsGetHighThreshold(uint8_t channel);
uint32_t relayThresholdsGetLowThreshold(uint8_t channel);
uint32_t relayThresholdsGetChannelValue(uint8_t channel, volatile uint16_t threshold[]);
uint8_t relayThresholdGetCurrentChannelThreshold(uint8_t channel, uint16_t *low, uint16_t *high);
uint8_t relayThresholdsGetEnableFlag(void);
uint8_t relayThresholdsGetInputChannelMask(void);
uint8_t relayThresholdsGetOutputPin(void);
uint8_t relayThresholdsGetLedPin(void);
uint8_t relayThresholdsGetCurrentState(void);
uint8_t relayThresholdsGetReportStateEnableFlag(void);
uint8_t relayThresholdsGetRelayValue(void);
uint8_t relayThresholdsGetRelaySetValue(void);
uint8_t relayThresholdsGetOutOfBoundsLockFlag(void);
uint8_t relayThresholdsGetExtThresholdsMask(void);
uint8_t relayThresholdsGetInBoundsPolarity(void);
uint8_t relayThresholdsGetOutOfBoundsPolarity(void);
uint8_t relayThresholdsGetExternalPolarityPinPos(void);
uint8_t relayThresholdsGetExternalPolarityPort(void);
uint8_t relayThresholdsGetExternalPolarity(void);
uint8_t relayThresholdsGetInvertPolarityFlag(void);
uint8_t relayThresholdsSetChannelThreshold(uint16_t value, int8_t channel, volatile uint16_t threshold[], uint8_t offset);
extern void (*relayThresholdDetermineStateAndTriggerRelay_p)(uint8_t);
#endif /* RELAY_H_ */