Skip to content

Commit 8fccef5

Browse files
authored
Merge pull request #30 from RT-Thread/master
p
2 parents 0611822 + 50bf490 commit 8fccef5

File tree

789 files changed

+13830
-13707
lines changed

Some content is hidden

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

789 files changed

+13830
-13707
lines changed

bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,16 @@ menu "On-chip Peripheral Drivers"
167167
default n
168168
endif
169169

170-
config BSP_USING_ONCHIP_RTC
170+
menuconfig BSP_USING_ONCHIP_RTC
171171
bool "Enable RTC"
172172
select RT_USING_RTC
173173
select RT_USING_LIBC
174174
default n
175+
if BSP_USING_ONCHIP_RTC
176+
config RTC_USING_INTERNAL_CLK
177+
bool "Using internal clock RTC"
178+
default y
179+
endif
175180

176181
menuconfig BSP_USING_ADC
177182
bool "Enable ADC"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -fsingle-precision-constant'
4242
DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32'
4343
# CFLAGS = DEVICE + ' -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
44-
CFLAGS = DEVICE
44+
CFLAGS = DEVICE + ' -D_USE_LONG_TIME_T'
4545
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
4646
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds'
4747
CPATH = ''

bsp/bluetrum/libraries/hal_drivers/drv_rtc.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2021-01-28 greedyhao first version
9+
* 2021-03-19 iysheng modify just set time first power up
910
*/
1011

1112
#include "board.h"
@@ -95,30 +96,44 @@ uint8_t irtc_sfr_read(uint32_t cmd)
9596
IRTC_EXIT_CRITICAL();
9697
}
9798

99+
static void _init_rtc_clock(void)
100+
{
101+
uint8_t rtccon0;
102+
uint8_t rtccon2;
103+
104+
rtccon0 = irtc_sfr_read(RTCCON0_CMD);
105+
rtccon2 = irtc_sfr_read(RTCCON2_CMD);
106+
#ifdef RTC_USING_INTERNAL_CLK
107+
rtccon0 &= ~RTC_CON0_XOSC32K_ENABLE;
108+
rtccon0 |= RTC_CON0_INTERNAL_32K;
109+
rtccon2 | RTC_CON2_32K_SELECT;
110+
#else
111+
rtccon0 |= RTC_CON0_XOSC32K_ENABLE;
112+
rtccon0 &= ~RTC_CON0_INTERNAL_32K;
113+
rtccon2 & ~RTC_CON2_32K_SELECT;
114+
#endif
115+
irtc_sfr_write(RTCCON0_CMD, rtccon0);
116+
irtc_sfr_write(RTCCON2_CMD, rtccon2);
117+
}
118+
98119
void hal_rtc_init(void)
99120
{
100121
time_t sec = 0;
101122
struct tm tm_new = {0};
123+
uint8_t temp;
102124

103-
uint8_t temp = irtc_sfr_read(RTCCON0_CMD);
104-
temp &= ~RTC_CON0_XOSC32K_ENABLE;
105-
temp |= RTC_CON0_EXTERNAL_32K;
106-
irtc_sfr_write(RTCCON0_CMD, temp);
107-
temp = irtc_sfr_read(RTCCON2_CMD);
108-
irtc_sfr_write(RTCCON2_CMD, temp | RTC_CON2_32K_SELECT);
109-
125+
_init_rtc_clock();
110126
temp = irtc_sfr_read(RTCCON0_CMD);
111-
if (temp & BIT(7)) {
112-
temp &= ~BIT(7);
127+
if (temp & RTC_CON0_PWRUP_FIRST) {
128+
temp &= ~RTC_CON0_PWRUP_FIRST;
113129
irtc_sfr_write(RTCCON0_CMD, temp); /* First power on */
114-
}
130+
tm_new.tm_mday = 29;
131+
tm_new.tm_mon = 1 - 1;
132+
tm_new.tm_year = 2021 - 1900;
133+
sec = timegm(&tm_new);
115134

116-
tm_new.tm_mday = 29;
117-
tm_new.tm_mon = 1 - 1;
118-
tm_new.tm_year = 2021 - 1900;
119-
sec = timegm(&tm_new);
120-
121-
irtc_time_write(RTCCNT_CMD, sec);
135+
irtc_time_write(RTCCNT_CMD, sec);
136+
}
122137
}
123138
/************** HAL End *******************/
124139

bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum
3434

3535
// RTCCON0
3636
#define RTC_CON0_PWRUP_FIRST (0x01u << 7) /*!< RTC first power up flag */
37-
#define RTC_CON0_EXTERNAL_32K (0x01u << 6) /*!< External 32K select */
37+
#define RTC_CON0_INTERNAL_32K (0x01u << 6) /*!< Internal 32K select */
3838
#define RTC_CON0_VDD_ENABLE (0x01u << 5) /*!< RTC VDD12 enable */
3939
#define RTC_CON0_BG_ENABLE (0x01u << 4) /*!< BG enable */
4040
#define RTC_CON0_LVD_OUTPUT_ENABLE (0x01u << 3) /*!< LVD output enable */

bsp/lpc1114/driver/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -33,7 +33,7 @@
3333
#define NVIC_ISPR HWREG32(SCB_BASE + 0x200)
3434
#define NVIC_ICPR HWREG32(SCB_BASE + 0x280)
3535
#define NVIC_IPR(irqno) HWREG32(SCB_BASE + 0x400 + (((irqno) / 4) << 2))
36-
#define SCB_SHPR3 HWREG32(SCB_BASE + 0xd20)
36+
#define SCB_SHPR3 HWREG32(SCB_BASE + 0xd20)
3737

3838
extern unsigned char __bss_end__[];
3939
extern unsigned char _ram_end[];

bsp/lpc1114/driver/drv_uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2019, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*

bsp/lpc176x/applications/application.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -38,44 +38,44 @@ extern int lwip_system_init(void);
3838
/* thread phase init */
3939
void rt_init_thread_entry(void *parameter)
4040
{
41-
/* initialize platform */
42-
platform_init();
41+
/* initialize platform */
42+
platform_init();
4343

4444
#ifdef RT_USING_LWIP
4545
/* register Ethernet interface device */
4646
lpc17xx_emac_hw_init();
4747

4848
/* initialize lwip stack */
49-
/* register ethernetif device */
50-
eth_system_device_init();
49+
/* register ethernetif device */
50+
eth_system_device_init();
5151

52-
/* initialize lwip system */
53-
lwip_system_init();
54-
rt_kprintf("TCP/IP initialized!\n");
52+
/* initialize lwip system */
53+
lwip_system_init();
54+
rt_kprintf("TCP/IP initialized!\n");
5555
#endif
5656

5757
/* Filesystem Initialization */
5858
#ifdef RT_USING_DFS
5959
rt_hw_sdcard_init();
6060

61-
/* initialize the device file system */
62-
dfs_init();
61+
/* initialize the device file system */
62+
dfs_init();
6363

6464
#ifdef RT_USING_DFS_ELMFAT
65-
/* initialize the elm chan FatFS file system*/
66-
elm_init();
65+
/* initialize the elm chan FatFS file system*/
66+
elm_init();
6767
#endif
6868

6969
/* mount sd card fat partition 1 as root directory */
7070
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
71-
rt_kprintf("File System initialized!\n");
71+
rt_kprintf("File System initialized!\n");
7272
else
73-
rt_kprintf("File System init failed!\n");
73+
rt_kprintf("File System init failed!\n");
7474
#endif
7575

7676
#ifdef RT_USING_FINSH
77-
/* initialize finsh */
78-
finsh_system_init();
77+
/* initialize finsh */
78+
finsh_system_init();
7979
#endif
8080
}
8181

@@ -84,8 +84,8 @@ int rt_application_init()
8484
rt_thread_t tid;
8585

8686
tid = rt_thread_create("init",
87-
rt_init_thread_entry, RT_NULL,
88-
2048, RT_THREAD_PRIORITY_MAX/3, 20);
87+
rt_init_thread_entry, RT_NULL,
88+
2048, RT_THREAD_PRIORITY_MAX/3, 20);
8989
if (tid != RT_NULL) rt_thread_startup(tid);
9090

9191
return 0;

bsp/lpc176x/applications/platform.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -16,11 +16,11 @@ static struct rt_memheap _memheap;
1616
void platform_init(void)
1717
{
1818
#ifdef RT_USING_MEMHEAP
19-
/* create memory heap object on 0x2007 C000 - 0x2008 4000*/
19+
/* create memory heap object on 0x2007 C000 - 0x2008 4000*/
2020
#ifdef RT_USING_LWIP
21-
rt_memheap_init(&_memheap, "system", (void*)0x2007C000, 16*1024);
21+
rt_memheap_init(&_memheap, "system", (void*)0x2007C000, 16*1024);
2222
#else
23-
rt_memheap_init(&_memheap, "system", (void*)0x2007C000, 32*1024);
23+
rt_memheap_init(&_memheap, "system", (void*)0x2007C000, 32*1024);
2424
#endif
2525
#endif
2626
}

bsp/lpc176x/applications/platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*

bsp/lpc176x/applications/startup.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -33,54 +33,54 @@ extern int __bss_end;
3333
*/
3434
void rtthread_startup(void)
3535
{
36-
/* initialize board */
37-
rt_hw_board_init();
36+
/* initialize board */
37+
rt_hw_board_init();
3838

39-
/* show version */
40-
rt_show_version();
39+
/* show version */
40+
rt_show_version();
4141

4242
#ifdef RT_USING_HEAP
43-
/* initialize memory system */
44-
#ifdef __CC_ARM
45-
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x10008000);
46-
#elif __ICCARM__
47-
rt_system_heap_init(__segment_end("HEAP"), (void*)0x10008000);
48-
#else
49-
rt_system_heap_init((void*)&__bss_end, (void*)0x10008000);
50-
#endif
43+
/* initialize memory system */
44+
#ifdef __CC_ARM
45+
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x10008000);
46+
#elif __ICCARM__
47+
rt_system_heap_init(__segment_end("HEAP"), (void*)0x10008000);
48+
#else
49+
rt_system_heap_init((void*)&__bss_end, (void*)0x10008000);
50+
#endif
5151
#endif
5252

53-
/* initialize scheduler system */
54-
rt_system_scheduler_init();
53+
/* initialize scheduler system */
54+
rt_system_scheduler_init();
5555

56-
/* initialize application */
57-
rt_application_init();
56+
/* initialize application */
57+
rt_application_init();
5858

5959
/* initialize timer */
6060
rt_system_timer_init();
6161

6262
/* initialize timer thread */
6363
rt_system_timer_thread_init();
6464

65-
/* initialize idle thread */
66-
rt_thread_idle_init();
65+
/* initialize idle thread */
66+
rt_thread_idle_init();
6767

68-
/* start scheduler */
69-
rt_system_scheduler_start();
68+
/* start scheduler */
69+
rt_system_scheduler_start();
7070

71-
/* never reach here */
72-
return ;
71+
/* never reach here */
72+
return ;
7373
}
7474

7575
int main(void)
7676
{
77-
/* disable interrupt first */
78-
rt_hw_interrupt_disable();
77+
/* disable interrupt first */
78+
rt_hw_interrupt_disable();
7979

80-
/* startup RT-Thread RTOS */
81-
rtthread_startup();
80+
/* startup RT-Thread RTOS */
81+
rtthread_startup();
8282

83-
return 0;
83+
return 0;
8484
}
8585

8686
/*@}*/

0 commit comments

Comments
 (0)