I2SD library

Photo by FlorinC

This library has a single class call I2SD with simple interface (see below).  A call to Wire.begin() must be made before any of these calls.  See Hello World to see a simple example of the library in use.

  /* Transmit n_byte bytes of data to I2SD card.
   * return true if identical bytes are returned from I2SD card
   */
  boolean ping(uint8_t* ping_data, uint8_t n_byte);

  /* Move file cursor to addr bytes from the beginning of the file
   */
  void seek(unsigned long addr);

  /* Open a file with the specified name and mode
   * May induce I2SD_OPEN_ERROR on I2SD card
   */
  void open(char* filename, uint8_t mode);

  /* Read n_byte bytes of the current file.
   * File must be open for reading
   */
  uint8_t read(uint8_t *data, uint8_t n_byte);

  /* Write n_byte bytes of data to current file
   * File must be open for writing
   * May induce I2SD_MODE_ERROR on I2SD card
   */
  void write(uint8_t *data, uint8_t n_byte);

  /* Clear any error on I2SD card.
   * May induce I2SD_MODE_ERROR on I2SD card
   */
  void clear_error();

**************************************************************************************************************

Oops: ATTN Vic and Florin!

While writing this I realized I left a bug in the inital version of the code.  The I2SD will show an error if the file “DEFAULT.TXT” is not present on the SD card.   So add that file to the root.  It does not have to have any bytes.  It just provides a default file pointer.  This will be taken care of in the next version, or you can delete the offending lines and re-load the script.

**************************************************************************************************************

Leave a Reply