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的迁移。
相关文章
|
25天前
|
安全 Linux 数据安全/隐私保护
Vanilla OS:下一代安全 Linux 发行版
【10月更文挑战第30天】
44 0
Vanilla OS:下一代安全 Linux 发行版
|
26天前
|
安全 Linux 虚拟化
|
5天前
|
人工智能 安全 Linux
Linux操作系统的演变与未来趋势###
本文深入探讨了Linux操作系统从诞生至今的发展历程,分析了其开源模式对技术创新和IT行业的影响,并展望了Linux在未来技术生态中的角色。通过历史回顾、现状分析和未来预测,本文旨在为读者提供一个关于Linux操作系统全面而深入的视角。 ###
|
5天前
|
缓存 网络协议 Linux
深入探索Linux操作系统的内核优化策略####
本文旨在探讨Linux操作系统内核的优化方法,通过分析当前主流的几种内核优化技术,结合具体案例,阐述如何有效提升系统性能与稳定性。文章首先概述了Linux内核的基本结构,随后详细解析了内核优化的必要性及常用手段,包括编译优化、内核参数调整、内存管理优化等,最后通过实例展示了这些优化技巧在实际场景中的应用效果,为读者提供了一套实用的Linux内核优化指南。 ####
20 1
|
18天前
|
缓存 资源调度 安全
深入探索Linux操作系统的心脏——内核配置与优化####
本文作为一篇技术性深度解析文章,旨在引领读者踏上一场揭秘Linux内核配置与优化的奇妙之旅。不同于传统的摘要概述,本文将以实战为导向,直接跳入核心内容,探讨如何通过精细调整内核参数来提升系统性能、增强安全性及实现资源高效利用。从基础概念到高级技巧,逐步揭示那些隐藏在命令行背后的强大功能,为系统管理员和高级用户打开一扇通往极致性能与定制化体验的大门。 --- ###
48 9
|
18天前
|
缓存 运维 网络协议
深入Linux内核架构:操作系统的核心奥秘
深入Linux内核架构:操作系统的核心奥秘
36 2
|
22天前
|
缓存 网络协议 Linux
Linux操作系统内核
Linux操作系统内核 1、进程管理: 进程调度 进程创建与销毁 进程间通信 2、内存管理: 内存分配与回收 虚拟内存管理 缓存管理 3、驱动管理: 设备驱动程序接口 硬件抽象层 中断处理 4、文件和网络管理: 文件系统管理 网络协议栈 网络安全及防火墙管理
38 4
|
21天前
|
安全 网络协议 Linux
Linux操作系统的内核升级与优化策略####
【10月更文挑战第29天】 本文深入探讨了Linux操作系统内核升级的重要性,并详细阐述了一系列优化策略,旨在帮助系统管理员和高级用户提升系统的稳定性、安全性和性能。通过实际案例分析,我们展示了如何安全有效地进行内核升级,以及如何利用调优技术充分发挥Linux系统的潜力。 ####
44 1
|
24天前
|
物联网 Linux 云计算
Linux操作系统的演变与未来趋势####
【10月更文挑战第29天】 本文深入探讨了Linux操作系统从诞生至今的发展历程,分析了其在服务器、桌面及嵌入式系统领域的应用现状,并展望了云计算、物联网时代下Linux的未来趋势。通过回顾历史、剖析现状、预测未来,本文旨在为读者提供一个全面而深入的视角,以理解Linux在当今技术生态中的重要地位及其发展潜力。 ####
|
29天前
|
边缘计算 人工智能 运维
Linux操作系统:开源力量的崛起与影响###
一场技术革命的回顾 回溯至1991年,当Linus Torvalds宣布Linux操作系统的诞生时,世界或许并未意识到这一举措将如何深刻地改变技术领域的面貌。本文旨在探讨Linux操作系统的发展历程、核心特性、以及它如何引领了一场开源运动,重塑了软件行业的生态。从最初的个人爱好项目成长为全球最广泛采用的服务器操作系统之一,Linux的故事是技术创新与社区精神共同推动下的辉煌篇章。 ###