Skip to content

Commit bacbf28

Browse files
authoredOct 11, 2021
Merge pull request #5139 from greedyhao/ab32
[bsp][bluetrum] convert uintxx_t to rt_uintxx_t
2 parents 465f5fa + 9fc0c75 commit bacbf28

File tree

10 files changed

+90
-84
lines changed

10 files changed

+90
-84
lines changed
 

‎bsp/bluetrum/ab32vg1-ab-prougen/README.md

+30-28
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@
1010

1111
通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
1212

13+
## 注意事项
14+
15+
芯片有部分不开源的代码是以静态库提供的,静态库在软件包中,默认已勾选,直接运行 `pkgs --update` 即可
16+
17+
波特率默认为 1.5M,需要使用 [Downloader](https://github.com/BLUETRUM/Downloader) 下载 `.dcf` 到芯片,需要编译后自动下载,需要在 `Downloader` 中的下载的下拉窗中选择 `自动`;目前暂时屏蔽 uart1 打印
18+
19+
使用 `romfs` 时,需要自己生成 `romfs.c` 进行替换,操作参考[使用 RomFS](https://www.rt-thread.org/document/site/tutorial/qemu-network/filesystems/filesystems/#romfs)
20+
21+
编译报错的时候,如果出现重复定义的报错,可能需要在 `cconfig.h` 中手动添加以下配置
22+
23+
``` c
24+
#define HAVE_SIGEVENT 1
25+
#define HAVE_SIGINFO 1
26+
#define HAVE_SIGVAL 1
27+
```
28+
29+
所有在中断中使用的函数或数据需要放在 RAM 中,否则会导致系统运行报错。具体做法可以参考下面
30+
31+
``` c
32+
RT_SECTION(".irq.example.str")
33+
static const char example_info[] = "example 0x%x";
34+
35+
RT_SECTION(".irq.example")
36+
void example_isr(void)
37+
{
38+
rt_kprintf(example_info, 11);
39+
...
40+
}
41+
```
42+
1343
## 开发板介绍
1444

1545
ab32vg1-prougen 是 中科蓝讯(Bluetrum) 推出的一款基于 RISC-V 内核的开发板,最高主频为 120Mhz,该开发板芯片为 AB32VG1。
@@ -102,34 +132,6 @@ msh >
102132

103133
4. 输入`scons` 命令重新编译工程。
104134

105-
## 注意事项
106-
107-
波特率默认为 1.5M,需要使用 [Downloader](https://github.com/BLUETRUM/Downloader) 下载 `.dcf` 到芯片,需要编译后自动下载,需要在 `Downloader` 中的下载的下拉窗中选择 `自动`;目前暂时屏蔽 uart1 打印
108-
109-
使用 `romfs` 时,需要自己生成 `romfs.c` 进行替换,操作参考[使用 RomFS](https://www.rt-thread.org/document/site/tutorial/qemu-network/filesystems/filesystems/#romfs)
110-
111-
编译报错的时候,如果出现重复定义的报错,可能需要在 `cconfig.h` 中手动添加以下配置
112-
113-
``` c
114-
#define HAVE_SIGEVENT 1
115-
#define HAVE_SIGINFO 1
116-
#define HAVE_SIGVAL 1
117-
```
118-
119-
所有在中断中使用的函数或数据需要放在 RAM 中,否则会导致系统运行报错。具体做法可以参考下面
120-
121-
``` c
122-
RT_SECTION(".irq.example.str")
123-
static const char example_info[] = "example 0x%x";
124-
125-
RT_SECTION(".irq.example")
126-
void example_isr(void)
127-
{
128-
rt_kprintf(example_info, 11);
129-
...
130-
}
131-
```
132-
133135
## 维护人信息
134136

135137
- [greedyhao](https://github.com/greedyhao)

‎bsp/bluetrum/ab32vg1-ab-prougen/link.lds

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ SECTIONS
4646
KEEP (*(.init_array*))
4747
PROVIDE(__ctors_end__ = .);
4848

49+
/* section information for at server */
50+
. = ALIGN(4);
51+
__rtatcmdtab_start = .;
52+
KEEP(*(RtAtCmdTab))
53+
__rtatcmdtab_end = .;
54+
4955
. = ALIGN(4);
5056
*save-restore.o (.text* .rodata*)
5157
*libcpu*cpu*context_gcc.o (.text* .rodata*)

‎bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.py

-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
OBJDUMP = PREFIX + 'objdump'
3939
OBJCPY = PREFIX + 'objcopy'
4040

41-
# DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -fsingle-precision-constant'
4241
DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -msave-restore'
43-
# CFLAGS = DEVICE + ' -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
4442
CFLAGS = DEVICE + ' -D_USE_LONG_TIME_T'
4543
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
4644
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds'

‎bsp/bluetrum/libraries/hal_drivers/drv_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <rthw.h>
1616
#include <rtdevice.h>
1717

18-
#define GET_PIN(PORTx,PIN) (uint8_t)__AB32_GET_PIN_##PORTx(PIN)
18+
#define GET_PIN(PORTx,PIN) (rt_uint8_t)__AB32_GET_PIN_##PORTx(PIN)
1919

2020
void uart0_irq_post(void);
2121
void uart1_irq_post(void);

‎bsp/bluetrum/libraries/hal_drivers/drv_gpio.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
struct port_info
2020
{
21-
uint8_t start_pin;
22-
uint8_t delta_pin;
23-
uint8_t total_pin;
21+
rt_uint8_t start_pin;
22+
rt_uint8_t delta_pin;
23+
rt_uint8_t total_pin;
2424
};
2525

2626
/* It needs to be adjusted to the hardware. */
@@ -40,9 +40,9 @@ static const hal_sfr_t port_sfr[] =
4040
GPIOF_BASE,
4141
};
4242

43-
static uint8_t _pin_port(uint32_t pin)
43+
static rt_uint8_t _pin_port(rt_uint32_t pin)
4444
{
45-
uint8_t port = 0;
45+
rt_uint8_t port = 0;
4646
for (port = 0; port < 3; port++) {
4747
if (pin < (port_table[port].total_pin + port_table[port].delta_pin)) {
4848
break;
@@ -51,12 +51,12 @@ static uint8_t _pin_port(uint32_t pin)
5151
return port;
5252
}
5353

54-
#define PIN_NUM(port, no) ((uint8_t)(port_table[port].total_pin + no - port_table[port].start_pin))
54+
#define PIN_NUM(port, no) ((rt_uint8_t)(port_table[port].total_pin + no - port_table[port].start_pin))
5555
#define PIN_PORT(pin) _pin_port(pin)
5656
#define PORT_SFR(port) (port_sfr[(port)])
57-
#define PIN_NO(pin) (uint8_t)((pin) & 0xFu)
57+
#define PIN_NO(pin) (rt_uint8_t)((pin) & 0xFu)
5858

59-
// #define PIN_ABPIN(pin) (uint8_t)(port_table[PIN_PORT(pin)].total_pin + PIN_NO(pin))
59+
// #define PIN_ABPIN(pin) (rt_uint8_t)(port_table[PIN_PORT(pin)].total_pin + PIN_NO(pin))
6060

6161
static rt_base_t ab32_pin_get(const char *name)
6262
{
@@ -103,22 +103,22 @@ static rt_base_t ab32_pin_get(const char *name)
103103

104104
static void ab32_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
105105
{
106-
uint8_t port = PIN_PORT(pin);
107-
uint8_t gpio_pin = pin - port_table[port].total_pin;
108-
hal_gpio_write(PORT_SFR(port), gpio_pin, (uint8_t)value);
106+
rt_uint8_t port = PIN_PORT(pin);
107+
rt_uint8_t gpio_pin = pin - port_table[port].total_pin;
108+
hal_gpio_write(PORT_SFR(port), gpio_pin, (rt_uint8_t)value);
109109
}
110110

111111
static int ab32_pin_read(rt_device_t dev, rt_base_t pin)
112112
{
113-
uint8_t port = PIN_PORT(pin);
114-
uint8_t gpio_pin = pin - port_table[port].total_pin;
113+
rt_uint8_t port = PIN_PORT(pin);
114+
rt_uint8_t gpio_pin = pin - port_table[port].total_pin;
115115
return hal_gpio_read(PORT_SFR(port), gpio_pin);
116116
}
117117

118118
static void ab32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
119119
{
120120
struct gpio_init gpio_init;
121-
uint8_t port = PIN_PORT(pin);
121+
rt_uint8_t port = PIN_PORT(pin);
122122

123123
gpio_init.pin = BIT(pin - port_table[port].total_pin);
124124
gpio_init.de = GPIO_DIGITAL;

‎bsp/bluetrum/libraries/hal_drivers/drv_hwtimer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void _rt_device_hwtimer_isr(rt_hwtimer_t *timer)
101101

102102
static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
103103
{
104-
uint32_t prescaler_value = 0;
104+
rt_uint32_t prescaler_value = 0;
105105
hal_sfr_t tim = RT_NULL;
106106
struct ab32_hwtimer *tim_device = RT_NULL;
107107

‎bsp/bluetrum/libraries/hal_drivers/drv_irrx.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
#define NO_KEY (0u)
4242

4343
struct ab32_irrx_data{
44-
uint16_t cnt; //ir data bit counter
45-
uint16_t rpt_cnt; //ir repeat counter
46-
uint16_t addr; //address, inverted address Extended NEC: 16bits address
47-
uint16_t cmd; //command, inverted command
44+
rt_uint16_t cnt; //ir data bit counter
45+
rt_uint16_t rpt_cnt; //ir repeat counter
46+
rt_uint16_t addr; //address, inverted address Extended NEC: 16bits address
47+
rt_uint16_t cmd; //command, inverted command
4848
};
4949
typedef struct ab32_irrx_data *ab32_irrx_data_t;
5050

@@ -58,7 +58,7 @@ static struct ab32_irrx_data _irrx = {0};
5858
* @param cmd inverted command
5959
*/
6060
RT_SECTION(".irq.irrx")
61-
uint8_t ab32_get_irkey(uint16_t *addr, uint16_t *cmd)
61+
rt_uint8_t ab32_get_irkey(rt_uint16_t *addr, rt_uint16_t *cmd)
6262
{
6363
if (_irrx.cnt != 32) {
6464
return NO_KEY;
@@ -90,8 +90,8 @@ static void irrx_isr(int vector, void *param)
9090
//IR RX data finish interrupt
9191
if (IRRXCON & BIT(16)) {
9292
IRRXCPND = BIT(16);
93-
_irrx.addr = (uint16_t)IRRXDAT;
94-
_irrx.cmd = (uint16_t)(IRRXDAT >> 16);
93+
_irrx.addr = (rt_uint16_t)IRRXDAT;
94+
_irrx.cmd = (rt_uint16_t)(IRRXDAT >> 16);
9595
_irrx.cnt = 32;
9696
}
9797

‎bsp/bluetrum/libraries/hal_drivers/drv_rtc.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,59 @@ static struct rt_device rtc;
2424

2525
/************** HAL Start *******************/
2626
#define IRTC_ENTER_CRITICAL() uint32_t cpu_ie = PICCON & BIT(0); PICCONCLR = BIT(0);
27-
#define IRTC_EXIT_CRITICAL() PICCON |= cpu_ie
27+
#define IRTC_EXIT_CRITICAL() PICCON |= cpu_ie
2828

29-
uint8_t get_weekday(struct tm *const _tm)
29+
rt_uint8_t get_weekday(struct tm *const _tm)
3030
{
31-
uint8_t weekday;
31+
rt_uint8_t weekday;
3232
time_t secs = timegm(_tm);
3333

3434
weekday = (secs / 86400 + 4) % 7;
3535
return weekday;
3636
}
3737

38-
void irtc_write(uint32_t cmd)
38+
void irtc_write(rt_uint32_t cmd)
3939
{
4040
RTCDAT = cmd;
4141
while (RTCCON & RTC_CON_TRANS_DONE);
4242
}
4343

44-
uint8_t irtc_read(void)
44+
rt_uint8_t irtc_read(void)
4545
{
4646
RTCDAT = 0x00;
4747
while (RTCCON & RTC_CON_TRANS_DONE);
48-
return (uint8_t)RTCDAT;
48+
return (rt_uint8_t)RTCDAT;
4949
}
5050

51-
void irtc_time_write(uint32_t cmd, uint32_t dat)
51+
void irtc_time_write(rt_uint32_t cmd, rt_uint32_t dat)
5252
{
5353
IRTC_ENTER_CRITICAL();
5454
RTCCON |= RTC_CON_CHIP_SELECT;
5555
irtc_write(cmd | RTC_WR);
56-
irtc_write((uint8_t)(dat >> 24));
57-
irtc_write((uint8_t)(dat >> 16));
58-
irtc_write((uint8_t)(dat >> 8));
59-
irtc_write((uint8_t)(dat >> 0));
56+
irtc_write((rt_uint8_t)(dat >> 24));
57+
irtc_write((rt_uint8_t)(dat >> 16));
58+
irtc_write((rt_uint8_t)(dat >> 8));
59+
irtc_write((rt_uint8_t)(dat >> 0));
6060
RTCCON &= ~RTC_CON_CHIP_SELECT;
6161
IRTC_EXIT_CRITICAL();
6262
}
6363

64-
uint32_t irtc_time_read(uint32_t cmd)
64+
rt_uint32_t irtc_time_read(rt_uint32_t cmd)
6565
{
66-
uint32_t rd_val;
66+
rt_uint32_t rd_val;
6767
IRTC_ENTER_CRITICAL();
6868
RTCCON |= RTC_CON_CHIP_SELECT;
6969
irtc_write(cmd | RTC_RD);
70-
*((uint8_t *)&rd_val + 3) = irtc_read();
71-
*((uint8_t *)&rd_val + 2) = irtc_read();
72-
*((uint8_t *)&rd_val + 1) = irtc_read();
73-
*((uint8_t *)&rd_val + 0) = irtc_read();
70+
*((rt_uint8_t *)&rd_val + 3) = irtc_read();
71+
*((rt_uint8_t *)&rd_val + 2) = irtc_read();
72+
*((rt_uint8_t *)&rd_val + 1) = irtc_read();
73+
*((rt_uint8_t *)&rd_val + 0) = irtc_read();
7474
RTCCON &= ~RTC_CON_CHIP_SELECT;
7575
IRTC_EXIT_CRITICAL();
7676
return rd_val;
7777
}
7878

79-
void irtc_sfr_write(uint32_t cmd, uint8_t dat)
79+
void irtc_sfr_write(rt_uint32_t cmd, rt_uint8_t dat)
8080
{
8181
IRTC_ENTER_CRITICAL();
8282
RTCCON |= RTC_CON_CHIP_SELECT;
@@ -86,9 +86,9 @@ void irtc_sfr_write(uint32_t cmd, uint8_t dat)
8686
IRTC_EXIT_CRITICAL();
8787
}
8888

89-
uint8_t irtc_sfr_read(uint32_t cmd)
89+
rt_uint8_t irtc_sfr_read(rt_uint32_t cmd)
9090
{
91-
uint8_t rd_val;
91+
rt_uint8_t rd_val;
9292
IRTC_ENTER_CRITICAL();
9393
RTCCON |= RTC_CON_CHIP_SELECT;
9494
irtc_write(cmd | RTC_RD);
@@ -99,8 +99,8 @@ uint8_t irtc_sfr_read(uint32_t cmd)
9999

100100
static void _init_rtc_clock(void)
101101
{
102-
uint8_t rtccon0;
103-
uint8_t rtccon2;
102+
rt_uint8_t rtccon0;
103+
rt_uint8_t rtccon2;
104104

105105
rtccon0 = irtc_sfr_read(RTCCON0_CMD);
106106
rtccon2 = irtc_sfr_read(RTCCON2_CMD);
@@ -121,7 +121,7 @@ void hal_rtc_init(void)
121121
{
122122
time_t sec = 0;
123123
struct tm tm_new = {0};
124-
uint8_t temp;
124+
rt_uint8_t temp;
125125

126126
_init_rtc_clock();
127127
temp = irtc_sfr_read(RTCCON0_CMD);

‎bsp/bluetrum/libraries/hal_drivers/drv_sdio.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ struct rthw_sdio
5050
ALIGN(SDIO_ALIGN_LEN)
5151
static rt_uint8_t cache_buf[SDIO_BUFF_SIZE];
5252

53-
static uint8_t sd_baud = 119;
53+
static rt_uint8_t sd_baud = 119;
5454

55-
uint8_t sysclk_update_baud(uint8_t baud);
55+
rt_uint8_t sysclk_update_baud(rt_uint8_t baud);
5656

5757
static rt_uint32_t ab32_sdio_clk_get(hal_sfr_t hw_sdio)
5858
{
@@ -633,7 +633,7 @@ int rt_hw_sdio_init(void)
633633
{
634634
struct ab32_sdio_des sdio_des = {0};
635635
struct sd_handle hsd = {0};
636-
uint8_t param = 0;
636+
rt_uint8_t param = 0;
637637
hsd.instance = SDMMC0_BASE;
638638

639639
hal_rcu_periph_clk_enable(RCU_SD0);

‎bsp/bluetrum/libraries/hal_drivers/drv_usart.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static struct ab32_uart_config uart_config[] =
6464
static struct ab32_uart uart_obj[sizeof(uart_config) / sizeof(uart_config[0])] = {0};
6565

6666
#ifdef HUART_ENABLE
67-
static uint8_t huart_dma[512];
67+
static rt_uint8_t huart_dma[512];
6868
#endif
6969

7070
static rt_err_t ab32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
@@ -179,13 +179,13 @@ static int ab32_getc(struct rt_serial_device *serial)
179179
uart = rt_container_of(serial, struct ab32_uart, serial);
180180

181181
ch = -1;
182-
switch ((uint32_t)(uart->handle.instance)) {
183-
case (uint32_t)UART0_BASE:
182+
switch ((rt_uint32_t)(uart->handle.instance)) {
183+
case (rt_uint32_t)UART0_BASE:
184184
if (uart->rx_idx != uart->rx_idx_prev) {
185185
ch = (int)(uart->rx_buf[uart->rx_idx_prev++ % 10]);
186186
}
187187
break;
188-
case (uint32_t)UART1_BASE:
188+
case (rt_uint32_t)UART1_BASE:
189189
#ifdef HUART_ENABLE
190190
if ((uart->uart_dma_flag) && (huart_get_rxcnt())) {
191191
ch = huart_getchar();
@@ -197,7 +197,7 @@ static int ab32_getc(struct rt_serial_device *serial)
197197
}
198198
}
199199
break;
200-
case (uint32_t)UART2_BASE:
200+
case (rt_uint32_t)UART2_BASE:
201201
if (uart->rx_idx != uart->rx_idx_prev) {
202202
ch = (int)(uart->rx_buf[uart->rx_idx_prev++ % 10]);
203203
}

0 commit comments

Comments
 (0)
Please sign in to comment.