-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39003e3
commit 462b6c3
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdint.h> | ||
#include "nrf_twi_mngr.h" | ||
|
||
namespace edge::aidan { | ||
|
||
static uint8_t i2c_reg_read(uint8_t i2c_addr, uint8_t reg_addr); | ||
|
||
static void i2c_reg_write(uint8_t i2c_addr, uint8_t reg_addr, uint8_t data); | ||
|
||
void lsm303agr_init(const nrf_twi_mngr_t* i2c); | ||
} // namespace edge::aidan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "hal/i2c_wrapper.hpp" | ||
#include "cmsis_gcc.h" | ||
#include "nrf_error.h" | ||
#include "nrf_twi_mngr.h" | ||
#include "sdk_errors.h" | ||
|
||
namespace edge::aidan { | ||
|
||
static const nrf_twi_mngr_t* i2c_manager = NULL; | ||
|
||
uint8_t i2c_reg_read(uint8_t i2c_addr, uint8_t reg_addr) | ||
{ | ||
uint8_t rx_buf = 0; | ||
nrf_twi_mngr_transfer_t const read_transfer[] = { | ||
NRF_TWI_MNGR_WRITE(i2c_addr, ®_addr, 1, NRF_TWI_MNGR_NO_STOP), | ||
NRF_TWI_MNGR_READ(i2c_addr, &rx_buf, 1, NRF_TWI_MNGR_NO_STOP) | ||
}; | ||
ret_code_t result = nrf_twi_mngr_perform(i2c_manager, NULL, read_transfer, 2, NULL); | ||
if (result != NRF_SUCCESS) | ||
{ | ||
printf("I2C TRANSACTION FAILED!"); | ||
} | ||
return rx_buf; | ||
}; | ||
|
||
void i2c_reg_write(uint8_t i2c_addr, uint8_t reg_addr, uint8_t data) | ||
{ | ||
return; | ||
} | ||
|
||
void lsm303agr_init(const int *i2c) | ||
{ | ||
return; | ||
} | ||
|
||
|
||
} |