hardctrl.c

来自「卫星接受机控制卫星和LCD显示」· C语言 代码 · 共 48 行

C
48
字号
#include "AT91SAM7S128.h"
#include "vars.h"

AT91PS_PIO    m_pPio   = AT91C_BASE_PIOA;               // 定义 PIOA 端口

const unsigned int C_ATT0[32]={
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,
0x0080,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087,
0x0090,0x0091,0x0092,0x0093,0x0094,0x0095,0x0096,0x0097
}; 

const unsigned int C_ATT1[32]={
0x0000000,0x0010000,0x0800000,0x0810000,0x1000000,0x1010000,0x1800000,0x1810000,
0x2000000,0x2010000,0x2800000,0x2810000,0x3000000,0x3010000,0x3800000,0x3810000,
0x4000000,0x4010000,0x4800000,0x4810000,0x5000000,0x5010000,0x5800000,0x5810000,
0x6000000,0x6010000,0x6800000,0x6810000,0x7000000,0x7010000,0x7800000,0x7810000
}; 

void init_pio()
{
   unsigned int tmp;
   tmp=BIT0+BIT1+BIT2+BIT4+BIT7+BIT16+BIT23+BIT24+BIT25+BIT26;
   m_pPio->PIO_PER |= tmp;  // 配置PA0为输出->att0 and att1
   m_pPio->PIO_OER |= tmp;  
   m_pPio->PIO_SODR|= tmp;
}

unsigned char set_att(unsigned char chn,unsigned char att)  //att0 控制功率; att1作温度补偿
{
   unsigned int tmp0;
   unsigned int tmp;
   if(att>31) return ACK_VALINVALID;
   if(chn==0) tmp0=C_ATT0[att];
   else tmp0=C_ATT1[att];
   tmp=~tmp0;
    m_pPio->PIO_SODR&= tmp;
    m_pPio->PIO_SODR|= tmp0;
   
   return 0;
}

unsigned char set_freq(unsigned char chn)
{
  return 0;
  
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?