예제 #1
0
/***********************************************************************************
* @fn           usbUartInit
*
* @brief        USB UART init function.
*               - Set initial line decoding to 8/NONE/1.
*               - Initialise the USB Firmware Library and the USB controller.
*
* @param        none
*
* @return       none
*/
void usbUartInit(uint32 baudrate)
{
    // Set default line coding.
    currentLineCoding.dteRate = baudrate;
    currentLineCoding.charFormat = CDC_CHAR_FORMAT_1_STOP_BIT;
    currentLineCoding.parityType = CDC_PARITY_TYPE_NONE;
    currentLineCoding.dataBits = 8;

    // Initialise hardware flow control
    cdcRTS= 0;      // TRUE when DCE connected
    cdcCTS= 1;      // Indicate CTS to DCE (here handled internally as CDC does
                    // not directly support CTC).

    // Init USB library
    usbfwInit();

    // Initialize the USB interrupt handler with bit mask containing all processed USBIRQ events
    usbirqInit(0xFFFF);

    // Enable pullup on D+
    HAL_USB_PULLUP_ENABLE();

    // Enable global interrupts
    halIntOn();
}
예제 #2
0
/** \brief Initializes the \ref module_usb_firmware_library_config module
 *
 * This function should be called first.
 */
void usbHidInit(void)
{
    //
    // Initialize the USB library
    //
    usbfwInit();

    //
    // Initialize the USB interrupt handler with bit mask containing all processed USBIRQ events
    //
    usbirqInit(USBIRQ_EVENT_RESET | USBIRQ_EVENT_SETUP | USBIRQ_EVENT_SUSPEND | USBIRQ_EVENT_RESUME);

    //
    // Activate the USB D+ pull-up resistor
    //
    UsbDplusPullUpEnable();

}
예제 #3
0
/***********************************************************************************
* @fn           usbUartInitUSB
*
* @brief        USB UART init function.
*               - Set initial line decoding to 8/NONE/1.
*               - Initialise the USB Firmware Library and the USB controller.
*
* @param        none
*
* @return       none
*/
void HalUARTInitUSB(void)
{
  // Set default line coding.
  currentLineCoding.dteRate = HAL_UART_BAUD_RATE;
  currentLineCoding.charFormat = CDC_CHAR_FORMAT_1_STOP_BIT;
  currentLineCoding.parityType = CDC_PARITY_TYPE_NONE;
  currentLineCoding.dataBits = 8;

  // Init USB library
  usbfwInit();

  // Initialize the USB interrupt handler with bit mask containing all processed USBIRQ events
  usbirqInit(0xFFFF);

#if defined HAL_SB_BOOT_CODE
  HAL_USB_PULLUP_ENABLE();  // Enable pullup on D+.
#endif
}
예제 #4
0
/******************************************************************************
 * @fn      HalUARTOpenUSB()
 *
 * @brief   Open a port according tp the configuration specified by parameter.
 *
 * @param   config - contains configuration information
 *
 * @return  none
 *****************************************************************************/
void HalUARTOpenUSB(halUARTCfg_t *config)
{
  /* Set default line coding. */
  usbCdcData.lineCoding.dteRate =  USBBRRTable[config->baudRate];
  usbCdcData.lineCoding.charFormat = USBCDC_CHAR_FORMAT_1_STOP_BIT;
  usbCdcData.lineCoding.parityType = USBCDC_PARITY_TYPE_NONE;
  usbCdcData.lineCoding.dataBits = 8;

  /* Init USB library */
  usbfwInit();

  /* Initialize the USB interrupt handler with bit 
   * mask containing all processed USBIRQ events
   */
  usbirqInit(0xFFFF);
  usbCB = config->callBackFunc;
  
  /* Enable pullup on D+ */
  UsbDplusPullUpEnable();  
}