mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Add STM32F3Discovery LED support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5618 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -158,22 +158,39 @@
|
||||
#define STM32_TIM27_FREQUENCY (STM32_HCLK_FREQUENCY/2)
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
|
||||
/* The STM32F3Discovery board has ten LEDs. Two of these are controlled by logic on
|
||||
* the board and are not available for software control:
|
||||
*
|
||||
* LD1 PWR: red LED indicates that the board is powered.
|
||||
* LD2 COM: LD2 default status is red. LD2 turns to green to indicate that
|
||||
* communications are in progress between the PC and the ST-LINK/V2.
|
||||
*
|
||||
* And eight can be controlled by software:
|
||||
*
|
||||
* User LD3: red LED is a user LED connected to the I/O PE9 of the STM32F303VCT6.
|
||||
* User LD4: blue LED is a user LED connected to the I/O PE8 of the STM32F303VCT6.
|
||||
* User LD5: orange LED is a user LED connected to the I/O PE10 of the STM32F303VCT6.
|
||||
* User LD6: green LED is a user LED connected to the I/O PE15 of the STM32F303VCT6.
|
||||
* User LD7: green LED is a user LED connected to the I/O PE11 of the STM32F303VCT6.
|
||||
* User LD8: orange LED is a user LED connected to the I/O PE14 of the STM32F303VCT6.
|
||||
* User LD9: blue LED is a user LED connected to the I/O PE12 of the STM32F303VCT6.
|
||||
* User LD10: red LED is a user LED connected to the I/O PE13 of the STM32F303VCT6.
|
||||
*
|
||||
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
|
||||
* way. The following definitions are used to access individual LEDs.
|
||||
*/
|
||||
|
||||
/* LED index values for use with stm32_setled() */
|
||||
|
||||
#define BOARD_LED1 0
|
||||
#define BOARD_LED2 1
|
||||
#define BOARD_LED3 2
|
||||
#define BOARD_LED4 3
|
||||
#define BOARD_NLEDS 4
|
||||
|
||||
#define BOARD_LED_GREEN BOARD_LED1
|
||||
#define BOARD_LED_ORANGE BOARD_LED2
|
||||
#define BOARD_LED_RED BOARD_LED3
|
||||
#define BOARD_LED_BLUE BOARD_LED4
|
||||
#define BOARD_LED1 0 /* User LD3 */
|
||||
#define BOARD_LED2 1 /* User LD4 */
|
||||
#define BOARD_LED3 2 /* User LD5 */
|
||||
#define BOARD_LED4 3 /* User LD6 */
|
||||
#define BOARD_LED5 4 /* User LD7 */
|
||||
#define BOARD_LED6 5 /* User LD8 */
|
||||
#define BOARD_LED7 6 /* User LD9 */
|
||||
#define BOARD_LED8 7 /* User LD10 */
|
||||
#define BOARD_NLEDS 8
|
||||
|
||||
/* LED bits for use with stm32_setleds() */
|
||||
|
||||
@@ -181,22 +198,44 @@
|
||||
#define BOARD_LED2_BIT (1 << BOARD_LED2)
|
||||
#define BOARD_LED3_BIT (1 << BOARD_LED3)
|
||||
#define BOARD_LED4_BIT (1 << BOARD_LED4)
|
||||
#define BOARD_LED5_BIT (1 << BOARD_LED5)
|
||||
#define BOARD_LED6_BIT (1 << BOARD_LED6)
|
||||
#define BOARD_LED7_BIT (1 << BOARD_LED7)
|
||||
#define BOARD_LED8_BIT (1 << BOARD_LED8)
|
||||
|
||||
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 4 LEDs on board the
|
||||
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 8 LEDs on board the
|
||||
* stm32f3discovery. The following definitions describe how NuttX controls the LEDs:
|
||||
*
|
||||
* SYMBOL Meaning LED state
|
||||
* Initially all LEDs are OFF
|
||||
* ------------------- ----------------------- ------------- ------------
|
||||
* LED_STARTED NuttX has been started LD3 ON
|
||||
* LED_HEAPALLOCATE Heap has been allocated LD4 ON
|
||||
* LED_IRQSENABLED Interrupts enabled LD4 ON
|
||||
* LED_STACKCREATED Idle stack created LD6 ON
|
||||
* LED_INIRQ In an interrupt LD7 should glow
|
||||
* LED_SIGNAL In a signal handler LD8 might glow
|
||||
* LED_ASSERTION An assertion failed LD9 ON while handling the assertion
|
||||
* LED_PANIC The system has crashed LD10 Blinking at 2Hz
|
||||
* LED_IDLE STM32 is is sleep mode (Optional, not used)
|
||||
*/
|
||||
|
||||
#define LED_STARTED 0 /* LED1 */
|
||||
#define LED_HEAPALLOCATE 1 /* LED2 */
|
||||
#define LED_IRQSENABLED 2 /* LED1 + LED2 */
|
||||
#define LED_STACKCREATED 3 /* LED3 */
|
||||
#define LED_INIRQ 4 /* LED1 + LED3 */
|
||||
#define LED_SIGNAL 5 /* LED2 + LED3 */
|
||||
#define LED_ASSERTION 6 /* LED1 + LED2 + LED3 */
|
||||
#define LED_PANIC 7 /* N/C + N/C + N/C + LED4 */
|
||||
#define LED_STARTED 0
|
||||
#define LED_HEAPALLOCATE 1
|
||||
#define LED_IRQSENABLED 2
|
||||
#define LED_STACKCREATED 3
|
||||
#define LED_INIRQ 4
|
||||
#define LED_SIGNAL 5
|
||||
#define LED_ASSERTION 6
|
||||
#define LED_PANIC 7
|
||||
|
||||
/* Button definitions ***************************************************************/
|
||||
/* The STM32F3Discovery supports one button: */
|
||||
/* The STM32F3Discovery supports two buttons; only one button is controllable by
|
||||
* software:
|
||||
*
|
||||
* B1 USER: user and wake-up button connected to the I/O PA0 of the STM32F303VCT6.
|
||||
* B2 RESET: pushbutton connected to NRST is used to RESET the STM32F303VCT6.
|
||||
*/
|
||||
|
||||
#define BUTTON_USER 0
|
||||
|
||||
|
||||
@@ -63,18 +63,54 @@
|
||||
#endif
|
||||
|
||||
/* STM32F3Discovery GPIOs **************************************************************************/
|
||||
/* LEDs */
|
||||
/* The STM32F3Discovery board has ten LEDs. Two of these are controlled by logic on
|
||||
* the board and are not available for software control:
|
||||
*
|
||||
* LD1 PWR: red LED indicates that the board is powered.
|
||||
* LD2 COM: LD2 default status is red. LD2 turns to green to indicate that
|
||||
* communications are in progress between the PC and the ST-LINK/V2.
|
||||
*
|
||||
* And eight can be controlled by software:
|
||||
*
|
||||
* User LD3: red LED is a user LED connected to the I/O PE9 of the STM32F303VCT6.
|
||||
* User LD4: blue LED is a user LED connected to the I/O PE8 of the STM32F303VCT6.
|
||||
* User LD5: orange LED is a user LED connected to the I/O PE10 of the STM32F303VCT6.
|
||||
* User LD6: green LED is a user LED connected to the I/O PE15 of the STM32F303VCT6.
|
||||
* User LD7: green LED is a user LED connected to the I/O PE11 of the STM32F303VCT6.
|
||||
* User LD8: orange LED is a user LED connected to the I/O PE14 of the STM32F303VCT6.
|
||||
* User LD9: blue LED is a user LED connected to the I/O PE12 of the STM32F303VCT6.
|
||||
* User LD10: red LED is a user LED connected to the I/O PE13 of the STM32F303VCT6.
|
||||
*
|
||||
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
|
||||
* way. The following definitions are used to access individual LEDs.
|
||||
*/
|
||||
|
||||
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN12)
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN9)
|
||||
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN13)
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN8)
|
||||
#define GPIO_LED3 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN14)
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN10)
|
||||
#define GPIO_LED4 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN15)
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN15)
|
||||
#define GPIO_LED5 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN11)
|
||||
#define GPIO_LED6 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN14)
|
||||
#define GPIO_LED7 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN12)
|
||||
#define GPIO_LED8 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN13)
|
||||
|
||||
/* BUTTONS -- NOTE that all have EXTI interrupts configured */
|
||||
/* Button definitions ***************************************************************/
|
||||
/* The STM32F3Discovery supports two buttons; only one button is controllable by
|
||||
* software:
|
||||
*
|
||||
* B1 USER: user and wake-up button connected to the I/O PA0 of the STM32F303VCT6.
|
||||
* B2 RESET: pushbutton connected to NRST is used to RESET the STM32F303VCT6.
|
||||
*
|
||||
* NOTE that EXTI interrupts are configured
|
||||
*/
|
||||
|
||||
#define MIN_IRQBUTTON BUTTON_USER
|
||||
#define MAX_IRQBUTTON BUTTON_USER
|
||||
|
||||
@@ -47,9 +47,7 @@
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32_internal.h"
|
||||
#include "stm32.h"
|
||||
#include "stm32f3discovery-internal.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
@@ -72,153 +70,32 @@
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/* The following definitions map the encoded LED setting to GPIO settings */
|
||||
|
||||
#define STM32F3_LED1 (1 << 0)
|
||||
#define STM32F3_LED2 (1 << 1)
|
||||
#define STM32F3_LED3 (1 << 2)
|
||||
#define STM32F3_LED4 (1 << 3)
|
||||
|
||||
#define ON_SETBITS_SHIFT (0)
|
||||
#define ON_CLRBITS_SHIFT (4)
|
||||
#define OFF_SETBITS_SHIFT (8)
|
||||
#define OFF_CLRBITS_SHIFT (12)
|
||||
|
||||
#define ON_BITS(v) ((v) & 0xff)
|
||||
#define OFF_BITS(v) (((v) >> 8) & 0x0ff)
|
||||
#define SETBITS(b) ((b) & 0x0f)
|
||||
#define CLRBITS(b) (((b) >> 4) & 0x0f)
|
||||
|
||||
#define ON_SETBITS(v) (SETBITS(ON_BITS(v))
|
||||
#define ON_CLRBITS(v) (CLRBITS(ON_BITS(v))
|
||||
#define OFF_SETBITS(v) (SETBITS(OFF_BITS(v))
|
||||
#define OFF_CLRBITS(v) (CLRBITS(OFF_BITS(v))
|
||||
|
||||
#define LED_STARTED_ON_SETBITS ((STM32F3_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_STARTED_ON_CLRBITS ((STM32F3_LED2|STM32F3_LED3|STM32F3_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STARTED_OFF_SETBITS (0 << OFF_SETBITS_SHIFT)
|
||||
#define LED_STARTED_OFF_CLRBITS ((STM32F3_LED1|STM32F3_LED2|STM32F3_LED3|STM32F3_LED4) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_HEAPALLOCATE_ON_SETBITS ((STM32F3_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_ON_CLRBITS ((STM32F3_LED1|STM32F3_LED3|STM32F3_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_SETBITS ((STM32F3_LED1) << OFF_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_CLRBITS ((STM32F3_LED2|STM32F3_LED3|STM32F3_LED4) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_IRQSENABLED_ON_SETBITS ((STM32F3_LED1|STM32F3_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_ON_CLRBITS ((STM32F3_LED3|STM32F3_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_SETBITS ((STM32F3_LED2) << OFF_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_CLRBITS ((STM32F3_LED1|STM32F3_LED3|STM32F3_LED4) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_STACKCREATED_ON_SETBITS ((STM32F3_LED3) << ON_SETBITS_SHIFT)
|
||||
#define LED_STACKCREATED_ON_CLRBITS ((STM32F3_LED1|STM32F3_LED2|STM32F3_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_SETBITS ((STM32F3_LED1|STM32F3_LED2) << OFF_SETBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_CLRBITS ((STM32F3_LED3|STM32F3_LED4) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_INIRQ_ON_SETBITS ((STM32F3_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_INIRQ_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_INIRQ_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_INIRQ_OFF_CLRBITS ((STM32F3_LED1) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_SIGNAL_ON_SETBITS ((STM32F3_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_SIGNAL_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_SIGNAL_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_SIGNAL_OFF_CLRBITS ((STM32F3_LED2) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_ASSERTION_ON_SETBITS ((STM32F3_LED4) << ON_SETBITS_SHIFT)
|
||||
#define LED_ASSERTION_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_ASSERTION_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_ASSERTION_OFF_CLRBITS ((STM32F3_LED4) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_PANIC_ON_SETBITS ((STM32F3_LED4) << ON_SETBITS_SHIFT)
|
||||
#define LED_PANIC_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_PANIC_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_PANIC_OFF_CLRBITS ((STM32F3_LED4) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const uint16_t g_ledbits[8] =
|
||||
/* This array maps an LED number to GPIO pin configuration */
|
||||
|
||||
static const uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||
{
|
||||
(LED_STARTED_ON_SETBITS | LED_STARTED_ON_CLRBITS |
|
||||
LED_STARTED_OFF_SETBITS | LED_STARTED_OFF_CLRBITS),
|
||||
|
||||
(LED_HEAPALLOCATE_ON_SETBITS | LED_HEAPALLOCATE_ON_CLRBITS |
|
||||
LED_HEAPALLOCATE_OFF_SETBITS | LED_HEAPALLOCATE_OFF_CLRBITS),
|
||||
|
||||
(LED_IRQSENABLED_ON_SETBITS | LED_IRQSENABLED_ON_CLRBITS |
|
||||
LED_IRQSENABLED_OFF_SETBITS | LED_IRQSENABLED_OFF_CLRBITS),
|
||||
|
||||
(LED_STACKCREATED_ON_SETBITS | LED_STACKCREATED_ON_CLRBITS |
|
||||
LED_STACKCREATED_OFF_SETBITS | LED_STACKCREATED_OFF_CLRBITS),
|
||||
|
||||
(LED_INIRQ_ON_SETBITS | LED_INIRQ_ON_CLRBITS |
|
||||
LED_INIRQ_OFF_SETBITS | LED_INIRQ_OFF_CLRBITS),
|
||||
|
||||
(LED_SIGNAL_ON_SETBITS | LED_SIGNAL_ON_CLRBITS |
|
||||
LED_SIGNAL_OFF_SETBITS | LED_SIGNAL_OFF_CLRBITS),
|
||||
|
||||
(LED_ASSERTION_ON_SETBITS | LED_ASSERTION_ON_CLRBITS |
|
||||
LED_ASSERTION_OFF_SETBITS | LED_ASSERTION_OFF_CLRBITS),
|
||||
|
||||
(LED_PANIC_ON_SETBITS | LED_PANIC_ON_CLRBITS |
|
||||
LED_PANIC_OFF_SETBITS | LED_PANIC_OFF_CLRBITS)
|
||||
GPIO_LED1, GPIO_LED2, GPIO_LED3, GPIO_LED4
|
||||
GPIO_LED5, GPIO_LED6, GPIO_LED7, GPIO_LED8
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline void led_clrbits(unsigned int clrbits)
|
||||
/****************************************************************************
|
||||
* Name: up_ledonoff
|
||||
****************************************************************************/
|
||||
|
||||
void up_ledonoff(int led, bool state)
|
||||
{
|
||||
if ((clrbits & STM32F3_LED1) != 0)
|
||||
if ((unsigned)led < BOARD_NLEDS)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED1, false);
|
||||
stm32_gpiowrite(g_ledcfg[led], state);
|
||||
}
|
||||
|
||||
if ((clrbits & STM32F3_LED2) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED2, false);
|
||||
}
|
||||
|
||||
if ((clrbits & STM32F3_LED3) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED3, false);
|
||||
}
|
||||
|
||||
if ((clrbits & STM32F3_LED4) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED4, false);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void led_setbits(unsigned int setbits)
|
||||
{
|
||||
if ((setbits & STM32F3_LED1) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED1, true);
|
||||
}
|
||||
|
||||
if ((setbits & STM32F3_LED2) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED2, true);
|
||||
}
|
||||
|
||||
if ((setbits & STM32F3_LED3) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED3, true);
|
||||
}
|
||||
|
||||
if ((setbits & STM32F3_LED4) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED4, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void led_setonoff(unsigned int bits)
|
||||
{
|
||||
led_clrbits(CLRBITS(bits));
|
||||
led_setbits(SETBITS(bits));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -231,12 +108,14 @@ static void led_setonoff(unsigned int bits)
|
||||
|
||||
void up_ledinit(void)
|
||||
{
|
||||
/* Configure LED1-4 GPIOs for output */
|
||||
int i;
|
||||
|
||||
stm32_configgpio(GPIO_LED1);
|
||||
stm32_configgpio(GPIO_LED2);
|
||||
stm32_configgpio(GPIO_LED3);
|
||||
stm32_configgpio(GPIO_LED4);
|
||||
/* Configure LED1-8 GPIOs for output */
|
||||
|
||||
for (i = 0; i < BOARD_NLEDS; i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -245,7 +124,7 @@ void up_ledinit(void)
|
||||
|
||||
void up_ledon(int led)
|
||||
{
|
||||
led_setonoff(ON_BITS(g_ledbits[led]));
|
||||
up_ledonoff(led, true);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -254,7 +133,7 @@ void up_ledon(int led)
|
||||
|
||||
void up_ledoff(int led)
|
||||
{
|
||||
led_setonoff(OFF_BITS(g_ledbits[led]));
|
||||
up_ledonoff(led, false);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
||||
@@ -159,6 +159,7 @@ xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
|
||||
{
|
||||
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,12 +45,9 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32_internal.h"
|
||||
#include "stm32.h"
|
||||
#include "stm32f3discovery-internal.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
@@ -78,114 +75,24 @@
|
||||
****************************************************************************/
|
||||
/* This array maps an LED number to GPIO pin configuration */
|
||||
|
||||
static uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||
static const uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||
{
|
||||
GPIO_LED1, GPIO_LED2, GPIO_LED3, GPIO_LED4
|
||||
GPIO_LED5, GPIO_LED6, GPIO_LED7, GPIO_LED8
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Protototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* LED Power Management */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
static int led_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static struct pm_callback_s g_ledscb =
|
||||
{
|
||||
.notify = led_pm_notify,
|
||||
.prepare = led_pm_prepare,
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_notify
|
||||
*
|
||||
* Description:
|
||||
* Notify the driver of new power state. This callback is called after
|
||||
* all drivers have had the opportunity to prepare for the new power state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
switch (pmstate)
|
||||
{
|
||||
case(PM_NORMAL):
|
||||
{
|
||||
/* Restore normal LEDs operation */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_IDLE):
|
||||
{
|
||||
/* Entering IDLE mode - Turn leds off */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_STANDBY):
|
||||
{
|
||||
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_SLEEP):
|
||||
{
|
||||
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
/* Should not get here */
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_prepare
|
||||
*
|
||||
* Description:
|
||||
* Request the driver to prepare for a new power state. This is a warning
|
||||
* that the system is about to enter into a new power state. The driver
|
||||
* should begin whatever operations that may be required to enter power
|
||||
* state. The driver may abort the state change mode by returning a
|
||||
* non-zero value from the callback function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
/* No preparation to change power modes is required by the LEDs driver.
|
||||
* We always accept the state change by returning OK.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -196,12 +103,14 @@ static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
|
||||
void stm32_ledinit(void)
|
||||
{
|
||||
/* Configure LED1-4 GPIOs for output */
|
||||
int i;
|
||||
|
||||
stm32_configgpio(GPIO_LED1);
|
||||
stm32_configgpio(GPIO_LED2);
|
||||
stm32_configgpio(GPIO_LED3);
|
||||
stm32_configgpio(GPIO_LED4);
|
||||
/* Configure LED1-8 GPIOs for output */
|
||||
|
||||
for (i = 0; i < BOARD_NLEDS; i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -222,27 +131,14 @@ void stm32_setled(int led, bool ledon)
|
||||
|
||||
void stm32_setleds(uint8_t ledset)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0);
|
||||
stm32_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0);
|
||||
stm32_gpiowrite(GPIO_LED3, (ledset & BOARD_LED3_BIT) == 0);
|
||||
stm32_gpiowrite(GPIO_LED4, (ledset & BOARD_LED4_BIT) == 0);
|
||||
}
|
||||
int i;
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledpminitialize
|
||||
****************************************************************************/
|
||||
/* Configure LED1-8 GPIOs for output */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
void up_ledpminitialize(void)
|
||||
{
|
||||
/* Register to receive power management callbacks */
|
||||
|
||||
int ret = pm_register(&g_ledscb);
|
||||
if (ret != OK)
|
||||
{
|
||||
up_ledon(LED_ASSERTION);
|
||||
for (i = 0; i < BOARD_NLEDS; i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
||||
|
||||
@@ -29,9 +29,7 @@ Development Environment
|
||||
|
||||
Either Linux or Cygwin on Windows can be used for the development environment.
|
||||
The source has been built only using the GNU toolchain (see below). Other
|
||||
toolchains will likely cause problems. Testing was performed using the Cygwin
|
||||
environment because the Raisonance R-Link emulatator and some RIDE7 development tools
|
||||
were used and those tools works only under Windows.
|
||||
toolchains will likely cause problems.
|
||||
|
||||
GNU Toolchain Options
|
||||
=====================
|
||||
@@ -476,6 +474,33 @@ options as used with the Atollic toolchain in the Make.defs file:
|
||||
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
|
||||
Configuration Changes
|
||||
---------------------
|
||||
|
||||
Below are all of the configuration changes that I had to make to configs/stm3240g-eval/nsh2
|
||||
in order to successfully build NuttX using the Atollic toolchain WITH FPU support:
|
||||
|
||||
-CONFIG_ARCH_FPU=n : Enable FPU support
|
||||
+CONFIG_ARCH_FPU=y
|
||||
|
||||
-CONFIG_STM32_CODESOURCERYW=y : Disable the CodeSourcery toolchain
|
||||
+CONFIG_STM32_CODESOURCERYW=n
|
||||
|
||||
-CONFIG_STM32_ATOLLIC_LITE=n : Enable *one* the Atollic toolchains
|
||||
CONFIG_STM32_ATOLLIC_PRO=n
|
||||
-CONFIG_STM32_ATOLLIC_LITE=y : The "Lite" version
|
||||
CONFIG_STM32_ATOLLIC_PRO=n : The "Pro" version
|
||||
|
||||
-CONFIG_INTELHEX_BINARY=y : Suppress generation FLASH download formats
|
||||
+CONFIG_INTELHEX_BINARY=n : (Only necessary with the "Lite" version)
|
||||
|
||||
-CONFIG_HAVE_CXX=y : Suppress generation of C++ code
|
||||
+CONFIG_HAVE_CXX=n : (Only necessary with the "Lite" version)
|
||||
|
||||
See the section above on Toolchains, NOTE 2, for explanations for some of
|
||||
the configuration settings. Some of the usual settings are just not supported
|
||||
by the "Lite" version of the Atollic toolchain.
|
||||
|
||||
FSMC SRAM
|
||||
=========
|
||||
|
||||
@@ -528,33 +553,6 @@ There are 4 possible SRAM configurations:
|
||||
CONFIG_STM32_FSMC_SRAM defined
|
||||
CONFIG_STM32_CCMEXCLUDE NOT defined
|
||||
|
||||
Configuration Changes
|
||||
---------------------
|
||||
|
||||
Below are all of the configuration changes that I had to make to configs/stm3240g-eval/nsh2
|
||||
in order to successfully build NuttX using the Atollic toolchain WITH FPU support:
|
||||
|
||||
-CONFIG_ARCH_FPU=n : Enable FPU support
|
||||
+CONFIG_ARCH_FPU=y
|
||||
|
||||
-CONFIG_STM32_CODESOURCERYW=y : Disable the CodeSourcery toolchain
|
||||
+CONFIG_STM32_CODESOURCERYW=n
|
||||
|
||||
-CONFIG_STM32_ATOLLIC_LITE=n : Enable *one* the Atollic toolchains
|
||||
CONFIG_STM32_ATOLLIC_PRO=n
|
||||
-CONFIG_STM32_ATOLLIC_LITE=y : The "Lite" version
|
||||
CONFIG_STM32_ATOLLIC_PRO=n : The "Pro" version
|
||||
|
||||
-CONFIG_INTELHEX_BINARY=y : Suppress generation FLASH download formats
|
||||
+CONFIG_INTELHEX_BINARY=n : (Only necessary with the "Lite" version)
|
||||
|
||||
-CONFIG_HAVE_CXX=y : Suppress generation of C++ code
|
||||
+CONFIG_HAVE_CXX=n : (Only necessary with the "Lite" version)
|
||||
|
||||
See the section above on Toolchains, NOTE 2, for explanations for some of
|
||||
the configuration settings. Some of the usual settings are just not supported
|
||||
by the "Lite" version of the Atollic toolchain.
|
||||
|
||||
SSD1289
|
||||
=======
|
||||
|
||||
|
||||
Reference in New Issue
Block a user