Skip to content
Snippets Groups Projects
Commit 6fc3674e authored by schneider's avatar schneider
Browse files

feat(BHI): Add I2C support

parent ccd2773c
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "i2c.h" #include "i2c.h"
#include "tmr_utils.h" #include "tmr_utils.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
/********************************************************************************/ /********************************************************************************/
/* STATIC VARIABLES */ /* STATIC VARIABLES */
...@@ -66,17 +67,22 @@ ...@@ -66,17 +67,22 @@
static struct bhy_t bhy; static struct bhy_t bhy;
static char *version = BHY_MCU_REFERENCE_VERSION; static char *version = BHY_MCU_REFERENCE_VERSION;
#define I2C_DEVICE MXC_I2C0_BUS0
/********************************************************************************/ /********************************************************************************/
/* EXTERN FUNCTION DECLARATIONS */ /* EXTERN FUNCTION DECLARATIONS */
/********************************************************************************/ /********************************************************************************/
static int8_t sensor_i2c_write(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size) static int8_t sensor_i2c_write(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size)
{ {
return 0; uint8_t buf[size + 1];
buf[0] = reg;
memcpy(buf + 1, p_buf, size);
return I2C_MasterWrite(I2C_DEVICE, addr << 1, buf, size + 1, 0);
} }
static int8_t sensor_i2c_read(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size) static int8_t sensor_i2c_read(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size)
{ {
return 0; I2C_MasterWrite(I2C_DEVICE, addr << 1, &reg, 1, 1);
return I2C_MasterRead(I2C_DEVICE, addr << 1, p_buf, size, 0);
} }
/********************************************************************************/ /********************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment