Skip to content

Commit 1512da3

Browse files
committed
Merge remote-tracking branch 'china/master'
2 parents 8d63cba + 71930b0 commit 1512da3

File tree

21 files changed

+355
-80
lines changed

21 files changed

+355
-80
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/drivers/gpio.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ static const struct pin_index pins[] =
8888
{53, RCC_AHB1Periph_GPIOA, GPIOA, GPIO_Pin_4},
8989
};
9090

91-
#define ITEM_NUM(items) sizeof(items)/sizeof(items[0])
92-
const struct pin_index * get_pin(uint8_t pin)
91+
#define ITEM_NUM(items) sizeof(items)/sizeof(items[0])
92+
const struct pin_index *get_pin(uint8_t pin)
9393
{
94-
const struct pin_index* index;
94+
const struct pin_index *index;
9595

96-
if(pin < ITEM_NUM(pins))
96+
if (pin < ITEM_NUM(pins))
9797
{
9898
index = &pins[pin];
9999
}
@@ -110,12 +110,12 @@ void stm32_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
110110
const struct pin_index *index;
111111

112112
index = get_pin(pin);
113-
if(index == RT_NULL)
113+
if (index == RT_NULL)
114114
{
115115
return;
116116
}
117117

118-
if(value == PIN_LOW)
118+
if (value == PIN_LOW)
119119
{
120120
GPIO_ResetBits(index->gpio, index->pin);
121121
}
@@ -133,12 +133,12 @@ int stm32_pin_read(rt_device_t dev, rt_base_t pin)
133133
value = PIN_LOW;
134134

135135
index = get_pin(pin);
136-
if(index == RT_NULL)
136+
if (index == RT_NULL)
137137
{
138138
return value;
139139
}
140140

141-
if(GPIO_ReadInputDataBit(index->gpio, index->pin) == Bit_RESET)
141+
if (GPIO_ReadInputDataBit(index->gpio, index->pin) == Bit_RESET)
142142
{
143143
value = PIN_LOW;
144144
}
@@ -156,7 +156,7 @@ void stm32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
156156
GPIO_InitTypeDef GPIO_InitStructure;
157157

158158
index = get_pin(pin);
159-
if(index == RT_NULL)
159+
if (index == RT_NULL)
160160
{
161161
return;
162162
}
@@ -169,19 +169,19 @@ void stm32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
169169
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
170170
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
171171

172-
if(mode == PIN_MODE_OUTPUT)
172+
if (mode == PIN_MODE_OUTPUT)
173173
{
174174
/* output setting */
175175
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
176176
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
177177
}
178-
else if(mode == PIN_MODE_INPUT)
178+
else if (mode == PIN_MODE_INPUT)
179179
{
180180
/* input setting: not pull. */
181181
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
182182
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
183183
}
184-
else if(mode == PIN_MODE_INPUT_PULLUP)
184+
else if (mode == PIN_MODE_INPUT_PULLUP)
185185
{
186186
/* input setting: pull up. */
187187
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
@@ -196,7 +196,7 @@ void stm32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
196196
GPIO_Init(index->gpio, &GPIO_InitStructure);
197197
}
198198

199-
const static struct rt_pin_ops _stm32_pin_ops =
199+
const static struct rt_pin_ops _stm32_pin_ops =
200200
{
201201
stm32_pin_mode,
202202
stm32_pin_write,

bsp/stm32f40x/drivers/usart.c

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222
#include <rtdevice.h>
2323

2424
/* UART GPIO define. */
25-
#define UART1_GPIO_TX GPIO_Pin_6
25+
#define UART1_GPIO_TX GPIO_Pin_6
2626
#define UART1_TX_PIN_SOURCE GPIO_PinSource6
27-
#define UART1_GPIO_RX GPIO_Pin_7
27+
#define UART1_GPIO_RX GPIO_Pin_7
2828
#define UART1_RX_PIN_SOURCE GPIO_PinSource7
29-
#define UART1_GPIO GPIOB
29+
#define UART1_GPIO GPIOB
3030
#define UART1_GPIO_RCC RCC_AHB1Periph_GPIOB
31-
#define RCC_APBPeriph_UART1 RCC_APB2Periph_USART1
32-
#define UART1_TX_DMA DMA1_Channel4
33-
#define UART1_RX_DMA DMA1_Channel5
31+
#define RCC_APBPeriph_UART1 RCC_APB2Periph_USART1
32+
#define UART1_TX_DMA DMA1_Channel4
33+
#define UART1_RX_DMA DMA1_Channel5
3434

35-
#define UART2_GPIO_TX GPIO_Pin_2
35+
#define UART2_GPIO_TX GPIO_Pin_2
3636
#define UART2_TX_PIN_SOURCE GPIO_PinSource2
37-
#define UART2_GPIO_RX GPIO_Pin_3
37+
#define UART2_GPIO_RX GPIO_Pin_3
3838
#define UART2_RX_PIN_SOURCE GPIO_PinSource3
39-
#define UART2_GPIO GPIOA
39+
#define UART2_GPIO GPIOA
4040
#define UART2_GPIO_RCC RCC_AHB1Periph_GPIOA
41-
#define RCC_APBPeriph_UART2 RCC_APB1Periph_USART2
42-
#define UART2_TX_DMA DMA1_Channel4
43-
#define UART2_RX_DMA DMA1_Channel5
41+
#define RCC_APBPeriph_UART2 RCC_APB1Periph_USART2
42+
#define UART2_TX_DMA DMA1_Channel4
43+
#define UART2_RX_DMA DMA1_Channel5
4444

4545
#define UART3_GPIO_TX GPIO_Pin_8
4646
#define UART3_TX_PIN_SOURCE GPIO_PinSource8
@@ -55,13 +55,13 @@
5555
/* STM32 uart driver */
5656
struct stm32_uart
5757
{
58-
USART_TypeDef* uart_device;
58+
USART_TypeDef *uart_device;
5959
IRQn_Type irq;
6060
};
6161

6262
static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
6363
{
64-
struct stm32_uart* uart;
64+
struct stm32_uart *uart;
6565
USART_InitTypeDef USART_InitStructure;
6666

6767
RT_ASSERT(serial != RT_NULL);
@@ -89,15 +89,13 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
8989

9090
/* Enable USART */
9191
USART_Cmd(uart->uart_device, ENABLE);
92-
/* enable interrupt */
93-
USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
9492

9593
return RT_EOK;
9694
}
9795

9896
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
9997
{
100-
struct stm32_uart* uart;
98+
struct stm32_uart *uart;
10199

102100
RT_ASSERT(serial != RT_NULL);
103101
uart = (struct stm32_uart *)serial->parent.user_data;
@@ -107,10 +105,14 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
107105
case RT_DEVICE_CTRL_CLR_INT:
108106
/* disable rx irq */
109107
UART_DISABLE_IRQ(uart->irq);
108+
/* disable interrupt */
109+
USART_ITConfig(uart->uart_device, USART_IT_RXNE, DISABLE);
110110
break;
111111
case RT_DEVICE_CTRL_SET_INT:
112112
/* enable rx irq */
113113
UART_ENABLE_IRQ(uart->irq);
114+
/* enable interrupt */
115+
USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
114116
break;
115117
}
116118

@@ -119,7 +121,7 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
119121

120122
static int stm32_putc(struct rt_serial_device *serial, char c)
121123
{
122-
struct stm32_uart* uart;
124+
struct stm32_uart *uart;
123125

124126
RT_ASSERT(serial != RT_NULL);
125127
uart = (struct stm32_uart *)serial->parent.user_data;
@@ -133,7 +135,7 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
133135
static int stm32_getc(struct rt_serial_device *serial)
134136
{
135137
int ch;
136-
struct stm32_uart* uart;
138+
struct stm32_uart *uart;
137139

138140
RT_ASSERT(serial != RT_NULL);
139141
uart = (struct stm32_uart *)serial->parent.user_data;
@@ -166,13 +168,13 @@ struct rt_serial_device serial1;
166168

167169
void USART1_IRQHandler(void)
168170
{
169-
struct stm32_uart* uart;
171+
struct stm32_uart *uart;
170172

171173
uart = &uart1;
172174

173175
/* enter interrupt */
174176
rt_interrupt_enter();
175-
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
177+
if (USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
176178
{
177179
rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
178180
/* clear interrupt */
@@ -200,13 +202,13 @@ struct rt_serial_device serial2;
200202

201203
void USART2_IRQHandler(void)
202204
{
203-
struct stm32_uart* uart;
205+
struct stm32_uart *uart;
204206

205207
uart = &uart2;
206208

207209
/* enter interrupt */
208210
rt_interrupt_enter();
209-
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
211+
if (USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
210212
{
211213
rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
212214
/* clear interrupt */
@@ -234,13 +236,13 @@ struct rt_serial_device serial3;
234236

235237
void USART3_IRQHandler(void)
236238
{
237-
struct stm32_uart* uart;
239+
struct stm32_uart *uart;
238240

239241
uart = &uart3;
240242

241243
/* enter interrupt */
242244
rt_interrupt_enter();
243-
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
245+
if (USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
244246
{
245247
rt_hw_serial_isr(&serial3, RT_SERIAL_EVENT_RX_IND);
246248
/* clear interrupt */
@@ -321,7 +323,7 @@ static void GPIO_Configuration(void)
321323
#endif /* RT_USING_UART3 */
322324
}
323325

324-
static void NVIC_Configuration(struct stm32_uart* uart)
326+
static void NVIC_Configuration(struct stm32_uart *uart)
325327
{
326328
NVIC_InitTypeDef NVIC_InitStructure;
327329

@@ -335,7 +337,7 @@ static void NVIC_Configuration(struct stm32_uart* uart)
335337

336338
int stm32_hw_usart_init(void)
337339
{
338-
struct stm32_uart* uart;
340+
struct stm32_uart *uart;
339341
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
340342

341343
RCC_Configuration();

0 commit comments

Comments
 (0)