Mercurial > public > ostc4
annotate Small_CPU/Src/spi.c @ 138:cc9c18075e00 FlipDisplay
Removed no longer supported scooter code
author | Ideenmodellierer |
---|---|
date | Sat, 23 Feb 2019 21:10:51 +0100 |
parents | 6ae8ba5683d6 |
children | 466c8d9c5e43 |
rev | line source |
---|---|
38 | 1 /** |
89 | 2 ****************************************************************************** |
3 * @file spi.c | |
4 * @author heinrichs weikamp gmbh | |
5 * @version V0.0.1 | |
6 * @date 16-Sept-2014 | |
7 * @brief Source code for spi control | |
8 * | |
9 @verbatim | |
10 ============================================================================== | |
11 ##### How to use ##### | |
12 ============================================================================== | |
13 @endverbatim | |
14 ****************************************************************************** | |
15 * @attention | |
16 * | |
17 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
18 * | |
19 ****************************************************************************** | |
20 */ | |
38 | 21 |
22 /* Includes ------------------------------------------------------------------*/ | |
23 #include "spi.h" | |
120 | 24 #include "dma.h" |
38 | 25 //#include "gpio.h" |
26 | |
27 /* USER CODE BEGIN 0 */ | |
28 #include "scheduler.h" | |
29 | |
120 | 30 #ifdef DEBUG_GPIO |
38 | 31 extern void GPIO_new_DEBUG_LOW(void); |
32 extern void GPIO_new_DEBUG_HIGH(void); | |
120 | 33 #endif |
38 | 34 |
89 | 35 uint8_t data_error = 0; |
36 uint32_t data_error_time = 0; | |
38 | 37 |
38 static void SPI_Error_Handler(void); | |
39 | |
40 /* USER CODE END 0 */ | |
41 | |
42 static uint8_t SPI_check_header_and_footer_ok(void); | |
43 | |
44 SPI_HandleTypeDef hspi1; | |
45 SPI_HandleTypeDef hspi3; | |
46 | |
47 DMA_HandleTypeDef hdma_tx; | |
48 DMA_HandleTypeDef hdma_rx; | |
49 | |
50 // SPI3 init function | |
89 | 51 void MX_SPI3_Init(void) { |
52 hspi3.Instance = SPI3; | |
53 hspi3.Init.Mode = SPI_MODE_MASTER; | |
54 hspi3.Init.Direction = SPI_DIRECTION_2LINES; | |
55 hspi3.Init.DataSize = SPI_DATASIZE_8BIT; | |
56 hspi3.Init.CLKPolarity = SPI_POLARITY_HIGH; | |
57 hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; | |
58 hspi3.Init.NSS = SPI_NSS_SOFT; | |
59 hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; | |
60 hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; | |
61 hspi3.Init.TIMode = SPI_TIMODE_DISABLED; | |
62 hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; | |
63 hspi3.Init.CRCPolynomial = 7; | |
64 HAL_SPI_Init(&hspi3); | |
38 | 65 } |
66 | |
89 | 67 void MX_SPI3_DeInit(void) { |
68 HAL_SPI_DeInit(&hspi3); | |
38 | 69 } |
70 | |
89 | 71 uint8_t SPI3_ButtonAdjust(uint8_t *arrayInput, uint8_t *arrayOutput) { |
38 | 72 HAL_StatusTypeDef status; |
73 uint8_t answer[10]; | |
74 uint8_t rework[10]; | |
75 | |
76 rework[0] = 0xFF; | |
89 | 77 for (int i = 0; i < 3; i++) { |
38 | 78 // limiter |
89 | 79 if (arrayInput[i] == 0xFF) |
38 | 80 arrayInput[i] = 0xFE; |
89 | 81 if (arrayInput[i] >= 15) { |
82 | 82 // copy - ausl�se-schwelle |
89 | 83 rework[i + 1] = arrayInput[i]; |
38 | 84 // wieder-scharf-schalte-schwelle |
89 | 85 rework[i + 3 + 1] = arrayInput[i] - 10; |
86 } else if (arrayInput[i] >= 10) { | |
82 | 87 // copy - ausl�se-schwelle |
89 | 88 rework[i + 1] = arrayInput[i]; |
38 | 89 // wieder-scharf-schalte-schwelle |
89 | 90 rework[i + 3 + 1] = arrayInput[i] - 5; |
91 } else { | |
82 | 92 // copy - ausl�se-schwelle |
89 | 93 rework[i + 1] = 7; |
38 | 94 // wieder-scharf-schalte-schwelle |
89 | 95 rework[i + 3 + 1] = 6; |
38 | 96 } |
97 } | |
98 | |
99 status = HAL_OK; /* = 0 */ | |
89 | 100 HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET); |
101 for (int i = 0; i < 7; i++) { | |
102 HAL_Delay(10); | |
103 HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_RESET); | |
63 | 104 HAL_Delay(10); |
89 | 105 status += HAL_SPI_TransmitReceive(&hspi3, &rework[i], &answer[i], 1, |
106 20); | |
63 | 107 HAL_Delay(10); |
89 | 108 HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET); |
38 | 109 } |
89 | 110 |
111 if (status == HAL_OK) { | |
112 for (int i = 0; i < 3; i++) { | |
113 arrayOutput[i] = answer[i + 2]; // first not, return of 0xFF not | |
114 } | |
38 | 115 return 1; |
89 | 116 } else |
117 | |
38 | 118 return 0; |
119 } | |
120 | |
121 // SPI5 init function | |
89 | 122 void MX_SPI1_Init(void) { |
123 hspi1.Instance = SPI1; | |
124 hspi1.Init.Mode = SPI_MODE_SLAVE; | |
125 hspi1.Init.Direction = SPI_DIRECTION_2LINES; | |
126 hspi1.Init.DataSize = SPI_DATASIZE_8BIT; | |
127 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; | |
128 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; | |
129 hspi1.Init.NSS = SPI_NSS_HARD_INPUT; //SPI_NSS_SOFT; | |
104 | 130 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; |
89 | 131 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; |
132 hspi1.Init.TIMode = SPI_TIMODE_DISABLED; | |
133 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; //_DISABLED; _ENABLED; | |
134 hspi1.Init.CRCPolynomial = 7; | |
135 HAL_SPI_Init(&hspi1); | |
38 | 136 } |
137 | |
89 | 138 void MX_SPI_DeInit(void) { |
139 HAL_SPI_DeInit(&hspi1); | |
38 | 140 } |
141 | |
89 | 142 void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { |
38 | 143 |
89 | 144 GPIO_InitTypeDef GPIO_InitStruct; |
38 | 145 |
89 | 146 if (hspi->Instance == SPI1) { |
147 // Peripheral clock enable | |
148 __SPI1_CLK_ENABLE(); | |
149 __GPIOA_CLK_ENABLE(); | |
38 | 150 //SPI1 GPIO Configuration |
151 //PA4 ------> SPI1_CS | |
152 //PA5 ------> SPI1_SCK | |
153 //PA6 ------> SPI1_MISO | |
154 //PA7 ------> SPI1_MOSI | |
89 | 155 |
156 GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; | |
38 | 157 // GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; |
89 | 158 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
159 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
124
4b355396557a
Change GPIO speed for SPI communication as recommended by STM32 Errata
Ideenmodellierer
parents:
120
diff
changeset
|
160 GPIO_InitStruct.Speed = GPIO_SPEED_FAST; /* Decision is based on errata which recommends FAST for GPIO at 90Mhz */ |
89 | 161 GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
162 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | |
38 | 163 |
164 //##-3- Configure the DMA streams ########################################## | |
165 // Configure the DMA handler for Transmission process | |
89 | 166 hdma_tx.Instance = DMA2_Stream3; |
167 hdma_tx.Init.Channel = DMA_CHANNEL_3; | |
168 hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; | |
169 hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE; | |
170 hdma_tx.Init.MemInc = DMA_MINC_ENABLE; | |
38 | 171 hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; |
89 | 172 hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; |
173 hdma_tx.Init.Mode = DMA_NORMAL; | |
174 hdma_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; | |
175 hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; | |
176 hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; | |
177 hdma_tx.Init.MemBurst = DMA_MBURST_INC4; | |
178 hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4; | |
179 | |
180 HAL_DMA_Init(&hdma_tx); | |
181 | |
38 | 182 // Associate the initialized DMA handle to the the SPI handle |
183 __HAL_LINKDMA(hspi, hdmatx, hdma_tx); | |
89 | 184 |
38 | 185 // Configure the DMA handler for Transmission process |
89 | 186 hdma_rx.Instance = DMA2_Stream0; |
187 hdma_rx.Init.Channel = DMA_CHANNEL_3; | |
188 hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; | |
189 hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE; | |
190 hdma_rx.Init.MemInc = DMA_MINC_ENABLE; | |
38 | 191 hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; |
89 | 192 hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; |
193 hdma_rx.Init.Mode = DMA_NORMAL; | |
194 hdma_rx.Init.Priority = DMA_PRIORITY_HIGH; | |
195 hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; | |
196 hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; | |
197 hdma_rx.Init.MemBurst = DMA_MBURST_INC4; | |
198 hdma_rx.Init.PeriphBurst = DMA_PBURST_INC4; | |
38 | 199 |
200 HAL_DMA_Init(&hdma_rx); | |
89 | 201 |
202 // Associate the initialized DMA handle to the the SPI handle | |
203 __HAL_LINKDMA(hspi, hdmarx, hdma_rx); | |
38 | 204 |
89 | 205 //##-4- Configure the NVIC for DMA ######################################### |
206 //NVIC configuration for DMA transfer complete interrupt (SPI3_RX) | |
207 HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 1, 0); | |
208 HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); | |
209 | |
210 // NVIC configuration for DMA transfer complete interrupt (SPI1_TX) | |
211 HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 1, 1); | |
212 HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); | |
213 } else if (hspi->Instance == SPI3) { | |
214 __GPIOC_CLK_ENABLE(); | |
215 __SPI3_CLK_ENABLE(); | |
38 | 216 |
217 //SPI1 GPIO Configuration | |
218 //PC10 ------> SPI3_SCK | |
219 //PC11 ------> SPI3_MISO | |
220 //PC12 ------> SPI3_MOSI | |
221 //PA15 ------> SPI3_NSS (official) | |
222 //PC9 ------> SPI3_NSS (hw) | |
89 | 223 |
224 GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; | |
225 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
226 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
227 GPIO_InitStruct.Speed = GPIO_SPEED_FAST; | |
228 GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | |
229 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | |
38 | 230 |
231 GPIO_InitStruct.Pin = GPIO_PIN_9; | |
232 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
233 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
234 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
89 | 235 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
38 | 236 |
89 | 237 HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET); |
38 | 238 } |
239 } | |
240 | |
89 | 241 void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { |
242 if (hspi->Instance == SPI1) { | |
38 | 243 __SPI1_FORCE_RESET(); |
244 __SPI1_RELEASE_RESET(); | |
245 | |
246 //SPI1 GPIO Configuration | |
247 //PA5 ------> SPI1_SCK | |
248 //PA6 ------> SPI1_MISO | |
249 //PA7 ------> SPI1_MOSI | |
89 | 250 |
251 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); | |
38 | 252 |
253 HAL_DMA_DeInit(&hdma_tx); | |
254 HAL_DMA_DeInit(&hdma_rx); | |
89 | 255 |
38 | 256 HAL_NVIC_DisableIRQ(DMA2_Stream3_IRQn); |
257 HAL_NVIC_DisableIRQ(DMA2_Stream0_IRQn); | |
89 | 258 } else if (hspi->Instance == SPI3) { |
38 | 259 __SPI3_FORCE_RESET(); |
260 __SPI3_RELEASE_RESET(); | |
261 | |
262 //SPI1 GPIO Configuration | |
263 //PC10 ------> SPI3_SCK | |
264 //PC11 ------> SPI3_MISO | |
265 //PC12 ------> SPI3_MOSI | |
266 //PA15 ------> SPI3_NSS (official) | |
267 //PC9 ------> SPI3_NSS (hw) | |
89 | 268 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12); |
38 | 269 } |
270 } | |
271 | |
89 | 272 void SPI_synchronize_with_Master(void) { |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
273 GPIO_InitTypeDef GPIO_InitStruct; |
89 | 274 // |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
275 #if 0 |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
276 __GPIOA_CLK_ENABLE(); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
277 /**SPI1 GPIO Configuration |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
278 PA5 ------> SPI1_SCK |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
279 */ |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
280 GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
281 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
282 GPIO_InitStruct.Pull = GPIO_PULLUP; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
283 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
284 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
89 | 285 // |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
286 HAL_Delay(10); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
287 while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4) == 0); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
288 HAL_Delay(10); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
289 while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_5) == 1); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
290 HAL_Delay(20); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
291 #endif |
38 | 292 } |
293 | |
89 | 294 void SPI_Start_single_TxRx_with_Master(void) { |
38 | 295 uint8_t * pOutput; |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
296 HAL_StatusTypeDef retval; |
38 | 297 |
89 | 298 if (global.dataSendToSlave.getDeviceDataNow) { |
38 | 299 global.dataSendToSlave.getDeviceDataNow = 0; |
89 | 300 pOutput = (uint8_t*) &(global.deviceDataSendToMaster); |
301 } else { | |
302 pOutput = (uint8_t*) &(global.dataSendToMaster); | |
38 | 303 } |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
304 retval = HAL_SPI_TransmitReceive_DMA(&hspi1, pOutput,(uint8_t*) &(global.dataSendToSlave), EXCHANGE_BUFFERSIZE); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
305 if ( retval!= HAL_OK) { |
38 | 306 SPI_Error_Handler(); |
307 } | |
308 } | |
309 | |
89 | 310 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) { |
311 /* restart SPI */ | |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
312 if (hspi == &hspi1) |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
313 { |
89 | 314 global.check_sync_not_running = 0; |
315 /* stop data exchange? */ | |
316 if (global.mode == MODE_SHUTDOWN) { | |
317 global.mode = MODE_SLEEP; | |
318 global.dataSendToSlavePending = 0; | |
319 global.dataSendToSlaveIsValid = 1; | |
320 global.dataSendToSlaveIsNotValidCount = 0; | |
321 return; | |
322 } | |
82 | 323 |
89 | 324 /* data consistent? */ |
325 if (SPI_check_header_and_footer_ok()) { | |
326 // GPIO_new_DEBUG_HIGH(); //For debug. | |
327 global.dataSendToSlaveIsValid = 1; | |
328 global.dataSendToSlaveIsNotValidCount = 0; | |
329 } else { | |
330 // GPIO_new_DEBUG_LOW(); //For debug. | |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
331 global.dataSendToSlaveIsValid = 0; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
332 global.dataSendToSlaveIsNotValidCount++; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
333 HAL_SPI_Abort_IT(&hspi1); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
334 global.dataSendToSlaveIsNotValidCount = 1; |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
335 } |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
336 } |
89 | 337 global.dataSendToMaster.power_on_reset = 0; |
338 global.deviceDataSendToMaster.power_on_reset = 0; | |
339 | |
104 | 340 //TODO:REMOVE |
89 | 341 // if ( !global.dataSendToSlaveStopEval ) { |
342 // scheduleSpecial_Evaluate_DataSendToSlave(); | |
343 // } | |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
344 scheduleSpecial_Evaluate_DataSendToSlave(); |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
345 |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
346 SPI_Start_single_TxRx_with_Master(); //Send data always. |
38 | 347 } |
348 | |
136
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
349 |
6ae8ba5683d6
Introduces abort of communication in case of a out of sync DMA transfer
Ideenmodellierer
parents:
124
diff
changeset
|
350 |
89 | 351 static uint8_t SPI_check_header_and_footer_ok(void) { |
352 if (global.dataSendToSlave.header.checkCode[0] != 0xBB) | |
38 | 353 return 0; |
89 | 354 if (global.dataSendToSlave.header.checkCode[1] != 0x01) |
38 | 355 return 0; |
89 | 356 if (global.dataSendToSlave.header.checkCode[2] != 0x01) |
38 | 357 return 0; |
89 | 358 if (global.dataSendToSlave.header.checkCode[3] != 0xBB) |
38 | 359 return 0; |
89 | 360 if (global.dataSendToSlave.footer.checkCode[0] != 0xF4) |
38 | 361 return 0; |
89 | 362 if (global.dataSendToSlave.footer.checkCode[1] != 0xF3) |
38 | 363 return 0; |
89 | 364 if (global.dataSendToSlave.footer.checkCode[2] != 0xF2) |
38 | 365 return 0; |
89 | 366 if (global.dataSendToSlave.footer.checkCode[3] != 0xF1) |
38 | 367 return 0; |
368 | |
369 return 1; | |
370 } | |
371 | |
89 | 372 static void SPI_Error_Handler(void) { |
82 | 373 //The device is locks. Hard to recover. |
374 // while(1) | |
375 // { | |
376 // } | |
38 | 377 } |
378 | |
379 /** | |
89 | 380 * @} |
381 */ | |
38 | 382 |
383 /** | |
89 | 384 * @} |
385 */ | |
38 | 386 |
387 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |