Skip to content

Commit

Permalink
fix -Wcast-function-type warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jul 12, 2022
1 parent 6c0bb9d commit 0811a47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ CFLAGS += \
-mcpu=cortex-m4 \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
-ggdb \
-Os \
-ffunction-sections \
-fdata-sections \
Expand All @@ -280,8 +281,7 @@ CFLAGS += \
-Wsign-compare \
-Wmissing-format-attribute \
-Wno-endif-labels \
-Wunreachable-code \
-ggdb
-Wunreachable-code

# Suppress warning caused by SDK
CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
Expand Down
7 changes: 5 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
void usb_init(bool cdc_only);
void usb_teardown(void);

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

#else

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

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

if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt);
if ( usbevt >= 0) tusb_hal_nrf_power_event((uint32_t) usbevt);
#endif
}

Expand Down
12 changes: 8 additions & 4 deletions src/usb/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
extern void tusb_hal_nrf_power_event(uint32_t event);

//--------------------------------------------------------------------+
// power callback when SD is not enabled
static void power_event_handler(nrfx_power_usb_evt_t event)
{
tusb_hal_nrf_power_event((uint32_t) event);
}

// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void USBD_IRQHandler(void)
{
tud_int_handler(0);
Expand Down Expand Up @@ -80,8 +84,8 @@ void usb_init(bool cdc_only)
const nrfx_power_config_t pwr_cfg = { 0 };
nrfx_power_init(&pwr_cfg);

// Register tusb function as USB power handler
const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event };
// Register USB power handler
const nrfx_power_usbevt_config_t config = { .handler = power_event_handler };
nrfx_power_usbevt_init(&config);

nrfx_power_usbevt_enable();
Expand Down

0 comments on commit 0811a47

Please sign in to comment.