VSF Documented
|
Go to the source code of this file.
Data Structures | |
struct | vsf_spi_status_t |
struct | vsf_spi_capability_t |
struct | vsf_spi_isr_t |
spi isr for api More... | |
struct | vsf_spi_cfg_t |
spi configuration for api More... | |
struct | vsf_spi_op_t |
struct | vsf_spi_t |
Typedefs | |
typedef enum vsf_spi_mode_t | vsf_spi_mode_t |
Predefined VSF SPI modes that can be reimplemented in specific hal drivers. | |
typedef enum vsf_spi_irq_mask_t | vsf_spi_irq_mask_t |
Predefined VSF SPI interrupt that can be reimplemented in specific hal drivers. | |
typedef struct vsf_spi_status_t | vsf_spi_status_t |
typedef struct vsf_spi_capability_t | vsf_spi_capability_t |
typedef struct vsf_spi_t | vsf_spi_t |
typedef void | vsf_spi_isr_handler_t(void *target_ptr, vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
typedef struct vsf_spi_isr_t | vsf_spi_isr_t |
spi isr for api | |
typedef struct vsf_spi_cfg_t | vsf_spi_cfg_t |
spi configuration for api | |
typedef struct vsf_spi_op_t | vsf_spi_op_t |
Enumerations | |
enum | vsf_spi_mode_t { VSF_SPI_MASTER = 0x00ul << 0 , VSF_SPI_SLAVE = 0x01ul << 0 , VSF_SPI_MSB_FIRST = 0x00ul << 1 , VSF_SPI_LSB_FIRST = 0x01ul << 1 , VSF_SPI_CPOL_LOW = 0x00ul << 2 , VSF_SPI_CPOL_HIGH = 0x01ul << 2 , VSF_SPI_CPHA_LOW = 0x00ul << 2 , VSF_SPI_CPHA_HIGH = 0x01ul << 2 , VSF_SPI_MODE_0 = VSF_SPI_CPOL_LOW | VSF_SPI_CPHA_LOW , VSF_SPI_MODE_1 = VSF_SPI_CPOL_LOW | VSF_SPI_CPHA_HIGH , VSF_SPI_MODE_2 = VSF_SPI_CPOL_HIGH | VSF_SPI_CPHA_LOW , VSF_SPI_MODE_3 = VSF_SPI_CPOL_HIGH | VSF_SPI_CPHA_HIGH , VSF_SPI_CS_SOFTWARE_MODE = 0x00ul << 4 , VSF_SPI_CS_HARDWARE_MODE = 0x01ul << 4 , VSF_SPI_DATASIZE_8 = 0x00ul << 8 , VSF_SPI_DATASIZE_16 = 0x01ul << 8 , VSF_SPI_DATASIZE_32 = 0x02ul << 8 } |
Predefined VSF SPI modes that can be reimplemented in specific hal drivers. More... | |
enum | { VSF_SPI_DIR_MODE_MASK , VSF_SPI_BIT_ORDER_MASK , VSF_SPI_MODE_MASK , VSF_SPI_CS_MODE_MASK , VSF_SPI_DATASIZE_MASK , VSF_SPI_MODE_ALL_BITS_MASK } |
enum | vsf_spi_irq_mask_t { VSF_SPI_IRQ_MASK_TX = 0x01ul << 0 , VSF_SPI_IRQ_MASK_RX = 0x01ul << 1 , VSF_SPI_IRQ_MASK_TX_CPL = 0x01ul << 2 , VSF_SPI_IRQ_MASK_CPL = 0x01ul << 3 , VSF_SPI_IRQ_MASK_OVERFLOW_ERR = 0x01ul << 4 , VSF_SPI_IRQ_MASK_ERROR = 0x01ul << 5 } |
Predefined VSF SPI interrupt that can be reimplemented in specific hal drivers. More... | |
enum | { VSF_SPI_IRQ_MASK_TX_FIFO_THRESHOLD = VSF_SPI_IRQ_MASK_TX , VSF_SPI_IRQ_MASK_RX_FIFO_THRESHOLD = VSF_SPI_IRQ_MASK_RX , VSF_SPI_IRQ_MASK_RX_CPL = VSF_SPI_IRQ_MASK_CPL , VSF_SPI_IRQ_ALL_BITS_MASK } |
Functions | |
vsf_err_t | vsf_spi_init (vsf_spi_t *spi_ptr, vsf_spi_cfg_t *cfg_ptr) |
initialize a spi instance. | |
void | vsf_spi_fini (vsf_spi_t *spi_ptr) |
finalize a spi instance. | |
fsm_rt_t | vsf_spi_enable (vsf_spi_t *spi_ptr) |
enable interrupt masks of spi instance. | |
fsm_rt_t | vsf_spi_disable (vsf_spi_t *spi_ptr) |
disable interrupt masks of spi instance. | |
void | vsf_spi_irq_enable (vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
enable interrupt masks of spi instance. | |
void | vsf_spi_irq_disable (vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
disable interrupt masks of spi instance. | |
void | vsf_spi_cs_active (vsf_spi_t *spi_ptr, uint_fast8_t index) |
spi set chip select active | |
void | vsf_spi_cs_inactive (vsf_spi_t *spi_ptr, uint_fast8_t index) |
spi set chip select inactive | |
vsf_spi_status_t | vsf_spi_status (vsf_spi_t *spi_ptr) |
get the status of spi instance. | |
vsf_spi_capability_t | vsf_spi_capability (vsf_spi_t *spi_ptr) |
get the capability of spi instance. | |
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) |
spi fifo transfer | |
vsf_err_t | vsf_spi_request_transfer (vsf_spi_t *spi_ptr, void *out_buffer_ptr, void *in_buffer_ptr, uint_fast32_t count) |
start spi transfer. The best way to do this is to use DMA. Software implementation is the solution when DMA cannot be used | |
vsf_err_t | vsf_spi_cancel_transfer (vsf_spi_t *spi_ptr) |
spi cancel transfer | |
void | vsf_spi_get_transferred_count (vsf_spi_t *spi_ptr, uint_fast32_t *sent_count, uint_fast32_t *received_count) |
spi get transferred counter | |
#define VSF_SPI_CFG_MULTI_CLASS ENABLED |
#define VSF_SPI_CFG_PREFIX vsf |
#define VSF_SPI_CFG_FUNCTION_RENAME ENABLED |
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
In the specific hardware driver, we can enable VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE to redefine vsf_spi_mode_t as needed.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED |
In the specific hardware driver, we can enable VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine vsf_spi_irq_mask_t as needed.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In the specific hardware driver, we can enable VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS to redefine vsf_spi_status_t as needed.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG DISABLED |
Redefine struct vsf_spi_cfg_t. The vsf_spi_isr_handler_t type also needs to be redefined For compatibility, members should not be deleted when struct vsf_spi_cfg_t redefining.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED |
Redefine struct vsf_spi_capability_t. For compatibility, members should not be deleted when struct vsf_spi_capability_t redefining.
#define VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED |
In the specific hardware driver, we can enable VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to reimplement the function vsf_spi_mode_to_data_bits as needed.
#define VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE DISABLED |
In the specific hardware driver, we can enable VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to reimplement the function vsf_spi_data_bits_to_mode as needed.
#define VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_BYTES DISABLED |
In the specific hardware driver, we can enable VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to reimplement the function vsf_spi_data_bits_to_mode as needed.
#define VSF_SPI_CFG_INHERT_HAL_CAPABILITY ENABLED |
#define VSF_SPI_APIS | ( | __prefix_name | ) |
#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP |
#define __vsf_spi_t VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_t) |
#define vsf_spi_init | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_init) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_enable | ( | __SPI | ) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_enable) ((__vsf_spi_t *)(__SPI)) |
#define vsf_spi_disable | ( | __SPI | ) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_disable) ((__vsf_spi_t *)(__SPI)) |
#define vsf_spi_irq_enable | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_irq_enable) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_irq_disable | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_irq_disable) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_status | ( | __SPI | ) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_status) ((__vsf_spi_t *)(__SPI)) |
#define vsf_spi_capability | ( | __SPI | ) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_capability) ((__vsf_spi_t *)(__SPI)) |
#define vsf_spi_cs_active | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_cs_active) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_cs_inactive | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_cs_inactive) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_fifo_transfer | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_fifo_transfer) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_request_transfer | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_request_transfer) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
#define vsf_spi_cancel_transfer | ( | __SPI | ) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_cancel_transfer) ((__vsf_spi_t *)(__SPI)) |
#define vsf_spi_get_transferred_count | ( | __SPI, | |
... | |||
) | VSF_MCONNECT(VSF_SPI_CFG_PREFIX, _spi_get_transferred_count) ((__vsf_spi_t *)(__SPI), ##__VA_ARGS__) |
typedef enum vsf_spi_mode_t vsf_spi_mode_t |
Predefined VSF SPI modes that can be reimplemented in specific hal drivers.
Even if the hardware doesn't support these modes, the following modes must be kept, If the hardware supports more modes, e.g. more databits, more slave select mode, we can implement it in the hardware driver:
If more new modes are added to the driver, then the corresponding MASK macros need to be defined to include the values of the new modes. For example, Adding the new databit option requires that the macro VSF_SPI_DATASIZE_MASK be defined.
Optional features require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.
typedef enum vsf_spi_irq_mask_t vsf_spi_irq_mask_t |
Predefined VSF SPI interrupt that can be reimplemented in specific hal drivers.
Even if the hardware doesn't support these features, these interrupt must be kept.
typedef struct vsf_spi_status_t vsf_spi_status_t |
typedef struct vsf_spi_capability_t vsf_spi_capability_t |
typedef void vsf_spi_isr_handler_t(void *target_ptr, vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
typedef struct vsf_spi_isr_t vsf_spi_isr_t |
spi isr for api
typedef struct vsf_spi_cfg_t vsf_spi_cfg_t |
spi configuration for api
typedef struct vsf_spi_op_t vsf_spi_op_t |
enum vsf_spi_mode_t |
Predefined VSF SPI modes that can be reimplemented in specific hal drivers.
Even if the hardware doesn't support these modes, the following modes must be kept, If the hardware supports more modes, e.g. more databits, more slave select mode, we can implement it in the hardware driver:
If more new modes are added to the driver, then the corresponding MASK macros need to be defined to include the values of the new modes. For example, Adding the new databit option requires that the macro VSF_SPI_DATASIZE_MASK be defined.
Optional features require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.
anonymous enum |
enum vsf_spi_irq_mask_t |
Predefined VSF SPI interrupt that can be reimplemented in specific hal drivers.
Even if the hardware doesn't support these features, these interrupt must be kept.
Enumerator | |
---|---|
VSF_SPI_IRQ_MASK_TX | |
VSF_SPI_IRQ_MASK_RX | |
VSF_SPI_IRQ_MASK_TX_CPL | |
VSF_SPI_IRQ_MASK_CPL | |
VSF_SPI_IRQ_MASK_OVERFLOW_ERR | |
VSF_SPI_IRQ_MASK_ERROR |
anonymous enum |
|
extern |
initialize a spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | cfg_ptr | a pointer to structure vsf_spi_cfg_t |
|
extern |
enable interrupt masks of spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
disable interrupt masks of spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
|
extern |
enable interrupt masks of spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | irq_mask | one or more value of enum vsf_spi_irq_mask_t |
|
extern |
disable interrupt masks of spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | irq_mask | one or more value of enum vsf_spi_irq_mask_t, vsf_spi_irq_mask_t |
|
extern |
spi set chip select active
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | index | chip select index |
|
extern |
spi set chip select inactive
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | index | chip select index |
|
extern |
get the status of spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
|
extern |
get the capability of spi instance.
[in] | spi_ptr | a pointer to structure vsf_spi_t |
|
extern |
spi fifo transfer
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | out_buffer_ptr | a pointer to spi send data buffer, it can be a null pointer |
[in,out] | out_offset_ptr | a pointer to spi send data buffer offset |
[in] | in_buffer_ptr | a pointer to spi receive data buffer, it can be a null pointer |
[in,out] | in_offset_ptr | a pointer to spi send data buffer offset |
[in] | count | The number of data received or sent |
|
extern |
start spi transfer. The best way to do this is to use DMA. Software implementation is the solution when DMA cannot be used
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[in] | out_buffer_ptr | a pointer to spi send data buffer, it can be a null pointer |
[in] | in_buffer_ptr | a pointer to spi receive data buffer, it can be a null pointer |
[in] | count | The number of data received or sent |
spi cancel transfer
[in] | spi_ptr | a pointer to structure vsf_spi_t |
|
extern |
spi get transferred counter
[in] | spi_ptr | a pointer to structure vsf_spi_t |
[out] | send_count | a pointer to the number of spi data already sent |
[out] | received_count | a pointer to the number of spi data already received |