Software Related Topics

This page gives you an overview about necessary software modifications to create a compliant device.

LED Behaviour controlled by uGOAL

The red Arduino Adaptershield uses LEDs to show the started industrial protocol as well as protocol specific encoded LED behaviours. Refering to most of the available Evaluations Kits for the SoM, the available LEDs are controlled by an GPIO Expander addressed via the well-known I2C.

Preparing with goal_maLedSet(…)

Each LED is controlled by two bits, according to the documentation of the IO Expander CAT9532-D.

grafik-20240704-105029.png

The function irj45_setLedState or goal_maLedSet clears the selected bits from the defined LED offset and, if state == GOAL_TRUE, enables the LED.

/**< LEDs definition for Arduino adapter board */ #define GOAL_MA_LED_LED1_RED (0) #define GOAL_MA_LED_LED1_GREEN (2) #define GOAL_MA_LED_LED2_RED (4) #define GOAL_MA_LED_LED2_GREEN (6) #define GOAL_MA_LED_ETHERCAT (8) #define GOAL_MA_LED_PROFINET (10) #define GOAL_MA_LED_MODBUS (12) #define GOAL_MA_LED_ETHERNETIP (14) #define GOAL_MA_LED_CANOPEN (16)
void irj45_setLedState( uint32_t *pLedStates, /**< pointer where led states are stored */ uint32_t led, /**< the LED to set */ GOAL_BOOL_T state /**< the new state of the LED */ ) { /* unset two bits of selected LEDs */ *(pLedStates) &= ~(3UL << led); if (state == GOAL_TRUE) { *(pLedStates) |= (1UL << led); } }

Following Example sets the PROFINET LED at the red Arduino Adapthershield:

irj45_setLedState(m_ledState, GOAL_MA_LED_PROFINET, GOAL_TRUE);

Setting with plat_ledSet(…)

After storing the LED states, uGOAL will set these values via I2C. The first byte ledState[0] contains the starting address 0b 0110 (LED 0-3 Selector) and the AUTO-INCREMENT FLAG, 0x 16. Afterwards the following three bytes corresponds to LED 0-3, LED 4-7 and LED 8-11.

grafik-20240704-100753.png
CAT9532-D Registers