Skip to content

Commit 360245f

Browse files
committed
[peripheral, tests, docs] Rename peripheral drivers to <chip>_<type> convention. Move spi_loopback test into spi/. Add platform test support to main.c for all device type
1 parent 1a67509 commit 360245f

23 files changed

Lines changed: 132 additions & 47 deletions

boards/peripheral/Makefile.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ BOARD_SOURCE += $(_PERIPHERAL_DIR)/peripheral.c
55
ifneq ($(filter sdhc_spi_sdcard32gb,$(PERIPHERALS)),)
66
CFLAGS += -DPERIPHERAL_SDHC_SPI_SDCARD32GB
77
BOARD_SOURCE += $(_PERIPHERAL_DIR)/block/sdhc_spi_sdcard32gb.c
8-
BOARD_SOURCE += $(WHAL_DIR)/src/block/sdhc_spi.c
8+
BOARD_SOURCE += $(WHAL_DIR)/src/block/sdhc_spi_block.c
99
endif
1010

1111
ifneq ($(filter spi_nor_w25q64,$(PERIPHERALS)),)
1212
CFLAGS += -DPERIPHERAL_SPI_NOR_W25Q64
1313
BOARD_SOURCE += $(_PERIPHERAL_DIR)/flash/spi_nor_w25q64.c
14-
BOARD_SOURCE += $(WHAL_DIR)/src/flash/spi_nor.c
14+
BOARD_SOURCE += $(WHAL_DIR)/src/flash/spi_nor_flash.c
1515
endif
1616

1717
ifneq ($(filter bmi270,$(PERIPHERALS)),)
1818
CFLAGS += -DPERIPHERAL_BMI270
1919
BOARD_SOURCE += $(_PERIPHERAL_DIR)/sensor/imu/bmi270.c
20-
BOARD_SOURCE += $(WHAL_DIR)/src/sensor/imu/bmi270.c
20+
BOARD_SOURCE += $(WHAL_DIR)/src/sensor/imu/bmi270_sensor.c
2121
BOARD_SOURCE += $(WHAL_DIR)/src/sensor/imu/bmi270_config_data.c
2222
endif

boards/peripheral/block/sdhc_spi_sdcard32gb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "sdhc_spi_sdcard32gb.h"
2-
#include <wolfHAL/block/sdhc_spi.h>
2+
#include <wolfHAL/block/sdhc_spi_block.h>
33
#include "board.h"
44

55
static whal_Spi_ComCfg g_sdcardComCfg = {

boards/peripheral/block/sdhc_spi_sdcard32gb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <wolfHAL/wolfHAL.h>
55
#include <wolfHAL/block/block.h>
6-
#include <wolfHAL/block/sdhc_spi.h>
6+
#include <wolfHAL/block/sdhc_spi_block.h>
77

88
extern whal_Block g_whalSdhcSpiSdcard32gb;
99

boards/peripheral/flash/spi_nor_w25q64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "spi_nor_w25q64.h"
2-
#include <wolfHAL/flash/spi_nor.h>
2+
#include <wolfHAL/flash/spi_nor_flash.h>
33
#include "board.h"
44

55
/*

boards/peripheral/flash/spi_nor_w25q64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <wolfHAL/wolfHAL.h>
55
#include <wolfHAL/flash/flash.h>
6-
#include <wolfHAL/flash/spi_nor.h>
6+
#include <wolfHAL/flash/spi_nor_flash.h>
77

88
extern whal_Flash g_whalSpiNorW25q64;
99

boards/peripheral/sensor/imu/bmi270.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "bmi270.h"
2-
#include <wolfHAL/sensor/imu/bmi270.h>
2+
#include <wolfHAL/sensor/imu/bmi270_sensor.h>
33
#include <wolfHAL/sensor/imu/bmi270_config_data.h>
44
#include "board.h"
55

boards/peripheral/sensor/imu/bmi270.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <wolfHAL/wolfHAL.h>
55
#include <wolfHAL/sensor/sensor.h>
6-
#include <wolfHAL/sensor/imu/bmi270.h>
6+
#include <wolfHAL/sensor/imu/bmi270_sensor.h>
77

88
extern whal_Sensor g_whalBmi270;
99

boards/stm32h563zi_nucleo/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stddef.h>
55
#include "board.h"
66
#include <wolfHAL/platform/st/stm32h563xx.h>
7-
#include <wolfHAL/eth_phy/lan8742a.h>
7+
#include <wolfHAL/eth_phy/lan8742a_eth_phy.h>
88
#include "peripheral.h"
99

1010
/* SysTick timing */

docs/adding_a_peripheral.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Declare the global device instance:
5050

5151
#include <wolfHAL/wolfHAL.h>
5252
#include <wolfHAL/flash/flash.h>
53-
#include <wolfHAL/flash/spi_nor.h>
53+
#include <wolfHAL/flash/spi_nor_flash.h>
5454

5555
extern whal_Flash g_whalSpiNorW25q64;
5656

@@ -65,7 +65,7 @@ globals (`g_whalSpi`, `g_whalGpio`, `SPI_CS_PIN`, `g_whalTimeout`) from
6565

6666
```c
6767
#include "spi_nor_w25q64.h"
68-
#include <wolfHAL/flash/spi_nor.h>
68+
#include <wolfHAL/flash/spi_nor_flash.h>
6969
#include "board.h"
7070

7171
#define W25Q64_PAGE_SZ 256
@@ -168,8 +168,16 @@ framework.
168168

169169
## Naming Convention
170170

171-
- Flag: `PERIPHERAL_<NAME>` (e.g., `PERIPHERAL_BMI270`)
172-
- PERIPHERALS variable: lowercase name (e.g., `bmi270`, `spi_nor_w25q64`)
171+
Instance files are named `<driver>_<instance>`:
172+
173+
- `sdhc_spi_sdcard32gb` — sdhc_spi driver, 32GB SD card
174+
- `spi_nor_w25q64` — spi_nor driver, W25Q64 chip
175+
- `bmi270` — bmi270 driver (single instance, no qualifier needed)
176+
177+
Summary:
178+
173179
- Directory: `boards/peripheral/<type>/` (e.g., `flash/`, `block/`, `sensor/imu/`)
174-
- Files: `<name>.h` and `<name>.c`
175-
- Global instance: `g_whal<Name>` (e.g., `g_whalBmi270`, `g_whalSpiNorW25q64`)
180+
- Files: `<driver>.h` and `<driver>.c` for single-instance peripherals; otherwise `<driver>_<instance>.h` and `<driver>_<instance>.c`
181+
- Flag: `PERIPHERAL_<NAME>` (e.g., `PERIPHERAL_SPI_NOR_W25Q64`)
182+
- PERIPHERALS variable: lowercase name (e.g., `spi_nor_w25q64`, `bmi270`)
183+
- Global instance: `g_whal<Name>` (e.g., `g_whalSpiNorW25q64`, `g_whalBmi270`)

docs/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ This eliminates the vtable indirection and lets the compiler inline or optimize
277277
the calls more aggressively.
278278
279279
Register-level drivers do not call other drivers internally, so this works
280-
without any caveats. Bus-device drivers (e.g., SPI flash) still call their
280+
without any caveats. Peripheral drivers (e.g., SPI flash) still call their
281281
bus driver through the vtable.
282282
283283
## Next Steps

0 commit comments

Comments
 (0)