nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
TWI Master Example

The TWI Master Example project demonstrates the initialization and reading of sensors using the a Two Wire Interface (TWI) driver.

Note
By default this example uses a bit-banged software TWI driver. The API is exactly the same for the hardware TWI driver. Therefore, twi_sw_master.c can be swapped out for the twi_hw_master.c to use on-chip hardware to achieve the same results.

Temperature sensor ds1624:

  • This example initializes the sensor ds1624_init. After initialization succeeds the temperature is read from the sensor register ds1624_temp_read. The read value is written to GPIO pins 14 to 8, where pin 8 is the lsb value of the temperature.

Touchpad sensor:

  • This example initializes the sensor touchpad_init. After initialization succeeded then we read the button status from sensor register. The read value is written to GPIO pin 15 (which can be connected to LED) when a button is pressed on the touch sensor.

Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

The touchpad pin setup:

  • SCL should be connected to PIN 24 (P3.0)
  • SDA should be connected to PIN 25 (P3.1)

LED assignments:

  • LED 0-7 shows error messages if initialization fails.
  • LED 0-6 shows the temperature value.
  • LED 7 shows is turned on when a button is pressed on the touch sensor.

Testing

TWI Master Example Application can be tested as follows:

  1. Compile and program the application.
  2. LED 0 to LED 6 should show the binary value of the temperature read from the ds1624 temperature sensor.
  3. LED 7 should be turned on if a touchpad button (Behind the touchpad) is pressed.