MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
spixr.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2017 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  *************************************************************************** */
38 
39 /* Define to prevent redundant inclusion */
40 #ifndef _MXC_SPIXR_H_
41 #define _MXC_SPIXR_H_
42 
43 /* **** Includes **** */
44 #include "spixr_regs.h"
45 #include "mxc_sys.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
57 /* **** Definitions **** */
62 
67 typedef enum {
68  MXC_SPIXR_SINGLE_SDIO = 0,
69  MXC_SPIXR_DUAL_SDIO,
70  MXC_SPIXR_QUAD_SDIO,
71  MXC_SPIXR_INVALID,
73 
78 typedef enum {
79  MXC_SPIXR_MODE_0,
80  MXC_SPIXR_MODE_1,
81  MXC_SPIXR_MODE_2,
82  MXC_SPIXR_MODE_3,
84 
88 typedef struct {
89 
90  uint32_t numbits;
92 
93  uint32_t ssel_act_1;
94  uint32_t ssel_act_2;
95  uint32_t ssel_inact;
96 
97  uint32_t baud_freq;
99 
100 
101 /* **** Function Prototypes **** */
102 
111 int MXC_SPIXR_ReadRXFIFO (uint8_t* buf, int len);
112 
121 int MXC_SPIXR_WriteTXFIFO (uint8_t* buf, int len);
122 
128 void MXC_SPIXR_SetSS (int ssIdx);
129 
135 int MXC_SPIXR_GetSS (void);
136 
143 void MXC_SPIXR_SetSSCtrl (int stayActive);
144 
151 
156 void MXC_SPIXR_Enable (void);
157 
163 void MXC_SPIXR_Disable (void);
164 
171 
177 
183 
190 
196 
202 
209 
215 
221 
228 
234 
240 
247 
253 
259 
266 
273 
280 
286 
292 
301 
310 
318 int MXC_SPIXR_SetSSPolarity (int activeLow);
319 
329 void MXC_SPIXR_SetSSTiming (unsigned int ssIActDelay, unsigned int postActive, unsigned int preActive);
330 
339 
346 
354 
360 void MXC_SPIXR_EnableInt (int flags);
361 
367 void MXC_SPIXR_DisableInt (int flags);
368 
376 
382 void MXC_SPIXR_EnableWakeUp (int flags);
383 
389 void MXC_SPIXR_DisableWakeUp (int flags);
390 
395 
400 
407 void MXC_SPIXR_ExMemUseDummy (int delay255);
408 
414 void MXC_SPIXR_ExMemSetWriteCommand (uint8_t command);
415 
422 
428 void MXC_SPIXR_ExMemSetReadCommand (uint8_t command);
429 
436 
444 int MXC_SPIXR_Busy (void);
445 
455 
463 
470 void MXC_SPIXR_SendCommand (uint8_t* cmd, uint32_t length, uint32_t tx_num_char);
471 
472 #ifdef __cplusplus
473 }
474 #endif
475 
478 #endif /* _MXC_SPIXR_H_ */
MXC_SPIXR_ExMemEnable
void MXC_SPIXR_ExMemEnable(void)
Enable the external memory mode.
mxc_spixr_width_t
mxc_spixr_width_t
Structure type for configuring a SPIXR port.
Definition: spixr.h:67
mxc_spixr_cfg_t::ssel_inact
uint32_t ssel_inact
Slave Select Inactive delay.
Definition: spixr.h:95
MXC_SPIXR_ExMemUseDummy
void MXC_SPIXR_ExMemUseDummy(int delay255)
Put 255 characters worth of clocks between address and read phase of external memory transactions.
MXC_SPIXR_SetSS
void MXC_SPIXR_SetSS(int ssIdx)
Select which SS pin is used in SPIXR.
MXC_SPIXR_SetSPIMode
int MXC_SPIXR_SetSPIMode(mxc_spixr_mode_t mode)
Set the SPI Mode used.
MXC_SPIXR_ThreeWireModeDisable
void MXC_SPIXR_ThreeWireModeDisable(void)
Disable three wire mode.
MXC_SPIXR_ThreeWireModeEnable
void MXC_SPIXR_ThreeWireModeEnable(void)
Enable three wire mode.
MXC_SPIXR_WriteTXFIFO
int MXC_SPIXR_WriteTXFIFO(uint8_t *buf, int len)
Loads bytes into the FIFO.
MXC_SPIXR_Busy
int MXC_SPIXR_Busy(void)
SPI active status.
MXC_SPIXR_Disable
void MXC_SPIXR_Disable(void)
Disable the SPIXR peripheral.
MXC_SPIXR_SetFrequency
int MXC_SPIXR_SetFrequency(int hz)
Set the SPI Frequency.
MXC_SPIXR_DmaTXFIFOIsEnabled
int MXC_SPIXR_DmaTXFIFOIsEnabled(void)
Get if TXFIFO DMA is enabled.
MXC_SPIXR_TXFIFOEnable
void MXC_SPIXR_TXFIFOEnable(void)
Enable the TXFIFO.
MXC_SPIXR_RXFIFOClear
void MXC_SPIXR_RXFIFOClear(void)
Clear RX FIFO.
MXC_SPIXR_ExMemSetWriteCommand
void MXC_SPIXR_ExMemSetWriteCommand(uint8_t command)
Set the write command used for external memory mode.
MXC_SPIXR_DmaTXFIFOEnable
void MXC_SPIXR_DmaTXFIFOEnable(void)
Enable the TXFIFO DMA.
MXC_SPIXR_RXFIFOIsEnabled
int MXC_SPIXR_RXFIFOIsEnabled(void)
Get if RXFIFO is enabled.
MXC_SPIXR_DisableInt
void MXC_SPIXR_DisableInt(int flags)
Disable SPIXR interrupts.
MXC_SPIXR_RXFIFOEnable
void MXC_SPIXR_RXFIFOEnable(void)
Enable the RXFIFO.
MXC_SPIXR_GetRXFIFOCount
int MXC_SPIXR_GetRXFIFOCount(void)
Get the number of bytes currently in the RX FIFO.
MXC_SPIXR_ExMemSetReadCommand
void MXC_SPIXR_ExMemSetReadCommand(uint8_t command)
Set the read command used for external memory mode.
MXC_SPIXR_DmaRXFIFOEnable
void MXC_SPIXR_DmaRXFIFOEnable(void)
Enable the RXFIFO DMA.
mxc_spixr_cfg_t::ssel_act_1
uint32_t ssel_act_1
Slave Select Action delay 1.
Definition: spixr.h:93
MXC_SPIXR_TXFIFOIsEnabled
int MXC_SPIXR_TXFIFOIsEnabled(void)
Get if TXFIFO is enabled.
MXC_SPIXR_ExMemGetReadCommand
uint8_t MXC_SPIXR_ExMemGetReadCommand(void)
Get the read command used for external memory mode.
MXC_SPIXR_EnableWakeUp
void MXC_SPIXR_EnableWakeUp(int flags)
Enable Wake up for SPIXR.
mxc_spixr_cfg_t::ssel_act_2
uint32_t ssel_act_2
Slave Select Action delay 2.
Definition: spixr.h:94
MXC_SPIXR_SetSSTiming
void MXC_SPIXR_SetSSTiming(unsigned int ssIActDelay, unsigned int postActive, unsigned int preActive)
Set the SS Timing Parameters.
mxc_spixr_cfg_t::data_width
mxc_spixr_width_t data_width
SPI Data width.
Definition: spixr.h:91
MXC_SPIXR_IsEnabled
int MXC_SPIXR_IsEnabled(void)
Get if SPIXR is enabled.
MXC_SPIXR_GetTXFIFOCount
int MXC_SPIXR_GetTXFIFOCount(void)
Get the number of bytes currently in the TX FIFO.
MXC_SPIXR_ExMemDisable
void MXC_SPIXR_ExMemDisable(void)
Disable the SPI RAM XIP Data module.
MXC_SPIXR_ExMemGetWriteCommand
uint8_t MXC_SPIXR_ExMemGetWriteCommand(void)
Get the write command used for external memory mode.
MXC_SPIXR_SendCommand
void MXC_SPIXR_SendCommand(uint8_t *cmd, uint32_t length, uint32_t tx_num_char)
Send a SPI formatted instruction to external RAM.
MXC_SPIXR_Init
int MXC_SPIXR_Init(mxc_spixr_cfg_t *cfg)
Initialize the SPI RAM XIP Data module.
MXC_SPIXR_Enable
void MXC_SPIXR_Enable(void)
Enable the SPIXR peripheral.
MXC_SPIXR_GetWakeUpFlags
int MXC_SPIXR_GetWakeUpFlags(void)
Get the active wake up flags.
MXC_SPIXR_DmaTXFIFODisable
void MXC_SPIXR_DmaTXFIFODisable(void)
Disable the TXFIFO DMA.
mxc_spixr_cfg_t::numbits
uint32_t numbits
Number of Bits per character. In slave mode 9-bit character length is not supported.
Definition: spixr.h:90
MXC_SPIXR_TXFIFODisable
void MXC_SPIXR_TXFIFODisable(void)
Disable the TXFIFO.
MXC_SPIXR_ReadRXFIFO
int MXC_SPIXR_ReadRXFIFO(uint8_t *buf, int len)
Unloads bytes from the FIFO.
MXC_SPIXR_SetWidth
int MXC_SPIXR_SetWidth(mxc_spixr_width_t width)
Set the SPI Width used.
MXC_SPIXR_GetSSCtrl
int MXC_SPIXR_GetSSCtrl(void)
Get the setting that controls deassertion of the SS line.
mxc_spixr_cfg_t::baud_freq
uint32_t baud_freq
Desired frequency.
Definition: spixr.h:97
MXC_SPIXR_GetSS
int MXC_SPIXR_GetSS(void)
Returns the SS line selected.
mxc_spixr_mode_t
mxc_spixr_mode_t
SPIXF mode.
Definition: spixr.h:78
MXC_SPIXR_SetSSCtrl
void MXC_SPIXR_SetSSCtrl(int stayActive)
Control the deassertion of the SS line.
MXC_SPIXR_EnableInt
void MXC_SPIXR_EnableInt(int flags)
Enable SPIXR interrupts.
MXC_SPIXR_DmaRXFIFODisable
void MXC_SPIXR_DmaRXFIFODisable(void)
Disable the RXFIFO DMA.
mxc_spixr_cfg_t
Configuration parameters of SPIXR.
Definition: spixr.h:88
MXC_SPIXR_GetFrequency
int MXC_SPIXR_GetFrequency(void)
Get the SPI Frequency.
MXC_SPIXR_GetIntFlags
int MXC_SPIXR_GetIntFlags(void)
Get the active interrupt flags.
MXC_SPIXR_DmaRXFIFOIsEnabled
int MXC_SPIXR_DmaRXFIFOIsEnabled(void)
Get if RXFIFO DMA is enabled.
MXC_SPIXR_RXFIFODisable
void MXC_SPIXR_RXFIFODisable(void)
Disable the RXFIFO.
MXC_SPIXR_SetSSPolarity
int MXC_SPIXR_SetSSPolarity(int activeLow)
Set the active state of the SS line.
MXC_SPIXR_DisableWakeUp
void MXC_SPIXR_DisableWakeUp(int flags)
Enable Wake up for SPIXR.
MXC_SPIXR_Shutdown
int MXC_SPIXR_Shutdown(void)
Shut Down the SPI RAM XIP Data Module.
MXC_SPIXR_TXFIFOClear
void MXC_SPIXR_TXFIFOClear(void)
Clear TX FIFO.
MXC_SPIXR_ThreeWireModeIsEnabled
int MXC_SPIXR_ThreeWireModeIsEnabled(void)
Get if three wire mode is enabled.