diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/LPC/LPC214x/hal_spi_lld.h')
-rw-r--r-- | lib/chibios/os/hal/ports/LPC/LPC214x/hal_spi_lld.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/LPC/LPC214x/hal_spi_lld.h b/lib/chibios/os/hal/ports/LPC/LPC214x/hal_spi_lld.h new file mode 100644 index 000000000..b108a540f --- /dev/null +++ b/lib/chibios/os/hal/ports/LPC/LPC214x/hal_spi_lld.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file LPC214x/hal_spi_lld.h | ||
19 | * @brief LPC214x low level SPI driver header. | ||
20 | * | ||
21 | * @addtogroup SPI | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | #ifndef HAL_SPI_LLD_H | ||
26 | #define HAL_SPI_LLD_H | ||
27 | |||
28 | #if HAL_USE_SPI || defined(__DOXYGEN__) | ||
29 | |||
30 | /*===========================================================================*/ | ||
31 | /* Driver constants. */ | ||
32 | /*===========================================================================*/ | ||
33 | |||
34 | /** | ||
35 | * @brief Circular mode support flag. | ||
36 | */ | ||
37 | #define SPI_SUPPORTS_CIRCULAR FALSE | ||
38 | |||
39 | /** | ||
40 | * @brief Hardware FIFO depth. | ||
41 | */ | ||
42 | #define LPC214x_SSP_FIFO_DEPTH 8 | ||
43 | |||
44 | /*===========================================================================*/ | ||
45 | /* Driver pre-compile time settings. */ | ||
46 | /*===========================================================================*/ | ||
47 | |||
48 | /** | ||
49 | * @brief SPI1 driver enable switch. | ||
50 | * @details If set to @p TRUE the support for SSP is included. | ||
51 | * @note The default is @p TRUE. | ||
52 | */ | ||
53 | #if !defined(LPC214x_SPI_USE_SSP) || defined(__DOXYGEN__) | ||
54 | #define LPC214x_SPI_USE_SSP TRUE | ||
55 | #endif | ||
56 | |||
57 | /** | ||
58 | * @brief SSP interrupt priority level setting. | ||
59 | */ | ||
60 | #if !defined(LPC214x_SPI_SSP_IRQ_PRIORITY) || defined(__DOXYGEN__) | ||
61 | #define LPC214x_SPI_SSP_IRQ_PRIORITY 4 | ||
62 | #endif | ||
63 | |||
64 | /** | ||
65 | * @brief Overflow error hook. | ||
66 | * @details The default action is to stop the system. | ||
67 | */ | ||
68 | #if !defined(LPC214x_SPI_SSP_ERROR_HOOK) || defined(__DOXYGEN__) | ||
69 | #define LPC214x_SPI_SSP_ERROR_HOOK() osalSysHalt("overflow") | ||
70 | #endif | ||
71 | |||
72 | /*===========================================================================*/ | ||
73 | /* Derived constants and error checks. */ | ||
74 | /*===========================================================================*/ | ||
75 | |||
76 | #if !LPC214x_SPI_USE_SSP | ||
77 | #error "SPI driver activated but no SPI peripheral assigned" | ||
78 | #endif | ||
79 | |||
80 | /*===========================================================================*/ | ||
81 | /* Driver data structures and types. */ | ||
82 | /*===========================================================================*/ | ||
83 | |||
84 | /*===========================================================================*/ | ||
85 | /* Driver macros. */ | ||
86 | /*===========================================================================*/ | ||
87 | |||
88 | /** | ||
89 | * @brief Low level fields of the SPI driver structure. | ||
90 | */ | ||
91 | #define spi_lld_driver_fields \ | ||
92 | /* Pointer to the SSP registers block.*/ \ | ||
93 | SSP *ssp; \ | ||
94 | /* Number of bytes yet to be received.*/ \ | ||
95 | uint32_t rxcnt; \ | ||
96 | /* Receive pointer or @p NULL.*/ \ | ||
97 | void *rxptr; \ | ||
98 | /* Number of bytes yet to be transmitted.*/ \ | ||
99 | uint32_t txcnt; \ | ||
100 | /* Transmit pointer or @p NULL.*/ \ | ||
101 | const void *txptr | ||
102 | |||
103 | /** | ||
104 | * @brief Low level fields of the SPI configuration structure. | ||
105 | */ | ||
106 | #define spi_lld_config_fields \ | ||
107 | /* SSP CR0 initialization data.*/ \ | ||
108 | uint16_t cr0; \ | ||
109 | /* SSP CPSR initialization data.*/ \ | ||
110 | uint32_t cpsr | ||
111 | |||
112 | /*===========================================================================*/ | ||
113 | /* External declarations. */ | ||
114 | /*===========================================================================*/ | ||
115 | |||
116 | #if LPC214x_SPI_USE_SSP && !defined(__DOXYGEN__) | ||
117 | extern SPIDriver SPID1; | ||
118 | #endif | ||
119 | |||
120 | #ifdef __cplusplus | ||
121 | extern "C" { | ||
122 | #endif | ||
123 | void spi_lld_init(void); | ||
124 | void spi_lld_start(SPIDriver *spip); | ||
125 | void spi_lld_stop(SPIDriver *spip); | ||
126 | void spi_lld_select(SPIDriver *spip); | ||
127 | void spi_lld_unselect(SPIDriver *spip); | ||
128 | void spi_lld_ignore(SPIDriver *spip, size_t n); | ||
129 | void spi_lld_exchange(SPIDriver *spip, size_t n, | ||
130 | const void *txbuf, void *rxbuf); | ||
131 | void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf); | ||
132 | void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf); | ||
133 | uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame); | ||
134 | #ifdef __cplusplus | ||
135 | } | ||
136 | #endif | ||
137 | |||
138 | #endif /* HAL_USE_SPI */ | ||
139 | |||
140 | #endif /* HAL_SPI_LLD_H */ | ||
141 | |||
142 | /** @} */ | ||