How to incorporate multiple OSS-ECALs in a user program (different MCU function)

To incorporate multiple OSS-ECALs (electronic components with the different MCU function) into a user program, refer to the following example.

Exe : Electronic Components ABC1 Sensor( ADC type ), ABC2 Sensor( SPI type ), HAL Renesas SSP

Step1 Create Folder

1 Create folder for OSS-ECAL (folder name is free)
2 Create folders for ABC1 and ABC2

Step2 Copy the ABC1 files

1 ABC1 files copy to ABC1 folder

Step3 Copy the ABC2 files

1 ABC2 files copy to ABC2 folder

Step4 Copy the Common files

1 Copy the latest version of “oss_ecal.h” and “OSS-ECAL Terms of Use.txt”
2 Copy “user_setting.c” and “user_setting.c” from ABC1

Step5 “user_setting.h” with MCU settings for ABC1 and ABC2

Configure the following settings in “user_setting.h” according to the MCU settings of ABC1.

1 Set ADC_VDD to MCU VDD voltage 3.3
2 Set ADC_BIT to MCU ADC bit length 12
3 Set ADC_ABC1 to the ADC Group g_adc0 used for ABC1
4 Set ADC_ABC1_CH to the ADC Channel ADC_REG_CHANNEL_0 used for ABC1
5 Copy the following code from ABC2 “user_setting.h”

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

// SPI settings
#define SPI_RETRY               3               // Retry times

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

extern const stSPI_SSP_OBJ      tblSPI[ CMP_SPI_NUM ];

6 Set SPI_ABC2 to the SPI communication Channel g_spi0 used for ABC2
7 Set GPIO_ABC2_CS to the GPIO Port g_ioport used for /CS of ABC2
8 Set PIN_ABC2_CS to the GPIO Port pin IOPORT_PORT_01_PIN_03 used for /CS of ABC2
9 Set SPI_RETRY to 3 retries for SPI communication

/*-- 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 Added ABC2 information to “user_setting.c”

1 include path change
2 ABC2 #include added
3 Copy the following code from ABC2 “user_setting.c”

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 Addition of oABC1 and oABC2 functions

1. Include ABC1 and ABC2 headers in the user program header file.

// user program header
#include "../oABC1.h"
#include "../oABC2.h"

2. Add API functions to the application, referring to “sample.c” in ABC1

// user application program
    etSTS sts = oABC1( eCMD_START_READ, &vgPHY1 );

or

// user application program
    etSTS sts = oABC1_START_READ( &vgPHY1 );

3. Add API functions to the application, referring to “sample.c” in ABC2

// user application program
    etSTS sts = oABC2( eCMD_START_READ, &vgPHY2 );

or

// user application program
    etSTS sts = oABC2_START_READ( &vgPHY2 );
OSS-ECAL English
error: Content is protected !!