external-flash-write.ino
Illustrates access to external storage memory via the SPI bus.
The board has 16 MB of external flash (likely via SPI). This code requires a specific driver for the flash chip model (e.g., W25Qxx). Check the CS, MOSI, MISO, CLK pins of the SPI used for flash. Write operations often require prior page or sector erasure.
external-flash-write.ino
#include "stm32c5xx_hal.h"
// Supposons que le driver SPI Flash (ex: W25Q128) est implémenté
// #include "spi_flash.h"
extern SPI_HandleTypeDef hspi2;
uint8_t write_buf[] = "Seeed XIAO STM32C5";
uint8_t read_buf[20];
int main(void) {
HAL_Init();
// Init SPI pour Flash Externe
// ... HAL_SPI_Init(&hspi2) ...
while(1) {
// Écrire à l'adresse 0
Flash_Write(0, write_buf, sizeof(write_buf));
HAL_Delay(100);
// Lire depuis l'adresse 0
Flash_Read(0, read_buf, sizeof(write_buf));
// Vérification simple
if (memcmp(write_buf, read_buf, sizeof(write_buf)) == 0) {
// Succès
}
HAL_Delay(1000);
}
}