Skip to content

Commit 3a1c1c4

Browse files
committed
[bsp] Add BSP for TM4C1294XL (TI Tiva C Series Connected LaunchPad)
1 parent fc6747e commit 3a1c1c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+136340
-0
lines changed

bsp/tm4c129x/SConscript

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# for module compiling
2+
import os
3+
Import('RTT_ROOT')
4+
5+
cwd = str(Dir('#'))
6+
objs = []
7+
list = os.listdir(cwd)
8+
9+
for d in list:
10+
path = os.path.join(cwd, d)
11+
if os.path.isfile(os.path.join(path, 'SConscript')):
12+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
13+
14+
Return('objs')

bsp/tm4c129x/SConstruct

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
if os.getenv('RTT_ROOT'):
6+
RTT_ROOT = os.getenv('RTT_ROOT')
7+
else:
8+
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
9+
10+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11+
from building import *
12+
13+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
14+
15+
env = Environment(tools = ['mingw'],
16+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
17+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
18+
AR = rtconfig.AR, ARFLAGS = '-rc',
19+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
20+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
21+
22+
Export('RTT_ROOT')
23+
Export('rtconfig')
24+
25+
# prepare building environment
26+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
27+
28+
# make a building
29+
DoBuilding(TARGET, objs)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Import('RTT_ROOT')
2+
Import('rtconfig')
3+
from building import *
4+
5+
cwd = os.path.join(str(Dir('#')), 'applications')
6+
src = Glob('*.c')
7+
CPPPATH = [cwd, str(Dir('#'))]
8+
9+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
10+
11+
Return('group')
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* File : application.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2014, RT-Thread Development Team
5+
*
6+
* The license and distribution terms for this file may be
7+
* found in the file LICENSE in this distribution or at
8+
* http://www.rt-thread.org/license/LICENSE
9+
*
10+
* Change Logs:
11+
* Date Author Notes
12+
* 2014-07-18 ArdaFu the first version for TM4C129X
13+
*/
14+
15+
#include <rtthread.h>
16+
#include <board.h>
17+
#include <components.h>
18+
19+
/* thread phase init */
20+
void rt_init_thread_entry(void *parameter)
21+
{
22+
/* Initialization RT-Thread Components */
23+
#ifdef RT_USING_COMPONENTS_INIT
24+
rt_components_init();
25+
#endif
26+
}
27+
28+
int rt_application_init(void)
29+
{
30+
rt_thread_t tid;
31+
tid = rt_thread_create("init",
32+
rt_init_thread_entry, RT_NULL,
33+
2048, RT_THREAD_PRIORITY_MAX / 3, 20);
34+
if (tid != RT_NULL) rt_thread_startup(tid);
35+
36+
return 0;
37+
}

bsp/tm4c129x/applications/board.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* File : board.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2013 RT-Thread Develop Team
5+
*
6+
* The license and distribution terms for this file may be
7+
* found in the file LICENSE in this distribution or at
8+
* http://www.rt-thread.org/license/LICENSE
9+
*
10+
* Change Logs:
11+
* Date Author Notes
12+
* 2009-01-05 Bernard first implementation
13+
* 2014-07-18 ArdaFu Port to TM4C129X
14+
*/
15+
16+
#include <rthw.h>
17+
#include <rtthread.h>
18+
#include <components.h>
19+
20+
#include "board.h"
21+
#include "drv_uart.h"
22+
#include "interrupt.h"
23+
#include "sysctl.h"
24+
#include "systick.h"
25+
#include "fpu.h"
26+
#include "driverlib/rom_map.h"
27+
28+
#define SYS_CLOCK_DEFAULT 120000000
29+
uint32_t SysClock;
30+
31+
#define FAULT_NMI 2 // NMI fault
32+
#define FAULT_HARD 3 // Hard fault
33+
#define FAULT_MPU 4 // MPU fault
34+
#define FAULT_BUS 5 // Bus fault
35+
#define FAULT_USAGE 6 // Usage fault
36+
#define FAULT_SVCALL 11 // SVCall
37+
#define FAULT_DEBUG 12 // Debug monitor
38+
#define FAULT_PENDSV 14 // PendSV
39+
#define FAULT_SYSTICK 15 // System Tick
40+
41+
/**
42+
* This is the timer interrupt service routine.
43+
*
44+
*/
45+
void SysTick_Handler(void)
46+
{
47+
/* enter interrupt */
48+
rt_interrupt_enter();
49+
50+
rt_tick_increase();
51+
52+
/* leave interrupt */
53+
rt_interrupt_leave();
54+
}
55+
56+
extern void PendSV_Handler(void);
57+
extern void HardFault_Handler(void);
58+
59+
60+
/**
61+
* This function will initial LPC40xx board.
62+
*/
63+
void rt_hw_board_init()
64+
{
65+
IntRegister(FAULT_HARD, HardFault_Handler);
66+
IntRegister(FAULT_PENDSV, PendSV_Handler);
67+
IntRegister(FAULT_SYSTICK, SysTick_Handler);
68+
69+
//
70+
// Enable lazy stacking for interrupt handlers. This allows floating-point
71+
// instructions to be used within interrupt handlers, but at the expense of
72+
// extra stack usage.
73+
//
74+
MAP_FPULazyStackingEnable();
75+
76+
//
77+
// Set the clocking to run directly from the external crystal/oscillator.
78+
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
79+
// crystal on your board.
80+
//
81+
SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
82+
SYS_CLOCK_DEFAULT);
83+
84+
MAP_SysTickDisable();
85+
MAP_SysTickPeriodSet(SysClock/ RT_TICK_PER_SECOND - 1);
86+
MAP_SysTickIntEnable();
87+
MAP_SysTickEnable();
88+
89+
90+
/* set pend exception priority */
91+
//IntPrioritySet(FAULT_PENDSV, (1 << __NVIC_PRIO_BITS) - 1);
92+
/*init uart device*/
93+
94+
rt_hw_uart_init();
95+
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
96+
//
97+
// Enable interrupts to the processor.
98+
//
99+
MAP_IntMasterEnable();
100+
}

bsp/tm4c129x/applications/board.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* File : board.h
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2009, RT-Thread Development Team
5+
*
6+
* The license and distribution terms for this file may be
7+
* found in the file LICENSE in this distribution or at
8+
* http://www.rt-thread.org/license/LICENSE
9+
*
10+
* Change Logs:
11+
* Date Author Notes
12+
* 2009-09-22 Bernard add board.h to this bsp
13+
* 2010-02-04 Magicoe add board.h to LPC176x bsp
14+
* 2014-07-18 ArdaFu port it to TM4C129X bsp
15+
*/
16+
17+
#ifndef __BOARD_H__
18+
#define __BOARD_H__
19+
20+
#include "tm4c129xnczad.h"
21+
#include <rtthread.h>
22+
#include <stdbool.h>
23+
#include <stdint.h>
24+
25+
extern uint32_t SysClock;
26+
// <RDTConfigurator URL="http://www.rt-thread.com/eclipse">
27+
28+
// <bool name="RT_USING_UART0" description="Using UART0" default="true" />
29+
#define RT_USING_UART0
30+
// <bool name="RT_USING_UART1" description="Using UART1" default="true" />
31+
//#define RT_USING_UART1
32+
// <bool name="RT_USING_UART2" description="Using UART2" default="true" />
33+
//#define RT_USING_UART2
34+
35+
// </RDTConfigurator>
36+
37+
#ifdef __CC_ARM
38+
extern int Image$$RW_IRAM1$$ZI$$Limit;
39+
#define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit)
40+
#elif __ICCARM__
41+
#pragma section="HEAP"
42+
#define HEAP_BEGIN (__segment_end("HEAP"))
43+
#else
44+
extern int __bss_end;
45+
#define HEAP_BEGIN ((void *)&__bss_end)
46+
#endif
47+
#define HEAP_END (0x20000000 + 256*1024)
48+
49+
#define FINSH_DEVICE_NAME RT_CONSOLE_DEVICE_NAME
50+
void rt_hw_board_init(void);
51+
52+
#endif
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* File : startup.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2009, RT-Thread Development Team
5+
*
6+
* The license and distribution terms for this file may be
7+
* found in the file LICENSE in this distribution or at
8+
* http://www.rt-thread.org/license/LICENSE
9+
*
10+
* Change Logs:
11+
* Date Author Notes
12+
* 2009-01-05 Bernard first implementation
13+
* 2010-03-04 Magicoe for LPC17xx
14+
* 2014-07-18 ArdaFu Port to TM4C129X
15+
*/
16+
17+
#include <rthw.h>
18+
#include <rtthread.h>
19+
20+
#include "board.h"
21+
22+
extern int rt_application_init(void);
23+
24+
/**
25+
* This function will startup RT-Thread RTOS.
26+
*/
27+
void rtthread_startup(void)
28+
{
29+
/* initialize board */
30+
rt_hw_board_init();
31+
32+
/* show version */
33+
rt_show_version();
34+
35+
#ifdef RT_USING_HEAP
36+
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
37+
#endif
38+
39+
/* initialize scheduler system */
40+
rt_system_scheduler_init();
41+
/* initialize system timer*/
42+
rt_system_timer_init();
43+
/* initialize application */
44+
rt_application_init();
45+
46+
/* initialize timer thread */
47+
rt_system_timer_thread_init();
48+
49+
/* initialize idle thread */
50+
rt_thread_idle_init();
51+
52+
/* start scheduler */
53+
rt_system_scheduler_start();
54+
55+
/* never reach here */
56+
return ;
57+
}
58+
59+
int main(void)
60+
{
61+
/* disable interrupt first */
62+
rt_hw_interrupt_disable();
63+
64+
/* startup RT-Thread RTOS */
65+
rtthread_startup();
66+
67+
return 0;
68+
}

bsp/tm4c129x/drivers/SConscript

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = Glob('*.c')
5+
6+
# remove no need file.
7+
if GetDepend('RT_USING_LWIP') == False:
8+
SrcRemove(src, 'drv_emac.c')
9+
10+
CPPPATH = [cwd]
11+
12+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
13+
14+
Return('group')

0 commit comments

Comments
 (0)