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
};
/*
* 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.
*/
@ -90,6 +106,11 @@ void c1_main(void) {
sioStart(&SIOD1, NULL);
sioStartOperation(&SIOD1, NULL);
/*
* Creates the timer thread.
*/
chThdCreateStatic(waThreadTimer, sizeof(waThreadTimer), NORMALPRIO, ThreadTimer, NULL);
/*
* Shell manager initialization.
*/

View File

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

View File

@ -110,10 +110,14 @@ void PendSV_Handler(void) {
*
* @isr
*/
CH_IRQ_HANDLER(RP_SIO_IRQ_PROC0_HANDLER) {
CH_IRQ_HANDLER(Vector7C) {
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) {
uint32_t message = SIO->FIFO_RD;
#if defined(PORT_HANDLE_FIFO_MESSAGE)
@ -136,10 +140,14 @@ CH_IRQ_HANDLER(RP_SIO_IRQ_PROC0_HANDLER) {
*
* @isr
*/
CH_IRQ_HANDLER(RP_SIO_IRQ_PROC1_HANDLER) {
CH_IRQ_HANDLER(Vector80) {
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) {
uint32_t message = SIO->FIFO_RD;
#if defined(PORT_HANDLE_FIFO_MESSAGE)
@ -180,11 +188,14 @@ void port_init(os_instance_t *oip) {
#if CH_CFG_SMP_MODE != FALSE
/* FIFO handlers for each core.*/
SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
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) {
NVIC_SetPriority(16, CORTEX_MAX_KERNEL_PRIORITY);
NVIC_SetPriority(16, CORTEX_MINIMUM_PRIORITY);
NVIC_EnableIRQ(16);
}
else {
chDbgAssert(false, "unexpected core id");

View File

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