STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
board_bringup.h
Go to the documentation of this file.
1#ifndef STAR_BOARD_BRINGUP_H
2#define STAR_BOARD_BRINGUP_H
3
4/*
5 * Bring-up: power and reset sequencing for every chip, then a probe that the
6 * self-test coordinator can call for any device ID.
7 *
8 * board_bringup_power_up() runs once, from a task, before self-test. It only
9 * enables a device's check (devices.configured_mask) after that device's
10 * power/reset/startup steps are done, as self_test_devices.h requires.
11 * It never enables a pyro output and never transmits on the radio.
12 */
13
14#include <stdbool.h>
15#include <stdint.h>
16
17#include "self_test_devices.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* GNSS probe diagnostics: PASS carries the baud rate that worked. */
24#define BOARD_GNSS_DIAG_ANTENNA_SHORT 1 /* PD10 low: antenna switch fault */
25#define BOARD_GNSS_LISTEN_MS 1500U /* > one 1 Hz NMEA period */
26
27/* SD NAND probe diagnostics. FAIL/TIMEOUT: (stage << 8) | last R1 byte.
28 * PASS: CID manufacturer ID | 0x100 if the card is high capacity (CCS). */
29#define BOARD_SD_STAGE_CMD0 1
30#define BOARD_SD_STAGE_CMD8 2
31#define BOARD_SD_STAGE_ACMD41 3
32#define BOARD_SD_STAGE_CMD58 4
33#define BOARD_SD_STAGE_CMD10 5
34#define BOARD_SD_INIT_MS 1000U /* ACMD41 loop limit (SD spec: 1 s) */
35
36typedef struct {
37 /* Pranay's SPI identity checks, wired to board_spi. */
41 bool emmc_init_attempted; /* the card is initialized once per power-up */
44 bool time_ok; /* TIM2 really ticks at 1 MHz (board_time_start) */
46
47/* eMMC probe diagnostics: PASS = CID manufacturer ID (Kioxia/Toshiba is
48 * 0x11). FAIL = HAL MMC error code, or BOARD_EMMC_DIAG_STATE | card state. */
49#define BOARD_EMMC_DIAG_STATE 0x10000
50
51/* Release resets / power rails in order and enable each ready device. */
53
54/* self_test_port_t.read_battery: PA0 counts, the mean of 16 conversions
55 * (VDD after the ORing, x 0.3125). Conversion and thresholds:
56 * src/app/battery.h.
57 */
58self_test_battery_t board_bringup_read_battery(void* context, uint32_t now_ms,
59 uint32_t budget_ms);
60
61/* SW_ST (PE10): true when the TPS2121 runs the board from USB, so PA0 reads
62 * USB_5V, not the pack. */
63bool board_bringup_on_usb(void);
64
65/* self_test_port_t.probe with a board_bringup_t context. */
66self_test_reply_t board_bringup_probe(void* context, uint16_t device_id,
67 uint8_t attempt, uint32_t now_ms,
68 uint32_t budget_ms);
69
70#ifdef __cplusplus
71}
72#endif
73#endif
bool board_bringup_on_usb(void)
self_test_battery_t board_bringup_read_battery(void *context, uint32_t now_ms, uint32_t budget_ms)
void board_bringup_power_up(board_bringup_t *bringup)
self_test_reply_t board_bringup_probe(void *context, uint16_t device_id, uint8_t attempt, uint32_t now_ms, uint32_t budget_ms)
static board_bringup_t bringup
self_test_reply_t emmc_result
self_test_devices_t devices