The CSR1011 is a single mode Bluetooth Smart chip and this tutorial show how to access its GPIOs and trigger a Relay.
Step 1: Grove Relay
The component used in this tutorial was the Grove-Relay.This module is a digital normally-open switch. Through it, you can control circuit of high voltage with low voltage, say 5V on the controller. There is an indicator LED on the board, which will light up when the controlled terminals get closed.
Step 2: Hardware Scheme
To connect the relay module in the CSR1011 was designed a hardware to power the relay, because the CSR1011 is powered with 3v3 and the component needs 5v to work. On CSR the pin 4 (GPIO 10) was used to connect the relay.
Step 3: Installing the CSR UEnergy SDK
To handle application on CSR1011 is used the Integrated Development Environment (xIDE) supplied with μEnergy Software Development Kits (SDKs). The software is provided on the CD-ROM but can also be downloaded from here.
Step 4: Software Architecture
On CSR1011 the application communicates with firmware using API calls that are implemented using firmware callbacks for various events in the application life cycle. When a project is created some functions are already implemented, this functions are used in the life cycle of the application:
- AppPowerOnReset(): Application function called just after a power-on reset;
- AppInit(): This function is called every boot and should contain application initialisation;
- AppProcessSystemEvent(): Function called by firmware to process system-level events, like Low battery and PIO level change;
- AppProcessLmEvent(): Function used to handles communication link-related events from firmware;
- Timers:Run on top of the hardware timer with microsecond accuracy.
Step 5: Code Example to Handle GPIOs Access
The code available demonstrates how to configure and set the state of the GPIO to trigger a relay plugged in the GPIO10 of the CSR1011. To handle the access of the GPIOwere used functions availables on pio.h library on group__PIO__B.html at uEnergy SDK.