123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- #ifndef APP_SDCARD_H_
- #define APP_SDCARD_H_
- #include "app_util_platform.h"
- #include "sdk_config.h"
- #define SDC_SECTOR_SIZE 512
- #define APP_SDCARD_CONFIG(MOSI_PIN, MISO_PIN, SCK_PIN, CS_PIN) { \
- .mosi_pin = MOSI_PIN, \
- .miso_pin = MISO_PIN, \
- .sck_pin = SCK_PIN, \
- .cs_pin = CS_PIN \
- }
- typedef enum {
- SDC_SUCCESS = 0,
- SDC_ERROR_NOT_RESPONDING,
- SDC_ERROR_TIMEOUT,
- SDC_ERROR_NOT_SUPPORTED,
- SDC_ERROR_COMMUNICATION,
- SDC_ERROR_DATA,
- SDC_ERROR_INTERNAL,
- } sdc_result_t;
- typedef enum {
- SDC_EVT_INIT = 0,
- SDC_EVT_READ,
- SDC_EVT_WRITE
- } sdc_evt_type_t;
- typedef struct {
- sdc_evt_type_t type;
- sdc_result_t result;
- } sdc_evt_t;
- typedef enum {
- SDC_TYPE_UNKNOWN = 0,
- SDC_TYPE_MMCV3,
- SDC_TYPE_SDV1,
- SDC_TYPE_SDV2
- } sdc_version_t;
- typedef struct {
- sdc_version_t version : 3;
- uint8_t sdhc : 1;
- } sdc_type_t;
- typedef struct {
- uint8_t mosi_pin;
- uint8_t miso_pin;
- uint8_t sck_pin;
- uint8_t cs_pin;
- } app_sdc_config_t;
- typedef struct {
- uint32_t num_blocks;
- uint16_t block_len;
- sdc_type_t type;
- } app_sdc_info_t;
- typedef void (*sdc_event_handler_t)(sdc_evt_t const * p_event);
- ret_code_t app_sdc_init(app_sdc_config_t const * const p_config, sdc_event_handler_t event_handler);
- ret_code_t app_sdc_uninit(void);
- bool app_sdc_busy_check(void);
- ret_code_t app_sdc_block_read(uint8_t * p_buf, uint32_t block_address, uint16_t block_count);
- ret_code_t app_sdc_block_write(uint8_t const * p_buf, uint32_t block_address, uint16_t block_count);
- app_sdc_info_t const * app_sdc_info_get(void);
- #endif
|