📄 link1.c
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** This example shows how to transmit and receive packets with packet length *
* *** + up to 255 bytes. The status byte is polled every 200 us in a timer1 int. *
* *** + + *** *
* *** +++ *** Link1.c *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* Compiler: Keil C51 V7.50 *
* Target platform: Chipcon CCxxx0 (Silabs F320) *
* Author: SNA *
*******************************************************************************************************
* Revision history: See end of file *
*******************************************************************************************************/
#include <Chipcon\srf04\regssrf04.h>
#include <Chipcon\srf04\halsrf04.h>
#include <Chipcon\srf04\ebsrf04.h>
#include <Link1.h>
#include <RegSettings_Link1.h>
//-------------------------------------------------------------------------------------------------------
// DESCRIPTION:
// This program allows the user to set up a simple link between two SmartRf04EBs with CC2500EM
// modules connected. The joystick is used to navigate through a menu, setting different parameters.
//
// Parameters | Values
// ------------------------------------------------------
// Packet Length | 10 , 30, 50, 70, ...., 230, 250
// Number of Packets | 100, 200, 300, ......, 900, 1000
// FEC | Enabled, Disabled
// Whitening | Enabled, Disabled
// Radio Mode | Rx, Tx
//
// RX UNIT:
// * Enable/disable FEC and/or Whitening
// * Set radio mode to RX.
// * Move joystick down until the message
// "Press S1 to start" is showed on the LCD display
// * Press S1
//
// The LCd display will show number of packets received with CRC OK
//
// TX UNIT:
// * Set packet length and number of packets to transmit
// * Enable/disable FEC and/or Whitening (set to the same as on the RX unit)
// * Set radio mode to TX
// * Press S1 to Start
//
// The LCD will show number of packets transmitted
//
// After all the packets have been transmitted, S1 can be pressed again to transmit
// or the joystick can be used to change packet length and number of packets
// to transmit
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Defines
#define CRC_OK 0x80
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Global Variables
RF_SETTINGS code rfSettings;
BYTE code paTable[];
BYTE xdata txBuffer[258]; // 1 length byte + 255 bytes payload + 2 status bytes
BYTE xdata rxBuffer[258]; // 1 length byte + 255 bytes payload + 2 status bytes
UINT16 xdata packetsReceived = 0;
UINT8 xdata joystickPosition = JOYSTICK_CENTER;
UINT8 xdata prevJoystickPosition = JOYSTICK_CENTER;
UINT8 state = SETUP; //Variable used to hold the next state in the state machine in the main loop
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// void main(void)
//
// DESCRIPTION:
// This function takes care of all the MCU initialization and radio configuration. The main loop
// is implemented as a state machine and a state diagram can be found in the
// SmartRF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -