CuVoodoo STM32F1 firmware template
|
library to communicate with an SD card flash memory using the SPI mode (code) More...
Go to the source code of this file.
Macros | |
#define | FLASH_SDCARD_SPI 1 |
SPI peripheral. | |
Functions | |
static void | flash_sdcard_spi_wait (void) |
wait one SPI round (one SPI word) | |
static uint16_t | flash_sdcard_spi_read (void) |
read one SPI word More... | |
static bool | flash_sdcard_card_detect (void) |
test if card is present More... | |
static void | flash_sdcard_send_command (uint8_t index, uint32_t argument) |
transmit command token More... | |
static uint8_t | flash_sdcard_command_response (uint8_t index, uint32_t argument, uint8_t *response, size_t size) |
transmit command token and receive response token More... | |
static uint8_t | flash_sdcard_read_block (uint8_t *data, size_t size) |
read a data block More... | |
static uint8_t | flash_sdcard_write_block (uint8_t *data, size_t size) |
write a data block More... | |
static uint16_t | flash_sdcard_status (uint8_t *status) |
get card status More... | |
static uint8_t | flash_sdcard_data_read (uint8_t index, uint32_t argument, uint8_t *data, size_t size) |
transmit command token, receive response token and data block More... | |
static uint8_t | flash_sdcard_data_write (uint8_t index, uint32_t argument, uint8_t *data, size_t size) |
transmit command token, receive response token and write data block More... | |
bool | flash_sdcard_setup (void) |
setup communication with SD card More... | |
uint64_t | flash_sdcard_size (void) |
get size of SD card flash memory More... | |
uint32_t | flash_sdcard_erase_size (void) |
get size of a erase block More... | |
bool | flash_sdcard_read_data (uint32_t block, uint8_t *data) |
read data on flash of SD card More... | |
bool | flash_sdcard_write_data (uint32_t block, uint8_t *data) |
write data on flash of SD card More... | |
Variables | |
static bool | initialized = false |
if the card has been initialized successfully | |
static uint32_t | n_ac = 8 |
maximum N_AC value (in 8-clock cycles) (time between the response token R1 and data block when reading data (see section 7.5.4) More... | |
static bool | sdsc = false |
is it a Standard Capacity SD card (true), or High Capacity SD cards (false) More... | |
static uint64_t | sdcard_size = 0 |
size of card in bytes | |
static uint32_t | erase_size = 0 |
size of an erase block bytes | |
static const uint8_t | crc7_table [] |
table for CRC-7 calculation for the command messages (see section 4.5) More... | |
library to communicate with an SD card flash memory using the SPI mode (code)
Definition in file flash_sdcard.c.
|
static |
test if card is present
Definition at line 106 of file flash_sdcard.c.
|
static |
transmit command token and receive response token
[in] | index | command index |
[in] | argument | command argument |
[out] | response | response data to read (if no error occurred) |
[in] | size | size of response to read |
Definition at line 137 of file flash_sdcard.c.
|
static |
transmit command token, receive response token and data block
[in] | index | command index |
[in] | argument | command argument |
[out] | data | data block to read (if no error occurred) |
[in] | size | size of data to read (a multiple of 2) |
Definition at line 309 of file flash_sdcard.c.
|
static |
transmit command token, receive response token and write data block
[in] | index | command index |
[in] | argument | command argument |
[out] | data | data block to write |
[in] | size | size of data to write (a multiple of 2) |
Definition at line 349 of file flash_sdcard.c.
uint32_t flash_sdcard_erase_size | ( | void | ) |
get size of a erase block
Definition at line 562 of file flash_sdcard.c.
|
static |
read a data block
[out] | data | data block to read (if no error occurred) |
[in] | size | size of response to read (a multiple of 2) |
Definition at line 168 of file flash_sdcard.c.
bool flash_sdcard_read_data | ( | uint32_t | block, |
uint8_t * | data | ||
) |
read data on flash of SD card
[in] | block | address of data to read (in block in 512 bytes unit) |
[out] | data | data block to read (with a size of 512 bytes) |
Definition at line 567 of file flash_sdcard.c.
|
static |
transmit command token
[in] | index | command index |
[in] | argument | command argument |
Definition at line 118 of file flash_sdcard.c.
bool flash_sdcard_setup | ( | void | ) |
setup communication with SD card
Definition at line 381 of file flash_sdcard.c.
uint64_t flash_sdcard_size | ( | void | ) |
get size of SD card flash memory
Definition at line 557 of file flash_sdcard.c.
|
static |
|
static |
get card status
[out] | status | SD status (512 bits) |
Definition at line 265 of file flash_sdcard.c.
|
static |
write a data block
[in] | data | data block to write |
[in] | size | size of response to read (a multiple of 2) |
Definition at line 222 of file flash_sdcard.c.
bool flash_sdcard_write_data | ( | uint32_t | block, |
uint8_t * | data | ||
) |
write data on flash of SD card
[in] | block | address of data to write (in block in 512 bytes unit) |
[in] | data | data block to write (with a size of 512 bytes) |
Definition at line 582 of file flash_sdcard.c.
|
static |
table for CRC-7 calculation for the command messages (see section 4.5)
Definition at line 64 of file flash_sdcard.c.
|
static |
maximum N_AC value (in 8-clock cycles) (time between the response token R1 and data block when reading data (see section 7.5.4)
Definition at line 49 of file flash_sdcard.c.
|
static |
is it a Standard Capacity SD card (true), or High Capacity SD cards (false)
Definition at line 54 of file flash_sdcard.c.