Midnight Sun Firmware
Loading...
Searching...
No Matches
cell_sense.h
1#pragma once
2
3/************************************************************************************************
4 * @file cell_sense.h
5 *
6 * @brief Header file for AFE cell sense
7 *
8 * @date 2025-01-12
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15#include <stdlib.h>
16
17/* Inter-component Headers */
18#include "gpio.h"
19
20/* Intra-component Headers */
21#include "bms_carrier.h"
22
29#define CONV_DELAY_MS 10
30#define AUX_CONV_DELAY_MS 3
31// Maximum number of retry attempts to read cell/aux data once triggered
32#define RETRY_DELAY_MS 1
33#define CELL_SENSE_CONVERSIONS 0
34
35// Fault thresholds - units of mV*10
36#define CELL_OVERVOLTAGE 42500
37#define CELL_UNDERVOLTAGE 25000
38#define CELL_UNBALANCED 5000
39#define CELL_MAX_TEMPERATURE_DISCHARGE 60
40#define CELL_MAX_TEMPERATURE_CHARGE 50
41
42#define SOLAR_VOLTAGE_THRESHOLD 42000
43
44#define AFE_BALANCING_UPPER_THRESHOLD 41500
45#define AFE_BALANCING_LOWER_THRESHOLD 40000
46
47StatusCode cell_sense_init(BmsStorage *storage);
48
49// Mark cell for discharging (takes effect after config is re-written)
50// |cell| should be [0, settings.num_cells)
51
52StatusCode cell_discharge(LtcAfeStorage *afe);
53
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Battery management system storage.
Definition: bms_carrier.h:50
Runtime Data Storage.
Definition: ltc_afe.h:113