@@ -10,7 +10,6 @@ use nrf52840_hal::gpio::{p0, p1, Level};
10
10
use nrf52840_hal:: prelude:: * ;
11
11
use nrf52840_hal:: timer:: { OneShot , Timer } ;
12
12
use nrf52840_hal:: usbd:: Usbd ;
13
- use nrf52840_hal:: clocks:: Clocks ;
14
13
use nrf52840_pac:: { interrupt, Peripherals , TIMER0 } ;
15
14
use usb_device:: device:: { UsbDeviceBuilder , UsbDeviceState , UsbVidPid } ;
16
15
use usbd_serial:: { SerialPort , USB_CLASS_CDC } ;
@@ -22,7 +21,7 @@ fn TIMER0() {
22
21
23
22
#[ entry]
24
23
fn main ( ) -> ! {
25
- static mut EP_BUF : [ u8 ; 512 ] = [ 0 ; 512 ] ;
24
+ static mut EP_BUF : [ u8 ; 256 ] = [ 0 ; 256 ] ;
26
25
27
26
let core = cortex_m:: Peripherals :: take ( ) . unwrap ( ) ;
28
27
let periph = Peripherals :: take ( ) . unwrap ( ) ;
@@ -34,18 +33,6 @@ fn main() -> ! {
34
33
. is_vbus_present ( )
35
34
{ }
36
35
37
- // wait until USB 3.3V supply is stable
38
- while !periph
39
- . POWER
40
- . events_usbpwrrdy
41
- . read ( )
42
- . events_usbpwrrdy ( )
43
- . bit_is_clear ( )
44
- { }
45
-
46
- let clocks = Clocks :: new ( periph. CLOCK ) ;
47
- let clocks = clocks. enable_ext_hfosc ( ) ;
48
-
49
36
let mut nvic = core. NVIC ;
50
37
let mut timer = Timer :: one_shot ( periph. TIMER0 ) ;
51
38
let usbd = periph. USBD ;
@@ -61,13 +48,12 @@ fn main() -> ! {
61
48
62
49
led. set_low ( ) . unwrap ( ) ;
63
50
64
- let usb_bus = Usbd :: new_alloc ( usbd, EP_BUF , & clocks ) ;
51
+ let usb_bus = Usbd :: new_alloc ( usbd, EP_BUF ) ;
65
52
let mut serial = SerialPort :: new ( & usb_bus) ;
66
53
67
54
let mut usb_dev = UsbDeviceBuilder :: new ( & usb_bus, UsbVidPid ( 0x16c0 , 0x27dd ) )
68
55
. product ( "nRF52840 Serial Port Demo" )
69
56
. device_class ( USB_CLASS_CDC )
70
- . max_packet_size_0 ( 64 ) // (makes control transfers 8x faster)
71
57
. build ( ) ;
72
58
73
59
hprintln ! ( "<start>" ) . ok ( ) ;
0 commit comments