HAL to LL migration: GPIO, HSEM, AES (#1069)
* gpio, hsem, crypto: switch from HAL to LL/registers * Moved GPIO initialization to furi_hal * More HAL removed * All HAL modules disabled * HAL is finally removed * hal_gpio -> furi_hal_gpio, main.h removed * Bootloader build fix * RTOS config moved to freertos-glue * delay -> furi_hal_delay Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "platform.h"
|
||||
#include <assert.h>
|
||||
#include <main.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal_spi.h>
|
||||
|
||||
@@ -30,25 +29,25 @@ void platformIrqThread() {
|
||||
}
|
||||
|
||||
void platformEnableIrqCallback() {
|
||||
hal_gpio_init(&pin, GpioModeInterruptRise, GpioPullDown, GpioSpeedLow);
|
||||
hal_gpio_enable_int_callback(&pin);
|
||||
furi_hal_gpio_init(&pin, GpioModeInterruptRise, GpioPullDown, GpioSpeedLow);
|
||||
furi_hal_gpio_enable_int_callback(&pin);
|
||||
}
|
||||
|
||||
void platformDisableIrqCallback() {
|
||||
hal_gpio_init(&pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
|
||||
hal_gpio_disable_int_callback(&pin);
|
||||
furi_hal_gpio_init(&pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_disable_int_callback(&pin);
|
||||
}
|
||||
|
||||
void platformSetIrqCallback(PlatformIrqCallback callback) {
|
||||
platform_irq_callback = callback;
|
||||
platform_irq_thread_id = osThreadNew(platformIrqThread, NULL, &platform_irq_thread_attr);
|
||||
hal_gpio_add_int_callback(&pin, nfc_isr, NULL);
|
||||
furi_hal_gpio_add_int_callback(&pin, nfc_isr, NULL);
|
||||
// Disable interrupt callback as the pin is shared between 2 apps
|
||||
// It is enabled in rfalLowPowerModeStop()
|
||||
hal_gpio_disable_int_callback(&pin);
|
||||
furi_hal_gpio_disable_int_callback(&pin);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {
|
||||
bool platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {
|
||||
bool ret = false;
|
||||
if(txBuf && rxBuf) {
|
||||
ret =
|
||||
@@ -59,11 +58,7 @@ HAL_StatusTypeDef platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t
|
||||
ret = furi_hal_spi_bus_rx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)rxBuf, len, 1000);
|
||||
}
|
||||
|
||||
if(!ret) {
|
||||
return HAL_ERROR;
|
||||
} else {
|
||||
return HAL_OK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void platformProtectST25RComm() {
|
||||
|
@@ -5,10 +5,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#include <cmsis_os2.h>
|
||||
#include <gpio.h>
|
||||
#include "timer.h"
|
||||
#include "math.h"
|
||||
#include "main.h"
|
||||
#include <furi_hal_gpio.h>
|
||||
#include <furi_hal_light.h>
|
||||
#include <furi_hal_spi.h>
|
||||
@@ -18,7 +16,7 @@ void platformSetIrqCallback(PlatformIrqCallback cb);
|
||||
void platformEnableIrqCallback();
|
||||
void platformDisableIrqCallback();
|
||||
|
||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t len);
|
||||
bool platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t len);
|
||||
void platformProtectST25RComm();
|
||||
void platformUnprotectST25RComm();
|
||||
|
||||
@@ -87,11 +85,18 @@ void platformUnprotectST25RComm();
|
||||
#define platformUnprotectST25RIrqStatus() \
|
||||
platformUnprotectST25RComm() /*!< Unprotect the IRQ status var - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
|
||||
|
||||
#define platformGpioSet(port, pin) LL_GPIO_SetOutputPin(port, pin)
|
||||
#define platformGpioSet(port, pin) \
|
||||
furi_hal_gpio_write_port_pin( \
|
||||
port, pin, true) /*!< Turns the given GPIO High */
|
||||
#define platformGpioClear(port, pin) \
|
||||
furi_hal_gpio_write_port_pin( \
|
||||
port, pin, false) /*!< Turns the given GPIO Low */
|
||||
|
||||
#define platformGpioClear(port, pin) LL_GPIO_ResetOutputPin(port, pin)
|
||||
|
||||
#define platformGpioIsHigh(port, pin) LL_GPIO_IsInputPinSet(port, pin)
|
||||
#define platformGpioIsHigh(port, pin) \
|
||||
(furi_hal_gpio_read_port_pin(port, pin) == \
|
||||
true) /*!< Checks if the given LED is High */
|
||||
#define platformGpioIsLow(port, pin) \
|
||||
(!platformGpioIsHigh(port, pin)) /*!< Checks if the given LED is Low */
|
||||
|
||||
#define platformTimerCreate(t) \
|
||||
timerCalculateTimer(t) /*!< Create a timer with the given time (ms) */
|
||||
|
@@ -41,6 +41,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "timer.h"
|
||||
#include <furi_hal_delay.h>
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
@@ -64,7 +65,7 @@ static uint32_t timerStopwatchTick;
|
||||
|
||||
/*******************************************************************************/
|
||||
uint32_t timerCalculateTimer(uint16_t time) {
|
||||
return (HAL_GetTick() + time);
|
||||
return (furi_hal_get_tick() + time);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
@@ -72,7 +73,7 @@ bool timerIsExpired(uint32_t timer) {
|
||||
uint32_t uDiff;
|
||||
int32_t sDiff;
|
||||
|
||||
uDiff = (timer - HAL_GetTick()); /* Calculate the diff between the timers */
|
||||
uDiff = (timer - furi_hal_get_tick()); /* Calculate the diff between the timers */
|
||||
sDiff = uDiff; /* Convert the diff to a signed var */
|
||||
|
||||
/* Check if the given timer has expired already */
|
||||
@@ -95,10 +96,10 @@ void timerDelay(uint16_t tOut) {
|
||||
|
||||
/*******************************************************************************/
|
||||
void timerStopwatchStart(void) {
|
||||
timerStopwatchTick = HAL_GetTick();
|
||||
timerStopwatchTick = furi_hal_get_tick();
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
uint32_t timerStopwatchMeasure(void) {
|
||||
return (uint32_t)(HAL_GetTick() - timerStopwatchTick);
|
||||
return (uint32_t)(furi_hal_get_tick() - timerStopwatchTick);
|
||||
}
|
||||
|
Reference in New Issue
Block a user