mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-26 01:07:21 +00:00
*** EFM32 branch ***
1. Upgrade Cortex driver library (CMSIS -> CMSIS & Device): version 2.3.2 -> 3.0.1 & 3.0.0 - Remove "bsp/efm32/Libraries/CMSIS/Lib/ARM", "bsp/efm32/Libraries/CMSIS/Lib/G++" and "bsp/efm32/Libraries/CMSIS/SVD" to save space 2. Upgrade EFM32 driver libraries (efm32lib -> emlib): version 2.3.2 -> 3.0.0 - Remove "bsp/efm32/Libraries/Device/EnergyMicro/EFM32LG" and "bsp/efm32/Libraries/Device/EnergyMicro/EFM32TG" to save space 3. Upgrade EFM32GG_DK3750 development kit driver library: version 1.2.2 -> 2.0.1 4. Upgrade EFM32_Gxxx_DK development kit driver library: version 1.7.3 -> 2.0.1 5. Add energy management unit driver and test code 6. Modify linker script and related code to compatible with new version of libraries 7. Change EFM32 branch version number to 1.0 8. Add photo frame demo application git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2122 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
/******************************************************************//**
|
||||
* @file dev_led.c
|
||||
* @brief LED driver of RT-Thread RTOS for EFM32
|
||||
* COPYRIGHT (C) 2011, RT-Thread Development Team
|
||||
* @author Bernard, onelife
|
||||
* @version 0.4 beta
|
||||
**********************************************************************
|
||||
/***************************************************************************//**
|
||||
* @file dev_led.c
|
||||
* @brief LED driver of RT-Thread RTOS for EFM32
|
||||
* COPYRIGHT (C) 2012, RT-Thread Development Team
|
||||
* @author onelife
|
||||
* @version 1.0
|
||||
*******************************************************************************
|
||||
* @section License
|
||||
* The license and distribution terms for this file may be found in the file LICENSE in this
|
||||
* distribution or at http://www.rt-thread.org/license/LICENSE
|
||||
**********************************************************************
|
||||
* The license and distribution terms for this file may be found in the file
|
||||
* LICENSE in this distribution or at http://www.rt-thread.org/license/LICENSE
|
||||
*******************************************************************************
|
||||
* @section Change Logs
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard the first version
|
||||
* 2010-12-27 onelife Modify for EFM32
|
||||
* 2011-05-06 onelife Add EFM32 development kit support
|
||||
* 2011-12-08 onelife Add giant gecko development kit support
|
||||
*********************************************************************/
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard the first version
|
||||
* 2010-12-27 onelife Modify for EFM32
|
||||
* 2011-05-06 onelife Add EFM32 development kit support
|
||||
* 2011-12-08 onelife Add giant gecko development kit support
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************//**
|
||||
/***************************************************************************//**
|
||||
* @addtogroup efm32
|
||||
* @{
|
||||
*********************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
/* Includes -------------------------------------------------------------------*/
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "board.h"
|
||||
#include "dev_led.h"
|
||||
|
||||
/* Private typedef -------------------------------------------------------------*/
|
||||
/* Private define --------------------------------------------------------------*/
|
||||
/* Private macro --------------------------------------------------------------*/
|
||||
/* Private constants -----------------------------------------------------------*/
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#if defined(EFM32_G8XX_STK)
|
||||
static const rt_uint8_t leds_list[LEDS_MAX_NUMBER][2] = \
|
||||
static const rt_uint8_t leds_list[LEDS_MAX_NUMBER][2] = \
|
||||
{
|
||||
{LEDS_PIN_PORT_0, LEDS_PIN_NUMBER_0},
|
||||
{LEDS_PIN_PORT_1, LEDS_PIN_NUMBER_1},
|
||||
{LEDS_PIN_PORT_2, LEDS_PIN_NUMBER_2},
|
||||
{LEDS_PIN_PORT_3, LEDS_PIN_NUMBER_3}
|
||||
{LEDS_PIN_PORT_0, LEDS_PIN_NUMBER_0},
|
||||
{LEDS_PIN_PORT_1, LEDS_PIN_NUMBER_1},
|
||||
{LEDS_PIN_PORT_2, LEDS_PIN_NUMBER_2},
|
||||
{LEDS_PIN_PORT_3, LEDS_PIN_NUMBER_3}
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Private variables ------------------------------------------------------------*/
|
||||
/* Private function prototypes ---------------------------------------------------*/
|
||||
/* Private functions ------------------------------------------------------------*/
|
||||
/******************************************************************//**
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Turn on a LED
|
||||
*
|
||||
@@ -54,24 +54,24 @@ static const rt_uint8_t leds_list[LEDS_MAX_NUMBER][2] = \
|
||||
* @param[in] num
|
||||
* LED number
|
||||
*
|
||||
*********************************************************************/
|
||||
******************************************************************************/
|
||||
void rt_hw_led_on(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
#if defined(EFM32_G8XX_STK)
|
||||
GPIO_PinOutSet(leds_list[num][0], leds_list[num][1]);
|
||||
GPIO_PinOutSet(leds_list[num][0], leds_list[num][1]);
|
||||
#elif (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
|
||||
{
|
||||
rt_uint16_t leds;
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs() | (rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
leds = DVK_getLEDs() | (rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Turn off a LED
|
||||
*
|
||||
@@ -82,24 +82,24 @@ void rt_hw_led_on(rt_uint8_t num)
|
||||
* @param[in] num
|
||||
* LED number
|
||||
*
|
||||
*********************************************************************/
|
||||
******************************************************************************/
|
||||
void rt_hw_led_off(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
#if defined(EFM32_G8XX_STK)
|
||||
GPIO_PinOutClear(leds_list[num][0], leds_list[num][1]);
|
||||
GPIO_PinOutClear(leds_list[num][0], leds_list[num][1]);
|
||||
#elif (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
|
||||
{
|
||||
rt_uint16_t leds;
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs() & ~(rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
leds = DVK_getLEDs() & ~(rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(leds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Toggle the state of a LED
|
||||
*
|
||||
@@ -110,36 +110,36 @@ void rt_hw_led_off(rt_uint8_t num)
|
||||
* @param[in] num
|
||||
* LED number
|
||||
*
|
||||
*********************************************************************/
|
||||
******************************************************************************/
|
||||
void rt_hw_led_toggle(rt_uint8_t num)
|
||||
{
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
#if defined(EFM32_G8XX_STK)
|
||||
GPIO_PinOutToggle(leds_list[num][0], leds_list[num][1]);
|
||||
GPIO_PinOutToggle(leds_list[num][0], leds_list[num][1]);
|
||||
#elif (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
|
||||
{
|
||||
rt_uint16_t leds;
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs() ^ (rt_uint16_t)(1 << num);
|
||||
DVK_setLEDs(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);
|
||||
RT_ASSERT(num < LEDS_MAX_NUMBER);
|
||||
|
||||
#if defined(EFM32_G8XX_STK)
|
||||
return (rt_uint8_t)GPIO_PinInGet(leds_list[num][0], leds_list[num][1]);
|
||||
return (rt_uint8_t)GPIO_PinInGet(leds_list[num][0], leds_list[num][1]);
|
||||
#elif (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
|
||||
return ((DVK_getLEDs() & (rt_uint16_t)(1 << num)) >> num);
|
||||
return ((DVK_getLEDs() & (rt_uint16_t)(1 << num)) >> num);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Initialize the LEDs related GPIO
|
||||
*
|
||||
@@ -148,73 +148,73 @@ rt_uint8_t rt_hw_led_state(rt_uint8_t num)
|
||||
* @note
|
||||
*
|
||||
* @return
|
||||
* Error code
|
||||
*********************************************************************/
|
||||
* Error code
|
||||
******************************************************************************/
|
||||
rt_err_t rt_hw_led_init(void)
|
||||
{
|
||||
#if defined(EFM32_G8XX_STK)
|
||||
rt_uint8_t i;
|
||||
rt_uint8_t i;
|
||||
|
||||
/* Configure GPIO */
|
||||
for (i = 0; i < LEDS_MAX_NUMBER; i++)
|
||||
{
|
||||
GPIO_PinModeSet(
|
||||
leds_list[i][0],
|
||||
leds_list[i][1],
|
||||
gpioModePushPull,
|
||||
0);
|
||||
}
|
||||
/* Configure GPIO */
|
||||
for (i = 0; i < LEDS_MAX_NUMBER; i++)
|
||||
{
|
||||
GPIO_PinModeSet(
|
||||
leds_list[i][0],
|
||||
leds_list[i][1],
|
||||
gpioModePushPull,
|
||||
0);
|
||||
}
|
||||
#endif
|
||||
return RT_EOK;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* Export to FINSH
|
||||
*********************************************************************/
|
||||
/***************************************************************************//**
|
||||
* Export to FINSH
|
||||
******************************************************************************/
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
|
||||
void list_leds(void)
|
||||
{
|
||||
rt_uint8_t i;
|
||||
rt_uint8_t i;
|
||||
|
||||
rt_kprintf(" led \t port \t pin \t state\n");
|
||||
rt_kprintf(" -----\t -----\t -----\t -----\n");
|
||||
rt_kprintf(" led \t port \t pin \t state\n");
|
||||
rt_kprintf(" -----\t -----\t -----\t -----\n");
|
||||
|
||||
for (i = 0; i < LEDS_MAX_NUMBER; i++)
|
||||
{
|
||||
{
|
||||
#if defined(EFM32_G8XX_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));
|
||||
i, leds_list[i][0], leds_list[i][1], rt_hw_led_state(i));
|
||||
#elif (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
|
||||
rt_uint16_t leds;
|
||||
rt_uint16_t leds;
|
||||
|
||||
leds = DVK_getLEDs();
|
||||
rt_kprintf(" %d \t FPGA \t FPGA \t %x \n",
|
||||
i, (leds & (1 << i))? 1 : 0);
|
||||
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.)
|
||||
|
||||
void set_led(rt_uint32_t led, rt_uint32_t state)
|
||||
{
|
||||
/* set led status */
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
rt_hw_led_off(led);
|
||||
break;
|
||||
case 1:
|
||||
rt_hw_led_on(led);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* set led status */
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
rt_hw_led_off(led);
|
||||
break;
|
||||
case 1:
|
||||
rt_hw_led_on(led);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(set_led, turn led (0 - 3) on (1) or off (0).)
|
||||
#endif
|
||||
|
||||
/******************************************************************//**
|
||||
/***************************************************************************//**
|
||||
* @}
|
||||
*********************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user