Hi every body.
I have trying without success to attach an event handler function to the TWI.
I am reading a temperature and humidity sensor using I2C. In polling mode everything is working perfectly but when I try to attach a callback function, that function is never called.
Any idea about what I am doing wrong?
Here is the code I am implementing:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ########## M.I. BSP ##########
#include "bsp_handler.h"
// ########## M.I. Lib ##########
#include "board.h"
#include "uart_handler.h"
#include "nrfx_twim.h"
// i2c parameters for SHT35
#define SHT35_I2C_ADDRESS 0x44
#define CMD_SOFT_RST0 0xA2 // soft reset command LSB
#define CMD_SOFT_RST1 0x30 // soft reset command MSB
#define HIGH_REP_WITH_STRCH0 0x06 // request command LSB
#define HIGH_REP_WITH_STRCH1 0x2C // request command MSB
#define NRF52833_XXAA
static const char messageBuffer[] =
"*** DEMO EHAL-I2C Driver ***\r\n"
"*** Website: https://monitoreointeligente.com/ ***\r\n";
Here is the prj.conf
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_UART_0_ASYNC=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_0_INTERRUPT_DRIVEN=n
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
# Enable I2C
CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_NRFX_TWIM=y
CONFIG_NRFX_TWIM0=y
CONFIG_NRFX_TWIM1=n
CONFIG_NRFX_PRS=y
CONFIG_NRFX_PRS_BOX_0=y
# Heap memory pool and Stack memory size 256/1024/4096/16384
CONFIG_HEAP_MEM_POOL_SIZE=1024