Trouble with ISELED digLED_Ping() command

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble with ISELED digLED_Ping() command

1,013 Views
johnathan_weise
Contributor II

I am trying to use the ping command with a strip of ISELED LEDs in order to have a dynamic strip length demonstrator.

I am trying to access the value for the number of LEDs currently connected in the strip by using the following commands based on the iseled_freemaster example program:

digLED_Ping(&digLEDResultStrip1, strip);

delay(9000);                     

 

uint16_t pingVal = digLEDResultBufferStrip1[0]; 

//Buffer[0] is the first response that reaches the MCU. For ping, only one response is transmitted.

 

pingVal &=0xFFF000; 

// the result buffer contains 24 bit. 12 bit for address (MSB) and 12 bit data (LSB).

When I check the value of pingVal while using the debugger however, I only ever see the value '0' regardless of how many LEDs are connected.

Has anyone else had success using this command, and how did you get it to work?

Tags (3)
0 Kudos
2 Replies

914 Views
dragosrachitan
NXP Employee
NXP Employee

Hello Johnathan,

If you reuse the callback as in the example:

void digLED_Callback(digLED_CommEventType state, uint8_t stripNr)
{
   stateFlag = state;
   stripCallback = stripNr;
   appState = BUS_FREE;
}

you can set the appState variable to "OPERATION_ONGOING" before calling any ISELED function, and then wait for the callback to change it back to "BUS_FREE", instead of using a simple delay:

digLED_ReturnType retCode;

appState = OPERATION_ONGOING;
retCode = digLED_Ping(&digLEDResultStrip1, strip);
while(appState == OPERATION_ONGOING);

This should assure that the command has enough time to execute as the callback is called when the transfer is complete. 

You can also use the "retCode" variable to check the return value of the function. It should return "DIGLED_OK" if everything is in order.

Please note that in order for this function to work, the LEDs need to be initialized first, so digLED_Init_Strip should be called before any other API function. If you try to call digLED_Ping before calling digLED_Init_Strip, the function will return "DIGLED_ERROR".

Best regards,

Dragos

0 Kudos

842 Views
6T9
Contributor III

Hello Dragos,

I'm trying to get an answer from the ping function.

The following code shows the ISELED initialization.

iseledFctReturnValues[0] = digLED_Init_Interface(NUMBER_OF_INTERFACES, iseled1_InitConfig);

appState = OPERATION_ONGOING;
iseledFctReturnValues[1] = digLED_Reset(strip);

while (appState != BUS_FREE)
{
// wait
}

// initialize LED-stripe
appState = OPERATION_ONGOING;
digLEDResultStrip1.chainLength = MAX_NUM_LEDS;
digLEDResultStrip1.retData = &isledReturn.digLEDResultBufferStrip1[0];

iseledFctReturnValues[2] = digLED_Init_Strip(&testInitType, &digLEDResultStrip1, strip);

while (appState != BUS_FREE)
{
// wait
}

// Turn all LEDs off
appState = OPERATION_ONGOING;
iseledFctReturnValues[3] = digLED_Set_RGB(0, 0, 0, 0, strip);

while (appState != BUS_FREE)
{
// wait
}

appState = OPERATION_ONGOING;
digLEDResultStrip1.chainLength = MAX_NUM_LEDS;
digLEDResultStrip1.retData = &idigLEDResultBufferStrip1[0];
iseledFctReturnValues[4] = digLED_Ping(&digLEDResultStrip1, strip);

while (appState != BUS_FREE)
{
// wait
}

Each digLED function returns DIGLED_OK, but digLED_Ping contains only zero, but actually there are 200 LEDs connected. These LEDs can be turned on without any problem.

The Callback is implemented as you mentioned.

Is there a Pin configuration necessary to make the Ping function work?

Best regards

Thomas

 

0 Kudos