[FL-1167] Rework GPIO and EXTI with LL lib (#424)
* api-hal-gpio: rework gpio on ll * one_wire_slave: rework gpio initialization * interrupts: add attribute weak to hal exti interrupts handlers * api-hal-gpio: add exti interrupt handlers * input: rework with api-hal-gpio interrupts * one_wire_slave: rework with api-hal-gpio interrupts * api-hal-gpio: fix incorrect exti line config * api-hal-gpio: add doxygen documentation * api-hal-gpio: add enable / disable interrupts * api-hal-gpio: add get_rfid_level * core: remove api-gpio * applications: rework gpio with api-hal-gpio * lib: rework gpio with api-hal-gpio * rfal: disable exti interrupt when rfal is inactive * rfal: add interrupt gpio reinitialization * api-hal-gpio: hide setting speed and pull mode LL implementation * stm32wbxx_it: remove unused EXTI handlers * api-hal-gpio: guard set, enable, disable and remove interrupt * Drop F4 target * Accessor: update gpio api usage Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
		@@ -8,12 +8,11 @@ static osThreadAttr_t platform_irq_thread_attr;
 | 
			
		||||
static volatile osThreadId_t platform_irq_thread_id = NULL;
 | 
			
		||||
static volatile PlatformIrqCallback platform_irq_callback = NULL;
 | 
			
		||||
static ApiHalSpiDevice* platform_st25r3916 = NULL;
 | 
			
		||||
static const GpioPin pin = {ST25R_INT_PORT, ST25R_INT_PIN};
 | 
			
		||||
 | 
			
		||||
void nfc_isr(void* _pin, void* _ctx) {
 | 
			
		||||
    uint32_t pin = (uint32_t)_pin;
 | 
			
		||||
    if(pin == NFC_IRQ_Pin
 | 
			
		||||
        && platform_irq_callback
 | 
			
		||||
        && platformGpioIsHigh(ST25R_INT_PORT, ST25R_INT_PIN)) {
 | 
			
		||||
void nfc_isr(void* _ctx) {
 | 
			
		||||
    if(platform_irq_callback
 | 
			
		||||
       && platformGpioIsHigh(ST25R_INT_PORT, ST25R_INT_PIN)) {
 | 
			
		||||
        osThreadFlagsSet(platform_irq_thread_id, 0x1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -27,13 +26,26 @@ void platformIrqWorker() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void platformEnableIrqCallback() {
 | 
			
		||||
    hal_gpio_init(&pin, GpioModeInterruptRise, GpioPullNo, GpioSpeedLow);
 | 
			
		||||
    hal_gpio_enable_int_callback(&pin);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void platformDisableIrqCallback() {
 | 
			
		||||
    hal_gpio_init(&pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
 | 
			
		||||
    hal_gpio_disable_int_callback(&pin);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void platformSetIrqCallback(PlatformIrqCallback callback) {
 | 
			
		||||
    platform_irq_callback = callback;
 | 
			
		||||
    platform_irq_thread_attr.name = "rfal_irq_worker";
 | 
			
		||||
    platform_irq_thread_attr.stack_size = 1024;
 | 
			
		||||
    platform_irq_thread_attr.priority = osPriorityISR;
 | 
			
		||||
    platform_irq_thread_id = osThreadNew(platformIrqWorker, NULL, &platform_irq_thread_attr);
 | 
			
		||||
    api_interrupt_add(nfc_isr, InterruptTypeExternalInterrupt, NULL);
 | 
			
		||||
    hal_gpio_add_int_callback(&pin, nfc_isr, NULL);
 | 
			
		||||
    // Disable interrupt callback as the pin is shared between 2 apps
 | 
			
		||||
    // It is enabled in rfalLowPowerModeStop()
 | 
			
		||||
    hal_gpio_disable_int_callback(&pin);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) {
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,8 @@
 | 
			
		||||
 | 
			
		||||
typedef void (*PlatformIrqCallback)();
 | 
			
		||||
void platformSetIrqCallback(PlatformIrqCallback cb);
 | 
			
		||||
void platformEnableIrqCallback();
 | 
			
		||||
void platformDisableIrqCallback();
 | 
			
		||||
 | 
			
		||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len);
 | 
			
		||||
void platformProtectST25RComm();
 | 
			
		||||
 
 | 
			
		||||
@@ -4559,6 +4559,8 @@ ReturnCode rfalLowPowerModeStart( void )
 | 
			
		||||
 
 | 
			
		||||
    gRFAL.state         = RFAL_STATE_IDLE;
 | 
			
		||||
    gRFAL.lpm.isRunning = true;
 | 
			
		||||
 | 
			
		||||
    platformDisableIrqCallback();
 | 
			
		||||
    
 | 
			
		||||
    return ERR_NONE;
 | 
			
		||||
}
 | 
			
		||||
@@ -4569,6 +4571,8 @@ ReturnCode rfalLowPowerModeStop( void )
 | 
			
		||||
{
 | 
			
		||||
    ReturnCode ret;
 | 
			
		||||
    
 | 
			
		||||
    platformEnableIrqCallback();
 | 
			
		||||
 | 
			
		||||
    /* Check if RFAL is on right state */
 | 
			
		||||
    if( !gRFAL.lpm.isRunning )
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user