mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add __run_demo.sh
This commit is contained in:
parent
be294d7253
commit
89e92a2fe1
30
port/qemu/__run_demo.sh
Normal file
30
port/qemu/__run_demo.sh
Normal file
@ -0,0 +1,30 @@
|
||||
# config
|
||||
OUT_NAME=result.txt
|
||||
|
||||
# clear
|
||||
rm $OUT_NAME
|
||||
|
||||
# make the project
|
||||
make clean >/dev/null
|
||||
make $1_ALL >/dev/null
|
||||
|
||||
# launch qemu service
|
||||
make $1_QEMURUN_TEL > qemu.out 2>&1 & echo $! > qemu.pid
|
||||
sleep 1
|
||||
# launch netcat client
|
||||
nc -d 0.0.0.0 7777 > $OUT_NAME 2>&1 & echo $! > nc.pid
|
||||
sleep 1
|
||||
|
||||
# kill the processes
|
||||
kill `cat nc.pid`
|
||||
kill `cat qemu.pid`
|
||||
rm nc.pid
|
||||
rm qemu.pid
|
||||
rm qemu.out
|
||||
|
||||
# print the result
|
||||
echo ======================================
|
||||
echo [info]: qemu benchmark output
|
||||
echo --------------------------------------
|
||||
cat $OUT_NAME
|
||||
echo ======================================
|
@ -11,7 +11,7 @@ void sleep() {
|
||||
/* redirect printf to myprintf */
|
||||
#define printf myprintf
|
||||
|
||||
static void prime_number_100_c() {
|
||||
static void prime_number_100_c(void) {
|
||||
int num = 0;
|
||||
num = 0;
|
||||
/* run */
|
||||
@ -32,6 +32,22 @@ static void prime_number_100_c() {
|
||||
}
|
||||
}
|
||||
|
||||
void systick_init(void) {
|
||||
uint32_t hclk_ticks_per_sec, ext_clock_ticks_per_sec;
|
||||
hclk_ticks_per_sec = SystemCoreClock;
|
||||
ext_clock_ticks_per_sec = hclk_ticks_per_sec / 8;
|
||||
if (SysTick_Config(ext_clock_ticks_per_sec)) {
|
||||
/* If SysTick_Config returns 1, that means the number ticks exceeds the
|
||||
* limit. */
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void SysTick_Handler(void) {
|
||||
GPIOC->ODR ^= 0x00001000;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
uint8_t b;
|
||||
int32_t num1 = 0x1234;
|
||||
@ -40,9 +56,8 @@ int main(void) {
|
||||
|
||||
// first init myprintf device(usart2)
|
||||
myprintf_init();
|
||||
systick_init();
|
||||
uint32_t tic = SysTick->VAL;
|
||||
prime_number_100_c();
|
||||
while (1) {
|
||||
myprintf("test num %d=0x%x str %s ch %c\n", num1, num1, str1, ch1);
|
||||
sleep();
|
||||
}
|
||||
myprintf("SysTick spend: %d\n", tic - (uint32_t)SysTick->VAL);
|
||||
}
|
||||
|
@ -36,5 +36,6 @@ int main(void) {
|
||||
last_button_state = GPIOA->IDR & 0x00000001;
|
||||
while (1) {
|
||||
SysTick->CTRL ^= SysTick_CTRL_CLKSOURCE_Msk;
|
||||
SysTick->VAL;
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1 @@
|
||||
# config
|
||||
OUT_NAME=result.txt
|
||||
|
||||
# clear
|
||||
rm $OUT_NAME
|
||||
|
||||
# make the project
|
||||
make clean
|
||||
make printf_demo_ALL
|
||||
|
||||
# launch qemu service
|
||||
make printf_demo_QEMURUN_TEL > qemu.out 2>&1 & echo $! > qemu.pid
|
||||
sleep 1
|
||||
# launch netcat client
|
||||
nc -d 0.0.0.0 7777 > $OUT_NAME 2>&1 & echo $! > nc.pid
|
||||
sleep 1
|
||||
|
||||
# kill the processes
|
||||
kill `cat nc.pid`
|
||||
kill `cat qemu.pid`
|
||||
rm nc.pid
|
||||
rm qemu.pid
|
||||
rm qemu.out
|
||||
|
||||
# print the result
|
||||
echo ======================================
|
||||
echo [info]: qemu benchmark output
|
||||
echo --------------------------------------
|
||||
cat $OUT_NAME
|
||||
echo ======================================
|
||||
sh __run_demo.sh printf_demo
|
||||
|
Loading…
x
Reference in New Issue
Block a user