diff --git a/.vscode/settings.json b/.vscode/settings.json index 00b8282..5f01d9f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,6 +42,8 @@ "os_obj.h": "c", "os_api.h": "c", "os_ring_buffer.h": "c", - "os_list.h": "c" + "os_list.h": "c", + "uartstdio.h": "c", + "gpio.h": "c" } } \ No newline at end of file diff --git a/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/bsp.h b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/bsp.h index ca7badd..e190424 100644 --- a/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/bsp.h +++ b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/bsp.h @@ -23,18 +23,14 @@ void light_red_off(void); void light_green_off(void); void light_blue_off(void); -#define BSP_TICKS_PER_SEC 1000U +#define BSP_TICKS_PER_SEC 10U typedef long clock_t; extern volatile clock_t* l_tickCtr; -void os_on_startup(void); - -void disable_irq(void); -void enable_irq(void); - +void system_init(void); void delay_block(clock_t tick); #endif \ No newline at end of file diff --git a/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/uart_debug.h b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/uart_debug.h new file mode 100644 index 0000000..9f45426 --- /dev/null +++ b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/include/uart_debug.h @@ -0,0 +1,26 @@ +/*************************************************** +* Ceno Real-time Operating System (CenoRTOS) +* version 0.1 +* author neroyang +* email nerosoft@outlook.com +* time 2019-01-27 +* +* Copyright (C) 2018 CenoCloud. All Rights Reserved +* +* Contract Information: +* https://www.cenocloud.com +****************************************************/ +#ifndef __CENO_RTOS_UART_DEBUG__ +#define __CENO_RTOS_UART_DEBUG__ + +void uart_debug_init(void); + +void uart_debug_print(char* str); + +void uart_debug_print_char(char str); + +void uart_debug_reveive(char* rec); + +char uart_debug_reveive_char(void); + +#endif //! __CENO_RTOS_UART_DEBUG__ diff --git a/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c index 9af80d3..f0bf785 100644 --- a/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c +++ b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c @@ -15,6 +15,7 @@ void os_on_startup(void){ } + void disable_irq(void){ __asm ( "CPSID I\n\t" diff --git a/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c new file mode 100644 index 0000000..2aa770e --- /dev/null +++ b/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c @@ -0,0 +1,56 @@ +#include "../include/uart_debug.h" +#include "TM4C123GH6PM.h" + +void uart_debug_init(void){ + SYSCTL->RCGCUART |= (1<<0); + SYSCTL->RCGCGPIO |= (1<<0); + + GPIOA->AFSEL = (1<<1)|(1<<0); + GPIOA->PCTL = (1<<0)|(1<<4); + GPIOA->DEN = (1<<0)|(1<<1); + + UART0->CTL &= ~(1<<0); + UART0->IBRD = 104; + UART0->FBRD = 11; + UART0->LCRH = (0x3<<5); + UART0->CC = 0x0; + + UART0->CTL = (1<<0)|(1<<8)|(1<<9); +} + +void uart_debug_print(char* str){ + while(*str){ + uart_debug_print_char(*(string++)); + } +} + +void uart_debug_print_char(char str){ + while((UART0->FR & (1<<5))!=0); + UART0->DR = str; +} + + +void uart_debug_reveive(char* rec){ + +} + +char uart_debug_reveive_char(void){ + char c; + while((UART0->FR & (1<<1))!=0); + c = UART0->DR; + return c; +} + +int main(){ + uart_debug_init(); + char c; + while(1){ + uart_debug_print("test uart print"); + uart_debug_reveive(c); + switch(c){ + case '1': + break; + } + } + +} \ No newline at end of file diff --git a/user/asm/bsp.s b/user/asm/bsp.s index 84c93e2..6dca4e9 100644 --- a/user/asm/bsp.s +++ b/user/asm/bsp.s @@ -136,7 +136,7 @@ os_on_startup: ldr r2, [r3] ldr r1, .L13+4 umull r3, r4, r2, r1 - lsr r3, r4, #6 + lsr r3, r4, #3 mov r0, r3 bl SysTick_Config mov r1, #0 @@ -151,7 +151,7 @@ os_on_startup: .align 2 .L13: .word SystemCoreClock - .word 274877907 + .word -858993459 .size os_on_startup, .-os_on_startup .align 2 .global disable_irq @@ -167,7 +167,7 @@ disable_irq: str fp, [sp, #-4]! add fp, sp, #0 .syntax divided -@ 19 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c" 1 +@ 20 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c" 1 CPSID I @ 0 "" 2 @@ -193,7 +193,7 @@ enable_irq: str fp, [sp, #-4]! add fp, sp, #0 .syntax divided -@ 24 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c" 1 +@ 25 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c" 1 CPSIE I @ 0 "" 2 diff --git a/user/bin/CenoRTOS.bin b/user/bin/CenoRTOS.bin index 7633ef6..84ef3bd 100755 Binary files a/user/bin/CenoRTOS.bin and b/user/bin/CenoRTOS.bin differ diff --git a/user/bin/CenoRTOS.elf b/user/bin/CenoRTOS.elf index b6d9511..466afde 100755 Binary files a/user/bin/CenoRTOS.elf and b/user/bin/CenoRTOS.elf differ diff --git a/user/obj/bsp.o b/user/obj/bsp.o index a98618e..366fe67 100644 Binary files a/user/obj/bsp.o and b/user/obj/bsp.o differ diff --git a/user/obj/uart_debug.d b/user/obj/uart_debug.d new file mode 100644 index 0000000..254757a --- /dev/null +++ b/user/obj/uart_debug.d @@ -0,0 +1,3 @@ +obj/uart_debug.o: \ + /Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c \ + /Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/../include/uart_debug.h diff --git a/user/obj/uart_debug.o b/user/obj/uart_debug.o new file mode 100644 index 0000000..7020e58 Binary files /dev/null and b/user/obj/uart_debug.o differ diff --git a/user/optimize/bsp.i b/user/optimize/bsp.i index 7a0d1d1..b51d084 100644 --- a/user/optimize/bsp.i +++ b/user/optimize/bsp.i @@ -220,11 +220,7 @@ void light_blue_off(void); typedef long clock_t; extern volatile clock_t* l_tickCtr; -void os_on_startup(void); - -void disable_irq(void); -void enable_irq(void); - +void system_init(void); void delay_block(clock_t tick); # 3 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/bsp.c" 2 # 1 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/include/TM4C123GH6PM.h" 1 @@ -3045,12 +3041,13 @@ volatile clock_t* l_tickCtr = &tickCtr; extern void os_init(void); void os_on_startup(void){ SystemCoreClockUpdate(); - SysTick_Config(SystemCoreClock / 1000U); + SysTick_Config(SystemCoreClock / 10U); __NVIC_SetPriority(SysTick_IRQn, 0U); } + void disable_irq(void){ __asm ( "CPSID I\n\t" diff --git a/user/optimize/interrupt.i b/user/optimize/interrupt.i index ec459c1..b1c5b71 100644 --- a/user/optimize/interrupt.i +++ b/user/optimize/interrupt.i @@ -150,11 +150,7 @@ void light_blue_off(void); typedef long clock_t; extern volatile clock_t* l_tickCtr; -void os_on_startup(void); - -void disable_irq(void); -void enable_irq(void); - +void system_init(void); void delay_block(clock_t tick); # 3 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/interrupt.c" 2 diff --git a/user/optimize/main.i b/user/optimize/main.i index 475f92a..0d08b8f 100644 --- a/user/optimize/main.i +++ b/user/optimize/main.i @@ -220,11 +220,7 @@ void light_blue_off(void); typedef long clock_t; extern volatile clock_t* l_tickCtr; -void os_on_startup(void); - -void disable_irq(void); -void enable_irq(void); - +void system_init(void); void delay_block(clock_t tick); # 3 "src/main.c" 2 # 1 "/Users/neroyang/project/Ceno-RTOS/kernel/ceno/include/os_api.h" 1 diff --git a/user/optimize/uart_debug.d b/user/optimize/uart_debug.d new file mode 100644 index 0000000..7beb793 --- /dev/null +++ b/user/optimize/uart_debug.d @@ -0,0 +1,3 @@ +uart_debug.o: \ + /Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c \ + /Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/../include/uart_debug.h diff --git a/user/optimize/uart_debug.i b/user/optimize/uart_debug.i new file mode 100644 index 0000000..04d8cc8 --- /dev/null +++ b/user/optimize/uart_debug.i @@ -0,0 +1,25 @@ +# 1 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c" +# 1 "/Users/neroyang/project/Ceno-RTOS/user//" +# 1 "" +# 1 "" +# 1 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c" +# 1 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/../include/uart_debug.h" 1 +# 16 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/../include/uart_debug.h" +void uart_debug_init(void); + +void uart_debug_print(char* str); + +void uart_debug_reveive(char* rec); +# 2 "/Users/neroyang/project/Ceno-RTOS/board/arch/arm32/ek-TM4C123gxl/TM4C123GH6PM/ceno_os/src/uart_debug.c" 2 + +void uart_debug_init(void){ + +} + +void uart_debug_print(char* str){ + +} + +void uart_debug_reveive(char* rec){ + +}