Standardize button interfaces
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3749 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
129333c54d
commit
00bc426aa6
@ -2,7 +2,7 @@
|
|||||||
* configs/avr32dev1/include/board.h
|
* configs/avr32dev1/include/board.h
|
||||||
* include/arch/board/board.h
|
* include/arch/board/board.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -158,8 +158,8 @@
|
|||||||
/* Button definitions ***************************************************************/
|
/* Button definitions ***************************************************************/
|
||||||
/* The AVR32DEV1 board has 3 BUTTONs, two of which can be sensed through GPIO pins. */
|
/* The AVR32DEV1 board has 3 BUTTONs, two of which can be sensed through GPIO pins. */
|
||||||
|
|
||||||
#define BUTTON1 1 /* Bit 0: Button 1 */
|
#define BUTTON1 1 /* Bit 0: Button 1 */
|
||||||
#define BUTTON2 2 /* Bit 1: Button 2 */
|
#define BUTTON2 2 /* Bit 1: Button 2 */
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
@ -198,10 +198,10 @@ EXTERN void avr32_boardinitialize(void);
|
|||||||
* Name: up_buttoninit
|
* Name: up_buttoninit
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* up_buttoninit() must be called to initialize button resources. After that,
|
* up_buttoninit() must be called to initialize button resources. After
|
||||||
* up_buttons() may be called to collect the state of all buttons. up_buttons()
|
* that, up_buttons() may be called to collect the current state of all
|
||||||
* returns an 8-bit bit set with each bit associated with a button. See the
|
* buttons or up_irqbutton() may be called to register button interrupt
|
||||||
* BUTTON* definitions above for the meaning of each bit in the returned value.
|
* handlers.
|
||||||
*
|
*
|
||||||
* NOTE: Nothing in the "base" NuttX code calls up_buttoninit(). If you want button
|
* NOTE: Nothing in the "base" NuttX code calls up_buttoninit(). If you want button
|
||||||
* support in an application, your application startup code must call up_buttoninit()
|
* support in an application, your application startup code must call up_buttoninit()
|
||||||
@ -226,11 +226,12 @@ EXTERN void up_buttoninit(void);
|
|||||||
EXTERN uint8_t up_buttons(void);
|
EXTERN uint8_t up_buttons(void);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: up_irqbutton1/2
|
* Name: up_irqbutton
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* These functions may be called to register an interrupt handler that will be
|
* This function may be called to register an interrupt handler that will be
|
||||||
* called when BUTTON1/2 is depressed. The previous interrupt handler value is
|
* called when a button is depressed or released. The ID value is one of the
|
||||||
|
* BUTTON* definitions provided above. The previous interrupt handler address is
|
||||||
* returned (so that it may restored, if so desired).
|
* returned (so that it may restored, if so desired).
|
||||||
*
|
*
|
||||||
* Configuration Notes:
|
* Configuration Notes:
|
||||||
@ -242,8 +243,7 @@ EXTERN uint8_t up_buttons(void);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_AVR32_GPIOIRQ
|
#ifdef CONFIG_AVR32_GPIOIRQ
|
||||||
EXTERN xcpt_t up_irqbutton1(xcpt_t irqhandler);
|
EXTERN xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
|
||||||
EXTERN xcpt_t up_irqbutton2(xcpt_t irqhandler);
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/sam3u-ek/src/up_leds.c
|
* configs/sam3u-ek/src/up_leds.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -65,12 +65,54 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irqbuttonx
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function implements the core of the up_irqbutton() logic.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_AVR32_GPIOIRQ) && \
|
||||||
|
(defined(CONFIG_AVR32DEV_BUTTON1_IRQ) || defined(CONFIG_AVR32DEV_BUTTON2_IRQ))
|
||||||
|
static xcpt_t up_irqbuttonx(int irq, xcpt_t irqhandler)
|
||||||
|
{
|
||||||
|
xcpt_t oldhandler;
|
||||||
|
|
||||||
|
/* Attach the handler */
|
||||||
|
|
||||||
|
gpio_irqattach(irq, irqhandler, &oldhandler);
|
||||||
|
|
||||||
|
/* Enable/disable the interrupt */
|
||||||
|
|
||||||
|
if (irqhandler)
|
||||||
|
{
|
||||||
|
gpio_irqenable(irq);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gpio_irqdisable(irq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the old button handler (so that it can be restored) */
|
||||||
|
|
||||||
|
return oldhandler;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_buttoninit
|
* Name: up_buttoninit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* up_buttoninit() must be called to initialize button resources. After
|
||||||
|
* that, up_buttons() may be called to collect the current state of all
|
||||||
|
* buttons or up_irqbutton() may be called to register button interrupt
|
||||||
|
* handlers.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_buttoninit(void)
|
void up_buttoninit(void)
|
||||||
@ -81,6 +123,13 @@ void up_buttoninit(void)
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_buttons
|
* Name: up_buttons
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* After up_buttoninit() has been called, up_buttons() may be called to
|
||||||
|
* collect the state of all buttons. up_buttons() returns an 8-bit bit set
|
||||||
|
* with each bit associated with a button. See the BUTTON* definitions
|
||||||
|
* above for the meaning of each bit in the returned value.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
uint8_t up_buttons(void)
|
uint8_t up_buttons(void)
|
||||||
@ -94,71 +143,43 @@ uint8_t up_buttons(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_irqbutton1
|
* Name: up_irqbutton
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function may be called to register an interrupt handler that will
|
||||||
|
* be called when a button is depressed or released. The ID value is one
|
||||||
|
* of the BUTTON* definitions provided above. The previous interrupt
|
||||||
|
* handler address isreturned (so that it may restored, if so desired).
|
||||||
|
*
|
||||||
|
* Configuration Notes:
|
||||||
|
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
|
||||||
|
* overall GPIO IRQ feature and CONFIG_AVR32_GPIOIRQSETA and/or
|
||||||
|
* CONFIG_AVR32_GPIOIRQSETB must be enabled to select GPIOs to support
|
||||||
|
* interrupts on. For button support, bits 2 and 3 must be set in
|
||||||
|
* CONFIG_AVR32_GPIOIRQSETB (PB2 and PB3).
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_AVR32_GPIOIRQ
|
#ifdef CONFIG_AVR32_GPIOIRQ
|
||||||
xcpt_t up_irqbutton1(xcpt_t irqhandler)
|
xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_AVR32DEV_BUTTON1_IRQ
|
#ifdef CONFIG_AVR32DEV_BUTTON1_IRQ
|
||||||
xcpt_t oldhandler;
|
if (id == BUTTON1)
|
||||||
|
|
||||||
/* Attach the handler */
|
|
||||||
|
|
||||||
gpio_irqattach(GPIO_BUTTON1_IRQ, irqhandler, &oldhandler);
|
|
||||||
|
|
||||||
/* Enable/disable the interrupt */
|
|
||||||
|
|
||||||
if (irqhandler)
|
|
||||||
{
|
{
|
||||||
gpio_irqenable(GPIO_BUTTON1_IRQ);
|
return up_irqbuttonx(GPIO_BUTTON1_IRQ, irqhandler);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gpio_irqdisable(GPIO_BUTTON1_IRQ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the old button handler (so that it can be restored) */
|
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_irqbutton2
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_AVR32_GPIOIRQ
|
|
||||||
xcpt_t up_irqbutton2(xcpt_t irqhandler)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_AVR32DEV_BUTTON2_IRQ
|
#ifdef CONFIG_AVR32DEV_BUTTON2_IRQ
|
||||||
xcpt_t oldhandler;
|
if (id == BUTTON2)
|
||||||
|
|
||||||
/* Attach the handler */
|
|
||||||
|
|
||||||
gpio_irqattach(GPIO_BUTTON2_IRQ, irqhandler, &oldhandler);
|
|
||||||
|
|
||||||
/* Enable/disable the interrupt */
|
|
||||||
|
|
||||||
if (irqhandler)
|
|
||||||
{
|
{
|
||||||
gpio_irqenable(GPIO_BUTTON2_IRQ);
|
return up_irqbuttonx(GPIO_BUTTON2_IRQ, irqhandler);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gpio_irqdisable(GPIO_BUTTON2_IRQ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the old button handler (so that it can be restored) */
|
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* configs/sam3u-ek/include/board.h
|
* configs/sam3u-ek/include/board.h
|
||||||
* include/arch/board/board.h
|
* include/arch/board/board.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -160,9 +160,8 @@ EXTERN void sam3u_boardinitialize(void);
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* up_buttoninit() must be called to initialize button resources. After that,
|
* up_buttoninit() must be called to initialize button resources. After that,
|
||||||
* up_buttons() may be called to collect the state of all buttons. up_buttons()
|
* up_buttons() may be called to collect the current state of all buttons or
|
||||||
* returns an 8-bit bit set with each bit associated with a button. See the
|
* up_irqbutton() may be called to register button interrupt handlers.
|
||||||
* BUTTON* definitions above for the meaning of each bit in the returned value.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
@ -183,18 +182,18 @@ EXTERN void up_buttoninit(void);
|
|||||||
EXTERN uint8_t up_buttons(void);
|
EXTERN uint8_t up_buttons(void);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: up_irqbutton1/2
|
* Name: up_irqbutton
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* These functions may be called to register an interrupt handler that will be
|
* This function may be called to register an interrupt handler that will be
|
||||||
* called when BUTTON1/2 is depressed. The previous interrupt handler value is
|
* called when a button is depressed or released. The ID value is one of the
|
||||||
|
* BUTTON* definitions provided above. The previous interrupt handler address is
|
||||||
* returned (so that it may restored, if so desired).
|
* returned (so that it may restored, if so desired).
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_GPIOA_IRQ
|
#ifdef CONFIG_GPIOA_IRQ
|
||||||
EXTERN xcpt_t up_irqbutton1(xcpt_t irqhandler);
|
EXTERN xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
|
||||||
EXTERN xcpt_t up_irqbutton2(xcpt_t irqhandler);
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|
||||||
|
@ -66,12 +66,57 @@ static xcpt_t g_irqbutton2;
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irqbuttonx
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function implements the core of the up_irqbutton() logic.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_GPIOA_IRQ
|
||||||
|
static xcpt_t up_irqbuttonx(int irq, xcpt_t irqhandler, xcpt_t *store)
|
||||||
|
{
|
||||||
|
xcpt_t oldhandler;
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
/* Disable interrupts until we are done. This guarantees that the following
|
||||||
|
* operations are atomic.
|
||||||
|
*/
|
||||||
|
|
||||||
|
flags = irqsave();
|
||||||
|
|
||||||
|
/* Get the old button interrupt handler and save the new one */
|
||||||
|
|
||||||
|
oldhandler = *store;
|
||||||
|
*store = irqhandler;
|
||||||
|
|
||||||
|
/* Configure the interrupt */
|
||||||
|
|
||||||
|
sam3u_gpioirq(irq);
|
||||||
|
(void)irq_attach(irq, irqhandler);
|
||||||
|
sam3u_gpioirqenable(irq);
|
||||||
|
irqrestore(flags);
|
||||||
|
|
||||||
|
/* Return the old button handler (so that it can be restored) */
|
||||||
|
|
||||||
|
return oldhandler;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_buttoninit
|
* Name: up_buttoninit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* up_buttoninit() must be called to initialize button resources. After
|
||||||
|
* that, up_buttons() may be called to collect the current state of all
|
||||||
|
* buttons or up_irqbutton() may be called to register button interrupt
|
||||||
|
* handlers.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_buttoninit(void)
|
void up_buttoninit(void)
|
||||||
@ -80,9 +125,16 @@ void up_buttoninit(void)
|
|||||||
(void)sam3u_configgpio(GPIO_BUTTON2);
|
(void)sam3u_configgpio(GPIO_BUTTON2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/************************************************************************************
|
||||||
* Name: up_buttons
|
* Name: up_buttons
|
||||||
****************************************************************************/
|
*
|
||||||
|
* Description:
|
||||||
|
* After up_buttoninit() has been called, up_buttons() may be called to collect
|
||||||
|
* the state of all buttons. up_buttons() returns an 8-bit bit set with each bit
|
||||||
|
* associated with a button. See the BUTTON* definitions above for the meaning of
|
||||||
|
* each bit in the returned value.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
uint8_t up_buttons(void)
|
uint8_t up_buttons(void)
|
||||||
{
|
{
|
||||||
@ -95,66 +147,38 @@ uint8_t up_buttons(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_irqbutton1
|
* Name: up_irqbutton
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function may be called to register an interrupt handler that will
|
||||||
|
* be called when a button is depressed or released. The ID value is one
|
||||||
|
* of the BUTTON* definitions provided above. The previous interrupt
|
||||||
|
* handler address isreturned (so that it may restored, if so desired).
|
||||||
|
*
|
||||||
|
* Configuration Notes:
|
||||||
|
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
|
||||||
|
* overall GPIO IRQ feature and CONFIG_AVR32_GPIOIRQSETA and/or
|
||||||
|
* CONFIG_AVR32_GPIOIRQSETB must be enabled to select GPIOs to support
|
||||||
|
* interrupts on. For button support, bits 2 and 3 must be set in
|
||||||
|
* CONFIG_AVR32_GPIOIRQSETB (PB2 and PB3).
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_GPIOA_IRQ
|
#ifdef CONFIG_GPIOA_IRQ
|
||||||
xcpt_t up_irqbutton1(xcpt_t irqhandler)
|
xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
if (id == BUTTON1)
|
||||||
irqstate_t flags;
|
{
|
||||||
|
return up_irqbuttonx(IRQ_BUTTON1, irqhandler, &g_irqbutton1);
|
||||||
/* Disable interrupts until we are done */
|
}
|
||||||
|
else if (id == BUTTON2)
|
||||||
flags = irqsave();
|
{
|
||||||
|
return up_irqbuttonx(IRQ_BUTTON2, irqhandler, &g_irqbutton2);
|
||||||
/* Get the old button interrupt handler and save the new one */
|
}
|
||||||
|
else
|
||||||
oldhandler = g_irqbutton1;
|
{
|
||||||
g_irqbutton1 = irqhandler;
|
return NULL;
|
||||||
|
}
|
||||||
/* Configure the interrupt */
|
|
||||||
|
|
||||||
sam3u_gpioirq(IRQ_BUTTON1);
|
|
||||||
(void)irq_attach(IRQ_BUTTON1, irqhandler);
|
|
||||||
sam3u_gpioirqenable(IRQ_BUTTON1);
|
|
||||||
irqrestore(flags);
|
|
||||||
|
|
||||||
/* Return the old button handler (so that it can be restored) */
|
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_irqbutton2
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_GPIOA_IRQ
|
|
||||||
xcpt_t up_irqbutton2(xcpt_t irqhandler)
|
|
||||||
{
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
irqstate_t flags;
|
|
||||||
|
|
||||||
/* Disable interrupts until we are done */
|
|
||||||
|
|
||||||
flags = irqsave();
|
|
||||||
|
|
||||||
/* Get the old button interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = g_irqbutton2;
|
|
||||||
g_irqbutton2 = irqhandler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
|
||||||
|
|
||||||
sam3u_gpioirq(IRQ_BUTTON2);
|
|
||||||
(void)irq_attach(IRQ_BUTTON2, irqhandler);
|
|
||||||
sam3u_gpioirqenable(IRQ_BUTTON2);
|
|
||||||
irqrestore(flags);
|
|
||||||
|
|
||||||
/* Return the old button handler (so that it can be restored) */
|
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -709,6 +709,7 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
|
|||||||
|
|
||||||
if (power > 0)
|
if (power > 0)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_LCD_BACKLIGHT
|
||||||
uint32_t duty;
|
uint32_t duty;
|
||||||
|
|
||||||
/* Caclulate the new backlight duty. It is a faction of the timer1
|
/* Caclulate the new backlight duty. It is a faction of the timer1
|
||||||
@ -722,7 +723,7 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
|
|||||||
duty = LCD_BL_TIMER_PERIOD - 1;
|
duty = LCD_BL_TIMER_PERIOD - 1;
|
||||||
}
|
}
|
||||||
putreg16((uint16_t)duty, STM32_TIM1_CCR1);
|
putreg16((uint16_t)duty, STM32_TIM1_CCR1);
|
||||||
|
#endif
|
||||||
/* Then turn the display on */
|
/* Then turn the display on */
|
||||||
|
|
||||||
stm3210e_writereg(LCD_REG_7, g_lcddev.spfd5408b ? 0x0112 : 0x0173);
|
stm3210e_writereg(LCD_REG_7, g_lcddev.spfd5408b ? 0x0112 : 0x0173);
|
||||||
|
@ -531,6 +531,68 @@ EXTERN void sched_process_timer(void);
|
|||||||
|
|
||||||
EXTERN void irq_dispatch(int irq, FAR void *context);
|
EXTERN void irq_dispatch(int irq, FAR void *context);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Board-specific button interfaces exported by the board-specific logic
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_buttoninit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* up_buttoninit() must be called to initialize button resources. After
|
||||||
|
* that, up_buttons() may be called to collect the current state of all
|
||||||
|
* buttons or up_irqbutton() may be called to register button interrupt
|
||||||
|
* handlers.
|
||||||
|
*
|
||||||
|
* NOTE: This interface may or may not be supported by board-specific
|
||||||
|
* logic. If the board supports button interfaces, then CONFIG_ARCH_BUTTONS
|
||||||
|
* will be defined.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_BUTTONS
|
||||||
|
EXTERN void up_buttoninit(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_buttons
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* After up_buttoninit() has been called, up_buttons() may be called to
|
||||||
|
* collect the state of all buttons. up_buttons() returns an 8-bit bit set
|
||||||
|
* with each bit associated with a button. The meaning of the each button
|
||||||
|
* bit is board-specific.
|
||||||
|
*
|
||||||
|
* NOTE: This interface may or may not be supported by board-specific
|
||||||
|
* logic. If the board supports button interfaces, then CONFIG_ARCH_BUTTONS
|
||||||
|
* will be defined
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_BUTTONS
|
||||||
|
EXTERN uint8_t up_buttons(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irqbutton
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function may be called to register an interrupt handler that will
|
||||||
|
* be called when a button is depressed or released. The ID value is a
|
||||||
|
* button enumeration value that uniquely identifies a button resource.
|
||||||
|
* The previous interrupt handler address is returned (so that it may
|
||||||
|
* restored, if so desired).
|
||||||
|
*
|
||||||
|
* NOTE: This interface may or may not be supported by board-specific
|
||||||
|
* logic. If the board supports button interfaces, then CONFIG_ARCH_BUTTONS
|
||||||
|
* will be defined
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_BUTTONS
|
||||||
|
EXTERN xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Debug interfaces exported by the architecture-specific logic
|
* Debug interfaces exported by the architecture-specific logic
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user