ulibSD – a library for use SD cards in SPI mode with uControllers

Contents hide

ulibSD

It’s a library for use SD cards in SPI mode with uControllers, entirely writtenin C. This library can work with SD cards and also has the possibility to emulate the behavior in a PC file (GNU/Linux) using the macro _M_IX86. It’s for debugging purposes. The data transfer is oriented to 512 byte size,
remember this.

Public methods

ulibSD has four public methods:

  • SD_Init: Initialization the SD card.
  • SD_Read: Read a single block of data.
  • SD_Write: Write a single block of data.
  • SD_Status: Allows know status of SD card.

Those methods require a device descriptor.

How is possible port the code to my platform?

This library uses a spi_io.h header. Here are defined the low-level methods
associated with the hardware. Those methods are:

  • SPI_Init: Initialize SPI hardware.
  • SPI_RW: Read/Write a single byte. Returns the byte that arrived.
  • SPI_Release: Flush of SPI buffer.
  • SPI_CS_Low: Selecting function in SPI terms, associated with SPI module.
  • SPI_CS_High: Deselecting function in SPI terms, associated with SPI module.
  • SPI_Freq_High: Setting frequency of SPI’s clock to maximun possible.
  • SPI_Freq_Low: Setting frequency of SPI’s clock equal or lower than 400kHz.
  • SPI_Timer_On: Start a non-blocking timer in milliseconds.
  • SPI_Timer_Status: Check the status of non-blocking timer.
  • SPI_Timer_Off: Stop of non-blocking timer.

You need write the proper code for this methods. I leave a spi_io.c.example
file for use as guideline. I hope this helps to you understand how is the logic
of portability. This example is for KL25Z board using my OpenKL25Z framework.

Also you need verify and adapt the integer types in the integer.h file.

Read more: ulibSD – a library for use SD cards in SPI mode with uControllers


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top