Cross-core signaling now apparently works.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14156 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-04-09 09:06:22 +00:00
parent c3a2ee2e35
commit 4913569895
4 changed files with 56 additions and 14 deletions

View File

@ -65,6 +65,22 @@ static const os_instance_config_t core1_cfg = {
#endif #endif
}; };
/*
* Green LED blinker thread, times are in milliseconds.
*/
static THD_WORKING_AREA(waThreadTimer, 128);
static THD_FUNCTION(ThreadTimer, arg) {
extern semaphore_t blinker_sem;
(void)arg;
chRegSetThreadName("timer");
while (true) {
chThdSleepMilliseconds(500);
chSemSignal(&blinker_sem);
}
}
/** /**
* Core 1 entry point. * Core 1 entry point.
*/ */
@ -90,6 +106,11 @@ void c1_main(void) {
sioStart(&SIOD1, NULL); sioStart(&SIOD1, NULL);
sioStartOperation(&SIOD1, NULL); sioStartOperation(&SIOD1, NULL);
/*
* Creates the timer thread.
*/
chThdCreateStatic(waThreadTimer, sizeof(waThreadTimer), NORMALPRIO, ThreadTimer, NULL);
/* /*
* Shell manager initialization. * Shell manager initialization.
*/ */

View File

@ -17,6 +17,8 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
semaphore_t blinker_sem;
/* /*
* Green LED blinker thread, times are in milliseconds. * Green LED blinker thread, times are in milliseconds.
*/ */
@ -26,10 +28,8 @@ static THD_FUNCTION(Thread1, arg) {
(void)arg; (void)arg;
chRegSetThreadName("blinker"); chRegSetThreadName("blinker");
while (true) { while (true) {
palClearLine(25U); chSemWait(&blinker_sem);
chThdSleepMilliseconds(500); palToggleLine(25U);
palSetLine(25U);
chThdSleepMilliseconds(500);
} }
} }
@ -43,6 +43,15 @@ static void start_core1(void) {
(uint32_t)_crt0_c1_entry}; (uint32_t)_crt0_c1_entry};
unsigned seq; unsigned seq;
#if 0
/* Resetting core1.*/
PSM_SET->FRCE_OFF = PSM_ANY_PROC1;
while ((PSM->FRCE_OFF & PSM_ANY_PROC1) == 0U) {
}
PSM_CLR->FRCE_OFF = PSM_ANY_PROC1;
#endif
/* Starting core 1.*/
seq = 0; seq = 0;
do { do {
uint32_t response; uint32_t response;
@ -77,7 +86,9 @@ int main(void) {
/* /*
* Starting core 1 after performing all OS-related initializations. * Starting core 1 after performing all OS-related initializations.
*/ */
chSysSuspend();
start_core1(); start_core1();
chSysEnable();
/* /*
* Setting up GPIOs. * Setting up GPIOs.
@ -87,6 +98,7 @@ int main(void) {
/* /*
* Creates the blinker thread. * Creates the blinker thread.
*/ */
chSemObjectInit(&blinker_sem, 0);
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/* /*

View File

@ -110,10 +110,14 @@ void PendSV_Handler(void) {
* *
* @isr * @isr
*/ */
CH_IRQ_HANDLER(RP_SIO_IRQ_PROC0_HANDLER) { CH_IRQ_HANDLER(Vector7C) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
/* Error flags cleared and ignored.*/
SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
/* Read FIFO is fully emptied.*/
while ((SIO->FIFO_ST & SIO_FIFO_ST_VLD) != 0U) { while ((SIO->FIFO_ST & SIO_FIFO_ST_VLD) != 0U) {
uint32_t message = SIO->FIFO_RD; uint32_t message = SIO->FIFO_RD;
#if defined(PORT_HANDLE_FIFO_MESSAGE) #if defined(PORT_HANDLE_FIFO_MESSAGE)
@ -136,10 +140,14 @@ CH_IRQ_HANDLER(RP_SIO_IRQ_PROC0_HANDLER) {
* *
* @isr * @isr
*/ */
CH_IRQ_HANDLER(RP_SIO_IRQ_PROC1_HANDLER) { CH_IRQ_HANDLER(Vector80) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
/* Error flags cleared and ignored.*/
SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
/* Read FIFO is fully emptied.*/
while ((SIO->FIFO_ST & SIO_FIFO_ST_VLD) != 0U) { while ((SIO->FIFO_ST & SIO_FIFO_ST_VLD) != 0U) {
uint32_t message = SIO->FIFO_RD; uint32_t message = SIO->FIFO_RD;
#if defined(PORT_HANDLE_FIFO_MESSAGE) #if defined(PORT_HANDLE_FIFO_MESSAGE)
@ -180,11 +188,14 @@ void port_init(os_instance_t *oip) {
#if CH_CFG_SMP_MODE != FALSE #if CH_CFG_SMP_MODE != FALSE
/* FIFO handlers for each core.*/ /* FIFO handlers for each core.*/
SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
if (core_id == 0U) { if (core_id == 0U) {
NVIC_SetPriority(15, CORTEX_MAX_KERNEL_PRIORITY); NVIC_SetPriority(15, CORTEX_MINIMUM_PRIORITY);
NVIC_EnableIRQ(15);
} }
else if (core_id == 1U) { else if (core_id == 1U) {
NVIC_SetPriority(16, CORTEX_MAX_KERNEL_PRIORITY); NVIC_SetPriority(16, CORTEX_MINIMUM_PRIORITY);
NVIC_EnableIRQ(16);
} }
else { else {
chDbgAssert(false, "unexpected core id"); chDbgAssert(false, "unexpected core id");

View File

@ -520,13 +520,11 @@ __STATIC_INLINE void port_notify_instance(os_instance_t *oip) {
(void)oip; (void)oip;
/* Waiting for space into the FIFO.*/ /* Sending a reschedule order to the other core if there is space in
while ((SIO->FIFO_ST & SIO_FIFO_ST_RDY) == 0U) { the FIFO.*/
__WFE(); if ((SIO->FIFO_ST & SIO_FIFO_ST_RDY) != 0U) {
SIO->FIFO_WR = PORT_FIFO_RESCHEDULE_MESSAGE;
} }
/* Sending a reschedule order to the other core.*/
SIO->FIFO_WR = PORT_FIFO_RESCHEDULE_MESSAGE;
} }
/** /**