要将多个 OSS-ECAL(具有不同 MCU 功能的电子元件)纳入用户程序,请参考以下示例。
Exe : 电子元件 ABC1 传感器(ADC 型),ABC2 传感器(SPI 型),HAL Renesas SSP

Step1 创建文件夹
1 为 OSS-ECAL 创建文件夹(文件夹名称自定)
2 为 ABC1 和 ABC2 创建文件夹

Step2 复制 ABC1 文件
1 ABC1 文件复制到 ABC1 文件夹

Step3 复制 ABC2 文件
1 ABC2 文件复制到 ABC2 文件夹

Step4 复制通用文件
1. 复制最新版本的 “oss_ecal.h” 和 “OSS-ECAL 使用条款.txt”。
2. 从 ABC1 复制 “user_setting.c “和 “user_setting.c

Step5 “user_setting.h” 包含 ABC1 和 ABC2 的 MCU 设置
根据 ABC1 的 MCU 设置,在 “user_setting.h “中配置以下设置。
1. 将 ADC_VDD 设置为 MCU VDD 电压 3.3
2. 将 ADC_BIT 设置为 MCU ADC 位长 12
3. 将 ADC_ABC1 设置为用于 ABC1 的 ADC 组 g_adc0
4. 将 ADC_ABC1_CH 设置为用于 ABC1 的 ADC 通道 ADC_REG_CHANNEL_0
5. 从 ABC2“user_setting.h”复制以下代码
6. 将 SPI_ABC2 设置为用于 ABC2 的 SPI 通信通道 g_spi0
7. 将 GPIO_ABC2_CS 设置为 ABC2 的 /CS 使用的 GPIO 端口 g_ioport
8. 将 PIN_ABC2_CS 设置为用于 ABC2 的 /CS 的 GPIO 端口引脚 IOPORT_PORT_01_PIN_03
9. 将 SPI_RETRY 设置为 3 次重试,以进行 SPI 通信
/*-- File Header Comment Start -----------------------------------------------*/
// File Name : user_setting.h
// Reason for change: 01.00.00 : 15/11/'23 : New Release
// Specifications : -
// HAL : Renesas SSP
// Terms of Use : OSS-ECAL Terms of Use.txt
// Nickname : Blue Dragon
/*-- File Header Comment End -------------------------------------------------*/
// Define to prevent recursive inclusion
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ifndef __USER_SETTING_H__
#define __USER_SETTING_H__
// Includes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "oss_ecal.h"
#include <hal_data.h>
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
// Immediate definitions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ADC components common setting
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define ADC_VDD 3.3F // MCU Vdd Configures the reference voltage [V]
#define ADC_BIT 12U // MCU ADC bit Note:iADC_bit is set according to MCU
// Hardware setting by user
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// OSS-ECAL DIO hard wiring
// OSS-ECAL ADC components hard wiring
#define CMP_ADC_NUM 1U // OSS-ECAL ADC components number
#define ADC_ABC1 g_adc0 // ADC Group control( g_adc0 : Generated by configuration )
#define ADC_ABC1_CH ADC_REG_CHANNEL_0 // ABC1 : MCU ADC Channel
// OSS-ECAL SPI components hard wiring
#define CMP_SPI_NUM 1U // OSS-ECAL SPI components number
#define SPI_ABC2 g_spi0 // SPI control( g_spi0 : Generated by configuration )
#define GPIO_ABC2_CS g_ioport // GPIO control( g_ioport : Generated by configuration )
#define PIN_ABC2_CS IOPORT_PORT_01_PIN_03 // ABC2 /CS : MCU Digital Out Pin
// OSS-ECAL I2C components hard wiring
// OSS-ECAL Wake-up components hard wiring
// Communication setting by user
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// SPI settings
#define SPI_RETRY 3 // Retry times
// Typedef definitions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ADC components object struct
typedef struct
{
etCMP cmp; // Components number codes
const adc_instance_t* obj; // ADC object of SSP
adc_register_t const pin; // ADC channel of SSP
}stADC_SSP_OBJ;
// SPI components object struct
typedef struct
{
etCMP cmp; // Components number codes
const spi_instance_t* obj; // SPI object of SSP
const ioport_instance_t* gpio; // SPI /CS pin object of SSP
ioport_port_pin_t pin_cs; // SPI /CS pin of SSP
}stSPI_SSP_OBJ;
// External constants data
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern const stADC_SSP_OBJ tblADC[ CMP_ADC_NUM ];
extern const stSPI_SSP_OBJ tblSPI[ CMP_SPI_NUM ];
// Exported global variables
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Exported public functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif /* __USER_SETTING_H__ */
Step6 在 “user_setting.c “中添加了 ABC2 信息
- #include Path change(路径更改)。
- ABC2 #include已添加
- 将 ABC2 添加到 tblADC
const stSPI_SSP_OBJ tblSPI[ CMP_SPI_NUM ] =
{
{ eABC2 , &SPI_ABC2 , &GPIO_ABC2_CS , PIN_ABC2_CS }
};
/*-- File Header Comment Start -----------------------------------------------*/
// File Name : user_setting.c
// Reason for change: 01.00.00 : 15/11/'23 : New Release
// Specifications : -
// HAL : Renesas SSP
// Terms of Use : OSS-ECAL Terms of Use.txt
// Nickname : Blue Dragon
/*-- File Header Comment End -------------------------------------------------*/
// Includes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "ABC1/oABC1.h"
#include "ABC2/oABC2.h"
// Static variables declaration
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Global variables declaration
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Static constants data declaration
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Global constants data declaration
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// HAL GPIO object table for components
// HAL ADC object table for components
const stADC_SSP_OBJ tblADC[ CMP_ADC_NUM ] =
{
{ eABC1 , &ADC_ABC1 , ADC_ABC1_CH }
};
// HAL SPI object table for components
const stSPI_SSP_OBJ tblSPI[ CMP_SPI_NUM ] =
{
{ eABC2 , &SPI_ABC2 , &GPIO_ABC2_CS , PIN_ABC2_CS }
};
// HAL I2C object table for components
// Private functions prototypes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Public functions prototypes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Functions program
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step7 增加 oABC1 和 oABC2 函数
1. 在用户程序头文件中加入 ABC1 和 ABC2 头文件。
// user program header
#include "../oABC1.h"
#include "../oABC2.h"
2. 参照 ABC1 中的 “sample.c”,为应用程序添加 API 函数。
// user application program
etSTS sts = oABC1( eCMD_START_READ, &vgPHY1 );
或添加命令型 API 函数。
// user application program
etSTS sts = oABC1_START_READ( &vgPHY1 );
3. 参照 ABC2 “sample.c”,在应用程序中添加 API 函数。
// user application program
etSTS sts = oABC2( eCMD_START_READ, &vgPHY2 );
或添加命令型 API 函数。
// user application program
etSTS sts = oABC2_START_READ( &vgPHY2 );