Skip to content

Commit 8897a1c

Browse files
committed
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
2 parents aad29c0 + 4a40ba9 commit 8897a1c

File tree

26 files changed

+814
-381
lines changed

26 files changed

+814
-381
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
*.c linguist-language=C
2+
*.C linguist-language=C
3+
*.h linguist-language=C
4+
*.H linguist-language=C
5+
16
* text=auto
27

38
*.S text

bsp/allwinner_tina/libcpu/interrupt.c

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* File : interrupt.c
33
* This file is part of RT-Thread RTOS
4-
* COPYRIGHT (C) 2017, RT-Thread Development Team
4+
* COPYRIGHT (C) 2017-2021, RT-Thread Development Team
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
2020
* Change Logs:
2121
* Date Author Notes
2222
* 2018-02-08 RT-Thread the first version
23+
* 2020-03-02 Howard Su Use structure to access registers
2324
*/
2425

2526
#include <rthw.h>
@@ -38,9 +39,6 @@ static void rt_hw_interrupt_handler(int vector, void *param)
3839
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
3940
}
4041

41-
#define readl(addr) (*(volatile unsigned int *)(addr))
42-
#define writel(value,addr) (*(volatile unsigned int *)(addr) = (value))
43-
4442
/**
4543
* This function will initialize hardware interrupt
4644
*/
@@ -63,20 +61,20 @@ void rt_hw_interrupt_init(void)
6361
/* set base_addr reg */
6462
INTC->base_addr_reg = 0x00000000;
6563
/* clear enable */
66-
INTC->en_reg0 = 0x00000000;
67-
INTC->en_reg1 = 0x00000000;
64+
INTC->en_reg[0] = 0x00000000;
65+
INTC->en_reg[1] = 0x00000000;
6866
/* mask interrupt */
69-
INTC->mask_reg0 = 0xFFFFFFFF;
70-
INTC->mask_reg1 = 0xFFFFFFFF;
67+
INTC->mask_reg[0] = 0xFFFFFFFF;
68+
INTC->mask_reg[1] = 0xFFFFFFFF;
7169
/* clear pending */
72-
INTC->pend_reg0 = 0x00000000;
73-
INTC->pend_reg1 = 0x00000000;
70+
INTC->pend_reg[0] = 0x00000000;
71+
INTC->pend_reg[1] = 0x00000000;
7472
/* set priority */
75-
INTC->resp_reg0 = 0x00000000;
76-
INTC->resp_reg1 = 0x00000000;
73+
INTC->resp_reg[0] = 0x00000000;
74+
INTC->resp_reg[1] = 0x00000000;
7775
/* close fiq interrupt */
78-
INTC->ff_reg0 = 0x00000000;
79-
INTC->ff_reg1 = 0x00000000;
76+
INTC->ff_reg[0] = 0x00000000;
77+
INTC->ff_reg[1] = 0x00000000;
8078
}
8179

8280
/**
@@ -85,20 +83,16 @@ void rt_hw_interrupt_init(void)
8583
*/
8684
void rt_hw_interrupt_mask(int vector)
8785
{
88-
rt_uint32_t mask_addr, data;
89-
86+
int index;
9087
if ((vector < 0) || (vector > INTERRUPTS_MAX))
9188
{
9289
return;
9390
}
9491

95-
mask_addr = (rt_uint32_t)(&INTC->mask_reg0);
96-
mask_addr += vector & 0xE0 ? sizeof(rt_uint32_t *) : 0;
92+
index = (vector & 0xE0) != 0;
93+
vector = (vector & 0x1F);
9794

98-
vector &= 0x1F;
99-
data = readl(mask_addr);
100-
data |= 0x1 << vector;
101-
writel(data, mask_addr);
95+
INTC->mask_reg[index] |= 1 << vector;
10296
}
10397

10498
/**
@@ -108,20 +102,16 @@ void rt_hw_interrupt_mask(int vector)
108102
*/
109103
void rt_hw_interrupt_umask(int vector)
110104
{
111-
rt_uint32_t mask_addr, data;
112-
105+
int index;
113106
if ((vector < 0) || (vector > INTERRUPTS_MAX))
114107
{
115108
return;
116109
}
117110

118-
mask_addr = (rt_uint32_t)(&INTC->mask_reg0);
119-
mask_addr += vector & 0xE0 ? sizeof(rt_uint32_t *) : 0;
111+
index = (vector & 0xE0) != 0;
112+
vector = (vector & 0x1F);
120113

121-
vector &= 0x1F;
122-
data = readl(mask_addr);
123-
data &= ~(0x1 << vector);
124-
writel(data, mask_addr);
114+
INTC->mask_reg[index] &= ~(1 << vector);
125115
}
126116

127117
/**
@@ -136,7 +126,7 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
136126
void *param, const char *name)
137127
{
138128
rt_isr_handler_t old_handler = RT_NULL;
139-
rt_uint32_t pend_addr, en_addr, data;
129+
int index;
140130

141131
if ((vector < 0) || (vector > INTERRUPTS_MAX))
142132
{
@@ -151,19 +141,11 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
151141
isr_table[vector].handler = handler;
152142
isr_table[vector].param = param;
153143

154-
pend_addr = (rt_uint32_t)(&INTC->pend_reg0);
155-
en_addr = (rt_uint32_t)(&INTC->en_reg0);
156-
pend_addr += vector & 0xE0 ? sizeof(rt_uint32_t *) : 0;
157-
en_addr += vector & 0xE0 ? sizeof(rt_uint32_t *) : 0;
144+
index = (vector & 0xE0) != 0;
145+
vector = (vector & 0x1F);
158146

159-
vector &= 0x1F;
160-
data = readl(pend_addr);
161-
data &= ~(0x1 << vector);
162-
writel(data, pend_addr);
163-
164-
data = readl(en_addr);
165-
data |= 0x1 << vector;
166-
writel(data, en_addr);
147+
INTC->pend_reg[index] &= ~(0x1 << vector);
148+
INTC->en_reg[index] |= 0x1 << vector;
167149

168150
return old_handler;
169151
}
@@ -173,7 +155,7 @@ void rt_interrupt_dispatch(rt_uint32_t fiq_irq)
173155
void *param;
174156
int vector;
175157
rt_isr_handler_t isr_func;
176-
rt_uint32_t pend_addr, data;
158+
int index;
177159

178160
vector = INTC->vector_reg - INTC->base_addr_reg;
179161
vector = vector >> 2;
@@ -184,13 +166,11 @@ void rt_interrupt_dispatch(rt_uint32_t fiq_irq)
184166
/* jump to fun */
185167
isr_func(vector, param);
186168
/* clear pend bit */
187-
pend_addr = (rt_uint32_t)(&INTC->pend_reg0);
188-
pend_addr += vector & 0xE0 ? sizeof(rt_uint32_t *) : 0;
189169

190-
vector &= 0x1F;
191-
data = readl(pend_addr);
192-
data &= ~(0x1 << vector);
193-
writel(data, pend_addr);
170+
index = (vector & 0xE0) != 0;
171+
vector = (vector & 0x1F);
172+
173+
INTC->pend_reg[index] &= ~(0x1 << vector);
194174

195175
#ifdef RT_USING_INTERRUPT_INFO
196176
isr_table[vector].counter ++;

bsp/allwinner_tina/libcpu/interrupt.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* File : interrupt.h
33
* This file is part of RT-Thread RTOS
4-
* COPYRIGHT (C) 2017, RT-Thread Development Team
4+
* COPYRIGHT (C) 2017-2021, RT-Thread Development Team
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
2020
* Change Logs:
2121
* Date Author Notes
2222
* 2018-02-08 RT-Thread the first version
23+
* 2020-03-2 Howard Su Define same regsiters as an array
2324
*/
2425
#ifndef __INTERRUPT_H__
2526
#define __INTERRUPT_H__
@@ -74,34 +75,21 @@ struct tina_intc
7475
volatile rt_uint32_t base_addr_reg; /* 0x04 */
7576
volatile rt_uint32_t reserved0;
7677
volatile rt_uint32_t nmi_ctrl_reg; /* 0x0C */
77-
volatile rt_uint32_t pend_reg0; /* 0x10 */
78-
volatile rt_uint32_t pend_reg1; /* 0x14 */
78+
volatile rt_uint32_t pend_reg[2]; /* 0x10, 0x14 */
7979
volatile rt_uint32_t reserved1[2];
80-
volatile rt_uint32_t en_reg0; /* 0x20 */
81-
volatile rt_uint32_t en_reg1; /* 0x24 */
80+
volatile rt_uint32_t en_reg[2]; /* 0x20, 0x24 */
8281
volatile rt_uint32_t reserved2[2];
83-
volatile rt_uint32_t mask_reg0; /* 0x30 */
84-
volatile rt_uint32_t mask_reg1; /* 0x34 */
82+
volatile rt_uint32_t mask_reg[2]; /* 0x30, 0x34 */
8583
volatile rt_uint32_t reserved3[2];
86-
volatile rt_uint32_t resp_reg0; /* 0x40 */
87-
volatile rt_uint32_t resp_reg1; /* 0x44 */
84+
volatile rt_uint32_t resp_reg[2]; /* 0x40, 0x44 */
8885
volatile rt_uint32_t reserved4[2];
89-
volatile rt_uint32_t ff_reg0; /* 0x50 */
90-
volatile rt_uint32_t ff_reg1; /* 0x54 */
86+
volatile rt_uint32_t ff_reg[2]; /* 0x50, 0x54 */
9187
volatile rt_uint32_t reserved5[2];
92-
volatile rt_uint32_t prio_reg0; /* 0x60 */
93-
volatile rt_uint32_t prio_reg1; /* 0x64 */
94-
volatile rt_uint32_t prio_reg2; /* 0x68 */
95-
volatile rt_uint32_t prio_reg3; /* 0x6C */
88+
volatile rt_uint32_t prio_reg[4]; /* 0x60 - 0x6c */
9689
} ;
9790

9891
typedef struct tina_intc *tina_intc_t;
9992

10093
#define INTC ((tina_intc_t)INTC_BASE_ADDR)
10194

102-
void rt_hw_interrupt_init(void);
103-
void rt_hw_interrupt_mask(int vector);
104-
void rt_hw_interrupt_umask(int vector);
105-
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, const char *name);
106-
10795
#endif /* __INTERRUPT_H__ */

bsp/fh8620/libraries/driverlib/fh_mmc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ int MMC_SetCardWidth(struct fh_mmc_obj *mmc_obj, int width)
194194
default:
195195
rt_kprintf("ERROR: %s, card width %d is not supported\n", __func__, width);
196196
return -RT_ERROR;
197-
break;
198197
}
199198
return 0;
200199
}

bsp/nrf5x/nrf52832/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# vscode common config
2+
.vscode/*
3+
!.vscode/launch.json
4+
!.vscode/tasks.json
5+
6+
# OS X icon info
7+
.DS_Store
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "cortex-debug",
6+
"request": "launch",
7+
"servertype": "jlink",
8+
"cwd": "${workspaceRoot}",
9+
"executable": "rt-thread.elf",
10+
"name": "Cortex Debug",
11+
"device": "nrf52",
12+
"interface": "swd"
13+
}
14+
]
15+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "config",
8+
"type": "shell",
9+
"command": "RTT_ROOT=../../.. scons --pyconfig",
10+
"problemMatcher": []
11+
},
12+
{
13+
"label": "build",
14+
"type": "shell",
15+
"command": "scons",
16+
"problemMatcher": [],
17+
"group": {
18+
"kind": "build",
19+
"isDefault": true
20+
}
21+
},
22+
{
23+
"label": "clean",
24+
"type": "shell",
25+
"command": "scons -c",
26+
"problemMatcher": []
27+
},
28+
{
29+
"label": "flash",
30+
"type": "shell",
31+
"command": "nrfjprog -f nrf52 --program rt-thread.hex --sectorerase",
32+
"group": "build",
33+
"problemMatcher": []
34+
},
35+
{
36+
"label": "flash_softdevice",
37+
"type": "shell",
38+
"command": "nrfjprog -f nrf52 --program packages/nrf5x_sdk-latest/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex --sectorerase",
39+
"problemMatcher": []
40+
},
41+
{
42+
"label": "erase",
43+
"type": "shell",
44+
"command": "nrfjprog -f nrf52 --eraseall",
45+
"problemMatcher": []
46+
},
47+
{
48+
"label": "reset",
49+
"type": "shell",
50+
"command": "nrfjprog -f nrf52 --reset",
51+
"problemMatcher": []
52+
}
53+
]
54+
}

bsp/nrf5x/nrf52832/README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 简介
44

5-
该文件夹主要存放所有主芯片为nRF52840的板级支持包。目前默认支持的开发板是官方[PCA10040](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52-DK)
5+
该文件夹主要存放所有主芯片为nRF52832的板级支持包。目前默认支持的开发板是官方[PCA10040](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52-DK)
66
主要内容如下:
77

88
- 开发板资源介绍
@@ -61,6 +61,30 @@ PCA10040-nrf52832开发板常用 **板载资源** 如下:
6161
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
6262

6363

64+
### VS Code开发支持
65+
66+
配置步骤:
67+
68+
1. 在命令行设置以下两个环境变量:
69+
70+
```bash
71+
export RTT_CC=gcc
72+
export RTT_EXEC_PATH=<工具链路径/bin>
73+
```
74+
75+
2. 搜索插件`Cortex-debug`并安装。
76+
3. 安装[nRF Command Line Tools](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools)以支持`nrfjprog`命令。
77+
4. 在.vscode/settings.json内配置工具链和`JlinkGDBServer`,sample:
78+
79+
```json
80+
{
81+
"cortex-debug.armToolchainPath": "/usr/local/gcc-arm-none-eabi-9-2019-q4-major/bin/",
82+
"cortex-debug.armToolchainPrefix": "arm-none-eabi",
83+
"cortex-debug.JLinkGDBServerPath": "/Applications/SEGGER/JLink/JLinkGDBServer"
84+
}
85+
```
86+
87+
5. 点击`终端`->`运行任务`->`build`编译,点击`终端`->`运行任务`->`flash`烧录,点击左侧`debug`->`run`使用VS Code进行debug。
6488

6589
## 支持其他开发板
6690

bsp/nrf5x/nrf52832/rtconfig.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
else:
5555
CFLAGS += ' -O2'
5656

57-
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
57+
POST_ACTION = OBJCPY + ' -O binary $TARGET rt-thread.bin\n'
58+
POST_ACTION += OBJCPY + ' -O ihex $TARGET rt-thread.hex\n'
59+
POST_ACTION += SIZE + ' $TARGET \n'
5860

5961
elif PLATFORM == 'armcc':
6062
# toolchains

bsp/stm32/libraries/STM32MPxx_HAL/SConscript

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ if GetDepend(['BSP_USING_CRYP']):
119119
src += ['STM32MP1xx_HAL_Driver/Src/stm32mp1xx_hal_cryp.c']
120120
src += ['STM32MP1xx_HAL_Driver/Src/stm32mp1xx_hal_cryp_ex.c']
121121

122+
if GetDepend(['BSP_USING_RTC']):
123+
src += ['STM32MP1xx_HAL_Driver/Src/stm32mp1xx_hal_rtc.c']
124+
src += ['STM32MP1xx_HAL_Driver/Src/stm32mp1xx_hal_rtc_ex.c']
125+
122126
path = [cwd + '/STM32MP1xx_HAL_Driver/Inc',
123127
cwd + '/CMSIS/Device/ST/STM32MP1xx/Include',
124128
cwd + '/CMSIS/Core/Include',

0 commit comments

Comments
 (0)