Author | Matthew Schinkel - borntechi.com, copyright © 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4q2 |
this library provides functions for SD memory cards.
SanDisk Secure Digital Card - http://www.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf How to use MMC/SDC - http://forums.parallax.com/forums/attach.aspx?a=32012
SD card SPI mode is 1,1
var bit sd_error = FALSE
const byte SD_SEND_OP_COND = 1
const SD_CARD = 1
const bit SD_STANDARD_CAPACITY = 1
const byte SD_CLR_WRITE_PROT = 29
const byte SD_ERASE_WR_BLK_END = 33
const byte SD_COM_CRC_ERROR = 3
const byte SD_SEND_IF_COND = 8
const DATA_MEDIA = SD_CARD
const byte SD_SEND_CSD = 9
const word SD_BYTE_PER_SECTOR = 512
const byte SD_STOP_TRANSMISSION = 12
const byte SD_WRITE_MULTIPLE_BLOCK = 25
const byte SD_SEND_STATUS = 13
var dword sd_number_of_sectors
const byte SD_PROGRAM_CSD = 27
const byte SD_ILLEGAL_COMMAND = 2
const byte SD_CRC_ON_OFF = 59
var word sd_sector_count = 0
const byte SD_SEND_NUM_WR_BLOCKS = 22
const byte SD_SET_CLR_CARD_DETECT = 42
const byte SD_WRITE_BLOCK = 24
var bit sd_card_type = 0
const bit SD_HIGH_CAPACITY = 0
const byte SD_SET_BLOCKLEN = 16
const byte SD_SEND_WRITE_PROT = 30
const byte SD_READ_SINGLE_BLOCK = 17
const byte SD_SD_APP_OP_COND = 41
const byte SD_ERASE_RESET = 1
const byte SD_SEND_SCR = 51
const byte SD_PARAMETER_ERROR = 6
const byte SD_READ_MULTIPLE_BLOCK = 18
const PATA_HARD_DISK = 0
const byte SD_ERASE_WR_BLK_START = 32
const byte SD_IN_IDLE_STATE = 0
var dword sd_sector_select
const byte SD_GEN_CMD = 56
const byte SD_SEND_CID = 10
const byte SD_APP_CMD = 55
const byte SD_SD_STATUS = 13
const byte SD_ERASE = 38
const byte SD_ADDRESS_ERROR = 5
const byte SD_GO_IDLE_STATE = 0
const byte SD_SET_WR_BLK_ERASE_COUNT = 23
const byte SD_READ_OCR = 58
const byte SD_ERASE_SEQUENCE_ERROR = 4
var word sd_byte_count = 0
const byte SD_SET_WRITE_PROT = 28
sd_read_sector_address(dword in address)
sd_stop_read()
sd_write_pulse(byte in count1)
sd_write_sector_with_callback(word in chunk_size)
sd_stop_write()
sd_get_number_of_sectors()
send_command(byte in command,dword in data, byte out response)
sd_sector_buffer'put(word in address, byte in data)
sd_set_idle()
sd_print_sector_hex(volatile byte out device,word in bytes_per_line,dword in address)
sd_write_sector_address(dword in address)
sd_ready()
sd_read_pulse_byte(word in count1)
sd_read_sector_with_callback(word in chunk_size)
sd_start_write(dword in address)
sd_write_to_sector_end(byte in input_byte)
sd_init()
sd_print_sector(volatile byte out device, dword in address)
sd_write_pulse_byte(word in count1)
sd_write_sector()
sd_read_sector()
sd_start_read(dword in address)
sd_data_byte'put(byte in data_byte)
var bit sd_error = FALSE
misc variables
const byte SD_SEND_OP_COND = 1
No documentation found
const SD_CARD = 1
No documentation found
const bit SD_STANDARD_CAPACITY = 1
No documentation found
const byte SD_CLR_WRITE_PROT = 29
No documentation found
const byte SD_ERASE_WR_BLK_END = 33
No documentation found
const byte SD_COM_CRC_ERROR = 3
No documentation found
const byte SD_SEND_IF_COND = 8
for SDHC only
const DATA_MEDIA = SD_CARD
No documentation found
const byte SD_SEND_CSD = 9
sd sends "Card Specific Data" standard or high capacity
const word SD_BYTE_PER_SECTOR = 512
No documentation found
const byte SD_STOP_TRANSMISSION = 12
No documentation found
const byte SD_WRITE_MULTIPLE_BLOCK = 25
No documentation found
const byte SD_SEND_STATUS = 13
No documentation found
var dword sd_number_of_sectors
number of sectors variable
const byte SD_PROGRAM_CSD = 27
No documentation found
const byte SD_ILLEGAL_COMMAND = 2
No documentation found
const byte SD_CRC_ON_OFF = 59
default is off
var word sd_sector_count = 0
No documentation found
const byte SD_SEND_NUM_WR_BLOCKS = 22
No documentation found
const byte SD_SET_CLR_CARD_DETECT = 42
No documentation found
const byte SD_WRITE_BLOCK = 24
Write Commands
var bit sd_card_type = 0
No documentation found
const bit SD_HIGH_CAPACITY = 0
No documentation found
const byte SD_SET_BLOCKLEN = 16
Read Commands
const byte SD_SEND_WRITE_PROT = 30
No documentation found
const byte SD_READ_SINGLE_BLOCK = 17
No documentation found
const byte SD_SD_APP_OP_COND = 41
No documentation found
const byte SD_ERASE_RESET = 1
No documentation found
const byte SD_SEND_SCR = 51
No documentation found
const byte SD_PARAMETER_ERROR = 6
No documentation found
const byte SD_READ_MULTIPLE_BLOCK = 18
No documentation found
const PATA_HARD_DISK = 0
constants for fat32 library
const byte SD_ERASE_WR_BLK_START = 32
Erase Commands
const byte SD_IN_IDLE_STATE = 0
R1 RESPONCE BITS
var dword sd_sector_select
No documentation found
const byte SD_GEN_CMD = 56
No documentation found
const byte SD_SEND_CID = 10
No documentation found
const byte SD_APP_CMD = 55
Application Specific Commands
const byte SD_SD_STATUS = 13
application specific command, must write command 55 first
const byte SD_ERASE = 38
No documentation found
const byte SD_ADDRESS_ERROR = 5
No documentation found
const byte SD_GO_IDLE_STATE = 0
Basic Commands
const byte SD_SET_WR_BLK_ERASE_COUNT = 23
No documentation found
const byte SD_READ_OCR = 58
Other Commands
const byte SD_ERASE_SEQUENCE_ERROR = 4
No documentation found
var word sd_byte_count = 0
counters
const byte SD_SET_WRITE_PROT = 28
Write Protection Commands
sd_read_sector_address(dword in address)
read one entire sector at address
sd_stop_read()
tell sd card you are finished reading needed to be the same as other mass media libs
sd_write_pulse(byte in count1)
No documentation found
sd_write_sector_with_callback(word in chunk_size)
sd_stop_write()
tell sd card you are finished writing
sd_get_number_of_sectors()
Gets sd card size in number of sectors into dword sd_number_of_sectors Total size in bytes = sd_number_of_sectors * 512
send_command(byte in command,dword in data, byte out response)
send a command to the sd card (commands with 1 response only)
sd_sector_buffer'put(word in address, byte in data)
No documentation found
sd_set_idle()
set the sd card to idle state
sd_print_sector_hex(volatile byte out device,word in bytes_per_line,dword in address)
print a sector to an output device in ascii hex
sd_write_sector_address(dword in address)
write one entire sector at address
sd_ready()
check if the sd card is ready after last command.
sd_read_pulse_byte(word in count1)
send a read pulse to the sd card, go 1 bytes forward in current sector.
sd_read_sector_with_callback(word in chunk_size)
No documentation found
sd_start_write(dword in address)
tell sd card you will be writing data to a specified sector must write 1 sector at a time, SD_BYTE_PER_SECTOR bytes do not interupt write process by switching to another spi component
sd_write_to_sector_end(byte in input_byte)
write till sector is finished with input byte data does not actually get written till you get to the end of the sector
sd_init()
initalize the sd card in SPI data transfer mode.
sd_print_sector(volatile byte out device, dword in address)
print a sector to an output device
sd_write_pulse_byte(word in count1)
No documentation found
sd_write_sector()
write one entire sector
sd_read_sector()
read one entire sector
sd_start_read(dword in address)
tell sd card you will be reading data from a specified sector do not interupt read process by switching to another spi component
sd_data_byte'put(byte in data_byte)
write 1 byte to the sd card (pseudo var)
_sd_read_512()
Extra speed read procedure
_sd_write_512()
Extra speed write procedure
sd_sector_buffer'get(word in address) return byte
define the sector buffer. Can be read as sd_sector_buffer[0-511]
sd_data_byte'get() return byte
read 1 bytes from the sd card (pseudo var)
16f877 | 16f877_sd_card.jal |
16f877 | 16f877_fat32_small_sd_card.jal |
16f877a | 16f877a_sd_card.jal |
16f877a | 16f877a_fat32_small_sd_card.jal |
18f27j53 | 18f27j53_sd_card_minix_demo.jal |
18f27j53 | 18f27j53_sd_card_minix_read.jal |
18f27j53 | 18f27j53_sd_card_minix_readi.jal |
18f452 | 18f452_fat32_small_sd_card.jal |
18f452 | 18f452_sd_card.jal |
18f4525 | 18f4525_fat32_sd_card.jal |
18f4525 | 18f4525_mp3_decoder_vs1053b_sd_card.jal |
18f4525 | 18f4525_sd_card.jal |
18f4525 | 18f4525_fat32_small_sd_card.jal |
18f4550 | 18f4550_sd_card.jal |
18f4550 | 18f4550_fat32_small_sd_card.jal |
18f4550 | 18f4550_fat32_sd_card.jal |
18f4620 | 18f4620_mp3_decoder_vs1053b_sd_card.jal |
18f4620 | 18f4620_sd_card.jal |
18f4620 | 18f4620_fat32_small_sd_card.jal |
18f4620 | 18f4620_fat32_sd_card.jal |
18f67j50 | 18f67j50_sd_card.jal |
18f67j50 | 18f67j50_mp3_decoder_vs1053b_sd_card.jal |
18f67j50 | 18f67j50_usb_msd_sd_card.jal |
18f67j50 | 18f67j50_fat32_usb_msd_sd_card.jal |
18f67j50 | 18f67j50_fat32_sd_card.jal |
18f67j50 | 18f67j50_fat32_small_sd_card.jal |