mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-26 01:07:21 +00:00
*** EFM32 branch ***
1. Add EFM32 development kit support 2. Add USART sync mode (SPI) support 3. Add SPI Flash device (ST M25PX16) driver and demo application git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1401 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
* @section Change Logs
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard the first version
|
||||
* 2010-12-27 onelife modify for EFM32
|
||||
* 2010-12-27 onelife Modify for EFM32
|
||||
* 2011-05-06 onelife Add EFM32 development kit support
|
||||
*********************************************************************/
|
||||
|
||||
/******************************************************************//**
|
||||
@@ -28,6 +29,7 @@
|
||||
/* Private define --------------------------------------------------------------*/
|
||||
/* Private macro --------------------------------------------------------------*/
|
||||
/* Private constants -----------------------------------------------------------*/
|
||||
#if defined(EFM32_G890_STK)
|
||||
static const rt_uint8_t leds_list[LEDS_MAX_NUMBER][2] = \
|
||||
{
|
||||
{LEDS_PIN_PORT_0, LEDS_PIN_NUMBER_0},
|
||||
@@ -35,6 +37,7 @@ static const rt_uint8_t leds_list[LEDS_MAX_NUMBER][2] = \
|
||||
{LEDS_PIN_PORT_2, LEDS_PIN_NUMBER_2},
|
||||
{LEDS_PIN_PORT_3, LEDS_PIN_NUMBER_3}
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Private variables ------------------------------------------------------------*/
|
||||
/* Private function prototypes ---------------------------------------------------*/
|
||||
@@ -54,8 +57,17 @@ static const rt_uint8_t leds_list[LEDS_MAX_NUMBER][2] = \
|
||||
void rt_hw_led_on(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
|
||||
#if defined(EFM32_G890_STK)
|
||||
GPIO_PinOutSet(leds_list[num][0], leds_list[num][1]);
|
||||
#elif defined(EFM32_G290_DK)
|
||||
{
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs() | (rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
@@ -73,8 +85,17 @@ void rt_hw_led_on(rt_uint8_t num)
|
||||
void rt_hw_led_off(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
|
||||
#if defined(EFM32_G890_STK)
|
||||
GPIO_PinOutClear(leds_list[num][0], leds_list[num][1]);
|
||||
#elif defined(EFM32_G290_DK)
|
||||
{
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs() & ~(rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
@@ -92,15 +113,29 @@ void rt_hw_led_off(rt_uint8_t num)
|
||||
void rt_hw_led_toggle(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
|
||||
#if defined(EFM32_G890_STK)
|
||||
GPIO_PinOutToggle(leds_list[num][0], leds_list[num][1]);
|
||||
#elif defined(EFM32_G290_DK)
|
||||
{
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs() ^ (rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
rt_uint8_t rt_hw_led_state(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
|
||||
#if defined(EFM32_G890_STK)
|
||||
return (rt_uint8_t)GPIO_PinInGet(leds_list[num][0], leds_list[num][1]);
|
||||
#elif defined(EFM32_G290_DK)
|
||||
return ((DVK_getLEDs() & (rt_uint16_t)(1 << num)) >> num);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
@@ -116,6 +151,7 @@ rt_uint8_t rt_hw_led_state(rt_uint8_t num)
|
||||
*********************************************************************/
|
||||
rt_err_t rt_hw_led_init(void)
|
||||
{
|
||||
#if defined(EFM32_G890_STK)
|
||||
rt_uint8_t i;
|
||||
|
||||
/* Configure GPIO */
|
||||
@@ -127,7 +163,7 @@ rt_err_t rt_hw_led_init(void)
|
||||
gpioModePushPull,
|
||||
0);
|
||||
}
|
||||
|
||||
#endif
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -146,8 +182,16 @@ void list_leds(void)
|
||||
|
||||
for (i = 0; i < LEDS_MAX_NUMBER; i++)
|
||||
{
|
||||
#if defined(EFM32_G890_STK)
|
||||
rt_kprintf(" %d \t %x \t %x \t %x \n",
|
||||
i, leds_list[i][0], leds_list[i][1], rt_hw_led_state(i));
|
||||
#elif defined(EFM32_G290_DK)
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs();
|
||||
rt_kprintf(" %d \t FPGA \t FPGA \t %x \n",
|
||||
i, (leds & (1 << i))? 1 : 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(list_leds, list all the LEDs.)
|
||||
|
||||
Reference in New Issue
Block a user