Midnight Sun Firmware
Loading...
Searching...
No Matches
pedal_calib.h
1#pragma once
2
3/************************************************************************************************
4 * @file pedal_calib.h
5 *
6 * @brief Header file to define the pedal calibration data
7 *
8 * @date 2025-05-15
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14
15/* Inter-component Headers */
16#include "global_enums.h"
17#include "gpio.h"
18
19/* Intra-component Headers */
20
28#define NUM_SAMPLES_ONE_SHOT 1000U
29
30#define NUM_SAMPLES_SINGLE_READ 100U
31
36typedef enum {
37 PEDAL_PRESSED = 0,
38 PEDAL_UNPRESSED,
39 NUM_PEDAL_STATES,
41
43typedef struct PedalCalibBlob {
44 PedalCalibrationData throttle_calib;
45 PedalCalibrationData brake_calib;
47
50 uint16_t min_reading;
51 uint16_t max_reading;
52 volatile uint32_t sample_counter;
54
57
58StatusCode pedal_calib_sample_single(PedalCalibrationStorage *calib_storage, PedalCalibrationData *data, PedalState state, GpioAddress *address, bool first_sample);
59
PedalCalibBlob global_calib_blob
A global struct that stores the throttle pedal and calibration data.
PedalState
Stores the possible pedal states that the pedal could be in.
Definition: pedal_calib.h:36
StatusCode pedal_calib_sample(PedalCalibrationStorage *calib_storage, PedalCalibrationData *data, PedalState state, GpioAddress *address)
Reads data from ADC and calculates appropriate pedal calibration values.
Definition: pedal_calib.c:29
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Port and pin data.
Definition: network.h:62
Stores pedal calibration data for the break and the throttle pedals.
Definition: pedal_calib.h:43
Stores data that defines when the pedal is full pressed or unpressed.
Definition: main.c:39
A struct that stores the max and min reading along with a sample counter for the data that is being p...
Definition: pedal_calib.h:49