Skip to content

Commit

Permalink
add #13: add uart print and receive
Browse files Browse the repository at this point in the history
  • Loading branch information
nerososft committed Jan 27, 2019
1 parent c5c9d4f commit 6d93d73
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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__
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void os_on_startup(void){
}



void disable_irq(void){
__asm (
"CPSID I\n\t"
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

}
8 changes: 4 additions & 4 deletions user/asm/bsp.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Binary file modified user/bin/CenoRTOS.bin
Binary file not shown.
Binary file modified user/bin/CenoRTOS.elf
Binary file not shown.
Binary file modified user/obj/bsp.o
Binary file not shown.
3 changes: 3 additions & 0 deletions user/obj/uart_debug.d
Original file line number Diff line number Diff line change
@@ -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
Binary file added user/obj/uart_debug.o
Binary file not shown.
9 changes: 3 additions & 6 deletions user/optimize/bsp.i
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions user/optimize/interrupt.i
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions user/optimize/main.i
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions user/optimize/uart_debug.d
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions user/optimize/uart_debug.i
Original file line number Diff line number Diff line change
@@ -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 "<built-in>"
# 1 "<command-line>"
# 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){

}

0 comments on commit 6d93d73

Please sign in to comment.