getting error when running method from struct because incompatible parameter

Hi,

I was creating a struct called ch201_device. So below is the code initialization.

typedef struct ch201_device;

//! Chirp sensor device structure.
typedef struct {		
	ch_mode_t	mode;			
	uint16_t	max_range;		
	uint16_t	static_range;	
	uint16_t 	sample_interval;
	uint16_t 	rtc_cal_result;
	uint32_t 	op_frequency; 
	uint16_t 	bandwidth; 	
	uint16_t 	scale_factor; 
	uint8_t  	i2c_address; 
	uint8_t  	app_i2c_address;	
	uint16_t	i2c_drv_flags;	
	uint16_t 	part_number; 	
	int8_t		oversample;		
	uint8_t  	sensor_connected;
	uint8_t  	io_index; 	
	uint8_t  	i2c_bus_index;
	uint16_t 	max_samples; 
	uint16_t 	num_rx_samples;
	uint32_t 	rtc_cal_pulse_ms;

	const char	  *fw_version_string;
	const uint8_t *firmware;		
	uint8_t *ram_init;				
	void     (*prepare_pulse_timer)(struct ch201_device *dev_ptr);
	void     (*store_pt_result)(struct ch201_device *dev_ptr);
	void     (*store_op_freq)(struct ch201_device *dev_ptr);	
	void     (*store_bandwidth)(struct ch201_device *dev_ptr);	
	void     (*store_scalefactor)(struct ch201_device *dev_ptr);
	uint8_t  (*get_locked_state)(struct ch201_device *dev_ptr);	
	uint16_t (*get_fw_ram_init_size)(void);			
	uint16_t (*get_fw_ram_init_addr)(void);			
	ch_api_funcs_t api_funcs;
} ch201_device;

and in the c code, I create a function for that use a method from ch201_device struct. One of them is ch201_wait_for_lock. Below is the code for that function.

int ch201_wait_for_lock(ch201_device *dev_ptr, uint16_t timeout_ms) {
	uint32_t start_time = ch201_timestamp_ms();
	int ch_err = !(dev_ptr->sensor_connected);

	while (!ch_err && !(dev_ptr->get_locked_state(dev_ptr))) {
		nrf_delay_ms(10);
		ch_err = ((ch201_timestamp_ms() - start_time) > timeout_ms);
	}
	return ch_err;
}

and as you can see, there is a get_locked_state(dev_ptr). But when I compile that, it gives me an error message on that method. Below is the error log.

..\..\..\..\..\..\components\libraries\ch201\ch201.c(255): error:  #167: argument of type "ch201_device *" is incompatible with parameter of type "struct ch201_device *"
  	while (!ch_err && !(dev_ptr->get_locked_state(dev_ptr))) {

I have load the library and there is no conflict initialization on it. I also use keil uvision for this. Anybody have solution for this? Thanks.

Parents Reply Children
No Data
Related