mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
@@ -21,8 +21,7 @@
|
||||
|
||||
#define TAG "FuriHalBt"
|
||||
|
||||
#define furi_hal_bt_DEFAULT_MAC_ADDR \
|
||||
{ 0x6c, 0x7a, 0xd8, 0xac, 0x57, 0x72 }
|
||||
#define furi_hal_bt_DEFAULT_MAC_ADDR {0x6c, 0x7a, 0xd8, 0xac, 0x57, 0x72}
|
||||
|
||||
/* Time, in ms, to wait for mode transition before crashing */
|
||||
#define C2_MODE_SWITCH_TIMEOUT 10000
|
||||
|
||||
@@ -513,8 +513,7 @@ typedef struct {
|
||||
uint32_t* ob_register_address;
|
||||
} FuriHalFlashObMapping;
|
||||
|
||||
#define OB_REG_DEF(INDEX, REG) \
|
||||
{ .ob_reg = INDEX, .ob_register_address = (uint32_t*)(REG) }
|
||||
#define OB_REG_DEF(INDEX, REG) {.ob_reg = INDEX, .ob_register_address = (uint32_t*)(REG)}
|
||||
|
||||
static const FuriHalFlashObMapping furi_hal_flash_ob_reg_map[FURI_HAL_FLASH_OB_TOTAL_WORDS] = {
|
||||
OB_REG_DEF(FuriHalFlashObRegisterUserRead, (&FLASH->OPTR)),
|
||||
|
||||
@@ -249,7 +249,7 @@ void furi_hal_gpio_remove_int_callback(const GpioPin* gpio) {
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void furi_hal_gpio_int_call(uint16_t pin_num) {
|
||||
FURI_ALWAYS_INLINE static void furi_hal_gpio_int_call(uint16_t pin_num) {
|
||||
if(gpio_interrupt[pin_num].callback) {
|
||||
gpio_interrupt[pin_num].callback(gpio_interrupt[pin_num].context);
|
||||
}
|
||||
|
||||
@@ -13,12 +13,22 @@
|
||||
|
||||
#define FURI_HAL_INTERRUPT_DEFAULT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 5)
|
||||
|
||||
#define FURI_HAL_INTERRUPT_ACCOUNT_START() const uint32_t _isr_start = DWT->CYCCNT;
|
||||
#define FURI_HAL_INTERRUPT_ACCOUNT_END() \
|
||||
const uint32_t _time_in_isr = DWT->CYCCNT - _isr_start; \
|
||||
furi_hal_interrupt.counter_time_in_isr_total += _time_in_isr;
|
||||
|
||||
typedef struct {
|
||||
FuriHalInterruptISR isr;
|
||||
void* context;
|
||||
} FuriHalInterruptISRPair;
|
||||
|
||||
FuriHalInterruptISRPair furi_hal_interrupt_isr[FuriHalInterruptIdMax] = {0};
|
||||
typedef struct {
|
||||
FuriHalInterruptISRPair isr[FuriHalInterruptIdMax];
|
||||
uint32_t counter_time_in_isr_total;
|
||||
} FuriHalIterrupt;
|
||||
|
||||
static FuriHalIterrupt furi_hal_interrupt = {};
|
||||
|
||||
const IRQn_Type furi_hal_interrupt_irqn[FuriHalInterruptIdMax] = {
|
||||
// TIM1, TIM16, TIM17
|
||||
@@ -67,12 +77,16 @@ const IRQn_Type furi_hal_interrupt_irqn[FuriHalInterruptIdMax] = {
|
||||
[FuriHalInterruptIdLpUart1] = LPUART1_IRQn,
|
||||
};
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void furi_hal_interrupt_call(FuriHalInterruptId index) {
|
||||
furi_check(furi_hal_interrupt_isr[index].isr);
|
||||
furi_hal_interrupt_isr[index].isr(furi_hal_interrupt_isr[index].context);
|
||||
FURI_ALWAYS_INLINE static void furi_hal_interrupt_call(FuriHalInterruptId index) {
|
||||
const FuriHalInterruptISRPair* isr_descr = &furi_hal_interrupt.isr[index];
|
||||
furi_check(isr_descr->isr);
|
||||
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_START();
|
||||
isr_descr->isr(isr_descr->context);
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_END();
|
||||
}
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void
|
||||
FURI_ALWAYS_INLINE static void
|
||||
furi_hal_interrupt_enable(FuriHalInterruptId index, uint16_t priority) {
|
||||
NVIC_SetPriority(
|
||||
furi_hal_interrupt_irqn[index],
|
||||
@@ -80,19 +94,19 @@ FURI_ALWAYS_STATIC_INLINE void
|
||||
NVIC_EnableIRQ(furi_hal_interrupt_irqn[index]);
|
||||
}
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void furi_hal_interrupt_clear_pending(FuriHalInterruptId index) {
|
||||
FURI_ALWAYS_INLINE static void furi_hal_interrupt_clear_pending(FuriHalInterruptId index) {
|
||||
NVIC_ClearPendingIRQ(furi_hal_interrupt_irqn[index]);
|
||||
}
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void furi_hal_interrupt_get_pending(FuriHalInterruptId index) {
|
||||
FURI_ALWAYS_INLINE static void furi_hal_interrupt_get_pending(FuriHalInterruptId index) {
|
||||
NVIC_GetPendingIRQ(furi_hal_interrupt_irqn[index]);
|
||||
}
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void furi_hal_interrupt_set_pending(FuriHalInterruptId index) {
|
||||
FURI_ALWAYS_INLINE static void furi_hal_interrupt_set_pending(FuriHalInterruptId index) {
|
||||
NVIC_SetPendingIRQ(furi_hal_interrupt_irqn[index]);
|
||||
}
|
||||
|
||||
FURI_ALWAYS_STATIC_INLINE void furi_hal_interrupt_disable(FuriHalInterruptId index) {
|
||||
FURI_ALWAYS_INLINE static void furi_hal_interrupt_disable(FuriHalInterruptId index) {
|
||||
NVIC_DisableIRQ(furi_hal_interrupt_irqn[index]);
|
||||
}
|
||||
|
||||
@@ -137,17 +151,18 @@ void furi_hal_interrupt_set_isr_ex(
|
||||
|
||||
uint16_t real_priority = FURI_HAL_INTERRUPT_DEFAULT_PRIORITY - priority;
|
||||
|
||||
FuriHalInterruptISRPair* isr_descr = &furi_hal_interrupt.isr[index];
|
||||
if(isr) {
|
||||
// Pre ISR set
|
||||
furi_check(furi_hal_interrupt_isr[index].isr == NULL);
|
||||
furi_check(isr_descr->isr == NULL);
|
||||
} else {
|
||||
// Pre ISR clear
|
||||
furi_hal_interrupt_disable(index);
|
||||
furi_hal_interrupt_clear_pending(index);
|
||||
}
|
||||
|
||||
furi_hal_interrupt_isr[index].isr = isr;
|
||||
furi_hal_interrupt_isr[index].context = context;
|
||||
isr_descr->isr = isr;
|
||||
isr_descr->context = context;
|
||||
__DMB();
|
||||
|
||||
if(isr) {
|
||||
@@ -304,27 +319,37 @@ extern void HW_IPCC_Tx_Handler(void);
|
||||
extern void HW_IPCC_Rx_Handler(void);
|
||||
|
||||
void SysTick_Handler(void) {
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_START();
|
||||
furi_hal_os_tick();
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_END();
|
||||
}
|
||||
|
||||
void USB_LP_IRQHandler(void) {
|
||||
#ifndef FURI_RAM_EXEC
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_START();
|
||||
usbd_poll(&udev);
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_END();
|
||||
#endif
|
||||
}
|
||||
|
||||
void USB_HP_IRQHandler(void) { //-V524
|
||||
#ifndef FURI_RAM_EXEC
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_START();
|
||||
usbd_poll(&udev);
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_END();
|
||||
#endif
|
||||
}
|
||||
|
||||
void IPCC_C1_TX_IRQHandler(void) {
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_START();
|
||||
HW_IPCC_Tx_Handler();
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_END();
|
||||
}
|
||||
|
||||
void IPCC_C1_RX_IRQHandler(void) {
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_START();
|
||||
HW_IPCC_Rx_Handler();
|
||||
FURI_HAL_INTERRUPT_ACCOUNT_END();
|
||||
}
|
||||
|
||||
void FPU_IRQHandler(void) {
|
||||
@@ -499,3 +524,7 @@ const char* furi_hal_interrupt_get_name(uint8_t exception_number) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t furi_hal_interrupt_get_time_in_isr_total(void) {
|
||||
return furi_hal_interrupt.counter_time_in_isr_total;
|
||||
}
|
||||
@@ -118,6 +118,12 @@ void furi_hal_interrupt_set_isr_ex(
|
||||
*/
|
||||
const char* furi_hal_interrupt_get_name(uint8_t exception_number);
|
||||
|
||||
/** Get total time(in CPU clocks) spent in ISR
|
||||
*
|
||||
* @return total time in CPU clocks
|
||||
*/
|
||||
uint32_t furi_hal_interrupt_get_time_in_isr_total(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,8 @@ static const uint8_t USB_DEVICE_NO_PROTOCOL = 0x0;
|
||||
#define CCID_TOTAL_SLOTS 1
|
||||
#define CCID_SLOT_INDEX 0
|
||||
|
||||
#define CCID_DATABLOCK_SIZE 256
|
||||
#define CCID_DATABLOCK_SIZE \
|
||||
(4 + 1 + CCID_SHORT_APDU_SIZE + 1) //APDU Header + Lc + Short APDU size + Le
|
||||
|
||||
#define ENDPOINT_DIR_IN 0x80
|
||||
#define ENDPOINT_DIR_OUT 0x00
|
||||
@@ -193,7 +194,8 @@ static void* ccid_set_string_descr(char* str) {
|
||||
struct usb_string_descriptor* dev_str_desc = malloc(len * 2 + 2);
|
||||
dev_str_desc->bLength = len * 2 + 2;
|
||||
dev_str_desc->bDescriptorType = USB_DTYPE_STRING;
|
||||
for(size_t i = 0; i < len; i++) dev_str_desc->wString[i] = str[i];
|
||||
for(size_t i = 0; i < len; i++)
|
||||
dev_str_desc->wString[i] = str[i];
|
||||
|
||||
return dev_str_desc;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,8 @@ static void* hid_set_string_descr(char* str) {
|
||||
struct usb_string_descriptor* dev_str_desc = malloc(len * 2 + 2);
|
||||
dev_str_desc->bLength = len * 2 + 2;
|
||||
dev_str_desc->bDescriptorType = USB_DTYPE_STRING;
|
||||
for(size_t i = 0; i < len; i++) dev_str_desc->wString[i] = str[i];
|
||||
for(size_t i = 0; i < len; i++)
|
||||
dev_str_desc->wString[i] = str[i];
|
||||
|
||||
return dev_str_desc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user