makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / lib / DEVICE / device.h
blob80abdc1178fe97f1d5345ca900faf80e1b9b7614
1 #pragma once
3 #include <stdio.h>
4 #include <stdint.h>
6 // duration constants which can be returned from start(), event() or timeout()
7 #define DURATION_IGNORE -2 // when returned from event() does not update the current timeout
8 #define DURATION_NEVER -1 // timeout() will not be called, only event()
9 #define DURATION_IMMEDIATELY 0 // timeout() will be called each loop
11 typedef struct {
12 // Called at the beginning of setup() so the device can configure IO pins etc
13 void (*initialize)();
14 // start() is called at the end of setup() and returns the number of ms when to call timeout()
15 int (*start)();
16 // An event was fired, take action and return new duration for timeout call
17 int (*event)();
18 // The duration has passed so take appropriate action and return a new duration, this function should never return DURATION_IGNORE
19 int (*timeout)();
20 } device_t;
22 typedef struct {
23 device_t *device;
24 int8_t core; // 0 = UART core or 1 = loopcore
25 } device_affinity_t;
27 void devicesRegister(device_affinity_t *devices, uint8_t count);
28 void devicesInit();
29 void devicesStart();
30 void devicesUpdate(unsigned long now);
31 void devicesTriggerEvent();