Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r9d4666bf3064df18a6d935125d7a69e4e8234e84 -r4ebc1f7e1aeb3a332e91fcdd1bbbe1a01873d93a --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 9d4666bf3064df18a6d935125d7a69e4e8234e84) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 4ebc1f7e1aeb3a332e91fcdd1bbbe1a01873d93a) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -26,145 +26,154 @@ #include "SystemCommMessages.h" #include "Utilities.h" +/** + * @addtogroup FPGA + * @{ + */ + // ********** private definitions ********** +/// Enumeration of FPGA states. typedef enum FPGA_States { - FPGA_STATE_START = 0, - FPGA_STATE_READ_HEADER, - FPGA_STATE_RCV_HEADER, - FPGA_STATE_WRITE_ALL_ACTUATORS, - FPGA_STATE_RCV_ALL_SENSORS, - FPGA_STATE_FAILED, - NUM_OF_FPGA_STATES + FPGA_STATE_START = 0, ///< Start state for the FPGA. + FPGA_STATE_READ_HEADER, ///< Read header command state for the FPGA. + FPGA_STATE_RCV_HEADER, ///< Receive header state for the FPGA. + FPGA_STATE_WRITE_ALL_ACTUATORS, ///< Write actuators command state for the FPGA. + FPGA_STATE_RCV_ALL_SENSORS, ///< Receive sensors state for the FPGA. + FPGA_STATE_FAILED, ///< Failed state for the FPGA. + NUM_OF_FPGA_STATES ///< Number of FPGA states. } FPGA_STATE_T; -#define FPGA_PAGE_SIZE 256 -#define FPGA_EXPECTED_ID 0x59 +#define FPGA_PAGE_SIZE 256 ///< FPGA register pages are 256 bytes. +#define FPGA_EXPECTED_ID 0x59 ///< Expected ID for HD FPGA. -#define FPGA_HEADER_START_ADDR 256 // update these after re-arranging w/ Randy -#define FPGA_BULK_READ_START_ADDR 262 -#define FPGA_BULK_WRITE_START_ADDR 2 +#define FPGA_HEADER_START_ADDR 0x0000 ///< Start address for FPGA header data. +#define FPGA_BULK_READ_START_ADDR 0x0100 ///< Start address for FPGA continuous priority reads. +#define FPGA_BULK_WRITE_START_ADDR 0x0008 ///< Start address for FPGA continuous priority writes. -#define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) -#define FPGA_READ_CMD_BUFFER_LEN 8 -#define FPGA_WRITE_RSP_BUFFER_LEN 8 -#define FPGA_READ_RSP_BUFFER_LEN (FPGA_PAGE_SIZE+8) +#define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA write command buffer byte length. +#define FPGA_READ_CMD_BUFFER_LEN 8 ///< FPGA read command buffer byte length. +#define FPGA_WRITE_RSP_BUFFER_LEN 8 ///< FPGA write command response buffer byte length. +#define FPGA_READ_RSP_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA read command response buffer byte length. -#define FPGA_WRITE_CMD_CODE 0x55 -#define FPGA_READ_CMD_CODE 0x5A -#define FPGA_WRITE_CMD_ACK 0xA5 -#define FPGA_READ_CMD_ACK 0xAA -#define FPGA_CMD_NAK 0xEE +#define FPGA_WRITE_CMD_CODE 0x55 ///< FPGA write command code. +#define FPGA_READ_CMD_CODE 0x5A ///< FPGA read command code. +#define FPGA_WRITE_CMD_ACK 0xA5 ///< FPGA write command ACK code. +#define FPGA_READ_CMD_ACK 0xAA ///< FPGA read command ACK code. +#define FPGA_CMD_NAK 0xEE ///< FPGA command NAK code. -#define FPGA_CRC_LEN 2 -#define FPGA_WRITE_CMD_HDR_LEN 4 -#define FPGA_READ_CMD_HDR_LEN 4 -#define FPGA_WRITE_RSP_HDR_LEN 3 -#define FPGA_READ_RSP_HDR_LEN 3 +#define FPGA_CRC_LEN 2 ///< FPGA CRC byte length. +#define FPGA_WRITE_CMD_HDR_LEN 4 ///< FPGA write command header byte length. +#define FPGA_READ_CMD_HDR_LEN 4 ///< FPGA read command header byte length. +#define FPGA_WRITE_RSP_HDR_LEN 3 ///< FPGA write command response header byte length. +#define FPGA_READ_RSP_HDR_LEN 3 ///< FPGA read command response header byte length. -#define SCI2_RECEIVE_DMA_REQUEST 28 -#define SCI2_TRANSMIT_DMA_REQUEST 29 +#define SCI2_RECEIVE_DMA_REQUEST 28 ///< Serial port 2 receive DMA request line. +#define SCI2_TRANSMIT_DMA_REQUEST 29 ///< Serial port 2 transmit DMA request line. -#define MAX_COMM_ERROR_RETRIES 5 +#define MAX_COMM_ERROR_RETRIES 5 ///< Maximum consecutive FPGA communication error retries. // FPGA Sensors Record #pragma pack(push,1) +/// Record structure for FPGA header read. typedef struct { - U08 fpgaId; - U08 fpgaRev; - U16 fpgaControl; - U16 fpgaStatus; + U08 fpgaId; ///< Reg 0. FPGA ID code. Checked against expected value at power up to verify basic FPGA communication and operation. + U08 fpgaRev; ///< Reg 1. FPGA revision being reported. + U16 fpgaControl; ///< Reg 2,3. TBD. + U16 fpgaStatus; ///< Reg 4,5. TBD. } FPGA_HEADER_T; // read only on FPGA +/// Record structure for FPGA continuous priority reads. typedef struct // TODO - add all sensor readings to this structure per FPGA register map { - U08 errorCountProcessor; // 256 - U08 errorCountPC; - U08 bloodFlowMeterDataPktCount; - U08 bloodFlowMeterSlowPktCounts; - F32 bloodFlowLast; // 260 - U08 bloodFlowMeterDeviceStatus; // 264 - U08 bloodFlowMeterResponse; - U08 dialysateFlowMeterDataPktCount; - U08 dialysateFlowMeterSlowPckCounts; - F32 dialysateFlowLast; // 268 - U08 dialysateFlowMeterDeviceStatus; // 272 - U08 dialysateFlowMeterResponse; - U08 bloodFlowMeterErrorCount; - U08 dialysateFlowMeterErrorCount; - U16 bloodOcclusionData; // 276 - U08 bloodOcclusionReadCount; - U08 bloodOcclusionErrorCount; - U16 dialysateInOcclusionData; // 280 - U08 dialysateInOcclusionReadCount; - U08 dialysateInOcclusionErrorCount; - U16 dialysateOutOcclusionData; // 284 - U08 dialysateOutOcclusionReadCount; - U08 dialysateOutOcclusionErrorCount; - U16 bloodPumpHallSensorCount; // 288 - U08 bloodPumpHallSensorStatus; - U08 dialInPumpHallSensorStatus; - U32 adc1Channel0; // 292 - U32 adc1Channel1; // 296 - U32 adc1Channel2; // 300 - U32 adc1Channel3; // 304 - U32 adc1channel4; // 308 - U08 adc1SequenceCount; // 312 - U08 adc1ErrorCount; - U16 accelX; - U16 accelY; // 316 - U16 accelZ; - U16 accelXMax; // 320 - U16 accelYMax; - U16 accelZMax; // 324 - U16 accelFaultRegister; - U16 accelSampleCounter; // 328 - U16 venousPressure; - U16 venousTemperature; // 332 - U08 venousReadCounter; - U08 dialOutPumpSensorStatus; - U16 dialInPumpHallSensorCount; // 336 - U16 dialOutPumpHallSensorCount; + U08 errorCountProcessor; ///< Reg 256. TBD. + U08 errorCountPC; ///< Reg 257. TBD. + U08 bloodFlowMeterDataPktCount; ///< Reg 258. Blood flow sensor data packet count. + U08 bloodFlowMeterSlowPktCounts; ///< Reg 259. Blood flow sensor slow data packet count. + F32 bloodFlowLast; ///< Reg 260. Blood flow rate data. + U08 bloodFlowMeterDeviceStatus; ///< Reg 264. Blood flow sensor status. + U08 bloodFlowMeterResponse; ///< Reg 265. TBD. + U08 dialysateFlowMeterDataPktCount; ///< Reg 266. Dialysate flow sensor data packet count. + U08 dialysateFlowMeterSlowPckCounts; ///< Reg 267. Dialysate flow sensor slow data packet count. + F32 dialysateFlowLast; ///< Reg 268. Dialysate flow rate data. + U08 dialysateFlowMeterDeviceStatus; ///< Reg 272. Dialysate flow sensor status. + U08 dialysateFlowMeterResponse; ///< Reg 273. TBD. + U08 bloodFlowMeterErrorCount; ///< Reg 274. Blood flow sensor error count. + U08 dialysateFlowMeterErrorCount; ///< Reg 275. Dialysate flow sensor error count. + U16 bloodOcclusionData; ///< Reg 276. Blood pump occlusion sensor data. + U08 bloodOcclusionReadCount; ///< Reg 278. Blood pump occlusion sensor read count. + U08 bloodOcclusionErrorCount; ///< Reg 279. Blood pump occlusion sensor error count. + U16 dialysateInOcclusionData; ///< Reg 280. Dialysate inlet pump occlusion sensor data. + U08 dialysateInOcclusionReadCount; ///< Reg 282. Dialysate inlet pump occlusion sensor read count. + U08 dialysateInOcclusionErrorCount; ///< Reg 283. Dialysate inlet pump occlusion sensor error count. + U16 dialysateOutOcclusionData; ///< Reg 284. Dialysate outlet pump occlusion sensor data. + U08 dialysateOutOcclusionReadCount; ///< Reg 286. Dialysate outlet pump occlusion sensor read count. + U08 dialysateOutOcclusionErrorCount; ///< Reg 287. Dialysate outlet pump occlusion sensor error count. + U16 bloodPumpHallSensorCount; ///< Reg 288. Blood pump hall sensor count. + U08 bloodPumpHallSensorStatus; ///< Reg 290. Blood pump hall sensor status. + U08 dialInPumpHallSensorStatus; ///< Reg 291. Dialysate inlet pump hall sensor status. + U32 adc1Channel0; ///< Reg 292. ADC1 channel 0 data. + U32 adc1Channel1; ///< Reg 296. ADC1 channel 1 data. + U32 adc1Channel2; ///< Reg 300. ADC1 channel 2 data. + U32 adc1Channel3; ///< Reg 304. ADC1 channel 3 data. + U32 adc1channel4; ///< Reg 308. ADC1 channel 4 data. + U08 adc1SequenceCount; ///< Reg 312. ADC1 round robin channel sequence count. + U08 adc1ErrorCount; ///< Reg 313. ADC1 error count. + U16 accelX; ///< Reg 314. Accelerometer X axis data. + U16 accelY; ///< Reg 316. Accelerometer Y axis data. + U16 accelZ; ///< Reg 318. Accelerometer Z axis data. + U16 accelXMax; ///< Reg 320. Accelerometer X axis max data (since last read). + U16 accelYMax; ///< Reg 322. Accelerometer Y axis max data (since last read). + U16 accelZMax; ///< Reg 324. Accelerometer Z axis max data (since last read). + U16 accelFaultRegister; ///< Reg 326. Accelerometer fault register. + U16 accelSampleCounter; ///< Reg 328. Accelerometer sample count. + U16 venousPressure; ///< Reg 330. Venous pressure sensor data. + U16 venousTemperature; ///< Reg 332. Venous pressure sensor temperature. + U08 venousReadCounter; ///< Reg 334. Venous pressure sensor read count. + U08 dialOutPumpSensorStatus; ///< Reg 335. Dialysate outlet pump hall sensor status. + U16 dialInPumpHallSensorCount; ///< Reg 336. Dialysate inlet pump hall sensor count. + U16 dialOutPumpHallSensorCount; ///< Reg 338. Dialysate outlet pump hall sensor count. } FPGA_SENSORS_T; +/// Record structure for FPGA continuous priority writes. typedef struct // TODO - add all actuator set points to this structure per FPGA register map { - U08 bloodValveSetState; + U08 bloodValveSetState; ///< Reg 8. Set valve actuator states. } FPGA_ACTUATORS_T; #pragma pack(pop) // ********** private data ********** // FPGA state -static FPGA_STATE_T fpgaState = FPGA_STATE_START; +static FPGA_STATE_T fpgaState = FPGA_STATE_START; ///< Current FPGA state. -static U32 fpgaCommRetryCount = 0; -static U32 fpgaReceiptCounter = 0; -static U32 fpgaTransmitCounter = 0; -static BOOL fpgaWriteCommandInProgress = FALSE; -static BOOL fpgaReadCommandInProgress = FALSE; -static BOOL fpgaBulkWriteAndReadInProgress = FALSE; -static BOOL fpgaWriteCommandResponseReceived = FALSE; -static BOOL fpgaReadCommandResponseReceived = FALSE; +static U32 fpgaCommRetryCount = 0; ///< FPGA communication retry counter. +static U32 fpgaReceiptCounter = 0; ///< FPGA response receipt counter. +static U32 fpgaTransmitCounter = 0; ///< FPGA command transmit counter. +static BOOL fpgaWriteCommandInProgress = FALSE; ///< Flag indicating an FPGA write command is in progress. +static BOOL fpgaReadCommandInProgress = FALSE; ///< Flag indicating an FPGA read command is in progress. +static BOOL fpgaBulkWriteAndReadInProgress = FALSE; ///< Flag indicating an FPGA bulk write and read command are in progress. +static BOOL fpgaWriteCommandResponseReceived = FALSE; ///< Flag indicating a response to an FPGA write command has been received. +static BOOL fpgaReadCommandResponseReceived = FALSE; ///< Flag indicating a response to an FPGA read command has been received. // FPGA comm buffers -static U08 fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_BUFFER_LEN ]; -static U08 fpgaReadCmdBuffer[ FPGA_READ_CMD_BUFFER_LEN ]; -static U08 fpgaWriteResponseBuffer[ FPGA_WRITE_RSP_BUFFER_LEN ]; -static U08 fpgaReadResponseBuffer[ FPGA_READ_RSP_BUFFER_LEN ]; +static U08 fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_BUFFER_LEN ]; ///< FPGA write command buffer. Holds the next FPGA write command to be transmitted. +static U08 fpgaReadCmdBuffer[ FPGA_READ_CMD_BUFFER_LEN ]; ///< FPGA read command buffer. Holds the next FPGA read command to be transmitted. +static U08 fpgaWriteResponseBuffer[ FPGA_WRITE_RSP_BUFFER_LEN ]; ///< FPGA write command response buffer. Memory reserved to capture the response to the last FPGA write command. +static U08 fpgaReadResponseBuffer[ FPGA_READ_RSP_BUFFER_LEN ]; ///< FPGA read command response buffer. Memory reserved to capture the response to the last FPGA read command. // DMA control records -static g_dmaCTRL fpgaDMAWriteControlRecord; -static g_dmaCTRL fpgaDMAWriteRespControlRecord; -static g_dmaCTRL fpgaDMAReadControlRecord; -static g_dmaCTRL fpgaDMAReadRespControlRecord; +static g_dmaCTRL fpgaDMAWriteControlRecord; ///< DMA record for controlling a DMA write command transmission from buffer. +static g_dmaCTRL fpgaDMAWriteRespControlRecord; ///< DMA record for controlling a DMA write command reception to buffer. +static g_dmaCTRL fpgaDMAReadControlRecord; ///< DMA record for controlling a DMA read command transmission from buffer. +static g_dmaCTRL fpgaDMAReadRespControlRecord; ///< DMA record for controlling a DMA read command reception to buffer. // FPGA data -static FPGA_HEADER_T fpgaHeader; -static FPGA_SENSORS_T fpgaSensorReadings; -static FPGA_ACTUATORS_T fpgaActuatorSetPoints; +static FPGA_HEADER_T fpgaHeader; ///< Record of last received FPGA header data. +static FPGA_SENSORS_T fpgaSensorReadings; ///< Record of last received FPGA sensor data. +static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< Record of next transmitted FPGA actuator data. // ********** private function prototypes ********** @@ -185,13 +194,12 @@ static void consumeUnexpectedData( void ); -/************************************************************************* - * @brief initFPGA +/*********************************************************************//** + * @brief * The initFPGA function initializes the FPGA module. * @details * Inputs : none * Outputs : FPGA module initialized. - * @param none * @return none *************************************************************************/ void initFPGA( void ) @@ -296,14 +304,13 @@ consumeUnexpectedData(); } -/************************************************************************* - * @brief resetFPGACommFlags +/*********************************************************************//** + * @brief * The resetFPGACommFlags function resets the various fpga comm flags and \n * counters. * @details * Inputs : none * Outputs : fpga comm flags & counters reset - * @param none * @return none *************************************************************************/ static void resetFPGACommFlags( void ) @@ -317,14 +324,13 @@ fpgaReceiptCounter = 0; } -/************************************************************************* - * @brief signalFPGAReceiptCompleted +/*********************************************************************//** + * @brief * The signalFPGAReceiptCompleted function increments a counter to indicate \n * that another DMA receipt from the FPGA has completed. * @details * Inputs : none * Outputs : fpgaReceiptCounter - * @param none * @return none *************************************************************************/ void signalFPGAReceiptCompleted( void ) @@ -353,28 +359,26 @@ } } -/************************************************************************* - * @brief signalFPGATransmitCompleted +/*********************************************************************//** + * @brief * The signalFPGATransmitCompleted function increments a counter to indicate \n * that another DMA transmit to the FPGA has completed. * @details * Inputs : none * Outputs : fpgaReceiptCounter - * @param none * @return none *************************************************************************/ void signalFPGATransmitCompleted( void ) { fpgaTransmitCounter++; } -/************************************************************************* - * @brief execFPGAIn +/*********************************************************************//** + * @brief * The execFPGA function manages incoming data exchanges with the FPGA. * @details * Inputs : fpgaState * Outputs : fpgaState - * @param none * @return none *************************************************************************/ void execFPGAIn( void ) @@ -422,13 +426,12 @@ resetFPGACommFlags(); } -/************************************************************************* - * @brief execFPGAOut +/*********************************************************************//** + * @brief * The execFPGAOut function manages outgoing data exchanges with the FPGA. * @details * Inputs : fpgaState * Outputs : fpgaState - * @param none * @return none *************************************************************************/ void execFPGAOut( void ) @@ -463,14 +466,13 @@ } } -/************************************************************************* - * @brief handleFPGAReadHeaderState +/*********************************************************************//** + * @brief * The handleFPGAReadHeaderState function handles the FPGA state where \n * the read header registers command is sent to the FPGA. * @details * Inputs : none * Outputs : read command sent to FPGA - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReadHeaderState( void ) @@ -480,8 +482,8 @@ // construct read command to read 3 registers starting at address 0 fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; - fpgaReadCmdBuffer[ 1 ] = 0x00; // start at FPGA address 0 - fpgaReadCmdBuffer[ 2 ] = 0x00; + fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_HEADER_START_ADDR ); + fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_HEADER_START_ADDR ); fpgaReadCmdBuffer[ 3 ] = sizeof(FPGA_HEADER_T); crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); @@ -496,14 +498,13 @@ return result; } -/************************************************************************* - * @brief handleFPGAReceiveHeaderState +/*********************************************************************//** + * @brief * The handleFPGAReceiveHeaderState function handles the FPGA state \n * where the header registers read response should be ready to take in. * @details * Inputs : none * Outputs : header register values updated - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveHeaderState( void ) @@ -549,14 +550,13 @@ return result; } -/************************************************************************* - * @brief handleFPGAWriteAllActuatorsState +/*********************************************************************//** + * @brief * The handleFPGAWriteAllActuatorsState function handles the FPGA state \n * where the bulk write command is sent to the FPGA. * @details * Inputs : actuator set points * Outputs : actuator set points sent to FPGA - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAWriteAllActuatorsState( void ) @@ -566,21 +566,23 @@ // construct bulk write command to write actuator data registers starting at address 3 (TODO - change address later) fpgaWriteCmdBuffer[ 0 ] = FPGA_WRITE_CMD_CODE; - fpgaWriteCmdBuffer[ 1 ] = 0x08; // start at FPGA address 8 - fpgaWriteCmdBuffer[ 2 ] = 0x00; + fpgaWriteCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_WRITE_START_ADDR ); + fpgaWriteCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_WRITE_START_ADDR ); fpgaWriteCmdBuffer[ 3 ] = sizeof(FPGA_ACTUATORS_T); 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 ); + // construct bulk read command to read sensor data registers starting at address 8 fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; - fpgaReadCmdBuffer[ 1 ] = 0x00; // start at FPGA address 0x100 (256) - fpgaReadCmdBuffer[ 2 ] = 0x01; + 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(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 ); + // 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 ); @@ -597,14 +599,13 @@ return result; } -/************************************************************************* - * @brief handleFPGAReceiveAllSensorsState +/*********************************************************************//** + * @brief * The handleFPGAReceiveAllSensorsState function handles the FPGA state \n * where the bulk read response should be ready to parse. * @details * Inputs : none * Outputs : sensor values updated - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveAllSensorsState( void ) @@ -656,13 +657,12 @@ return result; } -/************************************************************************* - * @brief execFPGATest +/*********************************************************************//** + * @brief * The execFPGATest function executes the FPGA self-test. \n * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execFPGATest( void ) @@ -687,8 +687,8 @@ return result; } -/************************************************************************* - * @brief setupDMAForWriteCmd +/*********************************************************************//** + * @brief * The setupDMAForWriteCmd function sets the byte count for the next DMA \n * write command to the FPGA. * @details @@ -710,14 +710,13 @@ } } -/************************************************************************* - * @brief startDMAWriteCmd +/*********************************************************************//** + * @brief * The startDMAWriteCmd function initiates the DMA transmit for the next \n * DMA write command to the FPGA. * @details * Inputs : none * Outputs : DMA write command to FPGA is initiated - * @param none * @return none *************************************************************************/ static void startDMAWriteCmd( void ) @@ -727,8 +726,8 @@ setSCI2DMATransmitInterrupt(); } -/************************************************************************* - * @brief setupDMAForWriteResp +/*********************************************************************//** + * @brief * The setupDMAForWriteResp function sets the expected byte count for the \n * next DMA write command response from the FPGA. * @details @@ -750,14 +749,13 @@ } } -/************************************************************************* - * @brief startDMAReceiptOfWriteResp +/*********************************************************************//** + * @brief * The startDMAReceiptOfWriteResp function initiates readiness of the DMA \n * receiver for the next DMA write command response from the FPGA. * @details * Inputs : none * Outputs : DMA write command response is ready to be received from the FPGA - * @param none * @return none *************************************************************************/ static void startDMAReceiptOfWriteResp( void ) @@ -767,8 +765,8 @@ setSCI2DMAReceiveInterrupt(); } -/************************************************************************* - * @brief setupDMAForReadCmd +/*********************************************************************//** + * @brief * The setupDMAForReadCmd function sets the byte count for the next DMA \n * read command to the FPGA. * @details @@ -790,14 +788,13 @@ } } -/************************************************************************* - * @brief startDMAReadCmd +/*********************************************************************//** + * @brief * The startDMAReadCmd function initiates the DMA transmit for the next \n * DMA read command to the FPGA. * @details * Inputs : none * Outputs : DMA read command to FPGA is initiated - * @param none * @return none *************************************************************************/ static void startDMAReadCmd( void ) @@ -807,8 +804,8 @@ setSCI2DMATransmitInterrupt(); } -/************************************************************************* - * @brief setupDMAForReadResp +/*********************************************************************//** + * @brief * The setupDMAForReadResp function sets the expected byte count for the \n * next DMA read command response from the FPGA. * @details @@ -830,14 +827,13 @@ } } -/************************************************************************* - * @brief startDMAReceiptOfReadResp +/*********************************************************************//** + * @brief * The startDMAReceiptOfReadResp function initiates readiness of the DMA \n * receiver for the next DMA read command response from the FPGA. * @details * Inputs : none * Outputs : DMA read command response is ready to be received from the FPGA - * @param none * @return none *************************************************************************/ static void startDMAReceiptOfReadResp( void ) @@ -847,23 +843,22 @@ setSCI2DMAReceiveInterrupt(); } -/************************************************************************* - * @brief getFPGAStatus +/*********************************************************************//** + * @brief * The getFPGAStatus function gets the version read from the diagnostic register \n * of the FPGA. * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return fpgaHeader.fpgaStatus *************************************************************************/ U16 getFPGAStatus( void ) { return fpgaHeader.fpgaStatus; } -/************************************************************************* - * @brief getFPGADiag +/*********************************************************************//** + * @brief * The getFPGADiag function sets the diagnostic register of the FPGA. * @details * Inputs : fpgaHeader @@ -876,114 +871,208 @@ fpgaHeader.fpgaControl = ctrl; } -/************************************************************************* - * @brief getFPGABloodFlow +/*********************************************************************//** + * @brief * The getFPGABloodFlow function gets the latest blood flow reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last blood flow reading *************************************************************************/ F32 getFPGABloodFlow( void ) { return fpgaSensorReadings.bloodFlowLast; } -/************************************************************************* - * @brief getFPGADialysateFlow +/*********************************************************************//** + * @brief * The getFPGADialysateFlow function gets the latest dialysate flow reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last dialysate flow reading *************************************************************************/ F32 getFPGADialysateFlow( void ) { return fpgaSensorReadings.dialysateFlowLast; } -/************************************************************************* - * @brief getFPGABloodPumpOcclusion +/*********************************************************************//** + * @brief + * The getFPGABloodPumpHallSensorCount function gets the latest blood pump \n + * hall sensor count. Count is a 16 bit free running counter. If counter is \n + * counting up, indicates motor is running in forward direction. If counter is \n + * counting down, indicates motor is running in reverse direction. Counter will \n + * wrap at 0/65535. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return last blood pump hall sensor count reading. + *************************************************************************/ +U16 getFPGABloodPumpHallSensorCount( void ) +{ + return fpgaSensorReadings.bloodPumpHallSensorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodPumpHallSensorStatus function gets the latest blood pump \n + * hall sensor status. \n + * Bit 0 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) \n + * Bit 1 - A direction error was detected in the current hall sensor phase \n + * Bit 2 - A direction error was detected since the last read of this register + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return last blood pump hall sensor status reading. + *************************************************************************/ +U08 getFPGABloodPumpHallSensorStatus( void ) +{ + return fpgaSensorReadings.bloodPumpHallSensorStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGADialInPumpHallSensorCount function gets the latest dialysate inlet pump \n + * hall sensor count. Count is a 16 bit free running counter. If counter is \n + * counting up, indicates motor is running in forward direction. If counter is \n + * counting down, indicates motor is running in reverse direction. Counter will \n + * wrap at 0/65535. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return last dialysate inlet pump hall sensor count reading. + *************************************************************************/ +U16 getFPGADialInPumpHallSensorCount( void ) +{ + return fpgaSensorReadings.dialInPumpHallSensorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialInPumpHallSensorStatus function gets the latest dialysate inlet pump \n + * hall sensor status. \n + * Bit 0 - Derived direction of the dialyste inlet pump motor (0=Fwd, 1=Rev) \n + * Bit 1 - A direction error was detected in the current hall sensor phase \n + * Bit 2 - A direction error was detected since the last read of this register + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return last dialysate inlet pump hall sensor status reading. + *************************************************************************/ +U08 getFPGADialInPumpHallSensorStatus( void ) +{ + return fpgaSensorReadings.dialInPumpHallSensorStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGADialOutPumpHallSensorCount function gets the latest dialysate outlet pump \n + * hall sensor count. Count is a 16 bit free running counter. If counter is \n + * counting up, indicates motor is running in forward direction. If counter is \n + * counting down, indicates motor is running in reverse direction. Counter will \n + * wrap at 0/65535. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return last dialysate outlet pump hall sensor count reading. + *************************************************************************/ +U16 getFPGADialOutPumpHallSensorCount( void ) +{ + return fpgaSensorReadings.dialOutPumpHallSensorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialOutPumpHallSensorStatus function gets the latest dialysate outlet pump \n + * hall sensor status. \n + * Bit 0 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) \n + * Bit 1 - A direction error was detected in the current hall sensor phase \n + * Bit 2 - A direction error was detected since the last read of this register + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return last dialysate outlet pump hall sensor status reading. + *************************************************************************/ +U08 getFPGADialOutPumpHallSensorStatus( void ) +{ + return fpgaSensorReadings.dialOutPumpSensorStatus; +} + +/*********************************************************************//** + * @brief * The getFPGABloodPumpOcclusion function gets the latest blood occlusion reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last blood occlusion reading *************************************************************************/ U16 getFPGABloodPumpOcclusion( void ) { return fpgaSensorReadings.bloodOcclusionData; } -/************************************************************************* - * @brief getFPGADialInPumpOcclusion +/*********************************************************************//** + * @brief * The getFPGADialInPumpOcclusion function gets the latest dialysate \n * inlet occlusion reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last dialysate inlet occlusion reading *************************************************************************/ U16 getFPGADialInPumpOcclusion( void ) { return fpgaSensorReadings.dialysateInOcclusionData; } -/************************************************************************* - * @brief getFPGADialOutPumpOcclusion +/*********************************************************************//** + * @brief * The getFPGADialOutPumpOcclusion function gets the latest dialysate \n * outlet occlusion reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last dialysate outlet occlusion reading *************************************************************************/ U16 getFPGADialOutPumpOcclusion( void ) { return fpgaSensorReadings.dialysateOutOcclusionData; } -/************************************************************************* - * @brief getFPGAArterialPressure +/*********************************************************************//** + * @brief * The getFPGAArterialPressure function gets the latest arterial pressure reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last arterial pressure reading *************************************************************************/ U16 getFPGAArterialPressure( void ) { return 0; // TODO - return reading when available } -/************************************************************************* - * @brief getFPGAVenousPressure +/*********************************************************************//** + * @brief * The getFPGAVenousPressure function gets the venous arterial pressure reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last venous pressure reading *************************************************************************/ U16 getFPGAVenousPressure( void ) { return 0; // TODO - return reading when available } -/************************************************************************* - * @brief consumeUnexpectedData +/*********************************************************************//** + * @brief * The consumeUnexpectedData function checks to see if a byte is sitting in \n * the SCI2 received data register. * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return fpgaDiag *************************************************************************/ static void consumeUnexpectedData( void ) @@ -997,3 +1086,4 @@ } } +/**@}*/