[FL-1167] Rework GPIO and EXTI with LL lib (#424)

* api-hal-gpio: rework gpio on ll
* one_wire_slave: rework gpio initialization
* interrupts: add attribute weak to hal exti interrupts handlers
* api-hal-gpio: add exti interrupt handlers
* input: rework with api-hal-gpio interrupts
* one_wire_slave: rework with api-hal-gpio interrupts
* api-hal-gpio: fix incorrect exti line config
* api-hal-gpio: add doxygen documentation
* api-hal-gpio: add enable / disable interrupts
* api-hal-gpio: add get_rfid_level
* core: remove api-gpio
* applications: rework gpio with api-hal-gpio
* lib: rework gpio with api-hal-gpio
* rfal: disable exti interrupt when rfal is inactive
* rfal: add interrupt gpio reinitialization
* api-hal-gpio: hide setting speed and pull mode LL implementation
* stm32wbxx_it: remove unused EXTI handlers
* api-hal-gpio: guard set, enable, disable and remove interrupt
* Drop F4 target
* Accessor: update gpio api usage

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-04-29 11:51:48 +03:00
committed by GitHub
parent c3350990c2
commit b405a22cd1
147 changed files with 482 additions and 18140 deletions

View File

@@ -1,55 +0,0 @@
#include "api-gpio.h"
#include <cmsis_os2.h>
#include <furi/record.h>
osMutexId_t gpioInitMutex;
bool gpio_api_init(void) {
gpioInitMutex = osMutexNew(NULL);
if(gpioInitMutex == NULL) return false;
return true;
}
// init GPIO
void gpio_init(const GpioPin* gpio, const GpioMode mode) {
if(osMutexAcquire(gpioInitMutex, osWaitForever) == osOK) {
hal_gpio_init(gpio, mode, GpioPullNo, GpioSpeedLow);
osMutexRelease(gpioInitMutex);
}
}
// init GPIO, extended version
void gpio_init_ex(
const GpioPin* gpio,
const GpioMode mode,
const GpioPull pull,
const GpioSpeed speed) {
hal_gpio_init(gpio, mode, pull, speed);
}
// put GPIO to Z-state
void gpio_disable(GpioDisableRecord* gpio_record) {
const GpioPin* gpio_pin = acquire_mutex(gpio_record->gpio_mutex, 0);
if(gpio_pin == NULL) {
gpio_pin = gpio_record->gpio;
}
hal_gpio_init(gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
release_mutex(gpio_record->gpio_mutex, gpio_pin);
}
// get GPIO record
ValueMutex* gpio_open_mutex(const char* name) {
ValueMutex* gpio_mutex = (ValueMutex*)furi_record_open(name);
// TODO disable gpio on app exit
//if(gpio_mutex != NULL) flapp_on_exit(gpio_disable, gpio_mutex);
return gpio_mutex;
}
// get GPIO record and acquire mutex
GpioPin* gpio_open(const char* name) {
ValueMutex* gpio_mutex = gpio_open_mutex(name);
GpioPin* gpio_pin = acquire_mutex(gpio_mutex, osWaitForever);
return gpio_pin;
}

View File

@@ -1,87 +0,0 @@
#pragma once
#include "api-hal-gpio.h"
#include <furi/valuemutex.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
ValueMutex* gpio_mutex;
GpioPin* gpio;
} GpioDisableRecord;
/**
* Init GPIO API
* @return true on successful gpio initialization, false otherwize
*/
bool gpio_api_init();
/**
* Init GPIO
* @param gpio GpioPin instance
* @param mode GpioMode gpio mode
*/
void gpio_init(const GpioPin* gpio, const GpioMode mode);
/**
* Init GPIO, extended version
* @param gpio GpioPin instance
* @param mode GpioMode gpio mode
* @param pull GpioPull gpio pull mode
* @param speed GpioSpeed gpio speed
*/
void gpio_init_ex(
const GpioPin* gpio,
const GpioMode mode,
const GpioPull pull,
const GpioSpeed speed);
/**
* Write value to GPIO
* @param gpio GpioPin instance
* @param state false = LOW, true = HIGH
*/
static inline void gpio_write(const GpioPin* gpio, const bool state) {
hal_gpio_write(gpio, state);
}
/**
* Read value from GPIO
* @param gpio GpioPin instance
* @return false = LOW, true = HIGH
*/
static inline bool gpio_read(const GpioPin* gpio) {
return hal_gpio_read(gpio);
}
/**
* Put GPIO to Z-state
* @param gpio_record GpioDisableRecord instance
*/
void gpio_disable(GpioDisableRecord* gpio_record);
/**
* Get GPIO record
* @param name name of record
* @return ValueMutex instance
*/
ValueMutex* gpio_open_mutex(const char* name);
/**
* Get GPIO record and acquire mutex
* @param name name of record
* @return GpioPin instance
*/
GpioPin* gpio_open(const char* name);
/**
* Get RFID IN level
* @return false = LOW, true = HIGH
*/
bool get_rfid_in_level();
#ifdef __cplusplus
}
#endif