modules.h 3.17 KB
Newer Older
1
2
3
#ifndef MODULES_H
#define MODULES_H

4
5
6
#include "FreeRTOS.h"
#include "semphr.h"

schneider's avatar
schneider committed
7
#include <stdint.h>
8
#include <stdbool.h>
9

10
11
/* ---------- Dispatcher --------------------------------------------------- */
void vApiDispatcher(void *pvParameters);
12
void dispatcher_mutex_init(void);
13
14
15
extern SemaphoreHandle_t api_mutex;
extern TaskHandle_t dispatcher_task_id;

16
17
18
19
20
/* ---------- Hardware Init & Reset ---------------------------------------- */
int hardware_early_init(void);
int hardware_init(void);
int hardware_reset(void);

Rahix's avatar
Rahix committed
21
22
23
24
/* ---------- Lifecycle ---------------------------------------------------- */
void vLifecycleTask(void *pvParameters);
void return_to_menu(void);

25
26
/* ---------- Serial ------------------------------------------------------- */
#define SERIAL_READ_BUFFER_SIZE 128
27
28
#define SERIAL_WRITE_STREAM_BUFFER_SIZE 512
void serial_init();
29
void vSerialTask(void *pvParameters);
30
void serial_enqueue_char(char chr);
Rahix's avatar
Rahix committed
31
extern TaskHandle_t serial_task_id;
32

33
34
35
36
37
38
// For the eSetBit xTaskNotify task semaphore trigger
enum serial_notify{
      SERIAL_WRITE_NOTIFY = 0x01,
      SERIAL_READ_NOTIFY  = 0x02,
};

39
40
41
42
43
/* ---------- LED Animation / Personal States ------------------------------ */
#define PERSONAL_STATE_LED 14
void vLedTask(void *pvParameters);
int personal_state_enabled();

44
45
46
/* ---------- PMIC --------------------------------------------------------- */
void vPmicTask(void *pvParameters);

47
/* ---------- Watchdog ----------------------------------------------------- */
48
void watchdog_init();
49
50
void watchdog_clearer_init();

51
52
53
/* Critical battery voltage */
#define BATTERY_CRITICAL   3.40f

Rahix's avatar
Rahix committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
enum pmic_amux_signal {
	PMIC_AMUX_CHGIN_U     = 0x1,
	PMIC_AMUX_CHGIN_I     = 0x2,
	PMIC_AMUX_BATT_U      = 0x3,
	PMIC_AMUX_BATT_CHG_I  = 0x4,
	PMIC_AMUX_BATT_DIS_I  = 0x5,
	PMIC_AMUX_BATT_NULL_I = 0x6,
	PMIC_AMUX_THM_U       = 0x7,
	PMIC_AMUX_TBIAS_U     = 0x8,
	PMIC_AMUX_AGND_U      = 0x9,
	PMIC_AMUX_SYS_U       = 0xA,
	_PMIC_AMUX_MAX,
};

/*
 * Read a value from the PMIC's AMUX.  The result is already converted into its
 * proper unit.  See the MAX77650 datasheet for details.
 */
int pmic_read_amux(enum pmic_amux_signal sig, float *result);


75
/* ---------- BLE ---------------------------------------------------------- */
76
void vBleTask(void *pvParameters);
77
bool ble_shall_start(void);
78
79
void ble_uart_write(uint8_t *pValue, uint8_t len);

80
81
82
83
84
/* ---------- Hardware (Peripheral) Locks ---------------------------------- */
void hwlock_init(void);

enum hwlock_periph {
	HWLOCK_I2C = 0,
Rahix's avatar
Rahix committed
85
	HWLOCK_ADC,
schneider's avatar
schneider committed
86
87
	HWLOCK_LED,
	HWLOCK_SPI_ECG,
88
89
90
91
92
93
	_HWLOCK_MAX,
};

int hwlock_acquire(enum hwlock_periph p, TickType_t wait);
int hwlock_release(enum hwlock_periph p);

Rahix's avatar
Rahix committed
94
95
/* ---------- Display ------------------------------------------------------ */
/* Forces an unlock of the display. Only to be used in Epicardium */
Gerd's avatar
Gerd committed
96
void disp_forcelock();
97

98
99
100
101
102
/* ---------- BHI160 ------------------------------------------------------- */
#define BHI160_FIFO_SIZE             128
#define BHI160_MUTEX_WAIT_MS          50
void vBhi160Task(void *pvParameters);

103
/* ---------- MAX30001 ----------------------------------------------------- */
schneider's avatar
schneider committed
104
105
#define MAX30001_MUTEX_WAIT_MS          50
void vMAX30001Task(void *pvParameters);
106
void max30001_mutex_init(void);
107

108
#endif /* MODULES_H */