Added coremark.
This commit is contained in:
parent
9d58a367ce
commit
7f5880d067
|
@ -1,3 +1,6 @@
|
||||||
[submodule "lib/printf"]
|
[submodule "lib/printf"]
|
||||||
path = lib/printf
|
path = lib/printf
|
||||||
url = https://github.com/mpaland/printf.git
|
url = https://github.com/mpaland/printf.git
|
||||||
|
[submodule "lib/coremark"]
|
||||||
|
path = lib/coremark
|
||||||
|
url = https://github.com/eembc/coremark.git
|
||||||
|
|
|
@ -2,13 +2,18 @@ cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
enable_language(ASM)
|
enable_language(ASM)
|
||||||
|
|
||||||
project(hello)
|
project(benchmark)
|
||||||
|
|
||||||
set(TARGET_LDSCRIPT "${CMAKE_SOURCE_DIR}/stx7105.ld")
|
set(TARGET_LDSCRIPT "${CMAKE_SOURCE_DIR}/stx7105.ld")
|
||||||
|
|
||||||
set(TARGET_SOURCES
|
set(TARGET_SOURCES
|
||||||
|
"lib/coremark/core_list_join.c"
|
||||||
|
"lib/coremark/core_main.c"
|
||||||
|
"lib/coremark/core_matrix.c"
|
||||||
|
"lib/coremark/core_state.c"
|
||||||
|
"lib/coremark/core_util.c"
|
||||||
"lib/printf/printf.c"
|
"lib/printf/printf.c"
|
||||||
"src/main.c"
|
"src/core_portme.c"
|
||||||
"src/stx7105_exc.c"
|
"src/stx7105_exc.c"
|
||||||
"src/stx7105_utils.c"
|
"src/stx7105_utils.c"
|
||||||
"startup_stx7105.S"
|
"startup_stx7105.S"
|
||||||
|
@ -16,13 +21,19 @@ set(TARGET_SOURCES
|
||||||
|
|
||||||
set(TARGET_INCLUDES
|
set(TARGET_INCLUDES
|
||||||
"include"
|
"include"
|
||||||
|
"lib/coremark"
|
||||||
"lib/printf"
|
"lib/printf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(TARGET_DEFS
|
||||||
|
"ITERATIONS=1"
|
||||||
|
"PERFORMANCE_RUN=1"
|
||||||
|
)
|
||||||
|
|
||||||
set(TARGET_FLAGS_HARDWARE "-m4-300 -ml")
|
set(TARGET_FLAGS_HARDWARE "-m4-300 -ml")
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O0")
|
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O2")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O2")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
|
||||||
|
|
|
@ -0,0 +1,210 @@
|
||||||
|
/*
|
||||||
|
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
Original Author: Shay Gal-on
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
|
/* Topic : Description
|
||||||
|
This file contains configuration constants required to execute on
|
||||||
|
different platforms
|
||||||
|
*/
|
||||||
|
#ifndef CORE_PORTME_H
|
||||||
|
#define CORE_PORTME_H
|
||||||
|
/************************/
|
||||||
|
/* Data types and settings */
|
||||||
|
/************************/
|
||||||
|
/* Configuration : HAS_FLOAT
|
||||||
|
Define to 1 if the platform supports floating point.
|
||||||
|
*/
|
||||||
|
#ifndef HAS_FLOAT
|
||||||
|
#define HAS_FLOAT 1
|
||||||
|
#endif
|
||||||
|
/* Configuration : HAS_TIME_H
|
||||||
|
Define to 1 if platform has the time.h header file,
|
||||||
|
and implementation of functions thereof.
|
||||||
|
*/
|
||||||
|
#ifndef HAS_TIME_H
|
||||||
|
#define HAS_TIME_H 0
|
||||||
|
#endif
|
||||||
|
/* Configuration : USE_CLOCK
|
||||||
|
Define to 1 if platform has the time.h header file,
|
||||||
|
and implementation of functions thereof.
|
||||||
|
*/
|
||||||
|
#ifndef USE_CLOCK
|
||||||
|
#define USE_CLOCK 0
|
||||||
|
#endif
|
||||||
|
/* Configuration : HAS_STDIO
|
||||||
|
Define to 1 if the platform has stdio.h.
|
||||||
|
*/
|
||||||
|
#ifndef HAS_STDIO
|
||||||
|
#define HAS_STDIO 0
|
||||||
|
#endif
|
||||||
|
/* Configuration : HAS_PRINTF
|
||||||
|
Define to 1 if the platform has stdio.h and implements the printf
|
||||||
|
function.
|
||||||
|
*/
|
||||||
|
#ifndef HAS_PRINTF
|
||||||
|
#define HAS_PRINTF 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configuration : CORE_TICKS
|
||||||
|
Define type of return from the timing functions.
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef uint32_t CORE_TICKS;
|
||||||
|
|
||||||
|
/* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
|
||||||
|
Initialize these strings per platform
|
||||||
|
*/
|
||||||
|
#ifndef COMPILER_VERSION
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define COMPILER_VERSION "GCC"__VERSION__
|
||||||
|
#else
|
||||||
|
#define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef COMPILER_FLAGS
|
||||||
|
#define COMPILER_FLAGS \
|
||||||
|
"-O2"
|
||||||
|
#endif
|
||||||
|
#ifndef MEM_LOCATION
|
||||||
|
#define MEM_LOCATION "DDR2 LMI"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Data Types :
|
||||||
|
To avoid compiler issues, define the data types that need ot be used for
|
||||||
|
8b, 16b and 32b in <core_portme.h>.
|
||||||
|
|
||||||
|
*Imprtant* :
|
||||||
|
ee_ptr_int needs to be the data type used to hold pointers, otherwise
|
||||||
|
coremark may fail!!!
|
||||||
|
*/
|
||||||
|
typedef signed short ee_s16;
|
||||||
|
typedef unsigned short ee_u16;
|
||||||
|
typedef signed int ee_s32;
|
||||||
|
typedef double ee_f32;
|
||||||
|
typedef unsigned char ee_u8;
|
||||||
|
typedef unsigned int ee_u32;
|
||||||
|
typedef ee_u32 ee_ptr_int;
|
||||||
|
typedef size_t ee_size_t;
|
||||||
|
/* align_mem :
|
||||||
|
This macro is used to align an offset to point to a 32b value. It is
|
||||||
|
used in the Matrix algorithm to initialize the input memory blocks.
|
||||||
|
*/
|
||||||
|
#define align_mem(x) (void *)(4 + (((ee_ptr_int)(x)-1) & ~3))
|
||||||
|
|
||||||
|
/* Configuration : SEED_METHOD
|
||||||
|
Defines method to get seed values that cannot be computed at compile
|
||||||
|
time.
|
||||||
|
|
||||||
|
Valid values :
|
||||||
|
SEED_ARG - from command line.
|
||||||
|
SEED_FUNC - from a system function.
|
||||||
|
SEED_VOLATILE - from volatile variables.
|
||||||
|
*/
|
||||||
|
#ifndef SEED_METHOD
|
||||||
|
#define SEED_METHOD SEED_VOLATILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configuration : MEM_METHOD
|
||||||
|
Defines method to get a block of memry.
|
||||||
|
|
||||||
|
Valid values :
|
||||||
|
MEM_MALLOC - for platforms that implement malloc and have malloc.h.
|
||||||
|
MEM_STATIC - to use a static memory array.
|
||||||
|
MEM_STACK - to allocate the data block on the stack (NYI).
|
||||||
|
*/
|
||||||
|
#ifndef MEM_METHOD
|
||||||
|
#define MEM_METHOD MEM_STACK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configuration : MULTITHREAD
|
||||||
|
Define for parallel execution
|
||||||
|
|
||||||
|
Valid values :
|
||||||
|
1 - only one context (default).
|
||||||
|
N>1 - will execute N copies in parallel.
|
||||||
|
|
||||||
|
Note :
|
||||||
|
If this flag is defined to more then 1, an implementation for launching
|
||||||
|
parallel contexts must be defined.
|
||||||
|
|
||||||
|
Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK>
|
||||||
|
to enable them.
|
||||||
|
|
||||||
|
It is valid to have a different implementation of <core_start_parallel>
|
||||||
|
and <core_end_parallel> in <core_portme.c>, to fit a particular architecture.
|
||||||
|
*/
|
||||||
|
#ifndef MULTITHREAD
|
||||||
|
#define MULTITHREAD 1
|
||||||
|
#define USE_PTHREAD 0
|
||||||
|
#define USE_FORK 0
|
||||||
|
#define USE_SOCKET 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configuration : MAIN_HAS_NOARGC
|
||||||
|
Needed if platform does not support getting arguments to main.
|
||||||
|
|
||||||
|
Valid values :
|
||||||
|
0 - argc/argv to main is supported
|
||||||
|
1 - argc/argv to main is not supported
|
||||||
|
|
||||||
|
Note :
|
||||||
|
This flag only matters if MULTITHREAD has been defined to a value
|
||||||
|
greater then 1.
|
||||||
|
*/
|
||||||
|
#ifndef MAIN_HAS_NOARGC
|
||||||
|
#define MAIN_HAS_NOARGC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configuration : MAIN_HAS_NORETURN
|
||||||
|
Needed if platform does not support returning a value from main.
|
||||||
|
|
||||||
|
Valid values :
|
||||||
|
0 - main returns an int, and return value will be 0.
|
||||||
|
1 - platform does not support returning a value from main
|
||||||
|
*/
|
||||||
|
#ifndef MAIN_HAS_NORETURN
|
||||||
|
#define MAIN_HAS_NORETURN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Variable : default_num_contexts
|
||||||
|
Not used for this simple port, must contain the value 1.
|
||||||
|
*/
|
||||||
|
extern ee_u32 default_num_contexts;
|
||||||
|
|
||||||
|
typedef struct CORE_PORTABLE_S
|
||||||
|
{
|
||||||
|
ee_u8 portable_id;
|
||||||
|
} core_portable;
|
||||||
|
|
||||||
|
/* target specific init/fini */
|
||||||
|
void portable_init(core_portable *p, int *argc, char *argv[]);
|
||||||
|
void portable_fini(core_portable *p);
|
||||||
|
|
||||||
|
#if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) \
|
||||||
|
&& !defined(VALIDATION_RUN)
|
||||||
|
#if (TOTAL_DATA_SIZE == 1200)
|
||||||
|
#define PROFILE_RUN 1
|
||||||
|
#elif (TOTAL_DATA_SIZE == 2000)
|
||||||
|
#define PERFORMANCE_RUN 1
|
||||||
|
#else
|
||||||
|
#define VALIDATION_RUN 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CORE_PORTME_H */
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit eefc986ebd3452d6adde22eafaff3e5c859f29e4
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit d3b984684bb8a8bdc48cc7a1abecb93ce59bbe3e
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*
|
||||||
|
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
Original Author: Shay Gal-on
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "coremark.h"
|
||||||
|
#include "printf.h"
|
||||||
|
#include "stx7105.h"
|
||||||
|
|
||||||
|
#define SYSTEM_CONFIG34 (0xFE001188U) /* PIO4 */
|
||||||
|
#define SYSTEM_CONFIG7 (0xFE00111CU) /* RXSEL */
|
||||||
|
#define CONSOLE_ASC ASC2
|
||||||
|
|
||||||
|
#if VALIDATION_RUN
|
||||||
|
volatile ee_s32 seed1_volatile = 0x3415;
|
||||||
|
volatile ee_s32 seed2_volatile = 0x3415;
|
||||||
|
volatile ee_s32 seed3_volatile = 0x66;
|
||||||
|
#endif
|
||||||
|
#if PERFORMANCE_RUN
|
||||||
|
volatile ee_s32 seed1_volatile = 0x0;
|
||||||
|
volatile ee_s32 seed2_volatile = 0x0;
|
||||||
|
volatile ee_s32 seed3_volatile = 0x66;
|
||||||
|
#endif
|
||||||
|
#if PROFILE_RUN
|
||||||
|
volatile ee_s32 seed1_volatile = 0x8;
|
||||||
|
volatile ee_s32 seed2_volatile = 0x8;
|
||||||
|
volatile ee_s32 seed3_volatile = 0x8;
|
||||||
|
#endif
|
||||||
|
volatile ee_s32 seed4_volatile = ITERATIONS;
|
||||||
|
volatile ee_s32 seed5_volatile = 0;
|
||||||
|
/* Porting : Timing functions
|
||||||
|
How to capture time and convert to seconds must be ported to whatever is
|
||||||
|
supported by the platform. e.g. Read value from on board RTC, read value from
|
||||||
|
cpu clock cycles performance counter etc. Sample implementation for standard
|
||||||
|
time.h and windows.h definitions included.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define EE_TICKS_PER_SEC 100000
|
||||||
|
|
||||||
|
/** Define Host specific (POSIX), or target specific global time variables. */
|
||||||
|
static uint32_t start_time_val, stop_time_val;
|
||||||
|
|
||||||
|
/* Function : start_time
|
||||||
|
This function will be called right before starting the timed portion of
|
||||||
|
the benchmark.
|
||||||
|
|
||||||
|
Implementation may be capturing a system timer (as implemented in the
|
||||||
|
example code) or zeroing some system parameters - e.g. setting the cpu clocks
|
||||||
|
cycles to 0.
|
||||||
|
*/
|
||||||
|
void start_time(void) {
|
||||||
|
uint32_t reload_value = 0xFFFFFFF;
|
||||||
|
|
||||||
|
start_time_val = reload_value;
|
||||||
|
|
||||||
|
TMU->TSTR &= ~TMU_TSTR_STR0_Msk; /* Stop counter */
|
||||||
|
TMU->TCR0 = 0x04U; /* 1024 prescale */
|
||||||
|
TMU->TCNT0 = reload_value; /* 100kHz */
|
||||||
|
TMU->TCOR0 = reload_value; /* Reload register */
|
||||||
|
TMU->TSTR |= TMU_TSTR_STR0_Msk; /* Start counter */
|
||||||
|
}
|
||||||
|
/* Function : stop_time
|
||||||
|
This function will be called right after ending the timed portion of the
|
||||||
|
benchmark.
|
||||||
|
|
||||||
|
Implementation may be capturing a system timer (as implemented in the
|
||||||
|
example code) or other system parameters - e.g. reading the current value of
|
||||||
|
cpu cycles counter.
|
||||||
|
*/
|
||||||
|
void stop_time(void) {
|
||||||
|
TMU->TSTR &= ~TMU_TSTR_STR0_Msk; /* Stop counter */
|
||||||
|
stop_time_val = TMU->TCNT0;
|
||||||
|
}
|
||||||
|
/* Function : get_time
|
||||||
|
Return an abstract "ticks" number that signifies time on the system.
|
||||||
|
|
||||||
|
Actual value returned may be cpu cycles, milliseconds or any other
|
||||||
|
value, as long as it can be converted to seconds by <time_in_secs>. This
|
||||||
|
methodology is taken to accommodate any hardware or simulated platform. The
|
||||||
|
sample implementation returns millisecs by default, and the resolution is
|
||||||
|
controlled by <TIMER_RES_DIVIDER>
|
||||||
|
*/
|
||||||
|
CORE_TICKS get_time(void) {
|
||||||
|
CORE_TICKS elapsed = (CORE_TICKS)(stop_time_val - start_time_val);
|
||||||
|
return elapsed;
|
||||||
|
}
|
||||||
|
/* Function : time_in_secs
|
||||||
|
Convert the value returned by get_time to seconds.
|
||||||
|
|
||||||
|
The <secs_ret> type is used to accommodate systems with no support for
|
||||||
|
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
|
||||||
|
macro above.
|
||||||
|
*/
|
||||||
|
secs_ret time_in_secs(CORE_TICKS ticks) {
|
||||||
|
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
ee_u32 default_num_contexts = 1;
|
||||||
|
|
||||||
|
static void uart_init(void) {
|
||||||
|
PIO4->CLR_PC0 = 1U; /* PC = 110, AFOUT, PP */
|
||||||
|
PIO4->SET_PC1 = 1U;
|
||||||
|
PIO4->SET_PC2 = 1U;
|
||||||
|
|
||||||
|
*(uint32_t *)SYSTEM_CONFIG34 = 0x00000100UL; /* BIT[8,0] = 10, AF 3 */
|
||||||
|
*(uint32_t *)SYSTEM_CONFIG7 &= ~(0x00000006UL); /* BIT[2:1], UART2 RX SEL */
|
||||||
|
|
||||||
|
CONSOLE_ASC->CTRL = 0x1509UL; /* 8N1, RX enable, FIFO enable, Baud mode 1 */
|
||||||
|
CONSOLE_ASC->BAUDRATE = 0x04B8UL; /* 115200 in baud mode 1, assuming Fcomm=100MHz */
|
||||||
|
CONSOLE_ASC->TX_RST = 0x01UL; /* Reset TX FIFO, any value OK */
|
||||||
|
CONSOLE_ASC->RX_RST = 0x01UL; /* Reset RX FIFO, any value OK */
|
||||||
|
CONSOLE_ASC->CTRL = 0x1589UL; /* 8N1, RX enable, FIFO enable, Baud mode 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function : portable_init
|
||||||
|
Target specific initialization code
|
||||||
|
Test for some common mistakes.
|
||||||
|
*/
|
||||||
|
void portable_init(core_portable *p, int *argc, char *argv[]) {
|
||||||
|
(void)argc; // prevent unused warning
|
||||||
|
(void)argv; // prevent unused warning
|
||||||
|
|
||||||
|
uart_init();
|
||||||
|
|
||||||
|
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
|
||||||
|
ee_printf(
|
||||||
|
"ERROR! Please define ee_ptr_int to a type that holds a "
|
||||||
|
"pointer!\n");
|
||||||
|
}
|
||||||
|
if (sizeof(ee_u32) != 4) {
|
||||||
|
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
|
||||||
|
}
|
||||||
|
p->portable_id = 1;
|
||||||
|
}
|
||||||
|
/* Function : portable_fini
|
||||||
|
Target specific final code
|
||||||
|
*/
|
||||||
|
void portable_fini(core_portable *p) {
|
||||||
|
p->portable_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _putchar(char ch) {
|
||||||
|
while (CONSOLE_ASC->STA & 1 << 9U) {
|
||||||
|
// wait for TX FIFO slot.
|
||||||
|
}
|
||||||
|
CONSOLE_ASC->TX_BUF = ch;
|
||||||
|
}
|
58
src/main.c
58
src/main.c
|
@ -1,58 +0,0 @@
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "printf.h"
|
|
||||||
#include "stx7105.h"
|
|
||||||
#include "stx7105_utils.h"
|
|
||||||
|
|
||||||
#define LED_RED_GPIO PIO0
|
|
||||||
#define LED_RED_PIN 5U
|
|
||||||
|
|
||||||
#define LED_BLUE_GPIO PIO0
|
|
||||||
#define LED_BLUE_PIN 4U
|
|
||||||
|
|
||||||
#define CONSOLE_ASC ASC2
|
|
||||||
#define SYSTEM_DEVID (0xFE001000U) /* DEVID */
|
|
||||||
#define SYSTEM_CONFIG34 (0xFE001188U) /* PIO4 */
|
|
||||||
#define SYSTEM_CONFIG7 (0xFE00111CU) /* RXSEL */
|
|
||||||
|
|
||||||
void uart_init(void) {
|
|
||||||
PIO4->CLR_PC0 = 1U; /* PC = 110, AFOUT, PP */
|
|
||||||
PIO4->SET_PC1 = 1U;
|
|
||||||
PIO4->SET_PC2 = 1U;
|
|
||||||
|
|
||||||
*(uint32_t *)SYSTEM_CONFIG34 = 0x00000100UL; /* BIT[8,0] = 10, AF 3 */
|
|
||||||
*(uint32_t *)SYSTEM_CONFIG7 &= ~(0x00000006UL); /* BIT[2:1], UART2 RX SEL */
|
|
||||||
|
|
||||||
CONSOLE_ASC->CTRL = 0x1509UL; /* 8N1, RX enable, FIFO enable, Baud mode 1 */
|
|
||||||
CONSOLE_ASC->BAUDRATE = 0x04B8UL; /* 115200 in baud mode 1, assuming Fcomm=100MHz */
|
|
||||||
CONSOLE_ASC->TX_RST = 0x01UL; /* Reset TX FIFO, any value OK */
|
|
||||||
CONSOLE_ASC->RX_RST = 0x01UL; /* Reset RX FIFO, any value OK */
|
|
||||||
CONSOLE_ASC->CTRL = 0x1589UL; /* 8N1, RX enable, FIFO enable, Baud mode 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
init_led(LED_RED_GPIO, LED_RED_PIN, 0U);
|
|
||||||
init_led(LED_BLUE_GPIO, LED_BLUE_PIN, 0U);
|
|
||||||
|
|
||||||
uart_init();
|
|
||||||
|
|
||||||
printf("Hello world\r\n");
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
set_led(LED_BLUE_GPIO, LED_BLUE_PIN, 1U);
|
|
||||||
delay_ms(500);
|
|
||||||
printf("Hello ?\r\n");
|
|
||||||
set_led(LED_BLUE_GPIO, LED_BLUE_PIN, 0U);
|
|
||||||
delay_ms(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _putchar(char ch) {
|
|
||||||
while(CONSOLE_ASC->STA & 1 << 9U) {
|
|
||||||
// wait for TX FIFO slot.
|
|
||||||
}
|
|
||||||
CONSOLE_ASC->TX_BUF = ch;
|
|
||||||
}
|
|
Loading…
Reference in New Issue