Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r8e6488e189349e0f87f2fb21fa8176aced0b5a43 -rf308cc4c35eab630ebbbde405cfe47d049afeafb --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 8e6488e189349e0f87f2fb21fa8176aced0b5a43) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) @@ -7,8 +7,8 @@ * * @file FPGA.c * -* @author (last) Sean Nash -* @date (last) 15-Jun-2020 +* @author (last) Quang Nguyen +* @date (last) 21-Jul-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -594,21 +594,25 @@ memcpy( &( fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN ] ), &fpgaActuatorSetPoints, sizeof( FPGA_ACTUATORS_T ) ); crc = crc16( fpgaWriteCmdBuffer, FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) ); fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) ] = GET_MSB_OF_WORD( crc ); - fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) + 1 ] = GET_LSB_OF_WORD( crc ); + fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) + 1 ] = GET_LSB_OF_WORD( crc ); + // construct bulk read command to read sensor data registers starting at address 8 fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_READ_START_ADDR ); fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_READ_START_ADDR ); fpgaReadCmdBuffer[ 3 ] = sizeof(DG_FPGA_SENSORS_T); crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); - fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); + fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); + // prep DMA for sending the bulk write cmd and receiving its response setupDMAForWriteCmd( FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) + FPGA_CRC_LEN ); - setupDMAForWriteResp( FPGA_WRITE_RSP_HDR_LEN + FPGA_CRC_LEN ); + setupDMAForWriteResp( FPGA_WRITE_RSP_HDR_LEN + FPGA_CRC_LEN ); + // prep DMA for sending the bulk read cmd and receiving its response setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); - setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof( DG_FPGA_SENSORS_T ) + FPGA_CRC_LEN ); + setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof( DG_FPGA_SENSORS_T ) + FPGA_CRC_LEN ); + // set fpga comm flags for bulk write cmd and follow-up bulk read command fpgaWriteCommandInProgress = TRUE; fpgaBulkWriteAndReadInProgress = TRUE; @@ -1400,3 +1404,91 @@ *cnt = fpgaSensorReadings.accelSampleCounter; *err = fpgaSensorReadings.accelFaultRegister; } + +/************************************************************************* + * @brief + * The getFPGACPiReadCount function gets inlet water conductivity sensor + * read count + * @details + * Inputs : fpgaSensorReadings.fpgaCPiReadCnt + * Outputs : none + * @param none + * @return Last inlet water conductivity sensor read count + *************************************************************************/ +U08 getFPGACPiReadCount ( void ) +{ + return fpgaSensorReadings.fpgaCPiReadCnt; +} + +/************************************************************************* + * @brief + * The getFPGACPiErrorCount function gets inlet water conductivity sensor + * error count + * @details + * Inputs : fpgaSensorReadings.fpgaCPiErrorCnt + * Outputs : none + * @param none + * @return Inlet water conductivity sensor read error count + *************************************************************************/ +U08 getFPGACPiErrorCount ( void ) +{ + return fpgaSensorReadings.fpgaCPiErrorCnt; +} + +/************************************************************************* + * @brief + * The getFPGACPi function gets inlet water conductivity value + * @details + * Inputs : fpgaSensorReadings.fpgaCPi + * Outputs : none + * @param none + * @return Last inlet water conductivity value + *************************************************************************/ +U32 getFPGACPi ( void ) +{ + return fpgaSensorReadings.fpgaCPi; +} + +/************************************************************************* + * @brief + * The getFPGACPoReadCount function gets outlet water conductivity sensor + * read count + * @details + * Inputs : fpgaSensorReadings.fpgaCPoReadCnt + * Outputs : none + * @param none + * @return Last outlet water conductivity sensor read count + *************************************************************************/ +U08 getFPGACPoReadCount ( void ) +{ + return fpgaSensorReadings.fpgaCPoReadCnt; +} + +/************************************************************************* + * @brief + * The getFPGACPoErrorCount function gets outlet water conductivity sensor + * error count + * @details + * Inputs : fpgaSensorReadings.fpgaCPoErrorCnt + * Outputs : none + * @param none + * @return Outlet water conductivity sensor read error count + *************************************************************************/ +U08 getFPGACPoErrorCount ( void ) +{ + return fpgaSensorReadings.fpgaCPoErrorCnt; +} + +/************************************************************************* + * @brief + * The getFPGACPo function gets outlet water conductivity value + * @details + * Inputs : fpgaSensorReadings.fpgaCPo + * Outputs : none + * @param none + * @return Last Outlet water conductivity value + *************************************************************************/ +U32 getFPGACPo ( void ) +{ + return fpgaSensorReadings.fpgaCPo; +}