/**********************************************************************//** * * Copyright (c) 2020 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file SensorProcess.c * * @date 20-Feb-2020 * @author S. Nejatali * * @brief Processing sensor data. * **************************************************************************/ #include "SensorProcess.h" #include "Common.h" #include "SystemCommMessages.h" #include "FPGA.h" /**@}*/ /*********************************************************************//** * @brief * The execSensorProcess function calls other routines that process sensor data. * @details * Inputs : none * Outputs : processing data. * @return none *************************************************************************/ void execSensorProcess() { #ifdef DEBUG_ENABLED char debugStr[ 256 ]; #endif static U32 Counter = 0; static U32 Load_cell_a1 = 0; static U32 Load_cell_a2 = 0; static U32 Load_cell_b1 = 0; static U32 Load_cell_b2 = 0; F32 load_cell_a1_f; F32 load_cell_a2_f; F32 load_cell_b1_f; F32 load_cell_b2_f; BOOL result; Load_cell_a1 += getFPGALoadCellA1(); // No overflow since ADC output is 24 bits. Load_cell_a2 += getFPGALoadCellA2(); Load_cell_b1 += getFPGALoadCellB1(); Load_cell_b2 += getFPGALoadCellB2(); Counter++; if (Counter == LOAD_CELL_REPORT_PERIOD) { Counter = 0; load_cell_a1_f = (F32)(Load_cell_a1)*ADC2GRAM; // division for averaging folded into ADC2GRAM load_cell_a2_f = (F32)(Load_cell_a2)*ADC2GRAM; load_cell_b1_f = (F32)(Load_cell_b1)*ADC2GRAM; load_cell_b2_f = (F32)(Load_cell_b2)*ADC2GRAM; result = broadcastLoadCellData( load_cell_a1_f, load_cell_a2_f, load_cell_b1_f, load_cell_b2_f ); #ifdef DEBUG_ENABLED if (result == FALSE) sprintf( debugStr, "Adding load cell data to CAN buffer failed" ); #else (void)result; #endif Load_cell_a1 = 0; Load_cell_a2 = 0; Load_cell_b1 = 0; Load_cell_b2 = 0; } }