Hardware Abstraction Layer for FreeRTOS
sd_prv.h File Reference
#include <FreeRTOS.h>
#include <semphr.h>
#include <stdint.h>
#include <stdbool.h>
#include <hal.h>
Include dependency graph for sd_prv.h:

Go to the source code of this file.

Macros

#define SD_PRV_
 
#define SD_ALREDY_INITED   1
 
#define sd_lock(u, w, e)
 
#define sd_unlock(u, e)
 
#define SD_ADDDEV(ns, p)   HAL_ADDDEV(sd, ns, p)
 
#define SD_GET_DEV(index)   HAL_GET_DEV(sd, index)
 
#define SD_OPS(ns)
 
#define SD_INIT_DEV(ns)
 
#define SD_INIT(ns, index, s)   struct sd *sd_init(uint32_t index, struct sd_setting *s)
 
#define SD_DEINIT(ns, p)   int32_t sd_deinit(struct sd *p)
 
#define SD_SET_BLOCK_SIZE(ns, s, bs)   int32_t sd_setBlockSize(struct sd *s, enum sd_block_size bs)
 
#define SD_SET_BUS_WIDE(ns, s, bw)   int32_t sd_setBusWide(struct sd *s, enum sd_bus_wide bw)
 
#define SD_SET_CLOCK(ns, s, clk)   int32_t sd_setClock(struct sd *s, uint64_t clk)
 
#define SD_SEND_COMMAND(ns, s, c, arg, r, w)   int32_t sd_sendCommand(struct sd *s, uint32_t c, uint32_t arg, struct sd_response *r, TickType_t w)
 
#define SD_WIRTE(ns, s, c, arg, l, d, w)   int32_t sd_write(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d, TickType_t w)
 
#define SD_READ(ns, s, c, arg, l, d, w)   int32_t sd_read(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d, TickType_t w)
 
#define SD_SEND_COMMAND_ISR(ns, s, c, arg, r)   int32_t sd_sendCommandISR(struct sd *s, uint32_t c, uint32_t arg, struct sd_response *r)
 
#define SD_WIRTE_ISR(ns, s, c, arg, l, d)   int32_t sd_writeISR(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d)
 
#define SD_READ_ISR(ns, s, c, arg, l, d)   int32_t sd_readISR(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d)
 

Enumerations

enum  sd_responseLength { SD_NO_RESPONSE, SD_SHORT, SD_LONG }
 

Functions

int32_t sd_genericInit (struct sd *sd, struct sd_setting *settings)
 
enum sd_responseLength sd_get_responseLength (struct sd *sd, uint32_t command, uint32_t argument)
 
int32_t sd_check_response (struct sd *sd, uint32_t command, uint32_t argument, struct sd_response *response)
 
 HAL_DEFINE_GLOBAL_ARRAY (sd)
 

Macro Definition Documentation

◆ SD_ADDDEV

#define SD_ADDDEV (   ns,
 
)    HAL_ADDDEV(sd, ns, p)

◆ SD_ALREDY_INITED

#define SD_ALREDY_INITED   1

◆ SD_DEINIT

#define SD_DEINIT (   ns,
 
)    int32_t sd_deinit(struct sd *p)

◆ SD_GET_DEV

#define SD_GET_DEV (   index)    HAL_GET_DEV(sd, index)

◆ SD_INIT

#define SD_INIT (   ns,
  index,
 
)    struct sd *sd_init(uint32_t index, struct sd_setting *s)

◆ SD_INIT_DEV

#define SD_INIT_DEV (   ns)

◆ sd_lock

#define sd_lock (   u,
  w,
 
)

◆ SD_OPS

#define SD_OPS (   ns)

◆ SD_PRV_

#define SD_PRV_

◆ SD_READ

#define SD_READ (   ns,
  s,
  c,
  arg,
  l,
  d,
 
)    int32_t sd_read(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d, TickType_t w)

◆ SD_READ_ISR

#define SD_READ_ISR (   ns,
  s,
  c,
  arg,
  l,
 
)    int32_t sd_readISR(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d)

◆ SD_SEND_COMMAND

#define SD_SEND_COMMAND (   ns,
  s,
  c,
  arg,
  r,
 
)    int32_t sd_sendCommand(struct sd *s, uint32_t c, uint32_t arg, struct sd_response *r, TickType_t w)

◆ SD_SEND_COMMAND_ISR

#define SD_SEND_COMMAND_ISR (   ns,
  s,
  c,
  arg,
 
)    int32_t sd_sendCommandISR(struct sd *s, uint32_t c, uint32_t arg, struct sd_response *r)

◆ SD_SET_BLOCK_SIZE

#define SD_SET_BLOCK_SIZE (   ns,
  s,
  bs 
)    int32_t sd_setBlockSize(struct sd *s, enum sd_block_size bs)

◆ SD_SET_BUS_WIDE

#define SD_SET_BUS_WIDE (   ns,
  s,
  bw 
)    int32_t sd_setBusWide(struct sd *s, enum sd_bus_wide bw)

◆ SD_SET_CLOCK

#define SD_SET_CLOCK (   ns,
  s,
  clk 
)    int32_t sd_setClock(struct sd *s, uint64_t clk)

◆ sd_unlock

#define sd_unlock (   u,
 
)

◆ SD_WIRTE

#define SD_WIRTE (   ns,
  s,
  c,
  arg,
  l,
  d,
 
)    int32_t sd_write(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d, TickType_t w)

◆ SD_WIRTE_ISR

#define SD_WIRTE_ISR (   ns,
  s,
  c,
  arg,
  l,
 
)    int32_t sd_writeISR(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d)

Enumeration Type Documentation

◆ sd_responseLength

Enumerator
SD_NO_RESPONSE 
SD_SHORT 
SD_LONG 

Function Documentation

◆ HAL_DEFINE_GLOBAL_ARRAY()

HAL_DEFINE_GLOBAL_ARRAY ( sd  )

◆ sd_check_response()

int32_t sd_check_response ( struct sd *  sd,
uint32_t  command,
uint32_t  argument,
struct sd_response response 
)

Check SD Response

Parameters
sdSD Instance
commandCommand
argumentArgument
responseResponse form Card
Returns
< 0 on error 0 on ok -1 == Unkown Error Is Response == R2, R3, R4 and R7 return is always 0 Is Response == R1 following error can occur (Desciption in Standart s. Card Status) SD_ERROR_AKE_SEQ_ERROR -2 SD_ERROR_ERROR -3 SD_ERROR_CC_ERROR -4 SD_ERROR_CARD_ECC_FAIELD -5 SD_ERROR_ILLEGAL_COMMAND -6 SD_ERROR_COM_CRC_ERROR -7 SD_ERROR_LOCK_UNLOCK_FAILED -8 SD_ERROR_CARD_IS_LOCKED -9 SD_ERROR_WP_VIOLATION -10 SD_ERROR_ERASE_PARAM -11 SD_ERROR_ERASE_SEQ_ERROR -12 SD_ERROR_ERASE_LEN_ERROR -13 SD_ERROR_ADDRESS_ERROR -14 SD_ERROR_OUT_OF_RANGE -15 Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5) SD_ERROR_ERROR -3 SD_ERROR_ILLEGAL_COMMAND -6 SD_ERROR_COM_CRC_ERROR -7 SD_ERROR_OUT_OF_RANGE -15 SD_ERROR_FUNCTION_NUMBER -16 Is Response == R6 following error can occur (Desciption in Standart Response R6) SD_ERROR_AKE_SEQ_ERROR -2 SD_ERROR_ERROR -3 SD_ERROR_ILLEGAL_COMMAND -6 SD_ERROR_COM_CRC_ERROR -7

◆ sd_genericInit()

int32_t sd_genericInit ( struct sd *  sd,
struct sd_setting settings 
)

◆ sd_get_responseLength()

enum sd_responseLength sd_get_responseLength ( struct sd *  sd,
uint32_t  command,
uint32_t  argument 
)

Return size of Response Fild

Parameters
sdSD Instance
commandCommand
argumentArgument
Returns
SD_SHORT for 48 Bit Response and SD_LONG for 136 Bit Response