monoZ docs
MZ_spi.h
Go to the documentation of this file.
1
7#ifndef INC_MZ_SPI_H_
8#define INC_MZ_SPI_H_
9
10#include "MZ_public.h"
11#include "MZ_common.h"
12#include "MZ_error_handler.h"
13#include "stm32l4xx_hal_spi.h"
14
20typedef enum
21{
22#if(MZ_SPI1 == 1)
23 _SPI1,
24#endif
25#if(MZ_SPI2 == 1)
26 _SPI2,
27#endif
28#if(MZ_SPI3 == 1)
29 _SPI3,
30#endif
33
34#define SPI_MAX_COUNT_SIZE SPI_MAX_COUNT
35
41
46typedef struct
47{
49 SPI_HandleTypeDef _handler;
62}MZ_SPIX;
63
68typedef struct
69{
70 SPI_HandleTypeDef *spi_ptr;
71 enum
72 {
75 }event;
77
82typedef MZ_SPIX MZ_SPI_BTYPE; /* SPI Base Type */
83
88typedef MZ_SPIX * MZ_SPI_BTYPE_PTR; /* SPI Base Type pointer */
89
99MZ_SPI_BTYPE_PTR MZ_SPI_get_base_address(void); // Get the base address of the SPI internal context */
100
108
115mz_error_t MZ_SPI_init(MZ_SPI_INIT_PTR _cfg); // Register a SPI. Need to call from Upper layer */
116
125
134
143
150void MZ_HAL_SPI_IRQHandler(uint8_t spi_no); // Global Interrupt handler function */
151
161mz_error_t MZ_SPI_Transmit(uint8_t spi_no, uint8_t *pData, uint16_t Size, uint32_t Timeout);
162
172mz_error_t MZ_SPI_Receive(uint8_t spi_no, uint8_t *pData, uint16_t Size, uint32_t Timeout);
173
184mz_error_t MZ_SPI_TransmitReceive(uint8_t spi_no, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size,
185 uint32_t Timeout);
186
195mz_error_t MZ_SPI_Transmit_IT(uint8_t spi_no, uint8_t *pData, uint16_t Size);
196
205mz_error_t MZ_SPI_Receive_IT(uint8_t spi_no, uint8_t *pData, uint16_t Size);
206
216mz_error_t MZ_SPI_TransmitReceive_IT(uint8_t spi_no, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
217
220#endif /* INC_MZ_SPI_H_ */
monoZ Lib Common.
unsigned char mzUint8
1 Byte data type
Definition: MZ_common.h:57
unsigned long int mzUint32
4 Byte data type
Definition: MZ_common.h:95
mzReg
monoZ Register and Deregister
Definition: MZ_common.h:123
void(* _mz_fp)(void *)
Definition: MZ_common.h:33
monoZ Error Handler
mz_error_t
Enumeration of monoZ Error Flags.
monoZ Public All peripheral Configurations will send to monoZ library through this file
en_spi_no
Enumeration for monoZ SPI Enable or disable the I2C instance.
Definition: MZ_spi.h:21
@ SPI_MAX_COUNT
Definition: MZ_spi.h:31
MZ_SPIX MZ_SPI_BTYPE
[TODO]
Definition: MZ_spi.h:82
MZ_SPIX * MZ_SPI_BTYPE_PTR
[TODO]
Definition: MZ_spi.h:88
_mz_fp _spi_api
use _spi_api as monoZ function pointer
Definition: MZ_spi.h:40
mz_error_t MZ_SPI_TransmitReceive_IT(uint8_t spi_no, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
This function is used to transmit/receive data using SPI in interrupt mode.
MZ_SPI_BTYPE_PTR MZ_SPI_reference(en_spi_no spi_no)
This function returns the address of specific SPI defined in SDK.
mz_error_t MZ_SPI_Receive_IT(uint8_t spi_no, uint8_t *pData, uint16_t Size)
This function is used to receive data using SPI in interrupt mode.
mz_error_t MZ_SPI_register_callback(uint8_t spi_no, _spi_api cb)
This function registers the SPI Event callback.
mz_error_t MZ_SPI_Transmit(uint8_t spi_no, uint8_t *pData, uint16_t Size, uint32_t Timeout)
This function is used to transmit data using SPI in polling mode.
mz_error_t MZ_SPI_init(MZ_SPI_INIT_PTR _cfg)
This function initializes the specific SPI.
mz_error_t MZ_SPI_register_intr_cb_tx(uint8_t spi_no, _spi_api cb)
This function registers the Interrupt for TX complete callback function for the specific SPI.
mz_error_t MZ_SPI_TransmitReceive(uint8_t spi_no, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout)
This function is used to transmit/receive data using SPI in polling mode.
mz_error_t MZ_SPI_register_intr_cb_rx(uint8_t spi_no, _spi_api cb)
This function registers the Interrupt for RX complete callback function for the specific SPI.
mz_error_t MZ_SPI_Receive(uint8_t spi_no, uint8_t *pData, uint16_t Size, uint32_t Timeout)
This function is used to receive data using SPI in polling mode.
void MZ_HAL_SPI_IRQHandler(uint8_t spi_no)
This function defines the Global Interrupt handler functions of SPI.
mz_error_t MZ_SPI_Transmit_IT(uint8_t spi_no, uint8_t *pData, uint16_t Size)
This function is used to transmit data using SPI in interrupt mode.
MZ_SPI_BTYPE_PTR MZ_SPI_get_base_address(void)
This function returns the base address of all the SPI defined in SDK.
Definition: MZ_spi.h:47
mzUint8 * _rx_buffer
Definition: MZ_spi.h:51
_spi_api write
Definition: MZ_spi.h:58
mzUint8 _enable
Definition: MZ_spi.h:50
_spi_api SPI_ev_call_back
Definition: MZ_spi.h:61
mzUint8 _tx_intr
Definition: MZ_spi.h:56
SPI_HandleTypeDef _handler
Definition: MZ_spi.h:49
mzUint8 * _tx_buffer
Definition: MZ_spi.h:53
_spi_api tx_intr_api
Definition: MZ_spi.h:60
mzUint8 _rx_intr
Definition: MZ_spi.h:55
mzReg _reg_status
Definition: MZ_spi.h:48
_spi_api read
Definition: MZ_spi.h:57
mzUint32 _tx_buffer_size
Definition: MZ_spi.h:54
_spi_api rx_intr_api
Definition: MZ_spi.h:59
mzUint32 _rx_buffer_size
Definition: MZ_spi.h:52
SPI_HandleTypeDef * spi_ptr
Definition: MZ_spi.h:70
@ SPI_HALF_COMPLETE
Definition: MZ_spi.h:74
@ SPI_FULL_COMPLETE
Definition: MZ_spi.h:73