Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: measure.cpp
- Revision:
- 10:186e097fb1e3
- Parent:
- 9:29db35656fcb
--- a/measure.cpp Tue Nov 02 10:14:25 2021 +0000 +++ b/measure.cpp Tue Nov 09 10:27:32 2021 +0000 @@ -67,21 +67,28 @@ static void DisplayMeasuredValue(double displayVal1, double displayVal2, double sweepVar); +/*============= C O D E =============*/ + /** * @brief Dsiplays the output value - * \ref DisplayMeasuredValue + * @param [in] displayVal1 - display value 1 + * @param [in] displayVal2 - display value 2 + * @param [in] sweepVar - sweep variable */ void DisplayMeasuredValue(double displayVal1, double displayVal2, double sweepVar) { + // Format the measured value and sweep variable snprintf(&displayString[0], MAX_DISPLAY_LENGTH, "Count = %d, Value = (%0.6e) + (%0.6e) j\n\r", (int32_t)sweepVar, displayVal1, displayVal2); + // Print the formated string printf("%s", &displayString[0]); } /** * @brief Function to read and display measured values + * @return Returns 0 for success or error code. */ int32_t ReadAndDisplay() { @@ -95,12 +102,12 @@ int32_t numValues = sizeof(measurementBuffer) / sizeof(measurementBuffer[0]); - + // Read measurement values into the measurement buffer if (status == 0) { status = Admx200xReadFifo(pAdmx200x, &measurementBuffer[0], &numValues); } - // Read sweep points + // Populate the fifo with sweep points if (status == 0) { cmdId = CMD_READ_SWEEP_POINTS; @@ -108,7 +115,7 @@ status = Admx200xSendCmd(pAdmx200x, &cmdId, &addr, (uint32_t *)&numValues, &statReg); } - // Read sweep points + // Read sweep points into the sweep points buffer if (status == 0) { status = Admx200xReadFifo(pAdmx200x, &sweepPoints[0], &numValues); @@ -129,6 +136,7 @@ /** * Sets up, measures and displays Impedance + * @return Returns 0 for success or error code. */ int32_t MeasureAndDisplay() { @@ -142,6 +150,7 @@ addr = 0; data = 0; + // Initiate measurement cmdId = CMD_Z; status = Admx200xSendCmd(pAdmx200x, &cmdId, &addr, &data, &statReg); @@ -150,6 +159,7 @@ status == ADMX_STATUS_UNCOMMITED_CAL || status == ADMX_STATUS_SUCCESS) { + // Wait for measurement to complete successfully status = Admx200xWaitForStatus( pAdmx200x, SPI_TIMEOUT, ADMX200X_STATUS_MEASURE_DONE_BITM, &measureStatus);