summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/valves.h
blob: 1b50b3afe6c7ccf44bbe3f3e9aee3c8f51f74043 (plain)
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
#ifndef VALVES_H_
#define VALVES_H_

#include "util.h"

#include <stdint.h>


/* Global valves state */
enum valves_global_state {
	VALVES_IDLE,
	VALVES_FLOW_IN,
	VALVES_FLOW_OUT,
};

/* State for one valve. */
enum valve_state {
	VALVE_STATE_IDLE,
	VALVE_STATE_12,
	VALVE_STATE_14,
};

#define VALVE_TOGGLE_MSEC	10

/* Wait for the valve to toggle from one position to another. */
static inline void valve_wait_toggle(void)
{
	mdelay(VALVE_TOGGLE_MSEC);
}

void valves_init(void);
void valves_work(void);
void valves_emergency_state(void);
void valves_shutdown(void);
void valves_global_switch(uint8_t global_state);
uint8_t valves_get_global_state(void);

void valve0_switch(uint8_t state);
void valve1_switch(uint8_t state);

#endif /* VALVES_H_ */
bues.ch cgit interface