Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Typo

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

Table of Contents
minLevel1
maxLevel6
outlinefalse
stylenone
typelist
printabletrue

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.

...

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

Code Block
/**< 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)
Code Block
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:

Code Block
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.pngImage Addedgrafik-20240704-101543.pngImage Added
Code Block
int plat_ledSet(
    uint32_t state                              /**< led state field */
)
{
    uint8_t ledState[4] = {0};                        /* transfer buffer */

    /* set new value for LED states */
    ledState[0] = 0x16;                         /* register offset */
    ledState[1] = (state >> 0) & 0xFF;
    ledState[2] = (state >> 8) & 0xFF;
    ledState[3] = (state >> 16) & 0xFF;
...
}