哪位有AD7771的相关SPI驱动程序,可否提供参考一下

哪位有AD7771的相关SPI驱动程序,可否提供参考一下

Parents
  • void AD7779_PINRESET(void)
    {
     SET_RESET();
     CLR_RESET();//0.34us
     delayus(100);// > 2 MCLK period 
     SET_RESET();
    }

    void AD7779_Initiate(void)
    {
     AD7779_PINRESET();
     delayms(1);// must > 100us
     LED4_ON_SPICSL();
     spi_writeonereg_AD7779(GENERAL_USER_CONFIG_1,(0x24|0x40));//High Resolution Mode
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL();
     spi_writeonereg_AD7779(GENERAL_USER_CONFIG_2,(0x09|0x00));//SAR_DIAG_MODE_EN
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL();
     spi_writeonereg_AD7779(DOUT_FORMAT,(0x20|0x08));// by 16 for ADuC7026 External Interrupt Active High
     LED4_OFF_SPICSH(); 
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_N_MSB,(0x00|0x02));//HP Mode:2.048M / DEC, ODR max 4ksps due to DOUT_FORMAT by 16.
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_N_LSB,(0x00|0x00));
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_UPDATE,(0x00|0x01));// > 2 MCLK periods
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_UPDATE,(0x01&0xFE));//
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(GENERAL_USER_CONFIG_3,(0x80|0x10));//SPI_SLAVE_MODE_EN
     LED4_OFF_SPICSH();
     
    // AD7779_PINSTART();
    }

    unsigned short spi_writeonereg_AD7779(unsigned char addr, unsigned char reg) //AD7606 output at /CS falling edge and SCLK rising edge

     unsigned char SDOH=0, SDOL=0;
     unsigned char tmpH=0;
     unsigned short SDO=0;
     tmpH = addr & 0x7F;//write: MSB low
     SPITX = tmpH;//8-bit MSBs
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOH = SPIRX;//header 0x20
     SPITX = reg;//8-bit LSBs
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOL = SPIRX;//8 bit '0'
     SDO = (unsigned short)SDOH;
     SDO = (SDO<<8)+SDOL;
     return SDO;
    }

    unsigned short spi_readonereg_AD7779(unsigned char addr) //AD7606 output at /CS falling edge and SCLK rising edge

     unsigned char SDOH=0, SDOL=0;
     unsigned char tmpH=0;
     unsigned short SDO=0;
     tmpH = addr | 0x80;//read: MSB high
     SPITX = tmpH;//8-bit header 0x20
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOH = SPIRX;
     SPITX = 0x00;//8-bit LSBs
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOL = SPIRX;
     SDO = (unsigned short)SDOH;
     SDO = (SDO<<8)+SDOL;
     return SDO;
    }
    void spi_readonecode_AD7779(unsigned char *data)

     SPITX = 0x80;          //Send dummy data 0x80
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte
     data++;
     SPITX = 0x00;          //Send dummy data
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte
     data++;
     SPITX = 0x00;          //Send dummy data
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte
     data++;
     SPITX = 0x00;          //Send dummy data
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte   
       
     data--;
     data--;
     data--;
    }

Reply
  • void AD7779_PINRESET(void)
    {
     SET_RESET();
     CLR_RESET();//0.34us
     delayus(100);// > 2 MCLK period 
     SET_RESET();
    }

    void AD7779_Initiate(void)
    {
     AD7779_PINRESET();
     delayms(1);// must > 100us
     LED4_ON_SPICSL();
     spi_writeonereg_AD7779(GENERAL_USER_CONFIG_1,(0x24|0x40));//High Resolution Mode
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL();
     spi_writeonereg_AD7779(GENERAL_USER_CONFIG_2,(0x09|0x00));//SAR_DIAG_MODE_EN
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL();
     spi_writeonereg_AD7779(DOUT_FORMAT,(0x20|0x08));// by 16 for ADuC7026 External Interrupt Active High
     LED4_OFF_SPICSH(); 
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_N_MSB,(0x00|0x02));//HP Mode:2.048M / DEC, ODR max 4ksps due to DOUT_FORMAT by 16.
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_N_LSB,(0x00|0x00));
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_UPDATE,(0x00|0x01));// > 2 MCLK periods
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(SRC_UPDATE,(0x01&0xFE));//
     LED4_OFF_SPICSH();
     LED4_ON_SPICSL(); 
     spi_writeonereg_AD7779(GENERAL_USER_CONFIG_3,(0x80|0x10));//SPI_SLAVE_MODE_EN
     LED4_OFF_SPICSH();
     
    // AD7779_PINSTART();
    }

    unsigned short spi_writeonereg_AD7779(unsigned char addr, unsigned char reg) //AD7606 output at /CS falling edge and SCLK rising edge

     unsigned char SDOH=0, SDOL=0;
     unsigned char tmpH=0;
     unsigned short SDO=0;
     tmpH = addr & 0x7F;//write: MSB low
     SPITX = tmpH;//8-bit MSBs
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOH = SPIRX;//header 0x20
     SPITX = reg;//8-bit LSBs
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOL = SPIRX;//8 bit '0'
     SDO = (unsigned short)SDOH;
     SDO = (SDO<<8)+SDOL;
     return SDO;
    }

    unsigned short spi_readonereg_AD7779(unsigned char addr) //AD7606 output at /CS falling edge and SCLK rising edge

     unsigned char SDOH=0, SDOL=0;
     unsigned char tmpH=0;
     unsigned short SDO=0;
     tmpH = addr | 0x80;//read: MSB high
     SPITX = tmpH;//8-bit header 0x20
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOH = SPIRX;
     SPITX = 0x00;//8-bit LSBs
        while ((SPISTA & 0x08) != 0x08)
      {;}
     SDOL = SPIRX;
     SDO = (unsigned short)SDOH;
     SDO = (SDO<<8)+SDOL;
     return SDO;
    }
    void spi_readonecode_AD7779(unsigned char *data)

     SPITX = 0x80;          //Send dummy data 0x80
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte
     data++;
     SPITX = 0x00;          //Send dummy data
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte
     data++;
     SPITX = 0x00;          //Send dummy data
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte
     data++;
     SPITX = 0x00;          //Send dummy data
        while ((SPISTA & 0x08) != 0x08)
      {;}
     *data = SPIRX;  // recieve byte   
       
     data--;
     data--;
     data--;
    }

Children
No Data