File tree 2 files changed +9
-51
lines changed 2 files changed +9
-51
lines changed Original file line number Diff line number Diff line change 1
1
sample :
2
- name : MTP USB
2
+ name : USB MTP device class sample
3
3
tests :
4
- sample.usb.mtp :
5
- depends_on : usb_device
6
- tags : usb
7
- arch_exclude : posix
8
- harness : console
9
- harness_config :
10
- type : one_line
11
- regex :
12
- - " Wait for DTR"
13
4
sample.usb_device_next.mtp :
14
5
depends_on : usbd
15
6
tags : usb
16
- extra_args : CONF_FILE="usbd_next_prj.conf"
17
- integration_platforms :
18
- - nrf52840dk/nrf52840
19
- - nrf54h20dk/nrf54h20/cpuapp
20
- - frdm_k64f
21
- - stm32f723e_disco
22
- - nucleo_f413zh
23
- - mimxrt685_evk/mimxrt685s/cm33
24
- - mimxrt1060_evk
25
7
harness : console
26
8
harness_config :
27
9
type : one_line
28
10
regex :
29
- - " Wait for DTR"
30
- sample.usb.mtp.buildonly :
31
- depends_on : usb_device
32
- tags : usb
33
- arch_allow : posix
34
- build_only : true
35
- integration_platforms :
36
- - native_sim
11
+ - " USB device support enabled"
Original file line number Diff line number Diff line change 21
21
#include <zephyr/logging/log.h>
22
22
LOG_MODULE_REGISTER (usb_mtp_sample , LOG_LEVEL_INF );
23
23
24
- static struct usbd_context * sample_usbd ;
25
-
26
24
static void sample_msg_cb (struct usbd_context * const ctx , const struct usbd_msg * msg )
27
25
{
28
26
LOG_INF ("USBD message: %s" , usbd_msg_type_string (msg -> type ));
@@ -42,36 +40,21 @@ static void sample_msg_cb(struct usbd_context *const ctx, const struct usbd_msg
42
40
}
43
41
}
44
42
45
- static int enable_usb_device_next (void )
43
+ int main (void )
46
44
{
47
- int err ;
45
+ struct usbd_context * sample_usbd ;
48
46
49
47
sample_usbd = sample_usbd_init_device (sample_msg_cb );
50
48
if (sample_usbd == NULL ) {
51
49
LOG_ERR ("Failed to initialize USB device" );
52
- return - ENODEV ;
50
+ return -1 ;
53
51
}
54
52
55
- if (!usbd_can_detect_vbus (sample_usbd )) {
56
- err = usbd_enable (sample_usbd );
57
- if (err ) {
58
- LOG_ERR ("Failed to enable device support" );
59
- return err ;
60
- }
53
+ if (usbd_enable (sample_usbd )) {
54
+ LOG_ERR ("Failed to enable device support" );
55
+ return -1 ;
61
56
}
62
57
63
- LOG_INF ("USB device support enabled" );
64
-
65
- return 0 ;
66
- }
67
-
68
- int main (void )
69
- {
70
- int ret ;
71
- #if defined(CONFIG_USB_DEVICE_STACK_NEXT )
72
- ret = enable_usb_device_next ();
73
- #else
74
- #error "Only Device next is supported"
75
- #endif
58
+ LOG_INF ("USB device support enabled\n" );
76
59
return 0 ;
77
60
}
You can’t perform that action at this time.
0 commit comments