Skip to content

Commit b8fa96a

Browse files
fix: CI build failures on non-RP2040 platforms
- Use UINT32_C(1) instead of 1u for bit shifts >= 16 in midi2_device.c to avoid shift-count-overflow on 16-bit platforms (MSP430) - Add Makefiles for midi2_device and midi2_host examples with family guard (skip if FAMILY != rp2040). These examples require Pico SDK and board-specific hardware - Restrict midi2_device CMakeLists.txt to rp2040 family (matching midi2_host)
1 parent 9f1001e commit b8fa96a

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

examples/device/midi2_device/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ project(midi2_device C CXX ASM)
77
# Checks this example is valid for the family and initializes the project
88
family_initialize_project(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR})
99

10-
# Espressif has its own cmake build system
11-
if(FAMILY STREQUAL "espressif")
10+
# This example requires RP2040/RP2350 (USB descriptors and config are board-specific)
11+
if(NOT FAMILY STREQUAL "rp2040")
1212
return()
1313
endif()
1414

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This example requires RP2040/RP2350 (USB descriptors and config are board-specific)
2+
ifeq (,$(findstring rp2040,$(FAMILY)))
3+
$(info Skipping midi2_device: requires FAMILY=rp2040)
4+
all:
5+
@:
6+
.DEFAULT:
7+
@:
8+
else
9+
10+
include ../../../hw/bsp/family_support.mk
11+
12+
INC += \
13+
src \
14+
15+
# Example source
16+
EXAMPLE_SOURCE += \
17+
src/main.c \
18+
src/usb_descriptors.c \
19+
20+
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
21+
22+
# Suppress pre-existing warning in usbd.c
23+
CFLAGS_GCC += -Wno-type-limits
24+
25+
include ../../../hw/bsp/family_rules.mk
26+
27+
endif

examples/host/midi2_host/Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This example requires RP2040/RP2350 (PIO-USB, Pico SDK I2C, SSD1306 display)
2+
ifeq (,$(findstring rp2040,$(FAMILY)))
3+
$(info Skipping midi2_host: requires FAMILY=rp2040)
4+
all:
5+
@:
6+
.DEFAULT:
7+
@:
8+
else
9+
10+
include ../../../hw/bsp/family_support.mk
11+
12+
INC += \
13+
src \
14+
15+
# Example source
16+
EXAMPLE_SOURCE += \
17+
src/main.c \
18+
src/display.c \
19+
20+
SRC_C += $(addprefix $(EXAMPLE_PATH)/, $(EXAMPLE_SOURCE))
21+
22+
# Suppress pre-existing warning
23+
CFLAGS_GCC += -Wno-type-limits
24+
25+
include ../../../hw/bsp/family_rules.mk
26+
27+
endif

src/class/midi/midi2_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ static void _nego_send_endpoint_info(midi2d_interface_t* p_midi) {
158158
| ((uint32_t) STREAM_ENDPOINT_INFO << 16)
159159
| ((uint32_t) UMP_VER_MAJOR << 8)
160160
| (uint32_t) UMP_VER_MINOR;
161-
msg[1] = (1u << 31) // Static Function Blocks flag
161+
msg[1] = (UINT32_C(1) << 31) // Static Function Blocks flag
162162
| ((uint32_t)(CFG_TUD_MIDI2_NUM_FUNCTION_BLOCKS & 0x7F) << 24)
163-
| (1u << 9) // MIDI 2.0 Protocol capability
164-
| (1u << 8); // MIDI 1.0 Protocol capability
163+
| (UINT32_C(1) << 9) // MIDI 2.0 Protocol capability
164+
| (UINT32_C(1) << 8); // MIDI 1.0 Protocol capability
165165
_nego_send_ump(p_midi, msg, 4);
166166
}
167167

@@ -214,7 +214,7 @@ static void _nego_send_fb_info(midi2d_interface_t* p_midi, uint8_t fb_idx) {
214214
uint32_t msg[4] = {0};
215215
msg[0] = ((uint32_t) MT_STREAM << 28)
216216
| ((uint32_t) STREAM_FB_INFO << 16)
217-
| (1u << 15)
217+
| (UINT32_C(1) << 15)
218218
| ((uint32_t) fb_idx << 8)
219219
| 0x02; // bDirection: bidirectional
220220
msg[1] = ((uint32_t) 0 << 24) // bFirstGroup

0 commit comments

Comments
 (0)