-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathINA3221_Drv.c
50 lines (40 loc) · 918 Bytes
/
INA3221_Drv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* INA3221_Drv.c
*
* Created on: Jun 15, 2024
* Author: codek
*/
#include "main.h"
/*
* Description: Read INA3221 register and call the callback if registered.
*
*/
int INA3221_Read(I2C_GenericDef *i2c, uint16_t reg, void (*callback)(struct __I2C_GenericDef_ *i2c))
{
int status = NO_ERROR;
i2c->registerAddr[0] = reg;
i2c->regSize = 1;
i2c->RxISR = callback;
status = I2C_Mem_Read_Generic_Method(i2c);
if(status != NO_ERROR)
{
return status;
}
return status;
}
/*
* Description: Be sure to initialize I2C data pointer with data and data size prior to calling this.
*/
int INA3221_Write(I2C_GenericDef *i2c, uint16_t reg, void (*callback)(struct __I2C_GenericDef_ *i2c))
{
int status = NO_ERROR;
i2c->registerAddr[0] = reg;
i2c->regSize = 1;
i2c->TxISR = callback;
status = I2C_Mem_Write_Generic_Method(i2c);
if(status != NO_ERROR)
{
return status;
}
return status;
}