Skip to content

Commit 6b704d4

Browse files
committed
[rp2040] review fixes
1 parent 6ba8d17 commit 6b704d4

File tree

7 files changed

+31
-20
lines changed

7 files changed

+31
-20
lines changed

ext/rp/irq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
*/
1717
#include "hardware/regs/intctrl.h"
1818

19-
static void irq_set_enabled(int irqn,bool enable) {
19+
static inline void irq_set_enabled(int irqn,bool enable) {
2020
if (enable) {
2121
NVIC_EnableIRQ(irqn);
2222
} else {
2323
NVIC_DisableIRQ(irqn);
2424
}
2525
}
2626

27-
static void irq_set_exclusive_handler(int irqn,void(*handler)()) {
27+
static inline void irq_set_exclusive_handler(int irqn,void(*handler)()) {
2828
(void)irqn;
2929
(void)handler;
3030
// do nothing, irq implemented at modm

ext/rp/module.lb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ def prepare(module, options):
2121
return False
2222

2323
module.depends(":cmsis:core")
24-
module.add_option(
25-
EnumerationOption(
26-
name="boot2",
27-
description="Boot2 variant",
28-
enumeration=['generic_03h','at25sf128a','is25lp080','w25q080','w25x10cl'],
29-
default='generic_03h'))
3024
return True
3125

3226
def build(env):
@@ -44,12 +38,12 @@ def build(env):
4438
env.copy("pico-sdk/include",'')
4539
env.copy("address_mapped.h",'hardware/address_mapped.h')
4640

47-
flash_variant = env.get("boot2")
48-
env.copy("pico-sdk/src/boot2_" + flash_variant + '.cpp','src/boot2.cpp')
49-
5041
if env.has_module(":tinyusb"):
42+
env.substitutions = {
43+
'with_debug': env.has_module(":debug")
44+
}
5145
env.copy('pico.h')
52-
env.copy('pico.cpp','src/pico.cpp')
46+
env.template('pico.cpp.in','src/pico.cpp')
5347
env.copy('irq.h','hardware/irq.h')
5448
env.copy('resets.h','hardware/resets.h')
5549

ext/rp/pico.cpp renamed to ext/rp/pico.cpp.in

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "hardware/resets.h"
33

44
#include <modm/platform/core/resets.hpp>
5+
%% if with_debug
6+
#include <modm/debug.hpp>
7+
%% endif
58

69
/**
710
* Pico SDK compatibility for tinyusb
@@ -15,6 +18,11 @@ extern "C" void unreset_block_wait(uint32_t blocks) {
1518
}
1619

1720
extern "C" void panic(const char *fmt, ...) {
18-
// @todo any modm implementation? assert?
19-
//va_list args;
21+
%% if with_debug
22+
va_list va;
23+
va_start(va, fmt);
24+
modm::log::debug.vprintf(fmt, va);
25+
va_end(va);
26+
%% endif
27+
modm_assert(0, "pico", "Pico-SDK panic!");
2028
}

ext/rp/pico.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717

1818

1919
#include <stdint.h>
20+
#include <modm/architecture/interface/assert.h>
21+
/* need for static_assert at C compilation */
2022
#include <assert.h>
21-
2223
#define TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX 0
2324

2425
#ifdef __cplusplus
2526
extern "C" {
2627
#endif
28+
/* override expensive assert implementation */
2729
#undef assert
28-
#define assert(X) do { } while(false)
30+
#define assert(X) modm_assert((X), "pico", __FILE__ ":" MODM_STRINGIFY(__LINE__) " -> \"" #X "\"")
2931
void panic(const char *fmt, ...);
3032

3133
#ifdef __cplusplus

src/modm/board/rp_pico/board.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<options>
99
<option name="modm:target">rp2040</option>
10-
<option name="modm:cmsis:device:boot2">w25q080</option>
10+
<option name="modm:platform:core:boot2">w25q080</option>
1111
</options>
1212
<modules>
1313
<module>modm:board:rp-pico</module>

src/modm/platform/core/rp/module.lb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ def prepare(module, options):
2424

2525
module.depends(":platform:cortex-m")
2626
module.depends(":platform:clockgen")
27-
27+
module.add_option(
28+
EnumerationOption(
29+
name="boot2",
30+
description="Boot2 variant",
31+
enumeration=['generic_03h','at25sf128a','is25lp080','w25q080','w25x10cl'],
32+
default='generic_03h'))
2833
return True
2934

3035

@@ -60,6 +65,9 @@ def build(env):
6065
env.copy('multicore.hpp')
6166
env.copy('multicore.cpp')
6267

68+
flash_variant = env.get("boot2")
69+
env.copy(repopath("ext/rp/pico-sdk/src/boot2_" + flash_variant + '.cpp'),'src/boot2.cpp')
70+
6371

6472
def post_build(env):
6573
env.substitutions = env.query("::cortex-m:linkerscript")

src/modm/platform/usb/rp/module.lb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ def prepare(module, options):
2727
module.depends(
2828
":architecture:interrupt",
2929
":cmsis:device",
30-
":platform:gpio",
31-
":platform:core")
30+
":platform:gpio")
3231

3332
return True
3433

0 commit comments

Comments
 (0)