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

📄 cul.h

📁 ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有底层驱动源码
💻 H
📖 第 1 页 / 共 4 页
字号:
 *     0000   00000  00000          - FREQUENCY HOPPING PROTOCOL -           *
 *     0      0   0  0                                                       *
 *     0      0   0  0                                                       *
 *                                                                           *
 *****************************************************************************
 *****************************************************************************
 * The Frequency Hopping Protocol (FHP) is a complete suite that easily      *
 * allows applications to benefit from the advantages of frequency hopping.  *
 *****************************************************************************
 * Author:              OGR                                                  *
 ****************************************************************************/

// This struct contains the settings used by FHP.
// An instance of this struct named fhpSettings must be declared by the user
// application and specify the preferred settings.
// That is typically done in the file Definitions.c.
typedef struct {
	word period;                // The period in milliseconds between beacons
	byte overhead;              // The approximate time in milliseconds that passes from the chip is interrupted to the beacon is received
	byte slotSize;              // The time in milliseconds a slave uses to transmit a request to send a packet
	byte timeslots;             // The number of slotSize periods the master will listen for requests
	byte listenTime;            // The timeout in tenths of milliseconds when listening for beacons, packets and acknowledgements
	bool useLEDs;               // If TRUE, status information is displayed on the LEDs on the evaluation board.
	bool useAck;                // If TRUE, all non-broadcasted packets are acknowledged.
	word clkFreq;               // The clock frequency of the main crystal oscillator of the chip in kilohertz
} FHP_SETTINGS;

extern xdata FHP_SETTINGS fhpSettings;


#define BROADCASTID 0

// An incoming packet is placed in the buffer message,
// and its length in messageLength.
extern xdata byte messageLength;
extern xdata byte message[];



//----------------------------------------------------------------------------
//  void initializeFHP(...)
//
//  Description:
//      Used to initialize the FHP protocol as either a master or a slave.
//      Frequencies are calibrated and timers are set up.
//
//  Arguments:
//      bool master
//          TRUE if master, FALSE if slave
//          
//  Return value:
//      void
//----------------------------------------------------------------------------
void initializeFHP(bool master);


//----------------------------------------------------------------------------
//  void setMode(...)
//
//  Description:
//      Determines how active the FHP will be.
//      If the FHP is set up as master, there are two alternatives:
//       - OFF:     The FHP is turned off and does nothing
//       - ACTIVE:  Beacons are transmitted periodically,
//                  packets from the slaves are received and
//                  any packets sent with newSending are transmitted.
//      If the FHP is set up as slave, there are three alternatives:
//       - OFF:     The FHP is turned off and does nothing
//       - PASSIVE: A timer is running in the background keeping track of
//                  where in the frequency sequence the master is.
//                  Packets sent with newSending are transmitted fast,
//                  but nothing is received (unless possibly when
//                  transmitting a packet itself).
//       - ACTIVE:  The FHP listens for every beacon transmitted by
//                  the master. Thus, the communication is full duplex.
//
//  Arguments:
//      byte mode
//          One of OFF, PASSIVE or ACTIVE
//
//  Return value:
//      void
//----------------------------------------------------------------------------
void setMode(byte mode);
#define OFF      0
#define PASSIVE  1
#define ACTIVE   2


//----------------------------------------------------------------------------
//  void setReceivingFunction(...)
//
//  Description:
//      Used to specify which function should be called when
//      a packet arrives. The function may simply set a flag to
//      indicate the arrival, or it may process the packet itself.
//      The packet is available in the buffer message until a new
//      packet arrives.
//      An argument of NULL specifies that no function will be called.
//      This is the default behaviour on start-up.
//
//  Arguments:
//      void (*pF) ()
//          A pointer to the function that will be notified of new packets.
//
//  Return value:
//      void
//----------------------------------------------------------------------------
void setReceivingFunction( void (*pF) () );

//----------------------------------------------------------------------------
//  void setCallbackFunction(...)
//
//  Description:
//      Used to specify which function should be called when
//      a packet is successfully sent.
//      An argument of NULL specifies that no function will be called.
//      This is the default behaviour on start-up.
//
//  Arguments:
//      void (*pF) ()
//          A pointer to the function that will be notified
//          of successful transmissions.
//
//  Return value:
//      void
//----------------------------------------------------------------------------
void setCallbackFunction( void (*pF) () );

//----------------------------------------------------------------------------
//  void setSynchronizationFailedFunction(...)
//
//  Description:
//      Used to specify which function should be called when
//      an acquisition attempt is unsuccessful.
//      The user application must then initiate a new attempt.
//      This could be done in a number of ways:
//        - calling the synchronize function
//        - calling setMode(ACTIVE)
//        - sending a new packet if in the PASSIVE mode
//          (any previous packet must be canceled)
//      An argument of NULL specifies that the FHP should go on trying
//      to synchronize until it is successful instead of calling a
//      user function. This is the default behaviour on start-up.
//
//  Arguments:
//      void (*pF) ()
//          A pointer to the function that will be notified failed acquisitions.
//
//  Return value:
//      void
//----------------------------------------------------------------------------
void setSynchronizationFailedFunction( void (*pF) () );

//----------------------------------------------------------------------------
//  bool newSending(...)
//
//  Description:
//      Initiates a new transmission.
//      The previous transmission must either have been successfully completed
//      or canceled.
//      The function returns immediately, and the packet must not be altered
//      before the packet has been sent or canceled.
//
//  Arguments:
//      byte xdata* packet
//          A pointer to the packet, which must reside in external memory.
//      byte length
//          The length of the packet in bytes.
//      byte destination
//          If the FHP is set up as slave, this argument has no effect as the
//          packet is sent to the master anyway.
//          If set up as master, the argument specifies the ID of the slave
//          to receive the packet or BROADCASTID if all slaves should receive
//          the packet.
//          
//  Return value:
//      bool
//          Returns TRUE if the previous transmission either has been
//          successfully completed or canceled. Otherwise, FALSE is returned
//          and the new packet is discarded.
//----------------------------------------------------------------------------
bool newSending(byte xdata* packet, byte length, byte destination);


//----------------------------------------------------------------------------
//  byte getSendStatus()
//
//  Description:
//      Used to check the status of the last initiated transmission.
//
//  Arguments:
//      None.
//          
//  Return value:
//      byte
//          The return value is one of:
//           - IDLE if the last transmission is canceled or completed
//           - NOLINK if this is a slave and
//             there is no radio link with master
//           - WAITING otherwise
//----------------------------------------------------------------------------
byte getSendStatus();
#define IDLE     0
#define WAITING  1
#define NOLINK   2

//----------------------------------------------------------------------------
//  void cancelSending()
//
//  Description:
//      Cancels the current transmission. Thus, it will not be transmitted
//      and a new transmission may be initiated.
//
//  Arguments:
//      None.
//          
//  Return value:
//      void
//----------------------------------------------------------------------------
void cancelSending();


//----------------------------------------------------------------------------
//  bool synchronize()
//
//  Description:
//      Performs an acquisition by scanning through the frequency sequence.
//
//  Arguments:
//      None.
//          
//  Return value:
//      bool
//          TRUE if a stable connection was obtained, FALSE otherwise
//----------------------------------------------------------------------------
bool synchronize();

//----------------------------------------------------------------------------
//  void setSystemID(...)
//
//  Description:
//      Sets the system ID. The master and all slaves that are to communicate
//      with each other must have the same system ID. The reason is that
//      all beacons and acknowledgements contain the system ID and are
//      discarded if they do not match. Thus, giving systems different
//      IDs prevents them from interfering with each other.
//      All application programs should choose a system ID different from
//      the default one, preferably chosen randomly for each particular system.
//
//  Arguments:
//      byte ID
//          The new system ID. Range 0-127.
//          
//  Return value:
//      void
//----------------------------------------------------------------------------
void setSystemID(byte ID);

//----------------------------------------------------------------------------
//  void setOwnID(...)
//
//  Description:
//      If the FHP is set up as master, this function has no effect.
//      Otherwise, it specifies the ID of the slave. The slave will only
//      receive packets addressed to the BROADCASTID or to its own ID.
//      The most significant bit in the ID must be 0, and the ID must not
//      equal the BROADCASTID (0).
//
//  Arguments:
//      byte ID
//          The new ID of the slave. Must be in the range 1-127.
//
//  Return value:
//      void
//----------------------------------------------------------------------------
void setOwnID(byte ID);


/****************************************************************************/



/*****************************************************************************
 *****************************************************************************
 *                                                                           *
 *     00000  0   0   0000                                                   *
 *     0      0   0  0                                                       *
 *     0000   00000   000          - FREQUENCY HOPPING SPP -                 *
 *     0      0   0      0                                                   *
 *     0      0   0  0000                                                    *
 *                                                                           *
 *****************************************************************************
 *****************************************************************************
 * The Frequency Hopping Simple Packet Protocol (FHSPP) emulates the Simple  *
 * Packet Protocol (SPP) using the Frequency Hopping Protocol (FHP) instead. *
 * Thus, an application developed for SPP can easily be updated to benefit   *
 * from the advantages of frequency hopping.                                 *
 *****************************************************************************
 * Author:              OGR                                                  *
 ****************************************************************************/

// Does nothing.
// initializeFHP must be used instead
#define fhsppSetupRF(a,b,c) 

// emulates sppSend
byte fhsppSend (SPP_TX_INFO xdata *pTXInfo);

// emulates sppReceive
byte fhsppReceive (SPP_RX_INFO xdata *pRXInfo);

// emulates sppStatus
byte fhsppStatus(void);


// emulates sppReset
void fhsppReset (void);


/****************************************************************************/


#endif // CUL_H

⌨️ 快捷键说明

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