21#if VSF_HAL_USE_SPI == ENABLED
23#define vsf_real_spi_t VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_t)
24#define vsf_real_spi_capability VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_capability)
26#ifndef VSF_SPI_CFG_REIMPLEMENT_API_CAPABILITY
27# define VSF_SPI_CFG_REIMPLEMENT_API_CAPABILITY DISABLED
30#ifdef VSF_SPI_CFG_IMP_REMAP_PREFIX
31# undef VSF_SPI_CFG_REIMPLEMENT_API_CAPABILITY
32# define VSF_SPI_CFG_REIMPLEMENT_API_CAPABILITY ENABLED
35#if VSF_SPI_CFG_REIMPLEMENT_API_CAPABILITY == DISABLED
36# ifndef VSF_SPI_CFG_CAPABILITY_SUPPORT_AUTO_CS
37# define VSF_SPI_CFG_CAPABILITY_SUPPORT_AUTO_CS 1
39# ifndef VSF_SPI_CFG_CAPABILITY_SUPPORT_MANUAL_CS
40# define VSF_SPI_CFG_CAPABILITY_SUPPORT_MANUAL_CS 1
42# ifndef VSF_SPI_CFG_CAPABILITY_CS_COUNT
43# define VSF_SPI_CFG_CAPABILITY_CS_COUNT 1
45# ifndef VSF_SPI_CFG_CAPABILITY_MAX_CLOCK_HZ
46# define VSF_SPI_CFG_CAPABILITY_MAX_CLOCK_HZ 0xFFFFFFFF
48# ifndef VSF_SPI_CFG_CAPABILITY_MIN_CLOCK_HZ
49# define VSF_SPI_CFG_CAPABILITY_MIN_CLOCK_HZ 1
55#if VSF_SPI_CFG_REIMPLEMENT_API_CAPABILITY == DISABLED
60 .support_software_cs = VSF_SPI_CFG_CAPABILITY_SUPPORT_MANUAL_CS,
61 .cs_count = VSF_SPI_CFG_CAPABILITY_CS_COUNT,
62 .max_clock_hz = VSF_SPI_CFG_CAPABILITY_MAX_CLOCK_HZ,
63 .min_clock_hz = VSF_SPI_CFG_CAPABILITY_MIN_CLOCK_HZ,
66 return spi_capability;
72#undef VSF_SPI_CFG_CAPABILITY_SUPPORT_AUTO_CS
73#undef VSF_SPI_CFG_CAPABILITY_SUPPORT_MANUAL_CS
74#undef VSF_SPI_CFG_CAPABILITY_CS_COUNT
75#undef VSF_SPI_CFG_CAPABILITY_MAX_CLOCK_HZ
76#undef VSF_SPI_CFG_CAPABILITY_MIN_CLOCK_HZ
78#undef vsf_real_spi_capability
86#ifdef VSF_SPI_CFG_IMP_REMAP_PREFIX
88# define vsf_imp_spi_t VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_t)
89# define vsf_imp_spi_init VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_init)
90# define vsf_imp_spi_enable VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_enable)
91# define vsf_imp_spi_disable VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_disable)
92# define vsf_imp_spi_irq_enable VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_irq_enable)
93# define vsf_imp_spi_irq_disable VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_irq_disable)
94# define vsf_imp_spi_status VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_status)
95# define vsf_imp_spi_capability VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_capability)
96# define vsf_imp_spi_cs_active VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_cs_active)
97# define vsf_imp_spi_cs_inactive VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_cs_inactive)
98# define vsf_imp_spi_fifo_transfer VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_fifo_transfer)
99# define vsf_imp_spi_request_transfer VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_request_transfer)
100# define vsf_imp_spi_cancel_transfer VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_cancel_transfer)
101# define vsf_imp_spi_get_transferred_count VSF_MCONNECT(VSF_SPI_CFG_IMP_PREFIX, _spi_get_transferred_count)
103# define vsf_remap_spi_t VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_t)
104# define vsf_remap_spi_init VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_init)
105# define vsf_remap_spi_enable VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_enable)
106# define vsf_remap_spi_disable VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_disable)
107# define vsf_remap_spi_irq_enable VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_irq_enable)
108# define vsf_remap_spi_irq_disable VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_irq_disable)
109# define vsf_remap_spi_status VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_status)
110# define vsf_remap_spi_capability VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_capability)
111# define vsf_remap_spi_cs_active VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_cs_active)
112# define vsf_remap_spi_cs_inactive VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_cs_inactive)
113# define vsf_remap_spi_fifo_transfer VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_fifo_transfer)
114# define vsf_remap_spi_request_transfer VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_request_transfer)
115# define vsf_remap_spi_cancel_transfer VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_cancel_transfer)
116# define vsf_remap_spi_get_transferred_count VSF_MCONNECT(VSF_SPI_CFG_IMP_REMAP_PREFIX, _spi_get_transferred_count)
118# define VSF_SPI_CFG_IMP_REMAP_FUNCTIONS \
119 vsf_err_t vsf_imp_spi_init(vsf_imp_spi_t *spi_ptr, vsf_spi_cfg_t *cfg_ptr) \
121 VSF_HAL_ASSERT(spi_ptr != NULL); \
122 return vsf_remap_spi_init(spi_ptr, cfg_ptr); \
124 void vsf_imp_spi_fini(vsf_imp_spi_t *spi_ptr) \
126 VSF_HAL_ASSERT(spi_ptr != NULL); \
127 vsf_remap_spi_fini(spi_ptr); \
129 fsm_rt_t vsf_imp_spi_enable(vsf_imp_spi_t *spi_ptr) \
131 VSF_HAL_ASSERT(spi_ptr != NULL); \
132 return vsf_remap_spi_enable(spi_ptr); \
134 fsm_rt_t vsf_imp_spi_disable(vsf_imp_spi_t *spi_ptr) \
136 VSF_HAL_ASSERT(spi_ptr != NULL); \
137 return vsf_remap_spi_disable(spi_ptr); \
139 void vsf_imp_spi_irq_enable(vsf_imp_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) \
141 VSF_HAL_ASSERT(spi_ptr != NULL); \
142 vsf_remap_spi_irq_enable(spi_ptr, irq_mask); \
144 void vsf_imp_spi_irq_disable(vsf_imp_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) \
146 VSF_HAL_ASSERT(spi_ptr != NULL); \
147 vsf_remap_spi_irq_disable(spi_ptr, irq_mask); \
149 vsf_spi_status_t vsf_imp_spi_status(vsf_imp_spi_t *spi_ptr) \
151 VSF_HAL_ASSERT(spi_ptr != NULL); \
152 return vsf_remap_spi_status(spi_ptr); \
154 void vsf_imp_spi_cs_active(vsf_imp_spi_t *spi_ptr, uint_fast8_t index) \
156 VSF_HAL_ASSERT(spi_ptr != NULL); \
157 vsf_remap_spi_cs_active(spi_ptr, index); \
159 void vsf_imp_spi_cs_inactive(vsf_imp_spi_t *spi_ptr, uint_fast8_t index) \
161 VSF_HAL_ASSERT(spi_ptr != NULL); \
162 vsf_remap_spi_cs_inactive(spi_ptr, index); \
164 void vsf_imp_spi_fifo_transfer(vsf_imp_spi_t *spi_ptr, \
165 void *out_buffer_ptr, \
166 uint_fast32_t* out_offset_ptr, \
167 void *in_buffer_ptr, \
168 uint_fast32_t* in_offset_ptr, \
171 VSF_HAL_ASSERT(spi_ptr != NULL); \
172 vsf_remap_spi_fifo_transfer(spi_ptr, \
173 out_buffer_ptr, out_offset_ptr, \
174 in_buffer_ptr, in_offset_ptr, \
177 vsf_err_t vsf_imp_spi_request_transfer(vsf_imp_spi_t *spi_ptr, void *out_buffer_ptr, \
178 void *in_buffer_ptr, uint_fast32_t count) \
180 VSF_HAL_ASSERT(spi_ptr != NULL); \
181 return vsf_remap_spi_request_transfer(spi_ptr, out_buffer_ptr, \
182 in_buffer_ptr, count); \
184 vsf_err_t vsf_imp_spi_cancel_transfer(vsf_imp_spi_t *spi_ptr) \
186 VSF_HAL_ASSERT(spi_ptr != NULL); \
187 return vsf_remap_spi_cancel_transfer(spi_ptr); \
189 void vsf_imp_spi_get_transferred_count(vsf_imp_spi_t *spi_ptr, \
190 uint_fast32_t * tx_count, uint_fast32_t *rx_count) \
192 VSF_HAL_ASSERT(spi_ptr != NULL); \
193 vsf_remap_spi_get_transferred_count(spi_ptr, tx_count, rx_count); \
195 vsf_spi_capability_t vsf_imp_spi_capability(vsf_imp_spi_t *spi_ptr) \
197 VSF_HAL_ASSERT(spi_ptr != NULL); \
198 return vsf_remap_spi_capability(spi_ptr); \
205#define VSF_HAL_TEMPLATE_IMP_NAME _spi
206#define VSF_HAL_TEMPLATE_IMP_UPCASE_NAME _SPI
208#ifndef VSF_SPI_CFG_IMP_PREFIX
209# error "Please define VSF_SPI_CFG_IMP_PREFIX in spi driver"
212#ifndef VSF_SPI_CFG_IMP_UPCASE_PREFIX
213# error "Please define VSF_SPI_CFG_IMP_UPCASE_PREFIX in spi driver"
216#ifndef VSF_SPI_CFG_IMP_COUNT_MASK_PREFIX
217# define VSF_SPI_CFG_IMP_COUNT_MASK_PREFIX VSF_SPI_CFG_IMP_UPCASE_PREFIX
220#ifdef VSF_SPI_CFG_IMP_REMAP_FUNCTIONS
221# define VSF_HAL_CFG_IMP_REMAP_FUNCTIONS VSF_SPI_CFG_IMP_REMAP_FUNCTIONS
226#undef VSF_SPI_CFG_IMP_PREFIX
227#undef VSF_SPI_CFG_IMP_COUNT_MASK_PREFIX
228#undef VSF_SPI_CFG_IMP_UPCASE_PREFIX
229#undef VSF_SPI_CFG_IMP_LV0
230#undef VSF_SPI_CFG_IMP_REMAP_FUNCTIONS
231#undef VSF_SPI_CFG_IMP_HAS_OP
232#undef VSF_SPI_CFG_IMP_EXTERN_OP
235#undef vsf_imp_spi_init
236#undef vsf_imp_spi_enable
237#undef vsf_imp_spi_disable
238#undef vsf_imp_spi_irq_enable
239#undef vsf_imp_spi_irq_disable
240#undef vsf_imp_spi_status
241#undef vsf_imp_spi_capability
242#undef vsf_imp_spi_cs_active
243#undef vsf_imp_spi_cs_inactive
244#undef vsf_imp_spi_fifo_transfer
245#undef vsf_imp_spi_request_transfer
246#undef vsf_imp_spi_cancel_transfer
247#undef vsf_imp_spi_get_transferred_count
249#undef vsf_remap_spi_t
250#undef vsf_remap_spi_init
251#undef vsf_remap_spi_enable
252#undef vsf_remap_spi_disable
253#undef vsf_remap_spi_irq_enable
254#undef vsf_remap_spi_irq_disable
255#undef vsf_remap_spi_status
256#undef vsf_remap_spi_capability
257#undef vsf_remap_spi_cs_active
258#undef vsf_remap_spi_cs_inactive
259#undef vsf_remap_spi_fifo_transfer
260#undef vsf_remap_spi_request_transfer
261#undef vsf_remap_spi_cancel_transfer
262#undef vsf_remap_spi_get_transferred_count
Definition vsf_template_spi.h:495
uint8_t support_hardware_cs
Definition vsf_template_spi.h:501