|
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
|
: Main program body More...
#include "main.h"#include <stdio.h>#include <string.h>#include <stdbool.h>#include "eve_example.h"Go to the source code of this file.
Macros | |
| #define | EVE_REG_ID 0x302000UL |
| #define | EVE_REG_CPURESET 0x302020UL |
| #define | EVE_RAM_CHIPID 0x0C0000UL |
| #define | EVE_REG_ID_VALUE 0x7CU |
| #define | EVE_CMD_ACTIVE 0x00U |
| #define | EVE_CMD_CLKEXT 0x44U |
| #define | EVE_CMD_RST_PULSE 0x68U |
| #define | EVE_CMD_CLKSEL 0x61U |
| #define | EVE_CLKSEL_72MHZ 0x46U |
| #define | EVE_SPI_RETRIES 3U |
| #define | EVE_SPI_TIMEOUT_MS 10U |
| #define | EVE_BOOT_TIMEOUT_MS 300U |
| #define | EVE_ENGINE_TIMEOUT_MS 3000U |
| #define | EVE_MAX_READ_BYTES 4U |
Functions | |
| static bool | eveSpiIsTransient (HAL_StatusTypeDef status) |
| Decides whether a failed HAL SPI call is worth retrying. | |
| 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 transaction on transient errors, up to EVE_SPI_RETRIES, then reports the reason and calls Error_Handler(). | |
| static void | eveHostCommand (uint8_t command, uint8_t parameter) |
| Sends a 3-byte BT817 host command (command, parameter, 0x00). | |
| 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, then the data (datasheet 4.1.3). | |
| 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. | |
| static void | evePrintNoAnswerHelp (uint8_t misoValue) |
| Prints the wiring checklist used when the BT817 does not answer. | |
| static void | eveChipIdTest (void) |
| BT817 bring-up test: resets the chip on PD#, starts its clock, waits for boot, then checks REG_ID (0x7C), REG_CPURESET (0) and the chip ID (08 17 01 00). Prints PASS, or the reason for the failure and calls Error_Handler(). | |
| int8_t | platform_calib_init (void) |
| Tell the Bridgetek example whether touch calibration can be stored. | |
| int8_t | platform_calib_write (struct touchscreen_calibration *calib) |
| Store touch calibration values (not supported in this project). | |
| int8_t | platform_calib_read (struct touchscreen_calibration *calib) |
| Read stored touch calibration values (not supported in this project). | |
| int | main (void) |
| The application entry point. | |
Variables | |
| static const bool | runChipIdTest = true |
| true = run our chip-ID start-up check before Bridgetek's example; false = skip it. | |
: Main program body
Copyright (c) 2026 STMicroelectronics. All rights reserved.
This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.
Definition in file main.c.
| #define EVE_BOOT_TIMEOUT_MS 300U |
Boot can take up to 300 ms (4.9.4)
Definition at line 88 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_CLKSEL_72MHZ 0x46U |
CLKSEL parameter: 6 x 12 MHz, PLL range 1 (Bridgetek EVE_HAL.c)
Definition at line 85 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_CMD_ACTIVE 0x00U |
| #define EVE_CMD_CLKEXT 0x44U |
Host command CLKEXT (external crystal)
Definition at line 82 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_CMD_CLKSEL 0x61U |
Host command CLKSEL (system clock select)
Definition at line 84 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_CMD_RST_PULSE 0x68U |
Host command RST_PULSE (core reset)
Definition at line 83 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_ENGINE_TIMEOUT_MS 3000U |
Wait for REG_CPURESET; the touch engine waits for the touch controller to boot
Definition at line 89 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_MAX_READ_BYTES 4U |
| #define EVE_RAM_CHIPID 0x0C0000UL |
Chip ID, 08 17 01 00 for a BT817
Definition at line 79 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_REG_CPURESET 0x302020UL |
REG_CPURESET, 0 = engines running
Definition at line 78 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_REG_ID 0x302000UL |
REG_ID, always reads 0x7C once booted
Definition at line 77 of file main.c.
Referenced by eveChipIdTest().
| #define EVE_REG_ID_VALUE 0x7CU |
| #define EVE_SPI_RETRIES 3U |
Attempts per SPI transaction
Definition at line 86 of file main.c.
Referenced by eveSpiTransaction().
| #define EVE_SPI_TIMEOUT_MS 10U |
HAL timeout per SPI transaction
Definition at line 87 of file main.c.
Referenced by eveSpiTransaction().
|
static |
BT817 bring-up test: resets the chip on PD#, starts its clock, waits for boot, then checks REG_ID (0x7C), REG_CPURESET (0) and the chip ID (08 17 01 00). Prints PASS, or the reason for the failure and calls Error_Handler().
Definition at line 240 of file main.c.
References EVE_BOOT_TIMEOUT_MS, EVE_CLKSEL_72MHZ, EVE_CMD_ACTIVE, EVE_CMD_CLKEXT, EVE_CMD_CLKSEL, EVE_CMD_RST_PULSE, EVE_ENGINE_TIMEOUT_MS, EVE_RAM_CHIPID, EVE_REG_CPURESET, EVE_REG_ID, EVE_REG_ID_VALUE, eveHostCommand(), evePrintNoAnswerHelp(), eveReadMemory(), and eveWaitForRegister().
Referenced by main().
|
static |
Sends a 3-byte BT817 host command (command, parameter, 0x00).
| command | Host command byte, e.g. EVE_CMD_CLKEXT or EVE_CMD_ACTIVE. |
| parameter | Second byte; 0x00 for most commands, the clock setting for CLKSEL. |
Definition at line 156 of file main.c.
References eveSpiTransaction().
Referenced by eveChipIdTest().
|
static |
Prints the wiring checklist used when the BT817 does not answer.
| misoValue | The last byte read back, to show whether MISO looks stuck. |
Definition at line 221 of file main.c.
Referenced by eveChipIdTest().
|
static |
Reads bytes from BT817 memory: 3 address bytes (top two bits 00 = read), one dummy byte, then the data (datasheet 4.1.3).
| address | 22-bit BT817 memory address. |
| data | Destination for the bytes read. |
| length | Number of bytes to read, 1 to EVE_MAX_READ_BYTES. |
Definition at line 172 of file main.c.
References EVE_MAX_READ_BYTES, and eveSpiTransaction().
Referenced by eveChipIdTest(), and eveWaitForRegister().
|
static |
Decides whether a failed HAL SPI call is worth retrying.
| status | The HAL status returned by the SPI call. |
Definition at line 99 of file main.c.
Referenced by eveSpiTransaction().
|
static |
Runs one complete SPI transaction with the BT817 (CS low, transfer, CS high). Retries the whole transaction on transient errors, up to EVE_SPI_RETRIES, then reports the reason and calls Error_Handler().
| tx | Bytes to send (must hold length bytes). |
| rx | Buffer for the bytes clocked back (must hold length bytes). |
| length | Number of bytes to clock. |
Definition at line 124 of file main.c.
References EVE_SPI_RETRIES, EVE_SPI_TIMEOUT_MS, and eveSpiIsTransient().
Referenced by eveHostCommand(), and eveReadMemory().
|
static |
Polls an 8-bit BT817 register until it holds the expected value or a timeout passes.
| address | Register address. |
| expected | Value to wait for. |
| timeoutMs | How long to keep polling, in milliseconds. |
| lastValue | Receives the last value read (for the failure report). |
Definition at line 200 of file main.c.
References eveReadMemory().
Referenced by eveChipIdTest().
| int main | ( | void | ) |
The application entry point.
| int |
Definition at line 372 of file main.c.
References eveChipIdTest(), and runChipIdTest.
| int8_t platform_calib_init | ( | void | ) |
Tell the Bridgetek example whether touch calibration can be stored.
Called by the vendor example (touch.c). This project has no storage for calibration yet, so it reports "not supported" and the example asks for a new calibration after every reset. Thread safety: safe from any context; it touches no shared state.
| 1 | Storing touchscreen settings is not supported. |
| int8_t platform_calib_read | ( | struct touchscreen_calibration * | calib | ) |
| int8_t platform_calib_write | ( | struct touchscreen_calibration * | calib | ) |