diff options
Diffstat (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c')
-rw-r--r-- | software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c | 323 |
1 files changed, 179 insertions, 144 deletions
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c index f765732..ef7a36b 100644 --- a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c +++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c @@ -2,7 +2,7 @@ File: oct6100_events.c - Copyright (c) 2001-2006 Octasic Inc. + Copyright (c) 2001-2007 Octasic Inc. Description: @@ -22,9 +22,9 @@ You should have received a copy of the GNU General Public License along with the OCT6100 GPL API; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -$Octasic_Release: OCT612xAPI-01.00-PR47 $ +$Octasic_Release: OCT612xAPI-01.00-PR48 $ -$Octasic_Revision: 80 $ +$Octasic_Revision: 81 $ \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ @@ -440,6 +440,7 @@ UINT32 Oct6100ApiTransferToneEvents( UINT32 ulBaseTimestamp; UINT32 ulToneCnt; UINT32 ulNumWordsToRead; + UINT32 ulEventCode; UINT32 ulResult; UINT32 i, j; @@ -587,38 +588,93 @@ UINT32 Oct6100ApiTransferToneEvents( /* Verify all the possible events that might have been detected. */ for ( j = 4; j < cOCT6100_NUM_WORDS_PER_TONE_EVENT; j++ ) { - if ( (( ausReadData[ j ] >> 8 ) & 0x7 ) != 0x0 ) + ulEventCode = ( ausReadData[ j ] >> 8 ) & 0x7; + + if ( ulEventCode != 0x0 ) { /* This tone generated an event, now check if event is masked for the channel. */ if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 ) { - /* If enough space. */ - if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && - ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + BOOL f2100Tone; + + /* Check if it is a 2100 Tone STOP and if the user wants receive those events*/ + ulResult = Oct6100ApiIs2100Tone(f_pApiInstance, + pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID, + &f2100Tone); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( (f2100Tone == FALSE) || + ( (f2100Tone == TRUE) && (ulEventCode != 2) ) || + ( (f2100Tone == TRUE) && pSharedInfo->ChipConfig.fEnable2100StopEvent == TRUE ) ) { - /* The tone event is not masked, The API can create a soft tone event. */ - mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) - pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; - - /* Decode the event type. */ - switch(( ausReadData[ j ] >> 8 ) & 0x7 ) + + /* If enough space. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) { - case 1: - pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; - break; - case 2: - pSoftEvent->ulEventType = cOCT6100_TONE_STOP; - break; - case 3: - /* This one is a little tricky. We first */ - /* generate the "PRESENT" event and then generate the "STOP" event. */ + /* The tone event is not masked, The API can create a soft tone event. */ + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + /* Decode the event type. */ + switch( ulEventCode ) + { + case 1: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + case 2: + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + break; + case 3: + /* This one is a little tricky. We first */ + /* generate the "PRESENT" event and then generate the "STOP" event. */ + + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */ + pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1; + pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* If enough space for the "STOP" event. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + continue; + } + + break; + case 4: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + default: + pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++; + /* do not process this packet*/ + continue; + } - pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; - /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */ - pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1; + pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; /* Update the control variables of the buffer. */ @@ -626,55 +682,17 @@ UINT32 Oct6100ApiTransferToneEvents( if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; - /* If enough space for the "STOP" event. */ - if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && - ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) - { - mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) - pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; - - pSoftEvent->ulEventType = cOCT6100_TONE_STOP; - } - else - { - /* Set the overflow flag of the buffer. */ - pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; - - /* We continue in the loop in order to empty the hardware buffer. */ - continue; - } - - break; - case 4: - pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; - break; - default: - pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++; - /* do not process this packet*/ - continue; + /* Set the interrupt manager such that the user knows that some tone events */ + /* are pending in the software Q. */ + pSharedInfo->IntrptManage.fToneEventsPending = TRUE; } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; - pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; - pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; - pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; - pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); - pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; - - /* Update the control variables of the buffer. */ - pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; - if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) - pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; - - /* Set the interrupt manager such that the user knows that some tone events */ - /* are pending in the software Q. */ - pSharedInfo->IntrptManage.fToneEventsPending = TRUE; - } - else - { - /* Set the overflow flag of the buffer. */ - pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; - - /* We continue in the loop in order to empty the hardware buffer. */ + /* We continue in the loop in order to empty the hardware buffer. */ + } } } else @@ -691,7 +709,7 @@ UINT32 Oct6100ApiTransferToneEvents( if ( fSSTone == TRUE ) { /* Check if this is a "PRESENT" or "STOP" event */ - switch( ( ( ausReadData[ j ] >> 8 ) & 0x7 ) ) + switch( ulEventCode ) { case 1: /* This is a signaling system present event. Keep this in the instance memory. */ @@ -710,39 +728,94 @@ UINT32 Oct6100ApiTransferToneEvents( } } ulToneCnt++; - + /* Check the other tone of this word. */ - if ( ( ausReadData[ j ] & 0x7 ) != 0x0 ) + ulEventCode = ausReadData[ j ] & 0x7; + + if ( ulEventCode != 0x0 ) { if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 ) { - /* If enough space. */ - if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && - ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + BOOL f2100Tone; + + /* Check if it is a 2100 Tone STOP and if the user wants receive those events*/ + ulResult = Oct6100ApiIs2100Tone(f_pApiInstance, + pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID, + &f2100Tone); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( (f2100Tone == FALSE) || + ( (f2100Tone == TRUE) && (ulEventCode != 2) ) || + ( (f2100Tone == TRUE) && pSharedInfo->ChipConfig.fEnable2100StopEvent == TRUE ) ) { - /* The tone event is not masked, The API can create a soft tone event. */ - mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) - pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; - - /* Decode the event type. */ - switch(( ausReadData[ j ] ) & 0x7 ) + + /* If enough space. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) { - case 1: - pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; - break; - case 2: - pSoftEvent->ulEventType = cOCT6100_TONE_STOP; - break; - case 3: - /* This one is a little tricky. We first */ - /* generate the "PRESENT" event and then generate the "STOP" event. */ + /* The tone event is not masked, The API can create a soft tone event. */ + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + /* Decode the event type. */ + switch( ulEventCode ) + { + case 1: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + case 2: + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + break; + case 3: + /* This one is a little tricky. We first */ + /* generate the "PRESENT" event and then generate the "STOP" event. */ + + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */ + pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1; + pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* If enough space for the "STOP" event. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + continue; + } + + break; + case 4: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + default: + pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++; + /* Do not process this packet. */ + continue; + } - pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; - /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */ - pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1; + pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; /* Update the control variables of the buffer. */ @@ -750,56 +823,18 @@ UINT32 Oct6100ApiTransferToneEvents( if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; - /* If enough space for the "STOP" event. */ - if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && - ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) - { - mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) - pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; - - pSoftEvent->ulEventType = cOCT6100_TONE_STOP; - } - else - { - /* Set the overflow flag of the buffer. */ - pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + /* Set the interrupt manager such that the user knows that some tone events */ + /* are pending in the software Q. */ + pSharedInfo->IntrptManage.fToneEventsPending = TRUE; - /* We continue in the loop in order to empty the hardware buffer. */ - continue; - } - - break; - case 4: - pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; - break; - default: - pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++; - /* Do not process this packet. */ - continue; } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; - pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; - pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; - pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; - pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); - pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; - - /* Update the control variables of the buffer. */ - pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; - if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) - pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; - - /* Set the interrupt manager such that the user knows that some tone events */ - /* are pending in the software Q. */ - pSharedInfo->IntrptManage.fToneEventsPending = TRUE; - - } - else - { - /* Set the overflow flag of the buffer. */ - pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; - - /* We continue in the loop in order to empty the hardware buffer. */ + /* We continue in the loop in order to empty the hardware buffer. */ + } } } else @@ -816,7 +851,7 @@ UINT32 Oct6100ApiTransferToneEvents( if ( fSSTone == TRUE ) { /* Check if this is a "PRESENT" event. */ - switch ( ( ausReadData[ j ] ) & 0x7 ) + switch ( ulEventCode ) { case 1: /* This is a signaling system present event. Keep this in the instance memory. */ |