18#ifndef __VSF_TEMPLATE_SPI_H__
19#define __VSF_TEMPLATE_SPI_H__
39#ifndef VSF_SPI_CFG_MULTI_CLASS
40# define VSF_SPI_CFG_MULTI_CLASS ENABLED
50#if defined(VSF_HW_SPI_COUNT) && !defined(VSF_HW_SPI_MASK)
51# define VSF_HW_SPI_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_SPI_COUNT)
61#if defined(VSF_HW_SPI_MASK) && !defined(VSF_HW_SPI_COUNT)
62# define VSF_HW_SPI_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_SPI_MASK)
73#ifndef VSF_SPI_CFG_PREFIX
74# if (VSF_SPI_CFG_MULTI_CLASS == DISABLED) && defined(VSF_HW_SPI_COUNT) && (VSF_HW_SPI_COUNT != 0)
75# define VSF_SPI_CFG_PREFIX vsf_hw
77# define VSF_SPI_CFG_PREFIX vsf
89#ifndef VSF_SPI_CFG_FUNCTION_RENAME
90# define VSF_SPI_CFG_FUNCTION_RENAME ENABLED
101#ifndef VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE
102# define VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE DISABLED
114#ifndef VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK
115# define VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
127#ifndef VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS
128# define VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
143#ifndef VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG
144# define VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG DISABLED
156#ifndef VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL
157# define VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL DISABLED
170#ifndef VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY
171# define VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
183#ifndef VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS
184# define VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED
196#ifndef VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE
197# define VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE DISABLED
209#ifndef VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES
210# define VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES DISABLED
222#ifndef VSF_SPI_CFG_INHERIT_HAL_CAPABILITY
223# define VSF_SPI_CFG_INHERIT_HAL_CAPABILITY ENABLED
236#define VSF_SPI_APIS(__prefix_name) \
237 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, spi, init, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, vsf_spi_cfg_t *cfg_ptr) \
238 __VSF_HAL_TEMPLATE_API(__prefix_name, void, spi, fini, VSF_MCONNECT(__prefix_name, _t) *spi_ptr) \
239 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, spi, enable, VSF_MCONNECT(__prefix_name, _t) *spi_ptr) \
240 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, spi, disable, VSF_MCONNECT(__prefix_name, _t) *spi_ptr) \
241 __VSF_HAL_TEMPLATE_API(__prefix_name, void, spi, irq_enable, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, vsf_spi_irq_mask_t irq_mask) \
242 __VSF_HAL_TEMPLATE_API(__prefix_name, void, spi, irq_disable, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, vsf_spi_irq_mask_t irq_mask) \
243 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_spi_status_t, spi, status, VSF_MCONNECT(__prefix_name, _t) *spi_ptr) \
244 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_spi_capability_t, spi, capability, VSF_MCONNECT(__prefix_name, _t) *spi_ptr) \
245 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, spi, cs_active, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, uint_fast8_t index) \
246 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, spi, cs_inactive, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, uint_fast8_t index) \
247 __VSF_HAL_TEMPLATE_API(__prefix_name, void, spi, fifo_transfer, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, void *out_buffer_ptr, uint_fast32_t *out_offset_ptr, void *in_buffer_ptr, uint_fast32_t *in_offset_ptr, uint_fast32_t cnt) \
248 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, spi, request_transfer, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, void *out_buffer_ptr, void *in_buffer_ptr, uint_fast32_t count) \
249 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, spi, cancel_transfer, VSF_MCONNECT(__prefix_name, _t) *spi_ptr) \
250 __VSF_HAL_TEMPLATE_API(__prefix_name, void, spi, get_transferred_count, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, uint_fast32_t * tx_count, uint_fast32_t *rx_count) \
251 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, spi, ctrl, VSF_MCONNECT(__prefix_name, _t) *spi_ptr, vsf_spi_ctrl_t ctrl, void* param)
256#if VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
298 VSF_SPI_DATASIZE_VALUE_OFFSET = 1,
299 VSF_SPI_DATASIZE_BIT_OFFSET = 8,
300 VSF_SPI_DATASIZE_4 = ( 4ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
301 VSF_SPI_DATASIZE_5 = ( 5ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
302 VSF_SPI_DATASIZE_6 = ( 6ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
303 VSF_SPI_DATASIZE_7 = ( 7ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
304 VSF_SPI_DATASIZE_8 = ( 8ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
305 VSF_SPI_DATASIZE_9 = ( 9ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
306 VSF_SPI_DATASIZE_10 = (10ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
307 VSF_SPI_DATASIZE_11 = (11ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
308 VSF_SPI_DATASIZE_12 = (12ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
309 VSF_SPI_DATASIZE_13 = (13ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
310 VSF_SPI_DATASIZE_14 = (14ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
311 VSF_SPI_DATASIZE_15 = (15ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
312 VSF_SPI_DATASIZE_16 = (16ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
313 VSF_SPI_DATASIZE_17 = (17ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
314 VSF_SPI_DATASIZE_18 = (18ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
315 VSF_SPI_DATASIZE_19 = (19ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
316 VSF_SPI_DATASIZE_20 = (20ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
317 VSF_SPI_DATASIZE_21 = (21ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
318 VSF_SPI_DATASIZE_22 = (22ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
319 VSF_SPI_DATASIZE_23 = (23ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
320 VSF_SPI_DATASIZE_24 = (24ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
321 VSF_SPI_DATASIZE_25 = (25ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
322 VSF_SPI_DATASIZE_26 = (26ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
323 VSF_SPI_DATASIZE_27 = (27ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
324 VSF_SPI_DATASIZE_28 = (28ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
325 VSF_SPI_DATASIZE_29 = (29ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
326 VSF_SPI_DATASIZE_30 = (30ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
327 VSF_SPI_DATASIZE_31 = (31ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
328 VSF_SPI_DATASIZE_32 = (32ul - VSF_SPI_DATASIZE_VALUE_OFFSET) << VSF_SPI_DATASIZE_BIT_OFFSET,
329 #define VSF_SPI_DATASIZE_BIT_OFFSET VSF_SPI_DATASIZE_BIT_OFFSET
330 #define VSF_SPI_DATASIZE_VALUE_OFFSET VSF_SPI_DATASIZE_VALUE_OFFSET
331 #define VSF_SPI_DATASIZE_4 VSF_SPI_DATASIZE_4
332 #define VSF_SPI_DATASIZE_5 VSF_SPI_DATASIZE_5
333 #define VSF_SPI_DATASIZE_6 VSF_SPI_DATASIZE_6
334 #define VSF_SPI_DATASIZE_7 VSF_SPI_DATASIZE_7
335 #define VSF_SPI_DATASIZE_8 VSF_SPI_DATASIZE_8
336 #define VSF_SPI_DATASIZE_9 VSF_SPI_DATASIZE_9
337 #define VSF_SPI_DATASIZE_10 VSF_SPI_DATASIZE_10
338 #define VSF_SPI_DATASIZE_11 VSF_SPI_DATASIZE_11
339 #define VSF_SPI_DATASIZE_12 VSF_SPI_DATASIZE_12
340 #define VSF_SPI_DATASIZE_13 VSF_SPI_DATASIZE_13
341 #define VSF_SPI_DATASIZE_14 VSF_SPI_DATASIZE_14
342 #define VSF_SPI_DATASIZE_15 VSF_SPI_DATASIZE_15
343 #define VSF_SPI_DATASIZE_16 VSF_SPI_DATASIZE_16
344 #define VSF_SPI_DATASIZE_17 VSF_SPI_DATASIZE_17
345 #define VSF_SPI_DATASIZE_18 VSF_SPI_DATASIZE_18
346 #define VSF_SPI_DATASIZE_19 VSF_SPI_DATASIZE_19
347 #define VSF_SPI_DATASIZE_20 VSF_SPI_DATASIZE_20
348 #define VSF_SPI_DATASIZE_21 VSF_SPI_DATASIZE_21
349 #define VSF_SPI_DATASIZE_22 VSF_SPI_DATASIZE_22
350 #define VSF_SPI_DATASIZE_23 VSF_SPI_DATASIZE_23
351 #define VSF_SPI_DATASIZE_24 VSF_SPI_DATASIZE_24
352 #define VSF_SPI_DATASIZE_25 VSF_SPI_DATASIZE_25
353 #define VSF_SPI_DATASIZE_26 VSF_SPI_DATASIZE_26
354 #define VSF_SPI_DATASIZE_27 VSF_SPI_DATASIZE_27
355 #define VSF_SPI_DATASIZE_28 VSF_SPI_DATASIZE_28
356 #define VSF_SPI_DATASIZE_29 VSF_SPI_DATASIZE_29
357 #define VSF_SPI_DATASIZE_30 VSF_SPI_DATASIZE_30
358 #define VSF_SPI_DATASIZE_31 VSF_SPI_DATASIZE_31
359 #define VSF_SPI_DATASIZE_32 VSF_SPI_DATASIZE_32
360 #define VSF_SPI_DATASIZE_MASK ( VSF_SPI_DATASIZE_4 \
361 | VSF_SPI_DATASIZE_5 \
362 | VSF_SPI_DATASIZE_6 \
363 | VSF_SPI_DATASIZE_7 \
364 | VSF_SPI_DATASIZE_8 \
365 | VSF_SPI_DATASIZE_9 \
366 | VSF_SPI_DATASIZE_10 \
367 | VSF_SPI_DATASIZE_11 \
368 | VSF_SPI_DATASIZE_12 \
369 | VSF_SPI_DATASIZE_13 \
370 | VSF_SPI_DATASIZE_14 \
371 | VSF_SPI_DATASIZE_15 \
372 | VSF_SPI_DATASIZE_16 \
373 | VSF_SPI_DATASIZE_17 \
374 | VSF_SPI_DATASIZE_18 \
375 | VSF_SPI_DATASIZE_19 \
376 | VSF_SPI_DATASIZE_20 \
377 | VSF_SPI_DATASIZE_21 \
378 | VSF_SPI_DATASIZE_22 \
379 | VSF_SPI_DATASIZE_23 \
380 | VSF_SPI_DATASIZE_24 \
381 | VSF_SPI_DATASIZE_25 \
382 | VSF_SPI_DATASIZE_26 \
383 | VSF_SPI_DATASIZE_27 \
384 | VSF_SPI_DATASIZE_28 \
385 | VSF_SPI_DATASIZE_29 \
386 | VSF_SPI_DATASIZE_30 \
387 | VSF_SPI_DATASIZE_31 \
388 | VSF_SPI_DATASIZE_32 )
394 VSF_SPI_DATALINE_2_LINE_FULL_DUPLEX = (0x00ul << 16), // 2 line, full-duplex, standard spi
395 VSF_SPI_DATALINE_2_LINE_RX_ONLY = (0x01ul << 16), // 2 line, but rx only
396 VSF_SPI_DATALINE_2_LINE_TX_ONLY = (0x02ul << 16), // 2 line, but tx only
397 VSF_SPI_DATALINE_1_LINE_HALF_DUPLEX = (0x03ul << 16), // 1 line, half-duplex
398 VSF_SPI_DATALINE_2_LINE_HALF_DUPLEX = (0x04ul << 16), // 2 line, half-duplex, dual spi
399 VSF_SPI_DATALINE_4_LINE_HALF_DUPLEX = (0x05ul << 16), // 4 line, half-duplex, qual spi
400 VSF_SPI_DATALINE_8_LINE_HALF_DUPLEX = (0x06ul << 16), // 8 line, half-duplex, octal spi
401 #define VSF_SPI_DATALINE_2_LINE_FULL_DUPLEX VSF_SPI_DATALINE_2_LINE_FULL_DUPLEX
402 #define VSF_SPI_DATALINE_2_LINE_RX_ONLY VSF_SPI_DATALINE_2_LINE_RX_ONLY
403 #define VSF_SPI_DATALINE_2_LINE_TX_ONLY VSF_SPI_DATALINE_2_LINE_TX_ONLY
404 #define VSF_SPI_DATALINE_1_LINE_HALF_DUPLEX VSF_SPI_DATALINE_1_LINE_HALF_DUPLEX
405 #define VSF_SPI_DATALINE_2_LINE_HALF_DUPLEX VSF_SPI_DATALINE_2_LINE_HALF_DUPLEX
406 #define VSF_SPI_DATALINE_4_LINE_HALF_DUPLEX VSF_SPI_DATALINE_4_LINE_HALF_DUPLEX
407 #define VSF_SPI_DATALINE_8_LINE_HALF_DUPLEX VSF_SPI_DATALINE_8_LINE_HALF_DUPLEX
408 #define VSF_SPI_DATALINE_MASK ( VSF_SPI_DATALINE_2_LINE_FULL_DUPLEX \
409 | VSF_SPI_DATALINE_1_LINE_HALF_DUPLEX \
410 | VSF_SPI_DATALINE_2_LINE_HALF_DUPLEX \
411 | VSF_SPI_DATALINE_4_LINE_HALF_DUPLEX \
412 | VSF_SPI_DATALINE_8_LINE_HALF_DUPLEX)
418 VSF_SPI_MOTOROLA_MODE = (0x00ul << 20), //! \~english Motorola SPI: Standard 4-wire SPI protocol \~chinese 摩托罗拉 SPI:标准 4 线 SPI 协议
419 VSF_SPI_TI_MODE = (0x01ul << 20), //! \~english TI SSI: Chip select timing differs from Motorola SPI \~chinese TI SSI:片选时序与摩托罗拉 SPI 不同
420 #define VSF_SPI_MOTOROLA_MODE VSF_SPI_MOTOROLA_MODE
421 #define VSF_SPI_TI_MODE VSF_SPI_TI_MODE
422 #define VSF_SPI_MOTOROLA_TI_MASK (VSF_SPI_MOTOROLA_MODE | VSF_SPI_TI_MODE)
427 // @brief Optional CRC calculation support for data integrity
428 // @note Hardware CRC calculation is platform-dependent
429 // @note When enabled, CRC is automatically calculated and verified
431 // @brief 可选的 CRC 数据完整性校验支持
432 // @note 硬件 CRC 计算依赖于平台
433 // @note 当使能时,CRC 将自动计算和验证
434 VSF_SPI_CRC_DISABLED = (0x00ul << 21), //! \~english CRC calculation disabled (no integrity check) \~chinese CRC 计算禁用(无完整性检查)
435 VSF_SPI_CRC_ENABLED = (0x01ul << 21), //! \~english CRC calculation enabled (hardware computes and verifies) \~chinese CRC 计算使能(硬件计算和验证)
436 #define VSF_SPI_CRC_DISABLED VSF_SPI_CRC_DISABLED
437 #define VSF_SPI_CRC_ENABLED VSF_SPI_CRC_ENABLED
438 #define VSF_SPI_CRC_MASK (VSF_SPI_CRC_DISABLED | VSF_SPI_CRC_ENABLED)
444 VSF_SPI_CLOCK_PRESCALER_2 = (0x00ul << 22), //! \~english Divide system clock by 2 (highest frequency) \~chinese 系统时钟除以 2(最高频率)
445 VSF_SPI_CLOCK_PRESCALER_4 = (0x01ul << 22), //! \~english Divide system clock by 4 \~chinese 系统时钟除以 4
446 VSF_SPI_CLOCK_PRESCALER_8 = (0x02ul << 22), //! \~english Divide system clock by 8 \~chinese 系统时钟除以 8
447 VSF_SPI_CLOCK_PRESCALER_16 = (0x03ul << 22), //! \~english Divide system clock by 16 \~chinese 系统时钟除以 16
448 VSF_SPI_CLOCK_PRESCALER_32 = (0x04ul << 22), //! \~english Divide system clock by 32 \~chinese 系统时钟除以 32
449 VSF_SPI_CLOCK_PRESCALER_64 = (0x05ul << 22), //! \~english Divide system clock by 64 \~chinese 系统时钟除以 64
450 VSF_SPI_CLOCK_PRESCALER_128 = (0x06ul << 22), //! \~english Divide system clock by 128 \~chinese 系统时钟除以 128
451 VSF_SPI_CLOCK_PRESCALER_256 = (0x07ul << 22), //! \~english Divide system clock by 256 (lowest frequency) \~chinese 系统时钟除以 256(最低频率)
452 #define VSF_SPI_CLOCK_PRESCALER_2 VSF_SPI_CLOCK_PRESCALER_2
453 #define VSF_SPI_CLOCK_PRESCALER_4 VSF_SPI_CLOCK_PRESCALER_4
454 #define VSF_SPI_CLOCK_PRESCALER_8 VSF_SPI_CLOCK_PRESCALER_8
455 #define VSF_SPI_CLOCK_PRESCALER_16 VSF_SPI_CLOCK_PRESCALER_16
456 #define VSF_SPI_CLOCK_PRESCALER_32 VSF_SPI_CLOCK_PRESCALER_32
457 #define VSF_SPI_CLOCK_PRESCALER_64 VSF_SPI_CLOCK_PRESCALER_64
458 #define VSF_SPI_CLOCK_PRESCALER_128 VSF_SPI_CLOCK_PRESCALER_128
459 #define VSF_SPI_CLOCK_PRESCALER_256 VSF_SPI_CLOCK_PRESCALER_256
460 #define VSF_SPI_CLOCK_PRESCALER_MASK ( VSF_SPI_CLOCK_PRESCALER_2 \
461 | VSF_SPI_CLOCK_PRESCALER_4 \
462 | VSF_SPI_CLOCK_PRESCALER_8 \
463 | VSF_SPI_CLOCK_PRESCALER_16 \
464 | VSF_SPI_CLOCK_PRESCALER_32 \
465 | VSF_SPI_CLOCK_PRESCALER_64 \
466 | VSF_SPI_CLOCK_PRESCALER_128 \
467 | VSF_SPI_CLOCK_PRESCALER_256)
518#ifndef VSF_SPI_CS_MODE_MASK
525#ifdef VSF_SPI_CS_HARDWARE_INPUT_MODE
526 | VSF_SPI_CS_HARDWARE_INPUT_MODE
535#ifndef VSF_SPI_DATASIZE_MASK
541#ifndef VSF_SPI_MODE_ALL_BITS_MASK
552#ifdef VSF_SPI_DATALINE_MASK
553 | VSF_SPI_DATALINE_MASK
555#ifdef VSF_SPI_MOTOROLA_TI_MASK
556 | VSF_SPI_MOTOROLA_TI_MASK
558#ifdef VSF_SPI_CRC_MASK
561#ifdef VSF_SPI_CLOCK_PRESCLER_MASK
562 | VSF_SPI_CLOCK_PRESCLER_MASK
567#if VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
602#ifndef VSF_SPI_IRQ_MASK_ERR
611#ifndef VSF_SPI_IRQ_ALL_BITS_MASK
624#if VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
646#if VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
656#if VSF_SPI_CFG_INHERIT_HAL_CAPABILITY == ENABLED
670#if VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
717#if VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
744 VSF_SPI_CTRL_REQUEST_PAUSE = (0x1ul << 0), //! \~english Request to pause SPI transfer \~chinese 请求暂停 SPI 传输
745 VSF_SPI_CTRL_REQUEST_RESUME = (0x1ul << 1), //! \~english Request to resume SPI transfer \~chinese 请求恢复 SPI 传输
746 #define VSF_SPI_CTRL_REQUEST_PAUSE VSF_SPI_CTRL_REQUEST_PAUSE
747 #define VSF_SPI_CTRL_REQUEST_RESUME VSF_SPI_CTRL_REQUEST_RESUME
770 VSF_SPI_CTRL_QSPI_ENABLE = 0x00ul,
775 VSF_SPI_CTRL_QSPI_DISABLE = 0x01ul,
776 #define VSF_SPI_CTRL_QSPI_ENABLE VSF_SPI_CTRL_QSPI_ENABLE
777 #define VSF_SPI_CTRL_QSPI_DISABLE VSF_SPI_CTRL_QSPI_DISABLE
796 VSF_SPI_CTRL_QSPI_CMD_PHASE_ENABLE = 0x02ul,
799 VSF_SPI_CTRL_QSPI_CMD_PHASE_DISABLE = 0x03ul,
802 VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_SIZE = 0x04ul,
805 VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_SIZE = 0x05ul,
812 VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_LINE_MODE = 0x06ul,
819 VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_LINE_MODE = 0x07ul,
822 VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_VALUE = 0x08ul,
825 VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_VALUE = 0x09ul,
826 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_ENABLE VSF_SPI_CTRL_QSPI_CMD_PHASE_ENABLE
827 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_DISABLE VSF_SPI_CTRL_QSPI_CMD_PHASE_DISABLE
828 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_SIZE VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_SIZE
829 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_SIZE VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_SIZE
830 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_LINE_MODE VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_LINE_MODE
831 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_LINE_MODE VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_LINE_MODE
832 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_VALUE VSF_SPI_CTRL_QSPI_CMD_PHASE_SET_VALUE
833 #define VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_VALUE VSF_SPI_CTRL_QSPI_CMD_PHASE_GET_VALUE
846 VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_ENABLE = 0x0Aul,
849 VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_DISABLE = 0x0Bul,
852 VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_SET_SIZE = 0x0Cul,
855 VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_GET_SIZE = 0x0Dul,
862 VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_SET_LINE_MODE = 0x0Eul,
868 VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_GET_LINE_MODE = 0x0Ful,
871 VSF_SPI_CTRL_QSPI_ADDRESS_SET = 0x10ul,
874 VSF_SPI_CTRL_QSPI_ADDRESS_GET = 0x11ul,
875 #define VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_ENABLE VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_ENABLE
876 #define VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_DISABLE VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_DISABLE
877 #define VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_SET_SIZE VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_SET_SIZE
878 #define VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_GET_SIZE VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_GET_SIZE
879 #define VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_SET_LINE_MODE VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_SET_LINE_MODE
880 #define VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_GET_LINE_MODE VSF_SPI_CTRL_QSPI_ADDRESS_PHASE_GET_LINE_MODE
881 #define VSF_SPI_CTRL_QSPI_ADDRESS_SET VSF_SPI_CTRL_QSPI_ADDRESS_SET
882 #define VSF_SPI_CTRL_QSPI_ADDRESS_GET VSF_SPI_CTRL_QSPI_ADDRESS_GET
895 VSF_SPI_CTRL_QSPI_DUMMY_PHASE_ENABLE = 0x18ul,
898 VSF_SPI_CTRL_QSPI_DUMMY_PHASE_DISABLE = 0x19ul,
901 VSF_SPI_CTRL_QSPI_DUMMY_PHASE_SET_CYCLES = 0x1Aul,
904 VSF_SPI_CTRL_QSPI_DUMMY_PHASE_GET_CYCLES = 0x1Bul,
905 #define VSF_SPI_CTRL_QSPI_DUMMY_PHASE_ENABLE VSF_SPI_CTRL_QSPI_DUMMY_PHASE_ENABLE
906 #define VSF_SPI_CTRL_QSPI_DUMMY_PHASE_DISABLE VSF_SPI_CTRL_QSPI_DUMMY_PHASE_DISABLE
907 #define VSF_SPI_CTRL_QSPI_DUMMY_PHASE_SET_CYCLES VSF_SPI_CTRL_QSPI_DUMMY_PHASE_SET_CYCLES
908 #define VSF_SPI_CTRL_QSPI_DUMMY_PHASE_GET_CYCLES VSF_SPI_CTRL_QSPI_DUMMY_PHASE_GET_CYCLES
925 VSF_SPI_CTRL_QSPI_DATA_PHASE_ENABLE = 0x12ul,
928 VSF_SPI_CTRL_QSPI_DATA_PHASE_DISABLE = 0x13ul,
931 VSF_SPI_CTRL_QSPI_DATA_PHASE_SET_SIZE = 0x14ul,
934 VSF_SPI_CTRL_QSPI_DATA_PHASE_GET_SIZE = 0x15ul,
942 VSF_SPI_CTRL_QSPI_DATA_PHASE_SET_LINE_MODE = 0x16ul,
950 VSF_SPI_CTRL_QSPI_DATA_PHASE_GET_LINE_MODE = 0x17ul,
951 #define VSF_SPI_CTRL_QSPI_DATA_PHASE_ENABLE VSF_SPI_CTRL_QSPI_DATA_PHASE_ENABLE
952 #define VSF_SPI_CTRL_QSPI_DATA_PHASE_DISABLE VSF_SPI_CTRL_QSPI_DATA_PHASE_DISABLE
953 #define VSF_SPI_CTRL_QSPI_DATA_PHASE_SET_SIZE VSF_SPI_CTRL_QSPI_DATA_PHASE_SET_SIZE
954 #define VSF_SPI_CTRL_QSPI_DATA_PHASE_GET_SIZE VSF_SPI_CTRL_QSPI_DATA_PHASE_GET_SIZE
955 #define VSF_SPI_CTRL_QSPI_DATA_PHASE_SET_LINE_MODE VSF_SPI_CTRL_QSPI_DATA_PHASE_SET_LINE_MODE
956 #define VSF_SPI_CTRL_QSPI_DATA_PHASE_GET_LINE_MODE VSF_SPI_CTRL_QSPI_DATA_PHASE_GET_LINE_MODE
962 VSF_SPI_CTRL_QSPI_TRANSFER_SET_MODE = 0x1Cul,
965 VSF_SPI_CTRL_QSPI_TRANSFER_GET_MODE = 0x1Dul,
966 #define VSF_SPI_CTRL_QSPI_TRANSFER_SET_MODE VSF_SPI_CTRL_QSPI_TRANSFER_SET_MODE
967 #define VSF_SPI_CTRL_QSPI_TRANSFER_GET_MODE VSF_SPI_CTRL_QSPI_TRANSFER_GET_MODE
978# undef __VSF_HAL_TEMPLATE_API
979# define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
985#if VSF_SPI_CFG_MULTI_CLASS == ENABLED
1270#if VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS == DISABLED
1285# if defined(VSF_SPI_DATASIZE_BIT_OFFSET) && defined(VSF_SPI_DATASIZE_VALUE_OFFSET)
1289 return bits + VSF_SPI_DATASIZE_VALUE_OFFSET;
1296#ifdef VSF_SPI_DATASIZE_4
1300#ifdef VSF_SPI_DATASIZE_5
1304#ifdef VSF_SPI_DATASIZE_6
1308#ifdef VSF_SPI_DATASIZE_7
1314#ifdef VSF_SPI_DATASIZE_9
1318#ifdef VSF_SPI_DATASIZE_10
1322#ifdef VSF_SPI_DATASIZE_11
1326#ifdef VSF_SPI_DATASIZE_12
1330#ifdef VSF_SPI_DATASIZE_13
1334#ifdef VSF_SPI_DATASIZE_14
1338#ifdef VSF_SPI_DATASIZE_15
1342#ifdef VSF_SPI_DATASIZE_16
1346#ifdef VSF_SPI_DATASIZE_17
1350#ifdef VSF_SPI_DATASIZE_18
1354#ifdef VSF_SPI_DATASIZE_19
1358#ifdef VSF_SPI_DATASIZE_20
1362#ifdef VSF_SPI_DATASIZE_21
1366#ifdef VSF_SPI_DATASIZE_22
1370#ifdef VSF_SPI_DATASIZE_23
1374#ifdef VSF_SPI_DATASIZE_24
1378#ifdef VSF_SPI_DATASIZE_25
1382#ifdef VSF_SPI_DATASIZE_26
1386#ifdef VSF_SPI_DATASIZE_27
1390#ifdef VSF_SPI_DATASIZE_28
1394#ifdef VSF_SPI_DATASIZE_29
1398#ifdef VSF_SPI_DATASIZE_30
1402#ifdef VSF_SPI_DATASIZE_31
1406#ifdef VSF_SPI_DATASIZE_32
1417#if VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE == DISABLED
1432# if defined(VSF_SPI_DATASIZE_BIT_OFFSET) && defined(VSF_SPI_DATASIZE_VALUE_OFFSET)
1441#ifdef VSF_SPI_DATASIZE_4
1445#ifdef VSF_SPI_DATASIZE_5
1449#ifdef VSF_SPI_DATASIZE_6
1453#ifdef VSF_SPI_DATASIZE_7
1459#ifdef VSF_SPI_DATASIZE_9
1463#ifdef VSF_SPI_DATASIZE_10
1467#ifdef VSF_SPI_DATASIZE_11
1471#ifdef VSF_SPI_DATASIZE_12
1475#ifdef VSF_SPI_DATASIZE_13
1479#ifdef VSF_SPI_DATASIZE_14
1483#ifdef VSF_SPI_DATASIZE_15
1487#ifdef VSF_SPI_DATASIZE_16
1491#ifdef VSF_SPI_DATASIZE_17
1495#ifdef VSF_SPI_DATASIZE_18
1499#ifdef VSF_SPI_DATASIZE_19
1503#ifdef VSF_SPI_DATASIZE_20
1507#ifdef VSF_SPI_DATASIZE_21
1511#ifdef VSF_SPI_DATASIZE_22
1515#ifdef VSF_SPI_DATASIZE_23
1519#ifdef VSF_SPI_DATASIZE_24
1523#ifdef VSF_SPI_DATASIZE_25
1527#ifdef VSF_SPI_DATASIZE_26
1531#ifdef VSF_SPI_DATASIZE_27
1535#ifdef VSF_SPI_DATASIZE_28
1539#ifdef VSF_SPI_DATASIZE_29
1543#ifdef VSF_SPI_DATASIZE_30
1547#ifdef VSF_SPI_DATASIZE_31
1551#ifdef VSF_SPI_DATASIZE_32
1562#if VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES == DISABLED
1593#if VSF_SPI_CFG_FUNCTION_RENAME == ENABLED
1594# define __vsf_spi_t VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_t)
1595# define vsf_spi_init(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_init) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1596# define vsf_spi_fini(__SPI) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_fini) ((__vsf_spi_t *)(__SPI))
1597# define vsf_spi_enable(__SPI) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_enable) ((__vsf_spi_t *)(__SPI))
1598# define vsf_spi_disable(__SPI) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_disable) ((__vsf_spi_t *)(__SPI))
1599# define vsf_spi_irq_enable(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_irq_enable) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1600# define vsf_spi_irq_disable(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_irq_disable) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1601# define vsf_spi_status(__SPI) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_status) ((__vsf_spi_t *)(__SPI))
1602# define vsf_spi_capability(__SPI) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_capability) ((__vsf_spi_t *)(__SPI))
1603# define vsf_spi_cs_active(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_cs_active) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1604# define vsf_spi_cs_inactive(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_cs_inactive) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1605# define vsf_spi_fifo_transfer(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_fifo_transfer) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1606# define vsf_spi_request_transfer(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_request_transfer) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1607# define vsf_spi_cancel_transfer(__SPI) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_cancel_transfer) ((__vsf_spi_t *)(__SPI))
1608# define vsf_spi_get_transferred_count(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_get_transferred_count)((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1609# define vsf_spi_ctrl(__SPI, ...) VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_ctrl) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__)
1611# define vsf_qspi_t vsf_spi_t
1612# define vsf_qspi_mode_t vsf_spi_mode_t
1613# define vsf_qspi_irq_mask_t vsf_spi_irq_mask_t
1614# define vsf_qspi_status_t vsf_spi_status_t
1615# define vsf_qspi_capability_t vsf_spi_capability_t
1616# define vsf_qspi_isr_handler_t vsf_spi_isr_handler_t
1617# define vsf_qspi_isr_t vsf_spi_isr_t
1618# define vsf_qspi_cfg_t vsf_spi_cfg_t
1619# define vsf_qspi_ctrl_t vsf_spi_ctrl_t
1635# define vsf_qspi_init(__SPI, __CFG_PTR) vsf_spi_init((__vsf_spi_t *)(__SPI), (__CFG_PTR))
1649# define vsf_qspi_fini(__SPI) vsf_spi_fini((__vsf_spi_t *)(__SPI))
1663# define vsf_qspi_enable(__SPI) vsf_spi_enable((__vsf_spi_t *)(__SPI))
1677# define vsf_qspi_disable(__SPI) vsf_spi_disable((__vsf_spi_t *)(__SPI))
1693# define vsf_qspi_irq_enable(__SPI, __IRQ_MASK) vsf_spi_irq_enable((__vsf_spi_t *)(__SPI), (__IRQ_MASK))
1709# define vsf_qspi_irq_disable(__SPI, __IRQ_MASK) vsf_spi_irq_disable((__vsf_spi_t *)(__SPI), (__IRQ_MASK))
1723# define vsf_qspi_status(__SPI) vsf_spi_status((__vsf_spi_t *)(__SPI))
1737# define vsf_qspi_capability(__SPI) vsf_spi_capability((__vsf_spi_t *)(__SPI))
1759# define vsf_qspi_fifo_write(__SPI, __OUT_BUFFER_PTR, __OUT_OFFSET_PTR, __COUNT) \
1760 vsf_spi_fifo_transfer((__vsf_spi_t *)(__SPI), (__OUT_BUFFER_PTR), (__OUT_OFFSET_PTR), NULL, NULL, (__COUNT))
1782# define vsf_qspi_fifo_read(__SPI, __IN_BUFFER_PTR, __IN_OFFSET_PTR, __COUNT) \
1783 vsf_spi_fifo_transfer((__vsf_spi_t *)(__SPI), NULL, NULL, (__IN_BUFFER_PTR), (__IN_OFFSET_PTR), (__COUNT))
1803# define vsf_qspi_request_tx(__SPI, __OUT_BUF, __CNT) vsf_spi_request_transfer((__vsf_spi_t *)(__SPI), (__OUT_BUF), NULL, (__CNT))
1823# define vsf_qspi_request_rx(__SPI, __IN_BUF, __CNT) vsf_spi_request_transfer((__vsf_spi_t *)(__SPI), NULL, (__IN_BUF), (__CNT))
1837# define vsf_qspi_cancel_transfer(__SPI) vsf_spi_cancel_transfer((__vsf_spi_t *)(__SPI))
1855# define vsf_qspi_get_transferred_count(__SPI, __TX_CNT, __RX_CNT) \
1856 vsf_spi_get_transferred_count((__vsf_spi_t *)(__SPI), (__TX_CNT), (__RX_CNT))
1874# define vsf_qspi_ctrl(__SPI, __CTRL, __PARAM) vsf_spi_ctrl((__vsf_spi_t *)(__SPI), (__CTRL), (__PARAM))
vsf_err_t
Definition __type.h:42
vsf_spi_mode_t
Definition spi.h:33
@ VSF_SPI_DATASIZE_31
Definition spi.h:67
@ VSF_SPI_DATASIZE_28
Definition spi.h:64
@ VSF_SPI_DATASIZE_6
Definition spi.h:98
@ VSF_SPI_DATASIZE_17
Definition spi.h:53
@ VSF_SPI_DATASIZE_9
Definition spi.h:45
@ VSF_SPI_DATASIZE_18
Definition spi.h:54
@ VSF_SPI_DATASIZE_11
Definition spi.h:47
@ VSF_SPI_DATASIZE_20
Definition spi.h:56
@ VSF_SPI_DATASIZE_21
Definition spi.h:57
@ VSF_SPI_DATASIZE_27
Definition spi.h:63
@ VSF_SPI_DATASIZE_14
Definition spi.h:50
@ VSF_SPI_DATASIZE_BIT_OFFSET
Definition spi.h:42
@ VSF_SPI_DATASIZE_26
Definition spi.h:62
@ VSF_SPI_DATASIZE_13
Definition spi.h:49
@ VSF_SPI_DATASIZE_7
Definition spi.h:99
@ VSF_SPI_DATASIZE_5
Definition spi.h:97
@ VSF_SPI_DATASIZE_12
Definition spi.h:48
@ VSF_SPI_DATASIZE_22
Definition spi.h:58
@ VSF_SPI_DATASIZE_24
Definition spi.h:60
@ VSF_SPI_DATASIZE_4
datasize is 8 bits
Definition spi.h:96
@ VSF_SPI_DATASIZE_29
Definition spi.h:65
@ VSF_SPI_DATASIZE_25
Definition spi.h:61
@ VSF_SPI_DATASIZE_30
Definition spi.h:66
@ VSF_SPI_DATASIZE_19
Definition spi.h:55
@ VSF_SPI_DATASIZE_23
Definition spi.h:59
@ VSF_SPI_DATASIZE_10
Definition spi.h:46
@ VSF_SPI_DATASIZE_15
Definition spi.h:51
vsf_arch_prio_t
Definition cortex_a_generic.h:88
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned char uint_fast8_t
Definition stdint.h:23
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
Predefined VSF SPI capability that can be reimplemented in specific HAL drivers. Even if the hardware...
Definition vsf_template_spi.h:655
uint8_t support_software_cs
Hardware chip select support (1: supported, 0: not supported)
Definition vsf_template_spi.h:662
uint32_t max_clock_hz
Number of available chip select lines (0-63)
Definition vsf_template_spi.h:665
uint8_t cs_count
Software chip select support (1: supported, 0: not supported)
Definition vsf_template_spi.h:663
vsf_spi_irq_mask_t irq_mask
Definition spi.h:165
uint8_t support_hardware_cs
Supported interrupt masks for SPI operations.
Definition vsf_template_spi.h:661
uint32_t min_clock_hz
Maximum supported SPI clock frequency in Hz.
Definition vsf_template_spi.h:666
inherit(vsf_peripheral_capability_t) vsf_spi_irq_mask_t irq_mask
Inherit peripheral capabilities.
Configuration structure for SPI.
Definition vsf_template_spi.h:708
uint32_t clock_hz
SPI operating mode (master/slave, CPOL/CPHA, bit order, data size)
Definition vsf_template_spi.h:710
vsf_spi_isr_t isr
SPI clock frequency in Hz (must be between min_clock_hz and max_clock_hz)
Definition vsf_template_spi.h:711
vsf_spi_mode_t mode
Definition vsf_template_spi.h:709
uint8_t auto_cs_index
Interrupt configuration (handler, target pointer, priority)
Definition vsf_template_spi.h:712
SPI interrupt service routine configuration structure.
Definition vsf_template_spi.h:696
vsf_spi_isr_handler_t * handler_fn
Definition vsf_template_spi.h:697
void * target_ptr
Interrupt handler function (NULL to disable interrupts)
Definition vsf_template_spi.h:698
vsf_arch_prio_t prio
User context pointer passed to handler.
Definition vsf_template_spi.h:699
SPI operation function pointer type, used for SPI Multi Class support.
Definition vsf_template_spi.h:976
Predefined VSF SPI status that can be reimplemented in specific HAL drivers. Even if the hardware doe...
Definition vsf_template_spi.h:635
uint32_t is_busy
Definition spi.h:155
SPI instance structure, used for SPI Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_spi.h:990
const vsf_spi_op_t * op
Definition vsf_template_spi.h:991
void vsf_spi_isr_handler_t(void *target_ptr, vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask)
Definition spi.h:181
vsf_spi_irq_mask_t
Definition spi.h:140
vsf_spi_mode_t
Definition spi.h:116
fsm_rt_t
Definition vsf_fsm.h:315
vsf_spi_t vsf_spi[SPI_COUNT]
Definition vsf_spi.c:3
void vsf_spi_fifo_transfer(vsf_spi_t *spi_ptr, void *out_buffer_ptr, uint_fast32_t *out_offset_ptr, void *in_buffer_ptr, uint_fast32_t *in_offset_ptr, uint_fast32_t count)
Perform FIFO-based data transfer on a SPI instance.
Definition spi_common.c:118
@ VSF_SPI_IRQ_MASK_RX_CPL
VSF_SPI_IRQ_MASK_RX 的别名
Definition vsf_template_spi.h:600
@ VSF_SPI_IRQ_MASK_TX_FIFO_THRESHOLD
Definition vsf_template_spi.h:593
@ VSF_SPI_IRQ_ALL_BITS_MASK
Definition vsf_template_spi.h:616
@ VSF_SPI_IRQ_MASK_RX_FIFO_THRESHOLD
VSF_SPI_IRQ_MASK_TX 的别名
Definition vsf_template_spi.h:594
@ VSF_SPI_IRQ_MASK_ERR
Definition vsf_template_spi.h:607
struct vsf_spi_isr_t vsf_spi_isr_t
SPI interrupt service routine configuration structure.
void vsf_spi_isr_handler_t(void *target_ptr, vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask)
SPI interrupt handler type declaration.
Definition vsf_template_spi.h:686
vsf_spi_status_t vsf_spi_status(vsf_spi_t *spi_ptr)
Get the current status of a SPI instance.
Definition spi_common.c:91
vsf_err_t vsf_spi_request_transfer(vsf_spi_t *spi_ptr, void *out_buffer_ptr, void *in_buffer_ptr, uint_fast32_t count)
Request a SPI data transfer operation.
Definition spi_common.c:130
struct vsf_spi_cfg_t vsf_spi_cfg_t
Configuration structure for SPI.
struct vsf_spi_capability_t vsf_spi_capability_t
Predefined VSF SPI capability that can be reimplemented in specific HAL drivers. Even if the hardware...
#define VSF_SPI_APIS(__prefix_name)
SPI API template, used to generate SPI type, specific prefix function declarations,...
Definition vsf_template_spi.h:236
@ VSF_SPI_MODE_MASK
SPI mode mask for clock polarity and phase configuration.
Definition vsf_template_spi.h:509
@ VSF_SPI_BIT_ORDER_MASK
SPI bit order mask for MSB/LSB first selection.
Definition vsf_template_spi.h:498
@ VSF_SPI_DIR_MODE_MASK
SPI direction mode mask for master/slave selection.
Definition vsf_template_spi.h:487
@ VSF_SPI_CS_MODE_MASK
Definition vsf_template_spi.h:519
@ VSF_SPI_MODE_ALL_BITS_MASK
Definition vsf_template_spi.h:546
@ VSF_SPI_DATASIZE_MASK
Definition vsf_template_spi.h:536
void vsf_spi_get_transferred_count(vsf_spi_t *spi_ptr, uint_fast32_t *sent_count, uint_fast32_t *received_count)
Get the number of data units transferred in the current or last SPI operation.
Definition spi_common.c:150
vsf_err_t vsf_spi_cs_active(vsf_spi_t *spi_ptr, uint_fast8_t index)
Activate (assert) a SPI chip select line.
Definition spi_common.c:100
vsf_spi_irq_mask_t
Predefined VSF SPI interrupt masks that can be reimplemented in specific HAL drivers....
Definition vsf_template_spi.h:579
@ VSF_SPI_IRQ_MASK_OVERFLOW_ERR
Transfer complete interrupt (triggers when both TX and RX are complete)
Definition vsf_template_spi.h:584
@ VSF_SPI_IRQ_MASK_CPL
TX complete interrupt (triggers when all TX data has been sent)
Definition vsf_template_spi.h:583
@ VSF_SPI_IRQ_MASK_RX
TX FIFO threshold interrupt (triggers when TX FIFO level is below threshold)
Definition vsf_template_spi.h:581
@ VSF_SPI_IRQ_MASK_TX
Definition vsf_template_spi.h:580
@ VSF_SPI_IRQ_MASK_TX_CPL
RX FIFO threshold interrupt (triggers when RX FIFO level is above threshold)
Definition vsf_template_spi.h:582
vsf_err_t vsf_spi_ctrl(vsf_spi_t *spi_ptr, vsf_spi_ctrl_t ctrl, void *param)
Execute a control command on the SPI instance.
Definition spi_common.c:169
fsm_rt_t vsf_spi_enable(vsf_spi_t *spi_ptr)
Enable a SPI instance for operation.
Definition spi_common.c:55
fsm_rt_t vsf_spi_disable(vsf_spi_t *spi_ptr)
Disable a SPI instance from operation.
Definition spi_common.c:64
struct vsf_spi_status_t vsf_spi_status_t
Predefined VSF SPI status that can be reimplemented in specific HAL drivers. Even if the hardware doe...
vsf_spi_mode_t
Predefined VSF SPI modes that can be reimplemented in specific HAL drivers.If we want to add optional...
Definition vsf_template_spi.h:273
@ VSF_SPI_CPHA_LOW
Clock polarity: idle state is high.
Definition vsf_template_spi.h:281
@ VSF_SPI_SLAVE
Master mode (controller)
Definition vsf_template_spi.h:275
@ VSF_SPI_DATASIZE_16
8-bit data transfer size
Definition vsf_template_spi.h:293
@ VSF_SPI_LSB_FIRST
Most Significant Bit (MSB) first.
Definition vsf_template_spi.h:277
@ VSF_SPI_CPOL_HIGH
Clock polarity: idle state is low.
Definition vsf_template_spi.h:280
@ VSF_SPI_MODE_1
Mode 0: CPOL=0 (idle low), CPHA=0 (sample on first edge)
Definition vsf_template_spi.h:285
@ VSF_SPI_DATASIZE_8
Hardware controlled chip select.
Definition vsf_template_spi.h:292
@ VSF_SPI_MASTER
Definition vsf_template_spi.h:274
@ VSF_SPI_CPHA_HIGH
Clock phase: sample on first edge.
Definition vsf_template_spi.h:282
@ VSF_SPI_MSB_FIRST
Slave mode (peripheral)
Definition vsf_template_spi.h:276
@ VSF_SPI_DATASIZE_32
16-bit data transfer size
Definition vsf_template_spi.h:294
@ VSF_SPI_CS_SOFTWARE_MODE
Mode 3: CPOL=1 (idle high), CPHA=1 (sample on second edge)
Definition vsf_template_spi.h:289
@ VSF_SPI_MODE_0
Clock phase: sample on second edge.
Definition vsf_template_spi.h:284
@ VSF_SPI_CS_HARDWARE_MODE
Software controlled chip select.
Definition vsf_template_spi.h:290
@ VSF_SPI_MODE_3
Mode 2: CPOL=1 (idle high), CPHA=0 (sample on first edge)
Definition vsf_template_spi.h:287
@ VSF_SPI_CPOL_LOW
Least Significant Bit (LSB) first.
Definition vsf_template_spi.h:279
@ VSF_SPI_MODE_2
Mode 1: CPOL=0 (idle low), CPHA=1 (sample on second edge)
Definition vsf_template_spi.h:286
void vsf_spi_irq_disable(vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask)
Disable specific interrupts for a SPI instance.
Definition spi_common.c:82
vsf_spi_ctrl_t
Predefined VSF SPI control commands that can be reimplemented in specific HAL drivers.
Definition vsf_template_spi.h:738
@ __VSF_SPI_CTRL_DUMMY
Definition vsf_template_spi.h:739
vsf_err_t vsf_spi_init(vsf_spi_t *spi_ptr, vsf_spi_cfg_t *cfg_ptr)
Initialize a SPI instance.
Definition spi_common.c:37
void vsf_spi_irq_enable(vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask)
Enable specific interrupts for a SPI instance.
Definition spi_common.c:73
void vsf_spi_fini(vsf_spi_t *spi_ptr)
Finalize (deinitialize) a SPI instance.
Definition spi_common.c:46
vsf_err_t vsf_spi_cs_inactive(vsf_spi_t *spi_ptr, uint_fast8_t index)
Deactivate (deassert) a SPI chip select line.
Definition spi_common.c:109
vsf_err_t vsf_spi_cancel_transfer(vsf_spi_t *spi_ptr)
Cancel an ongoing SPI transfer operation.
Definition spi_common.c:141
vsf_spi_capability_t vsf_spi_capability(vsf_spi_t *spi_ptr)
Get the capabilities of a SPI instance.
Definition spi_common.c:160