Small fixes (#260)

* pico_stdio_usb: be more explicit about includes, fix warning (#257)

* pico_base: NDEBUG backwards for absolute_time_t (#255)

* pico_util: missing extern C in queue.h (#249)

* build: remove -march which was masking -mcpu, now SVC available (#253)
This commit is contained in:
Graham Sanderson 2021-03-17 13:05:48 -05:00 committed by GitHub
parent d36b1ca8ae
commit fe3408b286
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 9 deletions

View File

@ -52,8 +52,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0) option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
# todo move to platform/Generix-xxx # todo move to platform/Generix-xxx
set(ARM_GCC_COMMON_FLAGS " -march=armv6-m -mcpu=cortex-m0plus -mthumb")
#set(ARM_GCC_COMMON_FLAGS " -mcpu=cortex-m0plus -mthumb") # on ARM -mcpu should not be mixed with -march
set(ARM_GCC_COMMON_FLAGS " -mcpu=cortex-m0plus -mthumb")
foreach(LANG IN ITEMS C CXX ASM) foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_FLAGS_INIT "${ARM_GCC_COMMON_FLAGS}") set(CMAKE_${LANG}_FLAGS_INIT "${ARM_GCC_COMMON_FLAGS}")
if (PICO_DEOPTIMIZED_DEBUG) if (PICO_DEOPTIMIZED_DEBUG)

View File

@ -25,7 +25,7 @@ typedef unsigned int uint;
\see update_us_since_boot() \see update_us_since_boot()
\ingroup timestamp \ingroup timestamp
*/ */
#ifndef NDEBUG #ifdef NDEBUG
typedef uint64_t absolute_time_t; typedef uint64_t absolute_time_t;
#else #else
typedef struct { typedef struct {
@ -40,7 +40,7 @@ typedef struct {
* \ingroup timestamp * \ingroup timestamp
*/ */
static inline uint64_t to_us_since_boot(absolute_time_t t) { static inline uint64_t to_us_since_boot(absolute_time_t t) {
#ifndef NDEBUG #ifdef NDEBUG
return t; return t;
#else #else
return t._private_us_since_boot; return t._private_us_since_boot;
@ -55,7 +55,7 @@ static inline uint64_t to_us_since_boot(absolute_time_t t) {
* \ingroup timestamp * \ingroup timestamp
*/ */
static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot) { static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot) {
#ifndef NDEBUG #ifdef NDEBUG
*t = us_since_boot; *t = us_since_boot;
#else #else
assert(us_since_boot <= INT64_MAX); assert(us_since_boot <= INT64_MAX);
@ -63,7 +63,7 @@ static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_bo
#endif #endif
} }
#ifndef NDEBUG #ifdef NDEBUG
#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = value #define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = value
#else #else
#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = {value} #define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = {value}

View File

@ -18,6 +18,10 @@
* \ingroup pico_util * \ingroup pico_util
*/ */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct { typedef struct {
spin_lock_t *lock; spin_lock_t *lock;
uint8_t *data; uint8_t *data;
@ -69,7 +73,7 @@ void queue_free(queue_t *q);
static inline uint queue_get_level_unsafe(queue_t *q) { static inline uint queue_get_level_unsafe(queue_t *q) {
int32_t rc = (int32_t)q->wptr - (int32_t)q->rptr; int32_t rc = (int32_t)q->wptr - (int32_t)q->rptr;
if (rc < 0) { if (rc < 0) {
rc += + q->element_count + 1; rc += q->element_count + 1;
} }
return (uint)rc; return (uint)rc;
} }
@ -181,4 +185,7 @@ void queue_remove_blocking(queue_t *q, void *data);
*/ */
void queue_peek_blocking(queue_t *q, void *data); void queue_peek_blocking(queue_t *q, void *data);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -60,7 +60,7 @@ static bool resetd_control_request_cb(uint8_t __unused rhport, tusb_control_requ
#if PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT #if PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT
if (request->bRequest == RESET_REQUEST_FLASH) { if (request->bRequest == RESET_REQUEST_FLASH) {
watchdog_reboot(0, SRAM_END, PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS); watchdog_reboot(0, 0, PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS);
return true; return true;
} }
#endif #endif

View File

@ -10,12 +10,13 @@
#include "pico/time.h" #include "pico/time.h"
#include "pico/stdio/driver.h" #include "pico/stdio/driver.h"
#include "pico/binary_info.h" #include "pico/binary_info.h"
#include "pico/mutex.h"
#include "hardware/irq.h" #include "hardware/irq.h"
static_assert(PICO_STDIO_USB_LOW_PRIORITY_IRQ > RTC_IRQ, ""); // note RTC_IRQ is currently the last one static_assert(PICO_STDIO_USB_LOW_PRIORITY_IRQ > RTC_IRQ, ""); // note RTC_IRQ is currently the last one
static mutex_t stdio_usb_mutex; static mutex_t stdio_usb_mutex;
static void low_priority_worker_irq() { static void low_priority_worker_irq(void) {
// if the mutex is already owned, then we are in user code // if the mutex is already owned, then we are in user code
// in this file which will do a tud_task itself, so we'll just do nothing // in this file which will do a tud_task itself, so we'll just do nothing
// until the next tick; we won't starve // until the next tick; we won't starve

View File

@ -83,6 +83,7 @@ int main(void) {
dma_channel_configure(0, &config, &dma_to, &dma_from, 1, true); dma_channel_configure(0, &config, &dma_to, &dma_from, 1, true);
dma_channel_set_config(0, &config, false); dma_channel_set_config(0, &config, false);
// note this loop expects to cause a breakpoint!!
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
puts("sleepy"); puts("sleepy");
sleep_ms(1000); sleep_ms(1000);
@ -94,4 +95,6 @@ int main(void) {
irq_remove_handler(DMA_IRQ_1, dma_handler_b); irq_remove_handler(DMA_IRQ_1, dma_handler_b);
} }
} }
// this should compile as we are Cortex M0+
__asm volatile("SVC #3");
} }