2020-10-26 07:16:54 +00:00
|
|
|
#pragma once
|
|
|
|
#include "main.h"
|
|
|
|
#include "stdbool.h"
|
|
|
|
|
2020-12-02 10:47:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-10-26 07:16:54 +00:00
|
|
|
// hw-api
|
|
|
|
|
|
|
|
typedef char GPIO_TypeDef;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GpioModeInput,
|
|
|
|
GpioModeOutputPushPull,
|
|
|
|
GpioModeOutputOpenDrain,
|
|
|
|
GpioModeAltFunctionPushPull,
|
|
|
|
GpioModeAltFunctionOpenDrain,
|
|
|
|
GpioModeAnalog,
|
|
|
|
GpioModeInterruptRise,
|
|
|
|
GpioModeInterruptFall,
|
|
|
|
GpioModeInterruptRiseFall,
|
|
|
|
GpioModeEventRise,
|
|
|
|
GpioModeEventFall,
|
|
|
|
GpioModeEventRiseFall,
|
|
|
|
} GpioMode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GpioSpeedLow,
|
|
|
|
GpioSpeedMedium,
|
|
|
|
GpioSpeedHigh,
|
|
|
|
GpioSpeedVeryHigh,
|
|
|
|
} GpioSpeed;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GpioPullNo,
|
|
|
|
GpioPullUp,
|
|
|
|
GpioPullDown,
|
|
|
|
} GpioPull;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GPIO_TypeDef* port;
|
|
|
|
uint16_t pin;
|
|
|
|
} GpioPin;
|
|
|
|
|
|
|
|
// init GPIO
|
2020-11-19 12:25:32 +00:00
|
|
|
void hal_gpio_init(
|
|
|
|
const GpioPin* gpio,
|
|
|
|
const GpioMode mode,
|
|
|
|
const GpioPull pull,
|
|
|
|
const GpioSpeed speed);
|
2020-10-26 07:16:54 +00:00
|
|
|
|
|
|
|
// write value to GPIO, false = LOW, true = HIGH
|
2020-11-19 12:25:32 +00:00
|
|
|
void hal_gpio_write(const GpioPin* gpio, const bool state);
|
2020-10-26 07:16:54 +00:00
|
|
|
|
|
|
|
// read value from GPIO, false = LOW, true = HIGH
|
2020-12-01 18:47:46 +00:00
|
|
|
bool hal_gpio_read(const GpioPin* gpio);
|
|
|
|
|
|
|
|
void enable_cc1101_irq();
|
2020-12-02 10:47:13 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|