|
int32_t | picoSDInit (void) |
|
uint32_t | picoSDWriteAll (char *filename, void *data, uint32_t datalen) |
|
uint32_t | picoSDReadAll (char *filename, void *data, uint32_t datalen) |
|
uint32_t | picoSDAppendAll (char *filename, void *data, uint32_t datalen) |
|
picoFile | picoSDOpen (char *filename, picoFileAccess fileAccess) |
|
void | picoSDClose (picoFile file) |
|
uint32_t | picoSDRead (picoFile file, void *data, uint32_t len) |
|
uint32_t | picoSDWrite (picoFile file, void *data, uint32_t len) |
|
uint32_t | picoSDPrint (picoFile file, char *string) |
|
int32_t | picoSDEndOfFile (picoFile f) |
|
Access to SD cards using SPI0
Connect the picoCIAA to the SDCard as follows:
picoCIAA | Signal | SDCard |
P6_11 | SPI0_MOSI | 2 CMD/DI |
P6_12 | SPI0_SCK | 5 CLK/SCK |
P6_13 | SPI0_SSEL0 | 1 DAT3/nCS |
P6_14 | SPI0_MISO | 7 DAT0/DO |
- Warning
- SD interface uses SPI0, do not use SD API and SPI API with SPI0 at the same time!
file access types
Enumerator |
---|
picoFILE_READ |
open file for reading
|
picoFILE_WRITE |
open file for writing
|
picoFILE_APPEND |
open file for appending
|
uint32_t picoSDAppendAll |
( |
char * |
filename, |
|
|
void * |
data, |
|
|
uint32_t |
datalen |
|
) |
| |
append data to file, open before and close after operation
- Parameters
-
filename | name of the file |
data | data to append |
datalen | length of the data in bytes |
- Returns
- number of bytes appended
close access to file
- Parameters
-
check end of file
- Parameters
-
- Returns
- true (!= 0) if end of file reached, false (== 0) otherwise
int32_t picoSDInit |
( |
void |
| ) |
|
init SPI interface to SD card.
- Returns
- 0 in case of successful initialization, -1 if error
open file for read and write operations
- Parameters
-
filename | name of the file |
fileAccess | picoFileAccess access type (READ, WRITE or APPEND) |
- Returns
- a file pointer picoFile, or NULL on error
uint32_t picoSDPrint |
( |
picoFile |
file, |
|
|
char * |
string |
|
) |
| |
write null-terminated string to previously open file
- Parameters
-
- Returns
- number of chars written, or 0 on error
uint32_t picoSDRead |
( |
picoFile |
file, |
|
|
void * |
data, |
|
|
uint32_t |
len |
|
) |
| |
read data from previously open file
- Parameters
-
file | picoFile given by picoSDOpen |
data | buffer to store data |
len | length of the buffer in bytes |
- Returns
- number of bytes read, or 0 on error
uint32_t picoSDReadAll |
( |
char * |
filename, |
|
|
void * |
data, |
|
|
uint32_t |
datalen |
|
) |
| |
read data from file, open before and close after operation
- Parameters
-
filename | name of the file |
data | data to be read |
datalen | length of the data buffer in bytes |
- Returns
- number of bytes read
uint32_t picoSDWrite |
( |
picoFile |
file, |
|
|
void * |
data, |
|
|
uint32_t |
len |
|
) |
| |
write data to previously open file
- Parameters
-
- Returns
- number of bytes written, or 0 on error
uint32_t picoSDWriteAll |
( |
char * |
filename, |
|
|
void * |
data, |
|
|
uint32_t |
datalen |
|
) |
| |
write data to file, open before and close after operation
- Parameters
-
filename | name of the file |
data | data to be written |
datalen | length of the data in bytes |
- Returns
- number of bytes written