📄 dsp281x_examples.h
字号:
//###########################################################################
//
// FILE: DSP281x_Examples.h
//
// TITLE: DSP281x Device Definitions.
//
//###########################################################################
//
// Ver | dd mmm yyyy | Who | Description of changes
// =====|=============|======|===============================================
// 1.00| 11 Sep 2003 | L.H. | First release. Seperated example specific headers
// | | | from the DSP28 peripheral headers.
// | | | Added DSP28_BIOS and DSP28_NONBIOS switches
// | | | to include or not include the default ISR's
//###########################################################################
#ifndef DSP281x_EXAMPLES_H
#define DSP281x_EXAMPLES_H
#ifdef __cplusplus
extern "C" {
#endif
// Note:$,represent " for test ";
#define TEST_RUN 1 // The robot works at the test mode ;
//#define TEST_RUN 0 // The robot works at the normal running mode ;
//#define SCIA_SCIB 1 // Use Scia;
#define SCIA_SCIB 0 // Use Scib;
//#define SciFIFO
//#define SciFIFOLen
//#define PSXII_MAX7219 1 // PSXII controller connects to Spi ;
#define PSXII_MAX7219 0 // 8 digits LED displays ;
#define CLOCK_3MINS
// CPU Timer0's period;
// Uint : uS;
//#define CPUTimer0Period 0x0F4240 // CPU Timer0's period is 1s;
//#define CPUTimer0Period 0x0C3500 // CPU Timer0's period is 800ms;
//#define CPUTimer0Period 0x0AAE60 // CPU Timer0's period is 700ms;
//#define CPUTimer0Period 0x0927C0 // CPU Timer0's period is 600ms;
#define CPUTimer0Period 0x07A120 // CPU Timer0's period is 500ms;
//#define CPUTimer0Period 0x061A80 // CPU Timer0's period is 400ms;
//#define CPUTimer0Period 0x0493E0 // CPU Timer0's period is 300ms;
//#define CPUTimer0Period 0x030D40 // CPU Timer0's period is 200ms;
//#define CPUTimer0Period 0x0249F0 // CPU Timer0's period is 150ms;
//#define CPUTimer0Period 0x0186A0 // CPU Timer0's period is 100ms;
//#define CPUTimer0Period 0x00C350 // CPU Timer0's period is 50ms;
//#define CPUTimer0Period 0x002710 // CPU Timer0's period is 10ms;
//#define CPUTimer0Period 0x001388 // CPU Timer0's period is 5ms;
//#define CPUTimer0Period 0x0007D0 // CPU Timer0's period is 2ms;
//#define CPUTimer0Period 0x0003E8 // CPU Timer0's period is 1ms;
#define CaculateThreshold 10
//#define EcoderNum 360
#define EcoderNum 200
//#define EcoderNum 1000
// LEcoderParam = PIE * diameter / EcoderNum / 4
//#define LEcoderParam 1 //Used for test,then the RoboSta.x or RoboSta.y equals
//#define REcoderParam 1 // to the circles ecoder run;
#define LEcoderParam 0.1767146 // 二代B机器人 ,d = 45mm ,EcoderNum = 200;
#define REcoderParam 0.1767146
#define EcoderLen 359
#define DetaTime 1
#define PIE 3.141592
// PC control command;
#define START 0x50
#define STOP 0x51
#define RESTART 0x52
#define PAUSE 0x53
// 多个宏名是为了与以前的程序兼容;
// Service unit address in FPGA;
#define FMotorAddr 0x35 // Motors direction control unit address in FPGA;
#define FPGA_MOTORSDIR_ADDR 0x35
#define FSMotor1Addr 0x01 // Servo motors direction control unit address in FPGA;
#define FSMotor2Addr 0x02
#define FSMotor3Addr 0x03
#define FSMotor4Addr 0x04
#define FPGA_SERVOMOTOR_1_ADDR 0x01
#define FPGA_SERVOMOTOR_2_ADDR 0x02
#define FPGA_SERVOMOTOR_3_ADDR 0x03
#define FPGA_SERVOMOTOR_4_ADDR 0x04
#define FPGA_ULTRASONIC_1_ADDR 0x21 // FPGA里面超声波传感器检测到的距离值地址,距离值单位:厘米;
#define FPGA_ULTRASONIC_2_ADDR 0x22
#define FPGA_ULTRASONIC_3_ADDR 0x23
#define FPGA_ULTRASONIC_4_ADDR 0x24
#define FPGA_ULTRASONIC_5_ADDR 0x25
#define FPGA_ULTRASONIC_6_ADDR 0x26
#define FPGA_ECODERCOUNTER_ADDR 0x30 // FPGA里面码盘计数器地址;
#define FPGA_RESET_ADDR 0x31 //reset button;
#define FPGA_YH_ADDR 0x42
#define FStrSwAddr 0x0A // Robot stroke switch check unit address in FPGA;
#define FPGA_STROKESWITCH_ADDR 0x0A
#define FUredSwAddr 0x0B // Robot ultrared switch check unit address in FPGA;
#define FPGA_ULTRAREDSWITCH_ADDR 0x0B
#define FPGA_PSXII_ADDR 0x50
// Robot drive Motors' direction;
#define MFastStop 0x0003
#define MFreeStop 0x0000
#define MForward 0x0001
#define MReverse 0x0002
#define MOTORDIR_FASTSTOP 0x0003
#define MOTORDIR_FREESTOP 0x0000
#define MOTORDIR_FORWARD 0x0001
#define MOTORDIR_REVERSE 0x0002
#define ObstaF 0x0000 //obstacles at front;
#define ObstaL 0x0001 //obstacles at left side;
#define ObstaR 0x0002 //obstacles at right side;
struct ROBOTSTATE {
float32 x;
float32 y;
float32 sita;
float32 LSpeed; // use cycle duty to represent Motor;
float32 Rspeed;
Uint16 Envir; // represent the environment around the robot;
};
struct MOTOR {
Uchar dir;
float32 speed;
};
// Sensor state type definiton;
typedef Uint16 ULTRAREDSWITCH;
typedef Uint16 STROKESWITCH;
typedef Uint16 SPIDATA;
/*-----------------------------------------------------------------------------
Specify the clock rate of the CPU (SYSCLKOUT) in nS.
Take into account the input clock frequency and the PLL multiplier
selected in step 1.
Use one of the values provided, or define your own.
The trailing L is required tells the compiler to treat
the number as a 64-bit value.
Only one statement should be uncommented.
Example: CLKIN is a 30MHz crystal.
In step 1 the user specified PLLCR = 0xA for a
150Mhz CPU clock (SYSCLKOUT = 150MHz).
In this case, the CPU_RATE will be 6.667L
Uncomment the line: #define CPU_RATE 6.667L
-----------------------------------------------------------------------------*/
//#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 7.143L // for a 140MHz CPU clock speed (SYSCLKOUT)
#define CPU_RATE 8.333L // for a 120MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 10.000L // for a 100MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 13.330L // for a 75MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 33.333L // for a 30MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 41.667L // for a 24MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 50.000L // for a 20MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 66.667L // for a 15MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 100.000L // for a 10MHz CPU clock speed (SYSCLKOUT)
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Include Example Header Files:
//
#include "DSP281x_GlobalPrototypes.h" // Prototypes for global functions within the
// .c files.
#include "DSP281x_SWPrioritizedIsrLevels.h" // Used for Software Prioritization of ISR's
// Include files not used with DSP/BIOS
#ifndef DSP28_BIOS
#include "DSP281x_DefaultISR.h"
#endif
// DO NOT MODIFY THIS LINE.
#define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // end of DSP281x_EXAMPELS_H definition
//===========================================================================
// No more.
//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -