IO-Link Master Firmware Hardware Abstraction Layer.
The FWHAL module provides an abstraction layer between the IO-Link stack and the PRU-ICSS firmware. It handles:
- PRU firmware loading and initialization
- Port mode configuration
- Data transfer operations
- Cycle timer management
- Wake-up sequence handling
|
| typedef struct IOLFW_PruMem | IOLFW_PruMem_t |
| |
| typedef struct IOLFW_PruMemTimer | IOLFW_PruMemTimer_t |
| |
| typedef void(* | IOLFW_cbSetMode_t) (IOLFW_Inst_t *pFwInstance, uint8_t portNum, IOLFW_ePortMode_t mode) |
| | Port mode change callback. More...
|
| |
| typedef const IOLFW_PortConfig_t *(* | IOLFW_cbGetPortCfg_t) (IOLFW_Inst_t *pFwInstance, uint8_t portNum) |
| | Get port configuration callback. More...
|
| |
| typedef void(* | IOLFW_cbRxErrEvent_t) (IOLFW_Inst_t *pFwInstance, uint8_t port, IOLFW_eRxErrorEvents_t rxErr) |
| | RX error event callback. More...
|
| |
| typedef void(* | IOLFW_cbTransferInd_t) (IOLFW_Inst_t *pFwInstance, uint8_t port, uint8_t dataLen, IOLFW_eTransferStatus_t eTrStatus) |
| | Transfer indication callback. More...
|
| |
| typedef void(* | IOLFW_cbStartupCmpl_t) (IOLFW_Inst_t *pFwInstance, uint8_t port, IOLFW_eStartupStatus_t eStrStatus) |
| | Startup/wake-up completion callback. More...
|
| |
| typedef IOLFW_Inst_t *(* | IOLFW_cbGetInstCont_t) (uint8_t inst_p) |
| | Get instance container callback. More...
|
| |
|
| enum | IOLFW_ePortMode_t {
IOLFW_ePortMode_SioInactive = 0,
IOLFW_ePortMode_Sdci,
IOLFW_ePortMode_SioDI,
IOLFW_ePortMode_SioDO,
IOLFW_ePortMode_Force32Bit = 0x7fffffff
} |
| | IO-Link port operating mode. More...
|
| |
| enum | IOLFW_eInstanceState_t { IOLFW_eInstanceState_NotInitialized = 0,
IOLFW_eInstanceState_Init,
IOLFW_eInstanceState_Running
} |
| | IOLFW instance state. More...
|
| |
| enum | IOLFW_eBaudrate_t { IOLFW_eBaudrate_Auto = 0,
IOLFW_eBaudrate_Com1,
IOLFW_eBaudrate_Com2,
IOLFW_eBaudrate_Com3
} |
| | IO-Link transmission rate (baud rate) More...
|
| |
| enum | IOLFW_eRxErrorEvents_t { IOLFW_eRxErrorEvents_Rxol = 0
} |
| | RX error event types. More...
|
| |
| enum | IOLFW_eTransferStatus_t { IOLFW_eTransferStatus_Ok = 0,
IOLFW_eTransferStatus_ParityError,
IOLFW_eTransferStatus_FramingError,
IOLFW_eTransferStatus_Overrun
} |
| | Data transfer status codes. More...
|
| |
| enum | IOLFW_eStartupStatus_t { IOLFW_eStartupStatus_Ok = 0,
IOLFW_eStartupStatus_NoResponse
} |
| | Port startup/wake-up status codes. More...
|
| |
◆ IOLFW_TA_BIT_DEFAULT
| #define IOLFW_TA_BIT_DEFAULT (11) |
◆ IOLFW_MAX_PD_SIZE
| #define IOLFW_MAX_PD_SIZE (32) |
◆ IOLFW_MAX_OD_SIZE
| #define IOLFW_MAX_OD_SIZE (32) |
◆ IOLFW_TR_DEF
◆ IOLFW_MAX_RESPONSE_TIME
| #define IOLFW_MAX_RESPONSE_TIME (85U) |
◆ IOLFW_STRUCT_PACKED
◆ IOLFW_ERR_SUCCESS
| #define IOLFW_ERR_SUCCESS (0) |
◆ IOLFW_ERR_BASE_CODE
| #define IOLFW_ERR_BASE_CODE (-150) |
◆ IOLFW_ERR_PRECONFIG
◆ IOLFW_ERR_EMPTY_ARG
◆ IOLFW_ERR_INST_INVALID
◆ IOLFW_ERR_INST_ALL_USED
All IOLFW instances in use
◆ IOLFW_ERR_CB_PORT_CFG
Port config callback not registered
◆ IOLFW_ERR_CB_SET_MODE
Set mode callback not registered
◆ IOLFW_ERR_CB_RX_ERR_EVT
RX error event callback not registered
◆ IOLFW_ERR_CB_TR_IND
Transfer indicator callback not registered
◆ IOLFW_ERR_CB_START_COMP
Startup completion callback not registered
◆ IOLFW_ERR_PRU_CLOCK
Configured PRU clock frequency is not supported for IO-Link
◆ IOLFW_ERR_IEP_CLOCK
Configured IEP clock frequency is not supported for IO-Link
◆ IOLFW_ERR_VAL_OUT_OF_RANGE
Parameter is out of range
◆ IOLFW_ERR_NULL_PTR
NULL pointer passed to function
◆ IOLFW_ERR_PORT_OUT_OF_RANGE
Port number out of valid range
◆ IOLFW_ERR_INVALID_CYCLE_TIME
◆ IOLFW_MAX_INST
| #define IOLFW_MAX_INST (1) |
◆ IOLFW_MAX_PORTS
| #define IOLFW_MAX_PORTS (8) |
◆ IOLFW_PruMem_t
◆ IOLFW_PruMemTimer_t
◆ IOLFW_cbSetMode_t
Port mode change callback.
Called when the FWHAL needs to change the port's physical layer mode. The application should configure the transceiver accordingly.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | portNum | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | mode | Target port mode |
◆ IOLFW_cbGetPortCfg_t
Get port configuration callback.
Called during initialization to retrieve the hardware configuration for a specific port.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | portNum | Port number (0 to IOLFW_MAX_PORTS-1) |
- Returns
- Pointer to port configuration, or NULL if port not available
◆ IOLFW_cbRxErrEvent_t
RX error event callback.
Called when an RX error is detected on a port.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number |
| [in] | rxErr | Error type |
◆ IOLFW_cbTransferInd_t
Transfer indication callback.
Called when an IO-Link data transfer completes (successfully or with error).
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number |
| [in] | dataLen | Number of bytes received |
| [in] | eTrStatus | Transfer result status |
◆ IOLFW_cbStartupCmpl_t
Startup/wake-up completion callback.
Called when the IO-Link wake-up sequence completes on a port.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number |
| [in] | eStrStatus | Startup result status |
◆ IOLFW_cbGetInstCont_t
| typedef IOLFW_Inst_t*(* IOLFW_cbGetInstCont_t) (uint8_t inst_p) |
Get instance container callback.
- Parameters
-
- Returns
- Pointer to IOLFW instance, or NULL if not found
◆ IOLFW_ePortMode_t
IO-Link port operating mode.
Defines the operating mode for an IO-Link port. Ports can operate in Standard IO (SIO) mode for legacy digital I/O or SDCI mode for IO-Link communication.
| Enumerator |
|---|
| IOLFW_ePortMode_SioInactive | SIO mode inactive (port disabled)
|
| IOLFW_ePortMode_Sdci | SDCI mode for IO-Link communication
|
| IOLFW_ePortMode_SioDI | SIO mode as digital input
|
| IOLFW_ePortMode_SioDO | SIO mode as digital output
|
| IOLFW_ePortMode_Force32Bit | Force enum to 32-bit
|
◆ IOLFW_eInstanceState_t
IOLFW instance state.
Tracks the lifecycle state of an IOLFW instance.
| Enumerator |
|---|
| IOLFW_eInstanceState_NotInitialized | Instance not initialized
|
| IOLFW_eInstanceState_Init | Instance initialized but not running
|
| IOLFW_eInstanceState_Running | Instance running and ready for operations
|
◆ IOLFW_eBaudrate_t
IO-Link transmission rate (baud rate)
Defines the IO-Link communication speed. IO-Link supports three transmission rates (COM1, COM2, COM3) as defined in the IO-Link specification.
| Enumerator |
|---|
| IOLFW_eBaudrate_Auto | Auto-detect baud rate during startup
|
| IOLFW_eBaudrate_Com1 | COM1: 4.8 kbit/s
|
| IOLFW_eBaudrate_Com2 | COM2: 38.4 kbit/s
|
| IOLFW_eBaudrate_Com3 | COM3: 230.4 kbit/s
|
◆ IOLFW_eRxErrorEvents_t
RX error event types.
Error events that can occur during reception of IO-Link frames.
| Enumerator |
|---|
| IOLFW_eRxErrorEvents_Rxol | RX overload: response received without request
|
◆ IOLFW_eTransferStatus_t
Data transfer status codes.
Status codes returned after an IO-Link data transfer operation completes.
| Enumerator |
|---|
| IOLFW_eTransferStatus_Ok | Transfer completed successfully
|
| IOLFW_eTransferStatus_ParityError | UART parity error detected
|
| IOLFW_eTransferStatus_FramingError | UART framing error (invalid stop bit)
|
| IOLFW_eTransferStatus_Overrun | UART overrun (octet collision)
|
◆ IOLFW_eStartupStatus_t
Port startup/wake-up status codes.
Status codes returned after the IO-Link wake-up sequence completes.
| Enumerator |
|---|
| IOLFW_eStartupStatus_Ok | Device found, communication established
|
| IOLFW_eStartupStatus_NoResponse | No device response during wake-up
|
◆ IOLFW_registerSetModeCallback()
Register port mode change callback.
See IOLFW_cbSetMode_t for callback details.
- Note
- Must be called before IOLFW_init().
- Parameters
-
| [in] | pCallback | Callback function pointer |
◆ IOLFW_registerGetPortCfgCallback()
Register port configuration callback.
See IOLFW_cbGetPortCfg_t for callback details.
- Note
- Must be called before IOLFW_init().
- Parameters
-
| [in] | pCallback | Callback function pointer |
◆ IOLFW_registerRxErrEventCallback()
Register RX error event callback.
See IOLFW_cbRxErrEvent_t for callback details.
- Note
- Must be called before IOLFW_init().
- Parameters
-
| [in] | pCallback | Callback function pointer |
◆ IOLFW_registerTransferIndCallback()
Register transfer indication callback.
See IOLFW_cbTransferInd_t for callback details.
- Note
- Must be called before IOLFW_init().
- Parameters
-
| [in] | pCallback | Callback function pointer |
◆ IOLFW_registerStartupCmplCallback()
Register startup completion callback.
See IOLFW_cbStartupCmpl_t for callback details.
- Note
- Must be called before IOLFW_init().
- Parameters
-
| [in] | pCallback | Callback function pointer |
◆ IOLFW_init()
Initialize IOLFW instance.
Initializes the IOLFW module for the specified PRU-ICSS instance. Loads PRU firmware and configures the ports.
- Precondition
- All required callbacks must be registered before calling this function.
- Parameters
-
| [out] | pFwInstance | Pointer to receive the instance handle |
| [in] | pConfig | Pointer to configuration structure |
- Return values
-
| IOLFW_ERR_SUCCESS | Initialization successful |
| IOLFW_ERR_PRECONFIG | PRU configuration failed |
| IOLFW_ERR_CB_PORT_CFG | Port config callback not registered |
| IOLFW_ERR_CB_SET_MODE | Set mode callback not registered |
| IOLFW_ERR_CB_RX_ERR_EVT | RX error callback not registered |
| IOLFW_ERR_CB_TR_IND | Transfer indication callback not registered |
| IOLFW_ERR_CB_START_COMP | Startup callback not registered |
| IOLFW_ERR_INST_ALL_USED | All instances in use |
| IOLFW_ERR_PRU_CLOCK | Unsupported PRU clock frequency |
| IOLFW_ERR_IEP_CLOCK | Unsupported IEP clock frequency |
◆ IOLFW_deInit()
De-initialize IOLFW instance.
Stops the PRU firmware and releases all resources associated with the IOLFW instance.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
- Return values
-
| IOLFW_ERR_SUCCESS | De-initialization successful |
| IOLFW_ERR_INST_INVALID | Invalid instance handle |
| IOLFW_ERR_PRECONFIG | PRU de-configuration failed |
◆ IOLFW_setPortMode()
Set port operating mode.
Changes the operating mode of the specified port. This triggers the cbSetMode callback for hardware reconfiguration.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | eTargetMode | Target port mode |
- Return values
-
| IOLFW_ERR_SUCCESS | Mode change successful |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
◆ IOLFW_getBaudRate()
Get current baud rate of port.
Returns the currently configured transmission rate for the specified port.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
- Returns
- Current baud rate setting
◆ IOLFW_wakeUp()
| int32_t IOLFW_wakeUp |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port |
|
) |
| |
Initiate IO-Link wake-up sequence.
Starts the IO-Link wake-up/startup sequence on the specified port. The result is reported via the cbStartupCmpl callback.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
- Return values
-
| IOLFW_ERR_SUCCESS | Wake-up initiated successfully |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
◆ IOLFW_transferPrepare()
| int32_t IOLFW_transferPrepare |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port, |
|
|
uint8_t * |
pData, |
|
|
uint8_t |
dataLength, |
|
|
uint8_t * |
pResponseData, |
|
|
uint8_t |
responseLength |
|
) |
| |
Prepare data transfer.
Prepares the TX buffer for the next IO-Link data transfer cycle. The transfer is triggered by the cycle timer or manually. The result is reported via the cbTransferInd callback.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | pData | Pointer to TX data buffer |
| [in] | dataLength | Number of bytes to transmit |
| [in] | pResponseData | Pointer to RX data buffer |
| [in] | responseLength | Expected number of response bytes |
- Return values
-
| IOLFW_ERR_SUCCESS | Transfer prepared successfully |
| IOLFW_ERR_NULL_PTR | NULL instance or data pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
| IOLFW_ERR_VAL_OUT_OF_RANGE | Data length exceeds maximum |
◆ IOLFW_setMaxRespTime()
| int32_t IOLFW_setMaxRespTime |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port, |
|
|
uint8_t |
taRespTime |
|
) |
| |
Set maximum response time.
Configures the maximum allowed response time (T_A) for the specified port. This is the time window after TX completes in which a response is expected.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | taRespTime | Maximum response time in bit times |
- Return values
-
| IOLFW_ERR_SUCCESS | Configuration successful |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
◆ IOLFW_resetCycleTime()
| int32_t IOLFW_resetCycleTime |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port |
|
) |
| |
Reset cycle timer counter.
Resets the cycle timer counter to zero for the specified port.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
- Return values
-
| IOLFW_ERR_SUCCESS | Reset successful |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
◆ IOLFW_setCycleTime()
| int32_t IOLFW_setCycleTime |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port, |
|
|
uint32_t |
timeUs |
|
) |
| |
Set cycle time.
Configures the cycle time for the specified port.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | timeUs | Cycle time in microseconds |
- Return values
-
| IOLFW_ERR_SUCCESS | Cycle time set successfully |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
◆ IOLFW_enableCycleTimer()
| int32_t IOLFW_enableCycleTimer |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port, |
|
|
bool |
enable |
|
) |
| |
Enable or disable cycle timer.
Enables or disables the automatic cycle timer for the specified port. When enabled, transfers are triggered automatically at the configured cycle time.
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | enable | true to enable, false to disable |
- Return values
-
| IOLFW_ERR_SUCCESS | Timer state changed successfully |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |
◆ IOLFW_configCycleTime()
| int32_t IOLFW_configCycleTime |
( |
IOLFW_Inst_t * |
pFwInstance, |
|
|
uint8_t |
port, |
|
|
uint32_t |
timeUs |
|
) |
| |
Configure and enable cycle time.
Convenience function that configures the cycle time and enables/disables the cycle timer in one call. If timeUs is 0, the timer is disabled.
Internal call sequence:
- Parameters
-
| [in] | pFwInstance | IOLFW instance handle |
| [in] | port | Port number (0 to IOLFW_MAX_PORTS-1) |
| [in] | timeUs | Cycle time in microseconds (0 to disable) |
- Return values
-
| IOLFW_ERR_SUCCESS | Configuration successful |
| IOLFW_ERR_NULL_PTR | NULL instance pointer |
| IOLFW_ERR_PORT_OUT_OF_RANGE | Invalid port number |