H753_CPP_SPI_BT817_EVE_01 1.0
STM32H753 drives a Bridgetek BT817 (ME817EV + DP-0701-01A) over SPI: a chip-ID start-up check, then Bridgetek's simple demo through the STM32_Bridgetek_EVE_API library
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 "eve_example.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_01)\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
338{
339 return 1;
340}
341
348int8_t platform_calib_write(struct touchscreen_calibration *calib)
349{
350 (void)calib;
351 return -1;
352}
353
360int8_t platform_calib_read(struct touchscreen_calibration *calib)
361{
362 (void)calib;
363 return -1;
364}
365
366/* USER CODE END 0 */
367
372int main(void)
373{
374
375 /* USER CODE BEGIN 1 */
376
377 /* USER CODE END 1 */
378
379 /* MCU Configuration--------------------------------------------------------*/
380
381 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
382 HAL_Init();
383
384 /* USER CODE BEGIN Init */
385
386 /* USER CODE END Init */
387
388 /* Configure the system clock */
389 SystemClock_Config();
390
391 /* USER CODE BEGIN SysInit */
392
393 /* USER CODE END SysInit */
394
395 /* Initialize all configured peripherals */
396 MX_GPIO_Init();
397 MX_USART1_UART_Init();
398 MX_SPI1_Init();
399 /* USER CODE BEGIN 2 */
400
401 printf("\x1b[2J\x1b[H"); // Clear the dumb terminal screen
402
403 /* Start-up check: prints REG_ID, REG_CPURESET and the chip ID, stops on failure. */
404 if (runChipIdTest)
405 {
407 }
408
409 printf("Starting the Bridgetek simple example.\r\n");
410 eve_example();
411
412 /* USER CODE END 2 */
413
414 /* Infinite loop */
415 /* USER CODE BEGIN WHILE */
416 while (1)
417 {
418 /* USER CODE END WHILE */
419
420 /* USER CODE BEGIN 3 */
421 }
422 /* USER CODE END 3 */
423}
424
429void SystemClock_Config(void)
430{
431 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
432 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
433
436 HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
437
440 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
441
442 while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
443
447 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
448 RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
449 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
450 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
451 RCC_OscInitStruct.PLL.PLLM = 1;
452 RCC_OscInitStruct.PLL.PLLN = 120;
453 RCC_OscInitStruct.PLL.PLLP = 2;
454 RCC_OscInitStruct.PLL.PLLQ = 5;
455 RCC_OscInitStruct.PLL.PLLR = 2;
456 RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
457 RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
458 RCC_OscInitStruct.PLL.PLLFRACN = 0;
459 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
460 {
461 Error_Handler();
462 }
463
466 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
467 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
468 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
469 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
470 RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
471 RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
472 RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
473 RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
474 RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
475 RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
476
477 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
478 {
479 Error_Handler();
480 }
481}
482
488static void MX_SPI1_Init(void)
489{
490
491 /* USER CODE BEGIN SPI1_Init 0 */
492
493 /* USER CODE END SPI1_Init 0 */
494
495 /* USER CODE BEGIN SPI1_Init 1 */
496
497 /* USER CODE END SPI1_Init 1 */
498 /* SPI1 parameter configuration*/
499 hspi1.Instance = SPI1;
500 hspi1.Init.Mode = SPI_MODE_MASTER;
501 hspi1.Init.Direction = SPI_DIRECTION_2LINES;
502 hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
503 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
504 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
505 hspi1.Init.NSS = SPI_NSS_SOFT;
506 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
507 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
508 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
509 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
510 hspi1.Init.CRCPolynomial = 0x0;
511 hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
512 hspi1.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
513 hspi1.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
514 hspi1.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
515 hspi1.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
516 hspi1.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
517 hspi1.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
518 hspi1.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
519 hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
520 hspi1.Init.IOSwap = SPI_IO_SWAP_DISABLE;
521 if (HAL_SPI_Init(&hspi1) != HAL_OK)
522 {
523 Error_Handler();
524 }
525 /* USER CODE BEGIN SPI1_Init 2 */
526
527 /* USER CODE END SPI1_Init 2 */
528
529}
530
536static void MX_USART1_UART_Init(void)
537{
538
539 /* USER CODE BEGIN USART1_Init 0 */
540
541 /* USER CODE END USART1_Init 0 */
542
543 /* USER CODE BEGIN USART1_Init 1 */
544
545 /* USER CODE END USART1_Init 1 */
546 huart1.Instance = USART1;
547 huart1.Init.BaudRate = 19200;
548 huart1.Init.WordLength = UART_WORDLENGTH_8B;
549 huart1.Init.StopBits = UART_STOPBITS_1;
550 huart1.Init.Parity = UART_PARITY_NONE;
551 huart1.Init.Mode = UART_MODE_TX_RX;
552 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
553 huart1.Init.OverSampling = UART_OVERSAMPLING_16;
554 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
555 huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
556 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
557 if (HAL_UART_Init(&huart1) != HAL_OK)
558 {
559 Error_Handler();
560 }
561 if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
562 {
563 Error_Handler();
564 }
565 if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
566 {
567 Error_Handler();
568 }
569 if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK)
570 {
571 Error_Handler();
572 }
573 /* USER CODE BEGIN USART1_Init 2 */
574
575 /* USER CODE END USART1_Init 2 */
576
577}
578
584static void MX_GPIO_Init(void)
585{
586 GPIO_InitTypeDef GPIO_InitStruct = {0};
587 /* USER CODE BEGIN MX_GPIO_Init_1 */
588
589 /* USER CODE END MX_GPIO_Init_1 */
590
591 /* GPIO Ports Clock Enable */
592 __HAL_RCC_GPIOC_CLK_ENABLE();
593 __HAL_RCC_GPIOF_CLK_ENABLE();
594 __HAL_RCC_GPIOH_CLK_ENABLE();
595 __HAL_RCC_GPIOA_CLK_ENABLE();
596 __HAL_RCC_GPIOD_CLK_ENABLE();
597 __HAL_RCC_GPIOB_CLK_ENABLE();
598
599 /*Configure GPIO pin Output Level */
600 HAL_GPIO_WritePin(EVE_PD__GPIO_Port, EVE_PD__Pin, GPIO_PIN_RESET);
601
602 /*Configure GPIO pin Output Level */
603 HAL_GPIO_WritePin(EVE_CS__GPIO_Port, EVE_CS__Pin, GPIO_PIN_SET);
604
605 /*Configure GPIO pin : EVE_INT_Pin */
606 GPIO_InitStruct.Pin = EVE_INT_Pin;
607 GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
608 GPIO_InitStruct.Pull = GPIO_PULLUP;
609 HAL_GPIO_Init(EVE_INT_GPIO_Port, &GPIO_InitStruct);
610
611 /*Configure GPIO pins : STLINK_RX_Pin STLINK_TX_Pin */
612 GPIO_InitStruct.Pin = STLINK_RX_Pin|STLINK_TX_Pin;
613 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
614 GPIO_InitStruct.Pull = GPIO_NOPULL;
615 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
616 GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
617 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
618
619 /*Configure GPIO pin : EVE_PD__Pin */
620 GPIO_InitStruct.Pin = EVE_PD__Pin;
621 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
622 GPIO_InitStruct.Pull = GPIO_NOPULL;
623 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
624 HAL_GPIO_Init(EVE_PD__GPIO_Port, &GPIO_InitStruct);
625
626 /*Configure GPIO pin : EVE_CS__Pin */
627 GPIO_InitStruct.Pin = EVE_CS__Pin;
628 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
629 GPIO_InitStruct.Pull = GPIO_NOPULL;
630 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
631 HAL_GPIO_Init(EVE_CS__GPIO_Port, &GPIO_InitStruct);
632
633 /* EXTI interrupt init*/
634 HAL_NVIC_SetPriority(EVE_INT_EXTI_IRQn, 0, 0);
635 HAL_NVIC_EnableIRQ(EVE_INT_EXTI_IRQn);
636
637 /* USER CODE BEGIN MX_GPIO_Init_2 */
638
639 /* USER CODE END MX_GPIO_Init_2 */
640}
641
642/* USER CODE BEGIN 4 */
643
644
651void _Error_Handler(const char *file, int line)
652{
653 __disable_irq();
654
655#ifdef REDIRECT_PRINTF
656 char buf[80];
657
658 snprintf(buf, sizeof(buf),
659 "Trapped in _Error_Handler(). Called from: %s, line: %d\r\n",
660 file, line);
661 printf("%s", buf);
662#endif
663
664 /* User can add an implementation to report the HAL error return state. */
665 while(1)
666 {
667 }
668}
669
670/* USER CODE END 4 */
671
672
673#ifdef USE_FULL_ASSERT
681void assert_failed(uint8_t *file, uint32_t line)
682{
683 /* USER CODE BEGIN 6 */
684 /* assert_param() can fire from inside any HAL call -- including before
685 * REDIRECT_PRINTF's UART is fully set up, or from an unusual calling
686 * context -- so this only attempts to report when REDIRECT_PRINTF is
687 * available, then halts either way. Continuing after a failed HAL
688 * parameter check is undefined behavior, not something safe to log
689 * and ignore. */
690 __disable_irq();
691
692#ifdef REDIRECT_PRINTF
693 {
694 char buf[96];
695
696 snprintf(buf, sizeof(buf),
697 "assert_param failed: file %s, line %lu\r\n",
698 (char *)file, (unsigned long)line);
699 printf("%s", buf);
700 }
701#endif
702
703 while (1)
704 {
705 }
706 /* USER CODE END 6 */
707}
708#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
int8_t platform_calib_init(void)
Tell the Bridgetek example whether touch calibration can be stored.
Definition main.c:337
#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
int8_t platform_calib_read(struct touchscreen_calibration *calib)
Read stored touch calibration values (not supported in this project).
Definition main.c:360
#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:372
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
int8_t platform_calib_write(struct touchscreen_calibration *calib)
Store touch calibration values (not supported in this project).
Definition main.c:348
#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 our chip-ID start-up check before Bridgetek's example; false = skip it.
Definition main.c:55
: Header for main.c file. This file contains the common defines of the application.