📄 sppreceive.c
字号:
/*****************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC1010 *
* *** + + *** CUL - spp *
* *** +++ *** *
* *** *** *
* *********** *
* ********* *
* *
*****************************************************************************
* *
*****************************************************************************
* Author: JOL *
*****************************************************************************
* Revision history: *
* *
* $Log: sppReceive.c,v $
* Revision 1.1 2002/10/14 12:27:33 tos
* Initial version in CVS.
*
* *
****************************************************************************/
#include <chipcon/sppInternal.h>
//----------------------------------------------------------------------------
// byte sppReceive (SPP_RX_INFO xdata* pRXInfo)
//
// Description:
// If the transceiver is ready (in idle mode), the receive section will
// be powered up and the RF interrupt enabled. The RF ISR will then
// receive the packet and transmit an ack if requested to. When finished,
// the receive section will be powered down.
//
// This function will return immediately and the application can
// continue while the ISR receives the packet. When finished, sppStatus()
// will return IDLE_MODE. During the transmission it will
// return RX_MODE or RXACK_MODE.
//
// After the reception: Use pRXInfo->status to find out what happened:
// SPP_RX_TIMEOUT = Timeout (nothing received).
// SPP_RX_TOO_LONG = dataLen > maxDataLen (the buffer is invalid).
// SPP_RX_FINISHED = source, dataLen and *pDataBuffer in *pRXInfo
// are valid.
//
// Arguments:
// SPP_RX_INFO xdata *pRXInfo
// An SPP_RX_INFO struct must be prepared before the reception,
// including the following values:
// maxDataLen (Length of the data buffer, 0-255)
// pDataBuffer (pointer to the reception buffer)
//
// Return value:
// byte
// SPP_RX_STARTED if OK
// SPP_BUSY if not ready
//----------------------------------------------------------------------------
byte sppReceive (SPP_RX_INFO xdata *pRXInfo) {
INT_GLOBAL_ENABLE (INT_OFF);
// Begin reception only if we're in the idle state
if (sppIntData.mode == SPP_IDLE_MODE) {
// Initialize the fsm
sppRFStateFunc = RX_WAIT;
sppIntData.mode = SPP_RX_MODE;
sppIntData.pRXI = pRXInfo;
sppIntData.pRXI->status = SPP_RX_WAITING;
// Activate receive timeout (disable timer 3 while we're changing the 16-bit number)
if (sppSettings.rxTimeout) {
SPP_ENABLE_TIMEOUT(sppSettings.rxTimeout);
} else {
SPP_DISABLE_TIMEOUT();
}
INT_GLOBAL_ENABLE (INT_ON);
// Enable transceiver interrupt and enter the FSM
INT_SETFLAG (INUM_RF, INT_CLR);
INT_PRIORITY (INUM_RF, INT_HIGH);
INT_ENABLE (INUM_RF, INT_ON);
// Power up for RX
SPP_POWER_UP_RX();
return SPP_RX_STARTED;
} else {
INT_GLOBAL_ENABLE (INT_ON);
return SPP_BUSY;
}
} // sppReceive
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -