예제 #1
0
//only 5803/5820
uint8 RDAFM_read_data(uint8 regaddr, uint16 *data, uint8 datalen)
{
    uint8 tempdata;
    uint8 i=0;
    uint8 acknowledge;
    
    SerialCommStart();///start
    acknowledge=SerialCommTxByte(FM_SINGLE_REG_ADRW);//chip adress
    acknowledge=SerialCommTxByte(regaddr);
    
    SerialCommStart();//start
    SerialCommTxByte(FM_SINGLE_REG_ADRR);//chip adress
    
    for( i=0;i<datalen-1;i++,data++)//data
    {
        SerialCommRxByte(&tempdata, 0);
        *data = (tempdata<<8);  
        SerialCommRxByte(&tempdata, 0);         
        *data |= tempdata;      
    }
    
    SerialCommRxByte(&tempdata, 0);
    *data = (tempdata<<8);  
    SerialCommRxByte(&tempdata, 1);         
    *data |= tempdata;  
    
    SerialCommStop();
    return acknowledge;
}
예제 #2
0
static bool NS953_I2cReadReg(uint8 *data, uint8 startAddr, uint8 bytesNum)
{
   int32 acknowledge;
#if defined(FM_DRIVER_DEBUG_TESTING)
   int32 i,latestRegNum;
#endif
   SerialCommStart();
   SerialCommTxByte(ADRW);
   SerialCommTxByte(startAddr);
   SerialCommStart();
   acknowledge = SerialCommTxByte(ADRR);

#if defined(FM_DRIVER_DEBUG_TESTING)
   latestRegNum = bytesNum + startAddr - 1;
   for(i=startAddr; i< latestRegNum; i++)
      SerialCommRxByte(data+i, 0); /* ACK */
   SerialCommRxByte(data+latestRegNum, 1); /* Non-ACK */
#else
   SerialCommRxByte(data, 1); /* Non-ACK */
#endif
   SerialCommStop();

   if(acknowledge)
      return false;

   return true;
}
예제 #3
0
int I2cReadReg(unsigned char dev_id, unsigned char Addr, unsigned char *Data)
{
    int acknowledge=0;    
    SerialCommStart();    
    acknowledge=SerialCommTxByte((dev_id<<1) & 0xff);
    if(acknowledge)
        acknowledge=SerialCommTxByte(Addr);
    else
        return 0;    
    SerialCommStart();
    acknowledge=SerialCommTxByte(((dev_id<<1) & 0xff) | 0x01);
    if(acknowledge)
        SerialCommRxByte(Data, 1);  // ack 0: ok , 1 error
    else
        return 0;    
    SerialCommStop();
    return acknowledge;
} 
예제 #4
0
uint8 OperationRDAFM_2w(uint8 operation, uint8 *data, uint8 numBytes)
{
    uint8 j;
    uint8 acknowledge=0;

    /***************************************************

    START: make sure here SDIO_DIR =OUT, RDABT_SCLK = 1, SDIO = 1

    ****************************************************/
    SerialCommStart();

    /***************************************************

    WRITE CONTROL DATA: make sure here: SLCK = 0; SDIO = 0

    ****************************************************/

    /***************************

    CHECK ACK for control word

    ***************************/

    if(operation == READ)
         acknowledge = SerialCommTxByte(ADRR);
    else 
         acknowledge = SerialCommTxByte(ADRW);
    
    //kal_prompt_trace(MOD_MED_V,"OperationRDAFM_2w   lrjaaaaaa acknowledge =%d ",acknowledge);  


    /***************************************

    WRITE or READ data

    ****************************************/   

    /******************************

    CHECK ACK or SEND ACK=0

    *******************************/

    for (j = 0; j < numBytes; j++, data++)
    {
        if (operation == READ)
        {
            if (j == (numBytes -1))
                SerialCommRxByte(data,1); 
            else
                SerialCommRxByte(data, 0); 
        }
        else
            acknowledge = SerialCommTxByte(*data);
        //kal_prompt_trace(MOD_MED_V,"OperationRDAFM_2w numBytes =%d acknowledge=%d,data=%x",numBytes,acknowledge,*data);  //lrj  add for test 20060522
    }
    /****************************

    STOP: make sure here: RDABT_SCLK = 0

    *****************************/
    SerialCommStop();
   
    return acknowledge;
}