File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 2424
2525#include <pbdrv/block_device.h>
2626#include <pbdrv/clock.h>
27+ #include <pbdrv/compiler.h>
2728#include <pbdrv/gpio.h>
2829
2930#include <tiam1808/edma.h>
@@ -486,8 +487,8 @@ static pbio_error_t spi_begin_for_flash(
486487
487488 spi_dev .status = SPI_STATUS_WAIT_TX | SPI_STATUS_WAIT_RX ;
488489
489- // TODO: pbio probably needs a framework for memory barriers and DMA cache management
490- __asm__ volatile ( "" ::: "memory" );
490+ // TODO: eventually needs DMA cache management
491+ pbdrv_compiler_memory_barrier ( );
491492
492493 EDMA3EnableTransfer (SOC_EDMA30CC_0_REGS , EDMA3_CHA_SPI0_TX , EDMA3_TRIG_MODE_EVENT );
493494 EDMA3EnableTransfer (SOC_EDMA30CC_0_REGS , EDMA3_CHA_SPI0_RX , EDMA3_TRIG_MODE_EVENT );
@@ -805,8 +806,8 @@ static pbio_error_t pbdrv_block_device_ev3_spi_begin_for_adc(const uint32_t *cmd
805806
806807 spi_dev .status = SPI_STATUS_WAIT_TX | SPI_STATUS_WAIT_RX ;
807808
808- // TODO: pbio probably needs a framework for memory barriers and DMA cache management
809- __asm__ volatile ( "" ::: "memory" );
809+ // TODO: eventually needs DMA cache management
810+ pbdrv_compiler_memory_barrier ( );
810811
811812 EDMA3EnableTransfer (SOC_EDMA30CC_0_REGS , EDMA3_CHA_SPI0_TX , EDMA3_TRIG_MODE_EVENT );
812813 EDMA3EnableTransfer (SOC_EDMA30CC_0_REGS , EDMA3_CHA_SPI0_RX , EDMA3_TRIG_MODE_EVENT );
Original file line number Diff line number Diff line change 99
1010#include <stdbool.h>
1111
12+ #include <pbdrv/compiler.h>
1213#include <pbdrv/reset.h>
1314#include <pbdrv/gpio.h>
1415
@@ -63,7 +64,7 @@ void pbdrv_reset(pbdrv_reset_action_t action) {
6364 break ;
6465 case PBDRV_RESET_ACTION_RESET_IN_UPDATE_MODE :
6566 ev3_persistent_data .bootloader_update_flag = BOOTLOADER_UPDATE_MODE_VALUE ;
66- __attribute__(( fallthrough )) ;
67+ PBDRV_FALL_THROUGH ;
6768 default :
6869 // PBDRV_RESET_ACTION_RESET
6970
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ // Copyright (c) 2025 The Pybricks Authors
3+
4+ #ifndef _PBDRV_COMPILER_H_
5+
6+ // Marks a switch case that intentionally falls through to the next one
7+ #define PBDRV_FALL_THROUGH __attribute__((fallthrough))
8+
9+ // Forces the compiler to not reorder memory access around this line
10+ #define pbdrv_compiler_memory_barrier () __asm__ volatile ("" ::: "memory")
11+
12+ #endif
You can’t perform that action at this time.
0 commit comments