zynq操作系统 : Linux下LHB155304测试用例

简介: Linux下LHB155304测试用例

前言

 第一种情况的改进和第三种情况,都可以在应用层来做

 比如我们可以设置快速读写模式fastmode,在应用层调用这个函数open时,配置寄存器屏蔽掉其他子地址的中断,直接源头上减少信号量,提升操作系统处理效率,退出时在close,恢复正常的配置,以免影响其他业务流程使用

 而高频率数据偶尔出现的读写错误,处理PL测对读写时序的修改,也可以通过多读几次数据判断筛选,大大降低错误概率,(目前没有发现过规避后的出错,但是源头上还是需要在FPGA部分更改读写时序)

 另外还有个驱动开发时需要注意的是:在接收到命令字之后,由于1553B特殊的机制,我们可以判断收发标志位,有区别的是,收到接收命令后再去做根据数据指针(芯片内部指针,不是编程创建的)做接收处理是完全没有问题的,但是如果收到的是发送命令,BC会在第一时间将对应子地址下的数据拿走,想根据收发标志去做发送处理的判断是完全来不及的,需要我们清楚的熟悉业务流程,在需要的时候提前填好数据,以便收到发送消息时可以让BC设备拿走正确的数据

1553test.c

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <pthread.h>
#include "rt.h"
static int fd;
unsigned int commandWord[8]={0};
void Xil_Out32(unsigned int * Addr, unsigned int Value)
{
  volatile unsigned int *LocalAddr = (volatile unsigned int *)Addr;
  *LocalAddr = Value;
}
void Delay()
{
unsigned int n=1000;
while(n--);
}
unsigned int MEM_Read(unsigned int BaseAddress,unsigned int RegOffset)             
  {
    unsigned int temp[3]= {0};
    temp[0] = Xil_In32((BaseAddress) + (RegOffset));
    Delay();
    temp[1] = Xil_In32((BaseAddress) + (RegOffset));
    Delay();
    temp[2] = Xil_In32((BaseAddress) + (RegOffset));
    if(temp[0] == temp[1])
      {
        return temp[0];
      }
    else if(temp[0] == temp[2] )
      {
        return temp[0];
      }
    else if(temp[1] == temp[2])
      {
        return temp[1];
      }
    else
      {
        return 0xFFFF;
      }
}
 unsigned int * Xil_In32(unsigned int * Addr)
{
  return *(volatile unsigned int *) Addr;
}
int rt1553open()
{
    int mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
    if (mem_fd < 0) {
        printf("can not open /dev/mem \n");
        return (-1);
    }   
    printf("/dev/mem is open \n");
    rt1553B_map_base0 = mmap(NULL, 4096 * 4, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, XPAR_BRAM_0_BASEADDR);
    rt1553B_map_base1 = mmap(NULL, 4096 * 4, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, MEM_BASEADDR);
    if (rt1553B_map_base0 == 0 || rt1553B_map_base1 == 0) { 
        printf("NULL pointer\n");
    }   
    else {
        printf("mmap successful\n");
    } 
    // Xil_Out32(rt1553B_map_base0+68,1);//fangwen mem
    close(mem_fd);
    return 0;
}
void  fastenable(void)
{
  Xil_Out32(rt1553B_map_base0 + 68, 0);
  RT_WriteReg(rt1553B_map_base1, 0x00, 0x0010);  
  Xil_Out32(rt1553B_map_base1 + 68, 1);
  MEM_Write(rt1553B_map_base1, (0x01A3) * 4, 0x4200); //子地址 3:所有消息类型使用单消息管理机制,tr产生中断
  MEM_Write(rt1553B_map_base1, (0x01A4) * 4, 0x4200); //子地址 4:所有消息类型使用单消息管理机制,tr生中断
  MEM_Write(rt1553B_map_base1, (0x01A5) * 4, 0x4200); //子地址 5:所有消息类型使用单消息管理机制,tr产生中断
  MEM_Write(rt1553B_map_base1, (0x01A6) * 4, 0x0000); //子地址 6:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A7) * 4, 0x0000); //子地址 7:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A8) * 4, 0x0000); //子地址 8:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A9) * 4, 0x0000); //子地址 9:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01AA) * 4, 0x0000); //子地址 10:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01AB) * 4, 0x0000); //子地址 11:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01AC) * 4, 0x0000); //子地址 12:所有消息类型使用单消息管理机制,不产生中断
}
void  fastdisable(void)
{
  Xil_Out32(rt1553B_map_base0 + 68, 0);
  RT_WriteReg(rt1553B_map_base1, 0x00, 0x0037);  
  Xil_Out32(rt1553B_map_base0 + 68, 1);
  MEM_Write(rt1553B_map_base1, (0x01A3) * 4, 0x0000); //子地址 3:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A4) * 4, 0x0000); //子地址 4:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A5) * 4, 0x0000); //子地址 5:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A6) * 4, 0x0000); //子地址 6:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A7) * 4, 0x0000); //子地址 7:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A8) * 4, 0x0000); //子地址 8:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01A9) * 4, 0x0000); //子地址 9:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01AA) * 4, 0x0000); //子地址 10:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01AB) * 4, 0x0000); //子地址 11:所有消息类型使用单消息管理机制,不产生中断
  MEM_Write(rt1553B_map_base1, (0x01AC) * 4, 0x0000); //子地址 12:所有消息类型使用单消息管理机制,不产生中断
}
unsigned int rt1553B_rcv()
{
  unsigned int tempVar = 0;
  unsigned int read_tmp=0;
  memset(rt1553B_BUMSG.data, 0, sizeof(rt1553B_BUMSG.data));
  if (!rt1553B_BUMSG.dataCntModeCode)
  {
    tempVar = 0x20; 
    printf("**********32*************\n");
  }    
  else
  {
    tempVar = rt1553B_BUMSG.dataCntModeCode;
    printf("**********tempVar is %d*************\n",tempVar);
  }
  Xil_Out32(rt1553B_map_base0 + 68, 1);  //fangwen mem
  for (int i = 0; i < tempVar; i++)
  {
    //read_tmp= MEM_Read(rt1553B_map_base1, (rt1553B_BUMSG.dataBlockPointer + i) * 4);
    //rt1553B_BUMSG.data[i*2]=read_tmp&0x00ff;
    //rt1553B_BUMSG.data[i*2+1]= (read_tmp&0xff00)>>8;
    rt1553B_BUMSG.data[i]= MEM_Read(rt1553B_map_base1, (rt1553B_BUMSG.dataBlockPointer + i) * 4);
  }
  //for (int i = 0; i < 64; i++)
  for (int i = 0; i < 32; i++)
  {
    printf(" rcv 32word data %d is 0x%x\r\n",i, rt1553B_BUMSG.data[i]);
  }
   memset(rt1553B_BUMSG.data, 0, sizeof(rt1553B_BUMSG.data));
  //return tempVar*2;
  return tempVar;
  } 
  unsigned int rt1553B_send(unsigned char *buf,int send_len,unsigned char subaddr)
  {
      unsigned int send_tmp=0;
      Xil_Out32(rt1553B_map_base0 + 68, 1); //fangwen mem
      usleep(10);
      printf("subaddr is %d",subaddr);
      switch (subaddr)
    {
      case BusCheckRespAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x400 + i) * 4, send_tmp);
        }
      break;
      case SelfCheckAndUpdateCtrlRespAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x440 + i) * 4, send_tmp);
        }
      break;
      case StatusCheckAndUpdateDataGroupRespAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x480 + i) * 4, send_tmp);
        }
      break;
      case UpdateBlock1Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x4C0 + i) * 4, send_tmp);
        }
      break;
      case UpdateBlock2Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x500 + i) * 4, send_tmp);
        }
      break;
      case EndecryptRespAndUpdateBlock3Addr :
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x540 + i) * 4, send_tmp);
        }
      break;
      case UpdateBlock4Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x580 + i) * 4, send_tmp);
        }
      break;
      case DdChannelSetRespAndUpdateBlock5Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x5C0 + i) * 4, send_tmp);
        }
      break;
      case UpdateBlock6Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x600 + i) * 4, send_tmp);
        }
      break;
      case UpdateBlock7Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x640 + i) * 4, send_tmp);
        }
      break;
      case UpdateBlock8Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x680 + i) * 4, send_tmp);
        }
      break;
      case TransBookRespAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x700 + i) * 4, send_tmp);
        }
      break;
      case DjChannelSetRespSysSetAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x780 + i) * 4, send_tmp);
        }
      break;
      case DxChannelSetRespAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x840 + i) * 4, send_tmp);
        }
      break;
      case ForwardDataG2Addr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x880 + i) * 4, send_tmp);
        }
      break;
      case DjChannelSetRespSelfCheckAddr:
        for (int i = 0; i < send_len; i++)
        {
          send_tmp=((unsigned int)buf[i*2])| (((unsigned int)buf[i*2+1])<<8);
          MEM_Write(rt1553B_map_base1, (0x8C0 + i) * 4, send_tmp);
        }
      break;
    default:
      break;
    }
     return 0;
  }
static void  RT_signal_func(int signum)
{
    //int command=0;
    int rcv_len;
    int status;
    // printf("before read signal\n");
    status = read(fd,&rt1553B_BUMSG,sizeof(rt1553B_BUMSG));
    // printf("read is %d\n");
    // read(fd,commandWord,sizeof(commandWord));
    printf("*********demo command is 0x%x*******************\n",rt1553B_BUMSG.commandWord);
    rt1553B_BUMSG.remoteTerminalAddr = (rt1553B_BUMSG.commandWord >> 11) & 0x1f; //远程终端地址
    rt1553B_BUMSG.tr = (rt1553B_BUMSG.commandWord >> 10) & 0x01;                 //(=0收=1发)
    rt1553B_BUMSG.subAddModeCode = (rt1553B_BUMSG.commandWord >> 5) & 0x1f;      //字地址/方式指令
    rt1553B_BUMSG.dataCntModeCode = (rt1553B_BUMSG.commandWord) & 0x1f;          //数据字指令/方式指令
    // INT = rt1553B_BUMSG.tr;
    switch (rt1553B_BUMSG.tr)
    {
    case BURX:
      rcv_len = rt1553B_rcv();
      printf("rcv length is 0x%x\r\n", rcv_len);
      break;
    case BUTX:
          printf("************INPUT  send**********************\n");
      break;
    default:
      break;
    }
}
// void data_fun(void *arg)
// {
//   int rcv_len;
//       printf("*********  command is 0x%x*******************\n",rt1553B_BUMSG.commandWord);
//       // rt1553B_BUMSG.remoteTerminalAddr = (rt1553B_BUMSG.commandWord[i] >> 11) & 0x1f; //远程终端地址
//       // rt1553B_BUMSG.tr = (rt1553B_BUMSG.commandWord[i] >> 10) & 0x01;                 //(=0收=1发)
//       // rt1553B_BUMSG.subAddModeCode = (rt1553B_BUMSG.commandWord[i] >> 5) & 0x1f;      //字地址/方式指令
//       // rt1553B_BUMSG.dataCntModeCode = (rt1553B_BUMSG.commandWord[i]) & 0x1f;          //数据字指令/方式指令
//       // // INT = rt1553B_BUMSG.tr;
//       switch (rt1553B_BUMSG.tr)
//       {
//       case BURX:
//         rcv_len = rt1553B_rcv();
//         printf("rcv length is 0x%x\r\n", rcv_len);
//         break;
//       case BUTX:
//             printf("************INPUT  send**********************\n");
//         break;
//       default:
//         break;
//       }
// }
int main(void)
{
    //int command;
    int flags = 0;
    int err;
    //pthread_t deal_data;
    rt1553open();
    // fastenable();
    fd = open("/dev/1553drv", O_RDWR);
    if(fd < 0) {
        printf("*********open fail************\n");
        return -1;
    }
    signal(SIGIO, RT_signal_func);
    fcntl(fd, F_SETOWN, getpid()); // 将当前进程的进程号告诉给内核
    flags = fcntl(fd, F_GETFD); // 获取当前的进程状态
    fcntl(fd, F_SETFL, flags | FASYNC); // 设置进程启用异步通知功能
    // err=pthread_create(&deal_data, NULL, &data_fun,NULL);
    //   if(err != 0)
    //   {
    //     printf("pthreadrx_create fail\n");
    //     return -1;
    //   }
    while(1)
    {
        sleep(1);
    }
    return 0;
}
// int main ()
// {
//   rt1553open();
//   readmemtest();
//   return 0;
// }
// int showmem()
// {
//   int Status;
//   int i;
//   Xil_Out32(rt1553B_map_base0+68,1);//fangwen mem
//   for (i = 0;i < 8;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x480+i)*4);
//     printf("addr4 %d value is 0x%x\n",i,Status);
//   }
//     for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x4C0+i)*4);
//     printf("addr5 %d value is 0x%x\n",i,Status);
//   }
//   for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x500+i)*4);
//     printf("addr6 %d value is 0x%x\n",i,Status);
//   }
//     for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x540+i)*4);
//     printf("addr7 %d value is 0x%x\n",i,Status);
//   }
//   for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x580+i)*4);
//     printf("addr8 %d value is 0x%x\n",i,Status);
//   }
//     for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x5C0+i)*4);
//     printf("addr9 %d value is 0x%x\n",i,Status);
//   }
//   for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x600+i)*4);
//     printf("addr10 %d value is 0x%x\n",i,Status);
//   }
//     for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x640+i)*4);
//     printf("addr11 %d value is 0x%x\n",i,Status);
//   }
//   for (i = 0;i <28;i++)
//   {
//     Status = RT_ReadReg(rt1553B_map_base1,(0x680+i)*4);
//     printf("addr12 %d value is 0x%x\n",i,Status);
//   }
// }
/*
int showmem()
{
  int Status;
  int i;
  Xil_Out32(rt1553B_map_base0+68,1);//fangwen mem
  for (i = 0;i < 8;i++)
  {
    int j=0;
    for(j=0;j<2;j++)
    {
      Status = RT_ReadReg(rt1553B_map_base1,(0x480+i)*4);
      if(j==2)
      {
          printf("addr4 %d value is 0x%x\n",i,Status);
      }
    }
  }
    for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x4C0+i)*4);
    printf("addr5 %d value is 0x%x\n",i,Status);
      Delay();
  }
  for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x500+i)*4);
    printf("addr6 %d value is 0x%x\n",i,Status);
      Delay();
  }
    for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x540+i)*4);
    printf("addr7 %d value is 0x%x\n",i,Status);
      Delay();
  }
  for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x580+i)*4);
    printf("addr8 %d value is 0x%x\n",i,Status);
      Delay();
  }
    for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x5C0+i)*4);
    printf("addr9 %d value is 0x%x\n",i,Status);
      Delay();
  }
  for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x600+i)*4);
    printf("addr10 %d value is 0x%x\n",i,Status);
    Delay();
  }
    for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x640+i)*4);
    printf("addr11 %d value is 0x%x\n",i,Status);
    Delay();
  }
  for (i = 0;i <28;i++)
  {
    Status = RT_ReadReg(rt1553B_map_base1,(0x680+i)*4);
    printf("addr12 %d value is 0x%x\n",i,Status);
    Delay();
  }
}
*/
/*
int readmemtest()
{
  int Status1,Status2,Status3,Status4;
  int i = 0,cnterror = 0,cntok = 0;
  Xil_Out32(rt1553B_map_base0+68,1);//fangwen mem
  sleep(1);
  for (i = 0;i < 10000000;i++)
  {
      RT_WriteReg(rt1553B_map_base1,0x1A8*4,0x4200);
      RT_WriteReg(rt1553B_map_base1,0x1A9*4,0x4100);
      RT_WriteReg(rt1553B_map_base1,0x480*4,0xf102);
      RT_WriteReg(rt1553B_map_base1,0x481*4,0xf103);
      Status1 = RT_ReadReg(rt1553B_map_base1,0x1A8*4);
      Status2 = RT_ReadReg(rt1553B_map_base1,0x1A9*4);
      Status3 = RT_ReadReg(rt1553B_map_base1,0x480*4);
      Status4 = RT_ReadReg(rt1553B_map_base1,0x481*4);
      if(Status1 != 0x4200)
      {
          cnterror++;
          printf("read error %d! error value is 0x%x,error cnt is%d\n",i,Status1,cnterror);
      }
      if(Status2 != 0x4100)
      {
          cnterror++;
          printf("read error %d! error value is 0x%x,error cnt is%d\n",i,Status2,cnterror);
      }
      if(Status2 != 0xf102)
      {
          cnterror++;
          printf("read error %d! error value is 0x%x,error cnt is%d\n",i,Status3,cnterror);
      }
      if(Status2 != 0xf103)
      {
          cnterror++;
          printf("read error %d! error value is 0x%x,error cnt is%d\n",i,Status4,cnterror);
      }
        cntok ++;
       //printf("%d read ok,value is 0x%x\n",i,Status); 
  }   
  if(cntok == 10000000)
        printf("10000000 success\n");
}
*/

rt.h

#ifndef __RT_H_
#define __RT_H_
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* 
 *Define all register macros
 *Some commonly used judgment values
 */
#define BUINTMASK                       0x0              //reg0
#define BUCFG1                          0x1
#define BUCFG2                          0x2
#define BURST                           0x3
#define BUCMDSTACKPOINT                 0x3
#define BURTSUBADDRCTRL                 0x4
#define BUTIMETAG                       0x5
#define BUINTSTATUS                     0x6
#define BUCFG3                          0x7
#define BUCFG4                          0x8
#define BUCFG5                          0x9
#define BURTDATASTACKADDR               0xa
#define BUBCFRAMETIME                   0xb
#define BUBCTIMEREMAIN                  0xc
#define BURTLASTCMD                     0xd
#define BURTSTATUSWORD                  0xe
#define BURTBITWORD                     0xf
#define BUTSTMODE0                      0x10
#define BUTSTMODE1                      0x11
#define BUTSTMODE2                      0x12
#define BUTSTMODE3                      0x13
#define BUTSTMODE4                      0x14
#define BUTSTMODE5                      0x15
#define BUTSTMODE6                      0x16
#define BUTSTMODE7                      0x17            //reg17
#define BUMSGDATANUM                    0x20            //1553 message data size 32
#define BUCHANNELA                      0x0
#define BUCHANNELB                      0x1
#define BURX                            0x0
#define BUTX                            0x1
#define ERR1                            0x0
#define ERR3                            0x1
#define ERR                             0x2
#define OK                              0x0
#define INTMASK                         0x0
#define BUM400                          0x400           //data block 13  
#define BUM800                          0x800           //data block 37  
#define BUZERO                          0x0
//#define BUMSGDATANUM                    0x40            //1553 message data size 32 word
#define BUMSGDATANUM                    0x20
#define BUSUBADDR0                      0x0
#define BUSUBADDR31                     0x20            //1553 subaddress 31
#define BUMSGBUFSIZE                    0x40            //1553 message buffer size 64
#define BUEOMINT                        0x1             //
#define BUMSGBUFBGN                     0x0             //1553 message buffer begin 0
#define BusCheckRespAddr                      1               //subaddress
#define SelfCheckAndUpdateCtrlRespAddr        3
#define StatusCheckAndUpdateDataGroupRespAddr 4
#define UpdateBlock1Addr                      5
#define UpdateBlock2Addr                      6
#define EndecryptRespAndUpdateBlock3Addr      7
#define UpdateBlock4Addr                      8
#define DdChannelSetRespAndUpdateBlock5Addr   9
#define UpdateBlock6Addr                      10
#define UpdateBlock7Addr                      11
#define UpdateBlock8Addr                      12
#define TransBookRespAddr                     15
#define DjChannelSetRespSysSetAddr            17
#define DxChannelSetRespAddr                  21
#define ForwardDataG2Addr                     24
#define DjChannelSetRespSelfCheckAddr         26
#define XPAR_BRAM_0_BASEADDR 0x40000000                 //mem ctrl baseaddr
#define MEM_BASEADDR         0x43c00000                 //1553  baseaddr
unsigned char *rt1553B_map_base0;                               //mem ctrl baseaddr
unsigned char *rt1553B_map_base1;                               //1553  baseaddr
/* 
 *Define a structure for transmitting instructions
 */
typedef struct
    {
      unsigned int channelAB;
      unsigned int blockStatusWord;
      unsigned int timeTagWord;
      unsigned int dataBlockPointer;
      unsigned int commandWord;
      unsigned int remoteTerminalAddr;
      unsigned int tr;
      unsigned int subAddModeCode;
      unsigned int dataCntModeCode;
      //unsigned char data[BUMSGDATANUM];
      unsigned int  data[BUMSGDATANUM];
    }BUMSGIFM;
 BUMSGIFM rt1553B_BUMSG;//消息
// 
typedef struct
    {
      BUMSGIFM       buRxRPool[BUMSGBUFSIZE];
      unsigned int   buRxRPoint;
      BUMSGIFM       buRxTPool[BUMSGBUFSIZE];
      unsigned int   buRxTPoint;
    } BUBUFFER;
//A read/write operation to memory
void Xil_Out32(unsigned int * Addr, unsigned int Value);
unsigned int * Xil_In32(unsigned int * Addr);
/* 
 *To facilitate access to registers and memory, 
 *the function of pointer manipulation is conveniently peak-decorated 
*/
#define RT_WriteReg(BaseAddress, RegOffset, Data)          \
    Xil_Out32((BaseAddress) + (RegOffset), (Data))
#define RT_ReadReg(BaseAddress, RegOffset)             \
    Xil_In32((BaseAddress) + (RegOffset))
#define MEM_Write(BaseAddress, RegOffset, Data)          \
    Xil_Out32((BaseAddress) + (RegOffset), (Data))
//#define MEM_Read(BaseAddress, RegOffset)             \
 //   Xil_In32((BaseAddress) + (RegOffset))
 extern unsigned int MEM_Read(BaseAddress, RegOffset);
/*
 *Memory mapping to 1553 
 *To facilitate enablement and manipulation of registers
 *@param[in] none
 *return 0
*/
int rt1553open();
/* 
 *For the initialization configuration of registers and memory,
 *please refer to the comments for details
 *@param[in] none
 *return 0
 */
int rt1553init();
/* 
 *Print out all register values to help better determine the current state
 *@param[in] none
 *return 0
 */
int showreg(); 
/* 
 *Used to make a judgment on the receiving or sending of RT
 *In fact, the configuration is already done in the rt1553init();, 
 *and the purpose of this function is only to print the send/receive data word in the absence of BM
 *Print the data word received when the BC-RT message is received
 *RT-BC prints out the data word sent
 *@param[in] none
 *return 0
 */
unsigned int rt1553B_handle();
/* 
 *Data word reception for 1553B
 *Stores the received data word in the specified data block after the mode selection, 
 *and returns twice the received length to the protocol layer
 *@param[in] none
 *return tempVar(length)
 */
unsigned int rt1553B_rcv();
/* 
 *Data word for 1553B sending
 *The pre-set instructions are filled into the fixed data block area,
 *and the data words stored in the existing specified data block area are sent to BC 
 *at the first time when receiving the sending signal
 *@param[in] buf send buffer
 *@param[in] send_len
 *@param[in] subaddr
 *return 0
 */
unsigned int rt1553B_send(unsigned char *buf,int send_len,unsigned char subaddr);
#endif
相关实践学习
CentOS 7迁移Anolis OS 7
龙蜥操作系统Anolis OS的体验。Anolis OS 7生态上和依赖管理上保持跟CentOS 7.x兼容,一键式迁移脚本centos2anolis.py。本文为您介绍如何通过AOMS迁移工具实现CentOS 7.x到Anolis OS 7的迁移。
相关文章
|
30天前
|
算法 Linux 调度
深入理解Linux操作系统的进程管理
本文旨在探讨Linux操作系统中的进程管理机制,包括进程的创建、执行、调度和终止等环节。通过对Linux内核中相关模块的分析,揭示其高效的进程管理策略,为开发者提供优化程序性能和资源利用率的参考。
67 1
|
23天前
|
Linux Shell 网络安全
Kali Linux系统Metasploit框架利用 HTA 文件进行渗透测试实验
本指南介绍如何利用 HTA 文件和 Metasploit 框架进行渗透测试。通过创建反向 shell、生成 HTA 文件、设置 HTTP 服务器和发送文件,最终实现对目标系统的控制。适用于教育目的,需合法授权。
55 9
Kali Linux系统Metasploit框架利用 HTA 文件进行渗透测试实验
|
28天前
|
安全 Ubuntu Linux
Metasploit Pro 4.22.6-2024111901 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.6-2024111901 (Linux, Windows) - 专业渗透测试框架
44 9
Metasploit Pro 4.22.6-2024111901 (Linux, Windows) - 专业渗透测试框架
|
1月前
|
安全 Linux 数据安全/隐私保护
深入Linux操作系统:文件系统和权限管理
在数字世界的海洋中,操作系统是连接用户与硬件的桥梁,而Linux作为其中的佼佼者,其文件系统和权限管理则是这座桥梁上不可或缺的结构。本文将带你探索Linux的文件系统结构,理解文件权限的重要性,并通过实际案例揭示如何有效地管理和控制这些权限。我们将一起航行在Linux的命令行海洋中,解锁文件系统的奥秘,并学习如何保护你的数据免受不必要的访问。
|
1月前
|
搜索推荐 Linux
深入理解Linux操作系统的启动过程
本文旨在揭示Linux操作系统从开机到完全启动的神秘面纱,通过逐步解析BIOS、引导加载程序、内核初始化等关键步骤,帮助读者建立对Linux启动流程的清晰认识。我们将探讨如何自定义和优化这一过程,以实现更高效、更稳定的系统运行。
|
30天前
|
存储 缓存 网络协议
Linux操作系统的内核优化与性能调优####
本文深入探讨了Linux操作系统内核的优化策略与性能调优方法,旨在为系统管理员和高级用户提供一套实用的指南。通过分析内核参数调整、文件系统选择、内存管理及网络配置等关键方面,本文揭示了如何有效提升Linux系统的稳定性和运行效率。不同于常规摘要仅概述内容的做法,本摘要直接指出文章的核心价值——提供具体可行的优化措施,助力读者实现系统性能的飞跃。 ####
|
1月前
|
缓存 监控 网络协议
Linux操作系统的内核优化与实践####
本文旨在探讨Linux操作系统内核的优化策略与实际应用案例,深入分析内核参数调优、编译选项配置及实时性能监控的方法。通过具体实例讲解如何根据不同应用场景调整内核设置,以提升系统性能和稳定性,为系统管理员和技术爱好者提供实用的优化指南。 ####
|
1月前
|
运维 监控 Linux
Linux操作系统的守护进程与服务管理深度剖析####
本文作为一篇技术性文章,旨在深入探讨Linux操作系统中守护进程与服务管理的机制、工具及实践策略。不同于传统的摘要概述,本文将以“守护进程的生命周期”为核心线索,串联起Linux服务管理的各个方面,从守护进程的定义与特性出发,逐步深入到Systemd的工作原理、服务单元文件编写、服务状态管理以及故障排查技巧,为读者呈现一幅Linux服务管理的全景图。 ####
|
1月前
|
消息中间件 安全 Linux
深入探索Linux操作系统的内核机制
本文旨在为读者提供一个关于Linux操作系统内核机制的全面解析。通过探讨Linux内核的设计哲学、核心组件、以及其如何高效地管理硬件资源和系统操作,本文揭示了Linux之所以成为众多开发者和组织首选操作系统的原因。不同于常规摘要,此处我们不涉及具体代码或技术细节,而是从宏观的角度审视Linux内核的架构和功能,为对Linux感兴趣的读者提供一个高层次的理解框架。
|
2月前
|
人工智能 安全 Linux
Linux操作系统的演变与未来趋势###
本文深入探讨了Linux操作系统从诞生至今的发展历程,分析了其开源模式对技术创新和IT行业的影响,并展望了Linux在未来技术生态中的角色。通过历史回顾、现状分析和未来预测,本文旨在为读者提供一个关于Linux操作系统全面而深入的视角。 ###

热门文章

最新文章