Lines Matching refs:ledState
123 led_state_t *ledState; member
146 static led_status_t LED_SetStatus(led_state_t *ledState, led_color_t color, uint32_t threshold) in LED_SetStatus() argument
157 ledState->expiryPeriodCount = s_ledList.periodCount + threshold; in LED_SetStatus()
160 ledRgbPin = (led_pin_config_t *)(const void *)&ledState->pinsConfig->ledRgb; in LED_SetStatus()
162 ledRgbPin = (led_pin_t *)ledState->pins; in LED_SetStatus()
166 if (kLED_TypeRgb == ledState->pinsConfig->type) in LED_SetStatus()
184 … (void)HAL_PwmUpdateDutycycle(ledState->pwmHandle[i], (uint8_t)ledRgbPin[i].dimming.channel, in LED_SetStatus()
191 (void)HAL_GpioSetOutput(ledState->gpioHandle[i], (colorSet != 0U) ? in LED_SetStatus()
195 (void)HAL_GpioSetOutput(ledState->gpioHandle[i], (colorSet != 0U) ? in LED_SetStatus()
207 led_state_t *ledState = (led_state_t *)s_ledList.ledState; in LED_TimerEvent() local
217 while (NULL != ledState) in LED_TimerEvent()
219 if (s_ledList.periodCount >= ledState->expiryPeriodCount) in LED_TimerEvent()
221 switch (ledState->controlType) in LED_TimerEvent()
228 if (LED_FLASH_CYCLE_FOREVER != ledState->flashCycle) in LED_TimerEvent()
230 if ((0U != ledState->flashCycle)) in LED_TimerEvent()
232 … if (((led_color_t)kLED_Black == ledState->currentColor) || (100U == ledState->flashDuty)) in LED_TimerEvent()
234 ledState->flashCycle--; in LED_TimerEvent()
238 if (0U != ledState->flashCycle) in LED_TimerEvent()
240 if ((100U > ledState->flashDuty)) in LED_TimerEvent()
242 color = ledState->nextColor; in LED_TimerEvent()
243 ledState->nextColor = ledState->currentColor; in LED_TimerEvent()
244 ledState->currentColor = color; in LED_TimerEvent()
247 if (((led_color_t)kLED_Black == ledState->currentColor)) in LED_TimerEvent()
249 … threshold = (uint32_t)ledState->flashPeriod * (100U - (uint32_t)ledState->flashDuty) / 100U; in LED_TimerEvent()
254 ledState->flashCount++; in LED_TimerEvent()
255 if ((uint16_t)kLED_TricolorCycleFlash == ledState->controlType) in LED_TimerEvent()
257 … ledState->currentColor = (led_color_t)(0xFFUL << ((ledState->flashCount % 3U) * 8U)); in LED_TimerEvent()
259 else if ((uint16_t)kLED_CycleFlash == ledState->controlType) in LED_TimerEvent()
262 if (0U == ((ledState->flashCount) & 0x07U)) in LED_TimerEvent()
264 (ledState->flashCount)++; in LED_TimerEvent()
266 if (0U != ((ledState->flashCount) & 0x04U)) in LED_TimerEvent()
270 if (0U != ((ledState->flashCount) & 0x02U)) in LED_TimerEvent()
274 if (0U != ((ledState->flashCount) & 0x01U)) in LED_TimerEvent()
278 ledState->currentColor = color; in LED_TimerEvent()
285 … threshold = (uint32_t)ledState->flashPeriod * (uint32_t)(ledState->flashDuty) / 100U; in LED_TimerEvent()
288 (void)LED_SetStatus(ledState, ledState->currentColor, threshold); in LED_TimerEvent()
295 uint8_t value = (uint8_t)((ledState->currentColor >> (8U * i)) & 0xFFU); in LED_TimerEvent()
296 if (0U != ledState->dimming.increasement) in LED_TimerEvent()
298 if ((value + ledState->dimming.powerDelta[i]) < 0xFFU) in LED_TimerEvent()
300 … power[i] = (uint16_t)value + (uint16_t)ledState->dimming.powerDelta[i]; in LED_TimerEvent()
309 if (value > ledState->dimming.powerDelta[i]) in LED_TimerEvent()
311 … power[i] = (uint16_t)value - (uint16_t)ledState->dimming.powerDelta[i]; in LED_TimerEvent()
320 if (kLED_TypeMonochrome == ledState->pinsConfig->type) in LED_TimerEvent()
322 if ((uint16_t)kLED_TypeMonochrome == ledState->pins[0].config.type) in LED_TimerEvent()
328 ledState->currentColor = LED_MAKE_COLOR(power[0], power[1], power[2]); in LED_TimerEvent()
329 (void)LED_SetStatus(ledState, ledState->currentColor, ledState->flashPeriod); in LED_TimerEvent()
337 ledState = ledState->next; in LED_TimerEvent()
343 led_state_t *ledState; in LED_Init() local
369 ledState = (led_state_t *)ledHandle; in LED_Init()
374 if (NULL == s_ledList.ledState) in LED_Init()
389 s_ledList.ledState = ledState; in LED_Init()
394 ledState->next = s_ledList.ledState; in LED_Init()
395 s_ledList.ledState = ledState; in LED_Init()
399 assert(s_ledList.ledState); in LED_Init()
400 ledState->settingColor = (led_color_t)kLED_White; in LED_Init()
404 ledState->pinsConfig = ledConfig; in LED_Init()
430 ledState->pins[i].config.type = (uint16_t)ledConfig->type; in LED_Init()
438 ledState->pins[i].config.dimmingEnable = ledRgbConfigPin[i].dimmingEnable; in LED_Init()
439 ledState->pins[i].dimming.instance = ledRgbConfigPin[i].dimming.instance; in LED_Init()
440 ledState->pins[i].dimming.channel = ledRgbConfigPin[i].dimming.channel; in LED_Init()
441 ledState->pins[i].dimming.pinStateDefault = ledRgbConfigPin[i].dimming.pinStateDefault; in LED_Init()
443 … (void)HAL_PwmInit((hal_pwm_handle_t)ledState->pwmHandle[i], ledRgbConfigPin[i].dimming.instance, in LED_Init()
451 … (void)HAL_PwmSetupPwm(ledState->pwmHandle[i], ledRgbConfigPin[i].dimming.channel, &setupConfig); in LED_Init()
458 ledState->pins[i].gpio.port = ledRgbConfigPin[i].gpio.port; in LED_Init()
459 ledState->pins[i].gpio.pin = ledRgbConfigPin[i].gpio.pin; in LED_Init()
460 ledState->pins[i].gpio.pinStateDefault = ledRgbConfigPin[i].gpio.pinStateDefault; in LED_Init()
467 if (kStatus_HAL_GpioSuccess != HAL_GpioInit((hal_gpio_handle_t)ledState->gpioHandle[i], in LED_Init()
470 …if (kStatus_HAL_GpioSuccess != HAL_GpioInit((hal_gpio_handle_t)ledState->gpioHandle[i], &controlPi… in LED_Init()
478 return LED_TurnOnOff(ledState, 0); in LED_Init()
483 led_state_t *ledState; in LED_Deinit() local
496 ledState = (led_state_t *)ledHandle; in LED_Deinit()
499 ledStatePre = s_ledList.ledState; in LED_Deinit()
500 if (ledStatePre != ledState) in LED_Deinit()
502 while ((NULL != ledStatePre) && (ledStatePre->next != ledState)) in LED_Deinit()
508 ledStatePre->next = ledState->next; in LED_Deinit()
513 s_ledList.ledState = ledState->next; in LED_Deinit()
516 if (NULL == s_ledList.ledState) in LED_Deinit()
524 ledRgbPin = (led_pin_config_t *)(void *)&ledState->pinsConfig->ledRgb; in LED_Deinit()
526 ledRgbPin = (led_pin_t *)(ledState->pins); in LED_Deinit()
538 HAL_PwmDeinit(ledState->pwmHandle[i]); in LED_Deinit()
543 (void)HAL_GpioDeinit(ledState->gpioHandle[i]); in LED_Deinit()
546 if (kLED_TypeRgb != ledState->pinsConfig->type) in LED_Deinit()
548 if (((uint16_t)kLED_TypeRgb != ledState->pins[i].config.type)) in LED_Deinit()
560 led_state_t *ledState; in LED_TurnOnOff() local
564 ledState = (led_state_t *)ledHandle; in LED_TurnOnOff()
565 ledState->controlType = (uint16_t)kLED_TurnOffOn; in LED_TurnOnOff()
566 ledState->currentColor = (1U == turnOnOff) ? ledState->settingColor : (led_color_t)kLED_Black; in LED_TurnOnOff()
567 (void)LED_SetStatus(ledState, ledState->currentColor, 0); in LED_TurnOnOff()
573 led_state_t *ledState; in LED_SetColor() local
577 ledState = (led_state_t *)ledHandle; in LED_SetColor()
579 assert(kLED_TypeRgb == ledState->pinsConfig->type); in LED_SetColor()
581 assert((uint16_t)kLED_TypeRgb == ledState->pins[0].config.type); in LED_SetColor()
584 ledState->settingColor = ledRgbColor; in LED_SetColor()
591 led_state_t *ledState; in LED_Flash() local
598 ledState = (led_state_t *)ledHandle; in LED_Flash()
600 ledState->flashPeriod = ledFlash->period; in LED_Flash()
601 ledState->flashDuty = ledFlash->duty; in LED_Flash()
603 ledState->currentColor = ledState->settingColor; in LED_Flash()
604 ledState->flashCycle = ledFlash->times; in LED_Flash()
605 ledState->nextColor = (led_color_t)kLED_Black; in LED_Flash()
610 ledState->controlType = (uint16_t)kLED_Flash; in LED_Flash()
615 assert(kLED_TypeRgb == ledState->pinsConfig->type); in LED_Flash()
617 assert((uint16_t)kLED_TypeRgb == ledState->pins[0].config.type); in LED_Flash()
619 ledState->controlType = (uint16_t)kLED_CycleFlash; in LED_Flash()
622 ledState->controlType = (uint16_t)kLED_Flash; in LED_Flash()
624 (void)LED_SetStatus(ledState, ledState->currentColor, in LED_Flash()
625 ((uint32_t)ledState->flashPeriod * (uint32_t)ledState->flashDuty) / 100U); in LED_Flash()
643 led_state_t *ledState; in LED_Dimming() local
651 ledState = (led_state_t *)ledHandle; in LED_Dimming()
654 assert(ledState->pinsConfig->ledRgb.redPin.dimmingEnable); in LED_Dimming()
656 assert(ledState->pins[0].config.dimmingEnable); in LED_Dimming()
661 ledState->controlType = (uint16_t)kLED_Dimming; in LED_Dimming()
662 ledState->flashPeriod = LED_DIMMING_UPDATE_INTERVAL; in LED_Dimming()
663 ledState->flashDuty = 100U; in LED_Dimming()
664 ledState->dimming.increasement = increasement; in LED_Dimming()
667 if (kLED_TypeRgb == ledState->pinsConfig->type) in LED_Dimming()
669 if ((uint16_t)kLED_TypeRgb == ledState->pins[0].config.type) in LED_Dimming()
672 ledState->currentColor = ledState->settingColor; in LED_Dimming()
677 ledState->dimming.powerDelta[i] = 0U; in LED_Dimming()
682 value = (uint8_t)((ledState->currentColor >> (8U * (i))) & 0xFFU); in LED_Dimming()
683 if (0U != ledState->dimming.increasement) in LED_Dimming()
685 ledState->dimming.powerDelta[i] = in LED_Dimming()
687 if ((value + ledState->dimming.powerDelta[i]) < 0xFFU) in LED_Dimming()
689 power[i] = (uint16_t)value + ledState->dimming.powerDelta[i]; in LED_Dimming()
698 ledState->dimming.powerDelta[i] = in LED_Dimming()
700 if (value > ledState->dimming.powerDelta[i]) in LED_Dimming()
702 power[i] = (uint16_t)value - (uint16_t)ledState->dimming.powerDelta[i]; in LED_Dimming()
710 if (kLED_TypeMonochrome == ledState->pinsConfig->type) in LED_Dimming()
712 if ((uint16_t)kLED_TypeMonochrome == ledState->pins[0].config.type) in LED_Dimming()
719 ledState->currentColor = LED_MAKE_COLOR(power[0], power[1], power[2]); in LED_Dimming()
720 ledState->flashCycle = LED_FLASH_CYCLE_FOREVER; in LED_Dimming()
722 (void)LED_SetStatus(ledState, ledState->currentColor, ledState->flashPeriod); in LED_Dimming()
733 led_state_t* ledState; in LED_EnterLowpower()
740 ledState = (led_state_t*)ledHandle; in LED_EnterLowpower()
742 ledRgbPin = (led_pin_config_t*)&ledState->config.ledRgb; in LED_EnterLowpower()
743 if (kLED_TypeRgb == ledState->config.type) in LED_EnterLowpower()
762 HAL_GpioEnterLowpower(ledState->gpioHandle[i]); in LED_EnterLowpower()
772 led_state_t* ledState; in LED_ExitLowpower()
779 ledState = (led_state_t*)ledHandle; in LED_ExitLowpower()
781 ledRgbPin = (led_pin_config_t*)&ledState->config.ledRgb; in LED_ExitLowpower()
782 if (kLED_TypeRgb == ledState->config.type) in LED_ExitLowpower()
801 HAL_GpioExitLowpower(ledState->gpioHandle[i]); in LED_ExitLowpower()