77 lines
1.4 KiB
C

#ifndef _COMMON_H_
#define _COMMON_H_
#include <stdint.h>
#include <stddef.h>
#define Q(x) #x
#define QUOTE(x) Q(x)
#define SET_BIT(value, bitPosition) ((value) |= (1U << (bitPosition)))
#define TRUE 1
#define FALSE 0
#ifndef DEVICE_NAME
#define HOST_NAME "AirsoftTimer"
#else
#define HOST_NAME DEVICE_NAME
#endif
#define SHUTDOWN_DELAY_MS 5000
#define STARTUP_DELAY_MS 20000
#define GPIO_LORA_TX D3
#define GPIO_LORA_RX D4
#define GPIO_LORA_AUX D0
#define GPIO_7SEG_EN_FAC1 D7
#define GPIO_7SEG_EN_FAC2 D6
#define GPIO_7SEG_EN_FAC3 D5
#define GPIO_7SEG_CLK D8
#define I2C_IO_BTN_FAC1 0
#define FAC_1_TRG_PRESSED LOW
#define I2C_IO_BTN_FAC2 1
#define FAC_2_TRG_PRESSED LOW
#define I2C_IO_BTN_FAC3 2
#define FAC_3_TRG_PRESSED LOW
#define I2C_IO_LORA_M0 4
#define I2C_IO_LORA_M1 3
#define EEPROM_TYPE 24LC64
#define I2C_IO_ADDRESS 0x38
#define I2C_POWER_ADDRESS 0x40
#define I2C_EEPROM_ADDRESS 0x50
#ifndef OTA_DELAY
#define OTA_DELAY 50 // ticks -> 10ms / tick
#endif
typedef enum eSystem_Status
{
sysStat_Init,
sysStat_Startup,
sysStat_Normal,
sysStat_Error,
sysStat_Shutdown
} tSystem_Status;
typedef enum batteryType_e
{
BATTERY_UNDEFINED,
BATTERY_LIPO_2S,
BATTERY_LIPO_3S
} batteryType_t;
// String representation of SpeedSource enum
extern const char *BatteryString[];
extern const size_t BatteryString_Elements;
#define STARTUP_DELAY 2500
#define SHUTDOWN_DELAY_MS 2500
#endif