STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
board_adc.h
Go to the documentation of this file.
1#ifndef STAR_BOARD_ADC_H
2#define STAR_BOARD_ADC_H
3
4/*
5 * ADC1 analog inputs (16-bit, VREF+ = 3V3 ~3.32 V, 387.5-cycle sampling for
6 * the TLV9004 buffers). The .ioc scans only PA0; these helpers point ADC1 at
7 * one channel per conversion, with the same settings CubeMX generated.
8 * Raw counts only: scaling and thresholds belong to the adapters (#137).
9 */
10
11#include <stdbool.h>
12#include <stdint.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18typedef enum {
19 BOARD_ADC_VBAT = 0, /* PA0 INP16: VDD after ORing x 0.3125 */
20 BOARD_ADC_EXT_SENSE_1, /* PA1 INP17 */
21 BOARD_ADC_PYRO_1_CONT, /* PA2 INP14: ~590 counts with an igniter */
22 BOARD_ADC_PYRO_2_CONT, /* PA3 INP15 */
23 BOARD_ADC_EXT_SENSE_2, /* PA4 INP18 (J4, unbuffered) */
24 BOARD_ADC_ALT_CURR, /* PC0 INP10: altimeter battery current */
25 BOARD_ADC_CURR, /* PC1 INP11: main current, 1 V/A */
28
33
34/* Offset + linearity calibration. Once, before the first conversion. */
35bool board_adc_init(void);
36
37/* One conversion. False on HAL error or timeout. */
38bool board_adc_read(board_adc_input_t input, uint16_t* counts,
39 uint32_t timeout_ms);
40
41/* Every input once (bring-up report). */
42void board_adc_snapshot(board_adc_snapshot_t* snapshot, uint32_t timeout_ms);
43
44#ifdef __cplusplus
45}
46#endif
47#endif
bool board_adc_read(board_adc_input_t input, uint16_t *counts, uint32_t timeout_ms)
Definition board_adc.c:28
board_adc_input_t
Definition board_adc.h:18
@ BOARD_ADC_VBAT
Definition board_adc.h:19
@ BOARD_ADC_CURR
Definition board_adc.h:25
@ BOARD_ADC_ALT_CURR
Definition board_adc.h:24
@ BOARD_ADC_COUNT
Definition board_adc.h:26
@ BOARD_ADC_EXT_SENSE_1
Definition board_adc.h:20
@ BOARD_ADC_PYRO_2_CONT
Definition board_adc.h:22
@ BOARD_ADC_PYRO_1_CONT
Definition board_adc.h:21
@ BOARD_ADC_EXT_SENSE_2
Definition board_adc.h:23
void board_adc_snapshot(board_adc_snapshot_t *snapshot, uint32_t timeout_ms)
Definition board_adc.c:54
bool board_adc_init(void)
Definition board_adc.c:19
bool valid[BOARD_ADC_COUNT]
Definition board_adc.h:30
uint16_t counts[BOARD_ADC_COUNT]
Definition board_adc.h:31