Overview

Overview

OSS-EC ( abbreviation : Open Source Software for Eectronic Components ) is a generic term for open source software for electronic components and related documentation.

Purpose

  1. OSS-EC should contribute to a win-win situation in the electronic components industry.
    Win for product manufacturers: Contribute to improving “quality,” “cost,” and “delivery time” of product software development.
    Win for component makers: Reduction of sample program development costs and contribution to sales expansion by providing OSS-EC
  2. To contribute to the development of embedded software by promoting OSS and standardization of software components for electronic components.

Feature

  • Provided free of charge as open source software
    However, please comply with the OSS-EC Terms of Use.
  • Provided as a standard API for each type of electronic component
  • Supports various Real-Time Operating Systems ( RTOS )
  • Supports various Hardware Abstraction Layer (HAL) / Microcontroller Abstraction Layer (MCAL)
  • Provide OSS-EC specifications and test results

Definition of Terms

TerminologyMeaning
ABCTemporary name of electronic component
APIApplication interface
HALHardware Abstraction Layer, AUTOSAR MCAL
HHH ( hhh )Temporary name of HAL
OSS-ECOpen Source Software for Eectronic Components and related documentation
MCALMicrocontroller Abstraction Layer
lib_lllTemporary name of Library program
RTOSReal-Time Operating System
rrrTemporary name of RTOS
XYZTemporary name of electronic component manufacturer

Architecture

HAL and RTOS support table

MCU ManufacturerHAL/MCAL ( SDK, IDE )MbedFree-RTOSThreadXOSEK
ArduinoArduinoX(X)
ARMMbedX
Infineon Technologies AGModusToolbox CYHALX(X)
NXP SemiconductorsMCUXpresso SDKX(X)
Renesas ElectronicsRenesas Synergy™ Software Package(X)X
STMicroelectronicsSTM32CubeX(X)
NXP SemiconductorsAUTOSAR MCAL(X)

X : Provides sample programs for HAL/M-CAL and RTOS
(X) : under development

OSS-EC API

OSS-EC API is an API for OSS-EC for each electronic component. The OSS-EC API aims to standardize APIs for different types of electronic components.

ADC type API

ADC type API is an API for Analog output type electronic components.
This section introduces APIs for electronic components of the type that performs AD conversion and linearly converts AD values to physical values. The stREC_ABC2 and stSEN_ABC2 declarations differ for each electronic component. The commands also differ for each HAL, so please refer to the respective OSS-EC specifications.

// API for ADC type components
stREC_ABC1 oABC1( stSEN_ABC1 );

#define stSEN_ABC1    stADC
#define stREC_ABC1    stADC_F

// ADC send struct
typedef struct
{
        etCMD        cmd;            // OSS-EC command codes
}stADC;
// ADC floating-point struct
typedef struct
{
        etERR        err;            // OSS-EC error codes
        float32      val;            // Linear transformation value[UNIT]
}stADC_F;
cmdeCMD_STARTStart Command
eCMD_READRead and physical value conversion Command
eCMD_START_READStart and Read and Physical value conversion Command
erreERR_NORMALNormalcy (non-error)
eERR_CMDCommand selection Error
eERR_CMPElectronic component code selection Error
eERR_MAXMaximum physical value exceeded Error
eERR_MINMinimum physical value less than Error
valPhysical value of linearly converted AD conversion value

SPI communication type API ( linear conversion and floating point conversion )

SPI communication type API is an API for SPI communication type electronic components.
This section introduces APIs for electronic components of the type that performs SPI communication and linear conversion of received data to physical values. The stREC_ABC2 and stSEN_ABC2 declarations differ for each electronic component. The commands also differ for each HAL, so please refer to the respective OSS-EC specifications.

// API for SPI type components
stREC_ABC2 oABC2( stSEN_ABC2 );

typedef struct
{
        etCMD                   cmd;            // OSS-EC command codes
}stSEN_ABC2;

typedef struct
{
        etSTS                   sts;            // OSS-EC status codes
        etERR                   err;            // OSS-EC error codes
        uint16                  dr_dat;         // SPI received data of ABC
        float32                 val;            // physical value[unit]
}stREC_ABC2;
cmdeCMD_READ_DATData reception and Physical value conversion Command
eCMD_STOPStop Command
stseSTS_INITIALInitial Status
eSTS_STARTCommand execution start Status
eSTS_EXECommand being executed Status
eSTS_FINCommand successfully completed Status
eSTS_ERRORCommand abnormal end Status
erreERR_NORMALNormalcy (non-error)
eERR_CMDCommand selection Error
eERR_CMPElectronic component code selection Error
eERR_MAXMaximum physical value exceeded Error
eERR_MINMinimum physical value less than Error
eERR_SPISPI communication Error
dr_datReceived data value
valPhysical value of linearly converted received data value

I2C communication type API ( Wake-up timer IC )

I2C communication type API is an API for I2C communication type electronic components.
This section introduces APIs for electronic components of the type that performs I2C communication and controls a wake-up timer. The stREC_ABC2 and stSEN_ABC2 declarations differ for each electronic component. The commands also differ for each HAL, so please refer to the respective OSS-EC specifications.

// API for I2C type components
stREC_ABC3 oABC3( stSEN_ABC3 );
typedef struct
{
        etCMD                   cmd;            // OSS-EC command codes
        uint32                  wu_time;        // Wake-up value
}stSEN_ABC3;

typedef struct
{
        etSTS                   sts;            // OSS-EC status codes
        etERR                   err;            // OSS-EC error codes
        uint32                  wur;            // Wake-up register value(write/read)
        uint32                  tr;             // Timer register value(read only)
}stREC_ABC3;
cmdeCMD_WRITE_WURWake-up time write Command
eCMD_READ_WURWake-up time read Command
eCMD_CLEAR_TRWake-up timer clear Command
eCMD_COUNTWake-up timer count-up Command
eCMD_READ_TRWake-up timer read Command
wu_timeWake-up time write value
stseSTS_INITIALInitial Status
eSTS_STARTCommand execution start Status
eSTS_EXECommand being executed Status
eSTS_FINCommand successfully completed Status
eSTS_ERRORCommand abnormal end Status
erreERR_NORMALNormalcy (non-error)
eERR_CMDCommand selection Error
eERR_CMPElectronic component code selection Error
eERR_SPISPI communication Error
wurWake-up time value
trWake-up timer value

OSS-EC implementation on RTOS

The OSS-EC implementation in RTOS is to make OSS-EC API calls from the RTOS Thread. Set and use OSS-EC API arguments before making OSS-EC API calls.
Here is an example of implementing ADC type ABC1 and SPI type ABC2 and I2C type ABC3 in a Free-RTOS Thread.

// Free-RTOS Thread for OSS-EC
void thread_oss_ec( void* pvParameters )
{
	(void)pvParameters;
        do
        {
                // Component application for arguments OSS-EC API
                // ADC type component application for arguments OSS-EC API
                vgSEN_ABC1 = REQUEST_ABC1( vgREC_ABC1 );
                // SPI type component application for arguments OSS-EC API
                vgSEN_ABC2 = REQUEST_ABC2( vgREC_ABC2 );
                // I2C type component application for arguments OSS-EC API
                vgSEN_ABC3 = REQUEST_ABC3( vgREC_ABC3 );

                // OSS-EC API
                // ADC type component OSS-EC API
                vgREC_ABC1 = oABC1( vgSEN_ABC1 );
                // SPI type component OSS-eC API
                vgREC_ABC2 = oABC2( vgSEN_ABC2 );
                // I2C type component OSS-EC API
                vgREC_ABC3 = oABC3( vgSEN_ABC3 );

                // Thread period wait
                vTaskDelay( 1000 );
        }while(1);
}

HAL Interface

HAL interface is a wrapper function that absorbs different HALs. HAL interface include ADC HAL interface and SPI HAL interface, I2C interface, GPIO interface.

ADC HAL Interface

The ADC HAL interface is the following ADC HAL wrapper function.

// ADC start function
stADC_LINEAR_F oADC_start( stADC_LINEAR_F adc )
{
        adc = oHAL_adc_start( adc );
        return( adc );
}

// ADC status read function

stADC_LINEAR_F oADC_status_read( stADC_LINEAR_F adc )
{
        adc = oHAL_adc_status_read( adc );
        return( adc );
}

// ADC start read function
stADC_LINEAR_F oADC_start_read( stADC_LINEAR_F adc )
{
        adc = oHAL_adc_start_read( adc );
        return( adc );
}

SPI HAL Interface

The SPI HAL interface is the following SPI HAL wrapper function

// SPI configure function
etERR oSPI_config( stSPI spi )
{
        etERR rtn = oHAL_spi_config( spi );
        return( rtn );
}

// SPI write & read function
etERR oSPI_write_read( stSPI spi, uint8 wlen, uint8* wbuf, uint8 rlen, uint8* rbuf )
{
        etERR rtn = oHAL_spi_write_read( spi, wlen, &wbuf[0], rlen, &rbuf[0] );
        return( rtn );
}

I2C HAL Interface

The I2C HAL interface is the following I2C HAL wrapper function.

// I2C write & read function
etERR oI2C_write_read( etCMP num, uint8 wlen, uint8* wbuf, uint8 rlen, uint8* rbuf )
{
        etERR  rtn = oHAL_i2c_write_read( num, wlen, &wbuf[0], rlen, &rbuf[0] );
        return( rtn );
}

// I2C write function
etERR oI2C_write( etCMP num, uint8 wlen, uint8* wbuf )
{
        etERR  rtn = oHAL_i2c_write( num, wlen, &wbuf[0] );
        return( rtn );
}

// I2C read function
etERR oI2C_read( etCMP num, uint8 rlen, uint8* rbuf )
{
        etERR  rtn = oHAL_i2c_read( num, rlen, &rbuf[0] );
        return( rtn );
}

GPIO HAL Interface

The GPIO HAL interface is the following GPIO HAL wrapper function.

// GPIO write function
void oGPIO_write( stGPIO pin, uint8 level )
{
        oHAL_gpio_write( pin, level );
}

// GPIO read function
uint8 oGPIO_read( stGPIO pin )
{
        uint8  rtn = oHAL_gpio_read( pin );
        return( rtn );
}

User setting

User setting is the configuration of HAL and power supply, MCU configuration, communication, etc.
Here, Infineon Cyhal psoc6 is used for HAL and the OSS-EC settings for ABC1 and ABC2 and ABC3 are presented.

// HAL type define
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define HAL_TYPE                eCYHAL          // HAL type select : oss_ec.h etHAL

// ADC components common setting
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define VREF                    3.3F            // Configures the reference voltage [V]
#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
#define K_TC                    1.0F            // Circuit Transformation ratio

// Hardware setting by user
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// OSS-EC DIO hard wiring
#define CMP_GPIO_NUM            1U              // OSS-EC GPIO components number

// OSS-EC ADC components hard wiring
#define CMP_ADC_NUM             1U              // OSS-EC ADC components number
#define PIABC1                  P10_0           // MCU ADC pin

// OSS-EC SPI components hard wiring
#define CMP_SPI_NUM             1U              // OSS-EC SPI components number
#define PIN_MOSI                P9_0            // MCU SPI mosi
#define PIN_MISO                P9_1            // MCU SPI miso
#define PIN_SCLK                P9_2            // MCU SPI sclk
#define SPI_ABC2                vgSPI_OBJ       // SPI object
#define PIN_ABC2_CS             P9_3            // ABC2 /CS : MCU Digital Out Pin

// OSS-EC I2C components hard wiring
#define CMP_I2C_NUM             1U              // OSS-EC I2C components number
#define I2C_HZ                  400000          // MCU I2C frequency
#define PIN_SDA                 P6_5            // MCU I2C SDA
#define PIN_SCL                 P6_4            // MCU I2C SCL
#define I2C_ABC3                vgI2C_OBJ       // I2C object

// OSS-EC Wake-up components hard wiring
#define PIN_ABC3_INT            P6_4            // ABC3 INT : MCU EXT-INT Pin
#define PIN_ABC3_RST            P5_6            // ABC3 /RST : MCU Digital Pin

// Communication setting by user
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// SPI settings
#define SPI_RETRY               3               // Retry times
// I2C settings
#define I2C_RETRY               3               // Retry times
#define I2C_TIMEOUT             10              // Timeout

// HAL ADC object table for ABC1
const stADC_CYHAL_OBJ tblADC[ CMP_ADC_NUM ] =
{
        { eABC1     , ePINID000     , &vgADC_ABC1      }
};

// HAL SPI object table for ABC2
const stSPI_CYHAL_OBJ tblSPI[ CMP_SPI_NUM ] =
{
        { eABC2     , &SPI_ABC2     , PIN_ABC2_CS      }
};

// HAL I2C object table for ABC3
const stI2C_CYHAL_OBJ tblI2C[ CMP_I2C_NUM ] =
{
        { eABC3     , eI2C_ADR_ABC3 , &I2C_ABC3        }
};

// HAL GPIO object table for ABC3 Reset Signal
const stGPIO_CYHAL_OBJ tblGPIO[ CMP_GPIO_NUM ] =
{
        { eABC3     , ePINID000     , PIN_ABC3_RST     }
};

To set up multiple HALs of the same type, do the following.
Example : To add I2C type ABC4

// OSS-EC I2C components hard wiring
#define CMP_I2C_NUM             2U              // OSS-EC I2C components number
#define I2C_ABC3                vgI2C_OBJ       // I2C object
#define I2C_ABC4                vgI2C_OBJ       // I2C object

// HAL I2C object table for ABC3
const stI2C_CYHAL_OBJ tblI2C[ CMP_I2C_NUM ] =
{
        { eABC3     , eI2C_ADR_ABC3 , &I2C_ABC3        },
        { eABC4     , eI2C_ADR_ABC4 , &I2C_ABC4        }
};

File Structure

The File structure of OSS-EC is shown in the table below.

FolderFileSummaryChange
ABC\components\ABC.cMain program of electronic component ABCProhibited
ABC.hMain header file of the electronic component ABCProhibited
ABC\hals\oHHH.cHAL HHH wrapper program fileProhibited
oHHH.hHAL HHH wrapper header fileProhibited
hhh_rrr.cHAL HHH and RTOS rrr program fileProhibited
hhh_rrr.hHAL HHH and RTOS rrr header fileProhibited
hal_config.hHAL HHH header fileProhibited
ABC\oss_ec\lib_lll.cLibrary program file used for electronic component ABCProhibited
lib_lll.hLibrary header file used for electronic component ABCProhibited
oss_ec.hOSS-EC Basic header FileProhibited
oss_ec_config.hHAL HHH include header fileProhibited
sensor_adc_linear.cCommon program file for linear conversion of AD value to physical value in ADC typeProhibited
sensor_adc_linear.hCommon header file for linear conversion of AD value to physical value in ADC typeProhibited
ABC\sample\sample_ABC.cSample application program file for electronic components ABCPermitted
sample_ABC.hSample Application header file for electronic components ABCPermitted
sample_thread.cThread Sample program filePermitted
sample_thread.hThread Sample header filePermitted
ABC\sample\rrr\sample_rtos_rrr.cRTOS rrr sample program filePermitted
sample_rtos_rrr.hRTOS rrr sample header filePermitted
ABC\hhh_rrr\user_setting\user_setting_hhh.cUser setting program file for HAL hhhPermitted
user_setting_hhh.hUser setting header file for HAL hhhPermitted

When incorporating into product software, please copy the following example. The same should be done when using multiple electronic components. ABC\sample\*. * is the sample code file.

Example :
ABC\components*. * of *.* copy
ABC\hals\*.* of *.* copy
ABC\oss_ec\*.* of *.* copy
ABC\hhh_rrr\user_setting\*.* of *.* copy

Documents

Related documents for OSS-EC are as follows. Please refer to each electronic component introduction page for details.

  • OSS-EC Specifications
  • Test Results
OSS-EC English
error: Content is protected !!