本文整理汇总了C++中USBD_Write函数的典型用法代码示例。如果您正苦于以下问题:C++ USBD_Write函数的具体用法?C++ USBD_Write怎么用?C++ USBD_Write使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USBD_Write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetInterface
/**
* Sets the active setting of the given interface if the configuration supports
* it; otherwise, the control pipe is STALLed. If the setting of an interface
* changes.
* \parma pDriver Pointer to a USBDDriver instance.
* \parma infnum Interface number.
* \parma setting New active setting for the interface.
*/
static void SetInterface(
USBDDriver *pDriver,
uint8_t infnum,
uint8_t setting)
{
/* Make sure alternate settings are supported */
if (!pDriver->pInterfaces) {
USBD_Stall(0);
}
else {
/* Change the current setting of the interface and trigger the callback */
/* if necessary */
if (pDriver->pInterfaces[infnum] != setting) {
pDriver->pInterfaces[infnum] = setting;
USBDDriverCallbacks_InterfaceSettingChanged(infnum, setting);
}
/* Acknowledge the request */
USBD_Write(0, 0, 0, 0, 0);
}
}
示例2: SendCsw
/**************************************************************************//**
* @brief
* Start a USB bulk-in transfer to send a CSW back to host.
*****************************************************************************/
__STATIC_INLINE void SendCsw(void)
{
if ( ledPort != -1 )
GPIO_PinOutToggle((GPIO_Port_TypeDef)ledPort, ledPin);
USBD_Write(BULK_IN, (void*) &csw, CSW_LEN, NULL);
}
示例3: GetDeviceStatus
//------------------------------------------------------------------------------
/// Sends the current status of the device to the host.
/// \param pDriver Pointer to a USBDDriver instance.
//------------------------------------------------------------------------------
static void GetDeviceStatus(const USBDDriver *pDriver)
{
static unsigned short data;
const USBConfigurationDescriptor *pConfiguration;
data = 0;
// Use different configuration depending on device speed
if (USBD_IsHighSpeed()) {
pConfiguration = pDriver->pDescriptors->pHsConfiguration;
}
else {
pConfiguration = pDriver->pDescriptors->pFsConfiguration;
}
// Check current configuration for power mode (if device is configured)
if (pDriver->cfgnum != 0) {
if (USBConfigurationDescriptor_IsSelfPowered(pConfiguration)) {
data |= 1;
}
}
// Check if remote wake-up is enabled
if (pDriver->isRemoteWakeUpEnabled) {
data |= 2;
}
// Send the device status
USBD_Write(0, &data, 2, 0, 0);
}
示例4: usb_send
inline uint16_t usb_send(const void *data, const uint16_t length) {
if((send_status & (USB_IN_FUNCTION))) {
return 0;
}
if(!(send_status & USB_CALLBACK)) {
send_status |= USB_IN_FUNCTION;
if(USBD_Write(IN_EP, data, length, usb_send_callback, 0) != USBD_STATUS_SUCCESS) {
send_status &= ~USB_IN_FUNCTION;
return 0;
}
} else {
return 0;
}
uint16_t num_tries = 0;
while(~send_status & USB_CALLBACK) {
taskYIELD();
num_tries++;
// USBD_Write does not always call callback when USBD_STATUS_SUCCESS
// Wait for NUM_SEND_TRIES
if(num_tries > NUM_SEND_TRIES) {
send_status = 0;
return 0;
}
}
send_status = 0;
return usb_send_transferred;
}
示例5: SetConfiguration
//------------------------------------------------------------------------------
/// Configures the device by setting it into the Configured state and
/// initializing all endpoints.
/// \param pDriver Pointer to a USBDDriver instance.
/// \param cfgnum Configuration number to set.
//------------------------------------------------------------------------------
static void SetConfiguration(USBDDriver *pDriver, unsigned char cfgnum)
{
USBEndpointDescriptor *pEndpoints[BOARD_USB_NUMENDPOINTS+1];
const USBConfigurationDescriptor *pConfiguration;
pConfiguration = pDriver->pDescriptors->pFsConfiguration;
// Set & save the desired configuration
USBD_SetConfiguration(cfgnum);
pDriver->cfgnum = cfgnum;
// If the configuration is not 0, configure endpoints
if (cfgnum != 0) {
// Parse configuration to get endpoint descriptors
USBConfigurationDescriptor_Parse(pConfiguration, 0, pEndpoints, 0);
// Configure endpoints
int i = 0;
while (pEndpoints[i] != 0) {
USBD_ConfigureEndpoint(pEndpoints[i]);
i++;
}
}
// Should be done before send the ZLP
USBDDriverCallbacks_ConfigurationChanged(cfgnum);
// Acknowledge the request
USBD_Write(0, // Endpoint #0
0, // No data buffer
0, // No data buffer
(TransferCallback) 0,
(void *) 0);
}
示例6: GPIO_EVEN_IRQHandler
/**********************************************************
* Interrupt handler for push button 1
**********************************************************/
void GPIO_EVEN_IRQHandler(void)
{
/* Clear the interrupt flag */
GPIO->IFC = 1 << 10;
/* Send message */
USBD_Write(EP_IN, button1message, sizeof(button1message), dataSentCallback);
}
示例7: write
/**
Write data to a USB host.
@param buffer The data to send.
@param length How many bytes to send.
@return The number of bytes successfully written.
\b Example
\code
UsbSerial* usb = UsbSerial::get(); // get a reference to the usb system
int written = usb->write( "hi hi", 5 );
\endcode
*/
int UsbSerial::write( const char *buffer, int length )
{
int rv = 0;
if( USBD_GetState() == USBD_STATE_CONFIGURED ) {
if( USBD_Write(CDCDSerialDriverDescriptors_DATAIN, buffer, length, 0, 0) == USBD_STATUS_SUCCESS )
rv = length;
}
return rv;
}
示例8: HIDDTransferDriver_ReportReceived
/**
* Callback function when SetReport request data received from host
* \param pArg Pointer to additional argument struct
* \param status Result status
* \param transferred Number of bytes transferred
* \param remaining Number of bytes that are not transferred yet
*/
static void HIDDTransferDriver_ReportReceived(void *pArg,
uint8_t status,
uint32_t transferred,
uint32_t remaining)
{
HIDDTransferDriver *pDrv = &hiddTransferDriver;
pDrv->iReportLen = transferred;
USBD_Write(0, 0, 0, 0, 0);
}
示例9: fastsource_get_feat_cur_val
static void fastsource_get_feat_cur_val(uint8_t entity, uint8_t channel,
uint8_t control, uint8_t length)
{
TRACE_INFO("get_feat(E%u, CN%u, CS%u, L%u) ", entity, channel, control, length);
if (channel == 0 && control == AUDFeatureUnitDescriptor_MUTE && length == 1)
USBD_Write(0, &usb_state.muted, sizeof(usb_state.muted), 0, 0);
else
USBD_Stall(0);
}
示例10: firmware_get
static int firmware_get(const USB_Setup_TypeDef *setup)
{
int res = USB_STATUS_REQ_ERR;
CHECK_SETUP_IN(USBTHING_FIRMWARE_MAX_SIZE);
res = USBD_Write(0, firmware_version, sizeof(firmware_version), NULL);
return res;
}
示例11: CDCDSerialDriver_GetLineCoding
//------------------------------------------------------------------------------
/// Sends the current line coding information to the host through Control
/// endpoint 0.
//------------------------------------------------------------------------------
static void CDCDSerialDriver_GetLineCoding(void)
{
TRACE_INFO_WP("gLineCoding ");
USBD_Write(0,
(void *) &(cdcdSerialDriver.lineCoding),
sizeof(CDCLineCoding),
0,
0);
}
示例12: _GetLineCoding
/**
* Sends the current line coding information to the host through Control
* endpoint 0.
* \param pCdcd Pointer to CDCDSerialPort instance.
*/
static void _GetLineCoding(CDCDSerialPort * pCdcd)
{
TRACE_INFO_WP("gLineCoding ");
USBD_Write(0,
(void *) &(pCdcd->lineCoding),
sizeof(CDCLineCoding),
0,
0);
}
示例13: CDCDSerialDriver_Write
//------------------------------------------------------------------------------
/// Sends a data buffer through the virtual COM port created by the CDC
/// device serial driver. This function behaves exactly like USBD_Write.
/// \param data Pointer to the data buffer to send.
/// \param size Size of the data buffer in bytes.
/// \param callback Optional callback function to invoke when the transfer
/// finishes.
/// \param argument Optional argument to the callback function.
/// \return USBD_STATUS_SUCCESS if the read operation has been started normally;
/// otherwise, the corresponding error code.
//------------------------------------------------------------------------------
unsigned char CDCDSerialDriver_Write(void *data,
unsigned int size,
TransferCallback callback,
void *argument)
{
return USBD_Write(CDCDSerialDriverDescriptors_DATAIN,
data,
size,
callback,
argument);
}
示例14: GetConfiguration
/**
* Sends the current configuration number to the host.
* \param pDriver Pointer to a USBDDriver instance.
*/
static void GetConfiguration(const USBDDriver *pDriver)
{
unsigned long tmp; // Coud be unsigned char : unsigned long has been chose to avoid any potential alignment issue with DMA
if( USBD_GetState() < USBD_STATE_CONFIGURED)
tmp = 0; // If device is unconfigured, returned configuration must be 0
else
tmp = pDriver->cfgnum;
USBD_Write(0, &tmp, 1, 0, 0);
}
示例15: TerminateCtrlInWithNull
/**
* Send a NULL packet
*/
static void TerminateCtrlInWithNull(void *pArg,
uint8_t status,
uint32_t transferred,
uint32_t remaining)
{
USBD_Write(0, /* Endpoint #0 */
0, /* No data buffer */
0, /* No data buffer */
(TransferCallback) 0,
(void *) 0);
}