int main() { int i; unsigned long sw_time_1, sw_time_2; //enable the temperature sensor temp_sensor_init(); //enable uCProbe communication ProbeCom_Init(); ProbeRS232_Init(0); ProbeRS232_RxIntEn(); // turn off the LEDS IOWR(LED_PIO_BASE,0,0xFF); printf("BeMicro SDK Lab1: \n"); printf("-----------------\n\n"); // Create the input data waveform printf("Creating buffer source data\n\n"); for(i = 0; i < DATA_BUFFER_SIZE; i++) { source_databuffer[i] = input_data[i%INPUT_LENGTH]; } // record the value of the high resolution time-stamp timer at the entry and exit points of the software filter if(alt_timestamp_start() < 0) { printf("Please add the high resolution timer to the timestamp timer setting in the syslib properties page.\n"); return 0; } printf("Software filter is operating (please be patient)\n"); sw_time_1 = alt_timestamp(); FIR_SW(source_databuffer, DATA_BUFFER_SIZE, sw_destination_databuffer, T, coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4], coefficients[5], coefficients[6], coefficients[7], DIVIDER_ORDER); sw_time_2 = alt_timestamp(); printf("Software filter is done\n\n"); sw_proc_time = ((double)(sw_time_2-sw_time_1))/((double)alt_timestamp_freq()); printf("Software processing time was: %f seconds\n\n", sw_proc_time); printf("Processing time will also be reported by uC-Probe:\n"); return 1; }
/* ------------------------------------------------------------------------*//** * @FUNCTION temp_sensor_list_get * @BRIEF return the list of temperature sensor(s) * @RETURNS list of temperature sensor(s) * NULL in case of architecture is not supported * @DESCRIPTION return the list of temperature sensor(s) *//*------------------------------------------------------------------------ */ const genlist *temp_sensor_list_get(void) { temp_sensor_init(); if (cpu_is_omap44xx()) { return (const genlist *) &temp_sensor_list; } else if (cpu_is_omap54xx()) { return (const genlist *) &temp_sensor_list; } else { fprintf(stderr, "omapconf: %s(): cpu not supported!!!\n", __func__); return NULL; } }
/* ------------------------------------------------------------------------*//** * @FUNCTION temp_sensor_count_get * @BRIEF return the number of temperature sensor(s) * @RETURNS > 0 number of temperature sensor(s) * OMAPCONF_ERR_CPU * @DESCRIPTION return the number of temperature sensor(s) *//*------------------------------------------------------------------------ */ int temp_sensor_count_get(void) { int count; temp_sensor_init(); if (cpu_is_omap44xx()) { count = genlist_getcount(&temp_sensor_list); } else if (cpu_is_omap54xx()) { count = genlist_getcount(&temp_sensor_list); } else { fprintf(stderr, "omapconf: %s(): cpu not supported!!!\n", __func__); count = OMAPCONF_ERR_CPU; } dprintf("%s() = %d\n", __func__, count); return count; }
// temperature thread handler void temp_sensor(void const * arg){ // set the initial Kalman filter state. KalmanState kstate; kstate.p = 0.1; kstate.k = 0.0; kstate.r = 2.25; kstate.q = 0.01; kstate.x = 0.0; float current_temperature = 0.0; temp_sensor_init(); while(1){ osSignalWait(TEMP_SENSOR_READY, osWaitForever); // sample the current temperature of the processor. current_temperature = kalmanFilter(volt_to_celsius(getADCVoltage()), &kstate); // send a message to the display thread send_message(current_temperature, temp_queue); } }