Skip to content

Commit d5c6519

Browse files
committed
Merge pull request #417 from BernardXiong/master
[BSP] Add more features for STM32F4.
2 parents 3962937 + 1512da3 commit d5c6519

38 files changed

+1243
-2261
lines changed

bsp/realview-a8/SConstruct

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ if GetDepend('RT_USING_VMM'):
3131
ldfile = rtconfig.LINK_SCRIPT)) != 0:
3232
print 'failed to generate linker script %s' % rtconfig.LINK_SCRIPT
3333
sys.exit(255)
34-
# if the linker script changed, relink the target
35-
Depends(TARGET, rtconfig.LINK_SCRIPT)
34+
# if the linker script changed, relink the target
35+
Depends(TARGET, rtconfig.LINK_SCRIPT)
36+
else:
37+
# we should use none-vmm link script
38+
link_flags = str(env['LINKFLAGS'])
39+
env['LINKFLAGS'] = link_flags.replace('_vmm.lds', '.lds')
3640

3741
# make a building
3842
DoBuilding(TARGET, objs)

bsp/realview-a8/applications/application.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,18 @@
1515
#include <rtthread.h>
1616
#include <components.h>
1717

18-
#include <pthread.h>
19-
20-
void *test_task(void *parameter)
18+
void init_thread(void* parameter)
2119
{
22-
int count = 0;
23-
24-
while (1)
25-
{
26-
rt_thread_delay(RT_TICK_PER_SECOND);
27-
rt_kprintf("count = %d\n", count ++);
28-
}
29-
30-
return RT_NULL;
20+
rt_components_init();
3121
}
3222

3323
int rt_application_init()
3424
{
35-
// pthread_t tid;
36-
37-
/* do component initialization */
38-
rt_components_init();
39-
#ifdef RT_USING_NEWLIB
40-
libc_system_init(RT_CONSOLE_DEVICE_NAME);
41-
#endif
25+
rt_thread_t tid;
4226

43-
// pthread_create(&tid, RT_NULL, test_task, RT_NULL);
27+
tid = rt_thread_create("init", init_thread, RT_NULL,
28+
1024, RT_THREAD_PRIORITY_MAX/3, 10);
29+
if (tid != RT_NULL) rt_thread_startup(tid);
4430

4531
return 0;
4632
}

bsp/realview-a8/drivers/board.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
#define SYS_CTRL __REG32(REALVIEW_SCTL_BASE)
3939

4040
#ifdef RT_USING_VMM
41-
#include <vmm.h>
42-
static rt_uint32_t timer_hw_base = 0;
43-
#define TIMER_HW_BASE (timer_hw_base)
41+
#include <vmm.h>
42+
static rt_uint32_t timer_hw_base = 0;
43+
#define TIMER_HW_BASE (timer_hw_base)
4444
#else
45-
#define TIMER_HW_BASE REALVIEW_TIMER2_3_BASE
45+
#define TIMER_HW_BASE REALVIEW_TIMER2_3_BASE
4646
#endif
4747

4848
void rt_hw_timer_ack(void)

bsp/realview-a8/drivers/serial.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "serial.h"
3434
#ifdef RT_USING_VMM
35-
#include <vmm.h>
35+
#include <vmm.h>
3636
#endif
3737

3838
struct hw_uart_device
@@ -165,8 +165,8 @@ int rt_hw_uart_init(void)
165165
config.parity = PARITY_NONE;
166166
config.stop_bits = STOP_BITS_1;
167167
config.invert = NRZ_NORMAL;
168-
config.bufsz = RT_SERIAL_RB_BUFSZ;
169-
168+
config.bufsz = RT_SERIAL_RB_BUFSZ;
169+
170170
#ifdef RT_USING_UART0
171171
uart = &_uart0_device;
172172
#ifdef RT_USING_VMM
@@ -194,7 +194,7 @@ int rt_hw_uart_init(void)
194194

195195
/* register UART1 device */
196196
rt_hw_serial_register(&_serial1, "uart1",
197-
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart);
197+
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart);
198198
/* enable Rx and Tx of UART */
199199
UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9);
200200
#endif

bsp/realview-a8/rtconfig.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
// </section>
108108

109109
// <section name="LIBC" description="C Runtime library setting" default="always" >
110-
// <bool name="RT_USING_NEWLIB" description="Using newlib library, only available under GNU GCC" default="true" />
111-
#define RT_USING_NEWLIB
110+
// <bool name="RT_USING_LIBC" description="Using libc library" default="true" />
111+
#define RT_USING_LIBC
112112
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
113113
#define RT_USING_PTHREADS
114114
// </section>
@@ -147,7 +147,7 @@
147147
#define RT_USING_LOGTRACE
148148

149149
// <section name="RT_USING_VMM" description="Enable RT-Thread hypervisor" default="true" >
150-
#define RT_USING_VMM
150+
// #define RT_USING_VMM
151151
// </section>
152152

153153
#endif

bsp/realview-a8/rtconfig.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
2222

2323
BUILD = 'debug'
24-
VMM = True
25-
#VMM = False
2624

2725
if PLATFORM == 'gcc':
2826
# toolchains
@@ -40,10 +38,7 @@
4038
DEVICE = ' -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3-d16 -ftree-vectorize -ffast-math -mfloat-abi=softfp'
4139
CFLAGS = DEVICE + ' -Wall'
4240
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
43-
if VMM:
44-
LINK_SCRIPT = 'realview_vmm.lds'
45-
else:
46-
LINK_SCRIPT = 'realview.lds'
41+
LINK_SCRIPT = 'realview_vmm.lds'
4742
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=realview.map,-cref,-u,system_vectors'+\
4843
' -T %s' % LINK_SCRIPT
4944

bsp/stm32f40x/SConstruct

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ else:
88
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
99

1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11-
from building import *
11+
try:
12+
from building import *
13+
except:
14+
print 'Cannot found RT-Thread root directory, please check RTT_ROOT'
15+
print RTT_ROOT
16+
exit(-1)
1217

1318
TARGET = 'rtthread-stm32f4xx.' + rtconfig.TARGET_EXT
1419

bsp/stm32f40x/drivers/board.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "stm32f4xx.h"
1919
#include "board.h"
20+
#include "usart.h"
21+
#include "gpio.h"
2022

2123
/**
2224
* @addtogroup STM32
@@ -91,7 +93,9 @@ void rt_hw_board_init()
9193
/* Configure the SysTick */
9294
SysTick_Configuration();
9395

94-
rt_hw_usart_init();
96+
stm32_hw_usart_init();
97+
stm32_hw_pin_init();
98+
9599
#ifdef RT_USING_CONSOLE
96100
rt_console_set_device(CONSOLE_DEVICE);
97101
#endif

bsp/stm32f40x/drivers/board.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040
#define STM32_SRAM_SIZE 128
4141
#define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024)
4242

43-
//#define RT_USING_UART1
44-
#define RT_USING_UART2
45-
//#define RT_USING_UART3
46-
//#define RT_USING_UART6
47-
4843
// <o> Console on USART: <0=> no console <1=>USART 1 <2=>USART 2 <3=> USART 3
4944
// <i>Default: 1
5045
#define STM32_CONSOLE_USART 2
@@ -63,11 +58,6 @@ void rt_hw_board_init(void);
6358

6459
#define FINSH_DEVICE_NAME CONSOLE_DEVICE
6560

66-
void rt_hw_usart_init(void);
67-
68-
/* SD Card init function */
69-
void rt_hw_msd_init(void);
70-
7161
#endif
7262

7363
// <<< Use Configuration Wizard in Context Menu >>>

0 commit comments

Comments
 (0)