This project shows the implementation of an IR signal generator and 4x4 matrix key scan with BLE on our EFR32 devices. The expectation is to ensure the IR signal generator works well in cases with heavy BLE traffic.
- GSDK v4.4.0
- Third Party Hardware Drivers v2.0.0.0
- EFR32xG22 Wireless Gecko Radio Board.
- Silicon Labs Wireless Starter Kits.
- 4x4 Matrix 16 Keys Button Keypad.
- Infrared diode
Connect 4x4 Matrix 16 Keys Button Keypad and Infrared diode to WSTK board through the expansion header.
To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.
-
From the Launcher Home, add your hardware to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with the filter "ir generator".
-
Click Create button on both Bluetooth - IR Generator examples. Example project creation dialog pops up -> click Create and Finish and Project should be generated.
-
Build and flash this example to the board.
-
Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.
-
Copy all attached files in the inc and src folders into the project root folder (overwriting existing).
-
Import the GATT configuration:
-
Open the .slcp file in the project.
-
Select the CONFIGURATION TOOLS tab and open the Bluetooth GATT Configurator.
-
Find the Import button and import the attached gatt_configuration.btconf file.
-
-
Open the .slcp file. Select the SOFTWARE COMPONENTS tab and install the software components:
- [Services] → [IO Stream] → [IO Stream: USART] → default instance name: vcom
- [Application] → [Utility] → [Log]
- [Third Party Hardware Drivers] → [Miscellaneous] → [IR Generator (Silabs)]
- [Platform] → [Driver] → [Button] → [Simple Button] → default instance name: btn0 and btn1
-
Build and flash the project to your device.
Note:
- Make sure that the Third Party Hardware Drivers extension is added to the required SDK: Preferences > Simplicity Studio > SDKs.
- SDK Extension must be enabled for the project to install the [IR Generator (Silabs)] component.
- Do not forget to flash a bootloader to your board, see Bootloader for more information.
When a key is active (pressed), the GPIO interrupt wakes-up the system, then the key scan and key timer (10ms) start to work. When a key is available or a key is released, the key callback is invoked to indicate, which key is detected or released. After a key is released, the system backs to idle state again.
- Initialization.
- key_init() function initializes the keypad with 2 callback, set GPIO direction, and interrupt.
- key_wakeup_callback_t wakeup_cb, is called in GPIO IRQ. It starts the key timer.
- key_callback_t cb, is called in the key detection. It reports which key is detected or released.
- Running the key detection
- key_scan() function runs in a key time slice, checks which key and how long the key is pressed, then reports the key status.
Most of the time the system stays in an idle state. When an IR send is required, the system configures the stream according to the given data, then sends out all the stream bit. If no stop command is inputted, the system will repeat the stream. If no need to repeat the IR signal, the system will go back to the idle state.
- Initialization.
- ir_generate_init() function initializes the keypad with callback.
- code_t ir_code sets the IR protocol, currently supports NEC and SONY types only.
- ir_callback_t cb is called if one frame stream is sent.
- Running the IR generate
- ir_generate_stream() function configures the data that desires to send and start, repeats flag used in NEC IR protocol.
- ir_generate_stop() function can stop the IR generate.
In this example, IR stream start/stop is controlled by a key event. We can use Console window for tracking the run status and logic analyzer/oscilloscope to check the IR waveform.