git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14122 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2021-04-02 10:52:23 +00:00
parent 151b06183f
commit 781b714fd3
4 changed files with 31 additions and 57 deletions

View File

@ -17,21 +17,19 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
/* #include "shell.h"
* Green LED blinker thread, times are in milliseconds. #include "chprintf.h"
*/
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {
(void)arg; #define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
chRegSetThreadName("blinker");
while (true) { static const ShellCommand commands[] = {
palClearLine(25U); {NULL, NULL}
chThdSleepMilliseconds(500); };
palSetLine(25U);
chThdSleepMilliseconds(500); static const ShellConfig shell_cfg1 = {
} (BaseSequentialStream *)&SIOD1,
} commands
};
/** /**
* @brief Core 1 OS instance. * @brief Core 1 OS instance.
@ -81,18 +79,22 @@ void c1_main(void) {
*/ */
palSetLineMode(0U, PAL_MODE_ALTERNATE_UART); palSetLineMode(0U, PAL_MODE_ALTERNATE_UART);
palSetLineMode(1U, PAL_MODE_ALTERNATE_UART); palSetLineMode(1U, PAL_MODE_ALTERNATE_UART);
palSetLineMode(25U, PAL_MODE_OUTPUT_PUSHPULL | PAL_RP_PAD_DRIVE12);
/* /*
* Creates the blinker thread. * Activates the Serial or SIO driver using the default configuration.
*/ */
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); sioStart(&SIOD1, NULL);
sioStartOperation(&SIOD1, NULL);
/* /*
* Normal main() thread activity, in this demo it does nothing except * Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop. * sleeping in a loop (re)spawning a shell.
*/ */
while (true) { while (true) {
thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
"shell", NORMALPRIO + 1,
shellThread, (void *)&shell_cfg1);
chThdWait(shelltp); /* Waiting termination. */
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
} }
} }

View File

@ -16,24 +16,7 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "rt_test_root.h"
#include "oslib_test_root.h"
#include "shell.h"
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
static const ShellCommand commands[] = {
{NULL, NULL}
};
static const ShellConfig shell_cfg1 = {
(BaseSequentialStream *)&SIOD1,
commands
};
#if 0
/* /*
* Green LED blinker thread, times are in milliseconds. * Green LED blinker thread, times are in milliseconds.
*/ */
@ -49,7 +32,6 @@ static THD_FUNCTION(Thread1, arg) {
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
} }
} }
#endif
/* Courtesy of Pico-SDK.*/ /* Courtesy of Pico-SDK.*/
static void start_core1(void) { static void start_core1(void) {
@ -100,30 +82,18 @@ int main(void) {
/* /*
* Setting up GPIOs. * Setting up GPIOs.
*/ */
// palSetLineMode(0U, PAL_MODE_ALTERNATE_UART); palSetLineMode(25U, PAL_MODE_OUTPUT_PUSHPULL | PAL_RP_PAD_DRIVE12);
// palSetLineMode(1U, PAL_MODE_ALTERNATE_UART);
// palSetLineMode(25U, PAL_MODE_OUTPUT_PUSHPULL | PAL_RP_PAD_DRIVE12);
/*
* Activates the Serial or SIO driver using the default configuration.
*/
sioStart(&SIOD1, NULL);
sioStartOperation(&SIOD1, NULL);
/* /*
* Creates the blinker thread. * Creates the blinker thread.
*/ */
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/* /*
* Normal main() thread activity, in this demo it does nothing except * Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop (re)spawning a shell. * sleeping in a loop.
*/ */
while (true) { while (true) {
thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
"shell", NORMALPRIO + 1,
shellThread, (void *)&shell_cfg1);
chThdWait(shelltp); /* Waiting termination. */
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
} }
} }

View File

@ -232,11 +232,13 @@ bool sio_lld_start(SIODriver *siop) {
#if RP_SIO_USE_UART0 == TRUE #if RP_SIO_USE_UART0 == TRUE
else if (&SIOD1 == siop) { else if (&SIOD1 == siop) {
hal_lld_peripheral_unreset(RESETS_ALLREG_UART0); hal_lld_peripheral_unreset(RESETS_ALLREG_UART0);
nvicEnableVector(RP_UART0_IRQ_NUMBER, RP_IRQ_UART0_PRIORITY);
} }
#endif #endif
#if RP_SIO_USE_UART1 == TRUE #if RP_SIO_USE_UART1 == TRUE
else if (&SIOD2 == siop) { else if (&SIOD2 == siop) {
hal_lld_peripheral_unreset(RESETS_ALLREG_UART1); hal_lld_peripheral_unreset(RESETS_ALLREG_UART1);
nvicEnableVector(RP_UART1_IRQ_NUMBER, RP_IRQ_UART1_PRIORITY);
} }
#endif #endif
else { else {
@ -275,14 +277,14 @@ void sio_lld_stop(SIODriver *siop) {
} }
#if RP_SIO_USE_UART0 == TRUE #if RP_SIO_USE_UART0 == TRUE
else if (&SIOD1 == siop) { else if (&SIOD1 == siop) {
nvicDisableVector(RP_UART0_IRQ_NUMBER);
hal_lld_peripheral_reset(RESETS_ALLREG_UART0); hal_lld_peripheral_reset(RESETS_ALLREG_UART0);
// rccDisableUSART1();
} }
#endif #endif
#if RP_SIO_USE_UART1 == TRUE #if RP_SIO_USE_UART1 == TRUE
else if (&SIOD2 == siop) { else if (&SIOD2 == siop) {
nvicDisableVector(RP_UART1_IRQ_NUMBER);
hal_lld_peripheral_reset(RESETS_ALLREG_UART1); hal_lld_peripheral_reset(RESETS_ALLREG_UART1);
// rccDisableUSART2();
} }
#endif #endif
else { else {

View File

@ -58,8 +58,8 @@
*/ */
void irqInit(void) { void irqInit(void) {
uart0_irq_init(); // uart0_irq_init();
uart1_irq_init(); // uart1_irq_init();
} }
/** /**
@ -69,8 +69,8 @@ void irqInit(void) {
*/ */
void irqDeinit(void) { void irqDeinit(void) {
uart0_irq_deinit(); // uart0_irq_deinit();
uart1_irq_deinit(); // uart1_irq_deinit();
} }
/** @} */ /** @} */