本文整理汇总了C++中ValBit函数的典型用法代码示例。如果您正苦于以下问题:C++ ValBit函数的具体用法?C++ ValBit怎么用?C++ ValBit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValBit函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetBit
/*******************************************************************************
* Function Name : Standard_GetStatus.
* Description : Copy the device request data to "StatusInfo buffer".
* Input : - Length - How many bytes are needed.
* Output : None.
* Return : Return 0, if the request is at end of data block,
* or is invalid when "Length" is 0.
*******************************************************************************/
u8 *Standard_GetStatus(u16 Length)
{
if (Length == 0)
{
pInformation->Ctrl_Info.Usb_wLength = 2;
return 0;
}
StatusInfo.w = 0;
/* Reset Status Information */
if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
{
u8 Feature = pInformation->Current_Feature; /*Get Device Status */
if (ValBit(Feature, 5)) /* Remote Wakeup enabled */
{
SetBit(StatusInfo0, 1);
}
if (ValBit(Feature, 6)) /* Bus-powered */
{
ClrBit(StatusInfo0, 0);
}
else
{
SetBit(StatusInfo0, 0); /* Self-powered */
}
}
else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
{ /*Interface Status*/
return (u8 *)&StatusInfo;
}
else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
{ /*Get EndPoint Status*/
u8 Related_Endpoint;
u8 wIndex0 = pInformation->USBwIndex0;
Related_Endpoint = (wIndex0 & 0x0f);
if (ValBit(wIndex0, 7))
{ /* IN endpoint */
if (_GetTxStallStatus(Related_Endpoint))
{
SetBit(StatusInfo0, 0); /* IN Endpoint stalled */
}
}
else
{ /* OUT endpoint */
if (_GetRxStallStatus(Related_Endpoint))
{
SetBit(StatusInfo0, 0); /* OUT Endpoint stalled */
}
}
}
else
return NULL;
pUser_Standard_Requests->User_GetStatus();
return (u8 *)&StatusInfo;
}
示例2: Standard_SetEndPointFeature
/*******************************************************************************
* Function Name : Standard_SetEndPointFeature
* Description : Set or enable a specific feature of EndPoint
* Input : None.
* Output : None.
* Return : - Return USB_SUCCESS, if the request is performed.
* - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_SetEndPointFeature(void) {
uint32_t wIndex0;
uint32_t Related_Endpoint;
uint32_t rEP;
uint32_t Status;
wIndex0 = pInformation->USBwIndex0;
rEP = wIndex0 & ~0x80;
Related_Endpoint = ENDP0 + rEP;
if(ValBit(pInformation->USBwIndex0, 7)) {
/* get Status of endpoint & stall the request if the related_ENdpoint
is Disabled*/
Status = _GetEPTxStatus(Related_Endpoint);
} else {
Status = _GetEPRxStatus(Related_Endpoint);
}
if(Related_Endpoint >= Device_Table.Total_Endpoint || pInformation->USBwValue != 0 || Status == 0 ||
pInformation->Current_Configuration == 0) {
return USB_UNSUPPORT;
} else {
if(wIndex0 & 0x80) {
/* IN endpoint */
_SetEPTxStatus(Related_Endpoint, EP_TX_STALL);
}
else {
/* OUT endpoint */
_SetEPRxStatus(Related_Endpoint, EP_RX_STALL);
}
}
pUser_Standard_Requests->User_SetEndPointFeature();
return USB_SUCCESS;
}
示例3: DrawChar5x7
/*
* Draw a Char
*/
u8 DrawChar5x7(u8 x, u8 y, char character, u16 color, u16 bgcolor) {
u16 fontHeight, i, j, fontWidth, fontPos = 0;
if ( character < 32 ) return;
if ( character > 127 ) return;
fontWidth = 5;
fontHeight = 7;
fontPos = ( character - 32 ) * fontWidth;
LCD_SetArea(x, y, x + fontWidth + 1, y+fontHeight);
LCD_SendCMD(RAMWR);
for (i = 0; i < fontWidth; i++) {
for (j = 0; j <= fontHeight; j++) {
if ( ValBit( Font5x7[ fontPos + i ], j ) ) {
LCD_SendDAT16(color);
} else {
LCD_SendDAT16(bgcolor);
}
}
}
for (j = 0; j <= fontHeight; j++) {
LCD_SendDAT16(bgcolor);
}
fontWidth++;
return x + fontWidth;
}
示例4: DrawChar5x5
/*
* Draw a Char
*/
u8 DrawChar5x5(u8 x, u8 y, char character, u16 color, u16 bgcolor) {
u16 fontIndex, i, j, fontWidth, fontPos = 0;
fontIndex = character-32;
if ( character < 32 ) return;
if ( fontIndex > 96 ) return;
if ( fontIndex > 0 ) {
fontPos = Font5x5WidthPos[ fontIndex - 1];
}
fontWidth = Font5x5WidthPos[ fontIndex ] - fontPos;
LCD_SetArea(x, y, x+fontWidth+1, y+5);
LCD_SendCMD(RAMWR);
for (i = 0; i < fontWidth; i++) {
for (j = 0; j <= 5; j++) {
if ( ValBit( Font5x5[ fontPos + i ], j ) ) {
LCD_SendDAT16(color);
} else {
LCD_SendDAT16(bgcolor);
}
}
}
for (j = 0; j <= 5; j++) {
LCD_SendDAT16(bgcolor);
}
fontWidth++;
return x + fontWidth;
}
示例5: Standard_ClearFeature
/*******************************************************************************
* Function Name : Standard_ClearFeature.
* Description : Clear or disable a specific feature.
* Input : None.
* Output : None.
* Return : - Return USB_SUCCESS, if the request is performed.
* - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_ClearFeature(void) {
uint32_t Type_Rec = Type_Recipient;
uint32_t Status;
if (Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
// Device Clear Feature
ClrBit(pInformation->Current_Feature, 5);
return USB_SUCCESS;
} else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) {
// EndPoint Clear Feature
DEVICE* pDev;
uint32_t Related_Endpoint;
uint32_t wIndex0;
uint32_t rEP;
if ((pInformation->USBwValue != ENDPOINT_STALL) || (pInformation->USBwIndex1 != 0)) {
return USB_UNSUPPORT;
}
pDev = &Device_Table;
wIndex0 = pInformation->USBwIndex0;
rEP = wIndex0 & ~0x80;
Related_Endpoint = ENDP0 + rEP;
if (ValBit(pInformation->USBwIndex0, 7)) {
// Get Status of endpoint & stall the request if the related_ENdpoint is Disabled
Status = GetEPTxStatus(Related_Endpoint);
} else {
Status = GetEPRxStatus(Related_Endpoint);
}
if ((rEP >= pDev->Total_Endpoint) || (Status == 0) || (pInformation->Current_Configuration == 0)) {
return USB_UNSUPPORT;
}
if (wIndex0 & 0x80) {
// IN endpoint
if (GetTxStallStatus(Related_Endpoint )) {
ClearDTOG_TX(Related_Endpoint);
SetEPTxStatus(Related_Endpoint, EP_TX_VALID);
}
} else {
// OUT endpoint
if (GetRxStallStatus(Related_Endpoint)) {
if (Related_Endpoint == ENDP0) {
// After clear the STALL, enable the default endpoint receiver
SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
} else {
ClearDTOG_RX(Related_Endpoint);
SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
}
}
}
pUser_Standard_Requests->User_ClearFeature();
return USB_SUCCESS;
}
return USB_UNSUPPORT;
}
示例6: if
/*******************************************************************************
* Function Name : Standard_GetStatus.
* Description : Copy the device request data to "StatusInfo buffer".
* Input : - Length - How many bytes are needed.
* Output : None.
* Return : Return 0, if the request is at end of data block,
* or is invalid when "Length" is 0.
*******************************************************************************/
uint8_t *Standard_GetStatus(uint16_t Length) {
if (Length == 0) {
pInformation->Ctrl_Info.Usb_wLength = 2;
return 0;
}
// Reset Status Information
StatusInfo.w = 0;
if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
// Get Device Status
uint8_t Feature = pInformation->Current_Feature;
// Remote Wakeup enabled
if (ValBit(Feature, 5)) SetBit(StatusInfo0,1); else ClrBit(StatusInfo0,1);
// Bus-powered or self-powered
if (ValBit(Feature, 6)) SetBit(StatusInfo0,0); else ClrBit(StatusInfo0,0);
} else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) {
// Interface Status
return (uint8_t *)&StatusInfo;
} else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) {
// Get EndPoint Status
uint8_t Related_Endpoint;
uint8_t wIndex0 = pInformation->USBwIndex0;
Related_Endpoint = (wIndex0 & 0x0f);
if (ValBit(wIndex0,7)) {
// IN endpoint
if (GetTxStallStatus(Related_Endpoint)) SetBit(StatusInfo0,0); // IN Endpoint stalled
} else {
// OUT endpoint
if (GetRxStallStatus(Related_Endpoint)) SetBit(StatusInfo0,0); // OUT Endpoint stalled
}
} else {
return NULL;
}
pUser_Standard_Requests->User_GetStatus();
return (uint8_t *)&StatusInfo;
}
示例7: Data_Setup0
/*******************************************************************************
* Function Name : Data_Setup0.
* Description : Proceed the processing of setup request with data stage.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Data_Setup0(void) {
uint8_t* (*CopyRoutine)(uint16_t);
RESULT Result;
uint32_t Request_No = pInformation->USBbRequest;
uint32_t Related_Endpoint, Reserved;
uint32_t wOffset, Status;
CopyRoutine = NULL;
wOffset = 0;
/*GET DESCRIPTOR*/
if(Request_No == GET_DESCRIPTOR) {
if(Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
uint8_t wValue1 = pInformation->USBwValue1;
if(wValue1 == DEVICE_DESCRIPTOR) {
CopyRoutine = pProperty->GetDeviceDescriptor;
} else if(wValue1 == CONFIG_DESCRIPTOR) {
CopyRoutine = pProperty->GetConfigDescriptor;
} else if(wValue1 == STRING_DESCRIPTOR) {
CopyRoutine = pProperty->GetStringDescriptor;
} /* End of GET_DESCRIPTOR */
}
}
/*GET STATUS*/
else if((Request_No == GET_STATUS) && (pInformation->USBwValue == 0) && (pInformation->USBwLength == 0x0002) &&
(pInformation->USBwIndex1 == 0)) {
/* GET STATUS for Device*/
if((Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) && (pInformation->USBwIndex == 0)) {
CopyRoutine = Standard_GetStatus;
}
/* GET STATUS for Interface*/
else if(Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) {
if(((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS) &&
(pInformation->Current_Configuration != 0)) {
CopyRoutine = Standard_GetStatus;
}
}
/* GET STATUS for EndPoint*/
else if(Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) {
Related_Endpoint = (pInformation->USBwIndex0 & 0x0f);
Reserved = pInformation->USBwIndex0 & 0x70;
if(ValBit(pInformation->USBwIndex0, 7)) {
/*Get Status of endpoint & stall the request if the related_ENdpoint
is Disabled*/
Status = _GetEPTxStatus(Related_Endpoint);
} else {
Status = _GetEPRxStatus(Related_Endpoint);
}
if((Related_Endpoint < Device_Table.Total_Endpoint) && (Reserved == 0) && (Status != 0)) {
CopyRoutine = Standard_GetStatus;
}
}
}
/*GET CONFIGURATION*/
else if(Request_No == GET_CONFIGURATION) {
if(Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
CopyRoutine = Standard_GetConfiguration;
}
}
/*GET INTERFACE*/
else if(Request_No == GET_INTERFACE) {
if((Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) && (pInformation->Current_Configuration != 0) &&
(pInformation->USBwValue == 0) && (pInformation->USBwIndex1 == 0) && (pInformation->USBwLength == 0x0001) &&
((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS)) {
CopyRoutine = Standard_GetInterface;
}
}
if(CopyRoutine) {
pInformation->Ctrl_Info.Usb_wOffset = wOffset;
pInformation->Ctrl_Info.CopyData = CopyRoutine;
/* sb in the original the cast to word was directly */
/* now the cast is made step by step */
(*CopyRoutine)(0);
Result = USB_SUCCESS;
} else {
Result = (*pProperty->Class_Data_Setup)(pInformation->USBbRequest);
if(Result == USB_NOT_READY) {
pInformation->ControlState = PAUSE;
return;
}
}
if(pInformation->Ctrl_Info.Usb_wLength == 0xFFFF) {
//.........这里部分代码省略.........
示例8: NoData_Setup0
/*******************************************************************************
* Function Name : NoData_Setup0.
* Description : Proceed the processing of setup request without data stage.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void NoData_Setup0(void) {
RESULT Result = USB_UNSUPPORT;
uint32_t RequestNo = pInformation->USBbRequest;
uint32_t ControlState;
if(Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
/* Device Request*/
/* SET_CONFIGURATION*/
if(RequestNo == SET_CONFIGURATION) {
Result = Standard_SetConfiguration();
}
/*SET ADDRESS*/
else if(RequestNo == SET_ADDRESS) {
if((pInformation->USBwValue0 > 127) || (pInformation->USBwValue1 != 0) || (pInformation->USBwIndex != 0) ||
(pInformation->Current_Configuration != 0))
/* Device Address should be 127 or less*/
{
ControlState = STALLED;
goto exit_NoData_Setup0;
} else {
Result = USB_SUCCESS;
#ifdef STM32F10X_CL
SetDeviceAddress(pInformation->USBwValue0);
#endif /* STM32F10X_CL */
}
}
/*SET FEATURE for Device*/
else if(RequestNo == SET_FEATURE) {
if((pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP) && (pInformation->USBwIndex == 0)) {
Result = Standard_SetDeviceFeature();
} else {
Result = USB_UNSUPPORT;
}
}
/*Clear FEATURE for Device */
else if(RequestNo == CLEAR_FEATURE) {
if(pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP && pInformation->USBwIndex == 0 &&
ValBit(pInformation->Current_Feature, 5)) {
Result = Standard_ClearFeature();
} else {
Result = USB_UNSUPPORT;
}
}
}
/* Interface Request*/
else if(Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) {
/*SET INTERFACE*/
if(RequestNo == SET_INTERFACE) {
Result = Standard_SetInterface();
}
}
/* EndPoint Request*/
else if(Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) {
/*CLEAR FEATURE for EndPoint*/
if(RequestNo == CLEAR_FEATURE) {
Result = Standard_ClearFeature();
}
/* SET FEATURE for EndPoint*/
else if(RequestNo == SET_FEATURE) {
Result = Standard_SetEndPointFeature();
}
} else {
Result = USB_UNSUPPORT;
}
if(Result != USB_SUCCESS) {
Result = (*pProperty->Class_NoData_Setup)(RequestNo);
if(Result == USB_NOT_READY) {
ControlState = PAUSE;
goto exit_NoData_Setup0;
}
}
if(Result != USB_SUCCESS) {
ControlState = STALLED;
goto exit_NoData_Setup0;
}
ControlState = WAIT_STATUS_IN; /* After no data stage SETUP */
USB_StatusIn();
exit_NoData_Setup0:
pInformation->ControlState = ControlState;
return;
}
示例9: NoData_Setup0
/*******************************************************************************
* Function Name : NoData_Setup0.
* Description : Proceed the processing of setup request without data stage.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void NoData_Setup0(void) {
RESULT Result = USB_UNSUPPORT;
uint32_t RequestNo = pInformation->USBbRequest;
uint32_t ControlState;
if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) {
// Device Request
// SET_CONFIGURATION
if (RequestNo == SET_CONFIGURATION) Result = Standard_SetConfiguration();
// SET ADDRESS
else if (RequestNo == SET_ADDRESS) {
if ((pInformation->USBwValue0 > 127) || (pInformation->USBwValue1 != 0)
|| (pInformation->USBwIndex != 0)
|| (pInformation->Current_Configuration != 0)) {
// Device Address should be 127 or less
ControlState = STALLED;
pInformation->ControlState = ControlState;
return;
} else Result = USB_SUCCESS;
} else if (RequestNo == SET_FEATURE) {
// SET FEATURE for Device
if ((pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP)
&& (pInformation->USBwIndex == 0)) {
Result = Standard_SetDeviceFeature();
} else {
Result = USB_UNSUPPORT;
}
} else if (RequestNo == CLEAR_FEATURE) {
// Clear FEATURE for Device
if (pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP
&& pInformation->USBwIndex == 0
&& ValBit(pInformation->Current_Feature, 5)) {
Result = Standard_ClearFeature();
} else {
Result = USB_UNSUPPORT;
}
}
} else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) {
// Interface Request
// SET INTERFACE
if (RequestNo == SET_INTERFACE) Result = Standard_SetInterface();
} else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) {
// EndPoint Request
// CLEAR FEATURE for EndPoint
if (RequestNo == CLEAR_FEATURE) {
Result = Standard_ClearFeature();
} else if (RequestNo == SET_FEATURE) {
// SET FEATURE for EndPoint
Result = Standard_SetEndPointFeature();
}
} else Result = USB_UNSUPPORT;
if (Result != USB_SUCCESS) {
Result = (*pProperty->Class_NoData_Setup)(RequestNo);
if (Result == USB_NOT_READY) {
ControlState = PAUSE;
pInformation->ControlState = ControlState;
return;
}
}
if (Result != USB_SUCCESS) {
ControlState = STALLED;
pInformation->ControlState = ControlState;
return;
}
ControlState = WAIT_STATUS_IN; // After no data stage SETUP
SetEPTxCount(ENDP0,0);
SaveTState = EP_TX_VALID;
pInformation->ControlState = ControlState;
return;
}