*** EFM32 branch ***

1. Add SD card driver (SPI mode)
2. Add ELM ChaN FatFs support (Please read "Readme.txt")
   - Warning: FatFs is really FAT! (35KB)
3. Upgrade EFM32 libraries (CMSIS and efm32lib) to version 2.0.0
4. Merge all of the C source code in "libcpu\arm\cortex-m3\" into "cpuport.c"
5. Merge all of the assembly source code in "libcpu\arm\cortex-m3\" into "context_gcc.S" (except "start_gcc.S")

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1525 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
onelife.real
2011-06-20 01:56:28 +00:00
parent 1eca19cb01
commit 69ad018bc0
168 changed files with 505057 additions and 12953 deletions
+16 -3
View File
@@ -13,6 +13,7 @@
* Date Author Notes
* 2009-10-11 Bernard first version
* 2010-12-29 onelife Modify for EFM32
* 2011-06-17 onelife Merge all of the assembly source code into context_gcc.S
*********************************************************************/
/******************************************************************//**
@@ -87,9 +88,9 @@ _reswitch:
* R1 --> swith to thread stack
* psr, pc, LR, R12, R3, R2, R1, R0 are pushed into [from] stack
*/
.global rt_hw_pend_sv
.type rt_hw_pend_sv, %function
rt_hw_pend_sv:
.global PendSV_Handler
.type PendSV_Handler, %function
PendSV_Handler:
/* disable interrupt to protect context switch */
MRS R2, PRIMASK
CPSID I
@@ -169,6 +170,18 @@ rt_hw_interrupt_thread_switch:
BX LR
NOP
.global HardFault_Handler
.type HardFault_Handler, %function
HardFault_Handler:
/* get current context */
MRS r0, psp /* get fault thread stack pointer */
PUSH {lr}
BL rt_hw_hard_fault_exception
POP {lr}
ORR lr, lr, #0x04
BX lr
/******************************************************************//**
* @}
*********************************************************************/
-54
View File
@@ -1,54 +0,0 @@
/******************************************************************//**
* @file cpu.c
* @brief This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Development Team
* @author Bernard, onelife
* @version 0.4 beta
**********************************************************************
* @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
**********************************************************************
* @section Change Logs
* Date Author Notes
* 2009-01-05 Bernard first version
* 2011-02-14 onelife Modify for EFM32
*********************************************************************/
/******************************************************************//**
* @addtogroup cortex-m3
* @{
*********************************************************************/
/* Includes -------------------------------------------------------------------*/
#include <rtthread.h>
/* Private typedef -------------------------------------------------------------*/
/* Private define --------------------------------------------------------------*/
/* Private macro --------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------*/
/* Private function prototypes ---------------------------------------------------*/
/* Private functions ------------------------------------------------------------*/
/**
* reset cpu by dog's time-out
*
*/
void rt_hw_cpu_reset()
{
/*NOTREACHED*/
}
/**
* shutdown CPU
*
*/
void rt_hw_cpu_shutdown()
{
rt_kprintf("shutdown...\n");
RT_ASSERT(0);
}
/******************************************************************//**
* @}
*********************************************************************/
@@ -1,5 +1,5 @@
/******************************************************************//**
* @file fault.c
* @file cpu.c
* @brief This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Development Team
* @author Bernard, onelife
@@ -13,6 +13,7 @@
* Date Author Notes
* 2009-01-05 Bernard first version
* 2011-02-14 onelife Modify for EFM32
* 2011-06-17 onelife Merge all of the C source code into cpuport.c
*********************************************************************/
/******************************************************************//**
@@ -39,12 +40,42 @@ struct stack_contex
/* Private define --------------------------------------------------------------*/
/* Private macro --------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------*/
/* External function prototypes --------------------------------------------------*/
extern void list_thread(void);
extern rt_thread_t rt_current_thread;
/* exception and interrupt handler table */
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrput_flag;
/* Private function prototypes ---------------------------------------------------*/
/* Private functions ------------------------------------------------------------*/
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint8_t *stack_addr, void *texit)
{
unsigned long *stk;
stk = (unsigned long *)stack_addr;
*(stk) = 0x01000000L; /* PSR */
*(--stk) = (unsigned long)tentry; /* entry point, pc */
*(--stk) = (unsigned long)texit; /* lr */
*(--stk) = 0; /* r12 */
*(--stk) = 0; /* r3 */
*(--stk) = 0; /* r2 */
*(--stk) = 0; /* r1 */
*(--stk) = (unsigned long)parameter; /* r0 : argument */
*(--stk) = 0; /* r11 */
*(--stk) = 0; /* r10 */
*(--stk) = 0; /* r9 */
*(--stk) = 0; /* r8 */
*(--stk) = 0; /* r7 */
*(--stk) = 0; /* r6 */
*(--stk) = 0; /* r5 */
*(--stk) = 0; /* r4 */
/* return task's current stack address */
return (rt_uint8_t *)stk;
}
extern void list_thread(void);
extern rt_thread_t rt_current_thread;
void rt_hw_hard_fault_exception(struct stack_contex* contex)
{
rt_kprintf("psr: 0x%08x\n", contex->psr);
@@ -63,6 +94,13 @@ void rt_hw_hard_fault_exception(struct stack_contex* contex)
while (1);
}
void rt_hw_cpu_shutdown()
{
rt_kprintf("shutdown...\n");
RT_ASSERT(0);
}
/******************************************************************//**
* @}
*********************************************************************/
-43
View File
@@ -1,43 +0,0 @@
/******************************************************************//**
* @file fault_gcc.S
* @brief Faults handling functions
* COPYRIGHT (C) 2011, RT-Thread Development Team
* @author Bernard, onelife
* @version 0.4 beta
**********************************************************************
* @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
**********************************************************************
* @section Change Logs
* Date Author Notes
* 2009-10-11 Bernard first version
* 2010-12-29 onelife Modify for EFM32
*********************************************************************/
/******************************************************************//**
* @addtogroup cortex-m3
* @{
*********************************************************************/
.cpu cortex-m3
.fpu softvfp
.syntax unified
.thumb
.text
.global rt_hw_hard_fault
.type rt_hw_hard_fault, %function
rt_hw_hard_fault:
/* get current context */
MRS r0, psp /* get fault thread stack pointer */
PUSH {lr}
BL rt_hw_hard_fault_exception
POP {lr}
ORR lr, lr, #0x04
BX lr
/******************************************************************//**
* @}
*********************************************************************/
-39
View File
@@ -1,39 +0,0 @@
/******************************************************************//**
* @file interrupt.c
* @brief This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Development Team
* @author Bernard, onelife
* @version 0.4 beta
**********************************************************************
* @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
**********************************************************************
* @section Change Logs
* Date Author Notes
* 2009-01-05 Bernard first version
* 2011-02-14 onelife Modify for EFM32
*********************************************************************/
/******************************************************************//**
* @addtogroup cortex-m3
* @{
*********************************************************************/
/* Includes -------------------------------------------------------------------*/
#include <rtthread.h>
/* Private typedef -------------------------------------------------------------*/
/* Private define --------------------------------------------------------------*/
/* Private macro --------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------*/
/* exception and interrupt handler table */
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrput_flag;
/* Private function prototypes ---------------------------------------------------*/
/* Private functions ------------------------------------------------------------*/
/******************************************************************//**
* @}
*********************************************************************/
-72
View File
@@ -1,72 +0,0 @@
/******************************************************************//**
* @file stack.c
* @brief This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Development Team
* @author Bernard, onelife
* @version 0.4 beta
**********************************************************************
* @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
**********************************************************************
* @section Change Logs
* Date Author Notes
* 2006-08-23 Bernard first version
* 2011-02-14 onelife Modify for EFM32
*********************************************************************/
/******************************************************************//**
* @addtogroup cortex-m3
* @{
*********************************************************************/
/* Includes -------------------------------------------------------------------*/
#include <rtthread.h>
/* Private typedef -------------------------------------------------------------*/
/* Private define --------------------------------------------------------------*/
/* Private macro --------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------*/
/* Private function prototypes ---------------------------------------------------*/
/* Private functions ------------------------------------------------------------*/
/**
* This function will initialize thread stack
*
* @param tentry the entry of thread
* @param parameter the parameter of entry
* @param stack_addr the beginning stack address
* @param texit the function will be called when thread exit
*
* @return stack address
*/
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint8_t *stack_addr, void *texit)
{
unsigned long *stk;
stk = (unsigned long *)stack_addr;
*(stk) = 0x01000000L; /* PSR */
*(--stk) = (unsigned long)tentry; /* entry point, pc */
*(--stk) = (unsigned long)texit; /* lr */
*(--stk) = 0; /* r12 */
*(--stk) = 0; /* r3 */
*(--stk) = 0; /* r2 */
*(--stk) = 0; /* r1 */
*(--stk) = (unsigned long)parameter; /* r0 : argument */
*(--stk) = 0; /* r11 */
*(--stk) = 0; /* r10 */
*(--stk) = 0; /* r9 */
*(--stk) = 0; /* r8 */
*(--stk) = 0; /* r7 */
*(--stk) = 0; /* r6 */
*(--stk) = 0; /* r5 */
*(--stk) = 0; /* r4 */
/* return task's current stack address */
return (rt_uint8_t *)stk;
}
/******************************************************************//**
* @}
*********************************************************************/
+3 -3
View File
@@ -51,7 +51,7 @@ g_pfnVectors:
.word Initial_spTop
.word Reset_Handler
.word NMI_Handler
.word rt_hw_hard_fault
.word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
.word UsageFault_Handler
@@ -62,8 +62,8 @@ g_pfnVectors:
.word SVC_Handler
.word DebugMon_Handler
.word 0
.word rt_hw_pend_sv
.word rt_hw_timer_handler
.word PendSV_Handler
.word SysTick_Handler
/* External Interrupts */
.word DMA_IRQHandler /* 0: DMA Interrupt (efm32_dma.c) */
.word GPIO_EVEN_IRQHandler /* 1: GPIO_EVEN Interrupt */