Merged in antmerlino/nuttx/photon-rgbled-fix (pull request #642)

Photon rgbled fix

* configs/photon: Simplifies RGB led start-up logic.

* configs/photon: RGB led on Photon is common anode. CONFIGS_RGBLED_INVERT is now enabled

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Anthony Merlino 2018-05-14 17:58:23 +00:00 committed by Gregory Nutt
parent addf7f1a4c
commit 2ed01b3c27
2 changed files with 25 additions and 95 deletions

View File

@ -1,21 +1,25 @@
# CONFIG_ARCH_LEDS is not set
# CONFIG_DEV_CONSOLE is not set
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="photon"
CONFIG_ARCH_BOARD_PHOTON=y
CONFIG_ARCH_CHIP_STM32F205RG=y
CONFIG_ARCH_CHIP_STM32=y
CONFIG_ARCH_CHIP_STM32F205RG=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_USBDEVCTRL=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_CDCACM_CONSOLE=y
CONFIG_CDCACM=y
# CONFIG_DEV_CONSOLE is not set
CONFIG_CDCACM_CONSOLE=y
CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_RGBLED=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
@ -23,10 +27,7 @@ CONFIG_MM_REGIONS=2
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_ARCHINIT=y
# CONFIG_NSH_ARGCAT is not set
CONFIG_NSH_BUILTIN_APPS=y
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
@ -36,16 +37,17 @@ CONFIG_PHOTON_WDG_THREAD=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_PWM=y
CONFIG_PWM_MULTICHAN=y
CONFIG_PWM_NCHANNELS=4
CONFIG_PWM=y
CONFIG_RAMLOG=y
CONFIG_RAMLOG_BUFSIZE=8192
CONFIG_RAMLOG_SYSLOG=y
CONFIG_RAMLOG=y
CONFIG_RAM_SIZE=114688
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RGBLED=y
CONFIG_RGBLED_INVERT=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
@ -56,6 +58,7 @@ CONFIG_STM32_IWDG=y
CONFIG_STM32_JTAG_SW_ENABLE=y
CONFIG_STM32_OTGHS=y
CONFIG_STM32_PWM_MULTICHAN=y
CONFIG_STM32_TIM2=y
CONFIG_STM32_TIM2_CH2OUT=y
CONFIG_STM32_TIM2_CH3OUT=y
CONFIG_STM32_TIM2_CH4OUT=y
@ -63,7 +66,6 @@ CONFIG_STM32_TIM2_CHANNEL2=y
CONFIG_STM32_TIM2_CHANNEL3=y
CONFIG_STM32_TIM2_CHANNEL4=y
CONFIG_STM32_TIM2_PWM=y
CONFIG_STM32_TIM2=y
CONFIG_STM32_USART1=y
CONFIG_USBDEV=y
CONFIG_USER_ENTRYPOINT="nsh_main"

View File

@ -106,9 +106,8 @@ int stm32_rgbled_setup(void)
struct pwm_lowerhalf_s *ledr;
struct pwm_lowerhalf_s *ledg;
struct pwm_lowerhalf_s *ledb;
struct pwm_info_s info;
int i;
int ret;
int fd;
/* Have we already initialized? */
@ -147,89 +146,6 @@ int stm32_rgbled_setup(void)
ledb->ops->setup(ledb);
/* Define frequency and duty cycle */
info.frequency = 100;
#ifdef CONFIG_PWM_MULTICHAN
/* Setup the duty cycle and channel for red */
i = 0;
info.channels[i].duty = 0;
info.channels[i++].channel = RGBLED_RPWMCHANNEL;
/* If red and green use same timer, setup together */
if (RGBLED_RPWMTIMER == RGBLED_GPWMTIMER)
{
info.channels[i++].channel = RGBLED_GPWMCHANNEL;
}
/* If red and blue use same timer, setup together */
if (RGBLED_RPWMTIMER == RGBLED_BPWMTIMER)
{
info.channels[i++].channel = RGBLED_BPWMCHANNEL;
}
/* Start the timer used for red, and any other colors that are
* sourced on a different channel of the same timer.
*/
ledr->ops->start(ledr, &info);
/* Clear the channels from the struct */
for (i = 0; i < CONFIG_PWM_NCHANNELS; i++)
{
info.channels[i].channel = 0;
}
/* If the green timer is not the same as the red timer, then set it
* up.
*/
if (RGBLED_GPWMTIMER != RGBLED_RPWMTIMER)
{
i = 0;
info.channels[i++].channel = RGBLED_GPWMCHANNEL;
/* If the blue timer uses the same timer and the green */
if (RGBLED_GPWMTIMER == RGBLED_BPWMTIMER)
{
info.channels[i++].channel = RGBLED_BPWMCHANNEL;
}
/* Start green timer (and maybe blue) */
ledg->ops->start(ledg, &info);
/* Clear the channels from the struct */
for (i = 0; i < CONFIG_PWM_NCHANNELS; i++)
{
info.channels[i].channel = 0;
}
}
/* If the blue timer is different than the red and the green, it must
* be setup separately.
*/
if (RGBLED_BPWMTIMER != RGBLED_RPWMTIMER &&
RGBLED_BPWMTIMER != RGBLED_GPWMTIMER)
{
info.channels[0].channel = RGBLED_BPWMCHANNEL;
ledb->ops->start(ledb, &info);
}
#else
info.duty = 0;
ledr->ops->start(ledr, &info);
ledg->ops->start(ledg, &info);
ledb->ops->start(ledb, &info);
#endif
/* Register the RGB LED diver at "/dev/rgbled0" */
#ifdef CONFIG_PWM_MULTICHAN
@ -245,6 +161,18 @@ int stm32_rgbled_setup(void)
return ret;
}
fd = open(fd, O_WRONLY);
if (fd < 0)
{
lederr("ERROR: open failed: %d\n", fd);
return ret;
}
/* Initialize led off */
write(fd, "#000000", 8);
close(fd);
/* Now we are initialized */
initialized = true;