56#include "nrfx_power.h"
59extern void tusb_hal_nrf_power_event(uint32_t event);
61#define SERIAL_NUMBER_STRING_SIZE 12
63static char serial[SERIAL_NUMBER_STRING_SIZE + 1];
72power_event_handler(nrfx_power_usb_evt_t event)
74 tusb_hal_nrf_power_event((uint32_t)event);
80 const uint16_t serial_num_high_bytes = nrf_ficr_deviceid_get(NRF_FICR, 1) | 0xC000;
81 const uint32_t serial_num_low_bytes = nrf_ficr_deviceid_get(NRF_FICR, 0);
82 const nrfx_power_config_t power_config = { 0 };
83 const nrfx_power_usbevt_config_t power_usbevt_config = {
84 .handler = power_event_handler
87 nrfx_power_init(&power_config);
89 nrfx_power_usbevt_init(&power_usbevt_config);
91 nrfx_power_usbevt_enable();
95 SERIAL_NUMBER_STRING_SIZE + 1,
96 "%04"PRIX16
"%08"PRIX32,
97 serial_num_high_bytes,
98 serial_num_low_bytes);
102 nrfx_power_usb_state_t usb_reg = nrfx_power_usbstatus_get();
103 if(usb_reg == NRFX_POWER_USB_STATE_CONNECTED) {
104 tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED);
105 }
else if(usb_reg == NRFX_POWER_USB_STATE_READY) {
106 tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
void usb_interrupt_handler(void)
Handles the interrupt.
void usb_descriptor_set_serial(char *serial)
Set the serial.
void usb_arch_init(void)
Initialize the architecture specific USB driver.
USB descriptors header file for the nRF.