H753_CPP_SPI_BT817_EVE_02 1.0
STM32H753 draws its own touch screens on a Bridgetek BT817 (ME817EV + DP-0701-01A) over SPI with the STM32_Bridgetek_EVE_API library: a two-page widget tour
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
18/* USER CODE END Header */
19/* Includes ------------------------------------------------------------------*/
20#include "main.h"
21
22/* Private includes ----------------------------------------------------------*/
23/* USER CODE BEGIN Includes */
24#include <stdio.h>
25#include <string.h>
26#include <stdbool.h>
27
28#include "widgetTour.h"
29
30/* USER CODE END Includes */
31
32/* Private typedef -----------------------------------------------------------*/
33/* USER CODE BEGIN PTD */
34
35/* USER CODE END PTD */
36
37/* Private define ------------------------------------------------------------*/
38/* USER CODE BEGIN PD */
39
40/* USER CODE END PD */
41
42/* Private macro -------------------------------------------------------------*/
43/* USER CODE BEGIN PM */
44
45/* USER CODE END PM */
46
47/* Private variables ---------------------------------------------------------*/
48
49SPI_HandleTypeDef hspi1;
50
51UART_HandleTypeDef huart1;
52
53/* USER CODE BEGIN PV */
55static const bool runChipIdTest = true;
56
57/* USER CODE END PV */
58
59/* Private function prototypes -----------------------------------------------*/
60void SystemClock_Config(void);
61static void MX_GPIO_Init(void);
62static void MX_USART1_UART_Init(void);
63static void MX_SPI1_Init(void);
64/* USER CODE BEGIN PFP */
65
66/* USER CODE END PFP */
67
68/* Private user code ---------------------------------------------------------*/
69/* USER CODE BEGIN 0 */
70
71/*
72 * BT817 SPI chip-ID bring-up test.
73 * Addresses, values and timings: Bridgetek BT817/8 datasheet BRT_000302 v1.4
74 * (4.1.3 host memory read, 4.2.3 clock enable, 4.9.4 reset/boot, 5.1 REG_ID,
75 * 5.2 chip ID). Temporary: the real driver goes into its own plain-C library.
76 */
77#define EVE_REG_ID 0x302000UL
78#define EVE_REG_CPURESET 0x302020UL
79#define EVE_RAM_CHIPID 0x0C0000UL
80#define EVE_REG_ID_VALUE 0x7CU
81#define EVE_CMD_ACTIVE 0x00U
82#define EVE_CMD_CLKEXT 0x44U
83#define EVE_CMD_RST_PULSE 0x68U
84#define EVE_CMD_CLKSEL 0x61U
85#define EVE_CLKSEL_72MHZ 0x46U
86#define EVE_SPI_RETRIES 3U
87#define EVE_SPI_TIMEOUT_MS 10U
88#define EVE_BOOT_TIMEOUT_MS 300U
89#define EVE_ENGINE_TIMEOUT_MS 3000U
90#define EVE_MAX_READ_BYTES 4U
99static bool eveSpiIsTransient(HAL_StatusTypeDef status)
100{
101 if ((status == HAL_BUSY) || (status == HAL_TIMEOUT))
102 {
103 return true;
104 }
105 if (status == HAL_ERROR)
106 {
107 uint32_t spiError = HAL_SPI_GetError(&hspi1);
108 return (spiError & (HAL_SPI_ERROR_MODF | HAL_SPI_ERROR_CRC | HAL_SPI_ERROR_OVR |
109 HAL_SPI_ERROR_FRE | HAL_SPI_ERROR_DMA | HAL_SPI_ERROR_FLAG)) != 0U;
110 }
111 return false;
112}
113
124static void eveSpiTransaction(const uint8_t *tx, uint8_t *rx, uint16_t length)
125{
126 HAL_StatusTypeDef status = HAL_ERROR;
127
128 for (uint32_t attempt = 1U; attempt <= EVE_SPI_RETRIES; attempt++)
129 {
130 HAL_GPIO_WritePin(EVE_CS__GPIO_Port, EVE_CS__Pin, GPIO_PIN_RESET);
131 status = HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)tx, rx, length, EVE_SPI_TIMEOUT_MS);
132 HAL_GPIO_WritePin(EVE_CS__GPIO_Port, EVE_CS__Pin, GPIO_PIN_SET);
133
134 if (status == HAL_OK)
135 {
136 return;
137 }
138 printf("EVE SPI: attempt %lu of %u failed (HAL status %d, SPI error 0x%08lX)\r\n",
139 (unsigned long)attempt, EVE_SPI_RETRIES, (int)status,
140 (unsigned long)HAL_SPI_GetError(&hspi1));
141 if (!eveSpiIsTransient(status))
142 {
143 break;
144 }
145 }
146 printf("EVE SPI: giving up, the transfer did not complete.\r\n");
147 Error_Handler();
148}
149
156static void eveHostCommand(uint8_t command, uint8_t parameter)
157{
158 uint8_t tx[3] = { command, parameter, 0x00U };
159 uint8_t rx[3];
160
161 eveSpiTransaction(tx, rx, (uint16_t)sizeof(tx));
162}
163
172static void eveReadMemory(uint32_t address, uint8_t *data, uint16_t length)
173{
174 uint8_t tx[4U + EVE_MAX_READ_BYTES] = { 0 };
175 uint8_t rx[4U + EVE_MAX_READ_BYTES] = { 0 };
176
177 if ((data == NULL) || (length == 0U) || (length > EVE_MAX_READ_BYTES))
178 {
179 printf("eveReadMemory: bad argument (data %p, length %u)\r\n", (void *)data, length);
180 Error_Handler();
181 return;
182 }
183 tx[0] = (uint8_t)((address >> 16) & 0x3FU);
184 tx[1] = (uint8_t)(address >> 8);
185 tx[2] = (uint8_t)address;
186 /* tx[3] = dummy byte, then zeros while the data is clocked in */
187 eveSpiTransaction(tx, rx, (uint16_t)(4U + length));
188 memcpy(data, &rx[4], length);
189}
190
200static bool eveWaitForRegister(uint32_t address, uint8_t expected, uint32_t timeoutMs, uint8_t *lastValue)
201{
202 uint32_t start = HAL_GetTick();
203
204 do
205 {
206 eveReadMemory(address, lastValue, 1U);
207 if (*lastValue == expected)
208 {
209 return true;
210 }
211 HAL_Delay(1U);
212 } while ((HAL_GetTick() - start) < timeoutMs);
213
214 return false;
215}
216
221static void evePrintNoAnswerHelp(uint8_t misoValue)
222{
223 if ((misoValue == 0x00U) || (misoValue == 0xFFU))
224 {
225 printf(" MISO reads 0x%02X: nothing is answering on the SPI lines.\r\n", misoValue);
226 }
227 printf(" Check the wiring against the schematic (ME817EV CN8 to the Nucleo):\r\n");
228 printf(" CN8-1 SCK = PA5, CN8-2 CS# = PB6, CN8-3 MISO = PA6, CN8-4 MOSI = PB5,\r\n");
229 printf(" CN8-13 PD# = PD15, CN8-11/12 GND, plus a heavy ground between the boards.\r\n");
230 printf(" ME817EV: SW2 all OFF, JP1 on 1-2, USB-C power in CN11.\r\n");
231}
232
240static void eveChipIdTest(void)
241{
242 static const uint8_t expectedChipId[4] = { 0x08U, 0x17U, 0x01U, 0x00U };
243 uint8_t value = 0U;
244 uint8_t chipId[4] = { 0U };
245
246 printf("BT817 SPI chip-ID test (H753_CPP_SPI_BT817_EVE_02)\r\n");
247
248 /* 1. Hardware reset: PD# low (MX_GPIO_Init() already starts it low), >= 5 ms (4.9.4) */
249 HAL_GPIO_WritePin(EVE_PD__GPIO_Port, EVE_PD__Pin, GPIO_PIN_RESET);
250 HAL_Delay(20U);
251 HAL_GPIO_WritePin(EVE_PD__GPIO_Port, EVE_PD__Pin, GPIO_PIN_SET);
252 HAL_Delay(20U);
253
254 /* 2. Clock enable (4.2.3): CLKEXT, CLKSEL (72 MHz), RST_PULSE, then ACTIVE, the order
255 * Bridgetek's EVE_HAL.c uses (CLKEXT itself can trigger a system reset);
256 * wait >= 20 ms (4.9.3.5) */
261 HAL_Delay(20U);
262
263 /* 3. Boot takes up to 300 ms; only REG_ID and REG_CPURESET may be read (4.9.4) */
265 {
266 printf("FAIL: REG_ID reads 0x%02X, expected 0x%02X within %u ms.\r\n",
269 Error_Handler();
270 return;
271 }
272 printf("REG_ID = 0x%02X OK\r\n", value);
273
274 /* REG_CPURESET bits: 0 = coprocessor, 1 = touch engine, 2 = audio engine (AN_033) */
275 uint32_t engineStart = HAL_GetTick();
277 {
278 printf("FAIL: REG_CPURESET reads 0x%02X, expected 0x00 within %u ms"
279 " (bit0 coprocessor, bit1 touch, bit2 audio still in reset).\r\n",
280 value, EVE_ENGINE_TIMEOUT_MS);
281 Error_Handler();
282 return;
283 }
284 printf("REG_CPURESET = 0x%02X OK (after %lu ms)\r\n", value,
285 (unsigned long)(HAL_GetTick() - engineStart));
286
287 /* 4. Chip ID at 0C0000h (5.2) */
288 eveReadMemory(EVE_RAM_CHIPID, chipId, (uint16_t)sizeof(chipId));
289 printf("Chip ID = %02X %02X %02X %02X\r\n", chipId[0], chipId[1], chipId[2], chipId[3]);
290 if (memcmp(chipId, expectedChipId, sizeof(chipId)) != 0)
291 {
292 printf("FAIL: expected 08 17 01 00 (BT817). A BT818 reads 08 18 01 00.\r\n");
293 Error_Handler();
294 return;
295 }
296 printf("PASS: BT817 found over SPI.\r\n");
297}
298
299
300#ifdef REDIRECT_PRINTF
301#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
302
313PUTCHAR_PROTOTYPE
314{
315 static int previousChar = 0;
316 uint8_t carriageReturn = (uint8_t)'\r';
317
318 if ((ch == '\n') && (previousChar != '\r'))
319 {
320 HAL_UART_Transmit(&huart1, &carriageReturn, 1, 0xFFFF);
321 }
322 HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
323 previousChar = ch;
324
325 return ch;
326}
327#endif
328
329/* USER CODE END 0 */
330
335int main(void)
336{
337
338 /* USER CODE BEGIN 1 */
339
340 /* USER CODE END 1 */
341
342 /* MCU Configuration--------------------------------------------------------*/
343
344 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
345 HAL_Init();
346
347 /* USER CODE BEGIN Init */
348
349 /* USER CODE END Init */
350
351 /* Configure the system clock */
352 SystemClock_Config();
353
354 /* USER CODE BEGIN SysInit */
355
356 /* USER CODE END SysInit */
357
358 /* Initialize all configured peripherals */
359 MX_GPIO_Init();
360 MX_USART1_UART_Init();
361 MX_SPI1_Init();
362 /* USER CODE BEGIN 2 */
363
364 printf("\x1b[2J\x1b[H"); // Clear the dumb terminal screen
365
366 /* Start-up check: prints REG_ID, REG_CPURESET and the chip ID, stops on failure. */
367 if (runChipIdTest)
368 {
370 }
371
372 /* Part 3: our own screen, drawn in code with the EVE library. */
375
376 /* USER CODE END 2 */
377
378 /* Infinite loop */
379 /* USER CODE BEGIN WHILE */
380 while (1)
381 {
382 /* USER CODE END WHILE */
383
384 /* USER CODE BEGIN 3 */
385 }
386 /* USER CODE END 3 */
387}
388
393void SystemClock_Config(void)
394{
395 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
396 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
397
400 HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
401
404 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
405
406 while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
407
411 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
412 RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
413 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
414 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
415 RCC_OscInitStruct.PLL.PLLM = 1;
416 RCC_OscInitStruct.PLL.PLLN = 120;
417 RCC_OscInitStruct.PLL.PLLP = 2;
418 RCC_OscInitStruct.PLL.PLLQ = 5;
419 RCC_OscInitStruct.PLL.PLLR = 2;
420 RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
421 RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
422 RCC_OscInitStruct.PLL.PLLFRACN = 0;
423 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
424 {
425 Error_Handler();
426 }
427
430 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
431 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
432 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
433 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
434 RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
435 RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
436 RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
437 RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
438 RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
439 RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
440
441 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
442 {
443 Error_Handler();
444 }
445}
446
452static void MX_SPI1_Init(void)
453{
454
455 /* USER CODE BEGIN SPI1_Init 0 */
456
457 /* USER CODE END SPI1_Init 0 */
458
459 /* USER CODE BEGIN SPI1_Init 1 */
460
461 /* USER CODE END SPI1_Init 1 */
462 /* SPI1 parameter configuration*/
463 hspi1.Instance = SPI1;
464 hspi1.Init.Mode = SPI_MODE_MASTER;
465 hspi1.Init.Direction = SPI_DIRECTION_2LINES;
466 hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
467 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
468 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
469 hspi1.Init.NSS = SPI_NSS_SOFT;
470 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
471 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
472 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
473 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
474 hspi1.Init.CRCPolynomial = 0x0;
475 hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
476 hspi1.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
477 hspi1.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
478 hspi1.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
479 hspi1.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
480 hspi1.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
481 hspi1.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
482 hspi1.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
483 hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
484 hspi1.Init.IOSwap = SPI_IO_SWAP_DISABLE;
485 if (HAL_SPI_Init(&hspi1) != HAL_OK)
486 {
487 Error_Handler();
488 }
489 /* USER CODE BEGIN SPI1_Init 2 */
490
491 /* USER CODE END SPI1_Init 2 */
492
493}
494
500static void MX_USART1_UART_Init(void)
501{
502
503 /* USER CODE BEGIN USART1_Init 0 */
504
505 /* USER CODE END USART1_Init 0 */
506
507 /* USER CODE BEGIN USART1_Init 1 */
508
509 /* USER CODE END USART1_Init 1 */
510 huart1.Instance = USART1;
511 huart1.Init.BaudRate = 19200;
512 huart1.Init.WordLength = UART_WORDLENGTH_8B;
513 huart1.Init.StopBits = UART_STOPBITS_1;
514 huart1.Init.Parity = UART_PARITY_NONE;
515 huart1.Init.Mode = UART_MODE_TX_RX;
516 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
517 huart1.Init.OverSampling = UART_OVERSAMPLING_16;
518 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
519 huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
520 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
521 if (HAL_UART_Init(&huart1) != HAL_OK)
522 {
523 Error_Handler();
524 }
525 if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
526 {
527 Error_Handler();
528 }
529 if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
530 {
531 Error_Handler();
532 }
533 if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK)
534 {
535 Error_Handler();
536 }
537 /* USER CODE BEGIN USART1_Init 2 */
538
539 /* USER CODE END USART1_Init 2 */
540
541}
542
548static void MX_GPIO_Init(void)
549{
550 GPIO_InitTypeDef GPIO_InitStruct = {0};
551 /* USER CODE BEGIN MX_GPIO_Init_1 */
552
553 /* USER CODE END MX_GPIO_Init_1 */
554
555 /* GPIO Ports Clock Enable */
556 __HAL_RCC_GPIOC_CLK_ENABLE();
557 __HAL_RCC_GPIOF_CLK_ENABLE();
558 __HAL_RCC_GPIOH_CLK_ENABLE();
559 __HAL_RCC_GPIOA_CLK_ENABLE();
560 __HAL_RCC_GPIOD_CLK_ENABLE();
561 __HAL_RCC_GPIOB_CLK_ENABLE();
562
563 /*Configure GPIO pin Output Level */
564 HAL_GPIO_WritePin(EVE_PD__GPIO_Port, EVE_PD__Pin, GPIO_PIN_RESET);
565
566 /*Configure GPIO pin Output Level */
567 HAL_GPIO_WritePin(EVE_CS__GPIO_Port, EVE_CS__Pin, GPIO_PIN_SET);
568
569 /*Configure GPIO pin : EVE_INT_Pin */
570 GPIO_InitStruct.Pin = EVE_INT_Pin;
571 GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
572 GPIO_InitStruct.Pull = GPIO_PULLUP;
573 HAL_GPIO_Init(EVE_INT_GPIO_Port, &GPIO_InitStruct);
574
575 /*Configure GPIO pins : STLINK_RX_Pin STLINK_TX_Pin */
576 GPIO_InitStruct.Pin = STLINK_RX_Pin|STLINK_TX_Pin;
577 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
578 GPIO_InitStruct.Pull = GPIO_NOPULL;
579 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
580 GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
581 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
582
583 /*Configure GPIO pin : EVE_PD__Pin */
584 GPIO_InitStruct.Pin = EVE_PD__Pin;
585 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
586 GPIO_InitStruct.Pull = GPIO_NOPULL;
587 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
588 HAL_GPIO_Init(EVE_PD__GPIO_Port, &GPIO_InitStruct);
589
590 /*Configure GPIO pin : EVE_CS__Pin */
591 GPIO_InitStruct.Pin = EVE_CS__Pin;
592 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
593 GPIO_InitStruct.Pull = GPIO_NOPULL;
594 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
595 HAL_GPIO_Init(EVE_CS__GPIO_Port, &GPIO_InitStruct);
596
597 /* EXTI interrupt init*/
598 HAL_NVIC_SetPriority(EVE_INT_EXTI_IRQn, 0, 0);
599 HAL_NVIC_EnableIRQ(EVE_INT_EXTI_IRQn);
600
601 /* USER CODE BEGIN MX_GPIO_Init_2 */
602
603 /* USER CODE END MX_GPIO_Init_2 */
604}
605
606/* USER CODE BEGIN 4 */
607
608
615void _Error_Handler(const char *file, int line)
616{
617 __disable_irq();
618
619#ifdef REDIRECT_PRINTF
620 char buf[80];
621
622 snprintf(buf, sizeof(buf),
623 "Trapped in _Error_Handler(). Called from: %s, line: %d\r\n",
624 file, line);
625 printf("%s", buf);
626#endif
627
628 /* User can add an implementation to report the HAL error return state. */
629 while(1)
630 {
631 }
632}
633
634/* USER CODE END 4 */
635
636
637#ifdef USE_FULL_ASSERT
645void assert_failed(uint8_t *file, uint32_t line)
646{
647 /* USER CODE BEGIN 6 */
648 /* assert_param() can fire from inside any HAL call -- including before
649 * REDIRECT_PRINTF's UART is fully set up, or from an unusual calling
650 * context -- so this only attempts to report when REDIRECT_PRINTF is
651 * available, then halts either way. Continuing after a failed HAL
652 * parameter check is undefined behavior, not something safe to log
653 * and ignore. */
654 __disable_irq();
655
656#ifdef REDIRECT_PRINTF
657 {
658 char buf[96];
659
660 snprintf(buf, sizeof(buf),
661 "assert_param failed: file %s, line %lu\r\n",
662 (char *)file, (unsigned long)line);
663 printf("%s", buf);
664 }
665#endif
666
667 while (1)
668 {
669 }
670 /* USER CODE END 6 */
671}
672#endif /* USE_FULL_ASSERT */
#define EVE_CMD_CLKEXT
Definition main.c:82
#define EVE_REG_ID_VALUE
Definition main.c:80
static void eveReadMemory(uint32_t address, uint8_t *data, uint16_t length)
Reads bytes from BT817 memory: 3 address bytes (top two bits 00 = read), one dummy byte,...
Definition main.c:172
#define EVE_CLKSEL_72MHZ
Definition main.c:85
static void eveHostCommand(uint8_t command, uint8_t parameter)
Sends a 3-byte BT817 host command (command, parameter, 0x00).
Definition main.c:156
static bool eveSpiIsTransient(HAL_StatusTypeDef status)
Decides whether a failed HAL SPI call is worth retrying.
Definition main.c:99
#define EVE_SPI_RETRIES
Definition main.c:86
#define EVE_REG_ID
Definition main.c:77
#define EVE_ENGINE_TIMEOUT_MS
Definition main.c:89
#define EVE_BOOT_TIMEOUT_MS
Definition main.c:88
#define EVE_CMD_RST_PULSE
Definition main.c:83
#define EVE_SPI_TIMEOUT_MS
Definition main.c:87
#define EVE_MAX_READ_BYTES
Definition main.c:90
#define EVE_RAM_CHIPID
Definition main.c:79
static void evePrintNoAnswerHelp(uint8_t misoValue)
Prints the wiring checklist used when the BT817 does not answer.
Definition main.c:221
int main(void)
The application entry point.
Definition main.c:335
static bool eveWaitForRegister(uint32_t address, uint8_t expected, uint32_t timeoutMs, uint8_t *lastValue)
Polls an 8-bit BT817 register until it holds the expected value or a timeout passes.
Definition main.c:200
static void eveSpiTransaction(const uint8_t *tx, uint8_t *rx, uint16_t length)
Runs one complete SPI transaction with the BT817 (CS low, transfer, CS high). Retries the whole trans...
Definition main.c:124
#define EVE_CMD_CLKSEL
Definition main.c:84
#define EVE_REG_CPURESET
Definition main.c:78
#define EVE_CMD_ACTIVE
Definition main.c:81
static void eveChipIdTest(void)
BT817 bring-up test: resets the chip on PD#, starts its clock, waits for boot, then checks REG_ID (0x...
Definition main.c:240
static const bool runChipIdTest
true = run the chip-ID start-up check before the widget tour; false = skip it.
Definition main.c:55
: Header for main.c file. This file contains the common defines of the application.
BT817 "widget tour": page 1 has a button, a toggle with an LED and a slider that drives a gauge and a...
void widgetTourInit(void)
Starts the BT817 and prepares the widget tour.
Definition widgetTour.c:465
void widgetTourRun(void)
Runs the widget tour forever: read touch, redraw, short pause.
Definition widgetTour.c:482