Documentation ¶
Overview ¶
package sdcard provides a TinyGo driver for sdcard/mmc devices using a SPI connection.
To use a file system on the SDcard, please see the TinyFS repo:
Index ¶
- Constants
- type CID
- type CSD
- type Device
- func (d *Device) Configure() error
- func (dev *Device) EraseBlockSize() int64
- func (dev *Device) EraseBlocks(start, len int64) error
- func (dev *Device) ReadAt(buf []byte, addr int64) (int, error)
- func (d Device) ReadCID(csd []byte) error
- func (d Device) ReadCSD(csd []byte) error
- func (d Device) ReadData(block uint32, dst []byte) error
- func (dev *Device) Size() int64
- func (dev *Device) WriteAt(buf []byte, addr int64) (n int, err error)
- func (dev *Device) WriteBlockSize() int64
- func (d Device) WriteData(block uint32, src []byte) error
- func (d Device) WriteMulti(buf []byte) error
- func (d Device) WriteMultiStart(block uint32) error
- func (d Device) WriteMultiStop() error
Constants ¶
View Source
const ( CMD0_GO_IDLE_STATE = 0 CMD1_SEND_OP_CND = 1 CMD2_ALL_SEND_CID = 2 CMD3_SEND_RELATIVE_ADDR = 3 CMD4_SET_DSR = 4 CMD6_SWITCH_FUNC = 6 CMD7_SELECT_DESELECT_CARD = 7 CMD8_SEND_IF_COND = 8 CMD9_SEND_CSD = 9 CMD10_SEND_CID = 10 CMD12_STOP_TRANSMISSION = 12 CMD13_SEND_STATUS = 13 CMD15_GO_INACTIVE_STATE = 15 CMD16_SET_BLOCKLEN = 16 CMD17_READ_SINGLE_BLOCK = 17 CMD18_READ_MULTIPLE_BLOCK = 18 CMD24_WRITE_BLOCK = 24 CMD25_WRITE_MULTIPLE_BLOCK = 25 CMD27_PROGRAM_CSD = 27 CMD28_SET_WRITE_PROT = 28 CMD29_CLR_WRITE_PROT = 29 CMD30_SEND_WRITE_PROT = 30 CMD32_ERASE_WR_BLK_START_ADDR = 32 CMD33_ERASE_WR_BLK_END_ADDR = 33 CMD38_ERASE = 38 CMD42_LOCK_UNLOCK = 42 CMD55_APP_CMD = 55 CMD56_GEN_CMD = 56 CMD58_READ_OCR = 58 CMD59_CRC_ON_OFF = 59 ACMD6_SET_BUS_WIDTH = 6 ACMD13_SD_STATUS = 13 ACMD22_SEND_NUM_WR_BLOCKS = 22 ACMD23_SET_WR_BLK_ERASE_COUNT = 23 ACMD41_SD_APP_OP_COND = 41 ACMD42_SET_CLR_CARD_DETECT = 42 ACMD51_SEND_SCR = 51 ACMD18_SECURE_READ_MULTI_BLOCK = 18 ACMD25_SECURE_WRITE_MULTI_BLOCK = 25 ACMD26_SECURE_WRITE_MKB = 26 ACMD38_SECURE_ERASE = 38 ACMD43_GET_MKB = 43 ACMD44_GET_MID = 44 ACMD45_SET_CER_RN1 = 45 ACMD46_SET_CER_RN2 = 46 ACMD47_SET_CER_RES2 = 47 ACMD48_SET_CER_RES1 = 48 ACMD49_CHANGE_SECURE_AREA = 49 )
View Source
const ( // card types SD_CARD_TYPE_SD1 = 1 // Standard capacity V1 SD card SD_CARD_TYPE_SD2 = 2 // Standard capacity V2 SD card SD_CARD_TYPE_SDHC = 3 // High Capacity SD card )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CID ¶
type CID struct { //// byte 0 ManufacturerID byte //uint8_t mid; // Manufacturer ID //// byte 1-2 OEMApplicationID uint16 //char oid[2]; // OEM/Application ID //// byte 3-7 ProductName string //char pnm[5]; // Product name //// byte 8 ProductVersion string //unsigned prv_m : 4; // Product revision n.m //unsigned prv_n : 4; //// byte 9-12 ProductSerialNumber uint32 //uint32_t psn; // Product serial number //// byte 13 ManufacturingYear byte ManufacturingMonth byte //unsigned mdt_year_high : 4; // Manufacturing date //unsigned reserved : 4; //// byte 14 //unsigned mdt_month : 4; //unsigned mdt_year_low : 4; //// byte 15 Always1 byte //unsigned always1 : 1; CRC byte }
type CSD ¶
type CSD struct { CSD_STRUCTURE byte // 2 R [127:126] 0x01 : CSD Structure TAAC byte // 8 R [119:112] 0x0E : Data Read Access-Time-1 NSAC byte // 8 R [111:104] 0x00 : Data Read Access-Time-2 in CLK Cycles (NSAC*100) TRAN_SPEED byte // 8 R [103:96] 0x5A : Max. Data Transfer Rate CCC uint16 // 12 R [95:84] 0x5B5 : Card Command Classes READ_BL_LEN byte // 4 R [83:80] 0x09 : Max. Read Data Block Length READ_BL_PARTIAL byte // 1 R [79:79] 0x00 : Partial Blocks for Read Allowed WRITE_BLK_MISALIGN byte // 1 R [78:78] 0x00 : Write Block Misalignment READ_BLK_MISALIGN byte // 1 R [77:77] 0x00 : Read Block Misalignment DSR_IMP byte // 1 R [76:76] 0x00 : DSR Implemented C_SIZE uint32 // 22 R [69:48] 0xXXXXXX : Device Size ERASE_BLK_EN byte // 1 R [46:46] 0x01 : Erase Single Block Enable SECTOR_SIZE byte // 7 R [45:39] 0x7F : Erase Sector Size WP_GRP_SIZE byte // 7 R [38:32] 0x00 : Write Protect Group Size WP_GRP_ENABLE byte // 1 R [31:31] 0x00 : Write Protect Group Enable R2W_FACTOR byte // 3 R [28:26] 0x02 : Write Speed Factor WRITE_BL_LEN byte // 4 R [25:22] 0x09 : Max. Write data Block Length WRITE_BL_PARTIAL byte // 1 R [21:21] 0x00 : Partial Blocks for Write Allowed FILE_FORMAT_GRP byte // 1 R [15:15] 0x00 : File Format Group COPY byte // 1 RW [14:14] 0x00 :Copy Flag PERM_WRITE_PROTECT byte // 1 RW [13:13] 0x00 : Permanent Write Protection TMP_WRITE_PROTECT byte // 1 RW [12:12] 0x00 : Temporary Write Protection FILE_FORMAT byte // 2 R [11:10] 0x00 : File Format CRC byte // 7 RW [7:1] 0xXX : CRC }
type Device ¶
func (*Device) EraseBlockSize ¶
EraseBlockSize returns the smallest erasable area on this sdcard in bytes.
func (*Device) EraseBlocks ¶
EraseBlocks erases the given number of blocks.
func (*Device) WriteBlockSize ¶
WriteBlockSize returns the block size in which data can be written to memory.
func (Device) WriteMulti ¶
WriteMulti performs continuous writing. It is necessary to call WriteMultiStart() in prior.
func (Device) WriteMultiStart ¶
WriteMultiStart starts the continuous write mode using CMD25.
func (Device) WriteMultiStop ¶
WriteMultiStop exits the continuous write mode.
Click to show internal directories.
Click to hide internal directories.