Compare commits

...

7 commits

Author SHA1 Message Date
P. Czarnota
877b22f5f4
Merge d3cb97240f into 8fcd44a171 2025-12-02 02:38:20 +01:00
armandomontanez
8fcd44a171
Forward declare __sev(), __wfe(), __wfi() (#2658)
Some checks failed
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Has been cancelled
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Has been cancelled
Bazel presubmit checks / other-bazel-checks (push) Has been cancelled
Check Configs / check-configs (push) Has been cancelled
CMake / build (push) Has been cancelled
Build on macOS / build (push) Has been cancelled
Build on Windows / build (push) Has been cancelled
If the compiler in use offers __sev(), __wfe(), or __wfi(), forward
declare them to be sure they're available for use.
2025-09-15 13:14:08 -05:00
Andrew Scheller
6b395cce04
Fix pico_status_led to change the color of an already-on colored LED (#2632)
Partially fixes #2630, as it doesn't take care of the required delay between setting the LED
2025-09-15 13:09:21 -05:00
armandomontanez
87c9c013fe
More robust clobbering of ARM builtins on host (#2657)
Since ARM hosts have builtins listed in hardware/sync.h, these builtins
should be clobbered. Newer versions of LLVM/Clang emit an error when
clobbering these builtins, so this switches the overrides to use the
same patterns as pico_atomic to clobber the builtins.
2025-09-15 13:04:09 -05:00
Martin Budden
17b914418d
Fix unused parameter warning. (#2663) 2025-09-15 12:53:06 -05:00
Andrew Scheller
db75b67533
Fix Multicoore typo (#2661) 2025-09-15 12:23:26 -05:00
Przemyslaw Czarnota
d3cb97240f Do not always set stdin to FNONBLOCK when PICO_PLATFORM=host
Because the UART simulation was setting FNONBLOCK flag on stdin, all
stdio functions like scanf() or fgets() were non blocking.
The workaround is to use a non_blocking_getchar() function to do the UART
simulation, which will temporarily set stdin to non blocking.
This will make stdio functions blocking like they normally do.
2023-03-29 11:36:22 +02:00
7 changed files with 55 additions and 13 deletions

View file

@ -109,8 +109,6 @@ extern "C" {
void __sev(); void __sev();
void __wev();
void __wfi(); void __wfi();
void __wfe(); void __wfe();

View file

@ -93,23 +93,44 @@ void PICO_WEAK_FUNCTION_IMPL_NAME(spin_unlock)(spin_lock_t *lock, uint32_t saved
spin_unlock_unsafe(lock); spin_unlock_unsafe(lock);
} }
PICO_WEAK_FUNCTION_DEF(__sev) // These are defined on ARM hosts, but don't do what we want for the host
// since this is a simulated build.
#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__sev)
#define __sev_c __sev
#else
#pragma redefine_extname __sev_c __sev
#endif
#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__wfi)
#define __wfi_c __wfi
#else
#pragma redefine_extname __wfi_c __wfi
#endif
#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__wfe)
#define __wfe_c __wfe
#else
#pragma redefine_extname __wfe_c __wfe
#endif
PICO_WEAK_FUNCTION_DEF(__sev_c)
volatile bool event_fired; volatile bool event_fired;
void PICO_WEAK_FUNCTION_IMPL_NAME(__sev)() { void PICO_WEAK_FUNCTION_IMPL_NAME(__sev_c)() {
event_fired = true; event_fired = true;
} }
PICO_WEAK_FUNCTION_DEF(__wfi) PICO_WEAK_FUNCTION_DEF(__wfi_c)
void PICO_WEAK_FUNCTION_IMPL_NAME(__wfi)() { void PICO_WEAK_FUNCTION_IMPL_NAME(__wfi_c)() {
panic("Can't wait on irq for host core0 only implementation"); panic("Can't wait on irq for host core0 only implementation");
} }
PICO_WEAK_FUNCTION_DEF(__wfe) PICO_WEAK_FUNCTION_DEF(__wfe_c)
void PICO_WEAK_FUNCTION_IMPL_NAME(__wfe)() { void PICO_WEAK_FUNCTION_IMPL_NAME(__wfe_c)() {
while (!event_fired) tight_loop_contents(); while (!event_fired) tight_loop_contents();
} }
@ -146,4 +167,4 @@ int PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_claim_unused)(bool required) {
PICO_WEAK_FUNCTION_DEF(spin_lock_num) PICO_WEAK_FUNCTION_DEF(spin_lock_num)
uint PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_num)(spin_lock_t *lock) { uint PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_num)(spin_lock_t *lock) {
return 0; return 0;
} }

View file

@ -48,12 +48,24 @@ void _inittty(void) {
//_tty.c_oflag &= ~ONLCR; //_tty.c_oflag &= ~ONLCR;
tcsetattr(STDIN_FILENO, TCSANOW, &_tty); tcsetattr(STDIN_FILENO, TCSANOW, &_tty);
fcntl(STDIN_FILENO, F_SETFL, FNONBLOCK);
atexit(_resettty); atexit(_resettty);
} }
static int non_blocking_getchar(void) {
fcntl(STDIN_FILENO, F_SETFL, FNONBLOCK);
int c = getchar();
int old = fcntl(STDIN_FILENO, F_GETFL);
fcntl(STDIN_FILENO, F_SETFL, old & ~FNONBLOCK);
return c;
}
#else #else
void _inittty() {} void _inittty() {}
static int non_blocking_getchar(void) { return getchar(); }
#endif #endif
typedef struct { typedef struct {
@ -67,7 +79,7 @@ static int _nextchar = EOF;
static bool _peekchar() { static bool _peekchar() {
if (_nextchar == EOF) { if (_nextchar == EOF) {
_nextchar = getchar(); _nextchar = non_blocking_getchar();
} }
return _nextchar != EOF; return _nextchar != EOF;
} }

View file

@ -556,6 +556,7 @@ static inline uint32_t dma_encode_transfer_count(uint transfer_count) {
*/ */
static inline uint32_t dma_encode_transfer_count_with_self_trigger(uint transfer_count) { static inline uint32_t dma_encode_transfer_count_with_self_trigger(uint transfer_count) {
#if PICO_RP2040 #if PICO_RP2040
(void)transfer_count;
panic_unsupported(); panic_unsupported();
#else #else
return dma_encode_transfer_count(transfer_count) | (DMA_CH0_TRANS_COUNT_MODE_VALUE_TRIGGER_SELF << DMA_CH0_TRANS_COUNT_MODE_LSB); return dma_encode_transfer_count(transfer_count) | (DMA_CH0_TRANS_COUNT_MODE_VALUE_TRIGGER_SELF << DMA_CH0_TRANS_COUNT_MODE_LSB);

View file

@ -94,6 +94,9 @@ __force_inline static void __sev(void) {
pico_default_asm_volatile ("sev"); pico_default_asm_volatile ("sev");
#endif #endif
} }
#else
// Forward declare so we don't have to #include <arm_acle.h>.
void __sev(void);
#endif #endif
/*! \brief Insert a WFE instruction in to the code path. /*! \brief Insert a WFE instruction in to the code path.
@ -110,6 +113,9 @@ __force_inline static void __wfe(void) {
pico_default_asm_volatile ("wfe"); pico_default_asm_volatile ("wfe");
#endif #endif
} }
#else
// Forward declare so we don't have to #include <arm_acle.h>.
void __wfe(void);
#endif #endif
/*! \brief Insert a WFI instruction in to the code path. /*! \brief Insert a WFI instruction in to the code path.
@ -121,6 +127,9 @@ __force_inline static void __wfe(void) {
__force_inline static void __wfi(void) { __force_inline static void __wfi(void) {
pico_default_asm_volatile("wfi"); pico_default_asm_volatile("wfi");
} }
#else
// Forward declare so we don't have to #include <arm_acle.h>.
void __wfi(void);
#endif #endif
/*! \brief Insert a DMB instruction in to the code path. /*! \brief Insert a DMB instruction in to the code path.

View file

@ -370,7 +370,7 @@ static bool multicore_doorbell_claim_under_lock(uint doorbell_num, uint core_mas
(is_bit_claimed(doorbell_claimed[1], doorbell_num + 1u) << 1)); (is_bit_claimed(doorbell_claimed[1], doorbell_num + 1u) << 1));
if (claimed_cores_for_doorbell & core_mask) { if (claimed_cores_for_doorbell & core_mask) {
if (required) { if (required) {
panic( "Multicoore doorbell %d already claimed on core mask 0x%x; requested core mask 0x%x\n", panic( "Multicore doorbell %d already claimed on core mask 0x%x; requested core mask 0x%x\n",
claimed_cores_for_doorbell, core_mask); claimed_cores_for_doorbell, core_mask);
} }
return false; return false;

View file

@ -80,7 +80,8 @@ bool colored_status_led_set_state(bool led_on) {
if (colored_status_led_supported()) { if (colored_status_led_supported()) {
#if COLORED_STATUS_LED_USING_WS2812_PIO #if COLORED_STATUS_LED_USING_WS2812_PIO
success = true; success = true;
if (led_on && !colored_status_led_on) { if (led_on) {
// Turn the LED "on" even if it was already on, as the color might have changed
success = set_ws2812(colored_status_led_on_color); success = set_ws2812(colored_status_led_on_color);
} else if (!led_on && colored_status_led_on) { } else if (!led_on && colored_status_led_on) {
success = set_ws2812(0); success = set_ws2812(0);