Unused return value causes warning

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unused return value causes warning

Jump to solution
697 Views
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;

}

 

 

 

 

 

 

Labels (1)
0 Kudos
Reply
1 Solution
543 Views
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);

View solution in original post

0 Kudos
Reply
2 Replies
544 Views
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 Kudos
Reply
543 Views
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 Kudos
Reply