wip: onboard pid
This commit is contained in:
7
src/usb/CMakeLists.txt
Normal file
7
src/usb/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
target_include_directories(app PRIVATE ./)
|
||||
|
||||
target_sources(app PRIVATE
|
||||
usb_cdc_acm.cpp
|
||||
)
|
||||
38
src/usb/usb_cdc_acm.cpp
Normal file
38
src/usb/usb_cdc_acm.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <zephyr/usb/usbd.h>
|
||||
|
||||
#include "usb_cdc_acm.hpp"
|
||||
|
||||
USBD_DEVICE_DEFINE(usb0, DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)), 0x2fe3, 0xffff);
|
||||
USBD_DESC_LANG_DEFINE(usb0_lang);
|
||||
USBD_DESC_MANUFACTURER_DEFINE(usb0_mfr, "Ohmman & Co. KG");
|
||||
USBD_DESC_PRODUCT_DEFINE(usb0_prod, "Microros Servo Node");
|
||||
|
||||
USBD_DESC_CONFIG_DEFINE(fs_cfg_desc, "FS Configuration");
|
||||
USBD_CONFIGURATION_DEFINE(usb0_conf, USB_SCD_SELF_POWERED, 100, &fs_cfg_desc);
|
||||
|
||||
static const char *const usb0_blocklist[] = {
|
||||
"dfu_dfu",
|
||||
NULL,
|
||||
};
|
||||
|
||||
void usb_init(void) {
|
||||
usbd_add_descriptor(&usb0, &usb0_lang);
|
||||
usbd_add_descriptor(&usb0, &usb0_mfr);
|
||||
usbd_add_descriptor(&usb0, &usb0_prod);
|
||||
//usbd_add_descriptor(&usb0, &usb0_sn);
|
||||
|
||||
if (usbd_add_configuration(&usb0, USBD_SPEED_FS, &usb0_conf)) {
|
||||
printk("Failed to add Full-Speed configuration\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbd_register_all_classes(&usb0, USBD_SPEED_FS, 1, usb0_blocklist)) {
|
||||
printk("Failed to register usb classes\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
usbd_device_set_code_triple(&usb0, USBD_SPEED_FS, USB_BCC_APPLICATION, 0x02, 0x01);
|
||||
|
||||
usbd_init(&usb0);
|
||||
usbd_enable(&usb0);
|
||||
}
|
||||
3
src/usb/usb_cdc_acm.hpp
Normal file
3
src/usb/usb_cdc_acm.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void usb_init(void);
|
||||
Reference in New Issue
Block a user