Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPCCSE-267-da1459x-spi-read-write-example-lsm6dsl #8

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
361 changes: 361 additions & 0 deletions interfaces/spi_write_read_example/.cproject

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions interfaces/spi_write_read_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
jlink.log
.settings
DA1459x-00-Debug_RAM
DA1459x-00-Debug_eFlash
/DA1459x-00-Release_eFLASH/
/DA1459x-00-Debug_eFLASH/
105 changes: 105 additions & 0 deletions interfaces/spi_write_read_example/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>spi_write_read_example</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.renesas.cdt.dialogsdk.dialogsdkBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>com.renesas.cdt.dialogsdk.dialogsdkNature</nature>
</natures>
<linkedResources>
<link>
<name>sdk</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>startup</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/startup</locationURI>
</link>
<link>
<name>sdk/FreeRTOS</name>
<type>2</type>
<locationURI>SDKROOT/sdk/free_rtos</locationURI>
</link>
<link>
<name>sdk/adapters</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/adapters</locationURI>
</link>
<link>
<name>sdk/bsp_include</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/include</locationURI>
</link>
<link>
<name>sdk/config</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/config</locationURI>
</link>
<link>
<name>sdk/ldscripts</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/ldscripts/non_ble_projects</locationURI>
</link>
<link>
<name>sdk/memory</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/memory</locationURI>
</link>
<link>
<name>sdk/middleware_config</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/config</locationURI>
</link>
<link>
<name>sdk/osal</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/osal</locationURI>
</link>
<link>
<name>sdk/peripherals</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/peripherals</locationURI>
</link>
<link>
<name>sdk/sys_man</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/system/sys_man</locationURI>
</link>
<link>
<name>sdk/util</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/util</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>SDKROOT</name>
<value>$%7BWORKSPACE_LOC%7D</value>
</variable>
</variableList>
</projectDescription>
76 changes: 76 additions & 0 deletions interfaces/spi_write_read_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
SPI Adapter Write Read Example
==============================

## Overview

This example implements a simple write and read communication scenario over
the SPI interface using the SPI adapter layer. For this demonstration the LSM6DSL ClickBoard is used. For more details about this module, you can visit [this link](https://www.mikroe.com/lsm6dsl-click).

The SPI interface is configured in the master role while LSM6DSL is used as an SPI slave. Button K1 is configured as a Wake Up button.

Upon pressing the K1 button, the SPI master begins a write operation to transmit a read command for accessing the WHO_AM_I register. Following this, it initiates a read operation to retrieve the value of the WHO_AM_I register. The data that is written and subsequently read is then displayed on the UART terminal.

## HW and SW configuration
* **Hardware configuration**

- This example runs on the DA14592 Bluetooth Smart SoC devices.
- The DA14592 Pro Development kit is needed for this example.
- Connect the Development kit to the host computer.
- Make sure the right jumpers are placed on J15 and J16.

**UART terminal with the following settings is needed to observe the master task printouts**

| Setting | Value |
|:------------:|:--------:|
| Baudrate | 115200 |
| Data bits | 8 |
| Stop bits | 1 |
| Parity | None |

**The following pin configuration is according to the ClickBoard connector provided on the DA14592 Development kit. The pins settings are located in `peripheral_setup.h`**

| DA14592 | LSM6DSL |
|:-----------: |:------------:|
| Master | Slave |
| P0_00 (CS) | CS |
| P0_01 (CLK) | SCK |
| P0_02 (MISO) | SDO |
| P0_03 (MOSI) | SDI |

___________________
| LSM6DSL |
| |
| CS SCK SDO SDI |
|___________________|
| | | |
_____________ | | | |
| CS |----------------' | | |
| CLK|---------------------' | |
|DA14592 MISO|-------------------------' |
| MOSI|------------------------------'
'_____________'

* **Software configuration**
- e²Studio 2023-10 or greater.
- SDK 10.1.2.x
- **SEGGER J-Link** tools should be downloaded and installed.

## How to run the example

### Initial Setup

- Download the source code from the Github.
- Import the project into your workspace.
- Compile and launch eFLASH target.
- Program the eFLASH and run the example.

Logic analyzer trace of SPI operation:

<img src="assets/sniffer_log.PNG">

The UART will show the following output on K1 button press:

<img src="assets/teraterm.PNG" width="500">



Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions interfaces/spi_write_read_example/config/custom_config_eflash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
****************************************************************************************
*
* @file custom_config_eflash.h
*
* @brief Board Support Package. User Configuration file for cached eFLASH mode.
*
* Copyright (C) 2020-2024 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/

#ifndef CUSTOM_CONFIG_EFLASH_H_
#define CUSTOM_CONFIG_EFLASH_H_

#include "bsp_definitions.h"

#define CONFIG_RETARGET

#define dg_configEXEC_MODE MODE_IS_CACHED
#define dg_configCODE_LOCATION NON_VOLATILE_IS_EMBEDDED_FLASH

#define dg_configUSE_WDOG (1)

#define dg_configUSE_SW_CURSOR (1)

/*************************************************************************************************\
* FreeRTOS specific config
*/
#define OS_FREERTOS /* Define this to use FreeRTOS */
#define configTOTAL_HEAP_SIZE 14000 /* This is the FreeRTOS Total Heap Size */

/*************************************************************************************************\
* Peripheral specific config
*/
#define dg_configRF_ENABLE_RECALIBRATION (0)
#define dg_configUSE_HW_SPI (1)
#define dg_configSPI_ADAPTER (1)
#define dg_configFLASH_ADAPTER (0)
#define dg_configNVMS_ADAPTER (0)
#define dg_configNVMS_VES (0)

#define DBG_PRINT_ENABLE ( 1 )

/* Include bsp default values */
#include "bsp_defaults.h"
/* Include middleware default values */
#include "middleware_defaults.h"

#endif /* CUSTOM_CONFIG_EFLASH_H_ */
49 changes: 49 additions & 0 deletions interfaces/spi_write_read_example/config/peripheral_setup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
****************************************************************************************
*
* @file periph_setup.h
*
* @brief Configuration of devices connected to board
*
* Copyright (C) 2020-2024 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/

#ifndef PERIPHERAL_SETUP_H_
#define PERIPHERAL_SETUP_H_

#define LSM6DSL_DO_PORT ( HW_GPIO_PORT_0 )
#define LSM6DSL_DO_PIN ( HW_GPIO_PIN_2 )

#define LSM6DSL_DI_PORT ( HW_GPIO_PORT_0 )
#define LSM6DSL_DI_PIN ( HW_GPIO_PIN_3 )

#define LSM6DSL_CLK_PORT ( HW_GPIO_PORT_0 )
#define LSM6DSL_CLK_PIN ( HW_GPIO_PIN_0 )

#define LSM6DSL_CS_PORT ( HW_GPIO_PORT_0 )
#define LSM6DSL_CS_PIN ( HW_GPIO_PIN_1 )

#endif /* PERIPHERAL_SETUP_H_ */
Loading
Loading