本文整理汇总了C++中USBDevice_SAMD21G18x::calibrate方法的典型用法代码示例。如果您正苦于以下问题:C++ USBDevice_SAMD21G18x::calibrate方法的具体用法?C++ USBDevice_SAMD21G18x::calibrate怎么用?C++ USBDevice_SAMD21G18x::calibrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USBDevice_SAMD21G18x
的用法示例。
在下文中一共展示了USBDevice_SAMD21G18x::calibrate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void USBDeviceClass::init()
{
#ifdef PIN_LED_TXL
txLEDPulse = 0;
pinMode(PIN_LED_TXL, OUTPUT);
digitalWrite(PIN_LED_TXL, HIGH);
#endif
#ifdef PIN_LED_RXL
rxLEDPulse = 0;
pinMode(PIN_LED_RXL, OUTPUT);
digitalWrite(PIN_LED_RXL, HIGH);
#endif
// Enable USB clock
PM->APBBMASK.reg |= PM_APBBMASK_USB;
// Set up the USB DP/DN pins
PORT->Group[0].PINCFG[PIN_PA24G_USB_DM].bit.PMUXEN = 1;
PORT->Group[0].PMUX[PIN_PA24G_USB_DM/2].reg &= ~(0xF << (4 * (PIN_PA24G_USB_DM & 0x01u)));
PORT->Group[0].PMUX[PIN_PA24G_USB_DM/2].reg |= MUX_PA24G_USB_DM << (4 * (PIN_PA24G_USB_DM & 0x01u));
PORT->Group[0].PINCFG[PIN_PA25G_USB_DP].bit.PMUXEN = 1;
PORT->Group[0].PMUX[PIN_PA25G_USB_DP/2].reg &= ~(0xF << (4 * (PIN_PA25G_USB_DP & 0x01u)));
PORT->Group[0].PMUX[PIN_PA25G_USB_DP/2].reg |= MUX_PA25G_USB_DP << (4 * (PIN_PA25G_USB_DP & 0x01u));
// Put Generic Clock Generator 0 as source for Generic Clock Multiplexer 6 (USB reference)
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(6) | // Generic Clock Multiplexer 6
GCLK_CLKCTRL_GEN_GCLK0 | // Generic Clock Generator 0 is source
GCLK_CLKCTRL_CLKEN;
while (GCLK->STATUS.bit.SYNCBUSY)
;
USB_SetHandler(&UDD_Handler);
// Reset USB Device
usbd.reset();
usbd.calibrate();
usbd.setUSBDeviceMode();
usbd.runInStandby();
usbd.setFullSpeed();
// Configure interrupts
NVIC_SetPriority((IRQn_Type) USB_IRQn, 0UL);
NVIC_EnableIRQ((IRQn_Type) USB_IRQn);
usbd.enable();
initialized = true;
}