Skip to content

Commit 0117260

Browse files
raiden00plxiaoxiang781216
authored andcommitted
arch/nrf53: add USBD support
USB device role is now supported for NRF53
1 parent 0455167 commit 0117260

File tree

7 files changed

+3726
-3
lines changed

7 files changed

+3726
-3
lines changed

arch/arm/src/nrf53/Kconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ config NRF53_APPCORE
2323
select ARM_HAVE_DSP
2424
select ARCH_HAVE_FPU
2525
select NRF53_HAVE_PWM
26-
select NRF52_HAVE_GPIOTE1
26+
select NRF53_HAVE_GPIOTE1
2727
select NRF53_HAVE_SAADC
2828
select NRF53_HAVE_UART1
2929
select NRF53_HAVE_I2C123
@@ -252,6 +252,12 @@ config NRF53_RTC1
252252
select NRF53_RTC
253253
default n
254254

255+
config NRF53_USBDEV
256+
bool "USB Device"
257+
default n
258+
depends on NRF53_HFCLK_XTAL
259+
select USBDEV
260+
255261
endmenu # NRF53 Peripheral Selection
256262

257263
menu "Clock Configuration"
@@ -613,7 +619,7 @@ config NRF53_SDC_PERIPHERAL_COUNT
613619

614620
CENTRAL_ROLES = CONFIG_BLUETOOTH_MAX_CONN - NRF53_SDC_PERIPHERAL_COUNT
615621
or
616-
CENTRAL_ROLES = NRF52_SDC_MAX_COUNT - NRF52_SDC_PERIPHERAL_COUNT
622+
CENTRAL_ROLES = NRF53_SDC_MAX_COUNT - NRF53_SDC_PERIPHERAL_COUNT
617623

618624
So by choosing these two variables you can control both capabilities.
619625

arch/arm/src/nrf53/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ ifeq ($(CONFIG_NRF53_I2C_MASTER),y)
9191
CHIP_CSRCS += nrf53_i2c.c
9292
endif
9393

94+
ifeq ($(CONFIG_USBDEV),y)
95+
CHIP_CSRCS += nrf53_usbd.c
96+
endif
97+
9498
ifeq ($(CONFIG_NRF53_SOFTDEVICE_CONTROLLER),y)
9599

96100
NRFXLIB_UNPACK := sdk-nrfxlib

arch/arm/src/nrf53/hardware/nrf53_memorymap_cpuapp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
#define NRF53_MUTEX_BASE 0x50030000
102102
#define NRF53_QDEC_BASE 0x50033000
103103
#define NRF53_USBD_BASE 0x50036000
104-
#define NRF53_USBREGULATOR_BASE 0x50037000
104+
#define NRF53_USBREG_BASE 0x50037000
105105
#define NRF53_KMU_BASE 0x50039000
106106
#define NRF53_NVMC_BASE 0x50039000
107107
#define NRF53_GPIO_P0_BASE 0x50842500

arch/arm/src/nrf53/hardware/nrf53_usbd.h

Lines changed: 394 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/****************************************************************************
2+
* arch/arm/src/nrf53/hardware/nrf53_usbreg.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
#ifndef __ARCH_ARM_SRC_NRF53_HARDWARE_NRF53_USBREG_H
22+
#define __ARCH_ARM_SRC_NRF53_HARDWARE_NRF53_USBREG_H
23+
24+
/****************************************************************************
25+
* Included Files
26+
****************************************************************************/
27+
28+
#include <nuttx/config.h>
29+
#include "nrf53_memorymap.h"
30+
31+
/****************************************************************************
32+
* Pre-processor Definitions
33+
****************************************************************************/
34+
35+
/* Register offsets *********************************************************/
36+
37+
#define NRF53_USBREG_EVENTS_USBDETECTED_OFFSET 0x000100 /* Voltage supply detected on VBUS */
38+
#define NRF53_USBREG_EVENTS_USBREMOVED_OFFSET 0x000104 /* Voltage supply removed from VBUS*/
39+
#define NRF53_USBREG_EVENTS_USBPWRRDY_OFFSET 0x000108 /* USB 3.3 V supply ready */
40+
#define NRF53_USBREG_INTEN_OFFSET 0x000300 /* Enable or disable interrrupt */
41+
#define NRF53_USBREG_INTENSET_OFFSET 0x000304 /* Enable interrrupt */
42+
#define NRF53_USBREG_INTENCLR_OFFSET 0x000308 /* Disable interrrupt */
43+
#define NRF53_USBREG_USBREGSTATUS_OFFSET 0x000400 /* USB supply status */
44+
45+
/* Register definitions *****************************************************/
46+
47+
#define NRF53_USBREG_EVENTS_USBDETECTED (NRF53_USBREG_BASE + NRF53_USBREG_EVENTS_USBDETECTED_OFFSET)
48+
#define NRF53_USBREG_EVENTS_USBREMOVED (NRF53_USBREG_BASE + NRF53_USBREG_EVENTS_USBREMOVED_OFFSET)
49+
#define NRF53_USBREG_EVENTS_USBPWRRDY (NRF53_USBREG_BASE + NRF53_USBREG_EVENTS_USBPWRRDY_OFFSET)
50+
#define NRF53_USBREG_INTEN (NRF53_USBREG_BASE + NRF53_USBREG_INTEN_OFFSET)
51+
#define NRF53_USBREG_INTENSET (NRF53_USBREG_BASE + NRF53_USBREG_INTENSET_OFFSET)
52+
#define NRF53_USBREG_INTENCLR (NRF53_USBREG_BASE + NRF53_USBREG_INTENCLR_OFFSET)
53+
#define NRF53_USBREG_USBREGSTATUS (NRF53_USBREG_BASE + NRF53_USBREG_USBREGSTATUS_OFFSET)
54+
55+
/* Register bit definitions *************************************************/
56+
57+
/* USBREGSTATUS */
58+
59+
#define USBREG_USBREGSTATUS_VBUSDETECT (1 << 0) /* Vbus Present */
60+
#define USBREG_USBREGSTATUS_OUTPUTRDY (1 << 1) /* Ready */
61+
62+
#endif /* __ARCH_ARM_SRC_NRF53_HARDWARE_NRF53_USBREG_H */

0 commit comments

Comments
 (0)