如何在用户程序中整合多个 OSS-ECAL(相同的 MCU 功能)

要将多个 OSS-ECAL(具有相同 MCU 功能的电子元件)纳入用户程序,请参考以下示例。

Exe : 电子元件 ABC1 传感器(ADC 型),ABC2 传感器(ADC 型),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. 将 CMP_ADC_NUM 设置为 ADC 类型的 OSS-ECAL 编号 2
4. 将 ADC_ABC1 设置为用于 ABC1 的 ADC 组 g_adc0
5. 将 ADC_ABC1_CH 设置为用于 ABC1 的 ADC 通道 ADC_REG_CHANNEL_0
6. 从 ABC2 的 “user_setting.h “中复制 ADC_ABC2 和 ADC_ABC2_CH 的 #define 行
7. 将 ADC_ABC2 设置为用于 ABC2 的 ADC 组 g_adc0
8. 将 ADC_ABC2_CH 设置为用于 ABC2 的 ADC 通道 ADC_REG_CHANNEL_1

/*-- 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             2U              // 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

#define ADC_ABC2                g_adc0          // ADC Group control( g_adc0 : Generated by configuration )
#define ADC_ABC2_CH             ADC_REG_CHANNEL_1 // ABC2 : MCU ADC Channel

// OSS-ECAL SPI components hard wiring

// OSS-ECAL I2C components hard wiring

// OSS-ECAL Wake-up components hard wiring


// Communication setting by user
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


// 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;


// External constants data
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern const stADC_SSP_OBJ      tblADC[ CMP_ADC_NUM ];


// Exported global variables
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


// Exported public functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


#if defined(__cplusplus)
}
#endif /* __cplusplus */

#endif /* __USER_SETTING_H__ */

Step6 在 “user_setting.c “中添加了 ABC2 信息

  1. #include Path change(路径更改)。
  2. ABC2 #include已添加
  3. 将 ABC2 添加到 tblADC
/*-- 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      },
        { eABC2    , &ADC_ABC2        , ADC_ABC2_CH      }
};

// HAL SPI object table for components

// 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 );
OSS-ECAL Chinese
error: 内容受保护 !