Fix: proper deinit of gpio and spi bus in NRF24 driver

This commit is contained in:
MX 2022-11-02 03:42:38 +03:00
parent 2ab9769b4b
commit 0f1e03fa51
No known key found for this signature in database
GPG Key ID: 6C4C311DFD4B4AB5
5 changed files with 16 additions and 3 deletions

View File

@ -382,7 +382,7 @@ int32_t mousejacker_app(void* p) {
}
furi_thread_free(plugin_state->mjthread);
furi_hal_spi_release(nrf24_HANDLE);
nrf24_deinit();
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
furi_record_close(RECORD_GUI);

View File

@ -440,7 +440,7 @@ int32_t nrfsniff_app(void* p) {
sample_time = DEFAULT_SAMPLE_TIME;
target_rate = 8; // rate can be either 8 (2Mbps) or 0 (1Mbps)
sniffing_state = false;
furi_hal_spi_release(nrf24_HANDLE);
nrf24_deinit();
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
furi_record_close(RECORD_GUI);

View File

@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,8.2,,
Version,+,8.3,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
@ -1790,6 +1790,7 @@ Function,+,notification_message,void,"NotificationApp*, const NotificationSequen
Function,+,notification_message_block,void,"NotificationApp*, const NotificationSequence*"
Function,-,nrand48,long,unsigned short[3]
Function,-,nrf24_configure,void,"FuriHalSpiBusHandle*, uint8_t, uint8_t*, uint8_t*, uint8_t, uint8_t, _Bool, _Bool"
Function,+,nrf24_deinit,void,
Function,+,nrf24_find_channel,uint8_t,"FuriHalSpiBusHandle*, uint8_t*, uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, _Bool"
Function,-,nrf24_flush_rx,uint8_t,FuriHalSpiBusHandle*
Function,-,nrf24_flush_tx,uint8_t,FuriHalSpiBusHandle*

1 entry status name type params
2 Version + 8.2 8.3
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
1790 Function + notification_message_block void NotificationApp*, const NotificationSequence*
1791 Function - nrand48 long unsigned short[3]
1792 Function - nrf24_configure void FuriHalSpiBusHandle*, uint8_t, uint8_t*, uint8_t*, uint8_t, uint8_t, _Bool, _Bool
1793 Function + nrf24_deinit void
1794 Function + nrf24_find_channel uint8_t FuriHalSpiBusHandle*, uint8_t*, uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, _Bool
1795 Function - nrf24_flush_rx uint8_t FuriHalSpiBusHandle*
1796 Function - nrf24_flush_tx uint8_t FuriHalSpiBusHandle*

View File

@ -12,6 +12,13 @@ void nrf24_init() {
furi_hal_gpio_write(nrf24_CE_PIN, false);
}
void nrf24_deinit() {
furi_hal_spi_release(nrf24_HANDLE);
furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
furi_hal_gpio_write(nrf24_CE_PIN, false);
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
}
void nrf24_spi_trx(
FuriHalSpiBusHandle* handle,
uint8_t* tx,

View File

@ -116,6 +116,11 @@ uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle);
*/
void nrf24_init();
/** Must call this when we end using nrf24 device
*
*/
void nrf24_deinit();
/** Send flush rx command
*
* @param handle - pointer to FuriHalSpiHandle