 |
MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
|
44 #include "mxc_device.h"
46 #include "spixfc_regs.h"
47 #include "spixfm_regs.h"
48 #include "spixfc_fifo_regs.h"
65 MXC_SPIXF_SSEL0_HIGH = (0x1 << 0),
66 MXC_SPIXF_SSEL0_LOW = 0,
67 MXC_SPIXF_SSEL1_HIGH = (0x1 << 1),
68 MXC_SPIXF_SSEL1_LOW = 0,
69 MXC_SPIXF_SSEL2_HIGH = (0x1 << 2),
70 MXC_SPIXF_SSEL2_LOW = 0,
71 MXC_SPIXF_SSEL3_HIGH = (0x1 << 3),
72 MXC_SPIXF_SSEL3_LOW = 0
80 MXC_SPIXF_HEADER_DIR_NONE,
81 MXC_SPIXF_HEADER_DIR_TX,
82 MXC_SPIXF_HEADER_DIR_RX,
83 MXC_SPIXF_HEADER_DIR_BOTH,
98 MXC_SPIXF_CMD_EVERY_TRANS,
99 MXC_SPIXF_CMD_FIRST_TRANS,
125 MXC_SPIXF_HEADER_UNITS_BITS,
126 MXC_SPIXF_HEADER_UNITS_BYTES,
127 MXC_SPIXF_HEADER_UNITS_PAGES,
152 MXC_SPIXF_SYS_CLOCKS_0,
153 MXC_SPIXF_SYS_CLOCKS_2,
154 MXC_SPIXF_SYS_CLOCKS_4,
155 MXC_SPIXF_SYS_CLOCKS_8,
172 MXC_SPIXF_SINGLE_SDIO,
uint8_t MXC_SPIXF_GetSampleOutputValue(void)
Get bit bang sample output value.
uint8_t MXC_SPIXF_GetModeClk(void)
Get number of SPI clocks being used for the mode/dummy phase of fetch.
int MXC_SPIXF_DisableInt(uint32_t mask)
Disable Interrupts.
int MXC_SPIXF_Transaction(mxc_spixf_req_t *req)
Read/write MXC_SPIXF data. Will block until transaction is complete.
void MXC_SPIXF_SetSSDriveOutputHigh(void)
Set Slave select in bit bang mode to a 1.
mxc_spixf_page_size_t MXC_SPIXF_GetPageSize(void)
Get the current page size for a transaction.
@ MXC_SPIXF_SYS_CLOCKS_3
3 system clocks
Definition: spixf.h:163
int MXC_SPIXF_Clocks(uint32_t len, uint8_t deass)
Send Clock cycles on SCK without reading or writing.
int MXC_SPIXF_SetModeClk(uint8_t mdclk)
Set number of SPI clocks needed during the mode/dummy phase of fetch.
uint8_t MXC_SPIXF_BBDataOutputIsEnabled(void)
Get if bit bang output mode is enabled or disabled for all bits.
#define MXC_S_SPIXFM_IO_CTRL_PU_PD_CTRL_TRI_STATE
Definition: spixfm_regs.h:282
mxc_spixf_mode_t
SPIXF mode.
Definition: spixf.h:106
uint8_t MXC_SPIXF_GetIoctrlSSDrive(void)
Get IOCTRL SS Drive.
int MXC_SPIXF_ClearFlags(uint32_t flags)
Clear Flags that have been set.
int MXC_SPIXF_EnableInt(uint32_t mask)
Enable Interrupts.
void MXC_SPIXF_SetIoctrlSSDriveLow()
Set IOCTRL SS Drive to Low.
int MXC_SPIXF_BitBangModeEnable(void)
Enable bit bang mode.
int MXC_SPIXF_SCKFeebackDisable(void)
Disable SCK Feedback.
uint32_t MXC_SPIXF_GetSPIFrequency(void)
Get the current SPI Frequency.
int MXC_SPIXF_SetSCKSampleDelay(uint8_t delay)
Set SPI clock periods to delay before sampling SDIO input. This value must be less than or equal to H...
uint8_t wait_tx
Wait for the TX FIFO to be empty before returning.
Definition: spixf.h:210
int MXC_SPIXF_IsEnabled(void)
Is SPIXF Enabled or Disabled.
uint8_t MXC_SPIXF_GetBBDataOutputValue(void)
Get Output data value.
@ MXC_SPIXF_SYS_CLOCKS_5
5 system clocks
Definition: spixf.h:164
MXC_SPIXF configuration type.
Definition: spixf.h:142
uint8_t deass
De-assert slave select at the end of the transaction.
Definition: spixf.h:209
int MXC_SPIXF_RXFIFOIsEnabled(void)
Is RX FIFO (results fifo) enabled or disabled.
int MXC_SPIXF_TXFIFODisable(void)
TX FIFO (Transaction FIFO) disable.
int MXC_SPIXF_BitBangModeIsEnabled(void)
Is Bit bang mode enabled or disabled.
#define MXC_S_SPIXFM_IO_CTRL_PU_PD_CTRL_PULL_UP
Definition: spixfm_regs.h:284
void MXC_SPIXF_Shutdown(void)
Shutdown MXC_SPIXF module.
int MXC_SPIXF_Set3ByteAddr(void)
Set address mode to be 3 byte address.
void MXC_SPIXF_SetPuPdCtrl(mxc_spixf_pup_t pupd)
Set pull up pull down.
@ MXC_SPIXF_WIDTH_2
2 Data Lines (x2).
Definition: spixf.h:135
mxc_spixf_ssiact_t
Slave select Inactive timing.
Definition: spixf.h:161
int MXC_SPIXF_RXFIFODisable(void)
RX FIFO (results fifo) disable.
unsigned len
Number of bytes to send.
Definition: spixf.h:214
uint8_t * rx_data
RX buffer.
Definition: spixf.h:212
int MXC_SPIXF_SCKFeebackIsEnabled(void)
Get if SCK Feedback is enabled or disabled.
int MXC_SPIXF_SetDataWidth(mxc_spixf_spiwidth_t width)
Set Number of data I/O used to send data.
void MXC_SPIXF_SetPageSize(mxc_spixf_page_size_t size)
Set Page Size for transactions.
int MXC_SPIXF_SetSSInactiveTime(mxc_spixf_ssiact_t ssiact)
Set slave select inactive timing to delay from de-assertion of slave select to re-assertion of slave ...
int MXC_SPIXF_GetFlags(void)
Get Flags of Interrupts of Flags that have been set.
uint8_t MXC_SPIXF_GetIoctrlSCLKDrive(void)
Get IOCTRL SCLK Drive.
mxc_spixf_sspol_t ssel_pol
Mask of active levels for slave select signals, use mxc_spixf_ssel_t.
Definition: spixf.h:144
int MXC_SPIXF_SimpleRXDisable(void)
Set to Receive only in simple mode.
unsigned int MXC_SPIXF_GetBytesPerAddr(void)
Get number of bytes in address.
int MXC_SPIXF_BitBangModeDisable(void)
Disable bit bang mode.
int MXC_SPIXF_SetSCKNonInverted(void)
Set SCK to be non-inverted.
void MXC_SPIXF_SetIoctrlSDIODriveHigh()
Set IOCTRL SDIO Drive to High.
int MXC_SPIXF_SetSSActiveTime(mxc_spixf_ssact_t ssact)
Set the slave select active timing. This will control the delay from assertion of slave select to sta...
void MXC_SPIXF_SetIoctrlSCLKDriveHigh()
Set IOCTRL SCLK Drive to High.
uint8_t MXC_SPIXF_GetIoctrlSDIODrive(void)
Get IOCTRL SDIO Drive.
uint8_t MXC_SPIXF_GetBBDataInputValue(void)
Get Input data value.
void MXC_SPIXF_SetSCKDriveLow(void)
Drive SCK Low.
int MXC_SPIXF_SetCmdValue(uint8_t cmdval)
Set command value for spi transaction.
mxc_spixf_hdr_units_t
Header units.
Definition: spixf.h:124
uint32_t hz
SPI Frequency in Hz.
Definition: spixf.h:145
MXC_SPIXF Transaction request.
Definition: spixf.h:208
void(* spixr_complete_cb_t)(mxc_spixf_req_t *, int)
Callback for asynchronous request.
Definition: spixf.h:206
int MXC_SPIXF_SampleOutputDisable(uint8_t mask)
Disable bit bang sample output mode on spefic bits.
int MXC_SPIXF_SetCmdWidth(mxc_spixf_spiwidth_t width)
Set Number of data I/O used to send commands.
void MXC_SPIXF_SetSCKDriveHigh(void)
Drive SCK High.
int MXC_SPIXF_SetSPIFrequency(unsigned int hz)
Set SPI Frequency.
unsigned int MXC_SPIXF_GetBusIdle(void)
Get Bus Idle time.
int MXC_SPIXF_SCKFeedbackEnable(void)
Enable SCK Feedback.
mxc_spixf_ssact_t
Slave select active timing.
Definition: spixf.h:151
#define MXC_S_SPIXFM_IO_CTRL_PU_PD_CTRL_PULL_DOWN
Definition: spixfm_regs.h:286
mxc_spixf_width_t
Number of data lines to use.
Definition: spixf.h:133
int MXC_SPIXF_SimpleRXIsEnabled(void)
Get Receive only mode setting.
void MXC_SPIXF_SetIoctrlSDIODriveLow()
Set IOCTRL SDIO Drive to Low.
const uint8_t * tx_data
TX buffer.
Definition: spixf.h:211
int MXC_SPIXF_RXFIFOEnable(void)
RX FIFO (results fifo) enable.
int MXC_SPIXF_TXFIFOEnable(void)
TX FIFO (Transaction FIFO) enable.
void MXC_SPIXF_SetIoctrlSSDriveHigh()
Set IOCTRL SS Drive to High.
int MXC_SPIXF_SetBusIdle(unsigned int busidle)
Set bus idle to a time where ss will be deactivated if timer runs out.
int MXC_SPIXF_SetSCKInverted(void)
Set SCK to be inverted.
mxc_spixf_pup_t
IO pullup/pulldown Control.
Definition: spixf.h:181
void MXC_SPIXF_IOCtrl(mxc_spixf_ds_t sclk_ds, mxc_spixf_ds_t ss_ds, mxc_spixf_ds_t sdio_ds, mxc_spixf_pup_t pupdctrl)
Setup Drive Strength on the I/O pins.
uint16_t MXC_SPIXF_GetModeData(void)
Get the data that is supposed to send with the dummy clocks.
int MXC_SPIXF_Disable(void)
Disables SPIXF but doesnt change any configurations.
int MXC_SPIXF_SetSSPolActiveHigh(void)
Set the slave select polarity to high or low.
mxc_spixf_hdr_direction_t
Header direction.
Definition: spixf.h:79
@ MXC_SPIXF_WIDTH_1
1 Data Line.
Definition: spixf.h:134
mxc_spixf_width_t width
Number of data lines to use
Definition: spixf.h:213
int MXC_SPIXF_SimpleModeIsEnabled(void)
Get if Simple mode is enabled or disabled.
int MXC_SPIXF_Enable(void)
Enables SPIXF but doesnt change any configurations.
@ MXC_SPIXF_SYS_CLOCKS_1
1 system clocks
Definition: spixf.h:162
mxc_spixf_mode_t MXC_SPIXF_GetMode(void)
Get which mode that spixf is currently set for.
mxc_spixf_cmd_t MXC_SPIXF_GetCmdMode(void)
Get Command mode.
@ MXC_SPIXF_WIDTH_4
4 Data Lines (x4).
Definition: spixf.h:136
uint8_t MXC_SPIXF_GetSCKDrive(void)
Get if SCK is high or low.
mxc_spixf_mode_t mode
MXC_SPIXF mode to use, 0-3.
Definition: spixf.h:143
mxc_spixf_spiwidth_t
Data Width, # of data I/O used to rcv data.
Definition: spixf.h:171
mxc_spixf_page_size_t
Select page size.
Definition: spixf.h:114
int MXC_SPIXF_SetAddrWidth(mxc_spixf_spiwidth_t width)
Set Number of data I/O used to send address.
int MXC_SPIXF_AbortAsync(mxc_spixf_req_t *req)
Abort asynchronous request.
uint8_t MXC_SPIXF_GetPuPdCtrl(void)
Get what setting the pull up pull down is set to.
int MXC_SPIXF_TransactionAsync(mxc_spixf_req_t *req)
Asynchronously read/write MXC_SPIXF data.
int MXC_SPIXF_GetSCKInverted(void)
Get weather SCK is inverted or non-inverted.
uint8_t MXC_SPIXF_GetSSDriveOutput(void)
Get current slave select output.
int MXC_SPIXF_SimpleRXEnabled(void)
Set to Receive only in simple mode.
unsigned read_num
Number of bytes read.
Definition: spixf.h:215
int MXC_SPIXF_SetSSPolActiveLow(void)
Set the slave select polarity to high or low.
uint8_t MXC_SPIXF_GetSCKSampleDelay(void)
Get the Number of clocks being delayed before sampling SDIO.
mxc_spixf_spiwidth_t MXC_SPIXF_GetCmdWidth(void)
Get number of data I/O expected to be used for commands.
uint8_t MXC_SPIXF_SampleOutputIsEnabled(void)
Get if sample output bit bang is enabled or disabled.
void MXC_SPIXF_Handler(void)
MXC_SPIXF interrupt handler.
@ MXC_SPIXF_SYS_CLOCKS_9
9 system clocks
Definition: spixf.h:165
int MXC_SPIXF_BBDataOutputEnable(uint8_t mask)
Enable bits to be in bit bang output mode.
mxc_spixf_spiwidth_t MXC_SPIXF_GetDataWidth(void)
Get number of data I/O expected to be used for data.
int MXC_SPIXF_Init(uint32_t cmdval, uint32_t frequency)
Setup MXC_SPIXF for Execute in Place.
int MXC_SPIXF_SetCmdModeFirstTrans(void)
Set command mode to send a read a command the first transaction.
mxc_spixf_ssel_t
Active levels for slave select lines.
Definition: spixf.h:64
int MXC_SPIXF_Set4ByteAddr(void)
Set address mode to be 4 byte address.
int MXC_SPIXF_BBDataOutputDisable(uint8_t mask)
Disable bits to not be in bit bang output mode.
int MXC_SPIXF_SampleOutputEnable(uint8_t mask)
Enable bit bang sample output mode on spefic bits.
int MXC_SPIXF_SimpleModeDisable(void)
Disable Simple Mode.
int MXC_SPIXF_TXFIFOIsEnabled(void)
Is TX FIFO (Transaction FIFO) Enabled or Disabled.
spixr_complete_cb_t callback
callback function
Definition: spixf.h:217
int MXC_SPIXF_SetModeData(uint16_t data)
Set the data to send with the dummy clocks.
mxc_spixf_sspol_t
SPIXF Pin mode.
Definition: spixf.h:89
mxc_spixf_ssiact_t MXC_SPIXF_GetSSInactiveTime(void)
Get slave select inactive timing to delay from de-assertion of slave select to re-assertion of slave ...
mxc_spixf_spiwidth_t MXC_SPIXF_GetAddrWidth(void)
Get number of data I/O expected to be used for address.
int MXC_SPIXF_ReadyForSleep(void)
Attempt to prepare the MXC_SPIXF for sleep.
mxc_spixf_cmd_t
SPIXF set command.
Definition: spixf.h:97
void MXC_SPIXF_SetIoctrlSCLKDriveLow()
Set IOCTRL SCLK Drive to Low.
int MXC_SPIXF_SimpleModeEnable(void)
Enable Simple Mode.
unsigned write_num
Number of bytes written.
Definition: spixf.h:216
mxc_spixf_ds_t
SPIXF drive strentgh.
Definition: spixf.h:191
mxc_spixf_ssact_t MXC_SPIXF_GetSSActiveTime(void)
Get the slave select active timing setting.
int MXC_SPIXF_SetCmdModeEveryTrans(void)
Set command mode to send read a command every time a spi transaction is initiated.
void MXC_SPIXF_SetSSDriveOutputLow(void)
Set Slave select in bit bang mode to a 0.
int MXC_SPIXF_GetSSPolarity(void)
Get the current slave select polarity.
int MXC_SPIXF_SetMode(mxc_spixf_mode_t mode)
Sets the SPI Mode.