IO-Link Master1.09.04
SMI General

Overview

SMI General.

Typedefs

typedef void(* IOLM_SMI_CBGenericCnf) (IOLM_SMI_SHeader *psuHeader_p, INT8U *pu8ArgBlock_p)
 SMI Generic request confirmation callback. More...
 
typedef void(* IOLM_SMI_CBLoadMasterIdentification) (INT16U *u16ArgBlockLength_p, INT8U *pu8ArgBlock_p)
 Load Master configuration callback. More...
 
typedef void(* IOLM_SMI_CBLoadNVCfg) (INT8U u8Instance_p, INT8U *pu8Data_p, INT32U *pu32Length_p)
 Load configuration callback. More...
 
typedef void(* IOLM_SMI_CBSaveNVCfg) (INT8U u8Instance_p, INT8U *pu8Data_p, INT32U u32Length_p)
 Save configuration callback. More...
 
typedef void(* IOLM_SMI_CBSMIExt) (INT8U u8Instance_p, INT8U *pu8Data_p, INT16U u16Length_p)
 SMI extension function callback. More...
 

Functions

IOL_FUNC_DECL void IOLM_SMI_vGenericReq (IOLM_SMI_SHeader *psuHeader_p, INT8U *pu8ArgBlock_p)
 SMI generic request. More...
 
IOL_FUNC_DECL void IOLM_SMI_vSaveNvFinished (void)
 Save configuration finished. More...
 
void IOLM_SMI_vExtRsp (IOL_EErrorType eError_p, INT8U *pu8Data_p, INT16U u16Length_p)
 SMI extension response. More...
 
IOL_FUNC_DECL void IOLM_SMI_vRun (void)
 SMI Mainloop. More...
 
IOL_FUNC_DECL void IOLM_SMI_vInit (IOLM_SMI_SCallbacks *psuCallbacks_p)
 Initialize SMI interface. More...
 

Typedef Documentation

◆ IOLM_SMI_CBGenericCnf

IOLM_SMI_CBGenericCnf

SMI Generic request confirmation callback.

This callback function is called by the stack for a generic access of all services of the SMI. Confirmation to the IOLM_SMI_vGenericReq request.

Parameters
[in]psuHeader_pHeader.
[in]pu8ArgBlock_pGeneric ArgBlock.
Example
void IOLM_SMI_vGenericCnf(IOLM_SMI_SHeader *psuHeader_p, INT8U *pu8ArgBlock_p)
{
IOLM_SMI_SGeneralArgBlock *psuGenericArgBlock;
INT8U u16ArgBlockLength = psuHeader_p->u16ArgBlockLength;
psuGenericArgBlock = malloc(u16ArgBlockLength);
...
// Get header parameters
psuHeader_p->u8ClientId;
...
// Get ArgBlock data
memcpy(psuGenericArgBlock, pu8ArgBlock_p, u16ArgBlockLength);
// ToDo: Insert application specific code here
}
uint8_t INT8U
8 bit unsigned integer
Definition: IOL_Port_Types.h:68
SGI dependent types.
Definition: IOLM_SMI_Types.h:1368
INT16U u16ArgBlockLength
Little endian.
Definition: IOLM_SMI_Types.h:1375
INT8U u8ClientId
Client id. IOLM_SMI_CLIENTID_INTERN and IOLM_SMI_CLIENTID_BROADCAST are reserved.
Definition: IOLM_SMI_Types.h:1374
This structure is used as general and void ArgBlock.
Definition: IOLM_SMI_Types.h:588
See also
IOLM_SMI_SCallbacks, IOLM_SMI_vInit, IOLM_SMI_EArgBlockID

◆ IOLM_SMI_CBLoadMasterIdentification

IOLM_SMI_CBLoadMasterIdentification

Load Master configuration callback.

This callback service is called by the stack and requests the Master configuration from the application. Since this is hardware specific, it has to be implemented in the application code.

Parameters
[in]u16ArgBlockLength_pLength of the ArgBlock.
[in]pu8ArgBlock_pData pointer which points to the Master identification (IOLM_SMI_SMasterident).
Example
void IOLM_SMI_vLoadMasterIdentification(INT16U *u16ArgBlockLength_p, INT8U *pu8ArgBlock_p)
{
IOLM_SMI_SMasterident *psuMasterIdent = (IOLM_SMI_SMasterident *)pu8ArgBlock_p;
psuMasterIdent->u16ArgBlockID = IOLM_SMI_ENDIAN_16(IOLM_SMI_eArgBlockID_MasterIdent);
...
// ToDo: Set up psuMasterIdent parameters
}
uint16_t INT16U
16 bit unsigned integer
Definition: IOL_Port_Types.h:70
This structure is used to get Master identification.
Definition: IOLM_SMI_Types.h:611
INT16U u16ArgBlockID
Big endian.
Definition: IOLM_SMI_Types.h:612
See also
IOLM_SMI_SCallbacks, IOLM_SMI_vInit, IOLM_SMI_EArgBlockID

◆ IOLM_SMI_CBLoadNVCfg

IOLM_SMI_CBLoadNVCfg

Load configuration callback.

This callback service is called by the stack and requests the saved configuration struct from non volatile memory. Since this is hardware specific, it has to be implemented in the application code.

Parameters
[in]u8Instance_p0-x for DataStorage Port and 0xFF for SMI configuration.
[in]pu8Data_pPointer to the configuration struct to be loaded (IOLM_SMI_SNVConfiguration).
[in]pu32Length_pPointer to the length of the configuration struct.
Example
void LOLM_SMI_vLoadNVCfg(INT8U u8Instance_p, INT8U *pu8Data_p, INT32U *pu32Length_p)
{
// Create local configuration struct in your application
IOLM_SMI_SNVConfiguration sNVConfiguration;
// Load configuration from non-volatile memory into struct
// ToDo: Insert hardware specific code here
// Copy configuration to pu8Data_p for the stack
memcpy(pu8Data_p, &sNVConfiguration, *pu32Length_p);
}
uint32_t INT32U
32 bit unsigned integer
Definition: IOL_Port_Types.h:72
Definition: IOLM_SMI.h:336
See also
IOLM_SMI_SCallbacks, IOLM_SMI_vInit, IOLM_SMI_EArgBlockID

◆ IOLM_SMI_CBSaveNVCfg

IOLM_SMI_CBSaveNVCfg

Save configuration callback.

This callback service is called by the stack and is used to save the configuration struct to non volatile memory. If this function is finished writing the data it must call IOLM_SMI_vSaveNvFinished to notify the stack. Since this is hardware specific, it has to be implemented in the application code.

Parameters
[in]u8Instance_p0-x for Data Storage port and 0xFF for SMI configuration.
[in]pu8Data_pPointer to the configuration struct to be saved (IOLM_SMI_SNVConfiguration).
[in]u32Length_pLength of the configuration struct.
Example
void LOLM_SMI_vSaveNVCfg(INT8U u8Instance_p, INT8U *pu8Data_p, INT32U u32Length_p)
{
// Create local configuration struct in your application
IOLM_SMI_SNVConfiguration *psuNVConfiguration = (IOLM_SMI_SNVConfiguration *)pu8Data_p;
// Save configuration to non-volatile memory
// ToDo: Insert hardware specific code here
// Tell the stack that saving the configuration is finished
}
void IOLM_SMI_vSaveNvFinished(void)
Save configuration finished.
Definition: IOLM_SMI.c:538
See also
IOLM_SMI_SCallbacks, IOLM_SMI_vInit, IOLM_SMI_EArgBlockID

◆ IOLM_SMI_CBSMIExt

IOLM_SMI_CBSMIExt

SMI extension function callback.

Callback for extension functions which are proprietary and not included in the IOL/IOLW specification. Can be used for additional application specific services, firmware updates, etc. Since this is hardware specific, it has to be implemented in the application code.

Parameters
[in]u8Instance_pInstance (defined by caller).
[in]pu8Data_pPointer to the response data.
[in]u16Length_pLength of the response data
Example
void IOLM_SMI_vExtensionService(INT8U u8Instance_p, INT8U *pu8Data_p, INT16U u16Length_p)
{
IOL_EErrorType eErrorResponse;
INT8U *pu8DataResponse;
// ToDo: Insert application specific code here
// Response to stack
IOLM_SMI_vExtRsp(eErrorResponse, pu8DataResponse, 0);
}
IOL_EErrorType
This enumeration indicates the permissible ISDU ErrorTypes resulting from the Device application.
Definition: IOL_Types.h:551
void IOLM_SMI_vExtRsp(IOL_EErrorType eError_p, INT8U *pu8Data_p, INT16U u16Length_p)
SMI extension response.
Definition: IOLM_SMI.c:2337
See also
IOLM_SMI_SCallbacks, IOLM_SMI_vInit, IOLM_SMI_EArgBlockID

Function Documentation

◆ IOLM_SMI_vExtRsp()

void IOLM_SMI_vExtRsp ( IOL_EErrorType  eError_p,
INT8U pu8Data_p,
INT16U  u16Length_p 
)

SMI extension response.

Responses of extension functions which are proprietary and not included in the IOL/IOLW specification.

Parameters
[in]eError_pError message as IOL_EErrorType.
[in]pu8Data_pPointer to the response data.
[in]u16Length_pLength of the response data
Example
void IOLM_SMI_vExtensionService(INT8U u8Instance_p, INT8U *pu8Data_p, INT16U u16Length_p)
{
IOL_EErrorType eErrorResponse;
INT8U *pu8DataResponse;
// ToDo: Insert application specific code here
// Response to stack
IOLM_SMI_vExtRsp(eErrorResponse, pu8DataResponse, 0);
}
See also
IOLM_SMI_CBSMIExt

◆ IOLM_SMI_vGenericReq()

IOL_FUNC_DECL void IOLM_SMI_vGenericReq ( IOLM_SMI_SHeader psuHeader_p,
INT8U pu8ArgBlock_p 
)

SMI generic request.

The function is used for a generic access of all services of the SMI. The answer to this request is the callback function IOLM_SMI_CBGenericCnf.

Parameters
[in]psuHeader_pHeader.
[in]pu8ArgBlock_pGeneric ArgBlock.
Example
// Allocate header memory
INT8U au8HeaderMem[sizeof(IOLM_SMI_SHeader)];
IOLM_SMI_SHeader *psuHeader = (IOLM_SMI_SHeader *)au8HeaderMem;
// Allocate ArgBlock memory (pu8Data contains the data of length u16DataLength)
INT16U u16ArgBlockLength = sizeof(IOLM_SMI_SGeneralArgBlock) + u16DataLength;
INT8U au8ArgBlockMem[u16ArgBlockLength];
IOLM_SMI_SGeneralArgBlock *psuArgblock = (IOLM_SMI_SGeneralArgBlock *)au8ArgBlockMem;
// Fill header
psuHeader->u16ArgBlockLength = u16ArgBlockLength;
psuHeader->u8Service = ...
...
// Fill request
psuArgblock->u16ArgBlockID = IOLM_SMI_ENDIAN_16(IOLM_SMI_SGeneralArgBlock); // ArgBlock ID (little endian)
...
// Copy user data into ArgBlock request
memcpy(psuArgblock + sizeof(IOLM_SMI_SGeneralArgBlock), pu8Data, u16ArgBlockLength);
// ToDo: Insert application specific code here
// Send request
IOLM_SMI_vGenericReq(psuHeader, (INT8U *)psuArgblock);
// wait for IOLM_SMI_CBGenericCnf
IOL_FUNC_DECL void IOLM_SMI_vGenericReq(IOLM_SMI_SHeader *psuHeader_p, INT8U *pu8ArgBlock_p)
SMI generic request.
Definition: IOLM_SMI_API.c:289
INT16U u16ArgBlockID
Big endian.
Definition: IOLM_SMI_Types.h:589

◆ IOLM_SMI_vInit()

IOL_FUNC_DECL void IOLM_SMI_vInit ( IOLM_SMI_SCallbacks psuCallbacks_p)

Initialize SMI interface.

Initializes the SMI Interface, sets initial values, loads saved configuration (if present), etc. Must be called once before SMI Mainloop (IOLM_SMI_vRun).

Parameters
[in]psuCallbacks_pSet of callback functions.
Example
// ToDo: Setup the desired callbacks
IOLM_SMI_SCallbacks suSMICallbacks_g =
{
.cbGenericCnf = IOLM_SMI_cbGenericCnf,
.cbPortConfigurationCnf = IOLM_SMI_cbPortConfigurationCn,
.cbReadbackPortConfigurationCnf = IOLM_SMI_cbReadbackPortConfigurationCnf,
.cbPortStatusCnf ...
...
};
// Initialize stack and SMI (suSMICallbacks_g must be global)
IOLM_SMI_vInit(&suSMICallbacks_g);
// Application Mainloop
while (1)
{
IOLM_SMI_vRun(); // SMI Mainloop (at least once per ms)
User_Application(); // ToDo: Insert application specific code here
}
void IOLM_SMI_vRun(void)
SMI Mainloop.
Definition: IOLM_SMI.c:3938
void IOLM_SMI_vInit(IOLM_SMI_SCallbacks *psuCallbacks_p)
Initialize SMI interface.
Definition: IOLM_SMI.c:351
SMI Callbacks. Must be initialized via IOLM_SMI_vInit.
Definition: IOLM_SMI.h:2342
IOLM_SMI_CBGenericCnf cbGenericCnf
Callback for IOLM_SMI_vGenericReq.
Definition: IOLM_SMI.h:2344
See also
IOLM_SMI_SCallbacks

◆ IOLM_SMI_vRun()

IOL_FUNC_DECL void IOLM_SMI_vRun ( void  )

SMI Mainloop.

Runs periodically to execute the next jobs in the queue, etc. Must be called at least once every millisecond to guarantee a stable stack environment.

Example
// ToDo: Setup the desired callbacks
IOLM_SMI_SCallbacks suSMICallbacks_g =
{
.cbGenericCnf = IOLM_SMI_vGenericCnf,
.cbMemFree = IOLM_SMI_vMemFree,
.cbMemAlloc = LOLM_SMI_pu8ArgBlockAlloc,
.cbLoadNvCfg = ...
...
};
// Initialize stack and SMI (suSMICallbacks_g must be global)
IOLM_SMI_vInit(&suSMICallbacks_g);
// Application Mainloop
while (1)
{
IOLM_SMI_vRun(); // SMI Mainloop (at least once per ms)
User_Application(); // ToDo: Insert application specific code here
}

◆ IOLM_SMI_vSaveNvFinished()

IOL_FUNC_DECL void IOLM_SMI_vSaveNvFinished ( void  )

Save configuration finished.

This service needs to be called by the application code, to inform the stack, that the configuration is successfully written to the non volatile memory function in the application code (which can take a few hundred milliseconds).

void LOLM_SMI_vSaveNVCfg(INT8U u8Instance_p, INT8U *pu8Data_p, INT32U u32Length_p)
{
// Create local configuration struct in your application
IOLM_SMI_SNVConfiguration *psuNVConfiguration = (IOLM_SMI_SNVConfiguration *)pu8Data_p;
// Save configuration to non-volatile memory
// ToDo: Insert hardware specific code here
// Tell the stack that saving the configuration is finished
}
See also
IOLM_SMI_CBSaveNVCfg