Hi all,
I am having a few header problems. When I declare setup(); in main.c, the functions in main.c cannot see the header files in .h file.
These are the errors I am getting when compiling. Can you see any obvious things I have missed?
I am currently using Amtel Studio 6.2 and the ATmega328P.
error 1) undefined reference to `assign_channel'
error 2) undefined reference to `write_single_byte'
error 3) undefined reference to `write_single_byte'
error 4) undefined reference to `initialize_serial'
error 5) undefined reference to `initialize_spi'
error 6) undefined reference to `convert_channel'
error 7) undefined reference to `read_voltage_or_resistance_results'
error 8 ) undefined reference to `read_temperature_results'
Below is main.c and the .h file.
Many Thanks, Tuurbo46
// main.c #include <avr/io.h> #include <stdint.h> #include <stdbool.h> #include "stdio.h" #include "math.h" #include "LTC2983_configuration_constants.h" #include "LTC2983_support_functions.h" #include "LTC2983_table_coeffs.h" typedef signed char byte; typedef int boolean; // Function prototypes void configure_channels(); void configure_global_parameters(); // -------------- Configure the LTC2983 ------------------------------- void setup() { initialize_serial(); initialize_spi(); configure_channels(); configure_global_parameters(); } void configure_channels() { byte channel_number; long channel_assignment_data; // ----- Channel 1: Assign RTD PT-100 ----- channel_assignment_data = (long) SENSOR_TYPE__RTD_PT_100 | (long) RTD_RSENSE_CHANNEL__NONE | (long) RTD_NUM_WIRES__4_WIRE | (long) RTD_EXCITATION_MODE__ROTATION_SHARING | (long) RTD_EXCITATION_CURRENT__5UA | (long) RTD_STANDARD__AMERICAN; assign_channel(1, channel_assignment_data); } void configure_global_parameters() { // -- Set global parameters write_single_byte(0xF0, TEMP_UNIT__C | REJECTION__50_60_HZ); // -- Set any extra delay between conversions (in this case, 0*100us) write_single_byte(0xFF, 0); } // -------------- Run the LTC2983 ------------------------------------- int main(void) { setup(); float temperature_result; byte channel_number; int channels_to_measure[] = {1}; int num_measured_channels = sizeof(channels_to_measure)/sizeof(channels_to_measure[0]); for (int i = 0; i < num_measured_channels; i++) { channel_number = channels_to_measure[i]; convert_channel(channel_number); read_voltage_or_resistance_results((channel_number)); // removed int read_temperature_results((channel_number)); // removed int } }
// header file.h #ifndef LTC2983_SUPPORT_FUNCTIONS_H_ #define LTC2983_SUPPORT_FUNCTIONS_H_ #include "LTC2983_table_coeffs.h" typedef signed char byte; typedef int boolean; void initialize_serial(); void initialize_spi(); void write_custom_table(struct table_coeffs coefficients[64], long start_address, long table_length); void write_custom_steinhart_hart(long steinhart_hart_coeffs[6], long start_address); void write_single_byte(long start_address, int single_byte); void initialize_memory_write(long start_address); void write_coefficient(long coeff, int bytes_in_coeff); void finish_memory_write(); void initialize_memory_read(long start_address); void finish_memory_read(); void convert_channel(byte channel_number); boolean conversion_done(); float read_temperature_results(int channel_number); float read_direct_adc_results(int channel_number); void get_raw_results(long base_address, int channel_number, unsigned char results[4]); float convert_to_signed_float(unsigned char results[4]); float get_temperature(float x); float get_direct_adc_reading(float x); void print_temperature_result(int channel_number, float temperature_result); void print_direct_adc_reading(int channel_number, float direct_adc_reading); void print_fault_data(unsigned char fault_byte); bool is_number_in_array(int number, int *array, int array_length); // -------------- Some raw data result... float read_voltage_or_resistance_results(int channel_number); float convert_vr_to_signed_float(unsigned char results[4]); float get_voltage_or_resistance(float x); void print_voltage_or_resistance_result(int channel_number, float voltage_or_resistance_result); #endif