Contiki-Inga 3.x
Macros | Functions
sdcard.h File Reference

    SD Card interface definitions
More...

#include "mspi.h"
#include <stdio.h>

Go to the source code of this file.

Macros

#define MICRO_SD_CS   5
 
Interface return codes
#define SDCARD_SUCCESS   0
 Successfully completed operation.
 
#define SDCARD_REJECTED   2
 Indicates the host cannot handle this card, maybe due to rejected voltage range.
 
#define SDCARD_CMD_TIMEOUT   4
 Timeout while trying to send command.
 
#define SDCARD_CMD_ERROR   3
 Card sent an error response.
 
#define SDCARD_DATA_TIMEOUT   6
 Card did not send a data start byte to indicate beginning of a data block.
 
#define SDCARD_DATA_ERROR   7
 Card returned error when trying to read or write data. More...
 
#define SDCARD_BUSY_TIMEOUT   8
 Busy waiting timed out (card held down data line too long)
 
#define SDCARD_CSD_ERROR   10
 Failed reading CSD register.
 

Functions

uint8_t sdcard_init (void)
 Initializes the SD Card. More...
 
uint8_t sdcard_read_csd (uint8_t *buffer)
 This function will read the CSD (16 Bytes) of the SD-Card. More...
 
uint16_t sdcard_get_block_size ()
 Returns the size of one block in bytes. More...
 
uint8_t sdcard_is_SDSC ()
 This function indicates if a card is a SDSC or SDHC/SDXC card. More...
 
uint8_t sdcard_set_CRC (uint8_t enable)
 Turns crc capabilities of the card on or off. More...
 
uint64_t sdcard_get_card_size ()
 Returns card size. More...
 
uint32_t sdcard_get_block_num ()
 
uint8_t sdcard_erase_blocks (uint32_t startaddr, uint32_t endaddr)
 
uint8_t sdcard_read_block (uint32_t addr, uint8_t *buffer)
 This function will read one block (512, 1024, 2048 or 4096Byte) of the SD-Card. More...
 
uint8_t sdcard_write_block (uint32_t addr, uint8_t *buffer)
 This function will write one block (512, 1024, 2048 or 4096Byte) of the SD-Card. More...
 
uint8_t sdcard_write_multi_block_start (uint32_t addr, uint32_t num_blocks)
 Prepares to write multiple blocks sequentially. More...
 
uint8_t sdcard_write_multi_block_next (uint8_t *buffer)
 Writes single of multiple sequental blocks. More...
 
uint8_t sdcard_write_multi_block_stop ()
 Stops multiple block write. More...
 
uint8_t sdcard_write_cmd (uint8_t cmd, uint32_t *arg, uint8_t *resp)
 This function sends a command via SPI to the SD-Card. More...
 
uint16_t sdcard_data_crc (uint8_t *data)
 This function calculates the CRC16 for a 512 Byte data block. More...
 

Detailed Description

    SD Card interface definitions
Author
Ulf Kulau kulau.nosp@m.@ibr.nosp@m..cs.t.nosp@m.u-bs.nosp@m..de Christoph Peltz peltz.nosp@m.@ibr.nosp@m..cs.t.nosp@m.u-bs.nosp@m..de Enrico Joerns joern.nosp@m.s@ib.nosp@m.r.cs..nosp@m.tu-b.nosp@m.s.de

Definition in file sdcard.h.