[FL-2733] multitarget support for fbt (#2209)
* First part of multitarget porting * Delete firmware/targets/f7/Inc directory * Delete firmware/targets/f7/Src directory * gpio: cli fixes; about: using version from HAL * sdk: path fixes * gui: include fixes * applications: more include fixes * gpio: ported to new apis * hal: introduced furi_hal_target_hw.h; libs: added one_wire * hal: f18 target * github: also build f18 by default * typo fix * fbt: removed extra checks on app list * api: explicitly bundling select mlib headers with sdk * hal: f18: changed INPUT_DEBOUNCE_TICKS to match f7 * cleaned up commented out code * docs: added info on hw targets * docs: targets: formatting fixes * f18: fixed link error * f18: fixed API version to match f7 * docs: hardware: minor wording fixes * faploader: added fw target check * docs: typo fixes * github: not building komi target by default * fbt: support for `targets` field for built-in apps * github: reworked build flow to exclude app_set; fbt: removed komi-specific appset; added additional target buildset check * github: fixed build; nfc: fixed pvs warnings * attempt to fix target id * f7, f18: removed certain HAL function from public API * apps: debug: enabled bt_debug_app for f18 * Targets: backport input pins configuration routine from F7 to F18 Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
+4
-13
@@ -2,15 +2,6 @@ Import("env")
|
||||
|
||||
env.Append(
|
||||
LINT_SOURCES=[Dir(".")],
|
||||
SDK_HEADERS=[
|
||||
*env.GlobRecursive("*.h", "targets/furi_hal_include", "*_i.h"),
|
||||
*env.GlobRecursive("*.h", "targets/f${TARGET_HW}/furi_hal", "*_i.h"),
|
||||
File("targets/f7/platform_specific/intrinsic_export.h"),
|
||||
],
|
||||
)
|
||||
|
||||
env.SetDefault(
|
||||
SDK_DEFINITION=env.File("./targets/f${TARGET_HW}/api_symbols.csv").srcnode()
|
||||
)
|
||||
|
||||
libenv = env.Clone(FW_LIB_NAME="flipper${TARGET_HW}")
|
||||
@@ -22,9 +13,9 @@ libenv.Append(
|
||||
libenv.ApplyLibFlags()
|
||||
|
||||
|
||||
sources = ["targets/f${TARGET_HW}/startup_stm32wb55xx_cm4.s"]
|
||||
sources += libenv.GlobRecursive("*.c")
|
||||
|
||||
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
|
||||
lib = libenv.StaticLibrary(
|
||||
"${FW_LIB_NAME}",
|
||||
env.get("TARGET_CFG").gatherSources(),
|
||||
)
|
||||
libenv.Install("${LIB_DIST_DIR}", lib)
|
||||
Return("lib")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
#include <furi_hal.h>
|
||||
#include <furi_hal_mpu.h>
|
||||
|
||||
#include <stm32wbxx_ll_cortex.h>
|
||||
|
||||
#include <fatfs.h>
|
||||
|
||||
#define TAG "FuriHal"
|
||||
|
||||
void furi_hal_init_early() {
|
||||
furi_hal_cortex_init_early();
|
||||
|
||||
furi_hal_clock_init_early();
|
||||
|
||||
furi_hal_resources_init_early();
|
||||
|
||||
furi_hal_os_init();
|
||||
|
||||
furi_hal_spi_config_init_early();
|
||||
|
||||
furi_hal_i2c_init_early();
|
||||
furi_hal_light_init();
|
||||
|
||||
furi_hal_rtc_init_early();
|
||||
}
|
||||
|
||||
void furi_hal_deinit_early() {
|
||||
furi_hal_rtc_deinit_early();
|
||||
|
||||
furi_hal_i2c_deinit_early();
|
||||
furi_hal_spi_config_deinit_early();
|
||||
|
||||
furi_hal_resources_deinit_early();
|
||||
|
||||
furi_hal_clock_deinit_early();
|
||||
}
|
||||
|
||||
void furi_hal_init() {
|
||||
furi_hal_mpu_init();
|
||||
furi_hal_clock_init();
|
||||
furi_hal_console_init();
|
||||
furi_hal_rtc_init();
|
||||
|
||||
furi_hal_interrupt_init();
|
||||
|
||||
furi_hal_flash_init();
|
||||
|
||||
furi_hal_resources_init();
|
||||
FURI_LOG_I(TAG, "GPIO OK");
|
||||
|
||||
furi_hal_version_init();
|
||||
|
||||
furi_hal_spi_config_init();
|
||||
|
||||
furi_hal_speaker_init();
|
||||
FURI_LOG_I(TAG, "Speaker OK");
|
||||
|
||||
furi_hal_crypto_init();
|
||||
|
||||
// USB
|
||||
#ifndef FURI_RAM_EXEC
|
||||
furi_hal_usb_init();
|
||||
FURI_LOG_I(TAG, "USB OK");
|
||||
#endif
|
||||
|
||||
furi_hal_i2c_init();
|
||||
|
||||
// High Level
|
||||
furi_hal_power_init();
|
||||
furi_hal_light_init();
|
||||
#ifndef FURI_RAM_EXEC
|
||||
furi_hal_vibro_init();
|
||||
#endif
|
||||
furi_hal_bt_init();
|
||||
furi_hal_compress_icon_init();
|
||||
|
||||
// FatFS driver initialization
|
||||
MX_FATFS_Init();
|
||||
FURI_LOG_I(TAG, "FATFS OK");
|
||||
}
|
||||
|
||||
void furi_hal_switch(void* address) {
|
||||
__set_BASEPRI(0);
|
||||
asm volatile("ldr r3, [%0] \n"
|
||||
"msr msp, r3 \n"
|
||||
"ldr r3, [%1] \n"
|
||||
"mov pc, r3 \n"
|
||||
:
|
||||
: "r"(address), "r"(address + 0x4)
|
||||
: "r3");
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi.h>
|
||||
|
||||
#include <stm32wbxx_ll_rcc.h>
|
||||
#include <stm32wbxx_ll_pwr.h>
|
||||
|
||||
const GpioPin vibro_gpio = {.port = GPIOA, .pin = LL_GPIO_PIN_8};
|
||||
const GpioPin ibutton_gpio = {.port = GPIOB, .pin = LL_GPIO_PIN_14};
|
||||
|
||||
const GpioPin gpio_display_cs = {.port = GPIOC, .pin = LL_GPIO_PIN_11};
|
||||
const GpioPin gpio_display_rst_n = {.port = GPIOB, .pin = LL_GPIO_PIN_0};
|
||||
const GpioPin gpio_display_di = {.port = GPIOB, .pin = LL_GPIO_PIN_1};
|
||||
const GpioPin gpio_sdcard_cs = {.port = GPIOC, .pin = LL_GPIO_PIN_12};
|
||||
const GpioPin gpio_sdcard_cd = {.port = GPIOC, .pin = LL_GPIO_PIN_10};
|
||||
|
||||
const GpioPin gpio_button_up = {.port = GPIOB, .pin = LL_GPIO_PIN_10};
|
||||
const GpioPin gpio_button_down = {.port = GPIOC, .pin = LL_GPIO_PIN_6};
|
||||
const GpioPin gpio_button_right = {.port = GPIOB, .pin = LL_GPIO_PIN_12};
|
||||
const GpioPin gpio_button_left = {.port = GPIOB, .pin = LL_GPIO_PIN_11};
|
||||
const GpioPin gpio_button_ok = {.port = GPIOH, .pin = LL_GPIO_PIN_3};
|
||||
const GpioPin gpio_button_back = {.port = GPIOC, .pin = LL_GPIO_PIN_13};
|
||||
|
||||
const GpioPin gpio_spi_d_miso = {.port = GPIOC, .pin = LL_GPIO_PIN_2};
|
||||
const GpioPin gpio_spi_d_mosi = {.port = GPIOB, .pin = LL_GPIO_PIN_15};
|
||||
const GpioPin gpio_spi_d_sck = {.port = GPIOD, .pin = LL_GPIO_PIN_1};
|
||||
|
||||
const GpioPin gpio_ext_pc0 = {.port = GPIOC, .pin = LL_GPIO_PIN_0};
|
||||
const GpioPin gpio_ext_pc1 = {.port = GPIOC, .pin = LL_GPIO_PIN_1};
|
||||
const GpioPin gpio_ext_pc3 = {.port = GPIOC, .pin = LL_GPIO_PIN_3};
|
||||
const GpioPin gpio_ext_pb2 = {.port = GPIOB, .pin = LL_GPIO_PIN_2};
|
||||
const GpioPin gpio_ext_pb3 = {.port = GPIOB, .pin = LL_GPIO_PIN_3};
|
||||
const GpioPin gpio_ext_pa4 = {.port = GPIOA, .pin = LL_GPIO_PIN_4};
|
||||
const GpioPin gpio_ext_pa6 = {.port = GPIOA, .pin = LL_GPIO_PIN_6};
|
||||
const GpioPin gpio_ext_pa7 = {.port = GPIOA, .pin = LL_GPIO_PIN_7};
|
||||
|
||||
const GpioPin gpio_ext_pc5 = {.port = GPIOC, .pin = LL_GPIO_PIN_5};
|
||||
const GpioPin gpio_ext_pc4 = {.port = GPIOC, .pin = LL_GPIO_PIN_4};
|
||||
const GpioPin gpio_ext_pa5 = {.port = GPIOA, .pin = LL_GPIO_PIN_5};
|
||||
const GpioPin gpio_ext_pb9 = {.port = GPIOB, .pin = LL_GPIO_PIN_9};
|
||||
const GpioPin gpio_ext_pa0 = {.port = GPIOA, .pin = LL_GPIO_PIN_0};
|
||||
const GpioPin gpio_ext_pa1 = {.port = GPIOA, .pin = LL_GPIO_PIN_1};
|
||||
const GpioPin gpio_ext_pa15 = {.port = GPIOA, .pin = LL_GPIO_PIN_15};
|
||||
const GpioPin gpio_ext_pe4 = {.port = GPIOE, .pin = LL_GPIO_PIN_4};
|
||||
const GpioPin gpio_ext_pa2 = {.port = GPIOA, .pin = LL_GPIO_PIN_2};
|
||||
const GpioPin gpio_ext_pb4 = {.port = GPIOB, .pin = LL_GPIO_PIN_4};
|
||||
const GpioPin gpio_ext_pb5 = {.port = GPIOB, .pin = LL_GPIO_PIN_5};
|
||||
const GpioPin gpio_ext_pd0 = {.port = GPIOD, .pin = LL_GPIO_PIN_0};
|
||||
const GpioPin gpio_ext_pb13 = {.port = GPIOB, .pin = LL_GPIO_PIN_13};
|
||||
|
||||
const GpioPin gpio_usart_tx = {.port = GPIOB, .pin = LL_GPIO_PIN_6};
|
||||
const GpioPin gpio_usart_rx = {.port = GPIOB, .pin = LL_GPIO_PIN_7};
|
||||
|
||||
const GpioPin gpio_i2c_power_sda = {.port = GPIOA, .pin = LL_GPIO_PIN_10};
|
||||
const GpioPin gpio_i2c_power_scl = {.port = GPIOA, .pin = LL_GPIO_PIN_9};
|
||||
|
||||
const GpioPin gpio_speaker = {.port = GPIOB, .pin = LL_GPIO_PIN_8};
|
||||
|
||||
const GpioPin periph_power = {.port = GPIOA, .pin = LL_GPIO_PIN_3};
|
||||
|
||||
const GpioPin gpio_usb_dm = {.port = GPIOA, .pin = LL_GPIO_PIN_11};
|
||||
const GpioPin gpio_usb_dp = {.port = GPIOA, .pin = LL_GPIO_PIN_12};
|
||||
|
||||
const GpioPinRecord gpio_pins[] = {
|
||||
{.pin = &gpio_ext_pa7, .name = "PA7", .debug = false},
|
||||
{.pin = &gpio_ext_pa6, .name = "PA6", .debug = false},
|
||||
{.pin = &gpio_ext_pa4, .name = "PA4", .debug = false},
|
||||
{.pin = &gpio_ext_pb3, .name = "PB3", .debug = false},
|
||||
{.pin = &gpio_ext_pb2, .name = "PB2", .debug = false},
|
||||
{.pin = &gpio_ext_pc3, .name = "PC3", .debug = false},
|
||||
{.pin = &gpio_ext_pc1, .name = "PC1", .debug = false},
|
||||
{.pin = &gpio_ext_pc0, .name = "PC0", .debug = false},
|
||||
|
||||
{.pin = &gpio_ext_pc5, .name = "PC5", .debug = false},
|
||||
{.pin = &gpio_ext_pc4, .name = "PC4", .debug = false},
|
||||
{.pin = &gpio_ext_pa5, .name = "PA5", .debug = false},
|
||||
{.pin = &gpio_ext_pb9, .name = "PB9", .debug = false},
|
||||
{.pin = &gpio_ext_pa0, .name = "PA0", .debug = false},
|
||||
{.pin = &gpio_ext_pa1, .name = "PA1", .debug = false},
|
||||
{.pin = &gpio_ext_pa15, .name = "PA15", .debug = false},
|
||||
{.pin = &gpio_ext_pe4, .name = "PE4", .debug = false},
|
||||
{.pin = &gpio_ext_pa2, .name = "PA2", .debug = false},
|
||||
{.pin = &gpio_ext_pb4, .name = "PB4", .debug = false},
|
||||
{.pin = &gpio_ext_pb5, .name = "PB5", .debug = false},
|
||||
{.pin = &gpio_ext_pd0, .name = "PD0", .debug = false},
|
||||
{.pin = &gpio_ext_pb13, .name = "PB13", .debug = false},
|
||||
|
||||
/* Dangerous pins, may damage hardware */
|
||||
{.pin = &gpio_usart_rx, .name = "PB7", .debug = true},
|
||||
{.pin = &gpio_speaker, .name = "PB8", .debug = true},
|
||||
};
|
||||
|
||||
const size_t gpio_pins_count = sizeof(gpio_pins) / sizeof(GpioPinRecord);
|
||||
|
||||
const InputPin input_pins[] = {
|
||||
{.gpio = &gpio_button_up, .key = InputKeyUp, .inverted = true, .name = "Up"},
|
||||
{.gpio = &gpio_button_down, .key = InputKeyDown, .inverted = true, .name = "Down"},
|
||||
{.gpio = &gpio_button_right, .key = InputKeyRight, .inverted = true, .name = "Right"},
|
||||
{.gpio = &gpio_button_left, .key = InputKeyLeft, .inverted = true, .name = "Left"},
|
||||
{.gpio = &gpio_button_ok, .key = InputKeyOk, .inverted = false, .name = "OK"},
|
||||
{.gpio = &gpio_button_back, .key = InputKeyBack, .inverted = true, .name = "Back"},
|
||||
};
|
||||
|
||||
const size_t input_pins_count = sizeof(input_pins) / sizeof(InputPin);
|
||||
|
||||
static void furi_hal_resources_init_input_pins(GpioMode mode) {
|
||||
for(size_t i = 0; i < input_pins_count; i++) {
|
||||
furi_hal_gpio_init(
|
||||
input_pins[i].gpio,
|
||||
mode,
|
||||
(input_pins[i].inverted) ? GpioPullUp : GpioPullDown,
|
||||
GpioSpeedLow);
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_resources_init_early() {
|
||||
furi_hal_resources_init_input_pins(GpioModeInput);
|
||||
|
||||
// SD Card stepdown control
|
||||
furi_hal_gpio_write(&periph_power, 1);
|
||||
furi_hal_gpio_init(&periph_power, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
// Display pins
|
||||
furi_hal_gpio_write(&gpio_display_rst_n, 1);
|
||||
furi_hal_gpio_init_simple(&gpio_display_rst_n, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
// Pullup display reset pin for shutdown
|
||||
SET_BIT(PWR->PUCRB, gpio_display_rst_n.pin);
|
||||
CLEAR_BIT(PWR->PDCRB, gpio_display_rst_n.pin);
|
||||
SET_BIT(PWR->CR3, PWR_CR3_APC);
|
||||
|
||||
// Hard reset USB
|
||||
furi_hal_gpio_write(&gpio_usb_dm, 1);
|
||||
furi_hal_gpio_write(&gpio_usb_dp, 1);
|
||||
furi_hal_gpio_init_simple(&gpio_usb_dm, GpioModeOutputOpenDrain);
|
||||
furi_hal_gpio_init_simple(&gpio_usb_dp, GpioModeOutputOpenDrain);
|
||||
furi_hal_gpio_write(&gpio_usb_dm, 0);
|
||||
furi_hal_gpio_write(&gpio_usb_dp, 0);
|
||||
furi_delay_us(5); // Device Driven disconnect: 2.5us + extra to compensate cables
|
||||
furi_hal_gpio_write(&gpio_usb_dm, 1);
|
||||
furi_hal_gpio_write(&gpio_usb_dp, 1);
|
||||
furi_hal_gpio_init_simple(&gpio_usb_dm, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(&gpio_usb_dp, GpioModeAnalog);
|
||||
furi_hal_gpio_write(&gpio_usb_dm, 0);
|
||||
furi_hal_gpio_write(&gpio_usb_dp, 0);
|
||||
|
||||
// External header pins
|
||||
furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pc1, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pc3, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pb2, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pb3, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pa4, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pa6, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(&gpio_ext_pa7, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
void furi_hal_resources_deinit_early() {
|
||||
furi_hal_resources_init_input_pins(GpioModeAnalog);
|
||||
}
|
||||
|
||||
void furi_hal_resources_init() {
|
||||
// Button pins
|
||||
furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall);
|
||||
|
||||
// Display pins
|
||||
furi_hal_gpio_init(&gpio_display_rst_n, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_write(&gpio_display_rst_n, 0);
|
||||
|
||||
furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_write(&gpio_display_di, 0);
|
||||
|
||||
// SD pins
|
||||
furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_write(&gpio_sdcard_cd, 0);
|
||||
|
||||
furi_hal_gpio_init(&vibro_gpio, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
furi_hal_gpio_init(&ibutton_gpio, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
NVIC_SetPriority(EXTI0_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI0_IRQn);
|
||||
|
||||
NVIC_SetPriority(EXTI1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI1_IRQn);
|
||||
|
||||
NVIC_SetPriority(EXTI2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI2_IRQn);
|
||||
|
||||
NVIC_SetPriority(EXTI3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI3_IRQn);
|
||||
|
||||
NVIC_SetPriority(EXTI4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI4_IRQn);
|
||||
|
||||
NVIC_SetPriority(EXTI9_5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI9_5_IRQn);
|
||||
|
||||
NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(EXTI15_10_IRQn);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include <stm32wbxx.h>
|
||||
#include <stm32wbxx_ll_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Input Related Constants */
|
||||
#define INPUT_DEBOUNCE_TICKS 4
|
||||
|
||||
/* Input Keys */
|
||||
typedef enum {
|
||||
InputKeyUp,
|
||||
InputKeyDown,
|
||||
InputKeyRight,
|
||||
InputKeyLeft,
|
||||
InputKeyOk,
|
||||
InputKeyBack,
|
||||
InputKeyMAX, /**< Special value */
|
||||
} InputKey;
|
||||
|
||||
/* Light */
|
||||
typedef enum {
|
||||
LightRed = (1 << 0),
|
||||
LightGreen = (1 << 1),
|
||||
LightBlue = (1 << 2),
|
||||
LightBacklight = (1 << 3),
|
||||
} Light;
|
||||
|
||||
typedef struct {
|
||||
const GpioPin* gpio;
|
||||
const InputKey key;
|
||||
const bool inverted;
|
||||
const char* name;
|
||||
} InputPin;
|
||||
|
||||
typedef struct {
|
||||
const GpioPin* pin;
|
||||
const char* name;
|
||||
const bool debug;
|
||||
} GpioPinRecord;
|
||||
|
||||
extern const InputPin input_pins[];
|
||||
extern const size_t input_pins_count;
|
||||
|
||||
extern const GpioPinRecord gpio_pins[];
|
||||
extern const size_t gpio_pins_count;
|
||||
|
||||
extern const GpioPin vibro_gpio;
|
||||
extern const GpioPin ibutton_gpio;
|
||||
|
||||
extern const GpioPin gpio_display_cs;
|
||||
extern const GpioPin gpio_display_rst_n;
|
||||
extern const GpioPin gpio_display_di;
|
||||
extern const GpioPin gpio_sdcard_cs;
|
||||
extern const GpioPin gpio_sdcard_cd;
|
||||
|
||||
extern const GpioPin gpio_button_up;
|
||||
extern const GpioPin gpio_button_down;
|
||||
extern const GpioPin gpio_button_right;
|
||||
extern const GpioPin gpio_button_left;
|
||||
extern const GpioPin gpio_button_ok;
|
||||
extern const GpioPin gpio_button_back;
|
||||
|
||||
extern const GpioPin gpio_spi_d_miso;
|
||||
extern const GpioPin gpio_spi_d_mosi;
|
||||
extern const GpioPin gpio_spi_d_sck;
|
||||
|
||||
extern const GpioPin gpio_ext_pc0;
|
||||
extern const GpioPin gpio_ext_pc1;
|
||||
extern const GpioPin gpio_ext_pc3;
|
||||
extern const GpioPin gpio_ext_pb2;
|
||||
extern const GpioPin gpio_ext_pb3;
|
||||
extern const GpioPin gpio_ext_pa4;
|
||||
extern const GpioPin gpio_ext_pa6;
|
||||
extern const GpioPin gpio_ext_pa7;
|
||||
|
||||
extern const GpioPin gpio_ext_pc5;
|
||||
extern const GpioPin gpio_ext_pc4;
|
||||
extern const GpioPin gpio_ext_pa5;
|
||||
extern const GpioPin gpio_ext_pb9;
|
||||
extern const GpioPin gpio_ext_pa0;
|
||||
extern const GpioPin gpio_ext_pa1;
|
||||
extern const GpioPin gpio_ext_pa15;
|
||||
extern const GpioPin gpio_ext_pe4;
|
||||
extern const GpioPin gpio_ext_pa2;
|
||||
extern const GpioPin gpio_ext_pb4;
|
||||
extern const GpioPin gpio_ext_pb5;
|
||||
extern const GpioPin gpio_ext_pd0;
|
||||
extern const GpioPin gpio_ext_pb13;
|
||||
|
||||
extern const GpioPin gpio_usart_tx;
|
||||
extern const GpioPin gpio_usart_rx;
|
||||
extern const GpioPin gpio_i2c_power_sda;
|
||||
extern const GpioPin gpio_i2c_power_scl;
|
||||
|
||||
extern const GpioPin gpio_speaker;
|
||||
|
||||
extern const GpioPin periph_power;
|
||||
|
||||
extern const GpioPin gpio_usb_dm;
|
||||
extern const GpioPin gpio_usb_dp;
|
||||
|
||||
void furi_hal_resources_init_early();
|
||||
|
||||
void furi_hal_resources_deinit_early();
|
||||
|
||||
void furi_hal_resources_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,377 @@
|
||||
#include <furi_hal_spi_config.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalSpiConfig"
|
||||
|
||||
/* SPI Presets */
|
||||
|
||||
const LL_SPI_InitTypeDef furi_hal_spi_preset_2edge_low_8m = {
|
||||
.Mode = LL_SPI_MODE_MASTER,
|
||||
.TransferDirection = LL_SPI_FULL_DUPLEX,
|
||||
.DataWidth = LL_SPI_DATAWIDTH_8BIT,
|
||||
.ClockPolarity = LL_SPI_POLARITY_LOW,
|
||||
.ClockPhase = LL_SPI_PHASE_2EDGE,
|
||||
.NSS = LL_SPI_NSS_SOFT,
|
||||
.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV8,
|
||||
.BitOrder = LL_SPI_MSB_FIRST,
|
||||
.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE,
|
||||
.CRCPoly = 7,
|
||||
};
|
||||
|
||||
const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_8m = {
|
||||
.Mode = LL_SPI_MODE_MASTER,
|
||||
.TransferDirection = LL_SPI_FULL_DUPLEX,
|
||||
.DataWidth = LL_SPI_DATAWIDTH_8BIT,
|
||||
.ClockPolarity = LL_SPI_POLARITY_LOW,
|
||||
.ClockPhase = LL_SPI_PHASE_1EDGE,
|
||||
.NSS = LL_SPI_NSS_SOFT,
|
||||
.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV8,
|
||||
.BitOrder = LL_SPI_MSB_FIRST,
|
||||
.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE,
|
||||
.CRCPoly = 7,
|
||||
};
|
||||
|
||||
const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_4m = {
|
||||
.Mode = LL_SPI_MODE_MASTER,
|
||||
.TransferDirection = LL_SPI_FULL_DUPLEX,
|
||||
.DataWidth = LL_SPI_DATAWIDTH_8BIT,
|
||||
.ClockPolarity = LL_SPI_POLARITY_LOW,
|
||||
.ClockPhase = LL_SPI_PHASE_1EDGE,
|
||||
.NSS = LL_SPI_NSS_SOFT,
|
||||
.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV16,
|
||||
.BitOrder = LL_SPI_MSB_FIRST,
|
||||
.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE,
|
||||
.CRCPoly = 7,
|
||||
};
|
||||
|
||||
const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_16m = {
|
||||
.Mode = LL_SPI_MODE_MASTER,
|
||||
.TransferDirection = LL_SPI_FULL_DUPLEX,
|
||||
.DataWidth = LL_SPI_DATAWIDTH_8BIT,
|
||||
.ClockPolarity = LL_SPI_POLARITY_LOW,
|
||||
.ClockPhase = LL_SPI_PHASE_1EDGE,
|
||||
.NSS = LL_SPI_NSS_SOFT,
|
||||
.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2,
|
||||
.BitOrder = LL_SPI_MSB_FIRST,
|
||||
.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE,
|
||||
.CRCPoly = 7,
|
||||
};
|
||||
|
||||
const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_2m = {
|
||||
.Mode = LL_SPI_MODE_MASTER,
|
||||
.TransferDirection = LL_SPI_FULL_DUPLEX,
|
||||
.DataWidth = LL_SPI_DATAWIDTH_8BIT,
|
||||
.ClockPolarity = LL_SPI_POLARITY_LOW,
|
||||
.ClockPhase = LL_SPI_PHASE_1EDGE,
|
||||
.NSS = LL_SPI_NSS_SOFT,
|
||||
.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32,
|
||||
.BitOrder = LL_SPI_MSB_FIRST,
|
||||
.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE,
|
||||
.CRCPoly = 7,
|
||||
};
|
||||
|
||||
/* SPI Buses */
|
||||
|
||||
FuriMutex* furi_hal_spi_bus_r_mutex = NULL;
|
||||
|
||||
void furi_hal_spi_config_init_early() {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_d);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_display);
|
||||
}
|
||||
|
||||
void furi_hal_spi_config_deinit_early() {
|
||||
furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_display);
|
||||
furi_hal_spi_bus_deinit(&furi_hal_spi_bus_d);
|
||||
}
|
||||
|
||||
void furi_hal_spi_config_init() {
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_fast);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_slow);
|
||||
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
static void furi_hal_spi_bus_r_event_callback(FuriHalSpiBus* bus, FuriHalSpiBusEvent event) {
|
||||
if(event == FuriHalSpiBusEventInit) {
|
||||
furi_hal_spi_bus_r_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_SPI1);
|
||||
FURI_CRITICAL_EXIT();
|
||||
bus->current_handle = NULL;
|
||||
} else if(event == FuriHalSpiBusEventDeinit) {
|
||||
furi_mutex_free(furi_hal_spi_bus_r_mutex);
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_SPI1);
|
||||
LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_SPI1);
|
||||
FURI_CRITICAL_EXIT();
|
||||
} else if(event == FuriHalSpiBusEventLock) {
|
||||
furi_check(furi_mutex_acquire(furi_hal_spi_bus_r_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
} else if(event == FuriHalSpiBusEventUnlock) {
|
||||
furi_check(furi_mutex_release(furi_hal_spi_bus_r_mutex) == FuriStatusOk);
|
||||
} else if(event == FuriHalSpiBusEventActivate) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_SPI1);
|
||||
FURI_CRITICAL_EXIT();
|
||||
} else if(event == FuriHalSpiBusEventDeactivate) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_SPI1);
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
}
|
||||
|
||||
FuriHalSpiBus furi_hal_spi_bus_r = {
|
||||
.spi = SPI1,
|
||||
.callback = furi_hal_spi_bus_r_event_callback,
|
||||
};
|
||||
|
||||
FuriMutex* furi_hal_spi_bus_d_mutex = NULL;
|
||||
|
||||
static void furi_hal_spi_bus_d_event_callback(FuriHalSpiBus* bus, FuriHalSpiBusEvent event) {
|
||||
if(event == FuriHalSpiBusEventInit) {
|
||||
furi_hal_spi_bus_d_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_SPI2);
|
||||
FURI_CRITICAL_EXIT();
|
||||
bus->current_handle = NULL;
|
||||
} else if(event == FuriHalSpiBusEventDeinit) {
|
||||
furi_mutex_free(furi_hal_spi_bus_d_mutex);
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_SPI2);
|
||||
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_SPI2);
|
||||
FURI_CRITICAL_EXIT();
|
||||
} else if(event == FuriHalSpiBusEventLock) {
|
||||
furi_check(furi_mutex_acquire(furi_hal_spi_bus_d_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
} else if(event == FuriHalSpiBusEventUnlock) {
|
||||
furi_check(furi_mutex_release(furi_hal_spi_bus_d_mutex) == FuriStatusOk);
|
||||
} else if(event == FuriHalSpiBusEventActivate) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_SPI2);
|
||||
FURI_CRITICAL_EXIT();
|
||||
} else if(event == FuriHalSpiBusEventDeactivate) {
|
||||
FURI_CRITICAL_ENTER();
|
||||
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_SPI2);
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
}
|
||||
|
||||
FuriHalSpiBus furi_hal_spi_bus_d = {
|
||||
.spi = SPI2,
|
||||
.callback = furi_hal_spi_bus_d_event_callback,
|
||||
};
|
||||
|
||||
/* SPI Bus Handles */
|
||||
|
||||
inline static void furi_hal_spi_bus_r_handle_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event,
|
||||
const LL_SPI_InitTypeDef* preset) {
|
||||
if(event == FuriHalSpiBusHandleEventInit) {
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
furi_hal_gpio_init(handle->cs, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
} else if(event == FuriHalSpiBusHandleEventDeinit) {
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
furi_hal_gpio_init(handle->cs, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
} else if(event == FuriHalSpiBusHandleEventActivate) {
|
||||
LL_SPI_Init(handle->bus->spi, (LL_SPI_InitTypeDef*)preset);
|
||||
LL_SPI_SetRxFIFOThreshold(handle->bus->spi, LL_SPI_RX_FIFO_TH_QUARTER);
|
||||
LL_SPI_Enable(handle->bus->spi);
|
||||
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->miso,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->mosi,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->sck,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
} else if(event == FuriHalSpiBusHandleEventDeactivate) {
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
|
||||
furi_hal_gpio_init(handle->miso, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(handle->mosi, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(handle->sck, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
LL_SPI_Disable(handle->bus->spi);
|
||||
}
|
||||
}
|
||||
|
||||
inline static void furi_hal_spi_bus_nfc_handle_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event,
|
||||
const LL_SPI_InitTypeDef* preset) {
|
||||
if(event == FuriHalSpiBusHandleEventInit) {
|
||||
// Configure GPIOs in normal SPI mode
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->miso,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->mosi,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->sck,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
furi_hal_gpio_init(handle->cs, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
} else if(event == FuriHalSpiBusHandleEventDeinit) {
|
||||
// Configure GPIOs for st25r3916 Transparent mode
|
||||
furi_hal_gpio_init(handle->sck, GpioModeInput, GpioPullUp, GpioSpeedLow);
|
||||
furi_hal_gpio_init(handle->miso, GpioModeInput, GpioPullUp, GpioSpeedLow);
|
||||
furi_hal_gpio_init(handle->cs, GpioModeInput, GpioPullUp, GpioSpeedLow);
|
||||
furi_hal_gpio_write(handle->mosi, false);
|
||||
furi_hal_gpio_init(handle->mosi, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
} else if(event == FuriHalSpiBusHandleEventActivate) {
|
||||
LL_SPI_Init(handle->bus->spi, (LL_SPI_InitTypeDef*)preset);
|
||||
LL_SPI_SetRxFIFOThreshold(handle->bus->spi, LL_SPI_RX_FIFO_TH_QUARTER);
|
||||
LL_SPI_Enable(handle->bus->spi);
|
||||
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->miso,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->mosi,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->sck,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI1);
|
||||
|
||||
} else if(event == FuriHalSpiBusHandleEventDeactivate) {
|
||||
furi_hal_gpio_init(handle->miso, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(handle->mosi, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_init(handle->sck, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
LL_SPI_Disable(handle->bus->spi);
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_spi_bus_handle_external_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event) {
|
||||
furi_hal_spi_bus_r_handle_event_callback(handle, event, &furi_hal_spi_preset_1edge_low_2m);
|
||||
}
|
||||
|
||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_external = {
|
||||
.bus = &furi_hal_spi_bus_r,
|
||||
.callback = furi_hal_spi_bus_handle_external_event_callback,
|
||||
.miso = &gpio_ext_pa6,
|
||||
.mosi = &gpio_ext_pa7,
|
||||
.sck = &gpio_ext_pb3,
|
||||
.cs = &gpio_ext_pa4,
|
||||
};
|
||||
|
||||
inline static void furi_hal_spi_bus_d_handle_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event,
|
||||
const LL_SPI_InitTypeDef* preset) {
|
||||
if(event == FuriHalSpiBusHandleEventInit) {
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
furi_hal_gpio_init(handle->cs, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
|
||||
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->miso,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI2);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->mosi,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI2);
|
||||
furi_hal_gpio_init_ex(
|
||||
handle->sck,
|
||||
GpioModeAltFunctionPushPull,
|
||||
GpioPullNo,
|
||||
GpioSpeedVeryHigh,
|
||||
GpioAltFn5SPI2);
|
||||
|
||||
} else if(event == FuriHalSpiBusHandleEventDeinit) {
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
furi_hal_gpio_init(handle->cs, GpioModeAnalog, GpioPullUp, GpioSpeedLow);
|
||||
} else if(event == FuriHalSpiBusHandleEventActivate) {
|
||||
LL_SPI_Init(handle->bus->spi, (LL_SPI_InitTypeDef*)preset);
|
||||
LL_SPI_SetRxFIFOThreshold(handle->bus->spi, LL_SPI_RX_FIFO_TH_QUARTER);
|
||||
LL_SPI_Enable(handle->bus->spi);
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
} else if(event == FuriHalSpiBusHandleEventDeactivate) {
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
LL_SPI_Disable(handle->bus->spi);
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_spi_bus_handle_display_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event) {
|
||||
furi_hal_spi_bus_d_handle_event_callback(handle, event, &furi_hal_spi_preset_1edge_low_4m);
|
||||
}
|
||||
|
||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_display = {
|
||||
.bus = &furi_hal_spi_bus_d,
|
||||
.callback = furi_hal_spi_bus_handle_display_event_callback,
|
||||
.miso = &gpio_spi_d_miso,
|
||||
.mosi = &gpio_spi_d_mosi,
|
||||
.sck = &gpio_spi_d_sck,
|
||||
.cs = &gpio_display_cs,
|
||||
};
|
||||
|
||||
static void furi_hal_spi_bus_handle_sd_fast_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event) {
|
||||
furi_hal_spi_bus_d_handle_event_callback(handle, event, &furi_hal_spi_preset_1edge_low_16m);
|
||||
}
|
||||
|
||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_sd_fast = {
|
||||
.bus = &furi_hal_spi_bus_d,
|
||||
.callback = furi_hal_spi_bus_handle_sd_fast_event_callback,
|
||||
.miso = &gpio_spi_d_miso,
|
||||
.mosi = &gpio_spi_d_mosi,
|
||||
.sck = &gpio_spi_d_sck,
|
||||
.cs = &gpio_sdcard_cs,
|
||||
};
|
||||
|
||||
static void furi_hal_spi_bus_handle_sd_slow_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event) {
|
||||
furi_hal_spi_bus_d_handle_event_callback(handle, event, &furi_hal_spi_preset_1edge_low_2m);
|
||||
}
|
||||
|
||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_sd_slow = {
|
||||
.bus = &furi_hal_spi_bus_d,
|
||||
.callback = furi_hal_spi_bus_handle_sd_slow_event_callback,
|
||||
.miso = &gpio_spi_d_miso,
|
||||
.mosi = &gpio_spi_d_mosi,
|
||||
.sck = &gpio_spi_d_sck,
|
||||
.cs = &gpio_sdcard_cs,
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal_spi_types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Preset for ST25R916 */
|
||||
extern const LL_SPI_InitTypeDef furi_hal_spi_preset_2edge_low_8m;
|
||||
|
||||
/** Preset for CC1101 */
|
||||
extern const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_8m;
|
||||
|
||||
/** Preset for ST7567 (Display) */
|
||||
extern const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_4m;
|
||||
|
||||
/** Preset for SdCard in fast mode */
|
||||
extern const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_16m;
|
||||
|
||||
/** Preset for SdCard in slow mode */
|
||||
extern const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_2m;
|
||||
|
||||
/** Furi Hal Spi Bus R (External) */
|
||||
extern FuriHalSpiBus furi_hal_spi_bus_r;
|
||||
|
||||
/** Furi Hal Spi Bus D (Display, SdCard) */
|
||||
extern FuriHalSpiBus furi_hal_spi_bus_d;
|
||||
|
||||
/** External on `furi_hal_spi_bus_r`
|
||||
* Preset: `furi_hal_spi_preset_1edge_low_2m`
|
||||
*
|
||||
* miso: pa6
|
||||
* mosi: pa7
|
||||
* sck: pb3
|
||||
* cs: pa4 (software controlled)
|
||||
*
|
||||
* @warning not initialized by default, call `furi_hal_spi_bus_handle_init` to initialize
|
||||
* Bus pins are floating on inactive state, CS high after initialization
|
||||
*
|
||||
*/
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_external;
|
||||
|
||||
/** ST7567(Display) on `furi_hal_spi_bus_d` */
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_display;
|
||||
|
||||
/** SdCard in fast mode on `furi_hal_spi_bus_d` */
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_sd_fast;
|
||||
|
||||
/** SdCard in slow mode on `furi_hal_spi_bus_d` */
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_sd_slow;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
bool furi_hal_version_do_i_belong_here() {
|
||||
return (furi_hal_version_get_hw_target() == 18) || (furi_hal_version_get_hw_target() == 0);
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_name() {
|
||||
return "Komi";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_code() {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_fcc_id() {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_ic_id() {
|
||||
return "N/A";
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"inherit": "7",
|
||||
"include_paths": [
|
||||
"furi_hal"
|
||||
],
|
||||
"sdk_header_paths": [
|
||||
"../furi_hal_include",
|
||||
"furi_hal",
|
||||
"platform_specific"
|
||||
],
|
||||
"sdk_symbols": "api_symbols.csv",
|
||||
"linker_dependencies": [
|
||||
"print",
|
||||
"flipper18",
|
||||
"furi",
|
||||
"freertos",
|
||||
"stm32cubewb",
|
||||
"hwdrivers",
|
||||
"fatfs",
|
||||
"littlefs",
|
||||
"flipperformat",
|
||||
"toolbox",
|
||||
"microtar",
|
||||
"usb_stm32",
|
||||
"appframe",
|
||||
"assets",
|
||||
"misc",
|
||||
"flipper_application",
|
||||
"flipperformat",
|
||||
"toolbox",
|
||||
"flipper18"
|
||||
],
|
||||
"excluded_sources": [
|
||||
"furi_hal_infrared.c",
|
||||
"furi_hal_nfc.c",
|
||||
"furi_hal_rfid.c",
|
||||
"furi_hal_subghz.c"
|
||||
],
|
||||
"excluded_headers": [
|
||||
"furi_hal_infrared.h",
|
||||
"furi_hal_nfc.h",
|
||||
"furi_hal_rfid.h",
|
||||
"furi_hal_subghz.h",
|
||||
"furi_hal_ibutton.h",
|
||||
"furi_hal_subghz_configs.h"
|
||||
],
|
||||
"excluded_modules": [
|
||||
"one_wire",
|
||||
"nfc",
|
||||
"lfrfid",
|
||||
"subghz",
|
||||
"infrared",
|
||||
"st25rfal002"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,11.10,,
|
||||
Version,+,12.1,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@@ -41,14 +41,19 @@ Header,+,firmware/targets/f7/furi_hal/furi_hal_flash.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_gpio.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_i2c_config.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_i2c_types.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_ibutton.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_idle_timer.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_interrupt.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_nfc.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_os.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_pwm.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_resources.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_rfid.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_spi_config.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_spi_types.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_subghz.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_subghz_configs.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_target_hw.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_uart.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_usb_cdc.h,,
|
||||
Header,+,firmware/targets/f7/platform_specific/intrinsic_export.h,,
|
||||
@@ -61,22 +66,18 @@ Header,+,firmware/targets/furi_hal_include/furi_hal_cortex.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_crypto.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_debug.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_i2c.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_ibutton.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_info.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_infrared.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_light.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_memory.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_mpu.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_nfc.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_power.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_random.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_region.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_rfid.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_rtc.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_sd.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_speaker.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_spi.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_subghz.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_usb.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid.h,,
|
||||
Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h,,
|
||||
@@ -150,6 +151,16 @@ Header,+,lib/libusb_stm32/inc/usbd_core.h,,
|
||||
Header,+,lib/mbedtls/include/mbedtls/des.h,,
|
||||
Header,+,lib/mbedtls/include/mbedtls/sha1.h,,
|
||||
Header,+,lib/micro-ecc/uECC.h,,
|
||||
Header,+,lib/mlib/m-algo.h,,
|
||||
Header,+,lib/mlib/m-array.h,,
|
||||
Header,+,lib/mlib/m-bptree.h,,
|
||||
Header,+,lib/mlib/m-core.h,,
|
||||
Header,+,lib/mlib/m-deque.h,,
|
||||
Header,+,lib/mlib/m-dict.h,,
|
||||
Header,+,lib/mlib/m-list.h,,
|
||||
Header,+,lib/mlib/m-rbtree.h,,
|
||||
Header,+,lib/mlib/m-tuple.h,,
|
||||
Header,+,lib/mlib/m-variant.h,,
|
||||
Header,+,lib/nfc/nfc_device.h,,
|
||||
Header,+,lib/one_wire/ibutton/ibutton_worker.h,,
|
||||
Header,+,lib/one_wire/maxim_crc.h,,
|
||||
@@ -852,6 +863,7 @@ Function,+,flipper_application_free,void,FlipperApplication*
|
||||
Function,+,flipper_application_get_manifest,const FlipperApplicationManifest*,FlipperApplication*
|
||||
Function,+,flipper_application_load_status_to_string,const char*,FlipperApplicationLoadStatus
|
||||
Function,+,flipper_application_manifest_is_compatible,_Bool,"const FlipperApplicationManifest*, const ElfApiInterface*"
|
||||
Function,+,flipper_application_manifest_is_target_compatible,_Bool,const FlipperApplicationManifest*
|
||||
Function,+,flipper_application_manifest_is_valid,_Bool,const FlipperApplicationManifest*
|
||||
Function,+,flipper_application_map_to_memory,FlipperApplicationLoadStatus,FlipperApplication*
|
||||
Function,+,flipper_application_preload,FlipperApplicationPreloadStatus,"FlipperApplication*, const char*"
|
||||
@@ -1022,7 +1034,7 @@ Function,+,furi_hal_cdc_get_port_settings,usb_cdc_line_coding*,uint8_t
|
||||
Function,+,furi_hal_cdc_receive,int32_t,"uint8_t, uint8_t*, uint16_t"
|
||||
Function,+,furi_hal_cdc_send,void,"uint8_t, uint8_t*, uint16_t"
|
||||
Function,+,furi_hal_cdc_set_callbacks,void,"uint8_t, CdcCallbacks*, void*"
|
||||
Function,+,furi_hal_clock_deinit_early,void,
|
||||
Function,-,furi_hal_clock_deinit_early,void,
|
||||
Function,-,furi_hal_clock_init,void,
|
||||
Function,-,furi_hal_clock_init_early,void,
|
||||
Function,+,furi_hal_clock_mco_disable,void,
|
||||
@@ -1103,7 +1115,7 @@ Function,+,furi_hal_hid_u2f_is_connected,_Bool,
|
||||
Function,+,furi_hal_hid_u2f_send_response,void,"uint8_t*, uint8_t"
|
||||
Function,+,furi_hal_hid_u2f_set_callback,void,"HidU2fCallback, void*"
|
||||
Function,+,furi_hal_i2c_acquire,void,FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_deinit_early,void,
|
||||
Function,-,furi_hal_i2c_deinit_early,void,
|
||||
Function,-,furi_hal_i2c_init,void,
|
||||
Function,-,furi_hal_i2c_init_early,void,
|
||||
Function,+,furi_hal_i2c_is_device_ready,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint32_t"
|
||||
@@ -1241,7 +1253,7 @@ Function,-,furi_hal_region_init,void,
|
||||
Function,+,furi_hal_region_is_frequency_allowed,_Bool,uint32_t
|
||||
Function,+,furi_hal_region_is_provisioned,_Bool,
|
||||
Function,+,furi_hal_region_set,void,FuriHalRegion*
|
||||
Function,+,furi_hal_resources_deinit_early,void,
|
||||
Function,-,furi_hal_resources_deinit_early,void,
|
||||
Function,-,furi_hal_resources_init,void,
|
||||
Function,-,furi_hal_resources_init_early,void,
|
||||
Function,+,furi_hal_rfid_change_read_config,void,"float, float"
|
||||
@@ -1270,7 +1282,7 @@ Function,+,furi_hal_rfid_tim_read_start,void,
|
||||
Function,+,furi_hal_rfid_tim_read_stop,void,
|
||||
Function,+,furi_hal_rfid_tim_reset,void,
|
||||
Function,+,furi_hal_rtc_datetime_to_timestamp,uint32_t,FuriHalRtcDateTime*
|
||||
Function,+,furi_hal_rtc_deinit_early,void,
|
||||
Function,-,furi_hal_rtc_deinit_early,void,
|
||||
Function,+,furi_hal_rtc_get_boot_mode,FuriHalRtcBootMode,
|
||||
Function,+,furi_hal_rtc_get_datetime,void,FuriHalRtcDateTime*
|
||||
Function,+,furi_hal_rtc_get_fault_data,uint32_t,
|
||||
@@ -1314,9 +1326,9 @@ Function,+,furi_hal_spi_bus_init,void,FuriHalSpiBus*
|
||||
Function,+,furi_hal_spi_bus_rx,_Bool,"FuriHalSpiBusHandle*, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_spi_bus_trx,_Bool,"FuriHalSpiBusHandle*, uint8_t*, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_spi_bus_tx,_Bool,"FuriHalSpiBusHandle*, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_spi_deinit_early,void,
|
||||
Function,-,furi_hal_spi_init,void,
|
||||
Function,+,furi_hal_spi_init_early,void,
|
||||
Function,-,furi_hal_spi_config_deinit_early,void,
|
||||
Function,-,furi_hal_spi_config_init,void,
|
||||
Function,-,furi_hal_spi_config_init_early,void,
|
||||
Function,+,furi_hal_spi_release,void,FuriHalSpiBusHandle*
|
||||
Function,-,furi_hal_subghz_dump_state,void,
|
||||
Function,+,furi_hal_subghz_flush_rx,void,
|
||||
@@ -1370,6 +1382,7 @@ Function,+,furi_hal_version_do_i_belong_here,_Bool,
|
||||
Function,+,furi_hal_version_get_ble_local_device_name_ptr,const char*,
|
||||
Function,+,furi_hal_version_get_ble_mac,const uint8_t*,
|
||||
Function,+,furi_hal_version_get_device_name_ptr,const char*,
|
||||
Function,+,furi_hal_version_get_fcc_id,const char*,
|
||||
Function,+,furi_hal_version_get_firmware_version,const Version*,
|
||||
Function,+,furi_hal_version_get_hw_body,uint8_t,
|
||||
Function,+,furi_hal_version_get_hw_color,FuriHalVersionColor,
|
||||
@@ -1380,6 +1393,8 @@ Function,+,furi_hal_version_get_hw_region_name,const char*,
|
||||
Function,+,furi_hal_version_get_hw_target,uint8_t,
|
||||
Function,+,furi_hal_version_get_hw_timestamp,uint32_t,
|
||||
Function,+,furi_hal_version_get_hw_version,uint8_t,
|
||||
Function,+,furi_hal_version_get_ic_id,const char*,
|
||||
Function,+,furi_hal_version_get_model_code,const char*,
|
||||
Function,+,furi_hal_version_get_model_name,const char*,
|
||||
Function,+,furi_hal_version_get_name_ptr,const char*,
|
||||
Function,+,furi_hal_version_get_otp_version,FuriHalVersionOtpVersion,
|
||||
@@ -3026,6 +3041,8 @@ Variable,+,gpio_infrared_rx,const GpioPin,
|
||||
Variable,+,gpio_infrared_tx,const GpioPin,
|
||||
Variable,+,gpio_nfc_cs,const GpioPin,
|
||||
Variable,+,gpio_nfc_irq_rfid_pull,const GpioPin,
|
||||
Variable,+,gpio_pins,const GpioPinRecord[],
|
||||
Variable,+,gpio_pins_count,const size_t,
|
||||
Variable,+,gpio_rf_sw_0,const GpioPin,
|
||||
Variable,+,gpio_rfid_carrier,const GpioPin,
|
||||
Variable,+,gpio_rfid_carrier_out,const GpioPin,
|
||||
|
||||
|
@@ -17,7 +17,7 @@ void furi_hal_init_early() {
|
||||
|
||||
furi_hal_os_init();
|
||||
|
||||
furi_hal_spi_init_early();
|
||||
furi_hal_spi_config_init_early();
|
||||
|
||||
furi_hal_i2c_init_early();
|
||||
furi_hal_light_init();
|
||||
@@ -29,7 +29,7 @@ void furi_hal_deinit_early() {
|
||||
furi_hal_rtc_deinit_early();
|
||||
|
||||
furi_hal_i2c_deinit_early();
|
||||
furi_hal_spi_deinit_early();
|
||||
furi_hal_spi_config_deinit_early();
|
||||
|
||||
furi_hal_resources_deinit_early();
|
||||
|
||||
@@ -52,7 +52,7 @@ void furi_hal_init() {
|
||||
furi_hal_version_init();
|
||||
furi_hal_region_init();
|
||||
|
||||
furi_hal_spi_init();
|
||||
furi_hal_spi_config_init();
|
||||
|
||||
furi_hal_ibutton_init();
|
||||
FURI_LOG_I(TAG, "iButton OK");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "furi_hal_bt_hid.h"
|
||||
#include "furi_hal_usb_hid.h"
|
||||
#include <furi_hal_bt_hid.h>
|
||||
#include <furi_hal_usb_hid.h>
|
||||
#include "usb_hid.h"
|
||||
#include "dev_info_service.h"
|
||||
#include "battery_service.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "furi_hal_bt_serial.h"
|
||||
#include <furi_hal_bt_serial.h>
|
||||
#include "dev_info_service.h"
|
||||
#include "battery_service.h"
|
||||
#include "serial_service.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "furi_hal_cortex.h"
|
||||
#include <furi_hal_cortex.h>
|
||||
|
||||
#include <stm32wbxx.h>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "furi_hal_i2c_config.h"
|
||||
#include <furi_hal_i2c_config.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi_hal_version.h>
|
||||
#include <stm32wbxx_ll_bus.h>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "furi_hal_gpio.h"
|
||||
#include <furi_hal_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "furi_hal_infrared.h"
|
||||
#include <furi_hal_infrared.h>
|
||||
#include <core/check.h>
|
||||
#include "stm32wbxx_ll_dma.h"
|
||||
#include "sys/_stdint.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "furi_hal_interrupt.h"
|
||||
#include "furi_hal_os.h"
|
||||
#include <furi_hal_interrupt.h>
|
||||
#include <furi_hal_os.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <core/common_defines.h>
|
||||
#include "furi_hal_resources.h"
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi_hal_light.h>
|
||||
#include <lp5562.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <limits.h>
|
||||
#include "furi_hal_nfc.h"
|
||||
#include <furi_hal_nfc.h>
|
||||
#include <st25r3916.h>
|
||||
#include <st25r3916_irq.h>
|
||||
#include <rfal_rf.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "furi_hal_pwm.h"
|
||||
#include <furi_hal_pwm.h>
|
||||
#include <core/check.h>
|
||||
#include <furi_hal_resources.h>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "furi_hal_random.h"
|
||||
#include <furi_hal_random.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
|
||||
@@ -62,6 +62,23 @@ const GpioPin periph_power = {.port = GPIOA, .pin = LL_GPIO_PIN_3};
|
||||
const GpioPin gpio_usb_dm = {.port = GPIOA, .pin = LL_GPIO_PIN_11};
|
||||
const GpioPin gpio_usb_dp = {.port = GPIOA, .pin = LL_GPIO_PIN_12};
|
||||
|
||||
const GpioPinRecord gpio_pins[] = {
|
||||
{.pin = &gpio_ext_pa7, .name = "PA7", .debug = false},
|
||||
{.pin = &gpio_ext_pa6, .name = "PA6", .debug = false},
|
||||
{.pin = &gpio_ext_pa4, .name = "PA4", .debug = false},
|
||||
{.pin = &gpio_ext_pb3, .name = "PB3", .debug = false},
|
||||
{.pin = &gpio_ext_pb2, .name = "PB2", .debug = false},
|
||||
{.pin = &gpio_ext_pc3, .name = "PC3", .debug = false},
|
||||
{.pin = &gpio_ext_pc1, .name = "PC1", .debug = false},
|
||||
{.pin = &gpio_ext_pc0, .name = "PC0", .debug = false},
|
||||
|
||||
/* Dangerous pins, may damage hardware */
|
||||
{.pin = &gpio_usart_rx, .name = "PB7", .debug = true},
|
||||
{.pin = &gpio_speaker, .name = "PB8", .debug = true},
|
||||
};
|
||||
|
||||
const size_t gpio_pins_count = sizeof(gpio_pins) / sizeof(GpioPinRecord);
|
||||
|
||||
const InputPin input_pins[] = {
|
||||
{.gpio = &gpio_button_up, .key = InputKeyUp, .inverted = true, .name = "Up"},
|
||||
{.gpio = &gpio_button_down, .key = InputKeyDown, .inverted = true, .name = "Down"},
|
||||
|
||||
@@ -38,9 +38,18 @@ typedef struct {
|
||||
const char* name;
|
||||
} InputPin;
|
||||
|
||||
typedef struct {
|
||||
const GpioPin* pin;
|
||||
const char* name;
|
||||
const bool debug;
|
||||
} GpioPinRecord;
|
||||
|
||||
extern const InputPin input_pins[];
|
||||
extern const size_t input_pins_count;
|
||||
|
||||
extern const GpioPinRecord gpio_pins[];
|
||||
extern const size_t gpio_pins_count;
|
||||
|
||||
extern const GpioPin vibro_gpio;
|
||||
extern const GpioPin ibutton_gpio;
|
||||
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
#include "furi_hal_sd.h"
|
||||
#include <furi_hal_sd.h>
|
||||
#include <stm32wbxx_ll_gpio.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
void hal_sd_detect_init(void) {
|
||||
// low speed input with pullup
|
||||
LL_GPIO_SetPinMode(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_MODE_INPUT);
|
||||
LL_GPIO_SetPinSpeed(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_SPEED_FREQ_LOW);
|
||||
LL_GPIO_SetPinPull(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_PULL_UP);
|
||||
furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullUp, GpioSpeedLow);
|
||||
}
|
||||
|
||||
void hal_sd_detect_set_low(void) {
|
||||
// low speed input with pullup
|
||||
LL_GPIO_SetPinMode(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_MODE_OUTPUT);
|
||||
LL_GPIO_SetPinOutputType(SD_CD_GPIO_Port, SD_CD_Pin, LL_GPIO_OUTPUT_OPENDRAIN);
|
||||
LL_GPIO_ResetOutputPin(SD_CD_GPIO_Port, SD_CD_Pin);
|
||||
furi_hal_gpio_init_simple(&gpio_sdcard_cd, GpioModeOutputOpenDrain);
|
||||
furi_hal_gpio_write(&gpio_sdcard_cd, 0);
|
||||
}
|
||||
|
||||
bool hal_sd_detect(void) {
|
||||
bool result = !(LL_GPIO_IsInputPinSet(SD_CD_GPIO_Port, SD_CD_Pin));
|
||||
bool result = !furi_hal_gpio_read(&gpio_sdcard_cd);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,14 @@
|
||||
#include "furi_hal_spi.h"
|
||||
#include "furi_hal_resources.h"
|
||||
#include <furi_hal_spi.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi_hal_power.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <furi.h>
|
||||
|
||||
#include <stm32wbxx_ll_spi.h>
|
||||
#include <stm32wbxx_ll_utils.h>
|
||||
#include <stm32wbxx_ll_cortex.h>
|
||||
|
||||
#define TAG "FuriHalSpi"
|
||||
|
||||
void furi_hal_spi_init_early() {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_d);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_display);
|
||||
}
|
||||
|
||||
void furi_hal_spi_deinit_early() {
|
||||
furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_display);
|
||||
furi_hal_spi_bus_deinit(&furi_hal_spi_bus_d);
|
||||
}
|
||||
|
||||
void furi_hal_spi_init() {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_r);
|
||||
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_nfc);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_fast);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_slow);
|
||||
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_spi_bus_init(FuriHalSpiBus* bus) {
|
||||
furi_assert(bus);
|
||||
bus->callback(bus, FuriHalSpiBusEventInit);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include <furi_hal_spi_config.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalSpiConfig"
|
||||
|
||||
/* SPI Presets */
|
||||
|
||||
@@ -72,6 +76,27 @@ const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_2m = {
|
||||
|
||||
FuriMutex* furi_hal_spi_bus_r_mutex = NULL;
|
||||
|
||||
void furi_hal_spi_config_init_early() {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_d);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_display);
|
||||
}
|
||||
|
||||
void furi_hal_spi_config_deinit_early() {
|
||||
furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_display);
|
||||
furi_hal_spi_bus_deinit(&furi_hal_spi_bus_d);
|
||||
}
|
||||
|
||||
void furi_hal_spi_config_init() {
|
||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_r);
|
||||
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_subghz);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_nfc);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_fast);
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_slow);
|
||||
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
static void furi_hal_spi_bus_r_event_callback(FuriHalSpiBus* bus, FuriHalSpiBusEvent event) {
|
||||
if(event == FuriHalSpiBusEventInit) {
|
||||
furi_hal_spi_bus_r_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "furi_hal_subghz.h"
|
||||
#include "furi_hal_subghz_configs.h"
|
||||
#include <furi_hal_subghz.h>
|
||||
#include <furi_hal_subghz_configs.h>
|
||||
|
||||
#include <furi_hal_region.h>
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal_subghz.h>
|
||||
#include <furi_hal_ibutton.h>
|
||||
#include <furi_hal_rfid.h>
|
||||
#include <furi_hal_nfc.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "furi_hal_version.h"
|
||||
#include "furi_hal_usb_i.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_usb_i.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <furi_hal_power.h>
|
||||
#include <stm32wbxx_ll_pwr.h>
|
||||
#include <furi.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "furi_hal_version.h"
|
||||
#include "furi_hal_usb_i.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include "furi_hal_usb_cdc.h"
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_usb_i.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <furi_hal_usb_cdc.h>
|
||||
#include <furi.h>
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "furi_hal_version.h"
|
||||
#include "furi_hal_usb_i.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include "furi_hal_usb_hid.h"
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_usb_i.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <furi_hal_usb_hid.h>
|
||||
#include <furi.h>
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "furi_hal_version.h"
|
||||
#include "furi_hal_usb_i.h"
|
||||
#include "furi_hal_usb_hid_u2f.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_usb_i.h>
|
||||
#include <furi_hal_usb_hid_u2f.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <furi.h>
|
||||
#include "usb.h"
|
||||
#include "usb_hid.h"
|
||||
|
||||
@@ -195,14 +195,6 @@ void furi_hal_version_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
bool furi_hal_version_do_i_belong_here() {
|
||||
return furi_hal_version_get_hw_target() == 7;
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_name() {
|
||||
return "Flipper Zero";
|
||||
}
|
||||
|
||||
FuriHalVersionOtpVersion furi_hal_version_get_otp_version() {
|
||||
if(*(uint64_t*)FURI_HAL_VERSION_OTP_ADDRESS == 0xFFFFFFFF) {
|
||||
return FuriHalVersionOtpVersionEmpty;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <furi_hal_version.h>
|
||||
|
||||
bool furi_hal_version_do_i_belong_here() {
|
||||
return (furi_hal_version_get_hw_target() == 7) || (furi_hal_version_get_hw_target() == 0);
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_name() {
|
||||
return "Flipper Zero";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_model_code() {
|
||||
return "FZ.1";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_fcc_id() {
|
||||
return "2A2V6-FZ";
|
||||
}
|
||||
|
||||
const char* furi_hal_version_get_ic_id() {
|
||||
return "27624-FZ";
|
||||
}
|
||||
@@ -51,4 +51,4 @@ void flipper_boot_recovery_exec() {
|
||||
furi_hal_rtc_set_pin_fails(0);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ static bool flipper_update_init() {
|
||||
furi_hal_rtc_init();
|
||||
furi_hal_interrupt_init();
|
||||
|
||||
furi_hal_spi_init();
|
||||
furi_hal_spi_config_init();
|
||||
|
||||
MX_FATFS_Init();
|
||||
if(!hal_sd_detect()) {
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : stm32wb55xx_flash_cm4.ld
|
||||
** File : stm32wb55xx_flash.ld
|
||||
**
|
||||
** Abstract : System Workbench Minimal System calls file
|
||||
**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : stm32wb55xx_flash_cm4.ld
|
||||
** File : stm32wb55xx_ram_fw.ld
|
||||
**
|
||||
** Abstract : System Workbench Minimal System calls file
|
||||
**
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"include_paths": [
|
||||
"ble_glue",
|
||||
"fatfs",
|
||||
"furi_hal",
|
||||
"inc"
|
||||
],
|
||||
"sdk_header_paths": [
|
||||
"../furi_hal_include",
|
||||
"furi_hal",
|
||||
"platform_specific"
|
||||
],
|
||||
"startup_script": "startup_stm32wb55xx_cm4.s",
|
||||
"linker_script_flash": "stm32wb55xx_flash.ld",
|
||||
"linker_script_ram": "stm32wb55xx_ram_fw.ld",
|
||||
"linker_script_app": "application_ext.ld",
|
||||
"sdk_symbols": "api_symbols.csv",
|
||||
"linker_dependencies": [
|
||||
"print",
|
||||
"flipper7",
|
||||
"furi",
|
||||
"freertos",
|
||||
"stm32cubewb",
|
||||
"hwdrivers",
|
||||
"fatfs",
|
||||
"littlefs",
|
||||
"subghz",
|
||||
"flipperformat",
|
||||
"toolbox",
|
||||
"nfc",
|
||||
"microtar",
|
||||
"usb_stm32",
|
||||
"st25rfal002",
|
||||
"infrared",
|
||||
"appframe",
|
||||
"assets",
|
||||
"one_wire",
|
||||
"misc",
|
||||
"mbedtls",
|
||||
"lfrfid",
|
||||
"flipper_application",
|
||||
"flipperformat",
|
||||
"toolbox"
|
||||
]
|
||||
}
|
||||
@@ -10,37 +10,34 @@ template <unsigned int N>
|
||||
struct STOP_EXTERNING_ME {};
|
||||
#endif
|
||||
|
||||
#include "furi_hal_cortex.h"
|
||||
#include "furi_hal_clock.h"
|
||||
#include "furi_hal_crypto.h"
|
||||
#include "furi_hal_console.h"
|
||||
#include "furi_hal_debug.h"
|
||||
#include "furi_hal_os.h"
|
||||
#include "furi_hal_sd.h"
|
||||
#include "furi_hal_i2c.h"
|
||||
#include "furi_hal_resources.h"
|
||||
#include "furi_hal_region.h"
|
||||
#include "furi_hal_rtc.h"
|
||||
#include "furi_hal_speaker.h"
|
||||
#include "furi_hal_gpio.h"
|
||||
#include "furi_hal_light.h"
|
||||
#include "furi_hal_power.h"
|
||||
#include "furi_hal_interrupt.h"
|
||||
#include "furi_hal_version.h"
|
||||
#include "furi_hal_bt.h"
|
||||
#include "furi_hal_spi.h"
|
||||
#include "furi_hal_flash.h"
|
||||
#include "furi_hal_subghz.h"
|
||||
#include "furi_hal_vibro.h"
|
||||
#include "furi_hal_ibutton.h"
|
||||
#include "furi_hal_rfid.h"
|
||||
#include "furi_hal_nfc.h"
|
||||
#include "furi_hal_usb.h"
|
||||
#include "furi_hal_usb_hid.h"
|
||||
#include "furi_hal_compress.h"
|
||||
#include "furi_hal_uart.h"
|
||||
#include "furi_hal_info.h"
|
||||
#include "furi_hal_random.h"
|
||||
#include <furi_hal_cortex.h>
|
||||
#include <furi_hal_clock.h>
|
||||
#include <furi_hal_crypto.h>
|
||||
#include <furi_hal_console.h>
|
||||
#include <furi_hal_debug.h>
|
||||
#include <furi_hal_os.h>
|
||||
#include <furi_hal_sd.h>
|
||||
#include <furi_hal_i2c.h>
|
||||
#include <furi_hal_region.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <furi_hal_speaker.h>
|
||||
#include <furi_hal_gpio.h>
|
||||
#include <furi_hal_light.h>
|
||||
#include <furi_hal_power.h>
|
||||
#include <furi_hal_interrupt.h>
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_bt.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <furi_hal_flash.h>
|
||||
#include <furi_hal_vibro.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <furi_hal_usb_hid.h>
|
||||
#include <furi_hal_compress.h>
|
||||
#include <furi_hal_uart.h>
|
||||
#include <furi_hal_info.h>
|
||||
#include <furi_hal_random.h>
|
||||
#include <furi_hal_target_hw.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <ble_glue.h>
|
||||
#include <ble_app.h>
|
||||
|
||||
#include "furi_hal_bt_serial.h"
|
||||
#include <furi_hal_bt_serial.h>
|
||||
|
||||
#define FURI_HAL_BT_STACK_VERSION_MAJOR (1)
|
||||
#define FURI_HAL_BT_STACK_VERSION_MINOR (12)
|
||||
|
||||
@@ -8,13 +8,13 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** Early initialize SPI HAL */
|
||||
void furi_hal_spi_init_early();
|
||||
void furi_hal_spi_config_init_early();
|
||||
|
||||
/** Early deinitialize SPI HAL */
|
||||
void furi_hal_spi_deinit_early();
|
||||
void furi_hal_spi_config_deinit_early();
|
||||
|
||||
/** Initialize SPI HAL */
|
||||
void furi_hal_spi_init();
|
||||
void furi_hal_spi_config_init();
|
||||
|
||||
/** Initialize SPI Bus
|
||||
*
|
||||
|
||||
@@ -67,6 +67,24 @@ bool furi_hal_version_do_i_belong_here();
|
||||
*/
|
||||
const char* furi_hal_version_get_model_name();
|
||||
|
||||
/** Get model name
|
||||
*
|
||||
* @return model code C-string
|
||||
*/
|
||||
const char* furi_hal_version_get_model_code();
|
||||
|
||||
/** Get FCC ID
|
||||
*
|
||||
* @return FCC id as C-string
|
||||
*/
|
||||
const char* furi_hal_version_get_fcc_id();
|
||||
|
||||
/** Get IC id
|
||||
*
|
||||
* @return IC id as C-string
|
||||
*/
|
||||
const char* furi_hal_version_get_ic_id();
|
||||
|
||||
/** Get OTP version
|
||||
*
|
||||
* @return OTP Version
|
||||
|
||||
Reference in New Issue
Block a user