This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Passing argument Waring

HI,

I am working on NRF52832 SOC. with SDK 15. where i need to read the SENSOR data from twi protocol.

Common Write and Read Register function has been created

ret_code_t read_register(nrf_drv_twi_t twi_instance, uint8_t device_addr, uint8_t register_addr, uint8_t *p_data, uint8_t bytes, bool no_stop)
{
  ret_code_t err_code;

  err_code = nrf_drv_twi_tx(&twi_instance, device_addr, &register_addr, 1, no_stop);
  APP_ERROR_CHECK(err_code);

  if(err_code != NRF_SUCCESS) {
    return err_code;
  }

  err_code = nrf_drv_twi_rx(&twi_instance, device_addr, p_data, bytes);
  return err_code;
}

ret_code_t Write_register(nrf_drv_twi_t twi_instance, uint8_t device_a, uint8_t register_a, uint8_t siz)
{
  ret_code_t err_code;

  err_code = nrf_drv_twi_tx(&twi_instance, device_a, &register_a, siz, false);
  APP_ERROR_CHECK(err_code);

  if(err_code != NRF_SUCCESS) {
    return err_code;
  }  
}

I receive some warnings like IMPLICIT DECLARATION, INCOMPATIBLE POINTERS

Write_register call function:

 uint8_t tx_data[2];
  tx_data[0] = CTRL3_C;
  tx_data[1] = 0x04;
 err_code =  Write_register(p_twi_sensors, LSM6DS0_ADDR, &tx_data, sizeof(tx_data));
 APP_ERROR_CHECK(err_code);

Read_register call function

  uint8_t tx_data[2] = {CTRL1_XL, 0};

  // read CTRL1_XL register to obtain current parameters.
  err_code = read_register(p_twi_sensors, LSM6DS0_ADDR, CTRL1_XL, &rx_data, sizeof(rx_data), false);
  APP_ERROR_CHECK(err_code);
  
  // This call function works fine no error warning  show 

ret_code_t err_code;
  uint8_t status = 0;
  uint8_t data[6];

  LSM6DS0_set_accel_high_performance_mode(settings.accel_samplerate);

  do {
    err_code = read_register(p_twi_sensors, LSM6DS0_ADDR, STATUS_REG, &status, sizeof(status), false);
  } while(!(status & 0x01));

  err_code = read_register(p_twi_sensors, LSM6DS0_ADDR, OUTX_L_XL, &data, sizeof(data), true);
  APP_ERROR_CHECK(err_code);

  LSM6DS0_set_accel_power_down_mode();

  *x_axis = (data[1] << 8) | data[0];
  *y_axis = (data[3] << 8) | data[2];
  *z_axis = (data[5] << 8) | data[4];
  
  
  
  /* In this function 
  there is no warning on   &status
  but the incompatible pointer on &data  */
  

please guide me clear this warning

  • The important thing when dealing with compiler diagnostics (errors & warning) is always to address the earliest message first.

    This is because later messages are often a direct result of the earlier problems - so fixing the earliest will also fix all of those!

    The 'C' programming language requires that everything must be declared before it is used.

    If you don't explicitly provide a declaration, the compiler may assume a default - or "implicit" - declaration.

    The first warning is telling you that this has happened!

    The subsequent warnings may well be because the compiler's "implicit"  declaration does not match what you actually want - so fix this problem first.

    Note that all of this is standard 'C' stuff - nothing specifically to do with Nordic or Segger Embedded Studio.

Related