Skip to content

Commit 56e5027

Browse files
Aart-KleinendorstAart Kleinendorst
andauthored
added release/LPCCSE-224-da1459x-spi-example-dac-click (#1)
Co-authored-by: Aart Kleinendorst <Aart.Kleinendorst.xz@Renesas.com>
1 parent 0194d5e commit 56e5027

14 files changed

+1355
-0
lines changed

interfaces/spi_example/.cproject

Lines changed: 363 additions & 0 deletions
Large diffs are not rendered by default.

interfaces/spi_example/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
jlink.log
2+
DA1459x-00-Debug_RAM
3+
DA1459x-00-Debug_eFlash
4+
/DA1459x-00-Release_eFLASH/
5+
/DA1459x-00-Debug_eFLASH/

interfaces/spi_example/.project

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>spi_example</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.renesas.cdt.dialogsdk.dialogsdkBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
15+
<triggers>clean,full,incremental,</triggers>
16+
<arguments>
17+
</arguments>
18+
</buildCommand>
19+
<buildCommand>
20+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
21+
<triggers>full,incremental,</triggers>
22+
<arguments>
23+
</arguments>
24+
</buildCommand>
25+
</buildSpec>
26+
<natures>
27+
<nature>org.eclipse.cdt.core.cnature</nature>
28+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
29+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
30+
<nature>com.renesas.cdt.dialogsdk.dialogsdkNature</nature>
31+
</natures>
32+
<linkedResources>
33+
<link>
34+
<name>sdk</name>
35+
<type>2</type>
36+
<locationURI>virtual:/virtual</locationURI>
37+
</link>
38+
<link>
39+
<name>startup</name>
40+
<type>2</type>
41+
<locationURI>SDKROOT/sdk/bsp/startup</locationURI>
42+
</link>
43+
<link>
44+
<name>sdk/FreeRTOS</name>
45+
<type>2</type>
46+
<locationURI>SDKROOT/sdk/free_rtos</locationURI>
47+
</link>
48+
<link>
49+
<name>sdk/adapters</name>
50+
<type>2</type>
51+
<locationURI>SDKROOT/sdk/middleware/adapters</locationURI>
52+
</link>
53+
<link>
54+
<name>sdk/bsp_include</name>
55+
<type>2</type>
56+
<locationURI>SDKROOT/sdk/bsp/include</locationURI>
57+
</link>
58+
<link>
59+
<name>sdk/config</name>
60+
<type>2</type>
61+
<locationURI>SDKROOT/sdk/bsp/config</locationURI>
62+
</link>
63+
<link>
64+
<name>sdk/ldscripts</name>
65+
<type>2</type>
66+
<locationURI>SDKROOT/sdk/bsp/ldscripts/non_ble_projects</locationURI>
67+
</link>
68+
<link>
69+
<name>sdk/memory</name>
70+
<type>2</type>
71+
<locationURI>SDKROOT/sdk/bsp/memory</locationURI>
72+
</link>
73+
<link>
74+
<name>sdk/middleware_config</name>
75+
<type>2</type>
76+
<locationURI>SDKROOT/sdk/middleware/config</locationURI>
77+
</link>
78+
<link>
79+
<name>sdk/osal</name>
80+
<type>2</type>
81+
<locationURI>SDKROOT/sdk/middleware/osal</locationURI>
82+
</link>
83+
<link>
84+
<name>sdk/peripherals</name>
85+
<type>2</type>
86+
<locationURI>SDKROOT/sdk/bsp/peripherals</locationURI>
87+
</link>
88+
<link>
89+
<name>sdk/sys_man</name>
90+
<type>2</type>
91+
<locationURI>SDKROOT/sdk/bsp/system/sys_man</locationURI>
92+
</link>
93+
<link>
94+
<name>sdk/util</name>
95+
<type>2</type>
96+
<locationURI>SDKROOT/sdk/bsp/util</locationURI>
97+
</link>
98+
</linkedResources>
99+
<variableList>
100+
<variable>
101+
<name>SDKROOT</name>
102+
<value>$%7BWORKSPACE_LOC%7D</value>
103+
</variable>
104+
</variableList>
105+
</projectDescription>

interfaces/spi_example/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
SPI Adapter Sample Code
2+
=======================
3+
4+
## Example description
5+
6+
This application demonstrates using the SPI adapter concept. The sample code makes use of an SPI-compatible module, that is the MCP4921 DAC (digital-to-analog converter). A digital multimeter is used to verify the analog output generated.
7+
8+
### HW & SW Configurations
9+
10+
- **Hardware Configurations**
11+
- This example runs on a DA14592 Bluetooth Smart SoC.
12+
- A DA14592 Pro DevKit is needed for this example.
13+
- DAC Click boarch with MCP4921.
14+
- **Software Configurations**
15+
- Download the latest SDK version
16+
- Downlaod latest version of e2studio.
17+
18+
## How to run the example
19+
20+
### Initial Setup
21+
22+
- Download the source code from the Github.
23+
24+
- Import the project into your workspace.
25+
26+
- Connect the target device to your host PC.
27+
28+
- Connect the DAC module to the Pro DevKit as illustrated below.
29+
30+
![DAC Click](assets/dac-click-thickbox_default-12x)
31+
you can get more details about the DAC module https://www.mikroe.com/dac-click
32+
33+
- Compile the code and load it into the chip.
34+
35+
- Open a serial terminal (115200/8 - N - 1)
36+
37+
- Press the reset button on DevKit to start executing the application.
38+
39+
- Press the **K1** button on the Pro DevKit. A debugging message is displayed on the console indicating the status of the current SPI operation as well as the data (2 bytes) sent to the DAC module. The analog output value of the selected DAC channel, by default channel B, should be changed randomly.
40+
41+
![Debug Console](assets/debug_console.PNG)
42+
43+
## Known Limitations
44+
45+
There are no known limitations for this application.
Loading
50.2 KB
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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-2023 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+
34+
#ifndef CUSTOM_CONFIG_EFLASH_H_
35+
#define CUSTOM_CONFIG_EFLASH_H_
36+
37+
#include "bsp_definitions.h"
38+
39+
#define CONFIG_RETARGET
40+
41+
#define dg_configEXEC_MODE MODE_IS_CACHED
42+
#define dg_configCODE_LOCATION NON_VOLATILE_IS_EMBEDDED_FLASH
43+
44+
#define dg_configUSE_WDOG (1)
45+
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_configRF_ENABLE_RECALIBRATION (0)
58+
#define dg_configUSE_HW_SPI (1)
59+
#define dg_configSPI_ADAPTER (1)
60+
#define dg_configFLASH_ADAPTER (0)
61+
#define dg_configNVMS_ADAPTER (0)
62+
#define dg_configNVMS_VES (0)
63+
64+
#define MCP4921_MODULE_USED ( 1 )
65+
#define DBG_PRINT_ENABLE ( 1 )
66+
67+
/* Include bsp default values */
68+
#include "bsp_defaults.h"
69+
/* Include middleware default values */
70+
#include "middleware_defaults.h"
71+
72+
#endif /* CUSTOM_CONFIG_EFLASH_H_ */
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
****************************************************************************************
3+
*
4+
* @file periph_setup.h
5+
*
6+
* @brief Configuration of devices connected to board
7+
*
8+
* Copyright (C) 2020-2024 Renesas Electronics Corporation and/or its affiliates
9+
* The MIT License (MIT)
10+
*
11+
* Permission is hereby granted, free of charge, to any person obtaining a copy
12+
* of this software and associated documentation files (the "Software"), to deal
13+
* in the Software without restriction, including without limitation the rights
14+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
* copies of the Software, and to permit persons to whom the Software is
16+
* furnished to do so, subject to the following conditions:
17+
*
18+
* The above copyright notice and this permission notice shall be included in all
19+
* copies or substantial portions of the Software.
20+
*
21+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
27+
* OR OTHER DEALINGS IN THE SOFTWARE.
28+
****************************************************************************************
29+
*/
30+
31+
#ifndef PERIPHERAL_SETUP_H_
32+
#define PERIPHERAL_SETUP_H_
33+
34+
#define MCP4921_DO_PORT ( HW_GPIO_PORT_0 )
35+
#define MCP4921_DO_PIN ( HW_GPIO_PIN_2 )
36+
37+
#define MCP4921_DI_PORT ( HW_GPIO_PORT_0 )
38+
#define MCP4921_DI_PIN ( HW_GPIO_PIN_3 )
39+
40+
#define MCP4921_CLK_PORT ( HW_GPIO_PORT_0 )
41+
#define MCP4921_CLK_PIN ( HW_GPIO_PIN_0 )
42+
43+
#define MCP4921_CS_PORT ( HW_GPIO_PORT_0 )
44+
#define MCP4921_CS_PIN ( HW_GPIO_PIN_1 )
45+
46+
#endif /* PERIPHERAL_SETUP_H_ */
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
****************************************************************************************
3+
*
4+
* @file platform_devices.c
5+
*
6+
* @brief Configuration of devices connected to board data structures
7+
*
8+
* Copyright (c) 2022 Dialog Semiconductor. All rights reserved.
9+
*
10+
* This software ("Software") is owned by Dialog Semiconductor. By using this Software
11+
* you agree that Dialog Semiconductor retains all intellectual property and proprietary
12+
* rights in and to this Software and any use, reproduction, disclosure or distribution
13+
* of the Software without express written permission or a license agreement from Dialog
14+
* Semiconductor is strictly prohibited. This Software is solely for use on or in
15+
* conjunction with Dialog Semiconductor products.
16+
*
17+
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES OR AS
18+
* REQUIRED BY LAW, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE PROVIDED
21+
* IN A LICENSE AGREEMENT BETWEEN THE PARTIES OR BY LAW, IN NO EVENT SHALL DIALOG
22+
* SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR
23+
* CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
24+
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25+
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
26+
*
27+
***************************************************************************************
28+
*/
29+
30+
#include <ad_spi.h>
31+
#include "peripheral_setup.h"
32+
#include "platform_devices.h"
33+
34+
/*
35+
* PLATFORM PERIPHERALS GPIO CONFIGURATION
36+
*****************************************************************************************
37+
*/
38+
39+
/* SPI chip-select pins */
40+
static ad_io_conf_t cs_MCP4921[] = {{
41+
42+
.port = MCP4921_CS_PORT,
43+
.pin = MCP4921_CS_PIN,
44+
.on = {
45+
.mode = HW_GPIO_MODE_OUTPUT,
46+
.function = HW_GPIO_FUNC_GPIO,
47+
.high = true
48+
},
49+
.off = {
50+
.mode = HW_GPIO_MODE_OUTPUT,
51+
.function = HW_GPIO_FUNC_GPIO,
52+
.high = true
53+
},}
54+
};
55+
56+
/* SPI1 IO */
57+
static const ad_spi_io_conf_t bus_MCP4921 = {
58+
59+
.spi_do = {
60+
.port = MCP4921_DO_PORT,
61+
.pin = MCP4921_DO_PIN,
62+
.on = {HW_GPIO_MODE_OUTPUT_PUSH_PULL, HW_GPIO_FUNC_SPI_DO, false},
63+
.off = {HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_GPIO, true},
64+
},
65+
.spi_di = { // Not required
66+
.port = MCP4921_DI_PORT,
67+
.pin = MCP4921_DI_PIN,
68+
.on = {HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_SPI_DI, false},
69+
.off = {HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_GPIO, true},
70+
},
71+
.spi_clk = {
72+
.port = MCP4921_CLK_PORT,
73+
.pin = MCP4921_CLK_PIN,
74+
.on = {HW_GPIO_MODE_OUTPUT_PUSH_PULL, HW_GPIO_FUNC_SPI_CLK, false},
75+
.off = {HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_GPIO, true},
76+
},
77+
78+
/*
79+
* The number of pins in spi_master_cs array.
80+
*
81+
*/
82+
.cs_cnt = 1,
83+
.spi_cs = cs_MCP4921,
84+
};
85+
86+
/* External sensor/module SPI driver */
87+
static const ad_spi_driver_conf_t drv_MCP4921 = {
88+
.spi = {
89+
.cs_pad = { MCP4921_CS_PORT, MCP4921_CS_PIN },
90+
.word_mode = HW_SPI_WORD_16BIT, /* Required by the module used */
91+
.smn_role = HW_SPI_MODE_MASTER,
92+
.cpol_cpha_mode = HW_SPI_CP_MODE_3,
93+
.xtal_freq = 16, /* Operating freq. @ DIVN / xtal_freq = 4MHz */
94+
.fifo_mode = HW_SPI_FIFO_RX_TX,
95+
.disabled = 0, /* Should be disabled during initialization phase */
96+
.spi_cs = HW_SPI_CS_GPIO,
97+
.rx_tl = HW_SPI_FIFO_LEVEL0,
98+
.tx_tl = HW_SPI_FIFO_LEVEL0,
99+
.swap_bytes = false,
100+
.select_divn = true,
101+
.use_dma = true,
102+
.rx_dma_channel = HW_DMA_CHANNEL_0,
103+
.tx_dma_channel = HW_DMA_CHANNEL_0 + 1,
104+
}
105+
};
106+
/* Sensor/module device configuration */
107+
const ad_spi_controller_conf_t dev_MCP4921 = {
108+
.id = HW_SPI1,
109+
.io = &bus_MCP4921,
110+
.drv = &drv_MCP4921,
111+
};
112+
113+
spi_device MCP4921_DEVICE = &dev_MCP4921;

0 commit comments

Comments
 (0)