monoZ docs
MZ_spi2_instance.c
Go to the documentation of this file.
1/*
2 * MZ_spi1_instance.c
3 *
4 * Created on: 20-Jul-2021
5 * Author: Mahendra
6 */
7#include <MZ_spi2_instance.h>
8#include "MZ_public.h"
9#include "MZ_spi.h"
10
11static char rx_char = 0;
12
13static void spi2_tx_intr(void * arg)
14{
15 st_spi_intr evt = * (st_spi_intr *)arg;
16 (void)evt;
17 // Transmission complete
18}
19
20static void spi2_rx_intr(void * arg)
21{
22 st_spi_intr evt = * (st_spi_intr *)arg;
23 (void)evt;
24
25 // 1 Byte Receive complete - Initiate another Byte receive
26 (void)MZ_SPI_Receive_IT(MZ_SPI_INSTANCE, (uint8_t *)&rx_char, 1);
27}
28
29MZ_SPI_INIT_ST _instance =
30{
31 .Instance = MZ_SPI2_INSTANCE,
32 .Init.Mode = MZ_SPI2_INIT_MODE,
33 .Init.Direction = MZ_SPI2_INIT_DIRECTION,
34 .Init.DataSize = MZ_SPI2_INIT_DATASIZE,
35 .Init.CLKPolarity = MZ_SPI2_INIT_CLKPOLARITY,
36 .Init.CLKPhase = MZ_SPI2_INIT_CLKPHASE,
37 .Init.NSS = MZ_SPI2_INIT_NSS,
38 .Init.BaudRatePrescaler = MZ_SPI2_INIT_BAUDRATEPRESCALER,
39 .Init.FirstBit = MZ_SPI2_INIT_FIRSTBIT,
40 .Init.TIMode = MZ_SPI2_INIT_TIMODE,
41 .Init.CRCCalculation = MZ_SPI2_INIT_CRCCALCULATION,
42 .Init.CRCPolynomial = MZ_SPI2_INIT_CRCPOLYNOMIAL,
43 .Init.CRCLength = MZ_SPI2_INIT_CRCLENGTH,
44 .Init.NSSPMode = MZ_SPI2_INIT_NSSPMODE
45};
46
48{
49 mz_error_t _ret = MZ_FAIL;
50
52 {
54 {
55 _ret = MZ_OK;
56 // Initiate 1 Byte receive
57 (void)MZ_SPI_Receive_IT(MZ_SPI_INSTANCE, (uint8_t *)&rx_char, 1);
58 }
59 }
60
61 return _ret;
62}
mz_error_t
Enumeration of monoZ Error Flags.
@ MZ_OK
@ MZ_FAIL
monoZ Public All peripheral Configurations will send to monoZ library through this file
MZ_SPI_INIT_ST _instance
mz_error_t SPI2_init(void)
static char rx_char
static void spi2_tx_intr(void *arg)
static void spi2_rx_intr(void *arg)
#define MZ_SPI2_INIT_FIRSTBIT
#define MZ_SPI2_INIT_MODE
#define MZ_SPI2_INIT_TIMODE
#define MZ_SPI2_INIT_CRCCALCULATION
#define MZ_SPI2_INSTANCE
#define MZ_SPI2_INIT_DIRECTION
#define MZ_SPI2_INIT_NSS
#define MZ_SPI2_INIT_BAUDRATEPRESCALER
#define MZ_SPI2_INIT_DATASIZE
#define MZ_SPI2_INIT_NSSPMODE
#define MZ_SPI2_INIT_CLKPHASE
#define MZ_SPI_INSTANCE
#define MZ_SPI2_INIT_CRCLENGTH
#define MZ_SPI2_INIT_CRCPOLYNOMIAL
#define MZ_SPI2_INIT_CLKPOLARITY
This file contains all the functionalities for SPI protocol.
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_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_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.