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