⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sppinternal.h

📁 ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有底层驱动源码
💻 H
字号:
/*****************************************************************************
 *                                                                           *
 *        **********                                                         *
 *       ************                                                        *
 *      ***        ***                                                       *
 *      ***   +++   ***                                                      *
 *      ***   + +   ***                                                      *
 *      ***   +                            CHIPCON CC1010                    *
 *      ***   + +   ***           CUL SIMPLE PACKET PROTOCOL (SPP)           *
 *      ***   +++   ***                 INTERNAL HEADER FILE                 *
 *      ***       ***                                                        *
 *       ***********                                                         *
 *        *********                                                          *
 *                                                                           *
 *****************************************************************************
 * Internal header file for the CUL simple packet protocol.                  *
 *****************************************************************************
 * Author:              JOL                                                  *
 *****************************************************************************
 * Revision history:                                                         *
 * 1.0  2002/06/17      First Public Release                                 *
 *                                                                           *
 * $Log: sppInternal.h,v $
 * Revision 1.1  2002/10/14 11:49:09  tos
 * Initial version in CVS.
 *
 *                                                                           *
 ****************************************************************************/

#ifndef SPP_INTERNAL_H
#define SPP_INTERNAL_H

#include <chipcon/cul.h>




//----------------------------------------------------------------------------
// The states of the SPP finite state machine (implemented in sppISR.c)
//
// Note: The mode definitions in spp.h (.._MODE) must equal the masks defined 
//       here (.._MASK)

typedef void (code *pCBF) ();
extern pCBF xdata sppRFStateFunc;

// TX
void TX_START (void);
void TX_PREAMBLE (void);
void TX_SYNC (void);
void TX_DAB (void);
void TX_SAB (void);
void TX_DATA_LEN (void);
void TX_FLAG (void);
void TX_CRC8 (void);
void TX_DBX_START (void);
void TX_DBX (void);
void TX_CRC16_DATA_H (void);
void TX_CRC16_DATA_L (void);
void TX_ZEROPAD_START (void);
void TX_ZEROPAD (void);

// TXACK
void TXACK_START (void);
void TXACK_WAIT (void);
void TXACK_DAB (void);
void TXACK_SAB (void);
void TXACK_DATA_LEN (void);
void TXACK_FLAG (void);
void TXACK_CRC8 (void);

// RX
void RX_WAIT (void);
void RX_DAB (void);
void RX_SAB (void);
void RX_DATA_LEN (void);
void RX_FLAG (void);
void RX_CRC8_HEADER (void);
void RX_DBX_START (void);
void RX_DBX (void);
void RX_CRC16_DATA_H (void);
void RX_CRC16_DATA_L (void);

// RXACK
void RXACK_START (void);
void RXACK_PREAMBLE (void);
void RXACK_SYNC (void);
void RXACK_DAB (void);
void RXACK_SAB (void);
void RXACK_DATA_LEN (void);
void RXACK_FLAG (void);
void RXACK_CRC8 (void);
void RXACK_ZEROPAD (void);
//----------------------------------------------------------------------------




//----------------------------------------------------------------------------
// The internal data struct
typedef struct {
	SPP_RX_INFO xdata* pRXI;
	SPP_TX_INFO xdata* pTXI;
	RF_RXTXPAIR_SETTINGS code* pRF_SETTINGS;
	RF_RXTXPAIR_CALDATA xdata* pRF_CALDATA;
	byte counter;
	byte crc8;
	word crc16;
	byte mode;
	word toTicks;
	byte usedTxAttempts;
} SPP_INTERNAL_DATA;

// This struct is declared in sppISR.c
extern SPP_INTERNAL_DATA xdata sppIntData;
//----------------------------------------------------------------------------

// Faster version of void sppStatus (void)
#define SPP_STATUS() (sppIntData.mode)




//----------------------------------------------------------------------------
// Tranceiver macros:
#define SPP_POWER_UP_TX()															\
	do { 																			\
		halRFSetRxTxOff (RF_TX, sppIntData.pRF_SETTINGS, sppIntData.pRF_CALDATA);	\
		RFCON|=0x01;																\
		RF_SEND_BYTE(RF_PREAMBLE_BYTE);												\
		RF_START_TX();                                    							\
	} while (0)

// Fast version of SPP_POWER_UP_TX() (used to switch from RX to TX in the FSM)
#define SPP_FAST_POWER_UP_TX()                             \
	do {                                                   \
		PLL = sppIntData.pRF_SETTINGS->pll_tx;             \
		RFMAIN = 0xF0;                                     \
        TEST5 = 0x10 | sppIntData.pRF_CALDATA->vco_ao_tx;  \
        TEST6 = 0x3B;                                      \
        CURRENT = sppIntData.pRF_SETTINGS->current_tx;     \
		RFCON|=0x01;								       \
		RF_SEND_BYTE(RF_PREAMBLE_BYTE);					   \
		RF_START_TX();                                     \
	} while (0)


#define SPP_POWER_UP_RX()															\
	do { 																			\
		halRFSetRxTxOff (RF_RX, sppIntData.pRF_SETTINGS, sppIntData.pRF_CALDATA);	\
		RF_START_RX();																\
	} while (0)

// Fast version of SPP_POWER_UP_RX() (used to switch from TX to RX in the FSM)
#define SPP_FAST_POWER_UP_RX()                             \
	do {                                                   \
		PLL = sppIntData.pRF_SETTINGS->pll_rx;             \
        RFMAIN = 0x30;                                     \
        TEST5 = 0x10 | sppIntData.pRF_CALDATA->vco_ao_rx;  \
        TEST6 = 0x20 | sppIntData.pRF_CALDATA->chp_co_rx;  \
        CURRENT = sppIntData.pRF_SETTINGS->current_rx;     \
		RF_START_RX();                                     \
    } while (0)                               


#define SPP_POWER_DOWN() SPP_FAST_POWER_DOWN() // equivalent to halRFSetRxTxOff(RF_OFF, 0, 0), but faster

// Fast version of SPP_POWER_UP_TX()
#define SPP_FAST_POWER_DOWN() (RFMAIN = 0x38)
//----------------------------------------------------------------------------




//----------------------------------------------------------------------------
//  void sppStartTimer (void)
//
//  Description:
//		Run timer3 with a period of 10 msecs.
//
//	Arguments:
//		word clkFreq
//			The XOSC clock frequency in kHz.
//----------------------------------------------------------------------------
void sppStartTimer (word clkFreq);




//----------------------------------------------------------------------------
//  void sppTimeout(void)
//
//  Description:
//		Timeout
//		Callback from sxpTimer: TIMER3_ISR()
//----------------------------------------------------------------------------
void sppTimeout(void);




//----------------------------------------------------------------------------
//  MACRO: SPP_INIT_TIMEOUTS
//
//  Description:
//      Initialize timeouts by adding sppTimeout() to the sxpTimer callback.
//----------------------------------------------------------------------------
#define SPP_INIT_TIMEOUTS() (sppSetTimerCB(SPP_FSM_TIMER, sppTimeout, &sppIntData.toTicks))




//----------------------------------------------------------------------------
//  SPP_ENABLE_TIMEOUT(int timeout), SPP_DISABLE_TIMEOUT()
//
//  Description:
//      Enables or disables the SPP timeout, which is used in the TXACK and RX 
//		modes. sppIntData.toTicks will count from _timeout down to 0.
//		The timeout uses timer 3 (sxpTimer.c/h).
//
//	Arguments:
//		int timeout
//			The timeout (in 10s of msecs)
//----------------------------------------------------------------------------
#define SPP_ENABLE_TIMEOUT(x) (sppIntData.toTicks = x)
#define SPP_DISABLE_TIMEOUT() (sppIntData.toTicks = 0)


// The tick function:
void sppTimerTick (void);


#endif // SPP_INTERNAL_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -