Hardware Abstraction Layer for FreeRTOS
sd_prv.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: MIT */
2
/*
3
* Author: Andreas Werner <kernel@andy89.org>
4
* Date: 2016
5
*/
6
#ifndef SD_PRV_H_
7
#define SD_PRV_H_
8
9
#define SD_PRV_
10
#ifndef SD_PRV
11
# error "Never include this file out of a SD driver"
12
#endif
13
#include <FreeRTOS.h>
14
#include <semphr.h>
15
#include <stdint.h>
16
#include <stdbool.h>
17
#include <
hal.h
>
18
enum
sd_responseLength
{
19
SD_NO_RESPONSE
,
20
SD_SHORT
,
21
SD_LONG
22
};
23
#define SD_ALREDY_INITED 1
24
int32_t
sd_genericInit
(
struct
sd *sd,
struct
sd_setting
*settings);
32
enum
sd_responseLength
sd_get_responseLength
(
struct
sd *sd, uint32_t command, uint32_t argument);
69
int32_t
sd_check_response
(
struct
sd *sd, uint32_t command, uint32_t argument,
struct
sd_response
*response);
70
#ifdef CONFIG_SD_THREAD_SAVE
71
# define sd_lock(u, w, e) HAL_LOCK(u, w, e)
72
# define sd_unlock(u, e) HAL_UNLOCK(u, e)
73
#else
74
# define sd_lock(u, w, e)
75
# define sd_unlock(u, e)
76
#endif
77
#define SD_ADDDEV(ns, p) HAL_ADDDEV(sd, ns, p)
78
HAL_DEFINE_GLOBAL_ARRAY
(sd);
79
#define SD_GET_DEV(index) HAL_GET_DEV(sd, index)
80
#ifndef CONFIG_SD_MULTI
81
# define SD_OPS(ns)
82
# define SD_INIT_DEV(ns)
83
84
# define SD_INIT(ns, index, s) struct sd *sd_init(uint32_t index, struct sd_setting *s)
85
# define SD_DEINIT(ns, p) int32_t sd_deinit(struct sd *p)
86
# define SD_SET_BLOCK_SIZE(ns, s, bs) int32_t sd_setBlockSize(struct sd *s, enum sd_block_size bs)
87
# define SD_SET_BUS_WIDE(ns, s, bw) int32_t sd_setBusWide(struct sd *s, enum sd_bus_wide bw)
88
# define SD_SET_CLOCK(ns, s, clk) int32_t sd_setClock(struct sd *s, uint64_t clk)
89
# 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)
90
# 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)
91
# 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)
92
# 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)
93
# 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)
94
# 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)
95
#else
96
# define SD_OPS(ns) static const struct sd_ops ns##_sd_ops = { \
97
.sd_init = &ns##_sd_init,\
98
.sd_deinit = &ns##_sd_deinit,\
99
.sd_setBlockSize = &ns##_sd_setBlockSize, \
100
.sd_setBusWide = &ns##_sd_setBusWide, \
101
.sd_setClock = &ns##_sd_setClock, \
102
.sd_sendCommand = &ns##_sd_sendCommand, \
103
.sd_write = &ns##_sd_write, \
104
.sd_read = &ns##_sd_read, \
105
.sd_sendCommandISR = &ns##_sd_sendCommandISR, \
106
.sd_writeISR = &ns##_sd_writeISR, \
107
.sd_readISR = &ns##_sd_readISR, \
108
}
109
# define SD_INIT_DEV(ns) .gen.ops = &ns##_sd_ops,
110
# define SD_INIT(ns, s) static struct sd *ns##_sd_init(uint32_t index, struct sd_setting *s)
111
# define SD_DEINIT(ns, p) static int32_t ns##_sd_deinit(struct sd *p)
112
# define SD_SET_BLOCK_SIZE(ns, s, bs) static int32_t ns##_sd_setBlockSize(struct sd *s, enum sd_block_size bs)
113
# define SD_SET_BUS_WIDE(ns, s, bw) static int32_t ns##_sd_setBusWide(struct sd *s, enum sd_bus_wide bw)
114
# define SD_SET_CLOCK(ns, s, clk) static int32_t ns##_sd_setClock(struct sd *s, uint64_t clk)
115
# define SD_SEND_COMMAND(ns, s, c, arg, r, w) static int32_t ns##_sd_sendCommand(struct sd *s, uint32_t c, uint32_t arg, struct sd_response *r, TickType_t w)
116
# define SD_WIRTE(ns, s, c, arg, l, d, w) static int32_t ns##_sd_write(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d, TickType_t w)
117
# define SD_READ(ns, s, c, arg, l, d, w) static int32_t ns##_sd_read(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d, TickType_t w)
118
# define SD_SEND_COMMAND_ISR(ns, s, c, arg, r) static int32_t ns##_sd_sendCommandISR(struct sd *s, uint32_t c, uint32_t arg, struct sd_response *r)
119
# define SD_WIRTE_ISR(ns, s, c, arg, l, d) static int32_t ns##_sd_writeISR(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d)
120
# define SD_READ_ISR(ns, s, c, arg, l, d) static int32_t ns##_sd_readISR(struct sd *s, uint32_t c, uint32_t arg, size_t l, uint32_t *d)
121
#endif
122
#endif
SD_LONG
@ SD_LONG
Definition:
sd_prv.h:21
sd_responseLength
sd_responseLength
Definition:
sd_prv.h:18
sd_genericInit
int32_t sd_genericInit(struct sd *sd, struct sd_setting *settings)
hal.h
sd_setting
Definition:
sd.h:206
sd_response
Definition:
sd.h:188
sd_check_response
int32_t sd_check_response(struct sd *sd, uint32_t command, uint32_t argument, struct sd_response *response)
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(sd)
sd_get_responseLength
enum sd_responseLength sd_get_responseLength(struct sd *sd, uint32_t command, uint32_t argument)
SD_SHORT
@ SD_SHORT
Definition:
sd_prv.h:20
SD_NO_RESPONSE
@ SD_NO_RESPONSE
Definition:
sd_prv.h:19
driver
include
sd_prv.h
Generated on Tue Aug 17 2021 15:19:23 for Hardware Abstraction Layer for FreeRTOS by
1.8.20