MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
spi17y.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  * $Date: 2018-11-05 13:40:08 -0600 (Mon, 05 Nov 2018) $
38  * $Revision: 38949 $
39  *
40  *************************************************************************** */
41 
42 /* Define to prevent redundant inclusion */
43 #ifndef _SPI17Y_H_
44 #define _SPI17Y_H_
45 
46 /* **** Includes **** */
47 #include "mxc_config.h"
48 #include "spi17y_regs.h"
49 #include "mxc_sys.h"
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
61 /* **** Definitions **** */
62 
66 typedef enum {
71 
75 typedef enum {
79 
83 typedef struct spi17y_req spi17y_req_t;
84 
85 
99 typedef void (*spi17y_callback_fn)(spi17y_req_t * req, int error_code);
100 
107 struct spi17y_req {
108  uint8_t ssel;
109  uint8_t deass;
111  const void *tx_data;
112  void *rx_data;
114  unsigned len;
115  unsigned bits;
116  unsigned rx_num;
117  unsigned tx_num;
118  spi17y_callback_fn callback;
119 };
120 
121 
122 /* **** Function Prototypes **** */
123 
134 int SPI17Y_Init(mxc_spi17y_regs_t *spi, unsigned int mode, unsigned int freq, const sys_cfg_spi17y_t* sys_cfg);
135 
144 
153 
163 int SPI17Y_MasterTrans(mxc_spi17y_regs_t *spi, spi17y_req_t *req);
164 
174 int SPI17Y_SlaveTrans(mxc_spi17y_regs_t *spi, spi17y_req_t *req);
175 
185 int SPI17Y_MasterTransAsync(mxc_spi17y_regs_t *spi, spi17y_req_t *req);
186 
196 int SPI17Y_SlaveTransAsync(mxc_spi17y_regs_t *spi, spi17y_req_t *req);
197 
205 int SPI17Y_AbortAsync(spi17y_req_t *req);
206 
215 
225 
234 
235 
238 #ifdef __cplusplus
239 }
240 #endif
241 
242 #endif /* _SPI17Y_H_ */
unsigned tx_num
Number of bytes actually sent from the tx_data buffer.
Definition: spi17y.h:117
4 Data Lines (x4).
Definition: spi17y.h:69
1 Data Line.
Definition: spi17y.h:67
spi17y_callback_fn callback
Callback function if desired, NULL otherwise.
Definition: spi17y.h:118
int SPI17Y_SlaveTrans(mxc_spi17y_regs_t *spi, spi17y_req_t *req)
Execute a slave transaction.
void SPI17Y_Clear_fifo(mxc_spi17y_regs_t *spi)
Clear the TX and RX FIFO.
spi17y_sspol_t ssel_pol
Slave select line polarity.
Definition: spi17y.h:110
int SPI17Y_Init(mxc_spi17y_regs_t *spi, unsigned int mode, unsigned int freq, const sys_cfg_spi17y_t *sys_cfg)
Initialize the spi.
void * rx_data
Pointer to a buffer to store data received.
Definition: spi17y.h:112
Polarity High.
Definition: spi17y.h:77
uint8_t ssel
Slave select line to use.
Definition: spi17y.h:108
Structure type representing a SPI17Y Master Transaction request.
Definition: spi17y.h:107
2 Data Lines (x2).
Definition: spi17y.h:68
int SPI17Y_MasterTransAsync(mxc_spi17y_regs_t *spi, spi17y_req_t *req)
Asynchronously read/write SPI Master data.
spi17y_width_t
Enumeration type for setting the number data lines to use for communication.
Definition: spi17y.h:66
unsigned bits
Number of bits in transfer unit (e.g.
Definition: spi17y.h:115
SPI17Y Configuration Object.
Definition: mxc_sys.h:177
unsigned rx_num
Number of bytes actually read into the rx_data buffer.
Definition: spi17y.h:116
void SPI17Y_Handler(mxc_spi17y_regs_t *spi)
Processing function for asynchronous SPI operations.
unsigned len
Number of transfer units to send from the tx_data buffer.
Definition: spi17y.h:114
int SPI17Y_Shutdown(mxc_spi17y_regs_t *spi)
Shutdown SPI module.
uint8_t deass
Non-zero to de-assert slave select after transaction.
Definition: spi17y.h:109
int SPI17Y_AbortAsync(spi17y_req_t *req)
Aborts an Asynchronous request.
spi17y_sspol_t
Enumeration type for setting the polarity of ss lines.
Definition: spi17y.h:75
int SPI17Y_SlaveTransAsync(mxc_spi17y_regs_t *spi, spi17y_req_t *req)
Asynchronously read/write SPI Slave data.
Structure type to access the SPI17Y Registers.
Definition: spi17y_regs.h:88
const void * tx_data
Pointer to a buffer to transmit data from.
Definition: spi17y.h:111
Polarity Low.
Definition: spi17y.h:76
void SPI17Y_Disable(mxc_spi17y_regs_t *spi)
Disable SPI.
spi17y_width_t width
Number of data lines to use, see spi17y_width_t.
Definition: spi17y.h:113
int SPI17Y_MasterTrans(mxc_spi17y_regs_t *spi, spi17y_req_t *req)
Execute a master transaction.
void SPI17Y_Enable(mxc_spi17y_regs_t *spi)
Enable SPI.