[FL-2060] FuriHal: SPI refactoring, flexible bus reconfiguration on fly, same design as i2c. (#853)
* FuriHal: SPI refactoring, flexible bus reconfigration on fly, same desiag as i2c. * Lib: update CC1101 driver documentation * FuriHal: update spi symbol names to match naming convention.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
static osThreadAttr_t platform_irq_thread_attr;
|
||||
static volatile osThreadId_t platform_irq_thread_id = NULL;
|
||||
static volatile PlatformIrqCallback platform_irq_callback = NULL;
|
||||
static FuriHalSpiDevice* platform_st25r3916 = NULL;
|
||||
static const GpioPin pin = {ST25R_INT_PORT, ST25R_INT_PIN};
|
||||
|
||||
void nfc_isr(void* _ctx) {
|
||||
@@ -49,14 +48,13 @@ void platformSetIrqCallback(PlatformIrqCallback callback) {
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) {
|
||||
furi_assert(platform_st25r3916);
|
||||
bool ret = false;
|
||||
if (txBuf && rxBuf) {
|
||||
ret = furi_hal_spi_bus_trx(platform_st25r3916->bus, (uint8_t*)txBuf, rxBuf, len, 1000);
|
||||
ret = furi_hal_spi_bus_trx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)txBuf, rxBuf, len, 1000);
|
||||
} else if (txBuf) {
|
||||
ret = furi_hal_spi_bus_tx(platform_st25r3916->bus, (uint8_t*)txBuf, len, 1000);
|
||||
ret = furi_hal_spi_bus_tx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)txBuf, len, 1000);
|
||||
} else if (rxBuf) {
|
||||
ret = furi_hal_spi_bus_rx(platform_st25r3916->bus, (uint8_t*)rxBuf, len, 1000);
|
||||
ret = furi_hal_spi_bus_rx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)rxBuf, len, 1000);
|
||||
}
|
||||
|
||||
if(!ret) {
|
||||
@@ -68,15 +66,9 @@ HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t
|
||||
}
|
||||
|
||||
void platformProtectST25RComm() {
|
||||
// Don't check platform_st25r3916 since spi device is used simultaneously from nfc worker
|
||||
// thread and platformIrqWorker thread with the highest priority
|
||||
|
||||
// furi_assert(platform_st25r3916 == NULL);
|
||||
platform_st25r3916 = (FuriHalSpiDevice*)furi_hal_spi_device_get(FuriHalSpiDeviceIdNfc);
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_nfc);
|
||||
}
|
||||
|
||||
void platformUnprotectST25RComm() {
|
||||
// furi_assert(platform_st25r3916);
|
||||
furi_hal_spi_device_return(platform_st25r3916);
|
||||
// platform_st25r3916 = NULL;
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_nfc);
|
||||
}
|
||||
|
Reference in New Issue
Block a user