Skip to content

Commit f2dfe12

Browse files
Initial commit for the quadrature decoder sample code. For more info refer to the readme file.
1 parent f458802 commit f2dfe12

22 files changed

+2549
-0
lines changed

features/quadrature_decoder_sample_code/.cproject

Lines changed: 617 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>quadrature_decoder_sample_code</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
<buildCommand>
15+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
16+
<triggers>full,incremental,</triggers>
17+
<arguments>
18+
</arguments>
19+
</buildCommand>
20+
</buildSpec>
21+
<natures>
22+
<nature>org.eclipse.cdt.core.cnature</nature>
23+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
24+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
25+
</natures>
26+
<linkedResources>
27+
<link>
28+
<name>sdk</name>
29+
<type>2</type>
30+
<locationURI>virtual:/virtual</locationURI>
31+
</link>
32+
<link>
33+
<name>startup</name>
34+
<type>2</type>
35+
<locationURI>SDKROOT/sdk/bsp/startup</locationURI>
36+
</link>
37+
<link>
38+
<name>sdk/FreeRTOS</name>
39+
<type>2</type>
40+
<locationURI>SDKROOT/sdk/free_rtos</locationURI>
41+
</link>
42+
<link>
43+
<name>sdk/adapters</name>
44+
<type>2</type>
45+
<locationURI>SDKROOT/sdk/middleware/adapters</locationURI>
46+
</link>
47+
<link>
48+
<name>sdk/bsp_include</name>
49+
<type>2</type>
50+
<locationURI>SDKROOT/sdk/bsp/include</locationURI>
51+
</link>
52+
<link>
53+
<name>sdk/cli</name>
54+
<type>2</type>
55+
<locationURI>SDKROOT/sdk/middleware/cli</locationURI>
56+
</link>
57+
<link>
58+
<name>sdk/config</name>
59+
<type>2</type>
60+
<locationURI>SDKROOT/sdk/bsp/config</locationURI>
61+
</link>
62+
<link>
63+
<name>sdk/console</name>
64+
<type>2</type>
65+
<locationURI>SDKROOT/sdk/middleware/console</locationURI>
66+
</link>
67+
<link>
68+
<name>sdk/ldscripts</name>
69+
<type>2</type>
70+
<locationURI>SDKROOT/sdk/bsp/ldscripts/non_ble_projects</locationURI>
71+
</link>
72+
<link>
73+
<name>sdk/memory</name>
74+
<type>2</type>
75+
<locationURI>SDKROOT/sdk/bsp/memory</locationURI>
76+
</link>
77+
<link>
78+
<name>sdk/middleware_config</name>
79+
<type>2</type>
80+
<locationURI>SDKROOT/sdk/middleware/config</locationURI>
81+
</link>
82+
<link>
83+
<name>sdk/osal</name>
84+
<type>2</type>
85+
<locationURI>SDKROOT/sdk/middleware/osal</locationURI>
86+
</link>
87+
<link>
88+
<name>sdk/peripherals</name>
89+
<type>2</type>
90+
<locationURI>SDKROOT/sdk/bsp/peripherals</locationURI>
91+
</link>
92+
<link>
93+
<name>sdk/sys_man</name>
94+
<type>2</type>
95+
<locationURI>SDKROOT/sdk/bsp/system/sys_man</locationURI>
96+
</link>
97+
<link>
98+
<name>sdk/util</name>
99+
<type>2</type>
100+
<locationURI>SDKROOT/sdk/bsp/util</locationURI>
101+
</link>
102+
</linkedResources>
103+
<variableList>
104+
<variable>
105+
<name>SDKROOT</name>
106+
<value>$%7BWORKSPACE_LOC%7D</value>
107+
</variable>
108+
</variableList>
109+
</projectDescription>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Quadrature Decoder (QDEC) Sample Code
2+
3+
This sample code demonstrates using the quadrature decoder peripheral supported by the DA1459x family of devices. The decoder can decode three pairs of axes as illustrated below reporting step count and direction. The decoder can forward a triggering signal to the PDC block upon movement detection on any of the three axes. Thus, exiting the device from the sleep state.
4+
5+
<img src="assets\QDEC_block_diagram.PNG" style="zoom: 67%;" />
6+
7+
For this example, the [KNOB G Click](https://www.mikroe.com/knob-g-click) rotary encoder is demonstrated and is connected to the X axis. The rest of the axes are disabled and left unconnected. The axis selection is arbitrary and developers are free to employ any of the supported axes. Each pair of axes can be routed to a list of pre-defined I/O pins and should automatically be handled by the QDEC upon enabling them. For more info on the integrated decoder block please refer to the [datasheet](https://www.renesas.com/us/en/products/wireless-connectivity/bluetooth-low-energy/da14592-016fdevkt-p-smartbond-da14592-bluetooth-low-energy-52-soc-development-kit-pro#documents). The following picture depicts the I/O connection between the rotary encoder module and the DA14592 PRO DevKit. Although the motherboard exhibits a mikroBUS connector which can be used to directly connect to click boards, such a topology is not feasible as the supported QDEC I/O pins are not routed to the mikroBUS connector. As such, a few female-female jumper wires should be used for the connection.
8+
9+
<img src="assets\KNOB_G_CLICK.PNG" style="zoom:80%;" />
10+
11+
To facilitate users, all I/O pins definitions are done through pre-processor directives which can be found in the `knob_G_click_config` configuration file. Users are free to change any of the default values by re-defining the corresponding macro(s) in the customer's configuration file, that should be `customer_config_xxx.h`. The following picture illustrates the file tree of the demonstrated example (apart from the `main` and `platform_devices` source files which can be found in every sample code that demonstrates using a peripheral block). The demonstration example exhibits all the capabilities of the rotary encoder module which can be enabled/disable per demand via the corresponding pre-processor directives as defined in `knob_G_click_config`. By default, all features should be enabled.
12+
13+
<img src="assets\file_tree.PNG" style="zoom: 25%;" />
14+
15+
16+
17+
1. The `knob_G_click_key` folder contains all the functionality required to support the push button by employing the WKUP controller. The main application task can get notifications on KEY events, reported by the WKUP, by registering a callback function that is called from with the WKUP ISR. To do so, the `knob_G_click_key_register_cb` API is called once and the `app_kbob_G_click_key_callback` application-defined callback function is called upon KEY events. In this example, the registered callback toggles the triggering polarity and OSAL notifications are used to further process the press and release events. The main functionality of the push button is to change the LEDs state.
18+
2. The `knob_G_click_led` folder contains all the functionality required to support the LED driver IC (PCA9956B), which drivers the 24-segment LED ring mounted on the underlying module. Please note that the current implementation supports only the basic functionality that includes resetting, turning on/off an individual or all LEDs as well as controlling the brightness of a LED. Providing full drivers for the [PCA9956B](https://download.mikroe.com/documents/datasheets/PCA9956B.pdf) IC is out of the scope of the demonstration example. Developer are free to provide more functionality by updating the `knob_G_click_led.x` files. Please note that the drivers implementation has been structured in such a way so that the underlying I2C controller is totally agnostic to the PCA9956B driver source files. This is achieved by using function pointers defined in the porting layer implemented in the `knob_G_click_led_port.c` source file. The DA14592 SoC integrated a single I2C block instance which can operate either in master or slave role on the I2C bus. The `knonb_G_click_port.c` source file exhibits the `app_knob_G_click_led_update` routine which is invoked upon QDEC events reported by the QDEC controller (that should occur when the rotary is rotated in either direction). This routine handles the state of the LEDs according to the current state selected by the push button. Currently three LED states are supported as follows:
19+
- `KEY STATE 0`: The brightness on all LEDs is increased/decreased by moving the rotary counterclockwise and clockwise respectively.
20+
- `KEY STATE 1`: A single LED is turned ON at a time reflecting the current position of the encoder.
21+
- `KEY STATE 2`: LEDs should be turned ON one-by-one as the rotary is rotated counterclockwise and be turned OFF one-by-one as the rotary is rotated clockwise.
22+
3. This files contains all the I/O pins selection along with pre-processor directives that can enable/disable the KEY and LED features per demand and thus, saving code space.
23+
4. This file should contain the main application task which registers the user-defined WKUP callback function and initialized the LED driver.
24+
25+
## HW and SW Configuration
26+
27+
- **Hardware Configuration**
28+
- This example runs on DA1459x family of devices.
29+
- A Pro development kit is needed for this example.
30+
- **Software Configuration**
31+
- Download the latest SDK version for the target family of devices.
32+
33+
- SEGGER J-Link tools are normally downloaded and installed as part of the e2 Studio installation.
34+
35+
## How to run the example
36+
37+
### Initial Setup
38+
39+
- Download the source code from the Support Website.
40+
- Import the project into your workspace (there should be no path dependencies).
41+
- Connect the target device to your host PC via USB1. The mentioned port is used to power the device as well as to support debugging (JTAG) and serial functionality (UART).
42+
- Compile the code (either in Release or Debug mode) and load it into the chip.
43+
- Open a serial terminal (115200/8 - N - 1)
44+
- Press the reset button on the daughter board to start executing the application.
45+
- Use the serial console to interact with the device.
46+
- Rotate the rotary in either direction to increase/decrease the brightness on all LEDs.
47+
- Press the push button once to move to the next KEY state. Rotate the rotary in either direction to move a single LED reflecting the current rotary position.
48+
- Press the push button to move to the last supported KEY state which should turn ON/OFF the LEDs one-by-one reflecting the current rotary position.
49+
- Pressing the push button once more will reset the KEY state to the initial state.
50+
51+
## Known Limitations
52+
53+
The mikroBUS connector of the PRO development kit cannot route any of the supported QDEC signals and thus the demonstrated rotary encoder module should be connected via jumper wires.
Loading
Loading
Loading
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
****************************************************************************************
3+
*
4+
* @file custom_config_eflash.h
5+
*
6+
* @brief Board Support Package. User Configuration file for cached eFLASH mode.
7+
*
8+
* Copyright (C) 2020-2024 Renesas Electronics Corporation and/or its affiliates.
9+
* All rights reserved. Confidential Information.
10+
*
11+
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
12+
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
13+
* revocable, non-sub-licensable right and license to use the Software, solely if used in
14+
* or together with Renesas products. You may make copies of this Software, provided this
15+
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
16+
* reserves the right to change or discontinue the Software at any time without notice.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
19+
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
21+
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
22+
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
25+
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
26+
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
27+
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
28+
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
29+
* SOFTWARE.
30+
*
31+
****************************************************************************************
32+
*/
33+
#ifndef CUSTOM_CONFIG_EFLASH_H_
34+
#define CUSTOM_CONFIG_EFLASH_H_
35+
36+
#include "bsp_definitions.h"
37+
38+
#define CONFIG_RETARGET
39+
#define DBG_PRINT_ENABLE ( 1 )
40+
#define DBG_IO_ENABLE ( 1 )
41+
42+
/* Make sure the console task has always higher priority than the application task
43+
* so that the device can enter a deep sleep mode */
44+
#define CONSOLE_TASK_PRIORITY ( OS_TASK_PRIORITY_NORMAL + 1 )
45+
46+
/*************************************************************************************************\
47+
* System configuration
48+
*/
49+
#define dg_configEXEC_MODE ( MODE_IS_CACHED )
50+
#define dg_configCODE_LOCATION ( NON_VOLATILE_IS_EMBEDDED_FLASH )
51+
52+
#define dg_configUSE_WDOG ( 1 )
53+
#define dg_configUSE_SW_CURSOR ( 1 )
54+
55+
/*************************************************************************************************\
56+
* FreeRTOS configuration
57+
*/
58+
#define OS_FREERTOS /* Define this to use FreeRTOS */
59+
#define configTOTAL_HEAP_SIZE ( 14000 ) /* FreeRTOS Total Heap Size */
60+
61+
/*************************************************************************************************\
62+
* Peripherals configuration
63+
*/
64+
#define dg_configFLASH_ADAPTER ( 0 )
65+
#define dg_configNVMS_ADAPTER ( 0 )
66+
#define dg_configNVMS_VES ( 0 )
67+
#define dg_configNVPARAM_ADAPTER ( 0 )
68+
69+
#define dg_configUSE_HW_QUAD ( 1 )
70+
#define dg_configI2C_ADAPTER ( 1 )
71+
#define dg_configUSE_HW_I2C ( 1 )
72+
73+
/* Include bsp default values */
74+
#include "bsp_defaults.h"
75+
/* Include middleware default values */
76+
#include "middleware_defaults.h"
77+
78+
#endif /* CUSTOM_CONFIG_EFLASH_H_ */
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
****************************************************************************************
3+
*
4+
* @file custom_config_ram.h
5+
*
6+
* @brief Board Support Package. User Configuration file for SYSRAM mode.
7+
*
8+
* Copyright (C) 2020-2024 Renesas Electronics Corporation and/or its affiliates.
9+
* All rights reserved. Confidential Information.
10+
*
11+
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
12+
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
13+
* revocable, non-sub-licensable right and license to use the Software, solely if used in
14+
* or together with Renesas products. You may make copies of this Software, provided this
15+
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
16+
* reserves the right to change or discontinue the Software at any time without notice.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
19+
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
21+
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
22+
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
25+
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
26+
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
27+
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
28+
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
29+
* SOFTWARE.
30+
*
31+
****************************************************************************************
32+
*/
33+
#ifndef CUSTOM_CONFIG_RAM_H_
34+
#define CUSTOM_CONFIG_RAM_H_
35+
36+
#include "bsp_definitions.h"
37+
38+
#define CONFIG_RETARGET
39+
#define DBG_PRINT_ENABLE ( 1 )
40+
#define DBG_IO_ENABLE ( 1 )
41+
42+
#define dg_configCODE_LOCATION ( NON_VOLATILE_IS_NONE )
43+
#define dg_configFLASH_CONNECTED_TO ( FLASH_IS_NOT_CONNECTED )
44+
45+
#define dg_configUSE_WDOG ( 1 )
46+
#define dg_configUSE_SW_CURSOR ( 1 )
47+
48+
/*************************************************************************************************\
49+
* FreeRTOS specific config
50+
*/
51+
#define OS_FREERTOS /* Define this to use FreeRTOS */
52+
#define configTOTAL_HEAP_SIZE ( 14000 ) /* This is the FreeRTOS Total Heap Size */
53+
54+
/*************************************************************************************************\
55+
* Peripheral specific config
56+
*/
57+
#define dg_configFLASH_ADAPTER ( 0 )
58+
#define dg_configNVMS_ADAPTER ( 0 )
59+
#define dg_configNVMS_VES ( 0 )
60+
#define dg_configNVPARAM_ADAPTER ( 0 )
61+
62+
#define dg_configUSE_HW_QUAD ( 1 )
63+
#define dg_configI2C_ADAPTER ( 1 )
64+
#define dg_configUSE_HW_I2C ( 1 )
65+
66+
/* Include bsp default values */
67+
#include "bsp_defaults.h"
68+
/* Include middleware default values */
69+
#include "middleware_defaults.h"
70+
71+
#endif /* CUSTOM_CONFIG_RAM_H_ */

0 commit comments

Comments
 (0)