Index: firmware/App/Controllers/SensorProcess.c =================================================================== diff -u -r6d2d8f0267c57135554e5a1acaca9aef37f27949 -ra24665c05496241e5ba9a73e0b1831a85dfbc3c9 --- firmware/App/Controllers/SensorProcess.c (.../SensorProcess.c) (revision 6d2d8f0267c57135554e5a1acaca9aef37f27949) +++ firmware/App/Controllers/SensorProcess.c (.../SensorProcess.c) (revision a24665c05496241e5ba9a73e0b1831a85dfbc3c9) @@ -13,9 +13,12 @@ * @brief Processing sensor data. * **************************************************************************/ + +#include "SensorProcess.h" +#include "Common.h" +#include "SystemCommMessages.h" +#include "FPGA.h" -#include "gio.h" - /**@}*/ /*********************************************************************//** @@ -28,4 +31,44 @@ *************************************************************************/ 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; + } }