TI中文支持网
TI专业的中文技术问题搜集分享网站

TM4C123GH6PM: freertos demo 里的led.c 看不懂,求帮助

Part Number:TM4C123GH6PM

if(xQueueReceive(g_pLEDQueue, &i8Message, 0) == pdPASS)
{
//
// If left button, update to next LED.
//
if(i8Message == LEFT_BUTTON)
{
//
// Update the LED buffer to turn off the currently working.
//
g_pui32Colors[g_ui8ColorsIndx] = 0x0000;

//
// Update the index to next LED
g_ui8ColorsIndx++;
if(g_ui8ColorsIndx > 2)
{
g_ui8ColorsIndx = 0;
}

//
// Update the LED buffer to turn on the newly selected LED.
//
g_pui32Colors[g_ui8ColorsIndx] = 0x8000;

//
// Configure the new LED settings.
//
RGBColorSet(g_pui32Colors);

//
// Guard UART from concurrent access. Print the currently
// blinking LED.
//
xSemaphoreTake(g_pUARTSemaphore, portMAX_DELAY);
UARTprintf("Led %d is blinking. [R, G, B]\n", g_ui8ColorsIndx);
xSemaphoreGive(g_pUARTSemaphore);
}

//
// If right button, update delay time between toggles of led.
//
if(i8Message == RIGHT_BUTTON)
{
ui32LEDToggleDelay *= 2;
if(ui32LEDToggleDelay > 1000)
{
ui32LEDToggleDelay = LED_TOGGLE_DELAY / 2;
}

//
// Guard UART from concurrent access. Print the currently
// blinking frequency.
//
xSemaphoreTake(g_pUARTSemaphore, portMAX_DELAY);
UARTprintf("Led blinking frequency is %d ms.\n",
(ui32LEDToggleDelay * 2));
xSemaphoreGive(g_pUARTSemaphore);
}
}

//
// Turn on the LED.
//
RGBEnable();

//
// Wait for the required amount of time.
//
vTaskDelayUntil(&ui32WakeTime, ui32LEDToggleDelay / portTICK_RATE_MS);

//
// Turn off the LED.
//
RGBDisable();

//
// Wait for the required amount of time.
//
vTaskDelayUntil(&ui32WakeTime, ui32LEDToggleDelay / portTICK_RATE_MS);
}
}

这是上面freertos demo里的例程的led.c,看不懂,帮帮我吧,谢谢朋友们

Susan Yang:

能否详细说明一下您的疑惑?

,

fengtuotuo feng:

好的,就是

if(i8Message == LEFT_BUTTON) { // // Update the LED buffer to turn off the currently working. // g_pui32Colors[g_ui8ColorsIndx] = 0x0000;

// // Update the index to next LED g_ui8ColorsIndx++; if(g_ui8ColorsIndx > 2) { g_ui8ColorsIndx = 0; }

,

fengtuotuo feng:

里面的0x0000比如这个在哪来的数据,代表什么含义呢

,

Susan Yang:

若是可以的话,请给出您下载例程的链接。单从代码来看,g_ui8ColorsIndx代表的是LED buffer,以给该buffer赋值来决定LED的状态,类似引脚的寄存器,当赋值为0时,代表led灭掉

赞(0)
未经允许不得转载:TI中文支持网 » TM4C123GH6PM: freertos demo 里的led.c 看不懂,求帮助
分享到: 更多 (0)