MAX32660 Peripheral Driver API
Peripheral Driver API for the MAX32660
spimss.h
1
6/******************************************************************************
7 *
8 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
9 * Analog Devices, Inc.),
10 * Copyright (C) 2023-2024 Analog Devices, Inc.
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 ******************************************************************************/
25
26/* Define to prevent redundant inclusion */
27#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32660_SPIMSS_H_
28#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32660_SPIMSS_H_
29
30/* **** Includes **** */
31#include "mxc_device.h"
32#include "mxc_sys.h"
33#include "mxc_pins.h"
34#include "gpio.h"
35#include "spimss_regs.h"
36#include "stdbool.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
48/* **** Definitions **** */
49
53typedef enum { // ONLY FOR COMPATIBILITY FOR CONSOLIDATION WITH SPY17, NOT USED OR NEEDED
58
62typedef struct mxc_spimss_req mxc_spimss_req_t;
63
76typedef void (*mxc_spimss_callback_fn)(mxc_spimss_req_t *req, int error_code);
77
84 uint8_t ssel;
85 uint8_t deass;
86 void *tx_data;
87 void *rx_data;
89 unsigned len;
90 unsigned bits;
91 unsigned rx_num;
92 unsigned tx_num;
94};
95
96/* **** Function Prototypes **** */
97
107int MXC_SPIMSS_Init(mxc_spimss_regs_t *spi, unsigned mode, unsigned freq, const sys_map_t sys_cfg);
108
116
125int MXC_SPIMSS_MasterTrans(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req);
126
135int MXC_SPIMSS_MasterTransDMA(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req);
136
143
152int MXC_SPIMSS_SlaveTrans(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req);
153
163int MXC_SPIMSS_MasterTransAsync(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req);
164
174int MXC_SPIMSS_SlaveTransAsync(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req);
175
183int MXC_SPIMSS_AbortAsync(mxc_spimss_req_t *req);
184
197
206int MXC_SPIMSS_SetTXDMAChannel(mxc_spimss_regs_t *spi, unsigned int channel);
207
215
224int MXC_SPIMSS_SetRXDMAChannel(mxc_spimss_regs_t *spi, unsigned int channel);
225
233
236#ifdef __cplusplus
237}
238#endif
239
240#endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32660_SPIMSS_H_
Definition: spimss_regs.h:76
unsigned rx_num
Definition: spimss.h:91
void * rx_data
Definition: spimss.h:87
mxc_spimss_callback_fn callback
Definition: spimss.h:93
unsigned len
Definition: spimss.h:89
mxc_spimss_width_t width
Definition: spimss.h:88
unsigned bits
Definition: spimss.h:90
uint8_t deass
Definition: spimss.h:85
void * tx_data
Definition: spimss.h:86
uint8_t ssel
Definition: spimss.h:84
unsigned tx_num
Definition: spimss.h:92
void(* mxc_spimss_callback_fn)(mxc_spimss_req_t *req, int error_code)
Callback function type used in asynchronous SPI Master communication requests.
Definition: spimss.h:76
int MXC_SPIMSS_GetTXDMAChannel(mxc_spimss_regs_t *spi)
Returns the current TX channel id set for SPIMSS DMA transaction.
int MXC_SPIMSS_SetAutoDMAHandlers(mxc_spimss_regs_t *spi, bool enable)
Enable Disable auto dma handling. If set to true, dma channel for transaction is acquired in the MXC_...
int MXC_SPIMSS_SlaveTrans(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req)
Execute a slave transaction.
int MXC_SPIMSS_AbortAsync(mxc_spimss_req_t *req)
Aborts an Asynchronous request.
int MXC_SPIMSS_MasterTransAsync(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req)
Asynchronously read/write SPI Master data.
int MXC_SPIMSS_SetRXDMAChannel(mxc_spimss_regs_t *spi, unsigned int channel)
Set the RX channel id for DMA to be used in SPIMSS DMA transaction.
int MXC_SPIMSS_MasterTrans(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req)
Execute a master transaction.
int MXC_SPIMSS_Init(mxc_spimss_regs_t *spi, unsigned mode, unsigned freq, const sys_map_t sys_cfg)
Initialize the spi.
int MXC_SPIMSS_Shutdown(mxc_spimss_regs_t *spi)
Shutdown SPI module.
int MXC_SPIMSS_MasterTransDMA(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req)
Execute a master transaction over DMA.
void MXC_SPIMSS_Handler(mxc_spimss_regs_t *spi)
Execute SPI transaction based on interrupt handler.
int MXC_SPIMSS_GetRXDMAChannel(mxc_spimss_regs_t *spi)
Returns the current RX channel id set for SPIMSS DMA transaction.
int MXC_SPIMSS_SetTXDMAChannel(mxc_spimss_regs_t *spi, unsigned int channel)
Set the TX channel id for DMA to be used in SPIMSS DMA transaction.
mxc_spimss_width_t
Enumeration type for setting the number data lines to use for communication.
Definition: spimss.h:53
int MXC_SPIMSS_SlaveTransAsync(mxc_spimss_regs_t *spi, mxc_spimss_req_t *req)
Asynchronously read/write SPI Slave data.
@ DUMMY_1
Definition: spimss.h:54
@ DUMMY_2
Definition: spimss.h:55
@ DUMMY_3
Definition: spimss.h:56
Structure definition for an SPI Master Transaction request.
Definition: spimss.h:83
Registers, Bit Masks and Bit Positions for the SPIMSS Peripheral Module.