Skip to content

Commit 3dcb9f8

Browse files
WonderMrclaude
andcommitted
furi_hal_spi: take const uint8_t* tx_buffer in trx_dma()
The DMA path only reads from tx_buffer; nothing inside writes through the pointer. Mirrors the signature of furi_hal_spi_bus_trx() which already takes const uint8_t* tx_buffer. Drops the (uint8_t*) cast that furi_hal_spi_bus_tx() needed to call furi_hal_spi_bus_trx_dma() with its own const uint8_t* buffer parameter, and turns the (uint8_t*)&dma_dummy_u32 cast (the dummy buffer is itself const uint32_t) into a properly const-preserving (const uint8_t*) cast. api_symbols.csv updated to match. Existing in-tree callers (furi_hal_sd.c) pass non-const pointers and continue to compile without changes; out-of-tree callers passing const pointers no longer need to drop qualifiers. Reported by Copilot review on #4360. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 79c1a06 commit 3dcb9f8

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

targets/f7/api_symbols.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,7 @@ Function,+,furi_hal_spi_bus_handle_init,void,const FuriHalSpiBusHandle*
17031703
Function,+,furi_hal_spi_bus_init,void,FuriHalSpiBus*
17041704
Function,+,furi_hal_spi_bus_rx,_Bool,"const FuriHalSpiBusHandle*, uint8_t*, size_t, uint32_t"
17051705
Function,+,furi_hal_spi_bus_trx,_Bool,"const FuriHalSpiBusHandle*, const uint8_t*, uint8_t*, size_t, uint32_t"
1706-
Function,+,furi_hal_spi_bus_trx_dma,_Bool,"const FuriHalSpiBusHandle*, uint8_t*, uint8_t*, size_t, uint32_t"
1706+
Function,+,furi_hal_spi_bus_trx_dma,_Bool,"const FuriHalSpiBusHandle*, const uint8_t*, uint8_t*, size_t, uint32_t"
17071707
Function,+,furi_hal_spi_bus_tx,_Bool,"const FuriHalSpiBusHandle*, const uint8_t*, size_t, uint32_t"
17081708
Function,-,furi_hal_spi_config_deinit_early,void,
17091709
Function,-,furi_hal_spi_config_init,void,

targets/f7/furi_hal/furi_hal_spi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool furi_hal_spi_bus_tx(
113113

114114
if(furi_kernel_is_running()) {
115115
// Use DMA for TX when scheduler is running, freeing the CPU during transfer
116-
bool ret = furi_hal_spi_bus_trx_dma(handle, (uint8_t*)buffer, NULL, size, timeout);
116+
bool ret = furi_hal_spi_bus_trx_dma(handle, buffer, NULL, size, timeout);
117117
LL_SPI_ClearFlag_OVR(handle->bus->spi);
118118
return ret;
119119
}
@@ -201,7 +201,7 @@ static void spi_dma_isr(void* context) {
201201

202202
bool furi_hal_spi_bus_trx_dma(
203203
const FuriHalSpiBusHandle* handle,
204-
uint8_t* tx_buffer,
204+
const uint8_t* tx_buffer,
205205
uint8_t* rx_buffer,
206206
size_t size,
207207
uint32_t timeout_ms) {
@@ -329,7 +329,7 @@ bool furi_hal_spi_bus_trx_dma(
329329

330330
if(tx_buffer == NULL) {
331331
// RX mode, use dummy data instead of TX buffer
332-
tx_buffer = (uint8_t*)&dma_dummy_u32;
332+
tx_buffer = (const uint8_t*)&dma_dummy_u32;
333333
tx_mem_increase_mode = LL_DMA_MEMORY_NOINCREMENT;
334334
} else {
335335
tx_mem_increase_mode = LL_DMA_MEMORY_INCREMENT;

targets/furi_hal_include/furi_hal_spi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool furi_hal_spi_bus_trx(
118118
*/
119119
bool furi_hal_spi_bus_trx_dma(
120120
const FuriHalSpiBusHandle* handle,
121-
uint8_t* tx_buffer,
121+
const uint8_t* tx_buffer,
122122
uint8_t* rx_buffer,
123123
size_t size,
124124
uint32_t timeout_ms);

0 commit comments

Comments
 (0)