Hanna
Sourcecode Batteriemanagementsystem
Makrodefinitionen | Funktionen | Variablen
sd_raw.c-Dateireferenz

SD-Card Reader Bibliothek von Roland Riegel. MMC/SD/SDHC raw access implementation (license: GPLv2 or LGPLv2.1) Mehr ...

#include <string.h>
#include <stdio.h>
#include <avr/io.h>
#include "sd_raw.h"
#include "port_driver.h"
Include-Abhängigkeitsdiagramm für sd_raw.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define CMD_APP   0x37
 
#define CMD_CLR_WRITE_PROT   0x1d
 
#define CMD_CRC_ON_OFF   0x3b
 
#define CMD_ERASE   0x26
 
#define CMD_GO_IDLE_STATE   0x00
 
#define CMD_LOCK_UNLOCK   0x2a
 
#define CMD_PROGRAM_CSD   0x1b
 
#define CMD_READ_MULTIPLE_BLOCK   0x12
 
#define CMD_READ_OCR   0x3a
 
#define CMD_READ_SINGLE_BLOCK   0x11
 
#define CMD_SD_SEND_OP_COND   0x29
 
#define CMD_SEND_CID   0x0a
 
#define CMD_SEND_CSD   0x09
 
#define CMD_SEND_IF_COND   0x08
 
#define CMD_SEND_OP_COND   0x01
 
#define CMD_SEND_STATUS   0x0d
 
#define CMD_SEND_WRITE_PROT   0x1e
 
#define CMD_SET_BLOCKLEN   0x10
 
#define CMD_SET_WRITE_PROT   0x1c
 
#define CMD_STOP_TRANSMISSION   0x0c
 
#define CMD_TAG_ERASE_GROUP_END   0x24
 
#define CMD_TAG_ERASE_GROUP_START   0x23
 
#define CMD_TAG_SECTOR_END   0x21
 
#define CMD_TAG_SECTOR_START   0x20
 
#define CMD_UNTAG_ERASE_GROUP   0x25
 
#define CMD_UNTAG_SECTOR   0x22
 
#define CMD_WRITE_MULTIPLE_BLOCK   0x19
 
#define CMD_WRITE_SINGLE_BLOCK   0x18
 
#define DR_STATUS_ACCEPTED   0x05
 
#define DR_STATUS_CRC_ERR   0x0a
 
#define DR_STATUS_MASK   0x0e
 
#define DR_STATUS_WRITE_ERR   0x0c
 
#define R1_ADDR_ERR   5
 
#define R1_COM_CRC_ERR   3
 
#define R1_ERASE_RESET   1
 
#define R1_ERASE_SEQ_ERR   4
 
#define R1_IDLE_STATE   0
 
#define R1_ILL_COMMAND   2
 
#define R1_PARAM_ERR   6
 
#define R2_ADDR_ERR   (R1_ADDR_ERR + 8)
 
#define R2_CARD_ECC_FAIL   4
 
#define R2_CARD_ERR   3
 
#define R2_CARD_LOCKED   0
 
#define R2_COM_CRC_ERR   (R1_COM_CRC_ERR + 8)
 
#define R2_CSD_OVERWRITE   7
 
#define R2_ERASE_RESET   (R1_ERASE_RESET + 8)
 
#define R2_ERASE_SEQ_ERR   (R1_ERASE_SEQ_ERR + 8)
 
#define R2_ERR   2
 
#define R2_IDLE_STATE   (R1_IDLE_STATE + 8)
 
#define R2_ILL_COMMAND   (R1_ILL_COMMAND + 8)
 
#define R2_INVAL_ERASE   6
 
#define R2_OUT_OF_RANGE   7
 
#define R2_PARAM_ERR   (R1_PARAM_ERR + 8)
 
#define R2_WP_ERASE_SKIP   1
 
#define R2_WP_VIOLATION   5
 
#define R3_ADDR_ERR   (R1_ADDR_ERR + 32)
 
#define R3_COM_CRC_ERR   (R1_COM_CRC_ERR + 32)
 
#define R3_ERASE_RESET   (R1_ERASE_RESET + 32)
 
#define R3_ERASE_SEQ_ERR   (R1_ERASE_SEQ_ERR + 32)
 
#define R3_IDLE_STATE   (R1_IDLE_STATE + 32)
 
#define R3_ILL_COMMAND   (R1_ILL_COMMAND + 32)
 
#define R3_OCR_MASK   (0xffffffffUL)
 
#define R3_PARAM_ERR   (R1_PARAM_ERR + 32)
 
#define SD_RAW_SPEC_1   0
 
#define SD_RAW_SPEC_2   1
 
#define SD_RAW_SPEC_SDHC   2
 

Funktionen

uint8_t sd_raw_available ()
 
uint8_t sd_raw_get_info (struct sd_raw_info *info)
 
uint8_t sd_raw_init ()
 
uint8_t sd_raw_locked ()
 
uint8_t sd_raw_read (offset_t offset, uint8_t *buffer, uintptr_t length)
 
uint8_t sd_raw_read_interval (offset_t offset, uint8_t *buffer, uintptr_t interval, uintptr_t length, sd_raw_read_interval_handler_t callback, void *p)
 
static uint8_t sd_raw_rec_byte ()
 
static void sd_raw_send_byte (uint8_t b)
 
static uint8_t sd_raw_send_command (uint8_t command, uint32_t arg)
 
uint8_t sd_raw_sync ()
 
uint8_t sd_raw_write (offset_t offset, const uint8_t *buffer, uintptr_t length)
 
uint8_t sd_raw_write_interval (offset_t offset, uint8_t *buffer, uintptr_t length, sd_raw_write_interval_handler_t callback, void *p)
 

Variablen

static uint8_t raw_block [512]
 
static offset_t raw_block_address
 
static uint8_t raw_block_written
 
static uint8_t sd_raw_card_type
 

Ausführliche Beschreibung

SD-Card Reader Bibliothek von Roland Riegel. MMC/SD/SDHC raw access implementation (license: GPLv2 or LGPLv2.1)

Autoren
Copyright (c) 2006-2011 by Roland Riegel feedb.nosp@m.ack@.nosp@m.rolan.nosp@m.d-ri.nosp@m.egel..nosp@m.de, Anpassungen Hanna Burggraf
Datum
2011 / 15.01.2016
            $Revision: 465 $
            $Date: 2016-04-02 12:42:42 +0200 (Sat, 02 Apr 2016) $

This module implements read and write access to MMC, SD and SDHC cards. It serves as a low-level driver for the higher level modules such as partition and file system access.

Definiert in Datei sd_raw.c.