Unused return value causes warning

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Unused return value causes warning

跳至解决方案
1,124 次查看
rayhall
Contributor V

I am converting code from a Atmel AVR project into S12XE. I am getting warnings that relate to return values not being used. What is the work around for this.

 

This is typical of the items that are causing the warnings SpiWriteRead(AT45DB041B_CMD_STATUS_REGISTER_READ);

 

Below is the offending code.

 

Ray.

 

//----------------------------- SPI Write ----------------------------------

void SpiWrite(uint8_t data)

  while (!SPI0SR_SPTEF);   /* Wait for empty data register */    

 

  SPI0DRL = data;      // initiate write              

}

 

 

//-------------------------------- SPI Read -------------------------------------

uint8_t SpiRead(void) {

     

   while ((SPI0SR & SPI0SR_SPIF_MASK));  /* Wait for data in the receive buffer */

  

   return(SPI0DRL);     /* Return received data */      

 

}

 

//---------------------------- SPI Write Read ------------------------------

uint8_t SpiWriteRead(uint8_t data)

{

  uint8_t rxdat;

 

  SpiWrite(data);

  rxdat = SpiRead();

 

  return(data);

}

 

//---------------------------------------------- AT45DB Get Status --------------------------------------------------

uint8_t at45db041b_get_status(void)

{

   uint8_t data;

    // Select serial Flash

    DF_CS_active;

 

 

    // Send command

    SpiWriteRead(AT45DB041B_CMD_STATUS_REGISTER_READ);

 

 

    // Read status

    data = SpiWriteRead(0x00);

 

 

    // Deselect serial Flash

    DF_CS_inactive;

 

 

    return data;

}

 

 

 

 

 

 

标签 (1)
0 项奖励
回复
1 解答
970 次查看
kef
Specialist I

Either disable this warning in compiler settings like

#pragma MESSAGE DISABLE xxx

where xxx is message number like C5909

, or typecast function return to void type like this

    (void)SpiWriteRead(AT45DB041B_CMD_STATUS_REGISTER_READ);

在原帖中查看解决方案

0 项奖励
回复
2 回复数
971 次查看
kef
Specialist I

Either disable this warning in compiler settings like

#pragma MESSAGE DISABLE xxx

where xxx is message number like C5909

, or typecast function return to void type like this

    (void)SpiWriteRead(AT45DB041B_CMD_STATUS_REGISTER_READ);

0 项奖励
回复
970 次查看
rayhall
Contributor V

Edward,

Thank you for the reply.

This will work for me.

, or typecast function return to void type like this

    (void)SpiWriteRead(AT45DB041B_CMD_STATUS_REGISTER_READ);

0 项奖励
回复