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