/**
 * Initializes the HID Transfer %device driver.
 * \param pDescriptors Pointer to USBDDriverDescriptors instance.
 */
void HIDDTransferDriver_Initialize(const USBDDriverDescriptors * pDescriptors)
{
    HIDDTransferDriver * pDrv = &hiddTransferDriver;
    USBDDriver *pUsbd = USBD_GetDriver();

    /* One input report */
    pDrv->inputReports[0] = (HIDDReport*)&inputReport;
    HIDDFunction_InitializeReport((HIDDReport *)pDrv->inputReports[0],
                                  HIDDTransferDriver_REPORTSIZE,
                                  0,
                                  0, 0);
    /* One output report */
    pDrv->outputReports[0] = (HIDDReport*)&outputReport;
    HIDDFunction_InitializeReport((HIDDReport *)pDrv->outputReports[0],
                                  HIDDTransferDriver_REPORTSIZE,
                                  0,
                                  0, 0);

    /* Initialize USBD Driver instance */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          0); /* Multiple interface settings not supported */
    /* Function instance initialize */
    HIDDFunction_Initialize(&pDrv->hidFunction,
                            pUsbd, 0,
                            hiddTransferReportDescriptor,
                            (HIDDReport **)(&pDrv->inputReports), 1,
                            (HIDDReport **)(&pDrv->outputReports), 1);
    /* Initialize USBD */
    USBD_Init();
}
Beispiel #2
0
//-----------------------------------------------------------------------------
/// Initializes the USB device CDCMSD device driver.
//-----------------------------------------------------------------------------
void CDCMSDDDriver_Initialize(MSDLun *pLuns, unsigned char numLuns)
{
    // CDC
    CDCDFunctionDriver_ConfigurePort(&cdcdPort,
                                     CDCD_Descriptors_INTERFACENUM0,
                                     CDCD_Descriptors_NOTIFICATION0,
                                     CDCD_Descriptors_DATAIN0,
                                     CDCD_Descriptors_DATAOUT0);
    CDCDFunctionDriver_Initialize(&usbdDriver,
                                  &cdcdPort,
                                  1);

    // MSD
    MSDDFunctionDriver_Initialize(&usbdDriver,
                                  pLuns, numLuns,
                                  MSDD_Descriptors_INTERFACENUM,
                                  MSDD_Descriptors_BULKIN,
                                  MSDD_Descriptors_BULKOUT);

    // Initialize the standard USB driver
    USBDDriver_Initialize(&usbdDriver,
                          &cdcmsddDriverDescriptors,
                          cdcmsddDriverInterfaces);

    // Initialize the USB driver
    USBD_Init();
}
Beispiel #3
0
/**
 *  Initializes the system, connects the USB and waits indefinitely.
 *
 * \callgraph
 */
int main(void)
{
    /* Disable watchdog */
    WDT_Disable( WDT );

    /* Output example information */
    printf( "-- USB Device Core Project %s --\n\r", SOFTPACK_VERSION ) ;
    printf( "-- %s\n\r", BOARD_NAME ) ;
    printf( "-- Compiled: %s %s --\n\r", __DATE__, __TIME__ ) ;

    /* If they are present, configure Vbus & Wake-up pins */
    PIO_InitializeInterrupts(0) ;

    /* Enable UPLL for USB */
    _ConfigureUsbClock();

    /* USB initialization, Disable Pull-up */
    TRACE_INFO("USB initialization\n\r");
    USBDDriver_Initialize(&usbdDriver, &usbdDriverDescriptors, 0);
    USBD_Init();

    /* Wait about 10ms so that host detach the device to re-enumerate
       Device connection */
    TRACE_INFO("Connecting device\n\r");

    /* connect if needed */
    VBus_Configure();
    while (USBD_GetState() < USBD_STATE_CONFIGURED);

    // Infinite loop
    while (1) {
    }
}
/**
 * Initializes the USB device composite device driver.
 * \param  pDescriptors Pointer to Descriptors list for CDC Serial Device.
 */
void DUALCDCDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
    USBDDriver *pUsbd = USBD_GetDriver();
    CDCDSerialPort *pCdcd = &dualcdcdDriver.cdcdSerialPort[0];

    TRACE_INFO("DUALCDCDDriver_Initialize\n\r");

    pCdcd = &dualcdcdDriver.cdcdSerialPort[0];
    CDCDSerialPort_Initialize(pCdcd, pUsbd,
                              0,
                              0,
                              DUALCDCDDriverDescriptors_INTERFACENUM0, 2);

    pCdcd = &dualcdcdDriver.cdcdSerialPort[1];
    CDCDSerialPort_Initialize(pCdcd, pUsbd,
                              0,
                              0,
                              DUALCDCDDriverDescriptors_INTERFACENUM1, 2);

    /*  Initialize the standard USB driver */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          0);
    /*  Initialize the USB driver */
    USBD_Init();
}
Beispiel #5
0
void fastsource_init(void)
{
	USBDDriver_Initialize(&fast_source_driver, &auddFastSourceDriverDescriptors,
				driver_interfaces);

	USBD_Init();
}
//-----------------------------------------------------------------------------
/// Initializes the USB device composite device driver.
//-----------------------------------------------------------------------------
void DUALCDCDDriver_Initialize()
{
    // CDC
    CDCDFunctionDriver_ConfigurePort(&cdcdPorts[0],
                                     CDCD_Descriptors_INTERFACENUM0,
                                     CDCD_Descriptors_NOTIFICATION0,
                                     CDCD_Descriptors_DATAIN0,
                                     CDCD_Descriptors_DATAOUT0);
    CDCDFunctionDriver_ConfigurePort(&cdcdPorts[1],
                                     CDCD_Descriptors_INTERFACENUM1,
                                     CDCD_Descriptors_NOTIFICATION1,
                                     CDCD_Descriptors_DATAIN1,
                                     CDCD_Descriptors_DATAOUT1);
    CDCDFunctionDriver_Initialize(&usbdDriver,
                                  cdcdPorts,
                                  2);

    // Initialize the standard USB driver
    USBDDriver_Initialize(&usbdDriver,
                          &dualcdcdDriverDescriptors,
                          compositedDriverInterfaces);

    // Initialize the USB driver
    USBD_Init();
}
Beispiel #7
0
/**
 * Initializes the HID Mouse %device driver.
 * \param pDescriptors Pointer to descriptor list for the HID Mouse.
 */
void HIDDMouseDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
    HIDDMouseDriver* pMouse = &hiddMouseDriver;
    HIDDFunction* pHidd = &pMouse->hidDrv;
    USBDDriver* pUsbd = USBD_GetDriver();

    /* One input report */
    pMouse->inputReports[0] = (HIDDReport*)&hiddInputReport;
    HIDDFunction_InitializeReport(pMouse->inputReports[0],
                                  HIDDMouseDriver_REPORTDESCRIPTORSIZE,
                                  0,
                                  0, 0);

    /* Initialize USBD Driver instance */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          0); /* Multiple interface settings not supported */
    /* Function initialize */
    HIDDFunction_Initialize(pHidd,
                            pUsbd, 0,
                            hiddReportDescriptor,
                            (HIDDReport**)(&pMouse->inputReports), 1,
                            0, 0);
    USBD_Init();
}
Beispiel #8
0
/**
 * Initializes the MSD driver and the associated USB driver.
 * \param  pDescriptors Pointer to Descriptors list for MSD Device.
 * \param  pLuns        Pointer to a list of LUNs
 * \param  numLuns      Number of LUN in list
 * \see MSDLun
 */
void MSDDriver_Initialize(
	const USBDDriverDescriptors *pDescriptors,
	MSDLun *pLuns, unsigned char numLuns)
{
	USBDDriver *pUsbd = USBD_GetDriver();
	USBDDriver_Initialize(pUsbd, pDescriptors, 0);
	MSDFunction_Initialize(pUsbd, 0, pLuns, numLuns);
	USBD_Init();
}
Beispiel #9
0
/* Initialize the driver */
void fastsource_init(void)
{
	memset(&usb_state, 0, sizeof(usb_state));
	memset(fastsource_interfaces, 0x00, sizeof(fastsource_interfaces));

	INIT_LLIST_HEAD(&usb_state.queue);

	USBDDriver_Initialize(&fast_source_driver, &auddFastSourceDriverDescriptors,
				fastsource_interfaces);

	USBD_Init();
}
Beispiel #10
0
//-----------------------------------------------------------------------------
/// Initializes the USB device composite device driver.
//-----------------------------------------------------------------------------
void MULTIDriver_Initialize(void)
{

    CDCDFunctionDriver_Initialize();

	/* CCID nees no initialization */

    // Initialize the standard USB driver
    USBDDriver_Initialize(&usbdDriver,
                          &multiDriverDescriptors,
                          multiDriverInterfaces);

    // Initialize the USB driver
    USBD_Init();
}
/**
 * Initializes the USB device composite device driver.
 */
void CDCAUDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
    USBDDriver *pUsbd = USBD_GetDriver();

    /* Initialize the standard USB driver */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          bAltInterfaces);

    /* CDC */
    CDCDSerial_Initialize(pUsbd, CDCAUDDDriverDescriptors_CDC_INTERFACE);
    /* Audio */
    AUDDFunction_Initialize(pUsbd, CDCAUDDDriverDescriptors_AUD_INTERFACE);

    /* Initialize the USB driver */
    USBD_Init();
}
Beispiel #12
0
/**
 * Initializes the USB device composite device driver.
 */
void HIDAUDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
	USBDDriver *pUsbd = USBD_GetDriver();

	/* Initialize the standard USB driver */
	USBDDriver_Initialize(pUsbd,
						  pDescriptors,
						  bAltInterfaces);

	/* HID */
	HIDDKeyboard_Initialize(pUsbd, HIDAUDDDriverDescriptors_HID_INTERFACE);
	/* Audio */
	AUDDFunction_Initialize(pUsbd, HIDAUDDDriverDescriptors_AUD_INTERFACE);

	/* Initialize the USB driver */
	USBD_Init();
}
Beispiel #13
0
/**
 * Initializes the USB device composite device driver.
 */
void CDCHIDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
	USBDDriver *pUsbd = USBD_GetDriver();

	/* Initialize the standard USB driver */
	USBDDriver_Initialize(pUsbd,
						  pDescriptors,
						  0);

	/* CDC */
	CDCDSerial_Initialize(pUsbd, CDCHIDDDriverDescriptors_CDC_INTERFACE);
	/* HID */
	HIDDKeyboard_Initialize(pUsbd, CDCHIDDDriverDescriptors_HID_INTERFACE);

	/* Initialize the USB driver */
	USBD_Init();
}
/**
 * Initializes the USB device CDCMSD device driver.
 */
void CDCMSDDriver_Initialize(
    const USBDDriverDescriptors *pDescriptors,
    MSDLun *pLuns, unsigned char numLuns)
{
    USBDDriver *pUsbd = USBD_GetDriver();

    /* Initialize the standard USB driver */
    USBDDriver_Initialize(pUsbd, pDescriptors, 0);

    /* CDC */
    CDCDSerial_Initialize(pUsbd, CDCMSDDriverDescriptors_CDC_INTERFACE);

    /* MSD */
    MSDFunction_Initialize(pUsbd, CDCMSDDriverDescriptors_MSD_INTERFACE,
                           pLuns, numLuns);

    /* Initialize the USB driver */
    USBD_Init();
}
/**
 * Initializes an USB audio speaker device driver, as well as the underlying
 * USB controller.
 */
void AUDDSpeakerDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
    AUDDSpeakerDriver *pAudd = &auddSpeakerDriver;
    AUDDSpeakerPhone *pAudf  = &pAudd->fun;
    AUDDStream *pAuds = &pAudd->speaker;
    USBDDriver *pUsbd = USBD_GetDriver();

    AUDDSpeakerPhone_InitializeStream(
        pAuds, AUDDSpeakerDriver_NUMCHANNELS, 0,
        (AUDDStreamEventCallback)AUDDSpeaker_EventCallback, pAuds);

    AUDDSpeakerPhone_Initialize(
        pAudf, pUsbd, pAuds, 0);

    /* Initialize the USB driver */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          pAudd->bAltInterfaces);
    USBD_Init();
}
/**
 * Initializes the USB device HIDMSD device driver.
 */
void HIDMSDDriver_Initialize(
    const USBDDriverDescriptors *pDescriptors,
    MSDLun *pLuns, uint8_t numLuns)
{
    USBDDriver *pUsbd = USBD_GetDriver();

    /* Initialize the standard USB driver */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          0);

    /* HID */
    HIDDKeyboard_Initialize(pUsbd, HIDMSDDriverDescriptors_HID_INTERFACE);

    /* MSD */
    MSDFunction_Initialize(pUsbd, HIDMSDDriverDescriptors_MSD_INTERFACE,
                           pLuns, numLuns);

    /* Initialize the USB driver */
    USBD_Init();
}
Beispiel #17
0
//------------------------------------------------------------------------------
/// Initializes the USB Device CDC serial driver & USBD Driver.
//------------------------------------------------------------------------------
void CDCDSerialDriver_Initialize(void)
{
    TRACE_INFO("CDCDSerialDriver_Initialize\n\r");
    
    // Initialize Abstract Control Model attributes
    CDCLineCoding_Initialize(&(cdcdSerialDriver.lineCoding),
                             115200,
                             CDCLineCoding_ONESTOPBIT,
                             CDCLineCoding_NOPARITY,
                             8);
    cdcdSerialDriver.isCarrierActivated = 0;
    cdcdSerialDriver.serialState = 0;

    // Initialize the standard driver
    USBDDriver_Initialize(&(cdcdSerialDriver.usbdDriver),
                          &cdcdSerialDriverDescriptors,
                          0); // Multiple settings for interfaces not supported

    // Initialize the USB driver
    USBD_Init();
}
Beispiel #18
0
//-----------------------------------------------------------------------------
/// Initializes the MSD driver and the associated USB driver.
/// \param  luns   Pointer to a list of LUNs
/// \param  numLuns Number of LUN in list
/// \see MSDLun
//-----------------------------------------------------------------------------
void MSDDriver_Initialize(MSDLun *luns, unsigned char numLuns)
{
    TRACE_INFO("MSD init\n\r");

    // Command state initialization
    msdDriver.commandState.state = 0;
    msdDriver.commandState.postprocess = 0;
    msdDriver.commandState.length = 0;
    msdDriver.commandState.transfer.semaphore = 0;

    // LUNs
    msdDriver.luns = luns;
    msdDriver.maxLun = (unsigned char) (numLuns - 1);

    // Reset BOT driver
    MSDDriver_Reset();

    // Init the USB driver
    USBDDriver_Initialize(&usbdDriver, &msdDriverDescriptors, 0);
    USBD_Init();
}
Beispiel #19
0
bool usb_init() {
    if(!usb_is_connected()) {
    	return false;
    }
	send_status = 0;
	receive_status = 0;

	usb_configure_clock_48mhz();

    USBDDriver_Initialize(&usbd_driver, &driver_descriptors, 0);
    USBD_Init();

    // Check current level on VBus
    if(usb_is_connected()) {
        USBD_Connect();
    } else {
        USBD_Disconnect();
        return false;
    }

	return true;
}
//------------------------------------------------------------------------------
/// Initializes an USB audio speaker device driver, as well as the underlying
/// USB controller.
//------------------------------------------------------------------------------
void AUDDSpeakerDriver_Initialize()
{
    // Initialize speaker channels
    AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[0]),
                                  AUDDSpeakerDriver_MASTERCHANNEL,
                                  0);
    AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[1]),
                                  AUDDSpeakerDriver_LEFTCHANNEL,
                                  0);
    AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[2]),
                                  AUDDSpeakerDriver_RIGHTCHANNEL,
                                  0);
    
    // Initialize the USB driver
    USBDDriver_Initialize(&(auddSpeakerDriver.usbdDriver),
                          &auddSpeakerDriverDescriptors,
                          auddSpeakerDriverInterfaces);
    USBD_Init();

    // Initialize the third LED to indicate when the audio interface is active
    LED_Configure(USBD_LEDOTHER);
}