1# TWIM with TWIS TX-RX {#twim_twis_txrx}
2
3The sample demonstrates a functionality of nrfx_twim and nrfx_twis drivers, when TWI transfer is performed in the TX-RX mode.
4
5## Requirements
6
7The sample supports the following development kits:
8
9
10| **Board**           | **Support** |
11|---------------------|:-----------:|
12| nrf52dk_nrf52832    |     Yes     |
13| nrf52833dk_nrf52833 |     Yes     |
14| nrf52840dk_nrf52840 |     Yes     |
15| nrf5340dk_nrf5340   |     Yes     |
16| nrf9160dk_nrf9160   |     Yes     |
17
18## Overview
19
20Application initializes nrfx_twim and nrfx_twis drivers.
21The main purpose of this sample is to emulate a situation, in which you read data from particular registers of the slave (usual sensor -> controller communication using two wire interface).
22The sample works as a simple simulation in which you can communicate with a drone by reading the values from its individual registers.
23* @p m_drone_reg is used as an internal register map of the drone.
24  In the first operation, which is the write operation (TX), define a register number from which the data will be read in the read operation (RX).
25* @p twim_handler() is executed with relevant log messages.
26* @p twis_handler() is used to prepare data for receiving and sending.
27* @p register_read() function is used to write data from particular registers to buffer in master device and print content of that buffer.
28
29> For more information, see **TWIM driver** and **TWIS driver** - **nrfx documentation**.
30## Wiring
31
32To run the sample correctly, connect pins as follows:
33* `LOOPBACK_PIN_1A` with `LOOPBACK_PIN_1B`
34* `LOOPBACK_PIN_2A` with `LOOPBACK_PIN_2B`
35
36> Refer to pin definitions in `common/nrfx_example.h`.
37
38You should monitor the output from the board to check if it is as expected.
39
40## Building and running
41
42To run this sample, build it for the appropriate board and then flash it as per instructions in [Building and running](@ref building_and_running) section.
43
44## Sample output
45
46You should see the following output:
47
48```
49- "Starting nrfx_twim_twis txrx example."
50- "................................"
51- "DRONE REGISTERS:    DEC  |  HEX"
52- "drone_idx:          1    |  0x1"
53- "drone_mass:         10   |  0xA"
54- "x_force:            50   |  0x32"
55- "y_force:            100  |  0x64"
56- "z_force:            150  |  0x96"
57- "x_acceleration:     5    |  0x5"
58- "y_acceleration:     10   |  0xA"
59- "z_acceleration:     15   |  0xF"
60- "additional_data[0]: 239  |  0xEF"
61- "additional_data[1]: 190  |  0xBE"
62- "additional_data[2]: 173  |  0xAD"
63- "additional_data[3]: 222  |  0xDE"
64- "................................"
65- "Reading value of DRONE_REG_FORCE_X register:"
66- "--> Master event: done - transfer completed"
67- "ctrl buff: 0x32"
68- "..."
69- "Reading value of DRONE_REG_ACC_Y register:"
70- "--> Master event: done - transfer completed"
71- "ctrl buff: 0xA"
72- "..."
73- "Reading values of DRONE_REG_DATA registers:"
74- "--> Master event: done - transfer completed"
75- "ctrl buff: 0xDEADBEEF"
76- "..."
77```
78
79[//]: #
80[Building and running]: <../../../README.md#building-and-running>
81