picoAPI  1.0.0
SDCard

Typedefs

typedef void * picoFile
 
typedef enum picoFileAccess picoFileAccess
 

Enumerations

enum  picoFileAccess { picoFILE_READ, picoFILE_WRITE, picoFILE_APPEND }
 

Functions

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)
 

Detailed Description

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!

Typedef Documentation

typedef void* picoFile

file pointer

file access types

Enumeration Type Documentation

file access types

Enumerator
picoFILE_READ 

open file for reading

picoFILE_WRITE 

open file for writing

picoFILE_APPEND 

open file for appending

Function Documentation

uint32_t picoSDAppendAll ( char *  filename,
void *  data,
uint32_t  datalen 
)

append data to file, open before and close after operation

Parameters
filenamename of the file
datadata to append
datalenlength of the data in bytes
Returns
number of bytes appended
void picoSDClose ( picoFile  file)

close access to file

Parameters
filepicoFile given by picoSDOpen
int32_t picoSDEndOfFile ( picoFile  f)

check end of file

Parameters
fpicoFile given by picoSDOpen
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

Here is the call graph for this function:

picoFile picoSDOpen ( char *  filename,
picoFileAccess  fileAccess 
)

open file for read and write operations

Parameters
filenamename of the file
fileAccesspicoFileAccess 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
filepicoFile given by picoSDOpen
stringnull-terminated string to write
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
filepicoFile given by picoSDOpen
databuffer to store data
lenlength 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
filenamename of the file
datadata to be read
datalenlength 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
filepicoFile given by picoSDOpen
datadata to be written
lenlength of the data in bytes
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
filenamename of the file
datadata to be written
datalenlength of the data in bytes
Returns
number of bytes written