The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_RO359B/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/drivers/fsl_dspi.h@143:86740a56073b
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 143:86740a56073b 3 * Copyright 2016-2017 NXP
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 143:86740a56073b 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 143:86740a56073b 13 * other materials provided with the distribution.
AnnaBridge 143:86740a56073b 14 *
AnnaBridge 143:86740a56073b 15 * o Neither the name of the copyright holder nor the names of its
AnnaBridge 143:86740a56073b 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 143:86740a56073b 17 * software without specific prior written permission.
AnnaBridge 143:86740a56073b 18 *
AnnaBridge 143:86740a56073b 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 29 */
AnnaBridge 143:86740a56073b 30 #ifndef _FSL_DSPI_H_
AnnaBridge 143:86740a56073b 31 #define _FSL_DSPI_H_
AnnaBridge 143:86740a56073b 32
AnnaBridge 143:86740a56073b 33 #include "fsl_common.h"
AnnaBridge 143:86740a56073b 34
AnnaBridge 143:86740a56073b 35 /*!
AnnaBridge 143:86740a56073b 36 * @addtogroup dspi_driver
AnnaBridge 143:86740a56073b 37 * @{
AnnaBridge 143:86740a56073b 38 */
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40
AnnaBridge 143:86740a56073b 41 /**********************************************************************************************************************
AnnaBridge 143:86740a56073b 42 * Definitions
AnnaBridge 143:86740a56073b 43 *********************************************************************************************************************/
AnnaBridge 143:86740a56073b 44
AnnaBridge 143:86740a56073b 45 /*! @name Driver version */
AnnaBridge 143:86740a56073b 46 /*@{*/
AnnaBridge 143:86740a56073b 47 /*! @brief DSPI driver version 2.1.4. */
AnnaBridge 143:86740a56073b 48 #define FSL_DSPI_DRIVER_VERSION (MAKE_VERSION(2, 1, 4))
AnnaBridge 143:86740a56073b 49 /*@}*/
AnnaBridge 143:86740a56073b 50
AnnaBridge 143:86740a56073b 51 #ifndef DSPI_DUMMY_DATA
AnnaBridge 143:86740a56073b 52 /*! @brief DSPI dummy data if there is no Tx data.*/
AnnaBridge 143:86740a56073b 53 #define DSPI_DUMMY_DATA (0x00U) /*!< Dummy data used for Tx if there is no txData. */
AnnaBridge 143:86740a56073b 54 #endif
AnnaBridge 143:86740a56073b 55
AnnaBridge 143:86740a56073b 56 /*! @brief Status for the DSPI driver.*/
AnnaBridge 143:86740a56073b 57 enum _dspi_status
AnnaBridge 143:86740a56073b 58 {
AnnaBridge 143:86740a56073b 59 kStatus_DSPI_Busy = MAKE_STATUS(kStatusGroup_DSPI, 0), /*!< DSPI transfer is busy.*/
AnnaBridge 143:86740a56073b 60 kStatus_DSPI_Error = MAKE_STATUS(kStatusGroup_DSPI, 1), /*!< DSPI driver error. */
AnnaBridge 143:86740a56073b 61 kStatus_DSPI_Idle = MAKE_STATUS(kStatusGroup_DSPI, 2), /*!< DSPI is idle.*/
AnnaBridge 143:86740a56073b 62 kStatus_DSPI_OutOfRange = MAKE_STATUS(kStatusGroup_DSPI, 3) /*!< DSPI transfer out of range. */
AnnaBridge 143:86740a56073b 63 };
AnnaBridge 143:86740a56073b 64
AnnaBridge 143:86740a56073b 65 /*! @brief DSPI status flags in SPIx_SR register.*/
AnnaBridge 143:86740a56073b 66 enum _dspi_flags
AnnaBridge 143:86740a56073b 67 {
AnnaBridge 143:86740a56073b 68 kDSPI_TxCompleteFlag = SPI_SR_TCF_MASK, /*!< Transfer Complete Flag. */
AnnaBridge 143:86740a56073b 69 kDSPI_EndOfQueueFlag = SPI_SR_EOQF_MASK, /*!< End of Queue Flag.*/
AnnaBridge 143:86740a56073b 70 kDSPI_TxFifoUnderflowFlag = SPI_SR_TFUF_MASK, /*!< Transmit FIFO Underflow Flag.*/
AnnaBridge 143:86740a56073b 71 kDSPI_TxFifoFillRequestFlag = SPI_SR_TFFF_MASK, /*!< Transmit FIFO Fill Flag.*/
AnnaBridge 143:86740a56073b 72 kDSPI_RxFifoOverflowFlag = SPI_SR_RFOF_MASK, /*!< Receive FIFO Overflow Flag.*/
AnnaBridge 143:86740a56073b 73 kDSPI_RxFifoDrainRequestFlag = SPI_SR_RFDF_MASK, /*!< Receive FIFO Drain Flag.*/
AnnaBridge 143:86740a56073b 74 kDSPI_TxAndRxStatusFlag = SPI_SR_TXRXS_MASK, /*!< The module is in Stopped/Running state.*/
AnnaBridge 143:86740a56073b 75 kDSPI_AllStatusFlag = SPI_SR_TCF_MASK | SPI_SR_EOQF_MASK | SPI_SR_TFUF_MASK | SPI_SR_TFFF_MASK | SPI_SR_RFOF_MASK |
AnnaBridge 143:86740a56073b 76 SPI_SR_RFDF_MASK | SPI_SR_TXRXS_MASK /*!< All statuses above.*/
AnnaBridge 143:86740a56073b 77 };
AnnaBridge 143:86740a56073b 78
AnnaBridge 143:86740a56073b 79 /*! @brief DSPI interrupt source.*/
AnnaBridge 143:86740a56073b 80 enum _dspi_interrupt_enable
AnnaBridge 143:86740a56073b 81 {
AnnaBridge 143:86740a56073b 82 kDSPI_TxCompleteInterruptEnable = SPI_RSER_TCF_RE_MASK, /*!< TCF interrupt enable.*/
AnnaBridge 143:86740a56073b 83 kDSPI_EndOfQueueInterruptEnable = SPI_RSER_EOQF_RE_MASK, /*!< EOQF interrupt enable.*/
AnnaBridge 143:86740a56073b 84 kDSPI_TxFifoUnderflowInterruptEnable = SPI_RSER_TFUF_RE_MASK, /*!< TFUF interrupt enable.*/
AnnaBridge 143:86740a56073b 85 kDSPI_TxFifoFillRequestInterruptEnable = SPI_RSER_TFFF_RE_MASK, /*!< TFFF interrupt enable, DMA disable.*/
AnnaBridge 143:86740a56073b 86 kDSPI_RxFifoOverflowInterruptEnable = SPI_RSER_RFOF_RE_MASK, /*!< RFOF interrupt enable.*/
AnnaBridge 143:86740a56073b 87 kDSPI_RxFifoDrainRequestInterruptEnable = SPI_RSER_RFDF_RE_MASK, /*!< RFDF interrupt enable, DMA disable.*/
AnnaBridge 143:86740a56073b 88 kDSPI_AllInterruptEnable = SPI_RSER_TCF_RE_MASK | SPI_RSER_EOQF_RE_MASK | SPI_RSER_TFUF_RE_MASK |
AnnaBridge 143:86740a56073b 89 SPI_RSER_TFFF_RE_MASK | SPI_RSER_RFOF_RE_MASK | SPI_RSER_RFDF_RE_MASK
AnnaBridge 143:86740a56073b 90 /*!< All above interrupts enable.*/
AnnaBridge 143:86740a56073b 91 };
AnnaBridge 143:86740a56073b 92
AnnaBridge 143:86740a56073b 93 /*! @brief DSPI DMA source.*/
AnnaBridge 143:86740a56073b 94 enum _dspi_dma_enable
AnnaBridge 143:86740a56073b 95 {
AnnaBridge 143:86740a56073b 96 kDSPI_TxDmaEnable = (SPI_RSER_TFFF_RE_MASK | SPI_RSER_TFFF_DIRS_MASK), /*!< TFFF flag generates DMA requests.
AnnaBridge 143:86740a56073b 97 No Tx interrupt request. */
AnnaBridge 143:86740a56073b 98 kDSPI_RxDmaEnable = (SPI_RSER_RFDF_RE_MASK | SPI_RSER_RFDF_DIRS_MASK) /*!< RFDF flag generates DMA requests.
AnnaBridge 143:86740a56073b 99 No Rx interrupt request. */
AnnaBridge 143:86740a56073b 100 };
AnnaBridge 143:86740a56073b 101
AnnaBridge 143:86740a56073b 102 /*! @brief DSPI master or slave mode configuration.*/
AnnaBridge 143:86740a56073b 103 typedef enum _dspi_master_slave_mode
AnnaBridge 143:86740a56073b 104 {
AnnaBridge 143:86740a56073b 105 kDSPI_Master = 1U, /*!< DSPI peripheral operates in master mode.*/
AnnaBridge 143:86740a56073b 106 kDSPI_Slave = 0U /*!< DSPI peripheral operates in slave mode.*/
AnnaBridge 143:86740a56073b 107 } dspi_master_slave_mode_t;
AnnaBridge 143:86740a56073b 108
AnnaBridge 143:86740a56073b 109 /*!
AnnaBridge 143:86740a56073b 110 * @brief DSPI Sample Point: Controls when the DSPI master samples SIN in the Modified Transfer Format. This field is valid
AnnaBridge 143:86740a56073b 111 * only when the CPHA bit in the CTAR register is 0.
AnnaBridge 143:86740a56073b 112 */
AnnaBridge 143:86740a56073b 113 typedef enum _dspi_master_sample_point
AnnaBridge 143:86740a56073b 114 {
AnnaBridge 143:86740a56073b 115 kDSPI_SckToSin0Clock = 0U, /*!< 0 system clocks between SCK edge and SIN sample.*/
AnnaBridge 143:86740a56073b 116 kDSPI_SckToSin1Clock = 1U, /*!< 1 system clock between SCK edge and SIN sample.*/
AnnaBridge 143:86740a56073b 117 kDSPI_SckToSin2Clock = 2U /*!< 2 system clocks between SCK edge and SIN sample.*/
AnnaBridge 143:86740a56073b 118 } dspi_master_sample_point_t;
AnnaBridge 143:86740a56073b 119
AnnaBridge 143:86740a56073b 120 /*! @brief DSPI Peripheral Chip Select (Pcs) configuration (which Pcs to configure).*/
AnnaBridge 143:86740a56073b 121 typedef enum _dspi_which_pcs_config
AnnaBridge 143:86740a56073b 122 {
AnnaBridge 143:86740a56073b 123 kDSPI_Pcs0 = 1U << 0, /*!< Pcs[0] */
AnnaBridge 143:86740a56073b 124 kDSPI_Pcs1 = 1U << 1, /*!< Pcs[1] */
AnnaBridge 143:86740a56073b 125 kDSPI_Pcs2 = 1U << 2, /*!< Pcs[2] */
AnnaBridge 143:86740a56073b 126 kDSPI_Pcs3 = 1U << 3, /*!< Pcs[3] */
AnnaBridge 143:86740a56073b 127 kDSPI_Pcs4 = 1U << 4, /*!< Pcs[4] */
AnnaBridge 143:86740a56073b 128 kDSPI_Pcs5 = 1U << 5 /*!< Pcs[5] */
AnnaBridge 143:86740a56073b 129 } dspi_which_pcs_t;
AnnaBridge 143:86740a56073b 130
AnnaBridge 143:86740a56073b 131 /*! @brief DSPI Peripheral Chip Select (Pcs) Polarity configuration.*/
AnnaBridge 143:86740a56073b 132 typedef enum _dspi_pcs_polarity_config
AnnaBridge 143:86740a56073b 133 {
AnnaBridge 143:86740a56073b 134 kDSPI_PcsActiveHigh = 0U, /*!< Pcs Active High (idles low). */
AnnaBridge 143:86740a56073b 135 kDSPI_PcsActiveLow = 1U /*!< Pcs Active Low (idles high). */
AnnaBridge 143:86740a56073b 136 } dspi_pcs_polarity_config_t;
AnnaBridge 143:86740a56073b 137
AnnaBridge 143:86740a56073b 138 /*! @brief DSPI Peripheral Chip Select (Pcs) Polarity.*/
AnnaBridge 143:86740a56073b 139 enum _dspi_pcs_polarity
AnnaBridge 143:86740a56073b 140 {
AnnaBridge 143:86740a56073b 141 kDSPI_Pcs0ActiveLow = 1U << 0, /*!< Pcs0 Active Low (idles high). */
AnnaBridge 143:86740a56073b 142 kDSPI_Pcs1ActiveLow = 1U << 1, /*!< Pcs1 Active Low (idles high). */
AnnaBridge 143:86740a56073b 143 kDSPI_Pcs2ActiveLow = 1U << 2, /*!< Pcs2 Active Low (idles high). */
AnnaBridge 143:86740a56073b 144 kDSPI_Pcs3ActiveLow = 1U << 3, /*!< Pcs3 Active Low (idles high). */
AnnaBridge 143:86740a56073b 145 kDSPI_Pcs4ActiveLow = 1U << 4, /*!< Pcs4 Active Low (idles high). */
AnnaBridge 143:86740a56073b 146 kDSPI_Pcs5ActiveLow = 1U << 5, /*!< Pcs5 Active Low (idles high). */
AnnaBridge 143:86740a56073b 147 kDSPI_PcsAllActiveLow = 0xFFU /*!< Pcs0 to Pcs5 Active Low (idles high). */
AnnaBridge 143:86740a56073b 148 };
AnnaBridge 143:86740a56073b 149
AnnaBridge 143:86740a56073b 150 /*! @brief DSPI clock polarity configuration for a given CTAR.*/
AnnaBridge 143:86740a56073b 151 typedef enum _dspi_clock_polarity
AnnaBridge 143:86740a56073b 152 {
AnnaBridge 143:86740a56073b 153 kDSPI_ClockPolarityActiveHigh = 0U, /*!< CPOL=0. Active-high DSPI clock (idles low).*/
AnnaBridge 143:86740a56073b 154 kDSPI_ClockPolarityActiveLow = 1U /*!< CPOL=1. Active-low DSPI clock (idles high).*/
AnnaBridge 143:86740a56073b 155 } dspi_clock_polarity_t;
AnnaBridge 143:86740a56073b 156
AnnaBridge 143:86740a56073b 157 /*! @brief DSPI clock phase configuration for a given CTAR.*/
AnnaBridge 143:86740a56073b 158 typedef enum _dspi_clock_phase
AnnaBridge 143:86740a56073b 159 {
AnnaBridge 143:86740a56073b 160 kDSPI_ClockPhaseFirstEdge = 0U, /*!< CPHA=0. Data is captured on the leading edge of the SCK and changed on the
AnnaBridge 143:86740a56073b 161 following edge.*/
AnnaBridge 143:86740a56073b 162 kDSPI_ClockPhaseSecondEdge = 1U /*!< CPHA=1. Data is changed on the leading edge of the SCK and captured on the
AnnaBridge 143:86740a56073b 163 following edge.*/
AnnaBridge 143:86740a56073b 164 } dspi_clock_phase_t;
AnnaBridge 143:86740a56073b 165
AnnaBridge 143:86740a56073b 166 /*! @brief DSPI data shifter direction options for a given CTAR.*/
AnnaBridge 143:86740a56073b 167 typedef enum _dspi_shift_direction
AnnaBridge 143:86740a56073b 168 {
AnnaBridge 143:86740a56073b 169 kDSPI_MsbFirst = 0U, /*!< Data transfers start with most significant bit.*/
AnnaBridge 143:86740a56073b 170 kDSPI_LsbFirst = 1U /*!< Data transfers start with least significant bit.
AnnaBridge 143:86740a56073b 171 Shifting out of LSB is not supported for slave */
AnnaBridge 143:86740a56073b 172 } dspi_shift_direction_t;
AnnaBridge 143:86740a56073b 173
AnnaBridge 143:86740a56073b 174 /*! @brief DSPI delay type selection.*/
AnnaBridge 143:86740a56073b 175 typedef enum _dspi_delay_type
AnnaBridge 143:86740a56073b 176 {
AnnaBridge 143:86740a56073b 177 kDSPI_PcsToSck = 1U, /*!< Pcs-to-SCK delay. */
AnnaBridge 143:86740a56073b 178 kDSPI_LastSckToPcs, /*!< The last SCK edge to Pcs delay. */
AnnaBridge 143:86740a56073b 179 kDSPI_BetweenTransfer /*!< Delay between transfers. */
AnnaBridge 143:86740a56073b 180 } dspi_delay_type_t;
AnnaBridge 143:86740a56073b 181
AnnaBridge 143:86740a56073b 182 /*! @brief DSPI Clock and Transfer Attributes Register (CTAR) selection.*/
AnnaBridge 143:86740a56073b 183 typedef enum _dspi_ctar_selection
AnnaBridge 143:86740a56073b 184 {
AnnaBridge 143:86740a56073b 185 kDSPI_Ctar0 = 0U, /*!< CTAR0 selection option for master or slave mode; note that CTAR0 and CTAR0_SLAVE are the
AnnaBridge 143:86740a56073b 186 same register address. */
AnnaBridge 143:86740a56073b 187 kDSPI_Ctar1 = 1U, /*!< CTAR1 selection option for master mode only. */
AnnaBridge 143:86740a56073b 188 kDSPI_Ctar2 = 2U, /*!< CTAR2 selection option for master mode only; note that some devices do not support CTAR2. */
AnnaBridge 143:86740a56073b 189 kDSPI_Ctar3 = 3U, /*!< CTAR3 selection option for master mode only; note that some devices do not support CTAR3. */
AnnaBridge 143:86740a56073b 190 kDSPI_Ctar4 = 4U, /*!< CTAR4 selection option for master mode only; note that some devices do not support CTAR4. */
AnnaBridge 143:86740a56073b 191 kDSPI_Ctar5 = 5U, /*!< CTAR5 selection option for master mode only; note that some devices do not support CTAR5. */
AnnaBridge 143:86740a56073b 192 kDSPI_Ctar6 = 6U, /*!< CTAR6 selection option for master mode only; note that some devices do not support CTAR6. */
AnnaBridge 143:86740a56073b 193 kDSPI_Ctar7 = 7U /*!< CTAR7 selection option for master mode only; note that some devices do not support CTAR7. */
AnnaBridge 143:86740a56073b 194 } dspi_ctar_selection_t;
AnnaBridge 143:86740a56073b 195
AnnaBridge 143:86740a56073b 196 #define DSPI_MASTER_CTAR_SHIFT (0U) /*!< DSPI master CTAR shift macro; used internally. */
AnnaBridge 143:86740a56073b 197 #define DSPI_MASTER_CTAR_MASK (0x0FU) /*!< DSPI master CTAR mask macro; used internally. */
AnnaBridge 143:86740a56073b 198 #define DSPI_MASTER_PCS_SHIFT (4U) /*!< DSPI master PCS shift macro; used internally. */
AnnaBridge 143:86740a56073b 199 #define DSPI_MASTER_PCS_MASK (0xF0U) /*!< DSPI master PCS mask macro; used internally. */
AnnaBridge 143:86740a56073b 200 /*! @brief Use this enumeration for the DSPI master transfer configFlags. */
AnnaBridge 143:86740a56073b 201 enum _dspi_transfer_config_flag_for_master
AnnaBridge 143:86740a56073b 202 {
AnnaBridge 143:86740a56073b 203 kDSPI_MasterCtar0 = 0U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR0 setting. */
AnnaBridge 143:86740a56073b 204 kDSPI_MasterCtar1 = 1U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR1 setting. */
AnnaBridge 143:86740a56073b 205 kDSPI_MasterCtar2 = 2U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR2 setting. */
AnnaBridge 143:86740a56073b 206 kDSPI_MasterCtar3 = 3U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR3 setting. */
AnnaBridge 143:86740a56073b 207 kDSPI_MasterCtar4 = 4U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR4 setting. */
AnnaBridge 143:86740a56073b 208 kDSPI_MasterCtar5 = 5U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR5 setting. */
AnnaBridge 143:86740a56073b 209 kDSPI_MasterCtar6 = 6U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR6 setting. */
AnnaBridge 143:86740a56073b 210 kDSPI_MasterCtar7 = 7U << DSPI_MASTER_CTAR_SHIFT, /*!< DSPI master transfer use CTAR7 setting. */
AnnaBridge 143:86740a56073b 211
AnnaBridge 143:86740a56073b 212 kDSPI_MasterPcs0 = 0U << DSPI_MASTER_PCS_SHIFT, /*!< DSPI master transfer use PCS0 signal. */
AnnaBridge 143:86740a56073b 213 kDSPI_MasterPcs1 = 1U << DSPI_MASTER_PCS_SHIFT, /*!< DSPI master transfer use PCS1 signal. */
AnnaBridge 143:86740a56073b 214 kDSPI_MasterPcs2 = 2U << DSPI_MASTER_PCS_SHIFT, /*!< DSPI master transfer use PCS2 signal.*/
AnnaBridge 143:86740a56073b 215 kDSPI_MasterPcs3 = 3U << DSPI_MASTER_PCS_SHIFT, /*!< DSPI master transfer use PCS3 signal. */
AnnaBridge 143:86740a56073b 216 kDSPI_MasterPcs4 = 4U << DSPI_MASTER_PCS_SHIFT, /*!< DSPI master transfer use PCS4 signal. */
AnnaBridge 143:86740a56073b 217 kDSPI_MasterPcs5 = 5U << DSPI_MASTER_PCS_SHIFT, /*!< DSPI master transfer use PCS5 signal. */
AnnaBridge 143:86740a56073b 218
AnnaBridge 143:86740a56073b 219 kDSPI_MasterPcsContinuous = 1U << 20, /*!< Indicates whether the PCS signal is continuous. */
AnnaBridge 143:86740a56073b 220 kDSPI_MasterActiveAfterTransfer = 1U << 21, /*!< Indicates whether the PCS signal is active after the last frame transfer.*/
AnnaBridge 143:86740a56073b 221 };
AnnaBridge 143:86740a56073b 222
AnnaBridge 143:86740a56073b 223 #define DSPI_SLAVE_CTAR_SHIFT (0U) /*!< DSPI slave CTAR shift macro; used internally. */
AnnaBridge 143:86740a56073b 224 #define DSPI_SLAVE_CTAR_MASK (0x07U) /*!< DSPI slave CTAR mask macro; used internally. */
AnnaBridge 143:86740a56073b 225 /*! @brief Use this enumeration for the DSPI slave transfer configFlags. */
AnnaBridge 143:86740a56073b 226 enum _dspi_transfer_config_flag_for_slave
AnnaBridge 143:86740a56073b 227 {
AnnaBridge 143:86740a56073b 228 kDSPI_SlaveCtar0 = 0U << DSPI_SLAVE_CTAR_SHIFT, /*!< DSPI slave transfer use CTAR0 setting. */
AnnaBridge 143:86740a56073b 229 /*!< DSPI slave can only use PCS0. */
AnnaBridge 143:86740a56073b 230 };
AnnaBridge 143:86740a56073b 231
AnnaBridge 143:86740a56073b 232 /*! @brief DSPI transfer state, which is used for DSPI transactional API state machine. */
AnnaBridge 143:86740a56073b 233 enum _dspi_transfer_state
AnnaBridge 143:86740a56073b 234 {
AnnaBridge 143:86740a56073b 235 kDSPI_Idle = 0x0U, /*!< Nothing in the transmitter/receiver. */
AnnaBridge 143:86740a56073b 236 kDSPI_Busy, /*!< Transfer queue is not finished. */
AnnaBridge 143:86740a56073b 237 kDSPI_Error /*!< Transfer error. */
AnnaBridge 143:86740a56073b 238 };
AnnaBridge 143:86740a56073b 239
AnnaBridge 143:86740a56073b 240 /*! @brief DSPI master command date configuration used for the SPIx_PUSHR.*/
AnnaBridge 143:86740a56073b 241 typedef struct _dspi_command_data_config
AnnaBridge 143:86740a56073b 242 {
AnnaBridge 143:86740a56073b 243 bool isPcsContinuous; /*!< Option to enable the continuous assertion of the chip select between transfers.*/
AnnaBridge 143:86740a56073b 244 dspi_ctar_selection_t whichCtar; /*!< The desired Clock and Transfer Attributes
AnnaBridge 143:86740a56073b 245 Register (CTAR) to use for CTAS.*/
AnnaBridge 143:86740a56073b 246 dspi_which_pcs_t whichPcs; /*!< The desired PCS signal to use for the data transfer.*/
AnnaBridge 143:86740a56073b 247 bool isEndOfQueue; /*!< Signals that the current transfer is the last in the queue.*/
AnnaBridge 143:86740a56073b 248 bool clearTransferCount; /*!< Clears the SPI Transfer Counter (SPI_TCNT) before transmission starts.*/
AnnaBridge 143:86740a56073b 249 } dspi_command_data_config_t;
AnnaBridge 143:86740a56073b 250
AnnaBridge 143:86740a56073b 251 /*! @brief DSPI master ctar configuration structure.*/
AnnaBridge 143:86740a56073b 252 typedef struct _dspi_master_ctar_config
AnnaBridge 143:86740a56073b 253 {
AnnaBridge 143:86740a56073b 254 uint32_t baudRate; /*!< Baud Rate for DSPI. */
AnnaBridge 143:86740a56073b 255 uint32_t bitsPerFrame; /*!< Bits per frame, minimum 4, maximum 16.*/
AnnaBridge 143:86740a56073b 256 dspi_clock_polarity_t cpol; /*!< Clock polarity. */
AnnaBridge 143:86740a56073b 257 dspi_clock_phase_t cpha; /*!< Clock phase. */
AnnaBridge 143:86740a56073b 258 dspi_shift_direction_t direction; /*!< MSB or LSB data shift direction. */
AnnaBridge 143:86740a56073b 259
AnnaBridge 143:86740a56073b 260 uint32_t pcsToSckDelayInNanoSec; /*!< PCS to SCK delay time in nanoseconds; setting to 0 sets the minimum
AnnaBridge 143:86740a56073b 261 delay. It also sets the boundary value if out of range.*/
AnnaBridge 143:86740a56073b 262 uint32_t lastSckToPcsDelayInNanoSec; /*!< The last SCK to PCS delay time in nanoseconds; setting to 0 sets the
AnnaBridge 143:86740a56073b 263 minimum delay. It also sets the boundary value if out of range.*/
AnnaBridge 143:86740a56073b 264
AnnaBridge 143:86740a56073b 265 uint32_t betweenTransferDelayInNanoSec; /*!< After the SCK delay time in nanoseconds; setting to 0 sets the minimum
AnnaBridge 143:86740a56073b 266 delay. It also sets the boundary value if out of range.*/
AnnaBridge 143:86740a56073b 267 } dspi_master_ctar_config_t;
AnnaBridge 143:86740a56073b 268
AnnaBridge 143:86740a56073b 269 /*! @brief DSPI master configuration structure.*/
AnnaBridge 143:86740a56073b 270 typedef struct _dspi_master_config
AnnaBridge 143:86740a56073b 271 {
AnnaBridge 143:86740a56073b 272 dspi_ctar_selection_t whichCtar; /*!< The desired CTAR to use. */
AnnaBridge 143:86740a56073b 273 dspi_master_ctar_config_t ctarConfig; /*!< Set the ctarConfig to the desired CTAR. */
AnnaBridge 143:86740a56073b 274
AnnaBridge 143:86740a56073b 275 dspi_which_pcs_t whichPcs; /*!< The desired Peripheral Chip Select (pcs). */
AnnaBridge 143:86740a56073b 276 dspi_pcs_polarity_config_t pcsActiveHighOrLow; /*!< The desired PCS active high or low. */
AnnaBridge 143:86740a56073b 277
AnnaBridge 143:86740a56073b 278 bool enableContinuousSCK; /*!< CONT_SCKE, continuous SCK enable. Note that the continuous SCK is only
AnnaBridge 143:86740a56073b 279 supported for CPHA = 1.*/
AnnaBridge 143:86740a56073b 280 bool enableRxFifoOverWrite; /*!< ROOE, receive FIFO overflow overwrite enable. If ROOE = 0, the incoming
AnnaBridge 143:86740a56073b 281 data is ignored and the data from the transfer that generated the overflow
AnnaBridge 143:86740a56073b 282 is also ignored. If ROOE = 1, the incoming data is shifted to the
AnnaBridge 143:86740a56073b 283 shift register. */
AnnaBridge 143:86740a56073b 284
AnnaBridge 143:86740a56073b 285 bool enableModifiedTimingFormat; /*!< Enables a modified transfer format to be used if true.*/
AnnaBridge 143:86740a56073b 286 dspi_master_sample_point_t samplePoint; /*!< Controls when the module master samples SIN in the Modified Transfer
AnnaBridge 143:86740a56073b 287 Format. It's valid only when CPHA=0. */
AnnaBridge 143:86740a56073b 288 } dspi_master_config_t;
AnnaBridge 143:86740a56073b 289
AnnaBridge 143:86740a56073b 290 /*! @brief DSPI slave ctar configuration structure.*/
AnnaBridge 143:86740a56073b 291 typedef struct _dspi_slave_ctar_config
AnnaBridge 143:86740a56073b 292 {
AnnaBridge 143:86740a56073b 293 uint32_t bitsPerFrame; /*!< Bits per frame, minimum 4, maximum 16.*/
AnnaBridge 143:86740a56073b 294 dspi_clock_polarity_t cpol; /*!< Clock polarity. */
AnnaBridge 143:86740a56073b 295 dspi_clock_phase_t cpha; /*!< Clock phase. */
AnnaBridge 143:86740a56073b 296 /*!< Slave only supports MSB and does not support LSB.*/
AnnaBridge 143:86740a56073b 297 } dspi_slave_ctar_config_t;
AnnaBridge 143:86740a56073b 298
AnnaBridge 143:86740a56073b 299 /*! @brief DSPI slave configuration structure.*/
AnnaBridge 143:86740a56073b 300 typedef struct _dspi_slave_config
AnnaBridge 143:86740a56073b 301 {
AnnaBridge 143:86740a56073b 302 dspi_ctar_selection_t whichCtar; /*!< The desired CTAR to use. */
AnnaBridge 143:86740a56073b 303 dspi_slave_ctar_config_t ctarConfig; /*!< Set the ctarConfig to the desired CTAR. */
AnnaBridge 143:86740a56073b 304
AnnaBridge 143:86740a56073b 305 bool enableContinuousSCK; /*!< CONT_SCKE, continuous SCK enable. Note that the continuous SCK is only
AnnaBridge 143:86740a56073b 306 supported for CPHA = 1.*/
AnnaBridge 143:86740a56073b 307 bool enableRxFifoOverWrite; /*!< ROOE, receive FIFO overflow overwrite enable. If ROOE = 0, the incoming
AnnaBridge 143:86740a56073b 308 data is ignored and the data from the transfer that generated the overflow
AnnaBridge 143:86740a56073b 309 is also ignored. If ROOE = 1, the incoming data is shifted to the
AnnaBridge 143:86740a56073b 310 shift register. */
AnnaBridge 143:86740a56073b 311 bool enableModifiedTimingFormat; /*!< Enables a modified transfer format to be used if true.*/
AnnaBridge 143:86740a56073b 312 dspi_master_sample_point_t samplePoint; /*!< Controls when the module master samples SIN in the Modified Transfer
AnnaBridge 143:86740a56073b 313 Format. It's valid only when CPHA=0. */
AnnaBridge 143:86740a56073b 314 } dspi_slave_config_t;
AnnaBridge 143:86740a56073b 315
AnnaBridge 143:86740a56073b 316 /*!
AnnaBridge 143:86740a56073b 317 * @brief Forward declaration of the _dspi_master_handle typedefs.
AnnaBridge 143:86740a56073b 318 */
AnnaBridge 143:86740a56073b 319 typedef struct _dspi_master_handle dspi_master_handle_t;
AnnaBridge 143:86740a56073b 320
AnnaBridge 143:86740a56073b 321 /*!
AnnaBridge 143:86740a56073b 322 * @brief Forward declaration of the _dspi_slave_handle typedefs.
AnnaBridge 143:86740a56073b 323 */
AnnaBridge 143:86740a56073b 324 typedef struct _dspi_slave_handle dspi_slave_handle_t;
AnnaBridge 143:86740a56073b 325
AnnaBridge 143:86740a56073b 326 /*!
AnnaBridge 143:86740a56073b 327 * @brief Completion callback function pointer type.
AnnaBridge 143:86740a56073b 328 *
AnnaBridge 143:86740a56073b 329 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 330 * @param handle Pointer to the handle for the DSPI master.
AnnaBridge 143:86740a56073b 331 * @param status Success or error code describing whether the transfer completed.
AnnaBridge 143:86740a56073b 332 * @param userData Arbitrary pointer-dataSized value passed from the application.
AnnaBridge 143:86740a56073b 333 */
AnnaBridge 143:86740a56073b 334 typedef void (*dspi_master_transfer_callback_t)(SPI_Type *base,
AnnaBridge 143:86740a56073b 335 dspi_master_handle_t *handle,
AnnaBridge 143:86740a56073b 336 status_t status,
AnnaBridge 143:86740a56073b 337 void *userData);
AnnaBridge 143:86740a56073b 338 /*!
AnnaBridge 143:86740a56073b 339 * @brief Completion callback function pointer type.
AnnaBridge 143:86740a56073b 340 *
AnnaBridge 143:86740a56073b 341 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 342 * @param handle Pointer to the handle for the DSPI slave.
AnnaBridge 143:86740a56073b 343 * @param status Success or error code describing whether the transfer completed.
AnnaBridge 143:86740a56073b 344 * @param userData Arbitrary pointer-dataSized value passed from the application.
AnnaBridge 143:86740a56073b 345 */
AnnaBridge 143:86740a56073b 346 typedef void (*dspi_slave_transfer_callback_t)(SPI_Type *base,
AnnaBridge 143:86740a56073b 347 dspi_slave_handle_t *handle,
AnnaBridge 143:86740a56073b 348 status_t status,
AnnaBridge 143:86740a56073b 349 void *userData);
AnnaBridge 143:86740a56073b 350
AnnaBridge 143:86740a56073b 351 /*! @brief DSPI master/slave transfer structure.*/
AnnaBridge 143:86740a56073b 352 typedef struct _dspi_transfer
AnnaBridge 143:86740a56073b 353 {
AnnaBridge 143:86740a56073b 354 uint8_t *txData; /*!< Send buffer. */
AnnaBridge 143:86740a56073b 355 uint8_t *rxData; /*!< Receive buffer. */
AnnaBridge 143:86740a56073b 356 volatile size_t dataSize; /*!< Transfer bytes. */
AnnaBridge 143:86740a56073b 357
AnnaBridge 143:86740a56073b 358 uint32_t
AnnaBridge 143:86740a56073b 359 configFlags; /*!< Transfer transfer configuration flags; set from _dspi_transfer_config_flag_for_master if the
AnnaBridge 143:86740a56073b 360 transfer is used for master or _dspi_transfer_config_flag_for_slave enumeration if the transfer
AnnaBridge 143:86740a56073b 361 is used for slave.*/
AnnaBridge 143:86740a56073b 362 } dspi_transfer_t;
AnnaBridge 143:86740a56073b 363
AnnaBridge 143:86740a56073b 364 /*! @brief DSPI master transfer handle structure used for transactional API. */
AnnaBridge 143:86740a56073b 365 struct _dspi_master_handle
AnnaBridge 143:86740a56073b 366 {
AnnaBridge 143:86740a56073b 367 uint32_t bitsPerFrame; /*!< The desired number of bits per frame. */
AnnaBridge 143:86740a56073b 368 volatile uint32_t command; /*!< The desired data command. */
AnnaBridge 143:86740a56073b 369 volatile uint32_t lastCommand; /*!< The desired last data command. */
AnnaBridge 143:86740a56073b 370
AnnaBridge 143:86740a56073b 371 uint8_t fifoSize; /*!< FIFO dataSize. */
AnnaBridge 143:86740a56073b 372
AnnaBridge 143:86740a56073b 373 volatile bool isPcsActiveAfterTransfer; /*!< Indicates whether the PCS signal is active after the last frame transfer.*/
AnnaBridge 143:86740a56073b 374 volatile bool isThereExtraByte; /*!< Indicates whether there are extra bytes.*/
AnnaBridge 143:86740a56073b 375
AnnaBridge 143:86740a56073b 376 uint8_t *volatile txData; /*!< Send buffer. */
AnnaBridge 143:86740a56073b 377 uint8_t *volatile rxData; /*!< Receive buffer. */
AnnaBridge 143:86740a56073b 378 volatile size_t remainingSendByteCount; /*!< A number of bytes remaining to send.*/
AnnaBridge 143:86740a56073b 379 volatile size_t remainingReceiveByteCount; /*!< A number of bytes remaining to receive.*/
AnnaBridge 143:86740a56073b 380 size_t totalByteCount; /*!< A number of transfer bytes*/
AnnaBridge 143:86740a56073b 381
AnnaBridge 143:86740a56073b 382 volatile uint8_t state; /*!< DSPI transfer state, see _dspi_transfer_state.*/
AnnaBridge 143:86740a56073b 383
AnnaBridge 143:86740a56073b 384 dspi_master_transfer_callback_t callback; /*!< Completion callback. */
AnnaBridge 143:86740a56073b 385 void *userData; /*!< Callback user data. */
AnnaBridge 143:86740a56073b 386 };
AnnaBridge 143:86740a56073b 387
AnnaBridge 143:86740a56073b 388 /*! @brief DSPI slave transfer handle structure used for the transactional API. */
AnnaBridge 143:86740a56073b 389 struct _dspi_slave_handle
AnnaBridge 143:86740a56073b 390 {
AnnaBridge 143:86740a56073b 391 uint32_t bitsPerFrame; /*!< The desired number of bits per frame. */
AnnaBridge 143:86740a56073b 392 volatile bool isThereExtraByte; /*!< Indicates whether there are extra bytes.*/
AnnaBridge 143:86740a56073b 393
AnnaBridge 143:86740a56073b 394 uint8_t *volatile txData; /*!< Send buffer. */
AnnaBridge 143:86740a56073b 395 uint8_t *volatile rxData; /*!< Receive buffer. */
AnnaBridge 143:86740a56073b 396 volatile size_t remainingSendByteCount; /*!< A number of bytes remaining to send.*/
AnnaBridge 143:86740a56073b 397 volatile size_t remainingReceiveByteCount; /*!< A number of bytes remaining to receive.*/
AnnaBridge 143:86740a56073b 398 size_t totalByteCount; /*!< A number of transfer bytes*/
AnnaBridge 143:86740a56073b 399
AnnaBridge 143:86740a56073b 400 volatile uint8_t state; /*!< DSPI transfer state.*/
AnnaBridge 143:86740a56073b 401
AnnaBridge 143:86740a56073b 402 volatile uint32_t errorCount; /*!< Error count for slave transfer.*/
AnnaBridge 143:86740a56073b 403
AnnaBridge 143:86740a56073b 404 dspi_slave_transfer_callback_t callback; /*!< Completion callback. */
AnnaBridge 143:86740a56073b 405 void *userData; /*!< Callback user data. */
AnnaBridge 143:86740a56073b 406 };
AnnaBridge 143:86740a56073b 407
AnnaBridge 143:86740a56073b 408 /**********************************************************************************************************************
AnnaBridge 143:86740a56073b 409 * API
AnnaBridge 143:86740a56073b 410 *********************************************************************************************************************/
AnnaBridge 143:86740a56073b 411 #if defined(__cplusplus)
AnnaBridge 143:86740a56073b 412 extern "C" {
AnnaBridge 143:86740a56073b 413 #endif /*_cplusplus*/
AnnaBridge 143:86740a56073b 414
AnnaBridge 143:86740a56073b 415 /*!
AnnaBridge 143:86740a56073b 416 * @name Initialization and deinitialization
AnnaBridge 143:86740a56073b 417 * @{
AnnaBridge 143:86740a56073b 418 */
AnnaBridge 143:86740a56073b 419
AnnaBridge 143:86740a56073b 420 /*!
AnnaBridge 143:86740a56073b 421 * @brief Initializes the DSPI master.
AnnaBridge 143:86740a56073b 422 *
AnnaBridge 143:86740a56073b 423 * This function initializes the DSPI master configuration. This is an example use case.
AnnaBridge 143:86740a56073b 424 * @code
AnnaBridge 143:86740a56073b 425 * dspi_master_config_t masterConfig;
AnnaBridge 143:86740a56073b 426 * masterConfig.whichCtar = kDSPI_Ctar0;
AnnaBridge 143:86740a56073b 427 * masterConfig.ctarConfig.baudRate = 500000000U;
AnnaBridge 143:86740a56073b 428 * masterConfig.ctarConfig.bitsPerFrame = 8;
AnnaBridge 143:86740a56073b 429 * masterConfig.ctarConfig.cpol = kDSPI_ClockPolarityActiveHigh;
AnnaBridge 143:86740a56073b 430 * masterConfig.ctarConfig.cpha = kDSPI_ClockPhaseFirstEdge;
AnnaBridge 143:86740a56073b 431 * masterConfig.ctarConfig.direction = kDSPI_MsbFirst;
AnnaBridge 143:86740a56073b 432 * masterConfig.ctarConfig.pcsToSckDelayInNanoSec = 1000000000U / masterConfig.ctarConfig.baudRate ;
AnnaBridge 143:86740a56073b 433 * masterConfig.ctarConfig.lastSckToPcsDelayInNanoSec = 1000000000U / masterConfig.ctarConfig.baudRate ;
AnnaBridge 143:86740a56073b 434 * masterConfig.ctarConfig.betweenTransferDelayInNanoSec = 1000000000U / masterConfig.ctarConfig.baudRate ;
AnnaBridge 143:86740a56073b 435 * masterConfig.whichPcs = kDSPI_Pcs0;
AnnaBridge 143:86740a56073b 436 * masterConfig.pcsActiveHighOrLow = kDSPI_PcsActiveLow;
AnnaBridge 143:86740a56073b 437 * masterConfig.enableContinuousSCK = false;
AnnaBridge 143:86740a56073b 438 * masterConfig.enableRxFifoOverWrite = false;
AnnaBridge 143:86740a56073b 439 * masterConfig.enableModifiedTimingFormat = false;
AnnaBridge 143:86740a56073b 440 * masterConfig.samplePoint = kDSPI_SckToSin0Clock;
AnnaBridge 143:86740a56073b 441 * DSPI_MasterInit(base, &masterConfig, srcClock_Hz);
AnnaBridge 143:86740a56073b 442 * @endcode
AnnaBridge 143:86740a56073b 443 *
AnnaBridge 143:86740a56073b 444 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 445 * @param masterConfig Pointer to the structure dspi_master_config_t.
AnnaBridge 143:86740a56073b 446 * @param srcClock_Hz Module source input clock in Hertz.
AnnaBridge 143:86740a56073b 447 */
AnnaBridge 143:86740a56073b 448 void DSPI_MasterInit(SPI_Type *base, const dspi_master_config_t *masterConfig, uint32_t srcClock_Hz);
AnnaBridge 143:86740a56073b 449
AnnaBridge 143:86740a56073b 450 /*!
AnnaBridge 143:86740a56073b 451 * @brief Sets the dspi_master_config_t structure to default values.
AnnaBridge 143:86740a56073b 452 *
AnnaBridge 143:86740a56073b 453 * The purpose of this API is to get the configuration structure initialized for the DSPI_MasterInit().
AnnaBridge 143:86740a56073b 454 * Users may use the initialized structure unchanged in the DSPI_MasterInit() or modify the structure
AnnaBridge 143:86740a56073b 455 * before calling the DSPI_MasterInit().
AnnaBridge 143:86740a56073b 456 * Example:
AnnaBridge 143:86740a56073b 457 * @code
AnnaBridge 143:86740a56073b 458 * dspi_master_config_t masterConfig;
AnnaBridge 143:86740a56073b 459 * DSPI_MasterGetDefaultConfig(&masterConfig);
AnnaBridge 143:86740a56073b 460 * @endcode
AnnaBridge 143:86740a56073b 461 * @param masterConfig pointer to dspi_master_config_t structure
AnnaBridge 143:86740a56073b 462 */
AnnaBridge 143:86740a56073b 463 void DSPI_MasterGetDefaultConfig(dspi_master_config_t *masterConfig);
AnnaBridge 143:86740a56073b 464
AnnaBridge 143:86740a56073b 465 /*!
AnnaBridge 143:86740a56073b 466 * @brief DSPI slave configuration.
AnnaBridge 143:86740a56073b 467 *
AnnaBridge 143:86740a56073b 468 * This function initializes the DSPI slave configuration. This is an example use case.
AnnaBridge 143:86740a56073b 469 * @code
AnnaBridge 143:86740a56073b 470 * dspi_slave_config_t slaveConfig;
AnnaBridge 143:86740a56073b 471 * slaveConfig->whichCtar = kDSPI_Ctar0;
AnnaBridge 143:86740a56073b 472 * slaveConfig->ctarConfig.bitsPerFrame = 8;
AnnaBridge 143:86740a56073b 473 * slaveConfig->ctarConfig.cpol = kDSPI_ClockPolarityActiveHigh;
AnnaBridge 143:86740a56073b 474 * slaveConfig->ctarConfig.cpha = kDSPI_ClockPhaseFirstEdge;
AnnaBridge 143:86740a56073b 475 * slaveConfig->enableContinuousSCK = false;
AnnaBridge 143:86740a56073b 476 * slaveConfig->enableRxFifoOverWrite = false;
AnnaBridge 143:86740a56073b 477 * slaveConfig->enableModifiedTimingFormat = false;
AnnaBridge 143:86740a56073b 478 * slaveConfig->samplePoint = kDSPI_SckToSin0Clock;
AnnaBridge 143:86740a56073b 479 * DSPI_SlaveInit(base, &slaveConfig);
AnnaBridge 143:86740a56073b 480 * @endcode
AnnaBridge 143:86740a56073b 481 *
AnnaBridge 143:86740a56073b 482 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 483 * @param slaveConfig Pointer to the structure dspi_master_config_t.
AnnaBridge 143:86740a56073b 484 */
AnnaBridge 143:86740a56073b 485 void DSPI_SlaveInit(SPI_Type *base, const dspi_slave_config_t *slaveConfig);
AnnaBridge 143:86740a56073b 486
AnnaBridge 143:86740a56073b 487 /*!
AnnaBridge 143:86740a56073b 488 * @brief Sets the dspi_slave_config_t structure to a default value.
AnnaBridge 143:86740a56073b 489 *
AnnaBridge 143:86740a56073b 490 * The purpose of this API is to get the configuration structure initialized for the DSPI_SlaveInit().
AnnaBridge 143:86740a56073b 491 * Users may use the initialized structure unchanged in the DSPI_SlaveInit() or modify the structure
AnnaBridge 143:86740a56073b 492 * before calling the DSPI_SlaveInit().
AnnaBridge 143:86740a56073b 493 * This is an example.
AnnaBridge 143:86740a56073b 494 * @code
AnnaBridge 143:86740a56073b 495 * dspi_slave_config_t slaveConfig;
AnnaBridge 143:86740a56073b 496 * DSPI_SlaveGetDefaultConfig(&slaveConfig);
AnnaBridge 143:86740a56073b 497 * @endcode
AnnaBridge 143:86740a56073b 498 * @param slaveConfig Pointer to the dspi_slave_config_t structure.
AnnaBridge 143:86740a56073b 499 */
AnnaBridge 143:86740a56073b 500 void DSPI_SlaveGetDefaultConfig(dspi_slave_config_t *slaveConfig);
AnnaBridge 143:86740a56073b 501
AnnaBridge 143:86740a56073b 502 /*!
AnnaBridge 143:86740a56073b 503 * @brief De-initializes the DSPI peripheral. Call this API to disable the DSPI clock.
AnnaBridge 143:86740a56073b 504 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 505 */
AnnaBridge 143:86740a56073b 506 void DSPI_Deinit(SPI_Type *base);
AnnaBridge 143:86740a56073b 507
AnnaBridge 143:86740a56073b 508 /*!
AnnaBridge 143:86740a56073b 509 * @brief Enables the DSPI peripheral and sets the MCR MDIS to 0.
AnnaBridge 143:86740a56073b 510 *
AnnaBridge 143:86740a56073b 511 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 512 * @param enable Pass true to enable module, false to disable module.
AnnaBridge 143:86740a56073b 513 */
AnnaBridge 143:86740a56073b 514 static inline void DSPI_Enable(SPI_Type *base, bool enable)
AnnaBridge 143:86740a56073b 515 {
AnnaBridge 143:86740a56073b 516 if (enable)
AnnaBridge 143:86740a56073b 517 {
AnnaBridge 143:86740a56073b 518 base->MCR &= ~SPI_MCR_MDIS_MASK;
AnnaBridge 143:86740a56073b 519 }
AnnaBridge 143:86740a56073b 520 else
AnnaBridge 143:86740a56073b 521 {
AnnaBridge 143:86740a56073b 522 base->MCR |= SPI_MCR_MDIS_MASK;
AnnaBridge 143:86740a56073b 523 }
AnnaBridge 143:86740a56073b 524 }
AnnaBridge 143:86740a56073b 525
AnnaBridge 143:86740a56073b 526 /*!
AnnaBridge 143:86740a56073b 527 *@}
AnnaBridge 143:86740a56073b 528 */
AnnaBridge 143:86740a56073b 529
AnnaBridge 143:86740a56073b 530 /*!
AnnaBridge 143:86740a56073b 531 * @name Status
AnnaBridge 143:86740a56073b 532 * @{
AnnaBridge 143:86740a56073b 533 */
AnnaBridge 143:86740a56073b 534
AnnaBridge 143:86740a56073b 535 /*!
AnnaBridge 143:86740a56073b 536 * @brief Gets the DSPI status flag state.
AnnaBridge 143:86740a56073b 537 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 538 * @return DSPI status (in SR register).
AnnaBridge 143:86740a56073b 539 */
AnnaBridge 143:86740a56073b 540 static inline uint32_t DSPI_GetStatusFlags(SPI_Type *base)
AnnaBridge 143:86740a56073b 541 {
AnnaBridge 143:86740a56073b 542 return (base->SR);
AnnaBridge 143:86740a56073b 543 }
AnnaBridge 143:86740a56073b 544
AnnaBridge 143:86740a56073b 545 /*!
AnnaBridge 143:86740a56073b 546 * @brief Clears the DSPI status flag.
AnnaBridge 143:86740a56073b 547 *
AnnaBridge 143:86740a56073b 548 * This function clears the desired status bit by using a write-1-to-clear. The user passes in the base and the
AnnaBridge 143:86740a56073b 549 * desired status bit to clear. The list of status bits is defined in the dspi_status_and_interrupt_request_t. The
AnnaBridge 143:86740a56073b 550 * function uses these bit positions in its algorithm to clear the desired flag state.
AnnaBridge 143:86740a56073b 551 * This is an example.
AnnaBridge 143:86740a56073b 552 * @code
AnnaBridge 143:86740a56073b 553 * DSPI_ClearStatusFlags(base, kDSPI_TxCompleteFlag|kDSPI_EndOfQueueFlag);
AnnaBridge 143:86740a56073b 554 * @endcode
AnnaBridge 143:86740a56073b 555 *
AnnaBridge 143:86740a56073b 556 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 557 * @param statusFlags The status flag used from the type dspi_flags.
AnnaBridge 143:86740a56073b 558 */
AnnaBridge 143:86740a56073b 559 static inline void DSPI_ClearStatusFlags(SPI_Type *base, uint32_t statusFlags)
AnnaBridge 143:86740a56073b 560 {
AnnaBridge 143:86740a56073b 561 base->SR = statusFlags; /*!< The status flags are cleared by writing 1 (w1c).*/
AnnaBridge 143:86740a56073b 562 }
AnnaBridge 143:86740a56073b 563
AnnaBridge 143:86740a56073b 564 /*!
AnnaBridge 143:86740a56073b 565 *@}
AnnaBridge 143:86740a56073b 566 */
AnnaBridge 143:86740a56073b 567
AnnaBridge 143:86740a56073b 568 /*!
AnnaBridge 143:86740a56073b 569 * @name Interrupts
AnnaBridge 143:86740a56073b 570 * @{
AnnaBridge 143:86740a56073b 571 */
AnnaBridge 143:86740a56073b 572
AnnaBridge 143:86740a56073b 573 /*!
AnnaBridge 143:86740a56073b 574 * @brief Enables the DSPI interrupts.
AnnaBridge 143:86740a56073b 575 *
AnnaBridge 143:86740a56073b 576 * This function configures the various interrupt masks of the DSPI. The parameters are a base and an interrupt mask.
AnnaBridge 143:86740a56073b 577 * Note, for Tx Fill and Rx FIFO drain requests, enable the interrupt request and disable the DMA request.
AnnaBridge 143:86740a56073b 578 *
AnnaBridge 143:86740a56073b 579 * @code
AnnaBridge 143:86740a56073b 580 * DSPI_EnableInterrupts(base, kDSPI_TxCompleteInterruptEnable | kDSPI_EndOfQueueInterruptEnable );
AnnaBridge 143:86740a56073b 581 * @endcode
AnnaBridge 143:86740a56073b 582 *
AnnaBridge 143:86740a56073b 583 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 584 * @param mask The interrupt mask; use the enum _dspi_interrupt_enable.
AnnaBridge 143:86740a56073b 585 */
AnnaBridge 143:86740a56073b 586 void DSPI_EnableInterrupts(SPI_Type *base, uint32_t mask);
AnnaBridge 143:86740a56073b 587
AnnaBridge 143:86740a56073b 588 /*!
AnnaBridge 143:86740a56073b 589 * @brief Disables the DSPI interrupts.
AnnaBridge 143:86740a56073b 590 *
AnnaBridge 143:86740a56073b 591 * @code
AnnaBridge 143:86740a56073b 592 * DSPI_DisableInterrupts(base, kDSPI_TxCompleteInterruptEnable | kDSPI_EndOfQueueInterruptEnable );
AnnaBridge 143:86740a56073b 593 * @endcode
AnnaBridge 143:86740a56073b 594 *
AnnaBridge 143:86740a56073b 595 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 596 * @param mask The interrupt mask; use the enum _dspi_interrupt_enable.
AnnaBridge 143:86740a56073b 597 */
AnnaBridge 143:86740a56073b 598 static inline void DSPI_DisableInterrupts(SPI_Type *base, uint32_t mask)
AnnaBridge 143:86740a56073b 599 {
AnnaBridge 143:86740a56073b 600 base->RSER &= ~mask;
AnnaBridge 143:86740a56073b 601 }
AnnaBridge 143:86740a56073b 602
AnnaBridge 143:86740a56073b 603 /*!
AnnaBridge 143:86740a56073b 604 *@}
AnnaBridge 143:86740a56073b 605 */
AnnaBridge 143:86740a56073b 606
AnnaBridge 143:86740a56073b 607 /*!
AnnaBridge 143:86740a56073b 608 * @name DMA Control
AnnaBridge 143:86740a56073b 609 * @{
AnnaBridge 143:86740a56073b 610 */
AnnaBridge 143:86740a56073b 611
AnnaBridge 143:86740a56073b 612 /*!
AnnaBridge 143:86740a56073b 613 * @brief Enables the DSPI DMA request.
AnnaBridge 143:86740a56073b 614 *
AnnaBridge 143:86740a56073b 615 * This function configures the Rx and Tx DMA mask of the DSPI. The parameters are a base and a DMA mask.
AnnaBridge 143:86740a56073b 616 * @code
AnnaBridge 143:86740a56073b 617 * DSPI_EnableDMA(base, kDSPI_TxDmaEnable | kDSPI_RxDmaEnable);
AnnaBridge 143:86740a56073b 618 * @endcode
AnnaBridge 143:86740a56073b 619 *
AnnaBridge 143:86740a56073b 620 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 621 * @param mask The interrupt mask; use the enum dspi_dma_enable.
AnnaBridge 143:86740a56073b 622 */
AnnaBridge 143:86740a56073b 623 static inline void DSPI_EnableDMA(SPI_Type *base, uint32_t mask)
AnnaBridge 143:86740a56073b 624 {
AnnaBridge 143:86740a56073b 625 base->RSER |= mask;
AnnaBridge 143:86740a56073b 626 }
AnnaBridge 143:86740a56073b 627
AnnaBridge 143:86740a56073b 628 /*!
AnnaBridge 143:86740a56073b 629 * @brief Disables the DSPI DMA request.
AnnaBridge 143:86740a56073b 630 *
AnnaBridge 143:86740a56073b 631 * This function configures the Rx and Tx DMA mask of the DSPI. The parameters are a base and a DMA mask.
AnnaBridge 143:86740a56073b 632 * @code
AnnaBridge 143:86740a56073b 633 * SPI_DisableDMA(base, kDSPI_TxDmaEnable | kDSPI_RxDmaEnable);
AnnaBridge 143:86740a56073b 634 * @endcode
AnnaBridge 143:86740a56073b 635 *
AnnaBridge 143:86740a56073b 636 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 637 * @param mask The interrupt mask; use the enum dspi_dma_enable.
AnnaBridge 143:86740a56073b 638 */
AnnaBridge 143:86740a56073b 639 static inline void DSPI_DisableDMA(SPI_Type *base, uint32_t mask)
AnnaBridge 143:86740a56073b 640 {
AnnaBridge 143:86740a56073b 641 base->RSER &= ~mask;
AnnaBridge 143:86740a56073b 642 }
AnnaBridge 143:86740a56073b 643
AnnaBridge 143:86740a56073b 644 /*!
AnnaBridge 143:86740a56073b 645 * @brief Gets the DSPI master PUSHR data register address for the DMA operation.
AnnaBridge 143:86740a56073b 646 *
AnnaBridge 143:86740a56073b 647 * This function gets the DSPI master PUSHR data register address because this value is needed for the DMA operation.
AnnaBridge 143:86740a56073b 648 *
AnnaBridge 143:86740a56073b 649 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 650 * @return The DSPI master PUSHR data register address.
AnnaBridge 143:86740a56073b 651 */
AnnaBridge 143:86740a56073b 652 static inline uint32_t DSPI_MasterGetTxRegisterAddress(SPI_Type *base)
AnnaBridge 143:86740a56073b 653 {
AnnaBridge 143:86740a56073b 654 return (uint32_t) & (base->PUSHR);
AnnaBridge 143:86740a56073b 655 }
AnnaBridge 143:86740a56073b 656
AnnaBridge 143:86740a56073b 657 /*!
AnnaBridge 143:86740a56073b 658 * @brief Gets the DSPI slave PUSHR data register address for the DMA operation.
AnnaBridge 143:86740a56073b 659 *
AnnaBridge 143:86740a56073b 660 * This function gets the DSPI slave PUSHR data register address as this value is needed for the DMA operation.
AnnaBridge 143:86740a56073b 661 *
AnnaBridge 143:86740a56073b 662 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 663 * @return The DSPI slave PUSHR data register address.
AnnaBridge 143:86740a56073b 664 */
AnnaBridge 143:86740a56073b 665 static inline uint32_t DSPI_SlaveGetTxRegisterAddress(SPI_Type *base)
AnnaBridge 143:86740a56073b 666 {
AnnaBridge 143:86740a56073b 667 return (uint32_t) & (base->PUSHR_SLAVE);
AnnaBridge 143:86740a56073b 668 }
AnnaBridge 143:86740a56073b 669
AnnaBridge 143:86740a56073b 670 /*!
AnnaBridge 143:86740a56073b 671 * @brief Gets the DSPI POPR data register address for the DMA operation.
AnnaBridge 143:86740a56073b 672 *
AnnaBridge 143:86740a56073b 673 * This function gets the DSPI POPR data register address as this value is needed for the DMA operation.
AnnaBridge 143:86740a56073b 674 *
AnnaBridge 143:86740a56073b 675 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 676 * @return The DSPI POPR data register address.
AnnaBridge 143:86740a56073b 677 */
AnnaBridge 143:86740a56073b 678 static inline uint32_t DSPI_GetRxRegisterAddress(SPI_Type *base)
AnnaBridge 143:86740a56073b 679 {
AnnaBridge 143:86740a56073b 680 return (uint32_t) & (base->POPR);
AnnaBridge 143:86740a56073b 681 }
AnnaBridge 143:86740a56073b 682
AnnaBridge 143:86740a56073b 683 /*!
AnnaBridge 143:86740a56073b 684 *@}
AnnaBridge 143:86740a56073b 685 */
AnnaBridge 143:86740a56073b 686
AnnaBridge 143:86740a56073b 687 /*!
AnnaBridge 143:86740a56073b 688 * @name Bus Operations
AnnaBridge 143:86740a56073b 689 * @{
AnnaBridge 143:86740a56073b 690 */
AnnaBridge 143:86740a56073b 691
AnnaBridge 143:86740a56073b 692 /*!
AnnaBridge 143:86740a56073b 693 * @brief Configures the DSPI for master or slave.
AnnaBridge 143:86740a56073b 694 *
AnnaBridge 143:86740a56073b 695 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 696 * @param mode Mode setting (master or slave) of type dspi_master_slave_mode_t.
AnnaBridge 143:86740a56073b 697 */
AnnaBridge 143:86740a56073b 698 static inline void DSPI_SetMasterSlaveMode(SPI_Type *base, dspi_master_slave_mode_t mode)
AnnaBridge 143:86740a56073b 699 {
AnnaBridge 143:86740a56073b 700 base->MCR = (base->MCR & (~SPI_MCR_MSTR_MASK)) | SPI_MCR_MSTR(mode);
AnnaBridge 143:86740a56073b 701 }
AnnaBridge 143:86740a56073b 702
AnnaBridge 143:86740a56073b 703 /*!
AnnaBridge 143:86740a56073b 704 * @brief Returns whether the DSPI module is in master mode.
AnnaBridge 143:86740a56073b 705 *
AnnaBridge 143:86740a56073b 706 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 707 * @return Returns true if the module is in master mode or false if the module is in slave mode.
AnnaBridge 143:86740a56073b 708 */
AnnaBridge 143:86740a56073b 709 static inline bool DSPI_IsMaster(SPI_Type *base)
AnnaBridge 143:86740a56073b 710 {
AnnaBridge 143:86740a56073b 711 return (bool)((base->MCR) & SPI_MCR_MSTR_MASK);
AnnaBridge 143:86740a56073b 712 }
AnnaBridge 143:86740a56073b 713 /*!
AnnaBridge 143:86740a56073b 714 * @brief Starts the DSPI transfers and clears HALT bit in MCR.
AnnaBridge 143:86740a56073b 715 *
AnnaBridge 143:86740a56073b 716 * This function sets the module to start data transfer in either master or slave mode.
AnnaBridge 143:86740a56073b 717 *
AnnaBridge 143:86740a56073b 718 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 719 */
AnnaBridge 143:86740a56073b 720 static inline void DSPI_StartTransfer(SPI_Type *base)
AnnaBridge 143:86740a56073b 721 {
AnnaBridge 143:86740a56073b 722 base->MCR &= ~SPI_MCR_HALT_MASK;
AnnaBridge 143:86740a56073b 723 }
AnnaBridge 143:86740a56073b 724 /*!
AnnaBridge 143:86740a56073b 725 * @brief Stops DSPI transfers and sets the HALT bit in MCR.
AnnaBridge 143:86740a56073b 726 *
AnnaBridge 143:86740a56073b 727 * This function stops data transfers in either master or slave modes.
AnnaBridge 143:86740a56073b 728 *
AnnaBridge 143:86740a56073b 729 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 730 */
AnnaBridge 143:86740a56073b 731 static inline void DSPI_StopTransfer(SPI_Type *base)
AnnaBridge 143:86740a56073b 732 {
AnnaBridge 143:86740a56073b 733 base->MCR |= SPI_MCR_HALT_MASK;
AnnaBridge 143:86740a56073b 734 }
AnnaBridge 143:86740a56073b 735
AnnaBridge 143:86740a56073b 736 /*!
AnnaBridge 143:86740a56073b 737 * @brief Enables or disables the DSPI FIFOs.
AnnaBridge 143:86740a56073b 738 *
AnnaBridge 143:86740a56073b 739 * This function allows the caller to disable/enable the Tx and Rx FIFOs independently.
AnnaBridge 143:86740a56073b 740 * Note that to disable, pass in a logic 0 (false) for the particular FIFO configuration. To enable,
AnnaBridge 143:86740a56073b 741 * pass in a logic 1 (true).
AnnaBridge 143:86740a56073b 742 *
AnnaBridge 143:86740a56073b 743 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 744 * @param enableTxFifo Disables (false) the TX FIFO; Otherwise, enables (true) the TX FIFO
AnnaBridge 143:86740a56073b 745 * @param enableRxFifo Disables (false) the RX FIFO; Otherwise, enables (true) the RX FIFO
AnnaBridge 143:86740a56073b 746 */
AnnaBridge 143:86740a56073b 747 static inline void DSPI_SetFifoEnable(SPI_Type *base, bool enableTxFifo, bool enableRxFifo)
AnnaBridge 143:86740a56073b 748 {
AnnaBridge 143:86740a56073b 749 base->MCR = (base->MCR & (~(SPI_MCR_DIS_RXF_MASK | SPI_MCR_DIS_TXF_MASK))) | SPI_MCR_DIS_TXF(!enableTxFifo) |
AnnaBridge 143:86740a56073b 750 SPI_MCR_DIS_RXF(!enableRxFifo);
AnnaBridge 143:86740a56073b 751 }
AnnaBridge 143:86740a56073b 752
AnnaBridge 143:86740a56073b 753 /*!
AnnaBridge 143:86740a56073b 754 * @brief Flushes the DSPI FIFOs.
AnnaBridge 143:86740a56073b 755 *
AnnaBridge 143:86740a56073b 756 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 757 * @param flushTxFifo Flushes (true) the Tx FIFO; Otherwise, does not flush (false) the Tx FIFO
AnnaBridge 143:86740a56073b 758 * @param flushRxFifo Flushes (true) the Rx FIFO; Otherwise, does not flush (false) the Rx FIFO
AnnaBridge 143:86740a56073b 759 */
AnnaBridge 143:86740a56073b 760 static inline void DSPI_FlushFifo(SPI_Type *base, bool flushTxFifo, bool flushRxFifo)
AnnaBridge 143:86740a56073b 761 {
AnnaBridge 143:86740a56073b 762 base->MCR = (base->MCR & (~(SPI_MCR_CLR_TXF_MASK | SPI_MCR_CLR_RXF_MASK))) | SPI_MCR_CLR_TXF(flushTxFifo) |
AnnaBridge 143:86740a56073b 763 SPI_MCR_CLR_RXF(flushRxFifo);
AnnaBridge 143:86740a56073b 764 }
AnnaBridge 143:86740a56073b 765
AnnaBridge 143:86740a56073b 766 /*!
AnnaBridge 143:86740a56073b 767 * @brief Configures the DSPI peripheral chip select polarity simultaneously.
AnnaBridge 143:86740a56073b 768 * For example, PCS0 and PCS1 are set to active low and other PCS is set to active high. Note that the number of
AnnaBridge 143:86740a56073b 769 * PCSs is specific to the device.
AnnaBridge 143:86740a56073b 770 * @code
AnnaBridge 143:86740a56073b 771 * DSPI_SetAllPcsPolarity(base, kDSPI_Pcs0ActiveLow | kDSPI_Pcs1ActiveLow);
AnnaBridge 143:86740a56073b 772 @endcode
AnnaBridge 143:86740a56073b 773 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 774 * @param mask The PCS polarity mask; use the enum _dspi_pcs_polarity.
AnnaBridge 143:86740a56073b 775 */
AnnaBridge 143:86740a56073b 776 static inline void DSPI_SetAllPcsPolarity(SPI_Type *base, uint32_t mask)
AnnaBridge 143:86740a56073b 777 {
AnnaBridge 143:86740a56073b 778 base->MCR = (base->MCR & ~SPI_MCR_PCSIS_MASK) | SPI_MCR_PCSIS(mask);
AnnaBridge 143:86740a56073b 779 }
AnnaBridge 143:86740a56073b 780
AnnaBridge 143:86740a56073b 781 /*!
AnnaBridge 143:86740a56073b 782 * @brief Sets the DSPI baud rate in bits per second.
AnnaBridge 143:86740a56073b 783 *
AnnaBridge 143:86740a56073b 784 * This function takes in the desired baudRate_Bps (baud rate) and calculates the nearest possible baud rate without
AnnaBridge 143:86740a56073b 785 * exceeding the desired baud rate, and returns the calculated baud rate in bits-per-second. It requires that the
AnnaBridge 143:86740a56073b 786 * caller also provide the frequency of the module source clock (in Hertz).
AnnaBridge 143:86740a56073b 787 *
AnnaBridge 143:86740a56073b 788 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 789 * @param whichCtar The desired Clock and Transfer Attributes Register (CTAR) of the type dspi_ctar_selection_t
AnnaBridge 143:86740a56073b 790 * @param baudRate_Bps The desired baud rate in bits per second
AnnaBridge 143:86740a56073b 791 * @param srcClock_Hz Module source input clock in Hertz
AnnaBridge 143:86740a56073b 792 * @return The actual calculated baud rate
AnnaBridge 143:86740a56073b 793 */
AnnaBridge 143:86740a56073b 794 uint32_t DSPI_MasterSetBaudRate(SPI_Type *base,
AnnaBridge 143:86740a56073b 795 dspi_ctar_selection_t whichCtar,
AnnaBridge 143:86740a56073b 796 uint32_t baudRate_Bps,
AnnaBridge 143:86740a56073b 797 uint32_t srcClock_Hz);
AnnaBridge 143:86740a56073b 798
AnnaBridge 143:86740a56073b 799 /*!
AnnaBridge 143:86740a56073b 800 * @brief Manually configures the delay prescaler and scaler for a particular CTAR.
AnnaBridge 143:86740a56073b 801 *
AnnaBridge 143:86740a56073b 802 * This function configures the PCS to SCK delay pre-scalar (PcsSCK) and scalar (CSSCK), after SCK delay pre-scalar
AnnaBridge 143:86740a56073b 803 * (PASC) and scalar (ASC), and the delay after transfer pre-scalar (PDT) and scalar (DT).
AnnaBridge 143:86740a56073b 804 *
AnnaBridge 143:86740a56073b 805 * These delay names are available in the type dspi_delay_type_t.
AnnaBridge 143:86740a56073b 806 *
AnnaBridge 143:86740a56073b 807 * The user passes the delay to the configuration along with the prescaler and scaler value.
AnnaBridge 143:86740a56073b 808 * This allows the user to directly set the prescaler/scaler values if pre-calculated or
AnnaBridge 143:86740a56073b 809 * to manually increment either value.
AnnaBridge 143:86740a56073b 810 *
AnnaBridge 143:86740a56073b 811 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 812 * @param whichCtar The desired Clock and Transfer Attributes Register (CTAR) of type dspi_ctar_selection_t.
AnnaBridge 143:86740a56073b 813 * @param prescaler The prescaler delay value (can be an integer 0, 1, 2, or 3).
AnnaBridge 143:86740a56073b 814 * @param scaler The scaler delay value (can be any integer between 0 to 15).
AnnaBridge 143:86740a56073b 815 * @param whichDelay The desired delay to configure; must be of type dspi_delay_type_t
AnnaBridge 143:86740a56073b 816 */
AnnaBridge 143:86740a56073b 817 void DSPI_MasterSetDelayScaler(
AnnaBridge 143:86740a56073b 818 SPI_Type *base, dspi_ctar_selection_t whichCtar, uint32_t prescaler, uint32_t scaler, dspi_delay_type_t whichDelay);
AnnaBridge 143:86740a56073b 819
AnnaBridge 143:86740a56073b 820 /*!
AnnaBridge 143:86740a56073b 821 * @brief Calculates the delay prescaler and scaler based on the desired delay input in nanoseconds.
AnnaBridge 143:86740a56073b 822 *
AnnaBridge 143:86740a56073b 823 * This function calculates the values for the following.
AnnaBridge 143:86740a56073b 824 * PCS to SCK delay pre-scalar (PCSSCK) and scalar (CSSCK), or
AnnaBridge 143:86740a56073b 825 * After SCK delay pre-scalar (PASC) and scalar (ASC), or
AnnaBridge 143:86740a56073b 826 * Delay after transfer pre-scalar (PDT) and scalar (DT).
AnnaBridge 143:86740a56073b 827 *
AnnaBridge 143:86740a56073b 828 * These delay names are available in the type dspi_delay_type_t.
AnnaBridge 143:86740a56073b 829 *
AnnaBridge 143:86740a56073b 830 * The user passes which delay to configure along with the desired delay value in nanoseconds. The function
AnnaBridge 143:86740a56073b 831 * calculates the values needed for the prescaler and scaler. Note that returning the calculated delay as an exact
AnnaBridge 143:86740a56073b 832 * delay match may not be possible. In this case, the closest match is calculated without going below the desired
AnnaBridge 143:86740a56073b 833 * delay value input.
AnnaBridge 143:86740a56073b 834 * It is possible to input a very large delay value that exceeds the capability of the part, in which case the maximum
AnnaBridge 143:86740a56073b 835 * supported delay is returned. The higher-level peripheral driver alerts the user of an out of range delay
AnnaBridge 143:86740a56073b 836 * input.
AnnaBridge 143:86740a56073b 837 *
AnnaBridge 143:86740a56073b 838 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 839 * @param whichCtar The desired Clock and Transfer Attributes Register (CTAR) of type dspi_ctar_selection_t.
AnnaBridge 143:86740a56073b 840 * @param whichDelay The desired delay to configure, must be of type dspi_delay_type_t
AnnaBridge 143:86740a56073b 841 * @param srcClock_Hz Module source input clock in Hertz
AnnaBridge 143:86740a56073b 842 * @param delayTimeInNanoSec The desired delay value in nanoseconds.
AnnaBridge 143:86740a56073b 843 * @return The actual calculated delay value.
AnnaBridge 143:86740a56073b 844 */
AnnaBridge 143:86740a56073b 845 uint32_t DSPI_MasterSetDelayTimes(SPI_Type *base,
AnnaBridge 143:86740a56073b 846 dspi_ctar_selection_t whichCtar,
AnnaBridge 143:86740a56073b 847 dspi_delay_type_t whichDelay,
AnnaBridge 143:86740a56073b 848 uint32_t srcClock_Hz,
AnnaBridge 143:86740a56073b 849 uint32_t delayTimeInNanoSec);
AnnaBridge 143:86740a56073b 850
AnnaBridge 143:86740a56073b 851 /*!
AnnaBridge 143:86740a56073b 852 * @brief Writes data into the data buffer for master mode.
AnnaBridge 143:86740a56073b 853 *
AnnaBridge 143:86740a56073b 854 * In master mode, the 16-bit data is appended to the 16-bit command info. The command portion
AnnaBridge 143:86740a56073b 855 * provides characteristics of the data, such as the optional continuous chip select
AnnaBridge 143:86740a56073b 856 * operation between transfers, the desired Clock and Transfer Attributes register to use for the
AnnaBridge 143:86740a56073b 857 * associated SPI frame, the desired PCS signal to use for the data transfer, whether the current
AnnaBridge 143:86740a56073b 858 * transfer is the last in the queue, and whether to clear the transfer count (normally needed when
AnnaBridge 143:86740a56073b 859 * sending the first frame of a data packet). This is an example.
AnnaBridge 143:86740a56073b 860 * @code
AnnaBridge 143:86740a56073b 861 * dspi_command_data_config_t commandConfig;
AnnaBridge 143:86740a56073b 862 * commandConfig.isPcsContinuous = true;
AnnaBridge 143:86740a56073b 863 * commandConfig.whichCtar = kDSPICtar0;
AnnaBridge 143:86740a56073b 864 * commandConfig.whichPcs = kDSPIPcs0;
AnnaBridge 143:86740a56073b 865 * commandConfig.clearTransferCount = false;
AnnaBridge 143:86740a56073b 866 * commandConfig.isEndOfQueue = false;
AnnaBridge 143:86740a56073b 867 * DSPI_MasterWriteData(base, &commandConfig, dataWord);
AnnaBridge 143:86740a56073b 868 @endcode
AnnaBridge 143:86740a56073b 869 *
AnnaBridge 143:86740a56073b 870 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 871 * @param command Pointer to the command structure.
AnnaBridge 143:86740a56073b 872 * @param data The data word to be sent.
AnnaBridge 143:86740a56073b 873 */
AnnaBridge 143:86740a56073b 874 static inline void DSPI_MasterWriteData(SPI_Type *base, dspi_command_data_config_t *command, uint16_t data)
AnnaBridge 143:86740a56073b 875 {
AnnaBridge 143:86740a56073b 876 base->PUSHR = SPI_PUSHR_CONT(command->isPcsContinuous) | SPI_PUSHR_CTAS(command->whichCtar) |
AnnaBridge 143:86740a56073b 877 SPI_PUSHR_PCS(command->whichPcs) | SPI_PUSHR_EOQ(command->isEndOfQueue) |
AnnaBridge 143:86740a56073b 878 SPI_PUSHR_CTCNT(command->clearTransferCount) | SPI_PUSHR_TXDATA(data);
AnnaBridge 143:86740a56073b 879 }
AnnaBridge 143:86740a56073b 880
AnnaBridge 143:86740a56073b 881 /*!
AnnaBridge 143:86740a56073b 882 * @brief Sets the dspi_command_data_config_t structure to default values.
AnnaBridge 143:86740a56073b 883 *
AnnaBridge 143:86740a56073b 884 * The purpose of this API is to get the configuration structure initialized for use in the DSPI_MasterWrite_xx().
AnnaBridge 143:86740a56073b 885 * Users may use the initialized structure unchanged in the DSPI_MasterWrite_xx() or modify the structure
AnnaBridge 143:86740a56073b 886 * before calling the DSPI_MasterWrite_xx().
AnnaBridge 143:86740a56073b 887 * This is an example.
AnnaBridge 143:86740a56073b 888 * @code
AnnaBridge 143:86740a56073b 889 * dspi_command_data_config_t command;
AnnaBridge 143:86740a56073b 890 * DSPI_GetDefaultDataCommandConfig(&command);
AnnaBridge 143:86740a56073b 891 * @endcode
AnnaBridge 143:86740a56073b 892 * @param command Pointer to the dspi_command_data_config_t structure.
AnnaBridge 143:86740a56073b 893 */
AnnaBridge 143:86740a56073b 894 void DSPI_GetDefaultDataCommandConfig(dspi_command_data_config_t *command);
AnnaBridge 143:86740a56073b 895
AnnaBridge 143:86740a56073b 896 /*!
AnnaBridge 143:86740a56073b 897 * @brief Writes data into the data buffer master mode and waits till complete to return.
AnnaBridge 143:86740a56073b 898 *
AnnaBridge 143:86740a56073b 899 * In master mode, the 16-bit data is appended to the 16-bit command info. The command portion
AnnaBridge 143:86740a56073b 900 * provides characteristics of the data, such as the optional continuous chip select
AnnaBridge 143:86740a56073b 901 * operation between transfers, the desired Clock and Transfer Attributes register to use for the
AnnaBridge 143:86740a56073b 902 * associated SPI frame, the desired PCS signal to use for the data transfer, whether the current
AnnaBridge 143:86740a56073b 903 * transfer is the last in the queue, and whether to clear the transfer count (normally needed when
AnnaBridge 143:86740a56073b 904 * sending the first frame of a data packet). This is an example.
AnnaBridge 143:86740a56073b 905 * @code
AnnaBridge 143:86740a56073b 906 * dspi_command_config_t commandConfig;
AnnaBridge 143:86740a56073b 907 * commandConfig.isPcsContinuous = true;
AnnaBridge 143:86740a56073b 908 * commandConfig.whichCtar = kDSPICtar0;
AnnaBridge 143:86740a56073b 909 * commandConfig.whichPcs = kDSPIPcs1;
AnnaBridge 143:86740a56073b 910 * commandConfig.clearTransferCount = false;
AnnaBridge 143:86740a56073b 911 * commandConfig.isEndOfQueue = false;
AnnaBridge 143:86740a56073b 912 * DSPI_MasterWriteDataBlocking(base, &commandConfig, dataWord);
AnnaBridge 143:86740a56073b 913 * @endcode
AnnaBridge 143:86740a56073b 914 *
AnnaBridge 143:86740a56073b 915 * Note that this function does not return until after the transmit is complete. Also note that the DSPI must be
AnnaBridge 143:86740a56073b 916 * enabled and running to transmit data (MCR[MDIS] & [HALT] = 0). Because the SPI is a synchronous protocol,
AnnaBridge 143:86740a56073b 917 * the received data is available when the transmit completes.
AnnaBridge 143:86740a56073b 918 *
AnnaBridge 143:86740a56073b 919 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 920 * @param command Pointer to the command structure.
AnnaBridge 143:86740a56073b 921 * @param data The data word to be sent.
AnnaBridge 143:86740a56073b 922 */
AnnaBridge 143:86740a56073b 923 void DSPI_MasterWriteDataBlocking(SPI_Type *base, dspi_command_data_config_t *command, uint16_t data);
AnnaBridge 143:86740a56073b 924
AnnaBridge 143:86740a56073b 925 /*!
AnnaBridge 143:86740a56073b 926 * @brief Returns the DSPI command word formatted to the PUSHR data register bit field.
AnnaBridge 143:86740a56073b 927 *
AnnaBridge 143:86740a56073b 928 * This function allows the caller to pass in the data command structure and returns the command word formatted
AnnaBridge 143:86740a56073b 929 * according to the DSPI PUSHR register bit field placement. The user can then "OR" the returned command word with the
AnnaBridge 143:86740a56073b 930 * desired data to send and use the function DSPI_HAL_WriteCommandDataMastermode or
AnnaBridge 143:86740a56073b 931 * DSPI_HAL_WriteCommandDataMastermodeBlocking to write the entire 32-bit command data word to the PUSHR. This helps
AnnaBridge 143:86740a56073b 932 * improve performance in cases where the command structure is constant. For example, the user calls this function
AnnaBridge 143:86740a56073b 933 * before starting a transfer to generate the command word. When they are ready to transmit the data, they OR
AnnaBridge 143:86740a56073b 934 * this formatted command word with the desired data to transmit. This process increases transmit performance when
AnnaBridge 143:86740a56073b 935 * compared to calling send functions, such as DSPI_HAL_WriteDataMastermode, which format the command word each time a
AnnaBridge 143:86740a56073b 936 * data word is to be sent.
AnnaBridge 143:86740a56073b 937 *
AnnaBridge 143:86740a56073b 938 * @param command Pointer to the command structure.
AnnaBridge 143:86740a56073b 939 * @return The command word formatted to the PUSHR data register bit field.
AnnaBridge 143:86740a56073b 940 */
AnnaBridge 143:86740a56073b 941 static inline uint32_t DSPI_MasterGetFormattedCommand(dspi_command_data_config_t *command)
AnnaBridge 143:86740a56073b 942 {
AnnaBridge 143:86740a56073b 943 /* Format the 16-bit command word according to the PUSHR data register bit field*/
AnnaBridge 143:86740a56073b 944 return (uint32_t)(SPI_PUSHR_CONT(command->isPcsContinuous) | SPI_PUSHR_CTAS(command->whichCtar) |
AnnaBridge 143:86740a56073b 945 SPI_PUSHR_PCS(command->whichPcs) | SPI_PUSHR_EOQ(command->isEndOfQueue) |
AnnaBridge 143:86740a56073b 946 SPI_PUSHR_CTCNT(command->clearTransferCount));
AnnaBridge 143:86740a56073b 947 }
AnnaBridge 143:86740a56073b 948
AnnaBridge 143:86740a56073b 949 /*!
AnnaBridge 143:86740a56073b 950 * @brief Writes a 32-bit data word (16-bit command appended with 16-bit data) into the data
AnnaBridge 143:86740a56073b 951 * buffer master mode and waits till complete to return.
AnnaBridge 143:86740a56073b 952 *
AnnaBridge 143:86740a56073b 953 * In this function, the user must append the 16-bit data to the 16-bit command information and then provide the total 32-bit word
AnnaBridge 143:86740a56073b 954 * as the data to send.
AnnaBridge 143:86740a56073b 955 * The command portion provides characteristics of the data, such as the optional continuous chip select operation
AnnaBridge 143:86740a56073b 956 * between transfers, the desired Clock and Transfer Attributes register to use for the associated SPI frame, the desired PCS
AnnaBridge 143:86740a56073b 957 * signal to use for the data transfer, whether the current transfer is the last in the queue, and whether to clear the
AnnaBridge 143:86740a56073b 958 * transfer count (normally needed when sending the first frame of a data packet). The user is responsible for
AnnaBridge 143:86740a56073b 959 * appending this command with the data to send. This is an example:
AnnaBridge 143:86740a56073b 960 * @code
AnnaBridge 143:86740a56073b 961 * dataWord = <16-bit command> | <16-bit data>;
AnnaBridge 143:86740a56073b 962 * DSPI_MasterWriteCommandDataBlocking(base, dataWord);
AnnaBridge 143:86740a56073b 963 * @endcode
AnnaBridge 143:86740a56073b 964 *
AnnaBridge 143:86740a56073b 965 * Note that this function does not return until after the transmit is complete. Also note that the DSPI must be
AnnaBridge 143:86740a56073b 966 * enabled and running to transmit data (MCR[MDIS] & [HALT] = 0).
AnnaBridge 143:86740a56073b 967 * Because the SPI is a synchronous protocol, the received data is available when the transmit completes.
AnnaBridge 143:86740a56073b 968 *
AnnaBridge 143:86740a56073b 969 * For a blocking polling transfer, see methods below.
AnnaBridge 143:86740a56073b 970 * Option 1:
AnnaBridge 143:86740a56073b 971 * uint32_t command_to_send = DSPI_MasterGetFormattedCommand(&command);
AnnaBridge 143:86740a56073b 972 * uint32_t data0 = command_to_send | data_need_to_send_0;
AnnaBridge 143:86740a56073b 973 * uint32_t data1 = command_to_send | data_need_to_send_1;
AnnaBridge 143:86740a56073b 974 * uint32_t data2 = command_to_send | data_need_to_send_2;
AnnaBridge 143:86740a56073b 975 *
AnnaBridge 143:86740a56073b 976 * DSPI_MasterWriteCommandDataBlocking(base,data0);
AnnaBridge 143:86740a56073b 977 * DSPI_MasterWriteCommandDataBlocking(base,data1);
AnnaBridge 143:86740a56073b 978 * DSPI_MasterWriteCommandDataBlocking(base,data2);
AnnaBridge 143:86740a56073b 979 *
AnnaBridge 143:86740a56073b 980 * Option 2:
AnnaBridge 143:86740a56073b 981 * DSPI_MasterWriteDataBlocking(base,&command,data_need_to_send_0);
AnnaBridge 143:86740a56073b 982 * DSPI_MasterWriteDataBlocking(base,&command,data_need_to_send_1);
AnnaBridge 143:86740a56073b 983 * DSPI_MasterWriteDataBlocking(base,&command,data_need_to_send_2);
AnnaBridge 143:86740a56073b 984 *
AnnaBridge 143:86740a56073b 985 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 986 * @param data The data word (command and data combined) to be sent.
AnnaBridge 143:86740a56073b 987 */
AnnaBridge 143:86740a56073b 988 void DSPI_MasterWriteCommandDataBlocking(SPI_Type *base, uint32_t data);
AnnaBridge 143:86740a56073b 989
AnnaBridge 143:86740a56073b 990 /*!
AnnaBridge 143:86740a56073b 991 * @brief Writes data into the data buffer in slave mode.
AnnaBridge 143:86740a56073b 992 *
AnnaBridge 143:86740a56073b 993 * In slave mode, up to 16-bit words may be written.
AnnaBridge 143:86740a56073b 994 *
AnnaBridge 143:86740a56073b 995 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 996 * @param data The data to send.
AnnaBridge 143:86740a56073b 997 */
AnnaBridge 143:86740a56073b 998 static inline void DSPI_SlaveWriteData(SPI_Type *base, uint32_t data)
AnnaBridge 143:86740a56073b 999 {
AnnaBridge 143:86740a56073b 1000 base->PUSHR_SLAVE = data;
AnnaBridge 143:86740a56073b 1001 }
AnnaBridge 143:86740a56073b 1002
AnnaBridge 143:86740a56073b 1003 /*!
AnnaBridge 143:86740a56073b 1004 * @brief Writes data into the data buffer in slave mode, waits till data was transmitted, and returns.
AnnaBridge 143:86740a56073b 1005 *
AnnaBridge 143:86740a56073b 1006 * In slave mode, up to 16-bit words may be written. The function first clears the transmit complete flag, writes data
AnnaBridge 143:86740a56073b 1007 * into data register, and finally waits until the data is transmitted.
AnnaBridge 143:86740a56073b 1008 *
AnnaBridge 143:86740a56073b 1009 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 1010 * @param data The data to send.
AnnaBridge 143:86740a56073b 1011 */
AnnaBridge 143:86740a56073b 1012 void DSPI_SlaveWriteDataBlocking(SPI_Type *base, uint32_t data);
AnnaBridge 143:86740a56073b 1013
AnnaBridge 143:86740a56073b 1014 /*!
AnnaBridge 143:86740a56073b 1015 * @brief Reads data from the data buffer.
AnnaBridge 143:86740a56073b 1016 *
AnnaBridge 143:86740a56073b 1017 * @param base DSPI peripheral address.
AnnaBridge 143:86740a56073b 1018 * @return The data from the read data buffer.
AnnaBridge 143:86740a56073b 1019 */
AnnaBridge 143:86740a56073b 1020 static inline uint32_t DSPI_ReadData(SPI_Type *base)
AnnaBridge 143:86740a56073b 1021 {
AnnaBridge 143:86740a56073b 1022 return (base->POPR);
AnnaBridge 143:86740a56073b 1023 }
AnnaBridge 143:86740a56073b 1024
AnnaBridge 143:86740a56073b 1025 /*!
AnnaBridge 143:86740a56073b 1026 *@}
AnnaBridge 143:86740a56073b 1027 */
AnnaBridge 143:86740a56073b 1028
AnnaBridge 143:86740a56073b 1029 /*!
AnnaBridge 143:86740a56073b 1030 * @name Transactional
AnnaBridge 143:86740a56073b 1031 * @{
AnnaBridge 143:86740a56073b 1032 */
AnnaBridge 143:86740a56073b 1033 /*Transactional APIs*/
AnnaBridge 143:86740a56073b 1034
AnnaBridge 143:86740a56073b 1035 /*!
AnnaBridge 143:86740a56073b 1036 * @brief Initializes the DSPI master handle.
AnnaBridge 143:86740a56073b 1037 *
AnnaBridge 143:86740a56073b 1038 * This function initializes the DSPI handle, which can be used for other DSPI transactional APIs. Usually, for a
AnnaBridge 143:86740a56073b 1039 * specified DSPI instance, call this API once to get the initialized handle.
AnnaBridge 143:86740a56073b 1040 *
AnnaBridge 143:86740a56073b 1041 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1042 * @param handle DSPI handle pointer to dspi_master_handle_t.
AnnaBridge 143:86740a56073b 1043 * @param callback DSPI callback.
AnnaBridge 143:86740a56073b 1044 * @param userData Callback function parameter.
AnnaBridge 143:86740a56073b 1045 */
AnnaBridge 143:86740a56073b 1046 void DSPI_MasterTransferCreateHandle(SPI_Type *base,
AnnaBridge 143:86740a56073b 1047 dspi_master_handle_t *handle,
AnnaBridge 143:86740a56073b 1048 dspi_master_transfer_callback_t callback,
AnnaBridge 143:86740a56073b 1049 void *userData);
AnnaBridge 143:86740a56073b 1050
AnnaBridge 143:86740a56073b 1051 /*!
AnnaBridge 143:86740a56073b 1052 * @brief DSPI master transfer data using polling.
AnnaBridge 143:86740a56073b 1053 *
AnnaBridge 143:86740a56073b 1054 * This function transfers data using polling. This is a blocking function, which does not return until all transfers
AnnaBridge 143:86740a56073b 1055 * have been completed.
AnnaBridge 143:86740a56073b 1056 *
AnnaBridge 143:86740a56073b 1057 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1058 * @param transfer Pointer to the dspi_transfer_t structure.
AnnaBridge 143:86740a56073b 1059 * @return status of status_t.
AnnaBridge 143:86740a56073b 1060 */
AnnaBridge 143:86740a56073b 1061 status_t DSPI_MasterTransferBlocking(SPI_Type *base, dspi_transfer_t *transfer);
AnnaBridge 143:86740a56073b 1062
AnnaBridge 143:86740a56073b 1063 /*!
AnnaBridge 143:86740a56073b 1064 * @brief DSPI master transfer data using interrupts.
AnnaBridge 143:86740a56073b 1065 *
AnnaBridge 143:86740a56073b 1066 * This function transfers data using interrupts. This is a non-blocking function, which returns right away. When all
AnnaBridge 143:86740a56073b 1067 * data is transferred, the callback function is called.
AnnaBridge 143:86740a56073b 1068
AnnaBridge 143:86740a56073b 1069 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1070 * @param handle Pointer to the dspi_master_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1071 * @param transfer Pointer to the dspi_transfer_t structure.
AnnaBridge 143:86740a56073b 1072 * @return status of status_t.
AnnaBridge 143:86740a56073b 1073 */
AnnaBridge 143:86740a56073b 1074 status_t DSPI_MasterTransferNonBlocking(SPI_Type *base, dspi_master_handle_t *handle, dspi_transfer_t *transfer);
AnnaBridge 143:86740a56073b 1075
AnnaBridge 143:86740a56073b 1076 /*!
AnnaBridge 143:86740a56073b 1077 * @brief Gets the master transfer count.
AnnaBridge 143:86740a56073b 1078 *
AnnaBridge 143:86740a56073b 1079 * This function gets the master transfer count.
AnnaBridge 143:86740a56073b 1080 *
AnnaBridge 143:86740a56073b 1081 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1082 * @param handle Pointer to the dspi_master_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1083 * @param count The number of bytes transferred by using the non-blocking transaction.
AnnaBridge 143:86740a56073b 1084 * @return status of status_t.
AnnaBridge 143:86740a56073b 1085 */
AnnaBridge 143:86740a56073b 1086 status_t DSPI_MasterTransferGetCount(SPI_Type *base, dspi_master_handle_t *handle, size_t *count);
AnnaBridge 143:86740a56073b 1087
AnnaBridge 143:86740a56073b 1088 /*!
AnnaBridge 143:86740a56073b 1089 * @brief DSPI master aborts a transfer using an interrupt.
AnnaBridge 143:86740a56073b 1090 *
AnnaBridge 143:86740a56073b 1091 * This function aborts a transfer using an interrupt.
AnnaBridge 143:86740a56073b 1092 *
AnnaBridge 143:86740a56073b 1093 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1094 * @param handle Pointer to the dspi_master_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1095 */
AnnaBridge 143:86740a56073b 1096 void DSPI_MasterTransferAbort(SPI_Type *base, dspi_master_handle_t *handle);
AnnaBridge 143:86740a56073b 1097
AnnaBridge 143:86740a56073b 1098 /*!
AnnaBridge 143:86740a56073b 1099 * @brief DSPI Master IRQ handler function.
AnnaBridge 143:86740a56073b 1100 *
AnnaBridge 143:86740a56073b 1101 * This function processes the DSPI transmit and receive IRQ.
AnnaBridge 143:86740a56073b 1102
AnnaBridge 143:86740a56073b 1103 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1104 * @param handle Pointer to the dspi_master_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1105 */
AnnaBridge 143:86740a56073b 1106 void DSPI_MasterTransferHandleIRQ(SPI_Type *base, dspi_master_handle_t *handle);
AnnaBridge 143:86740a56073b 1107
AnnaBridge 143:86740a56073b 1108 /*!
AnnaBridge 143:86740a56073b 1109 * @brief Initializes the DSPI slave handle.
AnnaBridge 143:86740a56073b 1110 *
AnnaBridge 143:86740a56073b 1111 * This function initializes the DSPI handle, which can be used for other DSPI transactional APIs. Usually, for a
AnnaBridge 143:86740a56073b 1112 * specified DSPI instance, call this API once to get the initialized handle.
AnnaBridge 143:86740a56073b 1113 *
AnnaBridge 143:86740a56073b 1114 * @param handle DSPI handle pointer to the dspi_slave_handle_t.
AnnaBridge 143:86740a56073b 1115 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1116 * @param callback DSPI callback.
AnnaBridge 143:86740a56073b 1117 * @param userData Callback function parameter.
AnnaBridge 143:86740a56073b 1118 */
AnnaBridge 143:86740a56073b 1119 void DSPI_SlaveTransferCreateHandle(SPI_Type *base,
AnnaBridge 143:86740a56073b 1120 dspi_slave_handle_t *handle,
AnnaBridge 143:86740a56073b 1121 dspi_slave_transfer_callback_t callback,
AnnaBridge 143:86740a56073b 1122 void *userData);
AnnaBridge 143:86740a56073b 1123
AnnaBridge 143:86740a56073b 1124 /*!
AnnaBridge 143:86740a56073b 1125 * @brief DSPI slave transfers data using an interrupt.
AnnaBridge 143:86740a56073b 1126 *
AnnaBridge 143:86740a56073b 1127 * This function transfers data using an interrupt. This is a non-blocking function, which returns right away. When all
AnnaBridge 143:86740a56073b 1128 * data is transferred, the callback function is called.
AnnaBridge 143:86740a56073b 1129 *
AnnaBridge 143:86740a56073b 1130 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1131 * @param handle Pointer to the dspi_slave_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1132 * @param transfer Pointer to the dspi_transfer_t structure.
AnnaBridge 143:86740a56073b 1133 * @return status of status_t.
AnnaBridge 143:86740a56073b 1134 */
AnnaBridge 143:86740a56073b 1135 status_t DSPI_SlaveTransferNonBlocking(SPI_Type *base, dspi_slave_handle_t *handle, dspi_transfer_t *transfer);
AnnaBridge 143:86740a56073b 1136
AnnaBridge 143:86740a56073b 1137 /*!
AnnaBridge 143:86740a56073b 1138 * @brief Gets the slave transfer count.
AnnaBridge 143:86740a56073b 1139 *
AnnaBridge 143:86740a56073b 1140 * This function gets the slave transfer count.
AnnaBridge 143:86740a56073b 1141 *
AnnaBridge 143:86740a56073b 1142 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1143 * @param handle Pointer to the dspi_master_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1144 * @param count The number of bytes transferred by using the non-blocking transaction.
AnnaBridge 143:86740a56073b 1145 * @return status of status_t.
AnnaBridge 143:86740a56073b 1146 */
AnnaBridge 143:86740a56073b 1147 status_t DSPI_SlaveTransferGetCount(SPI_Type *base, dspi_slave_handle_t *handle, size_t *count);
AnnaBridge 143:86740a56073b 1148
AnnaBridge 143:86740a56073b 1149 /*!
AnnaBridge 143:86740a56073b 1150 * @brief DSPI slave aborts a transfer using an interrupt.
AnnaBridge 143:86740a56073b 1151 *
AnnaBridge 143:86740a56073b 1152 * This function aborts a transfer using an interrupt.
AnnaBridge 143:86740a56073b 1153 *
AnnaBridge 143:86740a56073b 1154 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1155 * @param handle Pointer to the dspi_slave_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1156 */
AnnaBridge 143:86740a56073b 1157 void DSPI_SlaveTransferAbort(SPI_Type *base, dspi_slave_handle_t *handle);
AnnaBridge 143:86740a56073b 1158
AnnaBridge 143:86740a56073b 1159 /*!
AnnaBridge 143:86740a56073b 1160 * @brief DSPI Master IRQ handler function.
AnnaBridge 143:86740a56073b 1161 *
AnnaBridge 143:86740a56073b 1162 * This function processes the DSPI transmit and receive IRQ.
AnnaBridge 143:86740a56073b 1163 *
AnnaBridge 143:86740a56073b 1164 * @param base DSPI peripheral base address.
AnnaBridge 143:86740a56073b 1165 * @param handle Pointer to the dspi_slave_handle_t structure which stores the transfer state.
AnnaBridge 143:86740a56073b 1166 */
AnnaBridge 143:86740a56073b 1167 void DSPI_SlaveTransferHandleIRQ(SPI_Type *base, dspi_slave_handle_t *handle);
AnnaBridge 143:86740a56073b 1168
AnnaBridge 143:86740a56073b 1169 /*!
AnnaBridge 143:86740a56073b 1170 *@}
AnnaBridge 143:86740a56073b 1171 */
AnnaBridge 143:86740a56073b 1172
AnnaBridge 143:86740a56073b 1173 #if defined(__cplusplus)
AnnaBridge 143:86740a56073b 1174 }
AnnaBridge 143:86740a56073b 1175 #endif /*_cplusplus*/
AnnaBridge 143:86740a56073b 1176 /*!
AnnaBridge 143:86740a56073b 1177 *@}
AnnaBridge 143:86740a56073b 1178 */
AnnaBridge 143:86740a56073b 1179
AnnaBridge 143:86740a56073b 1180 #endif /*_FSL_DSPI_H_*/