打印

程序问题,帮下忙,谢谢

[复制链接]
1714|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zhl100|  楼主 | 2010-7-26 12:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
mx, ST, TE, AD, ge
本帖最后由 zhl100 于 2010-7-26 12:58 编辑

”identifier "sbit" is undefined“
“ expression must have a constant value”

程序错误帮忙看看怎么回事(我用stm32控制这个芯片的),底层函数就有这个问题。

谢谢!
typedef   unsigned char  uchar ;
typedef  unsigned int uint ;
//////////////////////////////////////////////////////////
/*  cmx868 Register Address Definitions  */
//////////////////////////////////////////////////////////
#define  CMXGENRESET   0x01
  //General Reset Command (No data)
#define  CMXGENCTRL_ADDR  0xE0
     //General Control Register
#define  CMXTXMODE_ADDR  0xE1
  //Transmit Mode Register
#define  CMXRXMODE_ADDR  0xE2
  //Receive Mode Register
#define  CMXTXDATA_ADDR  0xE3
  //Tx Data Register
#define  CMXTXDATAV14_ADDR 0xE4
        //Tx in V.14 Mode Register
#define  CMXRXDATA_ADDR  0xE5
  //Rx Data Register
#define  CMXSTAT_ADDR  0xE6
  //Status Register
#define  CMXPROG_ADDR  0xE8
//////////////////////////////////////////
/* CNM2400 cmx868 Shadow Registers */
//////////////////////////////////////////
uint   cmxgenctrl;  // 16 Bit General Control Reg
uint   cmxrxmode;  // 16 Bit Rx Mode Reg
uint   cmxstat;  // 16 Bit Status Reg
uint   cmxtxmode;  // 16 Bit Tx Mode Reg
uchar  cmxtxdata;  // 8 Bit Tx Data Reg
uchar  cmxrxdata;  // 8 Bit Rx Data Reg
uint   cmxprog ;  // 16 Bit Programming Reg(reserved)
//uchar data cmxtxdatav14; // 8 Bit V14 Tx Data Reg (reserved)
uchar  cmx_int_func; // cmx_commic interrupt require function
//////////////////////////////////////////
/*  cmx868 Register Bits  */
//////////////////////////////////////////
// General Control Register
sbit  IRQNOP_EN = cmxgenctrl ^ 14;
sbit RESET   = cmxgenctrl ^ 15;
sbit PWRUP   = cmxgenctrl ^ 0;
sbit RLYDRV_ON = cmxgenctrl ^ 1;
sbit FIX_EQU   = cmxgenctrl ^ 2;
sbit  LOOPBACK_EN=cmxgenctrl ^ 3;
sbit XTAL   = cmxgenctrl ^ 4;
// Rx Mode Register
sbit AUTO_EQU  = cmxrxmode ^ 0;
sbit RXUSART   = cmxrxmode ^ 13;
// Status Register
sbit FSKOUT = cmxstat ^ 8;   //FSK frequency demodulator output
sbit  RXEVENPAR=cmxstat ^ 11;  //Set to 1 on even Rx parity
sbit RXFERR = cmxstat ^ 12;  //Set to 1 on Rx framing error
sbit RXOF = cmxstat ^ 13;  //Set to 1 on Rx data overflow
sbit    DTMFDET = cmxstat ^ 13;  //1 when DTMF code is detected
sbit RXRDY = cmxstat ^ 14;  //Set to 1 on Rx data ready.
sbit ANS2225DET=cmxstat^ 14;  //1 when 2225Hz answer tone
sbit    T1DET = cmxstat ^ 14;  //the first programmable tone is detected
sbit ANS2100DET=cmxstat^ 15;  //1 when 2100Hz answer tone
sbit T2DET = cmxstat ^ 15;  //the second programmable tone is detected
sbit CONTA = cmxstat ^ 15;  //1 when continuous 1’s pattern detected in FSK modes
sbit  CONTB = cmxstat ^ 0;
sbit  HOOKDET = cmxstat ^ 0;  // Set to 1 on Hook Detect(cmx868 inside)
sbit  FSK0101 = cmxstat ^ 1;
sbit  S1DET = cmxstat ^ 1;
sbit  RXENERGYDET=cmxstat^2;
sbit  CPENERGYDET=cmxstat^2;
sbit T1T2DET = cmxstat ^ 2;
sbit TXUF = cmxstat ^ 3;
sbit  TXRDY = cmxstat ^ 4;
sbit PROGFLAG= cmxstat ^ 5;
sbit  CRD     = cmxstat ^ 6;
sbit IRQ  = cmxstat ^ 7;
void spi_write_8bit(uchar value)
//Write a byte into cmx868 rigister through SPI_BUS ,  bit7 is firstly writen
//entry:value to input
{
uchar data i;
//Locked into the chip on the risingedge of the serial CLOCK.
for(i=0;i<8;i++)
{
  if((value&0x80)!=0)
  {
   CDATA=1;
  }
  else
  {
   CDATA=0;
  }
  SPICLK=1;
  value=value<<1;
  SPICLK=0;
}
}
void SPI_WRITE_16(uchar address)
//Write into cmx868 a 16-bits data through SPI_BUS ,the data is in the correspond shadow register
//entry:the data address to writing
{
SPICLK=0;
CDATA=1;
mcsn_enable;
spi_write_8bit(address);
switch(address)
{
   case CMXGENRESET:  //only address
  break;
   case CMXGENCTRL_ADDR: //16 bit data
    spi_write_8bit(cmxgenctrl>>8);
    spi_write_8bit(cmxgenctrl);
    break;
   case CMXTXMODE_ADDR:
    spi_write_8bit(cmxtxmode>>8);
    spi_write_8bit(cmxtxmode);
    break;
   case CMXRXMODE_ADDR:
    spi_write_8bit(cmxrxmode>>8);
    spi_write_8bit(cmxrxmode);
    break;
   case CMXPROG_ADDR:
  spi_write_8bit(cmxprog>>8);
    spi_write_8bit(cmxprog);
    break;
   case CMXTXDATA_ADDR:           //8 bit data
   case CMXTXDATAV14_ADDR:
  spi_write_8bit(cmxtxdata);
  break;
}
mcsn_disable;
SPICLK=1;
CDATA=1;
}
uchar spi_read_8bit(void)
//Read a byte from the SPI_BUS , bit7 is firstly writen
//entry:none
//export:the reading data from SPI_BUS
{
uchar data i;
uchar data j;
//Replay data send from cmx868 to the UC is valid when the CLOCK is high.
RDATA=1;
j=0;
SPICLK=0;
for(i=0;i<8;i++)
{
  SPICLK=1;
  j=j<<1;
  if(RDATA==1)
  j^=0x01;
  SPICLK=0;
}
return(j);
}
void SPI_READ_16(uchar address)
//Read a 16-bits data from cmx868 by SPI_BUS ,and save into the correspond shadow register
//entry:the  register's address in cmx868 , that is RX_DATA and STATUS_REG
//export: cmxstat in shadow register
//       cmxrxdata in shadow register
{
uchar i;
SPICLK=0;
mcsn_enable;
i=address;
spi_write_8bit(address); // special the register address to reading
if(i==CMXSTAT_ADDR) //16-bit register
{
  cmxstat=spi_read_8bit();
  cmxstat=(cmxstat<<8)+spi_read_8bit();
}
else if(i==CMXRXDATA_ADDR)
{
  cmxrxdata=spi_read_8bit();
}
mcsn_disable;
SPICLK=1;
RDATA=1;
}
/////////////////////////////////////////////////////////////////////
void cmx_pwrup()
{
XTAL = 1;
// Ensure correct cmx868 Xtal is selected (S[24] Bit 0)
PWRUP = 1;    // Power Up cmx868
RESET = 1;    // Initially hold internal circuitry in reset condition
SPI_WRITE_16(CMXGENCTRL_ADDR); // Update CBUS register
DelayMs(20);    // 20ms Delay for Power Up
RESET = 0;  // Normal Operation
SPI_WRITE_16(CMXGENCTRL_ADDR); // Update CBUS register

cmxtxmode = 0X1A00;
SPI_WRITE_16(CMXTXMODE_ADDR);
cmxrxmode = 0X1A00;
SPI_WRITE_16(CMXRXMODE_ADDR);  
}
void cmx_reset()
{
  SPI_WRITE_16(CMXGENRESET);   // Load general reset byte,reset interal circuit
          // and on_hook when relay driver is the IC PIN
cmxgenctrl = 0x1180;
SPI_WRITE_16(CMXGENCTRL_ADDR);
DelayMs(20);    // 20ms Delay for Power Up
cmxgenctrl =0X1100;            // CML COMM_IC come into powersave mode
SPI_WRITE_16(CMXGENCTRL_ADDR);
cmxtxmode = 0;
cmxrxmode = 0;
cmxtxdata = 0;
cmxtxdatav14 = 0;
cmxrxdata=0;
cmxstat=0;
cmxprog = 0;
}
void hook(uchar state)    // Done by cmx868 relay_drive outpin
{
cmx_pwrup();                    // wake up CML COMM_IC from powersave mode
if (state == 0)
{
  RLYDRV_ON=0;    // On-Hook
}
else
{
  RLYDRV_ON=1;    // Off-Hook
}
SPI_WRITE_16(CMXGENCTRL_ADDR);
}
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

102

主题

787

帖子

2

粉丝