#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) {
/* 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) {
/* 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);
/* 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));
}
/* 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;
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 */
/* 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;
/* micro SD card init */
-int uSD_detect(int uart)
+int scialys_uSD_detect(int uart)
{
int i = 0, loop = 0, ret = 0;
#ifdef DEBUG
/* 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;
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 */