PUREmodules‎ > ‎

How to add PureModules to any Nrf52 project

This tutorial will outline the steps for adding PureModules functionality to any project on the NRF52 SDK. 

For the purposes of this tutorial I will add PureModules to the Blinky Project in the nRF5_SDK_12.2.0_f012efa SDK provided by Nordic.  

Step 1- Download and organize files.

From Scratch:
Step 1 can be accomplished by following this tutorial that outlines the steps for setting up the environment: 
http://www.pureengineering.com/puremodules/nrfcodesetup 

If you already have the SDK setup on your computer:
- Simply download the PureModules repo:
https://github.com/PureEngineering/PUREmodules

-Move the modules_examples and modules_libraries folders into a directory above your SDK location as shown in the image below. 


Step 2- Prepare Blinky Project MakeFile. 

    - 2A - Navigate to the Makefile of the project you would like to add PureModules to. This tutorial will use the Blinky Project. In my case I navigate to:
    > cd [YOURSDKDIRECTORY]\nRF5_SDK_12.2.0_f012efa\examples\peripheral\blinky\pca10040\s132\armgcc

    -Lets alter the Makefile to add PureModules. Open your Makefile with your choice of TextEditor. 

    - 2B- Add the Modules_Library directory by first adding LIB_DIR variable as shown below. 

                                LIB_DIR  := ../../../../../../../modules_libraries


    - 2C - Add the Module files to the SRC_FILES as shown below.
  
  $(LIB_DIR)/i2c_driver.c \
  $(LIB_DIR)/lis3mdl.c \
  $(LIB_DIR)/lis2de.c \
  $(LIB_DIR)/vl53l0.c \
  $(LIB_DIR)/si1153.c \
  $(LIB_DIR)/veml6075.c \
  $(LIB_DIR)/bme280.c \
  $(LIB_DIR)/ble_driver.c \
  $(LIB_DIR)/supersensor.c \
  $(LIB_DIR)/apds9250.c \



 - 2D- Add twi (i2c) code and BLE code to the project under SRC_FILES above the PureModules

  $(SDK_ROOT)/components/drivers_nrf/twi_master/nrf_drv_twi.c \
  $(SDK_ROOT)/components/drivers_nrf/twis_slave/nrf_drv_twis.c \
  $(SDK_ROOT)/components/ble/common/ble_advdata.c \
  $(SDK_ROOT)/components/ble/ble_advertising/ble_advertising.c \
  $(SDK_ROOT)/components/ble/common/ble_conn_params.c \
  $(SDK_ROOT)/components/ble/common/ble_srv_common.c \
  $(SDK_ROOT)/components/ble/ble_services/ble_nus/ble_nus.c \
  

Step 3- Configure sdk_config.h file to enable bluetooth and twi communication
sdk_config file is found here:
[YOURDIRECTORY[\nRF5_SDK_12.2.0_f012efa\examples\peripheral\blinky\pca10040\s132\config

Search for the variables and change the value to the designated value below:

#define BLE_ADVERTISING_ENABLED 1
#define BLE_NUS_ENABLED 1
#define GPIOTE_ENABLED 1 (0)
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4 (1)
#define TWIS_ENABLED 1
#define TWIS1_ENABLED 1
#define TWI_ENABLED 1
#define TWI0_ENABLED 1
#define APP_UART_ENABLED 1
#define BUTTON_ENABLED 1
#define FSTORAGE_ENABLED 1

For RTT print:
#define NRF_LOG_BACKEND_SERIAL_USES_UART 0
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 1

For UART print:
#define NRF_LOG_BACKEND_SERIAL_USES_UART 1
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0



Add this above APP_GPIOTE_ENABLED:

#ifndef APP_FIFO_ENABLED
#define APP_FIFO_ENABLED 1
#endif

Above: SLIP_ENABLED
// <q> RETARGET_ENABLED  - retarget - Retargeting stdio functions
 

#ifndef RETARGET_ENABLED
#define RETARGET_ENABLED 1
#endif





Comments