Skip to content

Commit 0811a47

Browse files
committed
fix -Wcast-function-type warnings
1 parent 6c0bb9d commit 0811a47

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ CFLAGS += \
261261
-mcpu=cortex-m4 \
262262
-mfloat-abi=hard \
263263
-mfpu=fpv4-sp-d16 \
264+
-ggdb \
264265
-Os \
265266
-ffunction-sections \
266267
-fdata-sections \
@@ -280,8 +281,7 @@ CFLAGS += \
280281
-Wsign-compare \
281282
-Wmissing-format-attribute \
282283
-Wno-endif-labels \
283-
-Wunreachable-code \
284-
-ggdb
284+
-Wunreachable-code
285285

286286
# Suppress warning caused by SDK
287287
CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined

src/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
void usb_init(bool cdc_only);
7777
void usb_teardown(void);
7878

79+
// tinyusb function that handles power event (detected, ready, removed)
80+
// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
81+
extern void tusb_hal_nrf_power_event(uint32_t event);
82+
7983
#else
8084

8185
#define usb_init(x) led_state(STATE_USB_MOUNTED) // mark nrf52832 as mounted
@@ -474,13 +478,12 @@ uint32_t proc_soc(void)
474478
pstorage_sys_event_handler(soc_evt);
475479

476480
#ifdef NRF_USBD
477-
extern void tusb_hal_nrf_power_event(uint32_t event);
478481
/*------------- usb power event handler -------------*/
479482
int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED:
480483
(soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY :
481484
(soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1;
482485

483-
if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt);
486+
if ( usbevt >= 0) tusb_hal_nrf_power_event((uint32_t) usbevt);
484487
#endif
485488
}
486489

src/usb/usb.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@
4242
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
4343
extern void tusb_hal_nrf_power_event(uint32_t event);
4444

45-
//--------------------------------------------------------------------+
45+
// power callback when SD is not enabled
46+
static void power_event_handler(nrfx_power_usb_evt_t event)
47+
{
48+
tusb_hal_nrf_power_event((uint32_t) event);
49+
}
50+
4651
// Forward USB interrupt events to TinyUSB IRQ Handler
47-
//--------------------------------------------------------------------+
4852
void USBD_IRQHandler(void)
4953
{
5054
tud_int_handler(0);
@@ -80,8 +84,8 @@ void usb_init(bool cdc_only)
8084
const nrfx_power_config_t pwr_cfg = { 0 };
8185
nrfx_power_init(&pwr_cfg);
8286

83-
// Register tusb function as USB power handler
84-
const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event };
87+
// Register USB power handler
88+
const nrfx_power_usbevt_config_t config = { .handler = power_event_handler };
8589
nrfx_power_usbevt_init(&config);
8690

8791
nrfx_power_usbevt_enable();

0 commit comments

Comments
 (0)