Midnight Sun Firmware
Loading...
Searching...
No Matches
current_acs37800.h
1#pragma once
2
3/************************************************************************************************
4 * @file current_sense_acs37800.h
5 *
6 * @brief Header file to implement the current sensing from the ACS37800 sensor
7 *
8 * @date 2025-07-29
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17#include "gpio.h"
18#include "i2c.h"
19#include "status.h"
20
21/* Intra-component Headers */
22#include "current_acs37800_defs.h"
23
30typedef struct {
31 I2CPort i2c_port;
32 I2CAddress i2c_address;
34
41StatusCode acs37800_init(ACS37800Storage *storage, I2CPort i2c_port, I2CAddress i2c_address);
42
48StatusCode acs37800_get_current(ACS37800Storage *storage, float *out_current_amps);
49
55StatusCode acs37800_get_voltage(ACS37800Storage *storage, float *out_voltage_mV);
56
62StatusCode acs37800_get_active_power(ACS37800Storage *storage, float *out_power_mW);
63
69StatusCode acs37800_get_overcurrent_flag(ACS37800Storage *storage, bool *overcurrent_flag);
70
76
82StatusCode acs37800_get_overvoltage_flag(ACS37800Storage *storage, bool *overvoltage_flag);
83
89StatusCode acs37800_get_undervoltage_flag(ACS37800Storage *storage, bool *undervoltage_flag);
90
97StatusCode acs37800_get_register(ACS37800Storage *storage, ACS37800_Registers reg, uint32_t *out_raw);
98
StatusCode acs37800_get_current(ACS37800Storage *storage, float *out_current_amps)
Gets the instantaneous current in amps.
Definition: current_acs37800.c:50
StatusCode acs37800_get_voltage(ACS37800Storage *storage, float *out_voltage_mV)
Gets the instantaneous voltage in volts.
Definition: current_acs37800.c:70
StatusCode acs37800_get_undervoltage_flag(ACS37800Storage *storage, bool *undervoltage_flag)
Gets if the ACS37800 unit detects under-voltage.
Definition: current_acs37800.c:180
StatusCode acs37800_reset_overcurrent_flag(ACS37800Storage *storage)
Resets the latched overcurrent fault, needs to write 1 to 0x2D register.
Definition: current_acs37800.c:133
StatusCode acs37800_get_overvoltage_flag(ACS37800Storage *storage, bool *overvoltage_flag)
Gets if the ACS37800 unit detects over-voltage.
Definition: current_acs37800.c:157
StatusCode acs37800_get_active_power(ACS37800Storage *storage, float *out_power_mW)
Gets the instantaneous power in milliwatts.
Definition: current_acs37800.c:90
StatusCode acs37800_init(ACS37800Storage *storage, I2CPort i2c_port, I2CAddress i2c_address)
Initialize the ACS37800 driver.
Definition: current_acs37800.c:20
StatusCode acs37800_get_register(ACS37800Storage *storage, ACS37800_Registers reg, uint32_t *out_raw)
Gets the 16 bit value from the ACS37800 volatile register.
Definition: current_acs37800.c:31
StatusCode acs37800_get_overcurrent_flag(ACS37800Storage *storage, bool *overcurrent_flag)
Gets if the ACS37800 unit detects over-current (latched)
Definition: current_acs37800.c:110
uint8_t I2CAddress
I2C address type.
Definition: i2c.h:34
I2CPort
I2C Port selection.
Definition: i2c.h:37
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Definition: current_acs37800.h:30