Example #1
0
static void handle_osmosdr_write(const USBGenericRequest* request)
{
	uint16_t func = USBGenericRequest_GetValue(request);
	int len = USBGenericRequest_GetLength(request);
	int i;
/*
	printf("OsmoSDR SET request: type:%d, request:%d, value:%04x, index: %04x, length: %d\n\r",
		USBGenericRequest_GetType(request),
		USBGenericRequest_GetRequest(request),
		USBGenericRequest_GetValue(request),
		USBGenericRequest_GetIndex(request),
		len);
*/
	for(i = 0; i < ARRAY_SIZE(g_writeRequests); i++) {
		if(g_writeRequests[i].func == func)
			break;
	}
	if(i == ARRAY_SIZE(g_writeRequests)) {
		USBD_Stall(0);
		return;
	}
	if(len != g_writeRequests[i].len) {
		USBD_Stall(0);
		return;
	}

	g_writeState.func = func;

	if(len > 0)
		USBD_Read(0, g_writeState.data, len, finalize_write, 0);
	else finalize_write(NULL, 0, 0, 0);
}
Example #2
0
static void handle_osmosdr_read(const USBGenericRequest* request)
{
	int len = USBGenericRequest_GetLength(request);
	printf("OsmoSDR GET request: type:%d, request:%d, value:%d, index: %d, length: %d\n\r",
		USBGenericRequest_GetType(request),
		USBGenericRequest_GetRequest(request),
		USBGenericRequest_GetValue(request),
		USBGenericRequest_GetIndex(request),
		len);
	USBD_Stall(0);
}
//------------------------------------------------------------------------------
/// Returns the number of the configuration that should be set in response
/// to the given SET_CONFIGURATION request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Number of the requested configuration.
//------------------------------------------------------------------------------
unsigned char USBSetConfigurationRequest_GetConfiguration(
    const USBGenericRequest *request)
{
    return USBGenericRequest_GetValue(request);
}
Example #4
0
//------------------------------------------------------------------------------
/// Returns the feature selector of a given CLEAR_FEATURE or SET_FEATURE
/// request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Feature selector.
//------------------------------------------------------------------------------
unsigned char USBFeatureRequest_GetFeatureSelector(
    const USBGenericRequest *request)
{
    return USBGenericRequest_GetValue(request);
}
Example #5
0
//------------------------------------------------------------------------------
/// Indicates the ID of the report targetted by a SET_REPORT or GET_REPORT
/// request. This value should be 0 if report IDs are not used.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Requested report ID.
//------------------------------------------------------------------------------
unsigned char HIDReportRequest_GetReportId(const USBGenericRequest *request)
{
    return (USBGenericRequest_GetValue(request) & 0xFF);
}
//------------------------------------------------------------------------------
/// Returns the index of the requested descriptor, given the corresponding
/// GET_DESCRIPTOR request.
/// \param request Pointer to a USBGenericDescriptor instance.
/// \return Index of the requested descriptor.
//------------------------------------------------------------------------------
unsigned char USBGetDescriptorRequest_GetDescriptorIndex(
    const USBGenericRequest *request)
{
    // Requested descriptor index if in the low byte of the wValue field
    return USBGenericRequest_GetValue(request) & 0xFF;
}
Example #7
0
//------------------------------------------------------------------------------
/// Returns the channel number of a Feature unit which should be altered by the
/// given request.
/// \param request  Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
unsigned char AUDFeatureUnitRequest_GetChannel(const USBGenericRequest *request)
{
    return (USBGenericRequest_GetValue(request) & 0xFF);
}
Example #8
0
/**
 * Indicates the new alternate setting that the interface targetted by a
 * SET_INTERFACE request should use.
 * \param request Pointer to a USBGenericRequest instance.
 * \return New active setting for the interface.
 */
uint8_t USBInterfaceRequest_GetAlternateSetting(
    const USBGenericRequest *request)
{
    return (USBGenericRequest_GetValue(request) & 0xFF);
}
Example #9
0
/**
 *  Returns the feature selector of a given CLEAR_FEATURE or SET_FEATURE
 *  request.
 *  \param request Pointer to a USBGenericRequest instance.
 *  \return Feature selector.
 */
uint8_t USBFeatureRequest_GetFeatureSelector(
    const USBGenericRequest *request)
{
    return USBGenericRequest_GetValue(request);
}
Example #10
0
/**
 * Returns the number of the configuration that should be set in response
 * to the given SET_CONFIGURATION request.
 * \param request Pointer to a USBGenericRequest instance.
 * \return Number of the requested configuration.
 */
uint8_t USBSetConfigurationRequest_GetConfiguration(
    const USBGenericRequest *request)
{
    return USBGenericRequest_GetValue(request);
}
Example #11
0
/**
 * Returns the address that the device must take in response to a
 * SET_ADDRESS request.
 * \param request Pointer to a USBGenericRequest instance.
 * \return New device address.
 */
uint8_t USBSetAddressRequest_GetAddress(const USBGenericRequest *request)
{
    return USBGenericRequest_GetValue(request) & 0x7F;
}
Example #12
0
/**
 * Returns the index of the requested descriptor, given the corresponding
 * GET_DESCRIPTOR request.
 * \param request Pointer to a USBGenericDescriptor instance.
 * \return Index of the requested descriptor.
 */
uint8_t USBGetDescriptorRequest_GetDescriptorIndex(
    const USBGenericRequest *request)
{
    /* Requested descriptor index if in the low byte of the wValue field */
    return USBGenericRequest_GetValue(request) & 0xFF;
}
//------------------------------------------------------------------------------
//         Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the address that the device must take in response to a
/// SET_ADDRESS request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return New device address.
//------------------------------------------------------------------------------
unsigned char USBSetAddressRequest_GetAddress(const USBGenericRequest *request)
{
    return USBGenericRequest_GetValue(request) & 0x7F;
}
Example #14
0
/**
 * Indicates the ID of the report targetted by a SET_REPORT or GET_REPORT
 * request. This value should be 0 if report IDs are not used.
 * \param request Pointer to a USBGenericRequest instance.
 * \return Requested report ID.
 */
uint8_t HIDReportRequest_GetReportId(const USBGenericRequest *request)
{
    return (USBGenericRequest_GetValue(request) & 0xFF);
}