From 1e62b75be3e9cc5c3d3a685f7e6c4f44302241b7 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Thu, 11 Nov 2021 03:48:36 +0100 Subject: [PATCH] Namespace update for uSD part of Scialys support app --- v10/uSD.c | 24 ++++++++++++------------ v10/uSD.h | 24 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/v10/uSD.c b/v10/uSD.c index 831b33b..4a5b5bb 100644 --- a/v10/uSD.c +++ b/v10/uSD.c @@ -47,7 +47,7 @@ uint8_t mmc_data[MMC_BUF_SIZE]; #define SCIALYS_MAGIC "Scialys data bloc" /* Read 1 block of 512 bytes */ -int uSD_read(uint32_t block_num) +int scialys_uSD_read(uint32_t block_num) { int ret = 0; if (got_uSD == 0) { @@ -60,7 +60,7 @@ int uSD_read(uint32_t block_num) /* Write 1 block of 512 bytes */ -int uSD_write(uint32_t block_num) +int scialys_uSD_write(uint32_t block_num) { int ret = 0; if (got_uSD == 0) { @@ -73,7 +73,7 @@ int uSD_write(uint32_t block_num) /* Setup the first part of a data buffer (a 512 bytes uSD block) */ -int uSD_init_buffer(void) +int scialys_uSD_init_buffer(void) { int idx = 0; memset((char*)mmc_data, 0, MMC_BUF_SIZE); @@ -98,7 +98,7 @@ int uSD_init_buffer(void) /* Check that the first part of a data buffer is a valid data block */ -int uSD_data_buffer_is_valid(void) +int scialys_uSD_data_buffer_is_valid(void) { return strncmp((char*)mmc_data, SCIALYS_MAGIC, strlen(SCIALYS_MAGIC)); } @@ -117,7 +117,7 @@ static struct last_block_info last_block = { /* Find last log entry (last used uSD block) */ -int uSD_logs_init(int uart) +int scialys_uSD_logs_init(int uart) { int idx = 0, ret = 0; @@ -140,13 +140,13 @@ int uSD_logs_init(int uart) return 0; } - -int uSD_append_data(struct sd_data_blob* data) +/* Append data to temporary data buffer, and possibly flush data to uSD when buffer is full */ +int scialys_uSD_append_data(struct sd_data_blob* data) { static uint16_t index = 0; if (index == 0) { - index = uSD_init_buffer(); + index = scialys_uSD_init_buffer(); } /* Store data to buffer */ @@ -155,7 +155,7 @@ int uSD_append_data(struct sd_data_blob* data) /* Flush buffer to uSD ? */ if ((index + sizeof(struct sd_data_blob)) >= MMC_BUF_SIZE) { - int ret = uSD_write(last_block.block_num + 1); + int ret = scialys_uSD_write(last_block.block_num + 1); if (ret != 0) { uprintf(UART0, "Write to uSD returned %d\n", ret); return ret; @@ -180,7 +180,7 @@ int uSD_append_data(struct sd_data_blob* data) /* micro SD card init */ -int uSD_detect(int uart) +int scialys_uSD_detect(int uart) { int i = 0, loop = 0, ret = 0; #ifdef DEBUG @@ -233,14 +233,14 @@ int uSD_detect(int uart) /* uSD card detected */ got_uSD = 1; /* got_uSD MUST be set to 1 from here on ! */ - ret = uSD_read(0); /* Read 1 block at start of card */ + ret = scialys_uSD_read(0); /* Read 1 block at start of card */ /* FIXME : check that the card magic is present */ uprintf(uart, "uSD read (ret : %d) : %s\n", ret, mmc_data); return 0; } -void uSD_config(struct pio* uSD_cs, uint32_t ssp_bus_num) +void scialys_uSD_config(struct pio* uSD_cs, uint32_t ssp_bus_num) { memcpy(&(micro_sd.chip_select), uSD_cs, sizeof(struct pio)); micro_sd.ssp_bus_num = ssp_bus_num; diff --git a/v10/uSD.h b/v10/uSD.h index b025fc1..2bf065d 100644 --- a/v10/uSD.h +++ b/v10/uSD.h @@ -64,17 +64,29 @@ struct flags { extern struct sdmmc_card micro_sd; extern uint8_t mmc_data[MMC_BUF_SIZE]; -int uSD_read(uint32_t block_num); -int uSD_write(uint32_t block_num); +/* Read 1 block of 512 bytes */ +int scialys_uSD_read(uint32_t block_num); + +/* Write 1 block of 512 bytes */ +int scialys_uSD_write(uint32_t block_num); + +/* Append data to temporary data buffer, and possibly flush data to uSD when buffer is full */ +int scialys_uSD_append_data(struct sd_data_blob* data); + +/* Check that the first part of a data buffer is a valid data block */ +int scialys_uSD_data_buffer_is_valid(void); -int uSD_append_data(struct sd_data_blob* data); /***************************************************************************** */ /* microSD card init */ -int uSD_logs_init(int uart); -int uSD_detect(int uart); -void uSD_config(struct pio* uSD_cs, uint32_t ssp_bus_num); + +/* Find last log entry (last used uSD block) */ +int scialys_uSD_logs_init(int uart); + +int scialys_uSD_detect(int uart); + +void scialys_uSD_config(struct pio* uSD_cs, uint32_t ssp_bus_num); #endif /* USD_H */ -- 2.43.0