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:
@@ -24,9 +24,6 @@
|
||||
/ Additional user header to be used
|
||||
/-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "main.h"
|
||||
#include "stm32wbxx_hal.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
/-----------------------------------------------------------------------------*/
|
||||
|
@@ -1,4 +1,3 @@
|
||||
#include "main.h"
|
||||
#include <furi_hal.h>
|
||||
#include <furi.h>
|
||||
|
||||
@@ -46,8 +45,8 @@ void SD_IO_Init(void) {
|
||||
uint8_t counter = 0;
|
||||
|
||||
/* SD chip select high */
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
delay_us(10);
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
furi_hal_delay_us(10);
|
||||
|
||||
/* Send dummy byte 0xFF, 10 times with CS high */
|
||||
/* Rise CS and MOSI for 80 clocks cycles */
|
||||
@@ -65,11 +64,11 @@ void SD_IO_Init(void) {
|
||||
void SD_IO_CSState(uint8_t val) {
|
||||
/* Some SD Cards are prone to fail if CLK-ed too soon after CS transition. Worst case found: 8us */
|
||||
if(val == 1) {
|
||||
delay_us(10); // Exit guard time for some SD cards
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
furi_hal_delay_us(10); // Exit guard time for some SD cards
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
} else {
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->cs, false);
|
||||
delay_us(10); // Entry guard time for some SD cards
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, false);
|
||||
furi_hal_delay_us(10); // Entry guard time for some SD cards
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -279,47 +279,47 @@ static uint8_t SD_ReadData(void);
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
void SD_SPI_Bus_To_Down_State() {
|
||||
hal_gpio_init_ex(
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->miso,
|
||||
GpioModeOutputPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFnUnused);
|
||||
hal_gpio_init_ex(
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->mosi,
|
||||
GpioModeOutputPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFnUnused);
|
||||
hal_gpio_init_ex(
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->sck,
|
||||
GpioModeOutputPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFnUnused);
|
||||
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->cs, false);
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->miso, false);
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->mosi, false);
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->sck, false);
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, false);
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->miso, false);
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->mosi, false);
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->sck, false);
|
||||
}
|
||||
|
||||
void SD_SPI_Bus_To_Normal_State() {
|
||||
hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, true);
|
||||
|
||||
hal_gpio_init_ex(
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->miso,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullUp,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI2);
|
||||
hal_gpio_init_ex(
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->mosi,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullUp,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI2);
|
||||
hal_gpio_init_ex(
|
||||
furi_hal_gpio_init_ex(
|
||||
furi_hal_sd_spi_handle->sck,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullUp,
|
||||
@@ -349,13 +349,13 @@ uint8_t BSP_SD_Init(bool reset_card) {
|
||||
furi_hal_power_disable_external_3_3v();
|
||||
SD_SPI_Bus_To_Down_State();
|
||||
hal_sd_detect_set_low();
|
||||
delay(250);
|
||||
furi_hal_delay_ms(250);
|
||||
|
||||
/* reinit bus and enable power */
|
||||
SD_SPI_Bus_To_Normal_State();
|
||||
hal_sd_detect_init();
|
||||
furi_hal_power_enable_external_3_3v();
|
||||
delay(100);
|
||||
furi_hal_delay_ms(100);
|
||||
}
|
||||
|
||||
/* Configure IO functionalities for SD pin */
|
||||
@@ -867,7 +867,7 @@ SD_CmdAnswer_typedef SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t
|
||||
retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE);
|
||||
/* Set CS High */
|
||||
SD_IO_CSState(1);
|
||||
HAL_Delay(1);
|
||||
furi_hal_delay_us(1000);
|
||||
/* Set CS Low */
|
||||
SD_IO_CSState(0);
|
||||
|
||||
|
Reference in New Issue
Block a user