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
- 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 - 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
Terminology | Meaning |
---|---|
ABC | Temporary name of electronic component |
API | Application interface |
HAL | Hardware Abstraction Layer, AUTOSAR MCAL |
HHH ( hhh ) | Temporary name of HAL |
OSS-EC | Open Source Software for Eectronic Components and related documentation |
MCAL | Microcontroller Abstraction Layer |
lib_lll | Temporary name of Library program |
RTOS | Real-Time Operating System |
rrr | Temporary name of RTOS |
XYZ | Temporary name of electronic component manufacturer |
Architecture

HAL and RTOS support table
MCU Manufacturer | HAL/MCAL ( SDK, IDE ) | Mbed | Free-RTOS | ThreadX | OSEK |
---|---|---|---|---|---|
Arduino | Arduino | – | X | (X) | – |
ARM | Mbed | X | – | – | – |
Infineon Technologies AG | ModusToolbox CYHAL | – | X | (X) | – |
NXP Semiconductors | MCUXpresso SDK | – | X | (X) | – |
Renesas Electronics | Renesas Synergy™ Software Package | – | (X) | X | – |
STMicroelectronics | STM32Cube | – | X | (X) | – |
NXP Semiconductors | AUTOSAR 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;
cmd | eCMD_START | Start Command |
| eCMD_READ | Read and physical value conversion Command |
| eCMD_START_READ | Start and Read and Physical value conversion Command |
err | eERR_NORMAL | Normalcy (non-error) |
| eERR_CMD | Command selection Error |
| eERR_CMP | Electronic component code selection Error |
| eERR_MAX | Maximum physical value exceeded Error |
| eERR_MIN | Minimum physical value less than Error |
val | – | Physical 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;
cmd | eCMD_READ_DAT | Data reception and Physical value conversion Command |
| eCMD_STOP | Stop Command |
sts | eSTS_INITIAL | Initial Status |
| eSTS_START | Command execution start Status |
| eSTS_EXE | Command being executed Status |
| eSTS_FIN | Command successfully completed Status |
| eSTS_ERROR | Command abnormal end Status |
err | eERR_NORMAL | Normalcy (non-error) |
| eERR_CMD | Command selection Error |
| eERR_CMP | Electronic component code selection Error |
| eERR_MAX | Maximum physical value exceeded Error |
| eERR_MIN | Minimum physical value less than Error |
| eERR_SPI | SPI communication Error |
dr_dat | – | Received data value |
val | – | Physical 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;
cmd | eCMD_WRITE_WUR | Wake-up time write Command |
| eCMD_READ_WUR | Wake-up time read Command |
| eCMD_CLEAR_TR | Wake-up timer clear Command |
| eCMD_COUNT | Wake-up timer count-up Command |
| eCMD_READ_TR | Wake-up timer read Command |
wu_time | – | Wake-up time write value |
sts | eSTS_INITIAL | Initial Status |
| eSTS_START | Command execution start Status |
| eSTS_EXE | Command being executed Status |
| eSTS_FIN | Command successfully completed Status |
| eSTS_ERROR | Command abnormal end Status |
err | eERR_NORMAL | Normalcy (non-error) |
| eERR_CMD | Command selection Error |
| eERR_CMP | Electronic component code selection Error |
| eERR_SPI | SPI communication Error |
wur | – | Wake-up time value |
tr | – | Wake-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.
Folder | File | Summary | Change |
---|---|---|---|
ABC\components\ | ABC.c | Main program of electronic component ABC | Prohibited |
| ABC.h | Main header file of the electronic component ABC | Prohibited |
ABC\hals\ | oHHH.c | HAL HHH wrapper program file | Prohibited |
| oHHH.h | HAL HHH wrapper header file | Prohibited |
| hhh_rrr.c | HAL HHH and RTOS rrr program file | Prohibited |
| hhh_rrr.h | HAL HHH and RTOS rrr header file | Prohibited |
hal_config.h | HAL HHH header file | Prohibited | |
ABC\oss_ec\ | lib_lll.c | Library program file used for electronic component ABC | Prohibited |
| lib_lll.h | Library header file used for electronic component ABC | Prohibited |
| oss_ec.h | OSS-EC Basic header File | Prohibited |
| oss_ec_config.h | HAL HHH include header file | Prohibited |
| sensor_adc_linear.c | Common program file for linear conversion of AD value to physical value in ADC type | Prohibited |
| sensor_adc_linear.h | Common header file for linear conversion of AD value to physical value in ADC type | Prohibited |
ABC\sample\ | sample_ABC.c | Sample application program file for electronic components ABC | Permitted |
| sample_ABC.h | Sample Application header file for electronic components ABC | Permitted |
sample_thread.c | Thread Sample program file | Permitted | |
sample_thread.h | Thread Sample header file | Permitted | |
ABC\sample\rrr\ | sample_rtos_rrr.c | RTOS rrr sample program file | Permitted |
| sample_rtos_rrr.h | RTOS rrr sample header file | Permitted |
ABC\hhh_rrr\user_setting\ | user_setting_hhh.c | User setting program file for HAL hhh | Permitted |
| user_setting_hhh.h | User setting header file for HAL hhh | Permitted |
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