Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated INA226 driver #190

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions general/include/INA226.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#ifndef INA226_H
#define INA226_H
#include <stdint.h>
#include <math.h>

// REGISTERS
#define INA226_CONFIGURATION 0x00
Expand Down Expand Up @@ -65,10 +67,12 @@ int ina226_configure(ina226_t *ina, uint8_t mode, uint8_t vshct, uint8_t vbusct,
uint8_t avg);

// Resets all registers to default values
int ina226_reset(ina226_t ina);
int ina226_reset(ina226_t *ina);

// Reads manufacturer id register
int ina226_read_manufacturer_id(ina226_t ina, uint16_t *data);
int ina226_read_manufacturer_id(ina226_t *ina, uint16_t *data);

// Reads die id
int ina226_read_die_id(ina226_t ina, uint16_t *data);
int ina226_read_die_id(ina226_t *ina, uint16_t *data);

#endif //INA226_H
6 changes: 3 additions & 3 deletions general/src/INA226.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ int ina226_configure(ina226_t *ina, uint8_t mode, uint8_t vshct, uint8_t vbusct,
}

// Resets all registers to default values
int ina226_reset(ina226_t ina)
int ina226_reset(ina226_t *ina)
{
uint16_t reset = INA226_CONFIG_RESET_MASK;
return ina226_write_reg(ina, INA226_CONFIGURATION, &reset);
}

// Reads manufacturer id register
int ina226_read_manufacturer_id(ina226_t ina, uint16_t *data)
int ina226_read_manufacturer_id(ina226_t *ina, uint16_t *data)
{
uint16_t manufacturer_id;

Expand All @@ -131,7 +131,7 @@ int ina226_read_manufacturer_id(ina226_t ina, uint16_t *data)
}

// Reads die id
int ina226_read_die_id(ina226_t ina, uint16_t *data)
int ina226_read_die_id(ina226_t *ina, uint16_t *data)
{
uint16_t die_id;

Expand Down
Loading