本文整理汇总了C++中INTFNUM_OFFSET函数的典型用法代码示例。如果您正苦于以下问题:C++ INTFNUM_OFFSET函数的具体用法?C++ INTFNUM_OFFSET怎么用?C++ INTFNUM_OFFSET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INTFNUM_OFFSET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kUSBHID_waitingForSend
/*
This function indicates the status of the interface intfNum.
If a send operation is active for this interface,
the function also returns the number of bytes that have been transmitted to the host.
If a receiver operation is active for this interface, the function also returns
the number of bytes that have been received from the host and are waiting at the assigned address.
returns kUSBHID_waitingForSend (indicates that a call to USBHID_SendData()
has been made, for which data transfer has not been completed)
returns kUSBHID_waitingForReceive (indicates that a receive operation
has been initiated, but not all data has yet been received)
returns kUSBHID_dataWaiting (indicates that data has been received
from the host, waiting in the USB receive buffers)
*/
BYTE USBHID_intfStatus(BYTE intfNum, WORD* bytesSent, WORD* bytesReceived)
{
BYTE ret = 0;
unsigned short bGIE;
BYTE edbIndex;
*bytesSent = 0;
*bytesReceived = 0;
edbIndex = stUsbHandle[intfNum].edb_Index;
bGIE = (__get_SR_register() &GIE); //save interrupt status
__disable_interrupt(); //disable interrupts - atomic operation
// Is send operation underway?
if (HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft != 0)
{
ret |= kUSBHID_waitingForSend;
*bytesSent = HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSend - HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft;
}
//Is receive operation underway?
if (HidReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer != NULL)
{
ret |= kUSBHID_waitingForReceive;
*bytesReceived = HidReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceive - HidReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceiveLeft;
}
else // not receive operation started
{
// do not access USB memory if suspended (PLL off). It may produce BUS_ERROR
if (!bFunctionSuspended)
{
if((tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX & EPBCNT_NAK) | //any of buffers has a valid data packet
(tOutputEndPointDescriptorBlock[edbIndex].bEPBCTY & EPBCNT_NAK))
{
ret |= kUSBHID_dataWaiting;
}
}
}
if ((bFunctionSuspended) ||
(bEnumerationStatus != ENUMERATION_COMPLETE))
{
// if suspended or not enumerated - report no other tasks pending
ret = kUSBHID_busNotAvailable;
}
//restore interrupt status
__bis_SR_register(bGIE); //restore interrupt status
return ret;
}
示例2: USBHID_abortSend
/*
Aborts an active send operation on interface intfNum.
Returns the number of bytes that were sent prior to the abort, in size.
*/
BYTE USBHID_abortSend(WORD* size, BYTE intfNum)
{
unsigned short bGIE;
bGIE = (__get_SR_register() &GIE); //save interrupt status
__disable_interrupt(); //disable interrupts - atomic operation
*size = (HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSend - HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft);
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSend = 0;
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft = 0;
__bis_SR_register(bGIE); //restore interrupt status
return kUSB_succeed;
}
示例3: USBPHDC_abortSend
/*
* Aborts an active send operation on interface intfNum.
* Returns the number of bytes that were sent prior to the abort, in size.
*/
uint8_t USBPHDC_abortSend (uint16_t* size, uint8_t intfNum)
{
uint8_t edbIndex;
uint16_t state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableInEndpointInterrupt(edbIndex);
*size =
(PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSend -
PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSendLeft);
PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSend = 0;
PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSendLeft = 0;
usbRestoreInEndpointInterrupt(state);
return (USB_SUCCEED);
}
示例4: USBPHDC_abortSend
/*
* Aborts an active send operation on interface intfNum.
* Returns the number of bytes that were sent prior to the abort, in size.
*/
BYTE USBPHDC_abortSend (WORD* size, BYTE intfNum)
{
BYTE edbIndex;
WORD state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableInEndpointInterrupt(edbIndex);
*size =
(PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSend -
PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSendLeft);
PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSend = 0;
PHDCWriteCtrl[INTFNUM_OFFSET(intfNum)].nPHDCBytesToSendLeft = 0;
usbRestoreInEndpointInterrupt(state);
return (kUSB_succeed);
}
示例5: USBHID_sendData
/*
Sends data over interface intfNum, of size size and starting at address data.
Returns: kUSBHID_sendStarted
kUSBHID_sendComplete
kUSBHID_intBusyError
*/
BYTE USBHID_sendData(const BYTE* data, WORD size, BYTE intfNum)
{
unsigned short bGIE;
BYTE edbIndex;
edbIndex = stUsbHandle[intfNum].edb_Index;
if (size == 0)
{
return kUSBHID_generalError;
}
bGIE = (__get_SR_register() &GIE); //save interrupt status
// atomic operation - disable interrupts
__disable_interrupt(); // Disable global interrupts
// do not access USB memory if suspended (PLL off). It may produce BUS_ERROR
if ((bFunctionSuspended) ||
(bEnumerationStatus != ENUMERATION_COMPLETE))
{
// data can not be read because of USB suspended
__bis_SR_register(bGIE); //restore interrupt status
return kUSBHID_busNotAvailable;
}
if (HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft != 0)
{
// the USB still sends previous data, we have to wait
__bis_SR_register(bGIE); //restore interrupt status
return kUSBHID_intfBusyError;
}
//This function generate the USB interrupt. The data will be sent out from interrupt
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSend = size;
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft = size;
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].pHidBufferToSend = data;
//trigger Endpoint Interrupt - to start send operation
USBIEPIFG |= 1<<(edbIndex+1); //IEPIFGx;
__bis_SR_register(bGIE); //restore interrupt status
return kUSBHID_sendStarted;
}
示例6: USBCDC_abortSend
/*
* Aborts an active send operation on interface intfNum.
* Returns the number of bytes that were sent prior to the abort, in size.
*/
BYTE USBCDC_abortSend (WORD* size, BYTE intfNum)
{
BYTE edbIndex;
WORD state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableInEndpointInterrupt(edbIndex); //disable interrupts - atomic operation
*size =
(CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSend -
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSendLeft);
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSend = 0;
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSendLeft = 0;
usbRestoreInEndpointInterrupt(state);
return (kUSB_succeed);
}
示例7: CdcToBufferFromHost_Bridge
//this function is used only by USB interrupt.
//It fills user receiving buffer with received data
BOOL CdcToBufferFromHost_Bridge (BYTE intfNum)
{
BYTE *pEP1, *pCT1;
BYTE nTmp1;
BYTE bWakeUp = FALSE; //per default we do not wake up after interrupt
BYTE i;
BYTE edbIndex;
edbIndex = stUsbHandle[intfNum].edb_Index;
//No data to receive...
if (!((tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX & 0x80))){
return (bWakeUp);
}
if (CdcBridgeCtrl.ctsState == 0) {
return (bWakeUp);
}
//this is the active EP buffer
pEP1 = (BYTE*)stUsbHandle[intfNum].oep_X_Buffer;
pCT1 = &tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX;
__no_operation();
__no_operation();
//how many byte we can get from endpoint buffer
nTmp1 = *pCT1;
if (nTmp1 & EPBCNT_NAK){
nTmp1 = nTmp1 & 0x7f; //clear NAK bit
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesInEp = nTmp1; //holds how many valid bytes in the EP buffer
if (nTmp1 > 0) {
//Start DMA
if (nTmp1 > 5 ) {
//Start DMA
while (!(*CdcBridgeCtrl.uartIFG & UCTXIFG));
*CdcBridgeCtrl.uartTx = *pEP1;
*CdcBridgeCtrl.usbToUartDmaChSz = nTmp1 - 1; // Block size
*CdcBridgeCtrl.usbToUartDmaChCtl = DMADT_0 + DMASRCINCR_3 + DMASBDB + DMAEN + DMAIE;// Rpt, inc src, enable
}
else {
for (i = 0; i < nTmp1; i++) {
while (!(*CdcBridgeCtrl.uartIFG & UCTXIFG)); // USCI_A0 TX buffer ready?
*CdcBridgeCtrl.uartTx = *pEP1++; // TX -> RXed character
}
*pCT1 = 0x00;
}
}
else {
*pCT1 = 0x00;
}
}
return (bWakeUp);
}
示例8: USBCDC_abortSend
uint8_t USBCDC_abortSend (uint16_t* size, uint8_t intfNum)
{
uint8_t edbIndex;
uint16_t state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableInEndpointInterrupt(edbIndex); //disable interrupts - atomic operation
*size =
(CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSend -
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSendLeft);
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSend = 0;
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSendLeft = 0;
usbRestoreInEndpointInterrupt(state);
return (USB_SUCCEED);
}
示例9: USBHID_sendData
/*
* Sends data over interface intfNum, of size size and starting at address data.
* Returns: kUSBHID_sendStarted
* kUSBHID_sendComplete
* kUSBHID_intBusyError
*/
BYTE USBHID_sendData (const BYTE* data, WORD size, BYTE intfNum)
{
WORD state;
BYTE edbIndex;
edbIndex = stUsbHandle[intfNum].edb_Index;
if (size == 0){
return (kUSBHID_generalError);
}
state = usbDisableInEndpointInterrupt(edbIndex);
//atomic operation - disable interrupts
//do not access USB memory if suspended (PLL off). It may produce BUS_ERROR
if ((bFunctionSuspended) ||
(bEnumerationStatus != ENUMERATION_COMPLETE)){
//data can not be read because of USB suspended
usbRestoreInEndpointInterrupt(state);
return (kUSBHID_busNotAvailable);
}
if (HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft != 0){
//the USB still sends previous data, we have to wait
usbRestoreInEndpointInterrupt(state);
return (kUSBHID_intfBusyError);
}
//This function generate the USB interrupt. The data will be sent out from interrupt
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSend = size;
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].nHidBytesToSendLeft = size;
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].pHidBufferToSend = data;
//trigger Endpoint Interrupt - to start send operation
USBIEPIFG |= 1 << (edbIndex + 1); //IEPIFGx;
usbRestoreInEndpointInterrupt(state);
return (kUSBHID_sendStarted);
}
示例10: USBHID_rejectData
/*
* This function rejects payload data that has been received from the host.
*/
BYTE USBHID_rejectData (BYTE intfNum)
{
WORD state;
BYTE edbIndex;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableOutEndpointInterrupt(edbIndex);
//interrupts disable
//do not access USB memory if suspended (PLL off). It may produce BUS_ERROR
if (bFunctionSuspended){
usbRestoreOutEndpointInterrupt(state);
return (kUSBHID_busNotAvailable);
}
//Is receive operation underway?
//- do not flush buffers if any operation still active.
if (!HidReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer){
BYTE tmp1 = tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX &
EPBCNT_NAK;
BYTE tmp2 = tOutputEndPointDescriptorBlock[edbIndex].bEPBCTY &
EPBCNT_NAK;
if (tmp1 ^ tmp2){ //switch current buffer if any and only ONE of the
//buffers is full
//switch current buffer
HidReadCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY =
(HidReadCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY +
1) & 0x01;
}
tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX = 0; //flush buffer X
tOutputEndPointDescriptorBlock[edbIndex].bEPBCTY = 0; //flush buffer Y
HidReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesInEp = 0; //indicates that no more data available in the EP
}
usbRestoreOutEndpointInterrupt(state);
return (kUSB_succeed);
}
示例11: USBCDC_abortReceive
/*
* Aborts an active receive operation on interface intfNum.
* Returns the number of bytes that were received and transferred
* to the data location established for this receive operation.
*/
BYTE USBCDC_abortReceive (WORD* size, BYTE intfNum)
{
//interrupts disable
BYTE edbIndex;
WORD state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableOutEndpointInterrupt(edbIndex);
*size = 0; //set received bytes count to 0
//is receive operation underway?
if (CdcReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer){
//how many bytes are already received?
*size = CdcReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceive -
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceiveLeft;
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesInEp = 0;
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer = NULL;
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceiveLeft = 0;
}
//restore interrupt status
usbRestoreOutEndpointInterrupt(state);
return (kUSB_succeed);
}
示例12: USBCDC_rejectData
uint8_t USBCDC_rejectData (uint8_t intfNum)
{
uint8_t edbIndex;
uint16_t state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableOutEndpointInterrupt(edbIndex);
//atomic operation - disable interrupts
//do not access USB memory if suspended (PLL off). It may produce BUS_ERROR
if (bFunctionSuspended){
usbRestoreOutEndpointInterrupt(state);
return (USBCDC_BUS_NOT_AVAILABLE);
}
//Is receive operation underway?
//- do not flush buffers if any operation still active.
if (!CdcReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer){
uint8_t tmp1 = tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX &
EPBCNT_NAK;
uint8_t tmp2 = tOutputEndPointDescriptorBlock[edbIndex].bEPBCTY &
EPBCNT_NAK;
if (tmp1 ^ tmp2){ //switch current buffer if any and only ONE of buffers
//is full
//switch current buffer
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY =
(CdcReadCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY +
1) & 0x01;
}
tOutputEndPointDescriptorBlock[edbIndex].bEPBCTX = 0; //flush buffer X
tOutputEndPointDescriptorBlock[edbIndex].bEPBCTY = 0; //flush buffer Y
CdcReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesInEp = 0; //indicates that no more data available in the EP
}
usbRestoreOutEndpointInterrupt(state);
return (USB_SUCCEED);
}
示例13: USBCDC_sendData
uint8_t USBCDC_sendData (const uint8_t* data, uint16_t size, uint8_t intfNum)
{
uint8_t edbIndex;
uint16_t state;
edbIndex = stUsbHandle[intfNum].edb_Index;
if (size == 0){
return (USBCDC_GENERAL_ERROR);
}
state = usbDisableInEndpointInterrupt(edbIndex);
//do not access USB memory if suspended (PLL uce BUS_ERROR
if ((bFunctionSuspended) ||
(bEnumerationStatus != ENUMERATION_COMPLETE)){
//data can not be read because of USB suspended
usbRestoreInEndpointInterrupt(state); //restore interrupt status
return (USBCDC_BUS_NOT_AVAILABLE);
}
if (CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSendLeft != 0){
//the USB still sends previous data, we have to wait
usbRestoreInEndpointInterrupt(state); //restore interrupt status
return (USBCDC_INTERFACE_BUSY_ERROR);
}
//This function generate the USB interrupt. The data will be sent out from interrupt
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSend = size;
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].nCdcBytesToSendLeft = size;
CdcWriteCtrl[INTFNUM_OFFSET(intfNum)].pUsbBufferToSend = data;
//trigger Endpoint Interrupt - to start send operation
USBIEPIFG |= 1 << (edbIndex + 1); //IEPIFGx;
usbRestoreInEndpointInterrupt(state);
return (USBCDC_SEND_STARTED);
}
示例14: USBPHDC_abortReceive
/*
* Aborts an active receive operation on interface intfNum.
* Returns the number of bytes that were received and transferred
* to the data location established for this receive operation.
*/
uint8_t USBPHDC_abortReceive (uint16_t* size, uint8_t intfNum)
{
uint16_t state;
edbIndex = stUsbHandle[intfNum].edb_Index;
state = usbDisableOutEndpointInterrupt(edbIndex);
*size = 0; //set received bytes count to 0
//is receive operation underway?
if (PHDCReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer){
//how many bytes are already received?
*size = PHDCReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceive -
PHDCReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceiveLeft;
PHDCReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesInEp = 0;
PHDCReadCtrl[INTFNUM_OFFSET(intfNum)].pUserBuffer = NULL;
PHDCReadCtrl[INTFNUM_OFFSET(intfNum)].nBytesToReceiveLeft = 0;
}
//restore interrupt status
usbRestoreOutEndpointInterrupt(state);
return (USB_SUCCEED);
}
示例15: USBHID_sendReport
/*
Sends a pre-built report reportData to the host.
Returns: kUSBHID_sendComplete
kUSBHID_intfBusyError
kUSBCDC_busNotAvailable
*/
BYTE USBHID_sendReport(const BYTE * reportData, BYTE intfNum)
{
BYTE byte_count;
BYTE * pEP1;
BYTE * pCT1;
BYTE edbIndex;
edbIndex = stUsbHandle[intfNum].edb_Index;
// do not access USB memory if suspended (PLL off). It may produce BUS_ERROR
if ((bFunctionSuspended) ||
(bEnumerationStatus != ENUMERATION_COMPLETE))
{
return kUSBHID_busNotAvailable;
}
if (HidWriteCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY == X_BUFFER)
{
//this is the active EP buffer
pEP1 = (BYTE*)stUsbHandle[intfNum].iep_X_Buffer;
pCT1 = &tInputEndPointDescriptorBlock[edbIndex].bEPBCTX;
}
else
{
//this is the active EP buffer
pEP1 = (BYTE*)stUsbHandle[intfNum].iep_Y_Buffer;
pCT1 = &tInputEndPointDescriptorBlock[edbIndex].bEPBCTY;
}
byte_count = USBHID_REPORT_LENGTH; // we support only one length of report
if(*pCT1 & EPBCNT_NAK) // if this EP is empty
{
USB_TX_memcpy(pEP1, reportData, byte_count); // copy data into IEP X or Y buffer
*pCT1 = byte_count; // Set counter for usb In-Transaction
HidWriteCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY = (HidWriteCtrl[INTFNUM_OFFSET(intfNum)].bCurrentBufferXY+1)&0x01; //switch buffer
return kUSBHID_sendComplete;
}
return kUSBHID_intfBusyError;
}