From 4c04057e493d661e2385d2220a771fa96a08e635 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Thu, 13 Jun 2019 21:32:47 +0200 Subject: [PATCH] feat(api-demo): Add dual-core stuff --- hw-tests/api-demo/flash.gdb | 13 +++++++++++++ hw-tests/api-demo/main.c | 10 ++++++++++ hw-tests/api-demo/meson.build | 18 +++++++++++++++--- hw-tests/api-demo/test-payload.c | 21 +++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 hw-tests/api-demo/flash.gdb create mode 100644 hw-tests/api-demo/test-payload.c diff --git a/hw-tests/api-demo/flash.gdb b/hw-tests/api-demo/flash.gdb new file mode 100644 index 00000000..1b9e60c0 --- /dev/null +++ b/hw-tests/api-demo/flash.gdb @@ -0,0 +1,13 @@ +source ../../.gdbinit + +set confirm off + +echo Loading core1 image ... +file ../../build/hw-tests/api-demo/api-demo-core1.elf +load +echo Loading core0 image ... +file ../../build/hw-tests/api-demo/api-demo-core0.elf +load + +reset +quit diff --git a/hw-tests/api-demo/main.c b/hw-tests/api-demo/main.c index 41cb0123..a78e9ea6 100644 --- a/hw-tests/api-demo/main.c +++ b/hw-tests/api-demo/main.c @@ -5,6 +5,16 @@ #include "card10.h" #include "tmr_utils.h" +void Core1_Start(void) { + //MXC_GCR->gp0 = (uint32_t)(&__isr_vector_core1); + MXC_GCR->gp0 = 0x10040000; + MXC_GCR->perckcn1 &= ~MXC_F_GCR_PERCKCN1_CPU1; +} + +void Core1_Stop(void) { + MXC_GCR->perckcn1 |= MXC_F_GCR_PERCKCN1_CPU1; +} + int main(void) { int count = 0; diff --git a/hw-tests/api-demo/meson.build b/hw-tests/api-demo/meson.build index 071241b1..a86ba8c8 100644 --- a/hw-tests/api-demo/meson.build +++ b/hw-tests/api-demo/meson.build @@ -1,10 +1,22 @@ -name = 'api-demo' +name = 'api-demo-core0' executable( name + '.elf', 'main.c', - dependencies: [libcard10, max32665_startup], - link_whole: [max32665_startup_lib, board_card10_lib], + dependencies: [libcard10, max32665_startup_core0], + link_whole: [max32665_startup_core0_lib, board_card10_lib], + link_args: [ + '-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map', + ], +) + +name = 'api-demo-core1' + +executable( + name + '.elf', + 'test-payload.c', + dependencies: [libcard10, max32665_startup_core1], + link_whole: [max32665_startup_core1_lib, board_card10_lib], link_args: [ '-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map', ], diff --git a/hw-tests/api-demo/test-payload.c b/hw-tests/api-demo/test-payload.c new file mode 100644 index 00000000..989c611a --- /dev/null +++ b/hw-tests/api-demo/test-payload.c @@ -0,0 +1,21 @@ +#include "board.h" +#include "gpio.h" +#include "mxc_delay.h" + +static const gpio_cfg_t motor_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE}; + +int main(void) +{ + // Enable rxev on core1 + MXC_GCR->evten |= 0x20; + for (int i = 0; 1; i++) { + __asm volatile("wfe"); + printf("core1: Hello! %d\n", i); + +#if 0 + GPIO_OutSet(&motor_pin); + mxc_delay(30000); + GPIO_OutClr(&motor_pin); +#endif + } +} -- GitLab