📄 c_function.c
字号:
#include "bsrsd.h"
#include "hardware.h"
#define P_IOA_Data (volatile unsigned int *)0x7000
#define P_IOA_Buffer (volatile unsigned int *)0x7001
#define P_IOA_Dir (volatile unsigned int *)0x7002
#define P_IOA_Attrib (volatile unsigned int *)0x7003
#define P_IOA_Latch (volatile unsigned int *)0x7004
#define P_IOB_Data (volatile unsigned int *)0x7005
#define P_IOB_Buffer (volatile unsigned int *)0x7006
#define P_IOB_Dir (volatile unsigned int *)0x7007
#define P_IOB_Attrib (volatile unsigned int *)0x7008
#define NAME_ID 0x100
#define COMMAND_ONE_ID 0x101
#define COMMAND_TWO_ID 0x102
#define COMMAND_THREE_ID 0x103
#define COMMAND_FORE_ID 0x104
#define COMMAND_FIVE_ID 0x105
#define COMMAND_SIX_ID 0x106
#define COMMAND_SEVEN_ID 0x107
#define RSP_INTR 0
#define RSP_NAME 1
#define RSP_FIRE 2
#define RSP_GUARD 3
#define RSP_AGAIN 4
#define RSP_NOVOICE 5
#define RSP_NAMEDIFF 6
#define RSP_CMDDIFF 7
#define RSP_STAR 8
#define RSP_MASTER 9
#define RSP_HERE 10
#define RSP_GUNSHOT 0
#define RSP_PATROL 11
#define RSP_READY 12
#define RSP_COPY 13
#define RSP_NOISY 14
extern unsigned int BSR_SDModel[100];
unsigned int commandID;
unsigned int g_Ret;
//..................全程变量....................
int gActivated = 0; //该变量用于检测是否有触发命令,当有识别出语句
//为触发名称则该位置1
int gTriggerRespond[] = {RSP_MASTER, RSP_HERE, RSP_MASTER};
int gComm2Respond[] = {RSP_PATROL, RSP_READY, RSP_COPY};
int PlayFlag = 0;
void SystemInitial(void)
{
Delay(500);
SP_Init_IOB(0xffff,0xffff,0xffff);
// SP_Init_IOA(0xffff,0x0000,0xffff);
*P_IOB_Data=0x0000;
Delay(500);
}
//**************************left leg*******************************************************
void F_LeftLegGoCtr(int n) //left leg go
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(9,1,1,1,1);
Delay(n);
Set_IOB_Bit(9,1,1,0,0);
}
void F_LeftLegBackUpCtr(int n) //left leg back up
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(8,1,1,1,1);
Delay(n);
Set_IOB_Bit(8,1,1,0,0);
}
//**********************************Right leg***********************************************************
void F_RightLegGoCtr(int n) //Right leg go
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(11,1,1,1,1);
Delay(n);
Set_IOB_Bit(11,1,1,0,0);
}
void F_RightLegBackUpCtr(int n) //Right leg back up
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(10,1,1,1,1);
Delay(n);
Set_IOB_Bit(10,1,1,0,0);
}
//****************************head**********************************************************************
void F_HeadTurnLeft(int n) //head turn left
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(13,1,1,1,1);
Delay(n);
Set_IOB_Bit(13,1,1,0,0);
}
void F_HeadTurnRight(int n) //head turn right
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(14,1,1,1,1);
Delay(n);
Set_IOB_Bit(14,1,1,0,0);
}
//***************************************shoot********************************
void F_Shoot(int n) //ShootPrepare
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(15,1,1,1,1);
Delay(n);
Set_IOB_Bit(15,1,1,0,0);
Set_IOB_Bit(7,1,1,0,0);
}
void F_ShootPrepare(int n) //Shoot
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(7,1,1,1,1);
Delay(n);
// Set_IOB_Bit(7,1,1,0,0);
}
//**********************************light********************************
void F_Light(int n)
{
int i,j ;
ClearWatchDog();
Set_IOB_Bit(12,1,1,1,1);
Delay(n);
Set_IOB_Bit(12,1,1,0,0);
}
//*************************************dance************************
void F_Dance3(int n)
{
int i;
for(i=0;i<n;i++)
{
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
// Set_IOB_Bit(13,1,1,1,1);
PlayRespond(30);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(10,1,1,1,1);
// Set_IOB_Bit(14,1,1,1,1);
PlayRespond(31);
SystemInitial();
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
// Set_IOB_Bit(13,1,1,1,1);
PlayRespond(32);
SystemInitial();
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(10,1,1,1,1);
PlayRespond(33);
SystemInitial();
// Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(13,1,1,1,1);
PlayRespond(34);
SystemInitial();
// Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(14,1,1,1,1);
PlayRespond(35);
SystemInitial();
// Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(13,1,1,1,1);
PlayRespond(36);
SystemInitial();
// Set_IOB_Bit(11,1,1,1,1);
Set_IOB_Bit(14,1,1,1,1);
PlayRespond(37);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
PlayRespond(38);
SystemInitial();
}
SystemInitial();
}
void F_Dance2(int n)
{
int i;
for(i=0;i<n;i++)
{
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
// Set_IOB_Bit(13,1,1,1,1);
PlayRespond(24);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(10,1,1,1,1);
// Set_IOB_Bit(14,1,1,1,1);
PlayRespond(25);
SystemInitial();
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
// Set_IOB_Bit(13,1,1,1,1);
PlayRespond(26);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
PlayRespond(24);
SystemInitial();
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(10,1,1,1,1);
PlayRespond(25);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
PlayRespond(26);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(14,1,1,1,1);
PlayRespond(27);
SystemInitial();
Set_IOB_Bit(11,1,1,1,1);
Set_IOB_Bit(13,1,1,1,1);
PlayRespond(28);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(9,1,1,1,1);
PlayRespond(29);
SystemInitial();
}
SystemInitial();
}
void F_Dance1(int n)
{
int i;
for(i=0;i<n;i++)
{
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
// Set_IOB_Bit(13,1,1,1,1);
PlayRespond(24);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(10,1,1,1,1);
// Set_IOB_Bit(14,1,1,1,1);
PlayRespond(25);
SystemInitial();
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
// Set_IOB_Bit(13,1,1,1,1);
PlayRespond(26);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
PlayRespond(24);
SystemInitial();
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(10,1,1,1,1);
PlayRespond(25);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
PlayRespond(26);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(13,1,1,1,1);
PlayRespond(27);
SystemInitial();
Set_IOB_Bit(11,1,1,1,1);
Set_IOB_Bit(14,1,1,1,1);
PlayRespond(28);
SystemInitial();
Set_IOB_Bit(9,1,1,1,1);
Set_IOB_Bit(9,1,1,1,1);
PlayRespond(29);
SystemInitial();
}
SystemInitial();
}
void F_Dance(int n)
{
int i;
for(i=0;i<n;i++)
{
Set_IOB_Bit(11,1,1,1,1);
PlayRespond(7);
Set_IOB_Bit(11,1,1,0,0);
Set_IOB_Bit(9,1,1,1,1);
ClearWatchDog();
PlayRespond(8);
Set_IOB_Bit(9,1,1,0,0);
Set_IOB_Bit(11,1,1,1,1);
Set_IOB_Bit(9,1,1,1,1);
ClearWatchDog();
PlayRespond(9);
Set_IOB_Bit(11,1,1,0,0);
Set_IOB_Bit(9,1,1,0,0);
Set_IOB_Bit(13,1,1,1,1);
ClearWatchDog();
PlayRespond(10);
Set_IOB_Bit(13,1,1,0,0);
Set_IOB_Bit(14,1,1,1,1);
Set_IOB_Bit(9,1,1,1,1);
ClearWatchDog();
PlayRespond(10);
Set_IOB_Bit(9,1,1,0,0);
Set_IOB_Bit(8,1,1,1,1);
Set_IOB_Bit(11,1,1,1,1);
Set_IOB_Bit(14,1,1,1,1);
ClearWatchDog();
Delay(400);
SystemInitial();
}
SystemInitial();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -