mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 12:48:35 -07:00
RPC: Add Virtual Display & Unify log tags (#814)
* RPC: Update protobuf sources * RPC: Add Virtual Display * Unify log tags * RPC: Virtual Display placeholder * Rpc: clear frame buffer callback before confirm. * Firmware: full assert for hal, move fatfs initialization to furi hal. * FuriHal: VCP optimizations, thread safe console. Rpc: adjust buffer sizes. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
40
firmware/targets/f6/Inc/stm32_assert.h
Normal file
40
firmware/targets/f6/Inc/stm32_assert.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32_assert.h
|
||||
* @brief STM32 assert file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32_ASSERT_H
|
||||
#define __STM32_ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed())
|
||||
void assert_failed();
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32_ASSERT_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -184,7 +184,7 @@
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
#define USE_FULL_ASSERT 1U
|
||||
|
||||
/* ################## SPI peripheral configuration ########################## */
|
||||
|
||||
@@ -329,17 +329,8 @@
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed())
|
||||
void assert_failed();
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "main.h"
|
||||
|
||||
#include "fatfs/fatfs.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi-hal.h>
|
||||
#include <flipper.h>
|
||||
|
||||
#define TAG "Main"
|
||||
|
||||
int main(void) {
|
||||
// Initialize FURI layer
|
||||
furi_init();
|
||||
@@ -16,13 +16,9 @@ int main(void) {
|
||||
// Flipper FURI HAL
|
||||
furi_hal_init();
|
||||
|
||||
// 3rd party
|
||||
MX_FATFS_Init();
|
||||
FURI_LOG_I("HAL", "FATFS OK");
|
||||
|
||||
// CMSIS initialization
|
||||
osKernelInitialize();
|
||||
FURI_LOG_I("HAL", "KERNEL OK");
|
||||
FURI_LOG_I(TAG, "KERNEL OK");
|
||||
|
||||
// Init flipper
|
||||
flipper_init();
|
||||
@@ -47,9 +43,6 @@ void Error_Handler(void) {
|
||||
* @retval None
|
||||
*/
|
||||
void assert_failed(uint8_t *file, uint32_t line) {
|
||||
/* USER CODE BEGIN 6 */
|
||||
/* User can add his own implementation to report the file name and line number,
|
||||
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
/* USER CODE END 6 */
|
||||
furi_crash("HAL assert failed");
|
||||
}
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define BATTERY_SERVICE_TAG "battery service"
|
||||
#define TAG "BtBatterySvc"
|
||||
|
||||
typedef struct {
|
||||
uint16_t svc_handle;
|
||||
@@ -23,7 +23,7 @@ void battery_svc_start() {
|
||||
// Add Battery service
|
||||
status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&service_uuid, PRIMARY_SERVICE, 4, &battery_svc->svc_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery service: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add Battery service: %d", status);
|
||||
}
|
||||
// Add Battery level characteristic
|
||||
status = aci_gatt_add_char(battery_svc->svc_handle,
|
||||
@@ -37,7 +37,7 @@ void battery_svc_start() {
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&battery_svc->char_level_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery level characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add Battery level characteristic: %d", status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ void battery_svc_stop() {
|
||||
// Delete Battery level characteristic
|
||||
status = aci_gatt_del_char(battery_svc->svc_handle, battery_svc->char_level_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery level characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete Battery level characteristic: %d", status);
|
||||
}
|
||||
// Delete Battery service
|
||||
status = aci_gatt_del_service(battery_svc->svc_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery service: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete Battery service: %d", status);
|
||||
}
|
||||
free(battery_svc);
|
||||
battery_svc = NULL;
|
||||
@@ -65,14 +65,14 @@ bool battery_svc_update_level(uint8_t battery_charge) {
|
||||
return false;
|
||||
}
|
||||
// Update battery level characteristic
|
||||
FURI_LOG_I(BATTERY_SERVICE_TAG, "Updating battery level characteristic");
|
||||
FURI_LOG_I(TAG, "Updating battery level characteristic");
|
||||
tBleStatus result = aci_gatt_update_char_value(battery_svc->svc_handle,
|
||||
battery_svc->char_level_handle,
|
||||
0,
|
||||
1,
|
||||
&battery_charge);
|
||||
if(result) {
|
||||
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed updating RX characteristic: %d", result);
|
||||
FURI_LOG_E(TAG, "Failed updating RX characteristic: %d", result);
|
||||
}
|
||||
return result != BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <furi-hal.h>
|
||||
|
||||
#define BLE_APP_TAG "ble app"
|
||||
#define TAG "Bt"
|
||||
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer;
|
||||
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE];
|
||||
@@ -53,7 +53,7 @@ bool ble_app_init() {
|
||||
};
|
||||
status = SHCI_C2_Config(&config_param);
|
||||
if(status) {
|
||||
FURI_LOG_E(BLE_APP_TAG, "Failed to configure 2nd core: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to configure 2nd core: %d", status);
|
||||
}
|
||||
|
||||
// Start ble stack on 2nd core
|
||||
@@ -82,7 +82,7 @@ bool ble_app_init() {
|
||||
};
|
||||
status = SHCI_C2_BLE_Init(&ble_init_cmd_packet);
|
||||
if(status) {
|
||||
FURI_LOG_E(BLE_APP_TAG, "Failed to start ble stack: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to start ble stack: %d", status);
|
||||
}
|
||||
return status == SHCI_Success;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "app_debug.h"
|
||||
#include <furi-hal.h>
|
||||
|
||||
#define TAG "Core2"
|
||||
|
||||
#define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH*4U*DIVC(( sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE ), 4U))
|
||||
|
||||
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t ble_glue_event_pool[POOL_SIZE];
|
||||
@@ -125,20 +127,20 @@ static void ble_glue_sys_user_event_callback( void * pPayload ) {
|
||||
|
||||
if(p_sys_event->subevtcode == SHCI_SUB_EVT_CODE_READY) {
|
||||
if(ble_app_init()) {
|
||||
FURI_LOG_I("Core2", "BLE stack started");
|
||||
FURI_LOG_I(TAG, "BLE stack started");
|
||||
ble_glue->status = BleGlueStatusStarted;
|
||||
if(SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7) == SHCI_Success) {
|
||||
FURI_LOG_I("Core2", "Flash activity control switched to SEM7");
|
||||
FURI_LOG_I(TAG, "Flash activity control switched to SEM7");
|
||||
} else {
|
||||
FURI_LOG_E("Core2", "Failed to switch flash activity control to SEM7");
|
||||
FURI_LOG_E(TAG, "Failed to switch flash activity control to SEM7");
|
||||
}
|
||||
} else {
|
||||
FURI_LOG_E("Core2", "BLE stack startup failed");
|
||||
FURI_LOG_E(TAG, "BLE stack startup failed");
|
||||
ble_glue->status = BleGlueStatusBleStackMissing;
|
||||
}
|
||||
furi_hal_power_insomnia_exit();
|
||||
} else if(p_sys_event->subevtcode == SHCI_SUB_EVT_ERROR_NOTIF) {
|
||||
FURI_LOG_E("Core2", "Error during initialization");
|
||||
FURI_LOG_E(TAG, "Error during initialization");
|
||||
furi_hal_power_insomnia_exit();
|
||||
} else if(p_sys_event->subevtcode == SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE) {
|
||||
SHCI_C2_BleNvmRamUpdate_Evt_t* p_sys_ble_nvm_ram_update_event = (SHCI_C2_BleNvmRamUpdate_Evt_t*)p_sys_event->payload;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define DEV_INFO_SVC_TAG "dev info service"
|
||||
#define TAG "BtDevInfoSvc"
|
||||
|
||||
typedef struct {
|
||||
uint16_t service_handle;
|
||||
@@ -29,7 +29,7 @@ void dev_info_svc_start() {
|
||||
uint16_t uuid = DEVICE_INFORMATION_SERVICE_UUID;
|
||||
status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&uuid, PRIMARY_SERVICE, 9, &dev_info_svc->service_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add Device Information Service: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add Device Information Service: %d", status);
|
||||
}
|
||||
|
||||
// Add characteristics
|
||||
@@ -45,7 +45,7 @@ void dev_info_svc_start() {
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&dev_info_svc->man_name_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add manufacturer name char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add manufacturer name char: %d", status);
|
||||
}
|
||||
uuid = SERIAL_NUMBER_UUID;
|
||||
status = aci_gatt_add_char(dev_info_svc->service_handle,
|
||||
@@ -59,7 +59,7 @@ void dev_info_svc_start() {
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&dev_info_svc->serial_num_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add serial number char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add serial number char: %d", status);
|
||||
}
|
||||
uuid = FIRMWARE_REVISION_UUID;
|
||||
status = aci_gatt_add_char(dev_info_svc->service_handle,
|
||||
@@ -73,7 +73,7 @@ void dev_info_svc_start() {
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&dev_info_svc->firmware_rev_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add firmware revision char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add firmware revision char: %d", status);
|
||||
}
|
||||
uuid = SOFTWARE_REVISION_UUID;
|
||||
status = aci_gatt_add_char(dev_info_svc->service_handle,
|
||||
@@ -87,7 +87,7 @@ void dev_info_svc_start() {
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&dev_info_svc->software_rev_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add software revision char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add software revision char: %d", status);
|
||||
}
|
||||
|
||||
// Update characteristics
|
||||
@@ -97,7 +97,7 @@ void dev_info_svc_start() {
|
||||
strlen(dev_info_man_name),
|
||||
(uint8_t*)dev_info_man_name);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update manufacturer name char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to update manufacturer name char: %d", status);
|
||||
}
|
||||
status = aci_gatt_update_char_value(dev_info_svc->service_handle,
|
||||
dev_info_svc->serial_num_char_handle,
|
||||
@@ -105,7 +105,7 @@ void dev_info_svc_start() {
|
||||
strlen(dev_info_serial_num),
|
||||
(uint8_t*)dev_info_serial_num);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update serial number char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to update serial number char: %d", status);
|
||||
}
|
||||
status = aci_gatt_update_char_value(dev_info_svc->service_handle,
|
||||
dev_info_svc->firmware_rev_char_handle,
|
||||
@@ -113,7 +113,7 @@ void dev_info_svc_start() {
|
||||
strlen(dev_info_firmware_rev_num),
|
||||
(uint8_t*)dev_info_firmware_rev_num);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update firmware revision char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to update firmware revision char: %d", status);
|
||||
}
|
||||
status = aci_gatt_update_char_value(dev_info_svc->service_handle,
|
||||
dev_info_svc->software_rev_char_handle,
|
||||
@@ -121,7 +121,7 @@ void dev_info_svc_start() {
|
||||
strlen(dev_info_software_rev_num),
|
||||
(uint8_t*)dev_info_software_rev_num);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update software revision char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to update software revision char: %d", status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,24 +131,24 @@ void dev_info_svc_stop() {
|
||||
// Delete service characteristics
|
||||
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->man_name_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete manufacturer name char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete manufacturer name char: %d", status);
|
||||
}
|
||||
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->serial_num_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete serial number char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete serial number char: %d", status);
|
||||
}
|
||||
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->firmware_rev_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete firmware revision char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete firmware revision char: %d", status);
|
||||
}
|
||||
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->software_rev_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete software revision char: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete software revision char: %d", status);
|
||||
}
|
||||
// Delete service
|
||||
status = aci_gatt_del_service(dev_info_svc->service_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete device info service: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete device info service: %d", status);
|
||||
}
|
||||
free(dev_info_svc);
|
||||
dev_info_svc = NULL;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <furi-hal.h>
|
||||
|
||||
#define GAP_TAG "BLE"
|
||||
#define TAG "BtGap"
|
||||
|
||||
#define FAST_ADV_TIMEOUT 30000
|
||||
#define INITIAL_ADV_TIMEOUT 60000
|
||||
@@ -80,7 +80,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
|
||||
if (disconnection_complete_event->Connection_Handle == gap->gap_svc.connection_handle) {
|
||||
gap->gap_svc.connection_handle = 0;
|
||||
gap->state = GapStateIdle;
|
||||
FURI_LOG_I(GAP_TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason);
|
||||
FURI_LOG_I(TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason);
|
||||
}
|
||||
if(gap->enable_adv) {
|
||||
// Restart advertising
|
||||
@@ -96,28 +96,28 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
|
||||
meta_evt = (evt_le_meta_event*) event_pckt->data;
|
||||
switch (meta_evt->subevent) {
|
||||
case EVT_LE_CONN_UPDATE_COMPLETE:
|
||||
FURI_LOG_D(GAP_TAG, "Connection update event");
|
||||
FURI_LOG_D(TAG, "Connection update event");
|
||||
break;
|
||||
|
||||
case EVT_LE_PHY_UPDATE_COMPLETE:
|
||||
evt_le_phy_update_complete = (hci_le_phy_update_complete_event_rp0*)meta_evt->data;
|
||||
if(evt_le_phy_update_complete->Status) {
|
||||
FURI_LOG_E(GAP_TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status);
|
||||
FURI_LOG_E(TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status);
|
||||
} else {
|
||||
FURI_LOG_I(GAP_TAG, "Update PHY succeed");
|
||||
FURI_LOG_I(TAG, "Update PHY succeed");
|
||||
}
|
||||
ret = hci_le_read_phy(gap->gap_svc.connection_handle,&tx_phy,&rx_phy);
|
||||
if(ret) {
|
||||
FURI_LOG_E(GAP_TAG, "Read PHY failed, status: %d", ret);
|
||||
FURI_LOG_E(TAG, "Read PHY failed, status: %d", ret);
|
||||
} else {
|
||||
FURI_LOG_I(GAP_TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy);
|
||||
FURI_LOG_I(TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_LE_CONN_COMPLETE:
|
||||
furi_hal_power_insomnia_enter();
|
||||
hci_le_connection_complete_event_rp0* connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data;
|
||||
FURI_LOG_I(GAP_TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle);
|
||||
FURI_LOG_I(TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle);
|
||||
|
||||
// Stop advertising as connection completed
|
||||
osTimerStop(gap->advertise_timer);
|
||||
@@ -141,7 +141,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
|
||||
aci_gap_pairing_complete_event_rp0 *pairing_complete;
|
||||
|
||||
case EVT_BLUE_GAP_LIMITED_DISCOVERABLE:
|
||||
FURI_LOG_I(GAP_TAG, "Limited discoverable event");
|
||||
FURI_LOG_I(TAG, "Limited discoverable event");
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_PASS_KEY_REQUEST:
|
||||
@@ -149,39 +149,39 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
|
||||
// Generate random PIN code
|
||||
uint32_t pin = rand() % 999999;
|
||||
aci_gap_pass_key_resp(gap->gap_svc.connection_handle, pin);
|
||||
FURI_LOG_I(GAP_TAG, "Pass key request event. Pin: %d", pin);
|
||||
FURI_LOG_I(TAG, "Pass key request event. Pin: %d", pin);
|
||||
BleEvent event = {.type = BleEventTypePinCodeShow, .data.pin_code = pin};
|
||||
gap->on_event_cb(event, gap->context);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_AUTHORIZATION_REQUEST:
|
||||
FURI_LOG_I(GAP_TAG, "Authorization request event");
|
||||
FURI_LOG_I(TAG, "Authorization request event");
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED:
|
||||
FURI_LOG_I(GAP_TAG, "Slave security initiated");
|
||||
FURI_LOG_I(TAG, "Slave security initiated");
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_BOND_LOST:
|
||||
FURI_LOG_I(GAP_TAG, "Bond lost event. Start rebonding");
|
||||
FURI_LOG_I(TAG, "Bond lost event. Start rebonding");
|
||||
aci_gap_allow_rebond(gap->gap_svc.connection_handle);
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_DEVICE_FOUND:
|
||||
FURI_LOG_I(GAP_TAG, "Device found event");
|
||||
FURI_LOG_I(TAG, "Device found event");
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_ADDR_NOT_RESOLVED:
|
||||
FURI_LOG_I(GAP_TAG, "Address not resolved event");
|
||||
FURI_LOG_I(TAG, "Address not resolved event");
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_KEYPRESS_NOTIFICATION:
|
||||
FURI_LOG_I(GAP_TAG, "Key press notification event");
|
||||
FURI_LOG_I(TAG, "Key press notification event");
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE:
|
||||
FURI_LOG_I(GAP_TAG, "Hex_value = %lx",
|
||||
FURI_LOG_I(TAG, "Hex_value = %lx",
|
||||
((aci_gap_numeric_comparison_value_event_rp0 *)(blue_evt->data))->Numeric_Value);
|
||||
aci_gap_numeric_comparison_value_confirm_yesno(gap->gap_svc.connection_handle, 1);
|
||||
break;
|
||||
@@ -189,17 +189,17 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
|
||||
case EVT_BLUE_GAP_PAIRING_CMPLT:
|
||||
pairing_complete = (aci_gap_pairing_complete_event_rp0*)blue_evt->data;
|
||||
if (pairing_complete->Status) {
|
||||
FURI_LOG_E(GAP_TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status);
|
||||
FURI_LOG_E(TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status);
|
||||
aci_gap_terminate(gap->gap_svc.connection_handle, 5);
|
||||
} else {
|
||||
FURI_LOG_I(GAP_TAG, "Pairing complete");
|
||||
FURI_LOG_I(TAG, "Pairing complete");
|
||||
BleEvent event = {.type = BleEventTypeConnected};
|
||||
gap->on_event_cb(event, gap->context);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_BLUE_GAP_PROCEDURE_COMPLETE:
|
||||
FURI_LOG_I(GAP_TAG, "Procedure complete event");
|
||||
FURI_LOG_I(TAG, "Procedure complete event");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -286,11 +286,11 @@ static void gap_init_svc(Gap* gap) {
|
||||
// Set GAP characteristics
|
||||
status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.dev_name_char_handle, 0, strlen(name), (uint8_t *) name);
|
||||
if (status) {
|
||||
FURI_LOG_E(GAP_TAG, "Failed updating name characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed updating name characteristic: %d", status);
|
||||
}
|
||||
status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.appearance_char_handle, 0, 2, gap_appearence_char_uuid);
|
||||
if(status) {
|
||||
FURI_LOG_E(GAP_TAG, "Failed updating appearence characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed updating appearence characteristic: %d", status);
|
||||
}
|
||||
// Set default PHY
|
||||
hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED);
|
||||
@@ -322,7 +322,7 @@ static void gap_advertise_start(GapState new_state)
|
||||
// Stop advertising
|
||||
status = aci_gap_set_non_discoverable();
|
||||
if (status) {
|
||||
FURI_LOG_E(GAP_TAG, "Stop Advertising Failed, result: %d", status);
|
||||
FURI_LOG_E(TAG, "Stop Advertising Failed, result: %d", status);
|
||||
}
|
||||
}
|
||||
// Configure advertising
|
||||
@@ -331,7 +331,7 @@ static void gap_advertise_start(GapState new_state)
|
||||
strlen(name), (uint8_t*)name,
|
||||
gap->gap_svc.adv_svc_uuid_len, gap->gap_svc.adv_svc_uuid, 0, 0);
|
||||
if(status) {
|
||||
FURI_LOG_E(GAP_TAG, "Set discoverable err: %d", status);
|
||||
FURI_LOG_E(TAG, "Set discoverable err: %d", status);
|
||||
}
|
||||
gap->state = new_state;
|
||||
BleEvent event = {.type = BleEventTypeStartAdvertising};
|
||||
@@ -355,14 +355,14 @@ static void gap_advertise_stop() {
|
||||
}
|
||||
|
||||
void gap_start_advertising() {
|
||||
FURI_LOG_I(GAP_TAG, "Start advertising");
|
||||
FURI_LOG_I(TAG, "Start advertising");
|
||||
gap->enable_adv = true;
|
||||
GapCommand command = GapCommandAdvFast;
|
||||
furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK);
|
||||
}
|
||||
|
||||
void gap_stop_advertising() {
|
||||
FURI_LOG_I(GAP_TAG, "Stop advertising");
|
||||
FURI_LOG_I(TAG, "Stop advertising");
|
||||
gap->enable_adv = false;
|
||||
GapCommand command = GapCommandAdvStop;
|
||||
furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define SERIAL_SERVICE_TAG "serial service"
|
||||
#define TAG "BtSerialSvc"
|
||||
|
||||
typedef struct {
|
||||
uint16_t svc_handle;
|
||||
@@ -37,26 +37,26 @@ static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void *event) {
|
||||
if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 2) {
|
||||
// Descriptor handle
|
||||
ret = SVCCTL_EvtAckFlowEnable;
|
||||
FURI_LOG_D(SERIAL_SERVICE_TAG, "RX descriptor event");
|
||||
FURI_LOG_D(TAG, "RX descriptor event");
|
||||
} else if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 1) {
|
||||
FURI_LOG_D(SERIAL_SERVICE_TAG, "Received %d bytes", attribute_modified->Attr_Data_Length);
|
||||
FURI_LOG_D(TAG, "Received %d bytes", attribute_modified->Attr_Data_Length);
|
||||
if(serial_svc->on_received_cb) {
|
||||
furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK);
|
||||
if(attribute_modified->Attr_Data_Length > serial_svc->bytes_ready_to_receive) {
|
||||
FURI_LOG_W(
|
||||
SERIAL_SERVICE_TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!",
|
||||
TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!",
|
||||
attribute_modified->Attr_Data_Length, serial_svc->bytes_ready_to_receive);
|
||||
}
|
||||
serial_svc->bytes_ready_to_receive -= MIN(serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length);
|
||||
uint32_t buff_free_size =
|
||||
serial_svc->on_received_cb(attribute_modified->Attr_Data, attribute_modified->Attr_Data_Length, serial_svc->context);
|
||||
FURI_LOG_D(SERIAL_SERVICE_TAG, "Available buff size: %d", buff_free_size);
|
||||
FURI_LOG_D(TAG, "Available buff size: %d", buff_free_size);
|
||||
furi_check(osMutexRelease(serial_svc->buff_size_mtx) == osOK);
|
||||
}
|
||||
ret = SVCCTL_EvtAckFlowEnable;
|
||||
}
|
||||
} else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) {
|
||||
FURI_LOG_D(SERIAL_SERVICE_TAG, "Ack received", blecore_evt->ecode);
|
||||
FURI_LOG_D(TAG, "Ack received", blecore_evt->ecode);
|
||||
if(serial_svc->on_sent_cb) {
|
||||
serial_svc->on_sent_cb(serial_svc->context);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void serial_svc_start() {
|
||||
// Add service
|
||||
status = aci_gatt_add_service(UUID_TYPE_128, (Service_UUID_t *)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Serial service: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add Serial service: %d", status);
|
||||
}
|
||||
|
||||
// Add RX characteristics
|
||||
@@ -88,7 +88,7 @@ void serial_svc_start() {
|
||||
CHAR_VALUE_LEN_VARIABLE,
|
||||
&serial_svc->rx_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add RX characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add RX characteristic: %d", status);
|
||||
}
|
||||
|
||||
// Add TX characteristic
|
||||
@@ -101,7 +101,7 @@ void serial_svc_start() {
|
||||
CHAR_VALUE_LEN_VARIABLE,
|
||||
&serial_svc->tx_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add TX characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add TX characteristic: %d", status);
|
||||
}
|
||||
// Add Flow Control characteristic
|
||||
status = aci_gatt_add_char(serial_svc->svc_handle, UUID_TYPE_128, (const Char_UUID_t*)flow_ctrl_uuid,
|
||||
@@ -113,7 +113,7 @@ void serial_svc_start() {
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&serial_svc->flow_ctrl_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Flow Control characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to add Flow Control characteristic: %d", status);
|
||||
}
|
||||
// Allocate buffer size mutex
|
||||
serial_svc->buff_size_mtx = osMutexNew(NULL);
|
||||
@@ -136,7 +136,7 @@ void serial_svc_notify_buffer_is_empty() {
|
||||
|
||||
furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK);
|
||||
if(serial_svc->bytes_ready_to_receive == 0) {
|
||||
FURI_LOG_D(SERIAL_SERVICE_TAG, "Buffer is empty. Notifying client");
|
||||
FURI_LOG_D(TAG, "Buffer is empty. Notifying client");
|
||||
serial_svc->bytes_ready_to_receive = serial_svc->buff_size;
|
||||
uint32_t buff_size_reversed = REVERSE_BYTES_U32(serial_svc->buff_size);
|
||||
aci_gatt_update_char_value(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle, 0, sizeof(uint32_t), (uint8_t*)&buff_size_reversed);
|
||||
@@ -150,20 +150,20 @@ void serial_svc_stop() {
|
||||
// Delete characteristics
|
||||
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->tx_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete TX characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete TX characteristic: %d", status);
|
||||
}
|
||||
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rx_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete RX characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete RX characteristic: %d", status);
|
||||
}
|
||||
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Flow Control characteristic: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete Flow Control characteristic: %d", status);
|
||||
}
|
||||
// Delete service
|
||||
status = aci_gatt_del_service(serial_svc->svc_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Serial service: %d", status);
|
||||
FURI_LOG_E(TAG, "Failed to delete Serial service: %d", status);
|
||||
}
|
||||
// Delete buffer size mutex
|
||||
osMutexDelete(serial_svc->buff_size_mtx);
|
||||
@@ -182,7 +182,7 @@ bool serial_svc_update_tx(uint8_t* data, uint8_t data_len) {
|
||||
data_len,
|
||||
data);
|
||||
if(result) {
|
||||
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed updating TX characteristic: %d", result);
|
||||
FURI_LOG_E(TAG, "Failed updating TX characteristic: %d", result);
|
||||
}
|
||||
return result != BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stm32wbxx_ll_rtc.h>
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalBoot"
|
||||
|
||||
// Boot request enum
|
||||
#define BOOT_REQUEST_TAINTED 0x00000000
|
||||
#define BOOT_REQUEST_CLEAN 0xDADEDADE
|
||||
@@ -11,7 +13,7 @@ void furi_hal_bootloader_init() {
|
||||
#ifndef DEBUG
|
||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED);
|
||||
#endif
|
||||
FURI_LOG_I("FuriHalBoot", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_bootloader_set_mode(FuriHalBootloaderMode mode) {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <stm32wbxx_ll_rcc.h>
|
||||
#include <stm32wbxx_ll_utils.h>
|
||||
|
||||
#define TAG "FuriHalClock"
|
||||
|
||||
#define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady())
|
||||
#define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady())
|
||||
|
||||
@@ -123,7 +125,7 @@ void furi_hal_clock_init() {
|
||||
// APB2
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
|
||||
|
||||
FURI_LOG_I("FuriHalClock", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_clock_switch_to_hsi() {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <lib/heatshrink/heatshrink_encoder.h>
|
||||
#include <lib/heatshrink/heatshrink_decoder.h>
|
||||
|
||||
#define TAG "FuriHalCompress"
|
||||
|
||||
#define FURI_HAL_COMPRESS_ICON_ENCODED_BUFF_SIZE (512)
|
||||
#define FURI_HAL_COMPRESS_ICON_DECODED_BUFF_SIZE (1024)
|
||||
|
||||
@@ -46,7 +48,7 @@ void furi_hal_compress_icon_init() {
|
||||
FURI_HAL_COMPRESS_LOOKAHEAD_BUFF_SIZE_LOG);
|
||||
heatshrink_decoder_reset(icon_decoder->decoder);
|
||||
memset(icon_decoder->decoded_buff, 0, sizeof(icon_decoder->decoded_buff));
|
||||
FURI_LOG_I("FuriHalCompress", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_compress_icon_decode(const uint8_t* icon_data, uint8_t** decoded_buff) {
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
#include <stm32wbxx_ll_usart.h>
|
||||
#include <m-string.h>
|
||||
|
||||
#include <utilities_conf.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalConsole"
|
||||
|
||||
#define CONSOLE_BAUDRATE 230400
|
||||
|
||||
volatile bool furi_hal_console_alive = false;
|
||||
@@ -16,7 +20,7 @@ void furi_hal_console_init() {
|
||||
furi_hal_uart_init(FuriHalUartIdUSART1, CONSOLE_BAUDRATE);
|
||||
furi_hal_console_alive = true;
|
||||
|
||||
FURI_LOG_I("FuriHalConsole", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_console_enable() {
|
||||
@@ -35,22 +39,26 @@ void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size) {
|
||||
if (!furi_hal_console_alive)
|
||||
return;
|
||||
|
||||
UTILS_ENTER_CRITICAL_SECTION();
|
||||
// Transmit data
|
||||
furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size);
|
||||
// Wait for TC flag to be raised for last char
|
||||
while (!LL_USART_IsActiveFlag_TC(USART1));
|
||||
UTILS_EXIT_CRITICAL_SECTION();
|
||||
}
|
||||
|
||||
void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size) {
|
||||
if (!furi_hal_console_alive)
|
||||
return;
|
||||
|
||||
UTILS_ENTER_CRITICAL_SECTION();
|
||||
// Transmit data
|
||||
furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size);
|
||||
// Transmit new line symbols
|
||||
furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)"\r\n", 2);
|
||||
// Wait for TC flag to be raised for last char
|
||||
while (!LL_USART_IsActiveFlag_TC(USART1));
|
||||
UTILS_EXIT_CRITICAL_SECTION();
|
||||
}
|
||||
|
||||
void furi_hal_console_printf(const char format[], ...) {
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
#include <furi.h>
|
||||
#include <shci.h>
|
||||
|
||||
#define TAG "FuriHalCrypto"
|
||||
|
||||
CRYP_HandleTypeDef crypt;
|
||||
|
||||
void furi_hal_crypto_init() {
|
||||
FURI_LOG_I("FuriHalCrypto", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_store_add_key(FuriHalCryptoKey* key, uint8_t* slot) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <furi.h>
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
#define TAG "FuriHalDelay"
|
||||
|
||||
static uint32_t clk_per_microsecond;
|
||||
|
||||
void furi_hal_delay_init(void) {
|
||||
@@ -10,7 +12,7 @@ void furi_hal_delay_init(void) {
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
DWT->CYCCNT = 0U;
|
||||
clk_per_microsecond = SystemCoreClock / 1000000.0f;
|
||||
FURI_LOG_I("FuriHalDelay", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void delay_us(float microseconds) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <stm32wbxx_ll_cortex.h>
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalI2C"
|
||||
|
||||
osMutexId_t furi_hal_i2c_mutex = NULL;
|
||||
|
||||
void furi_hal_i2c_init() {
|
||||
@@ -42,7 +44,7 @@ void furi_hal_i2c_init() {
|
||||
LL_I2C_DisableOwnAddress2(POWER_I2C);
|
||||
LL_I2C_DisableGeneralCall(POWER_I2C);
|
||||
LL_I2C_EnableClockStretching(POWER_I2C);
|
||||
FURI_LOG_I("FuriHalI2C", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_tx(
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <main.h>
|
||||
#include <stm32wbxx_ll_tim.h>
|
||||
|
||||
#define TAG "FuriHalInterrupt"
|
||||
|
||||
volatile FuriHalInterruptISR furi_hal_tim_tim2_isr = NULL;
|
||||
volatile FuriHalInterruptISR furi_hal_tim_tim1_isr = NULL;
|
||||
|
||||
@@ -22,7 +24,7 @@ void furi_hal_interrupt_init() {
|
||||
NVIC_SetPriority(DMA1_Channel1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 0));
|
||||
NVIC_EnableIRQ(DMA1_Channel1_IRQn);
|
||||
|
||||
FURI_LOG_I("FuriHalInterrupt", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_interrupt_set_timer_isr(TIM_TypeDef* timer, FuriHalInterruptISR isr) {
|
||||
@@ -161,10 +163,10 @@ void TAMP_STAMP_LSECSS_IRQHandler(void) {
|
||||
if (LL_RCC_IsActiveFlag_LSECSS()) {
|
||||
LL_RCC_ClearFlag_LSECSS();
|
||||
if (!LL_RCC_LSE_IsReady()) {
|
||||
FURI_LOG_E("FuriHalInterrupt", "LSE CSS fired: resetting system");
|
||||
FURI_LOG_E(TAG, "LSE CSS fired: resetting system");
|
||||
NVIC_SystemReset();
|
||||
} else {
|
||||
FURI_LOG_E("FuriHalInterrupt", "LSE CSS fired: but LSE is alive");
|
||||
FURI_LOG_E(TAG, "LSE CSS fired: but LSE is alive");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +178,7 @@ void RCC_IRQHandler(void) {
|
||||
void NMI_Handler(void) {
|
||||
if (LL_RCC_IsActiveFlag_HSECSS()) {
|
||||
LL_RCC_ClearFlag_HSECSS();
|
||||
FURI_LOG_E("FuriHalInterrupt", "HSE CSS fired: resetting system");
|
||||
FURI_LOG_E(TAG, "HSE CSS fired: resetting system");
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <furi-hal-light.h>
|
||||
#include <lp5562.h>
|
||||
|
||||
#define TAG "FuriHalLight"
|
||||
|
||||
#define LED_CURRENT_RED 50
|
||||
#define LED_CURRENT_GREEN 50
|
||||
#define LED_CURRENT_BLUE 50
|
||||
@@ -21,7 +23,7 @@ void furi_hal_light_init() {
|
||||
|
||||
lp5562_enable();
|
||||
lp5562_configure();
|
||||
FURI_LOG_I("FuriHalLight", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_light_set(Light light, uint8_t value) {
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include "furi-hal-nfc.h"
|
||||
#include <st25r3916.h>
|
||||
|
||||
#define TAG "FuriHalNfc"
|
||||
|
||||
static const uint32_t clocks_in_ms = 64 * 1000;
|
||||
|
||||
void furi_hal_nfc_init() {
|
||||
ReturnCode ret = rfalNfcInitialize();
|
||||
if(ret == ERR_NONE) {
|
||||
furi_hal_nfc_start_sleep();
|
||||
FURI_LOG_I("FuriHalNfc", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
} else {
|
||||
FURI_LOG_W("FuriHalNfc", "Initialization failed, RFAL returned: %d", ret);
|
||||
FURI_LOG_W(TAG, "Initialization failed, RFAL returned: %d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +65,7 @@ bool furi_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t ti
|
||||
while(state != RFAL_NFC_STATE_ACTIVATED) {
|
||||
rfalNfcWorker();
|
||||
state = rfalNfcGetState();
|
||||
FURI_LOG_D("HAL NFC", "Current state %d", state);
|
||||
FURI_LOG_D(TAG, "Current state %d", state);
|
||||
if(state == RFAL_NFC_STATE_POLL_ACTIVATION) {
|
||||
start = DWT->CYCCNT;
|
||||
continue;
|
||||
@@ -73,7 +75,7 @@ bool furi_hal_nfc_detect(rfalNfcDevice **dev_list, uint8_t* dev_cnt, uint32_t ti
|
||||
}
|
||||
if(DWT->CYCCNT - start > timeout * clocks_in_ms) {
|
||||
rfalNfcDeactivate(true);
|
||||
FURI_LOG_D("HAL NFC", "Timeout");
|
||||
FURI_LOG_D(TAG, "Timeout");
|
||||
return false;
|
||||
}
|
||||
osThreadYield();
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalOs"
|
||||
|
||||
#define FURI_HAL_OS_CLK_FREQUENCY 32768
|
||||
#define FURI_HAL_OS_TICK_PER_SECOND 1024
|
||||
#define FURI_HAL_OS_CLK_PER_TICK (FURI_HAL_OS_CLK_FREQUENCY / FURI_HAL_OS_TICK_PER_SECOND)
|
||||
@@ -44,7 +46,7 @@ void furi_hal_os_init() {
|
||||
osTimerStart(second_timer, 1024);
|
||||
#endif
|
||||
|
||||
FURI_LOG_I("FuriHalOs", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void LPTIM2_IRQHandler(void) {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "FuriHalPower"
|
||||
|
||||
typedef struct {
|
||||
volatile uint8_t insomnia;
|
||||
volatile uint8_t deep_insomnia;
|
||||
@@ -74,7 +76,7 @@ void furi_hal_power_init() {
|
||||
LL_PWR_SMPS_SetMode(LL_PWR_SMPS_STEP_DOWN);
|
||||
bq27220_init(&cedv);
|
||||
bq25896_init();
|
||||
FURI_LOG_I("FuriHalPower", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
uint16_t furi_hal_power_insomnia_level() {
|
||||
|
||||
@@ -104,7 +104,7 @@ void furi_hal_rfid_tim_read(float freq, float duty_cycle) {
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||
if(HAL_TIM_OC_ConfigChannel(&LFRFID_READ_TIM, &sConfigOC, LFRFID_READ_CHANNEL) != HAL_OK) {
|
||||
if(HAL_TIM_PWM_ConfigChannel(&LFRFID_READ_TIM, &sConfigOC, LFRFID_READ_CHANNEL) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
@@ -142,7 +142,6 @@ void furi_hal_rfid_tim_emulate(float freq) {
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
|
||||
|
||||
// basic PWM setup with needed freq and internal clock
|
||||
LFRFID_EMULATE_TIM.Init.Prescaler = prescaler;
|
||||
@@ -182,24 +181,6 @@ void furi_hal_rfid_tim_emulate(float freq) {
|
||||
HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
// no deadtime
|
||||
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
||||
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
||||
sBreakDeadTimeConfig.DeadTime = 0;
|
||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||
sBreakDeadTimeConfig.BreakFilter = 0;
|
||||
sBreakDeadTimeConfig.BreakAFMode = TIM_BREAK_AFMODE_INPUT;
|
||||
sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
|
||||
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
|
||||
sBreakDeadTimeConfig.Break2Filter = 0;
|
||||
sBreakDeadTimeConfig.Break2AFMode = TIM_BREAK_AFMODE_INPUT;
|
||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||
if(HAL_TIMEx_ConfigBreakDeadTime(&LFRFID_EMULATE_TIM, &sBreakDeadTimeConfig) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_rfid_tim_emulate_start() {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <stm32wbxx_ll_utils.h>
|
||||
#include <stm32wbxx_ll_cortex.h>
|
||||
|
||||
#define TAG "FuriHalSpi"
|
||||
|
||||
void furi_hal_spi_init() {
|
||||
// Spi structure is const, but mutex is not
|
||||
// Need some hell-ish casting to make it work
|
||||
@@ -33,7 +35,7 @@ void furi_hal_spi_init() {
|
||||
hal_gpio_init_ex(&gpio_spi_d_mosi, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn5SPI2);
|
||||
hal_gpio_init_ex(&gpio_spi_d_sck, GpioModeAltFunctionPushPull, GpioPullUp, GpioSpeedVeryHigh, GpioAltFn5SPI2);
|
||||
|
||||
FURI_LOG_I("FuriHalSpi", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_spi_bus_lock(const FuriHalSpiBus* bus) {
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <cc1101.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define TAG "FuriHalSubGhz"
|
||||
|
||||
static volatile SubGhzState furi_hal_subghz_state = SubGhzStateInit;
|
||||
static volatile SubGhzRegulation furi_hal_subghz_regulation = SubGhzRegulationTxRx;
|
||||
|
||||
@@ -303,7 +305,7 @@ void furi_hal_subghz_init() {
|
||||
cc1101_shutdown(device);
|
||||
|
||||
furi_hal_spi_device_return(device);
|
||||
FURI_LOG_I("FuriHalSubGhz", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_subghz_sleep() {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
#define TAG "FuriHalUsb"
|
||||
|
||||
#define USB_RECONNECT_DELAY 500
|
||||
|
||||
extern struct UsbInterface usb_cdc_single;
|
||||
@@ -64,7 +66,7 @@ void furi_hal_usb_init(void) {
|
||||
HAL_NVIC_SetPriority(USB_LP_IRQn, 5, 0);
|
||||
NVIC_EnableIRQ(USB_LP_IRQn);
|
||||
|
||||
FURI_LOG_I("FuriHalUsb", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_usb_set_config(UsbMode new_mode) {
|
||||
@@ -81,7 +83,7 @@ void furi_hal_usb_set_config(UsbMode new_mode) {
|
||||
usb_if_modes[usb_config.mode_cur]->deinit(&udev);
|
||||
if (usb_if_modes[new_mode] != NULL) {
|
||||
usb_if_modes[new_mode]->init(&udev, usb_if_modes[new_mode]);
|
||||
FURI_LOG_I("FuriHalUsb", "USB mode change %u -> %u", usb_config.mode_cur, new_mode);
|
||||
FURI_LOG_I(TAG, "USB mode change %u -> %u", usb_config.mode_cur, new_mode);
|
||||
usb_config.enabled = true;
|
||||
usb_config.mode_cur = new_mode;
|
||||
}
|
||||
@@ -98,7 +100,7 @@ void furi_hal_usb_disable() {
|
||||
susp_evt(&udev, 0, 0);
|
||||
usbd_connect(&udev, false);
|
||||
usb_config.enabled = false;
|
||||
FURI_LOG_I("FuriHalUsb", "USB Disable");
|
||||
FURI_LOG_I(TAG, "USB Disable");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +108,7 @@ void furi_hal_usb_enable() {
|
||||
if ((!usb_config.enabled) && (usb_if_modes[usb_config.mode_cur] != NULL)) {
|
||||
usbd_connect(&udev, true);
|
||||
usb_config.enabled = true;
|
||||
FURI_LOG_I("FuriHalUsb", "USB Enable");
|
||||
FURI_LOG_I(TAG, "USB Enable");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include <furi-hal-usb-cdc_i.h>
|
||||
|
||||
#include <furi-hal-console.h>
|
||||
#include <furi.h>
|
||||
#include <stream_buffer.h>
|
||||
|
||||
#define TAG "FuriHalVcp"
|
||||
|
||||
#define USB_CDC_PKT_LEN CDC_DATA_SZ
|
||||
#define VCP_RX_BUF_SIZE (USB_CDC_PKT_LEN * 3)
|
||||
#define VCP_TX_BUF_SIZE (USB_CDC_PKT_LEN * 3)
|
||||
@@ -17,11 +19,11 @@ typedef enum {
|
||||
VcpEvtDisable = (1 << 4),
|
||||
VcpEvtRx = (1 << 5),
|
||||
VcpEvtTx = (1 << 6),
|
||||
VcpEvtRxDone = (1 << 7),
|
||||
VcpEvtTxDone = (1 << 8),
|
||||
VcpEvtStreamRx = (1 << 7),
|
||||
VcpEvtStreamTx = (1 << 8),
|
||||
} WorkerEvtFlags;
|
||||
|
||||
#define VCP_THREAD_FLAG_ALL (VcpEvtConnect | VcpEvtDisconnect | VcpEvtEnable | VcpEvtDisable | VcpEvtRx | VcpEvtTx | VcpEvtRxDone | VcpEvtTxDone)
|
||||
#define VCP_THREAD_FLAG_ALL (VcpEvtConnect | VcpEvtDisconnect | VcpEvtEnable | VcpEvtDisable | VcpEvtRx | VcpEvtTx | VcpEvtStreamRx | VcpEvtStreamTx)
|
||||
|
||||
typedef struct {
|
||||
FuriThread* thread;
|
||||
@@ -62,61 +64,69 @@ void furi_hal_vcp_init() {
|
||||
|
||||
vcp->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(vcp->thread, "VcpWorker");
|
||||
furi_thread_set_stack_size(vcp->thread, 512);
|
||||
furi_thread_set_stack_size(vcp->thread, 1024);
|
||||
furi_thread_set_callback(vcp->thread, vcp_worker);
|
||||
furi_thread_start(vcp->thread);
|
||||
|
||||
FURI_LOG_I("FuriHalVcp", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
static int32_t vcp_worker(void* context) {
|
||||
bool enabled = true;
|
||||
bool tx_idle = false;
|
||||
bool rx_pending = false;
|
||||
size_t missed_rx = 0;
|
||||
|
||||
furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb);
|
||||
|
||||
|
||||
while (1) {
|
||||
uint32_t flags = osThreadFlagsWait(VCP_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_assert((flags & osFlagsError) == 0);
|
||||
|
||||
// New data received
|
||||
if((flags & VcpEvtRxDone) && enabled) {
|
||||
if((flags & VcpEvtStreamRx) && enabled && missed_rx > 0) {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP StreamRx\r\n");
|
||||
#endif
|
||||
if (xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) {
|
||||
size_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN);
|
||||
if (len > 0)
|
||||
xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever);
|
||||
else
|
||||
rx_pending = false;
|
||||
} else
|
||||
rx_pending = true; // Buffer is full, retry later
|
||||
flags |= VcpEvtRx;
|
||||
missed_rx--;
|
||||
}
|
||||
}
|
||||
|
||||
// Rx buffer was read, maybe there is enough space for new data?
|
||||
if((flags & VcpEvtRx) && rx_pending) {
|
||||
if((flags & VcpEvtRx)) {
|
||||
if (xStreamBufferSpacesAvailable(vcp->rx_stream) >= USB_CDC_PKT_LEN) {
|
||||
size_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN);
|
||||
if (len > 0)
|
||||
xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever);
|
||||
else
|
||||
rx_pending = false;
|
||||
int32_t len = furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN);
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_printf("VCP Rx %d\r\n", len);
|
||||
#endif
|
||||
if (len > 0) {
|
||||
furi_check(xStreamBufferSend(vcp->rx_stream, vcp->data_buffer, len, osWaitForever) == len);
|
||||
}
|
||||
} else {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP Rx missed\r\n");
|
||||
#endif
|
||||
missed_rx++;
|
||||
}
|
||||
}
|
||||
|
||||
// New data in Tx buffer
|
||||
if((flags & VcpEvtTx) && enabled) {
|
||||
if((flags & VcpEvtStreamTx) && enabled) {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP StreamTx\r\n");
|
||||
#endif
|
||||
if (tx_idle) {
|
||||
size_t len = xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
|
||||
if (len > 0) {
|
||||
tx_idle = false;
|
||||
furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len);
|
||||
}
|
||||
flags |= VcpEvtTx;
|
||||
}
|
||||
}
|
||||
|
||||
// CDC write transfer done
|
||||
if((flags & VcpEvtTxDone) && enabled) {
|
||||
if((flags & VcpEvtTx) && enabled) {
|
||||
size_t len = xStreamBufferReceive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0);
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_printf("VCP Tx %d\r\n", len);
|
||||
#endif
|
||||
if (len > 0) { // Some data left in Tx buffer. Sending it now
|
||||
tx_idle = false;
|
||||
furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len);
|
||||
@@ -127,6 +137,9 @@ static int32_t vcp_worker(void* context) {
|
||||
|
||||
// VCP session opened
|
||||
if((flags & VcpEvtConnect) && enabled) {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP Connect\r\n");
|
||||
#endif
|
||||
if (vcp->connected == false) {
|
||||
vcp->connected = true;
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_soh, 1, osWaitForever);
|
||||
@@ -135,6 +148,9 @@ static int32_t vcp_worker(void* context) {
|
||||
|
||||
// VCP session closed
|
||||
if((flags & VcpEvtDisconnect) && enabled) {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP Disconnect\r\n");
|
||||
#endif
|
||||
if (vcp->connected == true) {
|
||||
vcp->connected = false;
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
|
||||
@@ -143,6 +159,9 @@ static int32_t vcp_worker(void* context) {
|
||||
|
||||
// VCP enabled
|
||||
if((flags & VcpEvtEnable) && !enabled){
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP Enable\r\n");
|
||||
#endif
|
||||
furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb);
|
||||
enabled = true;
|
||||
furi_hal_cdc_receive(VCP_IF_NUM, vcp->data_buffer, USB_CDC_PKT_LEN); // flush Rx buffer
|
||||
@@ -154,6 +173,9 @@ static int32_t vcp_worker(void* context) {
|
||||
|
||||
// VCP disabled
|
||||
if((flags & VcpEvtDisable) && enabled) {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP Disable\r\n");
|
||||
#endif
|
||||
enabled = false;
|
||||
vcp->connected = false;
|
||||
xStreamBufferSend(vcp->rx_stream, &ascii_eot, 1, osWaitForever);
|
||||
@@ -182,9 +204,9 @@ size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeo
|
||||
batch_size = VCP_RX_BUF_SIZE;
|
||||
|
||||
size_t len = xStreamBufferReceive(vcp->rx_stream, buffer, batch_size, timeout);
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtRx);
|
||||
if (len == 0)
|
||||
break;
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamRx);
|
||||
size -= len;
|
||||
buffer += len;
|
||||
rx_cnt += len;
|
||||
@@ -207,7 +229,7 @@ void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) {
|
||||
batch_size = VCP_TX_BUF_SIZE;
|
||||
|
||||
xStreamBufferSend(vcp->tx_stream, buffer, batch_size, osWaitForever);
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtTx);
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtStreamTx);
|
||||
|
||||
size -= batch_size;
|
||||
buffer += batch_size;
|
||||
@@ -215,6 +237,9 @@ void furi_hal_vcp_tx(const uint8_t* buffer, size_t size) {
|
||||
}
|
||||
|
||||
static void vcp_state_callback(uint8_t state) {
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP State\r\n");
|
||||
#endif
|
||||
if (state == 0) {
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtDisconnect);
|
||||
}
|
||||
@@ -223,7 +248,9 @@ static void vcp_state_callback(uint8_t state) {
|
||||
static void vcp_on_cdc_control_line(uint8_t state) {
|
||||
// bit 0: DTR state, bit 1: RTS state
|
||||
bool dtr = state & (1 << 0);
|
||||
|
||||
#ifdef FURI_HAL_USB_VCP_DEBUG
|
||||
furi_hal_console_puts("VCP CtrlLine\r\n");
|
||||
#endif
|
||||
if (dtr == true) {
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtConnect);
|
||||
} else {
|
||||
@@ -232,12 +259,12 @@ static void vcp_on_cdc_control_line(uint8_t state) {
|
||||
}
|
||||
|
||||
static void vcp_on_cdc_rx() {
|
||||
uint32_t ret = osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtRxDone);
|
||||
uint32_t ret = osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtRx);
|
||||
furi_assert((ret & osFlagsError) == 0);
|
||||
}
|
||||
|
||||
static void vcp_on_cdc_tx_complete() {
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtTxDone);
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(vcp->thread), VcpEvtTx);
|
||||
}
|
||||
|
||||
bool furi_hal_vcp_is_connected(void) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <stdio.h>
|
||||
#include "ble.h"
|
||||
|
||||
#define TAG "FuriHalVersion"
|
||||
|
||||
#define FURI_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE
|
||||
#define FURI_HAL_VERSION_OTP_ADDRESS OTP_AREA_BASE
|
||||
|
||||
@@ -191,7 +193,7 @@ void furi_hal_version_init() {
|
||||
break;
|
||||
default: furi_crash(NULL);
|
||||
}
|
||||
FURI_LOG_I("FuriHalVersion", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
bool furi_hal_version_do_i_belong_here() {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <furi-hal-vibro.h>
|
||||
#include <furi-hal-gpio.h>
|
||||
|
||||
#define TAG "FuriHalVibro"
|
||||
|
||||
void furi_hal_vibro_init() {
|
||||
hal_gpio_init(&vibro_gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
hal_gpio_write(&vibro_gpio, false);
|
||||
FURI_LOG_I("FuriHalVibro", "Init OK");
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
#include <stm32wbxx_ll_cortex.h>
|
||||
|
||||
#include <fatfs.h>
|
||||
|
||||
#define TAG "FuriHal"
|
||||
|
||||
void furi_hal_init() {
|
||||
furi_hal_clock_init();
|
||||
furi_hal_console_init();
|
||||
@@ -14,23 +18,23 @@ void furi_hal_init() {
|
||||
furi_hal_delay_init();
|
||||
|
||||
MX_GPIO_Init();
|
||||
FURI_LOG_I("HAL", "GPIO OK");
|
||||
FURI_LOG_I(TAG, "GPIO OK");
|
||||
|
||||
MX_RTC_Init();
|
||||
FURI_LOG_I("HAL", "RTC OK");
|
||||
FURI_LOG_I(TAG, "RTC OK");
|
||||
furi_hal_bootloader_init();
|
||||
furi_hal_version_init();
|
||||
|
||||
furi_hal_spi_init();
|
||||
|
||||
MX_TIM1_Init();
|
||||
FURI_LOG_I("HAL", "TIM1 OK");
|
||||
FURI_LOG_I(TAG, "TIM1 OK");
|
||||
MX_TIM2_Init();
|
||||
FURI_LOG_I("HAL", "TIM2 OK");
|
||||
FURI_LOG_I(TAG, "TIM2 OK");
|
||||
MX_TIM16_Init();
|
||||
FURI_LOG_I("HAL", "TIM16 OK");
|
||||
FURI_LOG_I(TAG, "TIM16 OK");
|
||||
MX_COMP1_Init();
|
||||
FURI_LOG_I("HAL", "COMP1 OK");
|
||||
FURI_LOG_I(TAG, "COMP1 OK");
|
||||
|
||||
furi_hal_crypto_init();
|
||||
|
||||
@@ -38,7 +42,7 @@ void furi_hal_init() {
|
||||
furi_hal_usb_init();
|
||||
furi_hal_usb_set_config(UsbModeVcpSingle);
|
||||
furi_hal_vcp_init();
|
||||
FURI_LOG_I("HAL", "USB OK");
|
||||
FURI_LOG_I(TAG, "USB OK");
|
||||
|
||||
furi_hal_i2c_init();
|
||||
|
||||
@@ -55,6 +59,10 @@ void furi_hal_init() {
|
||||
// FreeRTOS glue
|
||||
furi_hal_os_init();
|
||||
|
||||
// FatFS driver initialization
|
||||
MX_FATFS_Init();
|
||||
FURI_LOG_I(TAG, "FATFS OK");
|
||||
|
||||
// Partial null pointer dereference protection
|
||||
LL_MPU_Disable();
|
||||
LL_MPU_ConfigRegion(
|
||||
|
||||
@@ -128,6 +128,11 @@ ifeq ($(FURI_HAL_OS_DEBUG), 1)
|
||||
CFLAGS += -DFURI_HAL_OS_DEBUG
|
||||
endif
|
||||
|
||||
FURI_HAL_USB_VCP_DEBUG ?= 0
|
||||
ifeq ($(FURI_HAL_USB_VCP_DEBUG), 1)
|
||||
CFLAGS += -DFURI_HAL_USB_VCP_DEBUG
|
||||
endif
|
||||
|
||||
FURI_HAL_SUBGHZ_TX_GPIO ?= 0
|
||||
ifneq ($(FURI_HAL_SUBGHZ_TX_GPIO), 0)
|
||||
CFLAGS += -DFURI_HAL_SUBGHZ_TX_GPIO=$(FURI_HAL_SUBGHZ_TX_GPIO)
|
||||
@@ -144,10 +149,10 @@ C_SOURCES += $(wildcard $(FURI_HAL_DIR)/*.c)
|
||||
# Other
|
||||
CFLAGS += \
|
||||
-I$(MXPROJECT_DIR)/Inc \
|
||||
-I$(MXPROJECT_DIR)/Src/fatfs
|
||||
-I$(MXPROJECT_DIR)/fatfs
|
||||
C_SOURCES += \
|
||||
$(wildcard $(MXPROJECT_DIR)/Src/*.c) \
|
||||
$(wildcard $(MXPROJECT_DIR)/Src/fatfs/*.c)
|
||||
$(wildcard $(MXPROJECT_DIR)/fatfs/*.c)
|
||||
|
||||
# Linker options
|
||||
ifeq ($(NO_BOOTLOADER), 1)
|
||||
|
||||
Reference in New Issue
Block a user