| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_spi_hal.h
Go to the documentation of this file.
1 /*!
2 ********************************************************************************
3 * File: fsl_spi_hal.h
4 *
5 * Copyright (c) 2014, Freescale Semiconductor, Inc.
6 *
7 *******************************************************************************/
8 /*!
9 * @file fsl_spi_hal.h
10 * @brief \b fsl_spi_hal.h defines structures and types for the spi master HAL layer.
11 */
12 #ifndef FSL_SPI_HAL_H_
13 #define FSL_SPI_HAL_H_
14 #include "isf_types.h"
15 #include <stdbool.h>
16 //#include "fsl_spi_features.h"
17 //#include "fsl_device_registers.h"
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include <assert.h>
21
22 /*! @addtogroup spi_hal*/
23 /*! @{*/
24
25 /*! @file*/
26
27 /*******************************************************************************
28 * Definitions
29 ******************************************************************************/
30
31 /*! @brief Error codes for the SPI driver.*/
32 typedef enum _spi_errors
33 {
34 kStatus_SPI_Success = 0,
35 kStatus_SPI_SlaveTxUnderrun, /*!< SPI Slave TX Underrun error.*/
36 kStatus_SPI_SlaveRxOverrun, /*!< SPI Slave RX Overrun error.*/
37 kStatus_SPI_Timeout, /*!< SPI tranfser timed out.*/
38 kStatus_SPI_Busy, /*!< SPI instance is already busy performing a transfer.*/
39 kStatus_SPI_NoTransferInProgress, /*!< Attempt to abort a transfer when no transfer was in progress.*/
40 kStatus_SPI_Error, /*!< SPI Error.*/
41 } spi_status_t;
42
43 /*! @brief SPI master or slave configuration.*/
44 typedef enum _spi_master_slave_mode {
45 kSpiMaster = 1, /*!< SPI peripheral operates in master mode.*/
46 kSpiSlave = 0 /*!< SPI peripheral operates in slave mode.*/
47 } spi_master_slave_mode_t;
48
49 /*! @brief SPI clock polarity configuration.*/
50 typedef enum _spi_clock_polarity {
51 kSpiClockPolarity_ActiveHigh = 0, /*!< Active-high SPI clock (idles low).*/
52 kSpiClockPolarity_ActiveLow = 1 /*!< Active-low SPI clock (idles high).*/
53 } spi_clock_polarity_t;
54
55 /*! @brief SPI clock phase configuration.*/
56 typedef enum _spi_clock_phase {
57 kSpiClockPhase_FirstEdge = 0, /*!< First edge on SPSCK occurs at the middle of the first cycle of a data transfer.*/
58 kSpiClockPhase_SecondEdge = 1 /*!< First edge on SPSCK occurs at the start of the first cycle of a data transfer.*/
59 } spi_clock_phase_t;
60
61 /*! @brief SPI data shifter direction options.*/
62 typedef enum _spi_shift_direction {
63 kSpiMsbFirst = 0, /*!< Data transfers start with most significant bit.*/
64 kSpiLsbFirst = 1 /*!< Data transfers start with least significant bit.*/
65 } spi_shift_direction_t;
66
67 /*! @brief SPI slave select output mode options.*/
68 typedef enum _spi_ss_output_mode {
69 kSpiSlaveSelect_AsGpio = 0, /*!< Slave select pin configured as GPIO.*/
70 kSpiSlaveSelect_FaultInput = 2, /*!< Slave select pin configured for fault detection.*/
71 kSpiSlaveSelect_AutomaticOutput = 3 /*!< Slave select pin configured for automatic SPI output.*/
72 } spi_ss_output_mode_t;
73
74 /*! @brief SPI pin mode options.*/
75 typedef enum _spi_pin_mode {
76 kSpiPinMode_Normal = 0, /*!< Pins operate in normal, single-direction mode.*/
77 kSpiPinMode_Input = 1, /*!< Bidirectional mode. Master: MOSI pin is input; Slave: MISO pin is input*/
78 kSpiPinMode_Output = 3 /*!< Bidirectional mode. Master: MOSI pin is output; Slave: MISO pin is output*/
79 } spi_pin_mode_t;
80
81 /*! @brief SPI hardware configuration settings.*/
82 /*!*/
83 /*! Use an instance of this struct with spi_hal_init(). This allows you to configure the*/
84 /*! most common settings of the SPI peripheral with a single function call.*/
85 /*!*/
86 /*! The @c kbitsPerSec member is handled specially. If this value is set to 0, then the baud is*/
87 /*! not set by spi_hal_init(), and must be set with a separate call to either spi_hal_set_baud()*/
88 /*! or spi_hal_set_baud_divisors(). This can be useful if you know the divisors in advance and*/
89 /*! don't want to spend the time to compute them for the provided rate in kilobits/sec.*/
90 typedef struct SpiConfig {
91 uint32_t kbitsPerSec; /*!< @brief Baud rate in kilobits per second.*/
92 spi_master_slave_mode_t masterOrSlave; /*!< Whether to put the peripheral in master or slave mode.*/
93 spi_clock_polarity_t polarity; /*!< Clock polarity setting.*/
94 spi_clock_phase_t phase; /*!< Clock phase setting.*/
95 spi_shift_direction_t shiftDirection; /*!< Direction in which data is shifted out.*/
96 spi_ss_output_mode_t ssOutputMode; /*!< Output mode for the slave select signal.*/
97 spi_pin_mode_t pinMode; /*!< Pin mode with bidirectional option.*/
98
99 } spi_config_t;
100
101 /*! @}*/
102
103
104 #endif /* FSL_SPI_HAL_H_ */
105
106
spi_status_t
enum _spi_errors spi_status_t
Error codes for the SPI driver.
kSpiPinMode_Input
Definition: fsl_spi_hal.h:77
kSpiClockPhase_FirstEdge
Definition: fsl_spi_hal.h:57
_spi_master_slave_mode
_spi_master_slave_mode
SPI master or slave configuration.
Definition: fsl_spi_hal.h:44
SpiConfig::pinMode
spi_pin_mode_t pinMode
Definition: fsl_spi_hal.h:97
kStatus_SPI_Timeout
Definition: fsl_spi_hal.h:37
kStatus_SPI_SlaveTxUnderrun
Definition: fsl_spi_hal.h:35
kSpiPinMode_Output
Definition: fsl_spi_hal.h:78
kSpiPinMode_Normal
Definition: fsl_spi_hal.h:76
kStatus_SPI_NoTransferInProgress
Definition: fsl_spi_hal.h:39
kStatus_SPI_SlaveRxOverrun
Definition: fsl_spi_hal.h:36
kSpiLsbFirst
Definition: fsl_spi_hal.h:64
spi_pin_mode_t
enum _spi_pin_mode spi_pin_mode_t
SPI pin mode options.
kSpiClockPhase_SecondEdge
Definition: fsl_spi_hal.h:58
kStatus_SPI_Success
Definition: fsl_spi_hal.h:34
spi_shift_direction_t
enum _spi_shift_direction spi_shift_direction_t
SPI data shifter direction options.
SpiConfig::polarity
spi_clock_polarity_t polarity
Definition: fsl_spi_hal.h:93
kSpiClockPolarity_ActiveHigh
Definition: fsl_spi_hal.h:51
kSpiMsbFirst
Definition: fsl_spi_hal.h:63
isf_types.h
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
spi_config_t
struct SpiConfig spi_config_t
SPI hardware configuration settings.
_spi_shift_direction
_spi_shift_direction
SPI data shifter direction options.
Definition: fsl_spi_hal.h:62
spi_master_slave_mode_t
enum _spi_master_slave_mode spi_master_slave_mode_t
SPI master or slave configuration.
_spi_pin_mode
_spi_pin_mode
SPI pin mode options.
Definition: fsl_spi_hal.h:75
_spi_ss_output_mode
_spi_ss_output_mode
SPI slave select output mode options.
Definition: fsl_spi_hal.h:68
kStatus_SPI_Error
Definition: fsl_spi_hal.h:40
kSpiSlave
Definition: fsl_spi_hal.h:46
_spi_clock_phase
_spi_clock_phase
SPI clock phase configuration.
Definition: fsl_spi_hal.h:56
SpiConfig
SPI hardware configuration settings.
Definition: fsl_spi_hal.h:90
spi_clock_phase_t
enum _spi_clock_phase spi_clock_phase_t
SPI clock phase configuration.
kSpiClockPolarity_ActiveLow
Definition: fsl_spi_hal.h:52
spi_clock_polarity_t
enum _spi_clock_polarity spi_clock_polarity_t
SPI clock polarity configuration.
kStatus_SPI_Busy
Definition: fsl_spi_hal.h:38
_spi_errors
_spi_errors
Error codes for the SPI driver.
Definition: fsl_spi_hal.h:32
spi_ss_output_mode_t
enum _spi_ss_output_mode spi_ss_output_mode_t
SPI slave select output mode options.
kSpiMaster
Definition: fsl_spi_hal.h:45
kSpiSlaveSelect_AutomaticOutput
Definition: fsl_spi_hal.h:71
kSpiSlaveSelect_FaultInput
Definition: fsl_spi_hal.h:70
SpiConfig::phase
spi_clock_phase_t phase
Definition: fsl_spi_hal.h:94
kSpiSlaveSelect_AsGpio
Definition: fsl_spi_hal.h:69
SpiConfig::shiftDirection
spi_shift_direction_t shiftDirection
Definition: fsl_spi_hal.h:95
SpiConfig::kbitsPerSec
uint32_t kbitsPerSec
Baud rate in kilobits per second.
Definition: fsl_spi_hal.h:91
SpiConfig::masterOrSlave
spi_master_slave_mode_t masterOrSlave
Definition: fsl_spi_hal.h:92
_spi_clock_polarity
_spi_clock_polarity
SPI clock polarity configuration.
Definition: fsl_spi_hal.h:50
SpiConfig::ssOutputMode
spi_ss_output_mode_t ssOutputMode
Definition: fsl_spi_hal.h:96
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.