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

 SD Card interface implementation
More...

#include "sdcard.h"
#include "dev/watchdog.h"
#include <util/delay.h>

Go to the source code of this file.

Macros

#define SDCARD_CMD0   0
 CMD0 – GO_IDLE_STATE.
 
#define SDCARD_CMD1   1
 CMD1 – SEND_OP_COND.
 
#define SDCARD_CMD8   8
 CMD8 – SEND_IF_COND (deprecated?)
 
#define SDCARD_CMD9   9
 CMD9 – SEND_CSD.
 
#define SDCARD_CMD10   10
 CMD10 – SEND_CID.
 
#define SDCARD_CMD13   13
 CMD13 – SEND_STATUS.
 
#define SDCARD_CMD16   16
 CMD16 – SET_BLOCKLEN.
 
#define SDCARD_CMD17   17
 CMD17 – READ_SINGLE_BLOCK.
 
#define SDCARD_CMD18   18
 CMD18 – READ_MULTIPLE_BLOCK.
 
#define SDCARD_CMD24   24
 CMD24 – WRITE_BLOCK.
 
#define SDCARD_CMD25   25
 CMD25 – WRITE_MULTIPLE_BLOCK.
 
#define SDCARD_CMD27   27
 CMD27 – PROGRAM_CSD.
 
#define SDCARD_CMD32   32
 CMD32 – ERASE_WR_BLK_START_ADDR.
 
#define SDCARD_CMD33   33
 CMD33 – ERASE_WR_BLK_END_ADDR.
 
#define SDCARD_CMD38   38
 CMD38 – ERASE.
 
#define SDCARD_CMD58   58
 CMD58 – READ_OCR.
 
#define SDCARD_CMD59   59
 CMD59 – CRC_ON_OFF.
 
#define SDCARD_CMD55   55
 CMD55 – APP_CMD.
 
#define SDCARD_ACMD23   (IS_ACMD | 23)
 ACMD23 – SET_WR_BLK_ERASE_COUNT.
 
#define SDCARD_ACMD41   (IS_ACMD | 41)
 ACMD41 – SD_SEND_OP_COND.
 

Functions

uint64_t sdcard_get_card_size ()
 Returns card size. More...
 
uint32_t sdcard_get_block_num ()
 
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...
 
uint8_t sdcard_read_csd (uint8_t *buffer)
 This function will read the CSD (16 Bytes) of the SD-Card. More...
 
void sdcard_cmd_crc (uint8_t *cmd)
 This function calculates the CRC7 for SD Card commands. More...
 
uint16_t sdcard_data_crc (uint8_t *data)
 This function calculates the CRC16 for a 512 Byte data block. More...
 
uint8_t sdcard_init (void)
 Initializes the SD Card. More...
 
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...
 

Detailed Description

 SD Card interface implementation
Author
Original source: Ulrich Radig << modified by >> 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 e.joe.nosp@m.rns@.nosp@m.tu-bs.nosp@m..de

Definition in file sdcard.c.