parameter set but not used error (SPI driver)

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

parameter set but not used error (SPI driver)

Postby zazas321 » Fri Nov 12, 2021 12:22 pm

Hello. I am writing EEPROM SPI driver and noticed an issue.


in my .c file I have a function:

Code: Select all

void EEPROM_read_10_byte_chunks(spi_device_handle_t spi,uint32_t address,uint8_t* data_bufer){
    while(EEPROM_check_if_busy(spi) != true){ // return true if flash is not busy
        vTaskDelay(10/portTICK_PERIOD_MS);
        printf("waiting for busy flag to clear \n");
    }
    spi_transaction_ext_t trans = {
       .base = {
            .flags = SPI_TRANS_VARIABLE_ADDR,
            .cmd = 0b00000011,
            .addr = address,
            .rxlength = 10*8,
       },
       .address_bits = 24,
   };
   spi_device_polling_transmit(spi, (spi_transaction_t*)&trans);
   printf("read data = %p \n",(uint8_t*)&trans.base.rx_buffer);
   printf("read data = %p \n",(uint8_t*)trans.base.rx_buffer);
   data_bufer = (uint8_t*)trans.base.rx_buffer;
}
In my .h file I have prototype:

Code: Select all

void EEPROM_read_10_byte_chunks(spi_device_handle_t spi,uint32_t address,uint8_t* data_bufer);

And in my main.c I call this function:

Code: Select all

    uint8_t data[10];
    EEPROM_read_10_byte_chunks(external_eeprom,0,data);

The error message when trying to build the code:

Code: Select all

mponents/M95M04/M95M04.cpp:182:83: error: parameter 'data_bufer' set but not used [-Werror=unused-but-set-parameter]
 void EEPROM_read_10_byte_chunks(spi_device_handle_t spi,uint32_t address,uint8_t* data_bufer){

Could someone help me understand what this issue means? As you can see from my function, I am clearly using the data_bufer parameter, why does it say that I am not using it? I am trying to read 10 bytes and assing the rx_buffer to my array that I pass as a parameter.

ESP_Sprite
Posts: 9749
Joined: Thu Nov 26, 2015 4:08 am

Re: parameter set but not used error (SPI driver)

Postby ESP_Sprite » Sat Nov 13, 2021 5:11 am

Yes you set it, but you don't do anything with it after. You likely want to use it in your trans struct as the rx_data member, but you did not specify that.

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Re: parameter set but not used error (SPI driver)

Postby zazas321 » Mon Nov 15, 2021 5:55 am

Hello. Thank you very much for your response but I still dont understand what is an issue? I dont want to do anything with that data I just want to set it.

In my main I pass an empty array:

Code: Select all

    uint8_t data[10];
    EEPROM_read_10_byte_chunks(external_eeprom,0,data);
    
So now I should have 10 bytes of data in my array. I dont want anything else.

ESP_Sprite
Posts: 9749
Joined: Thu Nov 26, 2015 4:08 am

Re: parameter set but not used error (SPI driver)

Postby ESP_Sprite » Mon Nov 15, 2021 6:53 am

Take a good look at your spi_transaction_ext_t structure. If you want the SPI transaction to read data into your data_bufer memory, you should say so in that structure. There is no reference to that data_bufer in that structure, though.

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Re: parameter set but not used error (SPI driver)

Postby zazas321 » Mon Nov 15, 2021 12:48 pm

I understood what was the issue.
I had to initialize .rx_bffer to my array:

Code: Select all

.rx_buffer = data_bufer,

Who is online

Users browsing this forum: Google [Bot] and 112 guests