📄 mac_timer.h
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC2420 INTEGRATED 802.15.4 MAC AND PHY *
* *** + + *** Low-Level Timing Functions *
* *** +++ *** *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* CONFIDENTIAL *
* The use of this file is restricted by the signed MAC software license agreement. *
* *
* Copyright Chipcon AS, 2004 *
*******************************************************************************************************
* This module contains the MAC callback timer, which is used to handle timer events, and start the *
* execution of tasks. handles. The timer generates a T1.COMPA interrupt at every *
* 320 usecs = 20 symbols = 1 backoff slot. *
* *
* Command strobes that need to be aligned with backoff slot boundary must use the WAIT_FOR_BOUNADRY() *
* macro. *
* *
* NOTE: These functions are meant to be used with an 8 MHz crystal oscillator! *
*******************************************************************************************************
* Compiler: NEC Electronics PM plus V5.20 *
* Target platform: CC2420DB, CC2420 + 78K0/KF2 *
*******************************************************************************************************
* The revision history is located at the bottom of this file *
*******************************************************************************************************/
#ifndef MAC_TIMER_H
#define MAC_TIMER_H
/*******************************************************************************************************
*******************************************************************************************************
************************** CONSTANTS AND MACROS **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// The timer overflow value
#if CLOCK_16MHZ
#define CLOCK_SPEED_MHZ 16 // MHz
#else
#define CLOCK_SPEED_MHZ 8 // MHz
#endif
///#define CLOCK_SPEED_MHZ 8 // MHz///
#define MAC_SYMBOL_DURATION 16 // us
#define MAC_TIMER_OVERFLOW_VALUE (CLOCK_SPEED_MHZ * MAC_SYMBOL_DURATION * aUnitBackoffPeriod - 1)
// Backoff slot boundary offset (1/4 into the timer tick interval)
#define MAC_TIMER_BACKOFF_SLOT_OFFSET ((MAC_TIMER_OVERFLOW_VALUE + 1) / 4)
// Waits for the next backoff slot boandary (global interrupts should be turned off!)
//KF1 #define WAIT_FOR_BOUNDARY() while (!(TMIF001))
///#define WAIT_FOR_BOUNDARY() while (!(TMIF51))
#define WAIT_FOR_BOUNDARY() while (!(TMIF010))///
// The number of callbacks available in the pool
#define MAC_CALLBACK_COUNT 12
// Callback queue terminator
#define NO_CALLBACK 0xFF
//-------------------------------------------------------------------------------------------------------
/*******************************************************************************************************
*******************************************************************************************************
************************** MODULE DATA **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// Internal module data
// Callback table
typedef struct {
VFPTR pFunc;
INT32 timeout;
UINT8 nextCallback;
UINT8 prevCallback;
ZBOOL occupied;
} MAC_CALLBACK_INFO;
// Backoff slot counter
typedef struct {
INT32 volatile bosCounter;
UINT32 captureTime;
UINT32 captureBosCounter;
UINT16 captureTcnt;
UINT32 bosCounterAdjustTime;
UINT8 beaconDuration;
UINT8 volatile nextCallback;
} MAC_TIMER_INFO;
extern __sreg MAC_TIMER_INFO mtimInfo;
//-------------------------------------------------------------------------------------------------------
/*******************************************************************************************************
*******************************************************************************************************
************************** FUNCTION PROTOTYPES **************************
*******************************************************************************************************
*******************************************************************************************************/
//-------------------------------------------------------------------------------------------------------
// Callback timer setup (timeout in backoff slots (rounded downwards)
void mtimInit(void);
ZBOOL mtimSetCallback(VFPTR pFunc, INT32 timeout);
ZBOOL mtimCancelCallback(void *pFunc);
// Callback timer adjustments (align this node's timer with the last received beacon)
void mtimAlignWithBeacon(void);
//-------------------------------------------------------------------------------------------------------
#endif
/*******************************************************************************************************
* Revision history:
*
* $Log: mac_timer.h,v $
* Revision 1.5 2004/08/13 13:04:44 jol
* CC2420 MAC Release v0.7
*
*
*******************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -