📄 cul.h
字号:
/*****************************************************************************
*****************************************************************************
************* Timer with Callback *************
*****************************************************************************
****************************************************************************/
// SPP supports 2 custom callbacks which can be set dynamically
//----------------------------------------------------------------------------
// void sppSetTimerCB (void)
//
// Description:
// Add timer callback
//
// Arguments:
// byte cb
// Callback index - use SPP_CUSTOM_0_TIMER or SPP_CUSTOM_1_TIMER
// The SPP finite state machine uses SPP_FSM_TIMER
// void (*pF) ()
// Pointer to the function to call
// word *pTicks
// The timeout in 10s of msecs
//
// NOTE: *pTicks will be decremented by the Timer 3 interrupt
//----------------------------------------------------------------------------
void sppSetTimerCB (byte cb, void (*pF) (), word *pTicks);
// Available callbacks
#define SPP_FSM_TIMER 0 // used by the SPP
#define SPP_CUSTOM_0_TIMER 1 // free
#define SPP_CUSTOM_1_TIMER 2 // free
//----------------------------------------------------------------------------
// word sppGetTime (void)
//
// Description:
// Returns the value of the 10-msec counter, which is started by
// sppSetupRF(...)
//
// Return value:
// The current time in 10s of msecs
//----------------------------------------------------------------------------
word sppGetTime (void);
//----------------------------------------------------------------------------
// MACRO: SPP_CHANGE_TICKS(var, value)
//
// Description:
// Use this macro to change the tick counter variables used with the
// callback timer
//
// Arguments
// (word) var
// The variable
// (word) value
// The new value
//----------------------------------------------------------------------------
#define SPP_CHANGE_TICKS(var, value) \
do { \
INT_ENABLE (INUM_TIMER3, INT_OFF); \
var = (word) value; \
INT_ENABLE (INUM_TIMER3, INT_ON); \
} while (0)
// sppInternal.h requires some of the type definitions listed above!
#include <chipcon/sppInternal.h>
/****************************************************************************/
/*****************************************************************************
*****************************************************************************
* *
* 00000 00000 0000 *
* 0 0 0 0 *
* 00000 0 0 - REAL TIME CLOCK - *
* 0 0 0 0 *
* 0 0 0 0000 *
* *
*****************************************************************************
*****************************************************************************
* The RealTime clock keeps track of the time. Its main advantage is that it *
* works even when the main clock source is changed, though with some *
* inaccuracy. *
*****************************************************************************
* Author: OGR *
****************************************************************************/
//----------------------------------------------------------------------------
// void RTstart()
//
// Description:
// Starts the real time clock.
//
// Arguments:
// None.
//
// Return value:
// void
//----------------------------------------------------------------------------
void RTstart();
//----------------------------------------------------------------------------
// void RTstop()
//
// Description:
// Stops the real time clock.
//
// Arguments:
// None.
//
// Return value:
// void
//----------------------------------------------------------------------------
void RTstop();
//----------------------------------------------------------------------------
// ulong getTime()
//
// Description:
// Reads the current time.
//
// Arguments:
// None.
//
// Return value:
// ulong
// The current time in microseconds.
//----------------------------------------------------------------------------
ulong getTime();
//----------------------------------------------------------------------------
// void setTime(...)
//
// Description:
// Sets the real time clock to the given time.
//
// Arguments:
// ulong time
// The current time in microseconds.
//
// Return value:
// void
//----------------------------------------------------------------------------
void setTime(ulong time);
//----------------------------------------------------------------------------
// void setModulus(...)
//
// Description:
// Specifies that whenever the time reaches the given value,
// it is reset to zero. A modulus of 0 cancels this effect.
//
// Arguments:
// ulong modulus
// The time will be measured modulo this value.
//
// Return value:
// void
//----------------------------------------------------------------------------
void setModulus(ulong modulus);
//----------------------------------------------------------------------------
// void useX32()
//
// Description:
// Switches to the 32 kHz crystal oscillator as main clock source.
// The oscillator must be powered up prior to calling this function.
// It is absolutely necessary to use this function when switching
// to the 32 kHz oscillator if the real time clock is to work properly.
//
// Arguments:
// None.
//
// Return value:
// void
//----------------------------------------------------------------------------
void useX32();
//----------------------------------------------------------------------------
// void useXOSC()
//
// Description:
// Switches to the main crystal oscillator as main clock source.
// The oscillator must be powered up prior to calling this function.
// It is absolutely necessary to use this function when switching
// to the main oscillator if the real time clock is to work properly.
//
// Arguments:
// None.
//
// Return value:
// void
//----------------------------------------------------------------------------
void useXOSC();
/****************************************************************************/
/*****************************************************************************
*****************************************************************************
* *
* 00000 0 0 0000 *
* 0 0 0 0 0 *
* 0000 00000 0000 - FREQUENCY HOPPING BASICS - *
* 0 0 0 0 0 *
* 0 0 0 0000 *
* *
*****************************************************************************
*****************************************************************************
* The basic methods for supporting frequency hopping include functions that *
* calibrate the frequencies and change between them. *
* When using FHP, the functions in FHB should not be called by the user *
* application as that can interfere with the operation of FHP. *
*****************************************************************************
* Author: OGR *
****************************************************************************/
typedef struct {
byte freq_2a; // RX channel frequency (A)
byte freq_1a;
byte freq_0a;
byte freq_2b; // TX channel frequency (B)
byte freq_1b;
byte freq_0b;
byte pll_rx; // refdiv
byte pll_tx; // refdiv
} FHP_RXTXPAIR_SETTINGS;
// The following variables must be declared by the user application.
// That is typically done in the file Definitions.c.
// See that file for details.
extern code FHP_RXTXPAIR_SETTINGS rxtxpair_settings[];
extern code RF_RXTXPAIR_SETTINGS RF_SETTINGS;
extern xdata byte numberOfFrequencies;
extern xdata RF_RXTXPAIR_CALDATA rxtxpair_caldata[];
extern xdata byte frequencyPermutation[];
// If the halRFOverrideXXX functions are being used,
// this variable must be set to TRUE.
extern xdata bool usingOverrides;
//----------------------------------------------------------------------------
// void initializeFrequencies()
//
// Description:
// Calibrates all the frequencies that are to be used.
// This function must be called before transmitting or receiving.
//
// Arguments:
// None.
//
// Return value:
// void
//----------------------------------------------------------------------------
void initializeFrequencies();
//----------------------------------------------------------------------------
// void changeFreq(...)
//
// Description:
// Used to change the current frequency and/or mode.
//
// Arguments:
// byte mode
// One of RF_OFF, RF_RX and RF_TX.
// byte increment
// The amount by which the position in the frequency
// hopping sequence will be advanced.
//
// Return value:
// void
//----------------------------------------------------------------------------
void changeFreq(byte mode, byte increment);
//----------------------------------------------------------------------------
// byte getFrequencyPosition()
//
// Description:
// Reads the current position in the frequency hopping sequence.
//
// Arguments:
// None.
//
// Return value:
// byte
// The current position.
//----------------------------------------------------------------------------
byte getFrequencyPosition();
//----------------------------------------------------------------------------
// void setFrequencyPosition(...)
//
// Description:
// Sets the current position in the frequency hopping sequence.
//
// Arguments:
// byte pos
// The new position in the sequence.
//
// Return value:
// void
//----------------------------------------------------------------------------
void setFrequencyPosition(byte pos);
/****************************************************************************/
/*****************************************************************************
*****************************************************************************
* *
* 00000 0 0 00000 *
* 0 0 0 0 0 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -