Skip to content

Commit 8a48555

Browse files
committed
fix warnings with cast function type for nrf
1 parent 5941324 commit 8a48555

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/arduino/ports/Adafruit_TinyUSB_nrf.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838

3939
#define USBD_STACK_SZ (200)
4040

41-
// tinyusb function that handles power event (detected, ready, removed)
42-
// We must call it within SD's SOC event handler, or set it as power event
43-
// handler if SD is not enabled.
44-
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
45-
4641
//--------------------------------------------------------------------+
4742
// Forward USB interrupt events to TinyUSB IRQ Handler
4843
//--------------------------------------------------------------------+
@@ -105,6 +100,16 @@ uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16]) {
105100
// Helper
106101
//--------------------------------------------------------------------+
107102

103+
// tinyusb function that handles power event (detected, ready, removed)
104+
// We must call it within SD's SOC event handler, or set it as power event
105+
// handler if SD is not enabled.
106+
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
107+
108+
static void power_event_handler(nrfx_power_usb_evt_t event)
109+
{
110+
tusb_hal_nrf_power_event((uint32_t) event);
111+
}
112+
108113
// Init usb hardware when starting up. Softdevice is not enabled yet
109114
static void usb_hardware_init(void) {
110115
// Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice
@@ -120,10 +125,9 @@ static void usb_hardware_init(void) {
120125
nrfx_power_init(&pwr_cfg);
121126

122127
// Register tusb function as USB power handler
123-
const nrfx_power_usbevt_config_t config = {
124-
.handler = (nrfx_power_usb_event_handler_t)tusb_hal_nrf_power_event};
125-
nrfx_power_usbevt_init(&config);
128+
const nrfx_power_usbevt_config_t config = { .handler = power_event_handler};
126129

130+
nrfx_power_usbevt_init(&config);
127131
nrfx_power_usbevt_enable();
128132

129133
if (usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk) {

0 commit comments

Comments
 (0)