Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
reference:add-ons:dmm-shield:libraryuserguide [2018/05/07 07:45]
Cristian Fatu [UART_PutString]
— (current)
Line 1: Line 1:
-====== DMM Shield Library User Guide ====== 
- 
-Digilent provides a DMMShield MPLAB X library for Digilent uC32 board. Basically, it accesses DMMShield hardware in order to implement DMMShield functionality. The library has multiple modules, corresponding to different hardware modules. ​ 
- 
-The library is aimed to run on the Digilent uC32 board, which acts as a carrier for DMMShield. The DMMShield is attached to uC32 carrier board, that is accessing DMMShield using digital pins.  
-  
-  
- 
- 
- 
-== Download This User Guide ==  
-  * {{ :​reference:​add-ons:​pmod-hat:​171205ag_dual_brand_pmod-hat-adapter_rm.pdf |PDF}} 
- 
----- 
- 
- 
-====== Overview ====== 
- 
-The overview diagram shows the general structure of the DMMShield library, the library modules, and the relations between them. 
-From the perspective of providing to user the access to the hardware, there as three stacked layers. 
-The GPIO, SPI and UART belong to the lowest level, which can be seen as the Data layer. GPIO provides direct connection to the hardware digital pins, while SPI implements the SPI bit-bang protocol over the digital pins. UART provides the communication from the UART interface of the carrier board. 
-The DMM, EPROM and CALIB modules belong to the middle layer, which can be seen as the Business layer. The DMM and EPROM functionality is implemented using the SPI module, while CALIB is using the DBB and EPROM modules. 
-The DMMCMD module belongs to the highest layer, which can be seen as the Presentation layer. It provides a command interpreter that listens to the commands received over UART (from a terminal, for example), while the command output is sent back over UART. 
- 
- 
-====== Library overall structure ====== 
- 
-====== Library usage ====== 
- 
-The library can be used as a whole or modules can be individually included in the user applications. 
- 
- 
-==== Library usage as a whole ==== 
- 
-The provided software package can be used to access all the DMMShield functionality. 
-The main program is calling a command interpreter from [[#​dmmcmd_module|DMMCMD module]], that provides access to all DMMShield functionality. ​ 
- 
-==== Library usage as modules included in user application ==== 
- 
-User may choose to include different modules in specific applications. For example, the user may choose to include [[#​dmm_module|DMM module]] in order to perform DMM configuration and measurements,​ [[#​calib_module|CALIB module]] to perform user calibration operations, or [[#​eprom_module|EPROM module]] in order to perform EPROM operations. 
- 
- 
- 
-====== Library modules ====== 
-===== DMMCMD module ===== 
- 
-The DMMCMD module implements a command interpreter that basically has these functions: 
-  - It listens over UART for individual DMMShield commands. User will have to provide these commands using a terminal connected to the USB port corresponding to the connected uC32 board. ​ 
-  - The commands are recognized by DMMCMD module and implemented by calls to needed modules. 
-  - The command interpreter will send over UART (see UART module) the commands output messages, which can be seen in the terminal window. ​ 
-It is important to comply with each command expected formalism. 
-Each command is terminated with a ‘\r’, or ‘\n’ or both characters. It might contain one or more arguments, as detailed in the subsequent sections of the document.\\ ​ 
-The following chapters provide details about data formatting: 
-  * [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] 
-  * [[#​format_of_values_provided_as_parameter|Format of values provided as parameter]]\\ 
-The following list enumerates the commands implemented in the DMMCMD module: 
-  * [[#​dmmconfig|DMMConfig]] 
-  * [[#​dmmmeasurerep|DMMMeasureRep]] 
-  * [[#​dmmmeasurestop|DMMMeasureStop]] 
-  * [[#​dmmmeasureraw|DMMMeasureRaw]] 
-  * [[#​dmmmeasureawg|DMMMeasureAwg]] 
-  * [[#​dmmcalib|DMMCalib]] 
-  * [[#​dmmmeasureforcalib|DMMMeasureForCalib]] 
-  * [[#​dmmfinalizecalib|DMMFinalizeCalib]] 
-  * [[#​dmmsaveeprom|DMMSaveEPROM]] 
-  * [[#​dmmverifyeprom|DMMVerifyEPROM]]  ​ 
-  * [[#​dmmimportcalib|DMMImportCalib]] 
-  * [[#​dmmrestorefactcalibs|DMMRestoreFactCalibs]] 
-  * [[#​dmmreadserialno|DMMReadSerialNo]] 
- 
-==== Interpreting values provided as parameter ==== 
-Values formatted in character strings must be provided as parameters for some functions, for example the reference value provided as parameter to calibration functions in [[#​dmmcmd_module|DMMCMD module]], see [[##​dmmcalib|DMMCalib]].\\ ​ 
-Providing a value as a parameter must comply to the following rules: 
-The value is composed by a fractional number followed by the unit. The unit is formed by the base unit (“V”, “A” or “Ohm”), eventually prefixed by multiple / submultiple designators (“u”, “m”, “k” and “M”). It is mandatory that the base unit matches the current selected scale, otherwise the following error is returned: "​ERROR,​ The provided value <value string> has a wrong measure unit"​.\\ ​ 
-The function that implements value interpreting is [[#​dmm_interpretvalue|DMM_InterpretValue]].\\ ​ 
- 
-Example: “2.456789 mV” is correct for VoltageDC5 scale, and corresponds to the 0.002456789 value. 
- 
-==== Format of values in the answer text ==== 
-Some functions return character strings representing values, for example get value functions of the [[#​dmmcmd_module|DMMCMD module]], see [[##​dmmmeasurerep|DMMMeasureRep]].\\ ​ 
-The values will be formatted as a fractional number (6 decimals), followed by the base unit (“V”, “A” or “Ohm”) corresponding to the current selected scale. No multiple / submultiple designators of the base unit are used. 
- 
-Example: 0.002456789 is formatted "​0.002456 V" for all of the voltage scales. 
- 
-==== DMMConfig ==== 
-=== Syntax: ===  
-“DMMConfig <​Scale>​” 
- 
-=== Example: ===  
-“DMMConfig VoltageDC5” 
- 
-=== Description:​ ===  
-The DMMConfig command configures the DMM for a specific scale. 
- 
- 
-=== Parameters: ===  
- 
-The possible values from the <​Scale>​ are shown in the Scale column of the following table: 
-^No.^ Scale  ^ 
-|1| Resistance50M | 
-|2| Resistance5M | 
-|3| Resistance500k | 
-|4| Resistance50k | 
-|5| Resistance5k | 
-|6| Resistance500 | 
-|7| Resistance50 | 
-|8| VoltageDC50 | 
-|9| VoltageDC5 | 
-|10| VoltageDC500m | 
-|11| VoltageDC50m | 
-|12| VoltageAC50 | 
-|13| VoltageAC5 | 
-|14| VoltageAC500m | 
-|15| VoltageAC50m | 
-|16| CurrentDC5 | 
-|17| CurrentAC5 | 
-|18| Continuity | 
-|19| Diode | 
-|20| CurrentDC500m | 
-|21| CurrentDC50m | 
-|22| CurrentDC5m | 
-|23| CurrentDC500u | 
-|24| CurrentAC5 | 
-|25| CurrentAC500m | 
-|26| CurrentAC50m | 
-|27| CurrentAC5m | 
-|28| CurrentAC500u | 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| “OK, Selected scale index is: <integer value>​” \\  Example:​\\ ​ “OK, Selected scale index is: 8” | Success.\\ The provided value is the scale index . | 
-| “ERROR, Missing valid configuration:​ \"<​provided value>​\"​” | ERROR, the provided configuration is not valid.\\ The faulty string is provided between “”.| 
-| "​ERROR,​ Invalid scale index" | ERROR, invalid selected scale index.| 
-| "​ERROR,​ DMM Configuration verify error" | ERROR, the configuration verification failed.| 
- 
-==== DMMMeasureRep ==== 
-=== Syntax: ===  
-“DMMMeasureRep” 
- 
- 
-=== Description:​ ===  
-This commands initiates a session of repetitive measurements. These repetitive measurements will be performed until the [[#​dmmmeasurestop|DMMMeasureStop]] command is issued. ​ 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
-  - After issuing the command: “OK, Measure repeated” 
-  - Repeatedly, for each measurement:​ 
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| “Value: <value, 6 decimals followed by unit>” | The value included in the message is formatted as explained in [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter.| 
-| "​ERROR,​ Invalid scale index" | ERROR, invalid selected scale index.| 
-| "​ERROR,​ Valid DMM data timeout"​ | ERROR, a valid data was not received within expected time.| 
- 
-==== DMMMeasureStop ==== 
-=== Syntax: ===  
-“DMMMeasureStop” 
- 
- 
-=== Description:​ ===  
-This command terminates the repetitive measurements session initiated by [[#​dmmmeasurerep|DMMMeasureRep]] or [[#​dmmmeasureraw|DMMMeasureRaw]] commands. 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
-"OK, Measure stop" 
- 
-==== DMMMeasureRaw ==== 
-=== Syntax: ===  
-“DMMMeasureRaw” 
- 
- 
-=== Description:​ ===  
-This commands initiates a session of repetitive measurements of raw values. Raw values are values acquired from DMM, without applying the calibration corrections. These repetitive measurements will be performed until the [[#​dmmmeasurestop|DMMMeasureStop]] command is issued. 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
-  - After issuing the command: “OK, Measure raw” 
-  - Repeatedly, for each measurement:​ 
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| “Value: <value, 6 decimals followed by unit>” | The value included in the message is formatted as explained in [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter.| 
-| "​ERROR,​ Invalid scale index" | ERROR, invalid selected scale index.| 
-| "​ERROR,​ Valid DMM data timeout"​ | ERROR, a valid data was not received within expected time.| 
- 
-==== DMMMeasureAvg ==== 
-=== Syntax: ===  
-“DMMMeasureAvg” 
- 
- 
-=== Description:​ ===  
-This commands performs one average measurement (taking the average value of a set of measurements). 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| “Avg. Value: ​ <value, 6 decimals followed by unit>” | The value included in the message is formatted as explained in [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter.| 
-| "​ERROR,​ Invalid scale index" | ERROR, invalid selected scale index.| 
-| "​ERROR,​ Valid DMM data timeout"​ | ERROR, a valid data was not received within expected time.| 
- 
-==== DMMCalib ==== 
-=== Syntax: ===  
-““DMMCalib<​P,​ N or S> <​reference value>​”” 
- 
-=== Example: ===  
-“DMMCalibP 5.000115 V”\\ ​ 
-“DMMCalibN -5.001185”\\ ​ 
-“DMMCalibS” 
- 
- 
- 
-=== Description:​ ===  
-This command performs the positive, negative, or on short calibration,​ depending on the character following DMMCalib command (‘P’, ‘N’ or ‘S’). This is performed by initiating a measurement and then saving the measured value to be later processed when all the needed data will be present and the calibration will be finalized. For positive and negative calibration,​ a reference value is provided as a parameter, which is also saved together with the measured value. 
- 
- 
-=== Parameters: ===  
- 
-| <​reference value, 6 decimals, followed by Unit> ​ | This parameter is only for positive and negative calibrations.\\ This is a character string containing a formatted value. For more details see [[#​format_of_values_provided_as_parameter|Format of values provided as parameter]] chapter. ​ | 
- 
- 
-=== Answer: ===  
- 
-^ Answer ​                                                                                                                                                                                                                                                                                                                                                                                                                                   ^ Meaning ​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^ 
-| "OK, Calibration on positive done. Reference: <​reference value, 6 decimals, followed by Unit>, Measured: <​measured value, 6 decimals, followed by Unit>, Dispersion: <​dispersion,​ 2 decimals>​%[Coeff:​ <Mult calibration coefficient,​ 6 decimals>,​ <Add calibration coefficient,​ 6 decimals>​]"​\\ Example:\\ “OK, Calibration on positive done. Reference: 5.000115 V, Measured: 5.108844 V, Dispersion: 0.02% Coeff: -0.067295, 0.043947" ​ | Success.\\ <The message is dependent to the calibration type (positive, negative or on short)>​\\ \\ The dispersion is computed as the difference between the measured and the reference values, divided by the scale range.\\ \\ \\ The calibration coefficients are appended in the end of the message only if this calibration finalizes a calibration process.\\ \\ The values included in the message are formatted as explained in the [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter. ​ | 
-| “OK, Calibration on negative done. Reference: <​reference value, 6 decimals, followed by Unit>, Measured: <​measured value, 6 decimals, followed by Unit>, Dispersion: <​dispersion,​ 2 decimals>​%[Coeff:​ <Mult calibration coefficient,​ 6 decimals>,​ <Add calibration coefficient,​ 6 decimals>​]"​\\ Example:\\ “OK, Calibration on negative done. Reference: -5.001185 V, Measured: -5.109310 V, Dispersion: 0.02%" ​                          | :::                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | 
-| “OK, Calibration on short done: Measured Val = <value, 6 decimals>,​ Dispersion <​dispersion,​ 2 decimals>​%[Coeff:​ <Mult calibration coefficient,​ 6 decimals>,​ <Add calibration coefficient,​ 6 decimals>​]"​\\ Example:\\ “OK, Calibration on short done. Measured Value: - 0.000028 V, Dispersion: 0.00%" ​                                                                                                                                    | :::                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | 
-| "​ERROR,​ Invalid scale index" ​                                                                                                                                                                                                                                                                                                                                                                                                             | ERROR, invalid selected scale index. ​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | 
-| "​ERROR,​ Valid DMM data timeout" ​                                                                                                                                                                                                                                                                                                                                                                                                          | ERROR, a valid data was not received within expected time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | 
-| "​ERROR,​ The provided value \"<​provided value string>​\"​ has a wrong measure unit." ​                                                                                                                                                                                                                                                                                                                                                        | <This message may occur just for positive and negative calibration>​\\ ERROR, the measure unit does not match the scale unit. This shouldn’t occur if reference value is correctly provided. ​                                                                                                                                                                                                                                                                                                                                       | 
-| "​ERROR,​ The provided value \"<​provided value string>​\"​ must have a measure unit." ​                                                                                                                                                                                                                                                                                                                                                        | <This message may occur just for positive and negative calibration>​\\ ERROR, the value must be followed by an Unit. This shouldn’t occur if reference value is correctly provided. ​                                                                                                                                                                                                                                                                                                                                                | 
-| “ERROR, Missing valid reference value: \"<​provided value string>​\"​” ​                                                                                                                                                                                                                                                                                                                                                                      | <This message may occur just for positive and negative calibration>​\\ ERROR, the provided reference value is not valid. This shouldn’t occur if reference value is correctly provided. ​                                                                                                                                                                                                                                                                                                                                            | 
-| "​ERROR:​ Calibration measure dispersion error: Measured <​measured value, 6 decimals, followed by Unit>, Reference: <​reference value, 6 decimals, followed by Unit>, Dispersion: <​Dispersion,​ 2 decimals>​%,​ Max. dispersion: <Max Dispersion, 2 decimals>​%" ​                                                                                                                                                                                | ERROR, the measurement dispersion is outside the expected limits.\\ The values are just for information,​ no need to be extracted. ​                                                                                                                                                                                                                                                                                                                                                                                                 | 
-| "​ERROR,​ Unrecognized calibration setting" ​                                                                                                                                                                                                                                                                                                                                                                                                | ERROR, the DMMCalib is not followed by any of '​P',​ '​N'​ or '​S'​ characters. ​                                                                                                                                                                                                                                                                                                                                                                                                                                                         | 
- 
-==== DMMMeasureForCalibCalib ==== 
-=== Syntax: ===  
-“DMMMeasureForCalibCalib<​P or N>” 
- 
-=== Example: ===  
-“DMMMeasureForCalibCalibP”\\ ​ 
-or\\  
-“DMMMeasureForCalibCalibN”\\ ​ 
- 
- 
- 
- 
-=== Description:​ ===  
-This command initiates the positive or negative (depending on the character following DMMCalib command: ‘P’ or ‘N’) measurement for calibration,​ depending on the character following DMMCalib command (‘P’ or ‘N’). This is performed by initiating a measurement and then saving the measured value to be later processed when all the needed data will be present and the calibration will be finalized. Compared to [[#​dmmcalib|DMMCalib]] function, the calibration process is split in two steps: ​ 
-- the calibration measurement is launched (using this command) prior declaring the reference value 
-- the reference value is later declared using [[#​dmmfinalizecalib|DMMFinalizeCalib]] command. 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
- 
-=== Answer: ===  
- 
-^ Answer ​                                                                                                                                                                                          ^ Meaning ​                                                                                                                                                                                                                                              ^ 
-| “OK, Calibration positive measurement done. Measured Value: <​measured value, 6 decimals, followed by Unit>"​\\ Example:\\ “Calibration positive measurement done. Measured Value: 5.108844 V" ​    | Success.\\ <The message is dependent to the calibration type (positive or negative)>​\\ \\ The values included in the message are formatted as explained in the [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter. ​ | 
-| “OK, Calibration negative measurement done. Measured Value: ​ <​measured value, 6 decimals, followed by Unit>"​\\ Example:\\ “Calibration negative measurement done. Measured Value: ​ -5.109310 V" ​ | :::                                                                                                                                                                                                                                                   | 
-| "​ERROR,​ Invalid scale index" ​                                                                                                                                                                    | ERROR, invalid selected scale index. ​                                                                                                                                                                                                                 | 
-| "​ERROR,​ Valid DMM data timeout" ​                                                                                                                                                                 | ERROR, a valid data was not received within expected time.                                                                                                                                                                                            | 
-| "​ERROR,​ Unrecognized calibration setting" ​                                                                                                                                                       | ERROR, the DMMMeasureForCalibCalib command is not followed by any of ‘P’ or ‘N’ characters. ​                                                                                                                                                          | 
- 
-==== DMMFinalizeCalib ==== 
-=== Syntax: ===  
-“DMMFinalizeCalib<​P or N> <​reference value>​” 
- 
-=== Example: ===  
-“DMMFinalizeCalibP 5.000115 V”\\ ​ 
-or\\  
-“DMMFinalizeCalibN -5.001185” 
- 
- 
- 
- 
-=== Description:​ ===  
-This command finalizes the positive or negative (depending on the character following DMMCalib command: ‘P’ or ‘N’) calibration process started using DMMeasureForCalib by declaring the reference value. The reference value is saved to be later processed when all the needed data will be present and the calibration will be finalized. Compared to [[#​dmmcalib|DMMCalib]] function, the calibration process is split in two steps: ​ 
-- the calibration measurement is launched (using [[#​dmmmeasureforcalib|DMMeasureForCalib]] command) prior declaring the reference value 
-- the reference value is later declared using this command. 
- 
- 
- 
-=== Parameters: ===  
- 
-|<​reference value, 6 decimals, followed by Unit> |This parameter is only for positive and negative calibrations.\\ This is a character string containing a formatted value. For more details see [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter. | 
- 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| OK, Calibration on positive done. Reference: <​reference value, 6 decimals, followed by Unit>, Measured: <​measured value, 6 decimals, followed by Unit>, Dispersion: <​dispersion,​ 2 decimals>​%[Coeff:​ <Mult calibration coefficient,​ 6 decimals>,​ <Add calibration coefficient,​ 6 decimals>​]"​\\ Example:\\ “OK, Calibration on positive done. Reference: 5.000115 V, Measured: 5.108844 V, Dispersion: 0.02% Coeff: -0.067295, 0.043947"​ | Success.\\ <The message is dependent to the calibration type (positive or negative)>​\\ \\The calibration coefficients are appended in the end of the message only if this calibration finalizes a calibration process.\\ \\ The dispersion is computed as the difference between the measured and the reference values, divided by the scale range.\\ \\ The values included in the message are formatted as explained in the [[#​interpreting_values_provided_as_parameter|Interpreting values provided as parameter]] chapter.| 
-| “OK, Calibration on negative done. Reference: <​reference value, 6 decimals, followed by Unit>, Measured: <​measured value, 6 decimals, followed by Unit>, Dispersion: <​dispersion,​ 2 decimals>​%[Coeff:​ <Mult calibration coefficient,​ 6 decimals>,​ <Add calibration coefficient,​ 6 decimals>​]"​\\Example:​\\ “OK, Calibration on negative done. Reference: -5.001185 V, Measured: -5.109310 V, Dispersion: 0.02%" | ::: | 
-| "​ERROR,​ Invalid scale index" | ERROR, invalid selected scale index.| 
-| "​ERROR,​ The provided value \"<​provided value string>​\"​ has a wrong measure unit." | <This message may occur just for positive and negative calibration>​\\ ERROR, the measure unit does not match the scale unit. This shouldn’t occur if reference value is correctly provided.| 
-| "​ERROR,​ The provided value \"<​provided value string>​\"​ must have a measure unit." | <This message may occur just for positive and negative calibration>​\\ ERROR, the value must be followed by an Unit. This shouldn’t occur if reference value is correctly provided.| 
-| “ERROR, Missing valid reference value: \"<​provided value string>​\"​” | <This message may occur just for positive and negative calibration>​\\ ERROR, the provided reference value is not valid. This shouldn’t occur if reference value is correctly provided.| 
-| "​ERROR:​ Calibration measure dispersion error: Measured <​measured value, 6 decimals, followed by Unit>, Reference: <​reference value, 6 decimals, followed by Unit>, Dispersion: <​Dispersion,​ 2 decimals>​%,​ Max. dispersion: <Max Dispersion, 2 decimals>​%"​ | ERROR, the measurement dispersion is outside the expected limits.\\ The values are just for information,​ no need to be extracted.| 
-| "​ERROR,​ Unrecognized calibration setting"​ | ERROR, the DMMFinalizeCalib is not followed by any of ‘P’, or ‘N’ characters.| 
- 
-==== DMMSaveEPROM ==== 
-=== Syntax: ===  
-“DMMSaveEPROM” 
- 
- 
-=== Description:​ ===  
-This command saves to user EPROM all the calibrations. It is important to save calibration data to EPROM after calibrations are performed, otherwise the calibrations are lost next time the board is powered off. 
- 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| "OK, <number of saved calibrations>​ calibrations written to EPROM"​\\ Example:\\ "OK, 4 calibrations written to EPROM" | Success.\\ The message also communicates the number of calibrations performed since the last power up and not saved to EPROM.| 
-| “ERROR, EPROM write data ready timeout ” | ERROR, the write to EPROM failed. | 
- 
-==== DMMVerifyEPROM ==== 
-=== Syntax: ===  
-“DMMVerifyEPROM” 
- 
- 
-=== Description:​ ===  
-This function verifies the content of the calibration data against the user calibration data stored in EPROM. 
- 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| "OK, EPROM Calibration data is verified"​ | Success, the calibration data is identical with the user calibration data stored in EPROM.| 
-| "​ERROR,​ EPROM Calibration data mismatch values found" | ERROR, the calibration data is different than the user calibration data stored in EPROM. | 
-| "​ERROR,​ EPROM write data ready timeout " | ERROR, the write to EPROM failed. | 
-| "​ERROR,​ Invalid EPROM magic number"​ | ERROR, the magic number was not properly retrieved. ​ | 
-| "​ERROR,​ Invalid EPROM checksum"​ | ERROR, the checksum does not match the content. | 
- 
-==== DMMExportCalib ==== 
-=== Syntax: ===  
-“DMMExportCalib” 
- 
- 
-=== Description:​ ===  
-This command exports the content of the user calibration data as a table, showing for each scale index the additive and multiplicative coefficients. The coefficients are formatted as fractional numbers, with 6 decimals. 
- 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| "OK, Calibration data is exported ​ <one line for each scale, showing “<​Scale index>, <​Multiplicative calibration coefficient>,​ <​Additive calibration coefficient>​”>​\\ Example:\\ OK, Calibration data is exported\\ 00, 0.000000, 0.000000\\ 01, 0.000000, 0.000000\\ 02, 0.000000, 0.000000\\ 03, 0.000000, 0.000000\\ 04, 0.000000, 0.000000\\ 05, 0.000000, 0.000000\\ 06, 0.000000, 0.000000\\ 07, 0.000000, 0.000000\\ 08, -0.021222, -0.000072\\ 09, -0.032600, 0.000125\\ 10, 0.000000, 0.000000\\ 11, 0.000000, 0.000000\\ 12, -0.062725, 0.004843\\ 13, 0.000000, 0.000000\\ 14, 0.000000, 0.000000\\ 15, 0.000000, 0.000000\\ 16, 0.000000, 0.000000\\ 17, 0.000000, 0.000000\\ 18, 0.000000, 0.000000\\ 19, 0.000000, 0.000000\\ 20, 0.000000, 0.000000\\ 21, 0.000000, 0.000000\\ 22, 0.000000, 0.000000\\ 23, 0.000000, 0.000000\\ 24, 0.000000, 0.000000\\ 25, 0.000000, 0.000000\\ 26, 0.000000, 0.000000 | Success, the tabular data shows signed values, 6 digits for calibration coefficients.| 
-| "​ERROR,​ EPROM Calibration data mismatch values found" | ERROR, the calibration data is different than the user calibration data stored in EPROM. | 
-| "​ERROR,​ Invalid EPROM magic number"​ | ERROR, the magic number was not properly retrieved when reading from EPROM. ​ | 
-| "​ERROR,​ Invalid EPROM checksum"​ | ERROR, the checksum does not match the content when reading from EPROM. | 
- 
- 
-==== DMMImportCalib ==== 
-=== Syntax: ===  
-“DMMImportCalib <Scale index>, <​Multiplicative calibration coefficient>,​ <​Additive calibration coefficient>​” 
- 
-=== Example: ===  
-“DMMImportCalib 10, 0.021222, -0.000125” 
- 
-=== Description:​ ===  
-This command imports the calibration data for a specific scale. It does not save calibration the data in EPROM. 
- 
- 
- 
-=== Parameters: ===  
- 
-|<Scale index>​|the index of the scale whose coefficients are imported (integer number)| 
-|<​Multiplicative calibration coefficient>​|the multiplicative coefficient to be imported (signed float value)| 
-|<​Additive calibration coefficient>​|the additive coefficient to be imported (signed float value)| 
- 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| “OK, Scale: <scale index>, Calibration coefficients:​ Mult = <​Multiplicative calibration coefficient>,​ Add = <​Additive calibration coefficient>​”\\ Example:​\\ ​ “OK, Scale: 10, Calibration coefficients:​ Mult = 0.021222, Add = -0.000125”| Success, the calibration data is imported, the message communicates the scale index (integer value), the calibration multiplicative coefficient (6 decimals signed value) and the calibration additive coefficient (signed float value) | 
-| "​ERROR,​ Invalid scale index " | ERROR, invalid selected scale index. | 
-| "​ERROR,​ Invalid value, provide a float number for second token" | ERROR, the second parameter does not contain a proper integer value (signed float value).| 
-| "​ERROR,​ Invalid value, provide a float number for third token" | ERROR, the third parameter does not contain a proper integer value (signed float value). | 
-| "​ERROR,​ The expected parameters were not provided on the UART command"​ | ERROR, the three expected parameters were not provided.| 
- 
-==== DMMRestoreFactCalibs ==== 
-=== Syntax: ===  
-“DMMRestoreFactCalibs” 
- 
- 
- 
-=== Description:​ ===  
-This command restores the calibration data with the factory loaded values. It reads data from the factory calibration area of EPROM and saves it to the user calibration area of EPROM. 
- 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| "OK, Calibration data restored from FACTORY EPROM"​| Success, the calibration data is restored from the Factory Calibration area of EPROM.| 
-| "​ERROR,​ Invalid EPROM magic number"​| ERROR, the magic number was not properly retrieved.| 
-| "​ERROR,​ Invalid EPROM checksum"​ | ERROR, the checksum does not match the content.| 
-| “ERROR, EPROM write data ready timeout ” | ERROR, the write to EPROM failed.| 
- 
-==== DMMReadSerialNo ==== 
-=== Syntax: ===  
-“DMMReadSerialNo” 
- 
- 
- 
-=== Description:​ ===  
-This command retrieves the 12 digits serial number information from EPROM. 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
- 
-=== Answer: ===  
- 
-^ Answer ​ ^ Meaning ​ ^ 
-| “OK, SerialNo = \"<​12 characters serial number>​\"​”\\ Example:\\ "OK, SerialNo = "​210356A76C0C""​| Success, the message contains serial number information.| 
-| "​ERROR,​ Invalid EPROM magic number"​| ERROR, the magic number was not properly retrieved.| 
-| "​ERROR,​ Invalid EPROM checksum"​ | ERROR, the checksum does not match the content.| 
- 
- 
- 
-===== DMM module ===== 
-The DMM library module implements DMM (digital multimeter) related functions.\\ ​ 
-Basically, these functions configure the DMM device over the custom SPI in order to set a specific scale. They read over the custom SPI the status / convertor values specific to each scale, thus retrieving measured values.\\ ​ 
-The value retrieval function waits until the converters provide valid values. The values retrieved from DMM device are considered raw values. The DMM module applies (controlled by a flag) calibration coefficients over the raw values, obtaining measured values. See [[#​calibration_procedure|Calibration Procedure]] for more details.\\ ​ 
-In order to implement the custom SPI communication,​ the DMM module accesses functions implemented in [[#​spi_module|SPI Module]]. It uses digital IO pins exposed in the DMMShield connector: CS_DMM (SPI chip select), DO (SPI MISO), DI (SPI MOSI) and CLK (SPI CLK). While the chip select is specific to DMM, the SPI lines (data and clock) are shared with EPROM Device.\\ ​ 
-The DMM module functions are accessed by [[#​calib_module|CALIB Module]] and [[#​dmmcmd_module|DMMCMD module]] functions. See [[#​library_overall_structure|Library overall structure]] for more details about the interaction between modules.\\ ​ 
-See [[#​dmm_device|DMM device]] for more details about DMM functionality.\\ ​ 
-See [[#​dmm_measured_values|DMM Measured Values]] for more information regarding the values retrieved from DMM.\\ ​ 
-Read [[#​dmm_getvalue|DMM_DGetValue]] for more details about the measured values.\\ ​ 
- 
-The DMM functions can be grouped in the following way:​\\ ​ 
-- Initialization:​\\ ​ 
-  * [[#​dmm_init|DMM_Init]] \\  
-- Scale functions: 
-  * [[#​dmm_setscale|DMM_SetScale]] 
-  * [[#​dmm_getcurrentscale|DMM_GetCurrentScale]] 
-- Value functions: 
-  * [[#​dmm_getvalue|DMM_DGetValue]] 
-  * [[#​dmm_dgetavgvalue|DMM_DGetAvgValue]] 
-  * [[#​dmm_setusecalib|DMM_SetUseCalib]] 
-  * [[#​dmm_checkacceptedmeasureddispersion|DMM_CheckAcceptedMeasurementDispersion]] 
-- Value formatting functions: 
-  * [[#​dmm_formatvalue|DMM_FormatValue]] 
-  * [[#​dmm_interpretvalue|DMM_InterpretValue]] 
- 
- 
- 
- 
-==== DMM_Init ==== 
-=== Synopsis: ===  
-void DMM_Init(); 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Return value: ===  
- 
-<​none>​ 
-=== Description:​ ===  
-This function initializes the DMM module.\\ ​ 
-It calls the SPI_Init() function to initialize the digital pins used by DMMShield. 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-DMM_Init(); 
- 
-==== DMM_SetScale ==== 
-=== Synopsis: ===  
-uint8_t DMM_SetScale(int idxScale); 
- 
-=== Parameters: ===  
- 
-|int idxScale|the Scale index| 
- 
-=== Return value: ===  
- 
-uint8_t - The error code: 
-|ERRVAL_SUCCESS| 0|success| 
-|ERRVAL_DMM_IDXCONFIG| 0xFC |wrong scale index| 
-|ERRVAL_DMM_CFGVERIFY| 0xF5|DMM Configuration verify error| 
- 
-=== Description:​ ===  
-This function configures a specific scale as the current scale. 
-According to this scale, it uses data defined in dmmcfg structure to configure the switches and to set the value of the registers (24 registers starting at 0x1F address).\\ ​ 
-It also verifies the configuration setting success status by reading the values of these registers.\\ ​ 
-It returns ERRVAL_SUCCESS if the operation is successful.\\ ​ 
-It returns ERRVAL_DMM_CFGVERIFY if verifying fails.\\ ​ 
-It returns ERRVAL_DMM_IDXCONFIG if the scale index is not valid. 
- 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-bErrCode = DMM_SetScale(idxCfg); ​ 
- 
-==== DMM_GetCurrentScale ==== 
-=== Synopsis: ===  
-int DMM_GetCurrentScale();​ 
- 
-=== Parameters: ===  
-<​none>​ 
- 
- 
- 
-=== Return value: ===  
-int 
-|positive value|current scale index| 
-|-1|if no current scale was selected| 
- 
-=== Description:​ ===  
-This function returns the current scale index. This is the last scale index selected using the DMM_SetScale function.\\ ​ 
-In case no current scale was selected, the function returns -1. 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-int idxScale = DMM_GetCurrentScale();​ 
- 
- 
-==== DMM_DGetValue ==== 
-=== Synopsis: ===  
-double DMM_DGetValue(uint8_t *pbErr); 
- 
-=== Parameters: ===  
-|uint8_t *pbErr|Pointer to the error parameter| 
-The *pbErr parameter can be set to: 
-|ERRVAL_SUCCESS| 0|success| 
-|ERRVAL_DMM_VALIDDATATIMEOUT| 0xFA|wrong scale index| 
-|ERRVAL_DMM_IDXCONFIG| 0xFC|wrong scale index| 
- 
- 
- 
-=== Return value: ===  
-double 
-|the measured value (value computed according to the converter / RMS registers values)| 
-|+/- INFINITY if the converter / RMS registers values are outside the expected range. The INFINITY special value is defined as 1e+308| 
-|NAN (not a number) value if ERRVAL_DMM_IDXCONFIG or ERRVAL_DMM_VALIDDATATIMEOUT are set. The NAN special value is defined as 0.0f/0.0f| 
- 
-=== Description:​ ===  
-This function repeatedly retrieves the value from the converter / RMS registers, until a valid value is detected\\ ​ 
-It returns INFINITY when measured values are outside the expected converter range.\\ ​ 
-If there is no valid current scale selected, the function sets the error value to ERRVAL_DMM_IDXCONFIG and NAN value is returned.\\ ​ 
-If there is no valid value retrieved within a specific timeout period, the error is set to ERRVAL_DMM_VALIDDATATIMEOUT and NAN value is returned.\\ ​ 
-When no errors are detected, the error is set to ERRVAL_SUCCESS.\\ ​ 
-The error is copied in the byte pointed by pbErr, if pbErr is not null. 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-double dVal = DMM_DGetValue(&​bErr);​ 
- 
-==== DMM_DGetAvgValue ==== 
-=== Synopsis: ===  
-double DMM_DGetAvgValue(uint8_t *pbErr); 
- 
-=== Parameters: ===  
-|int cbSamples|The number of values to be used for the average value| 
-|uint8_t *pbErr|Pointer to the error parameter| 
-The *pbErr parameter can be set to: 
-|ERRVAL_SUCCESS| 0|success| 
-|ERRVAL_DMM_VALIDDATATIMEOUT| 0xFA|wrong scale index| 
-|ERRVAL_DMM_IDXCONFIG| 0xFC|wrong scale index| 
- 
- 
- 
-=== Return value: ===  
-double 
-|the average of the measured values (values computed according to the converter / RMS registers values)| 
-|+/- INFINITY if the converter / RMS registers values are outside the expected range. The INFINITY special value is defined as 1e+308| 
-|NAN (not a number) value if ERRVAL_DMM_IDXCONFIG or ERRVAL_DMM_VALIDDATATIMEOUT are set. The NAN special value is defined as 0.0f/0.0f| 
- 
-=== Description:​ ===  
-This function computes an average value corresponding to the DMM value returned by DMM_DGetValue,​ for the specified number of samples.\\ ​ 
-If there is no valid current scale selected, the error is set to ERRVAL_DMM_IDXCONFIG.\\ ​ 
-If there is no valid value retrieved within a specific timeout period, the error is set to ERRVAL_DMM_VALIDDATATIMEOUT.\\ ​ 
-It returns INFINITY when measured values are outside the expected convertor range.\\ ​ 
-When no error is detected, the error is set to ERRVAL_SUCCESS.\\  ​ 
-The error is copied on the byte pointed by pbErr, if pbErr is not null.\\ ​ 
-When errors are detected, the function returns NAN. 
- 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-double dVal;​\\ ​ 
-dVal = DMM_DGetAvgValue(20,​ &​bResult);​ 
- 
-==== DMM_SetUseCalib ==== 
-=== Synopsis: ===  
-void DMM_SetUseCalib(uint8_t f); 
- 
-=== Parameters: ===  
-|uint8_t f|1| if calibrations coefficients should be applied in future DMM_DGetStatus calls| ​ 
-| ::: |0| if calibrations coefficients should not be applied in future DMM_DGetStatus calls| 
- 
-=== Return value: ===  
-<​none>​ 
-=== Description:​ ===  
-This function sets the parameter that will determine whether or not the calibration coefficients will be applied when value is computed in subsequent DMM_DGetStatus calls.\\ ​ 
-The default value for this parameter is 1. 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-DMM_SetUseCalib(0);​ 
- 
- 
- 
- 
-==== DMM_CheckAcceptedMeasurementDispersion ==== 
-=== Synopsis: ===  
-uint8_t DMM_CheckAcceptedMeasurementDispersion(double dMeasuredVal,​ double dRefVal, double *pDispersion);​ 
- 
-=== Parameters: ===  
-|double dMeasuredVal|The measured value| 
-|double dRefVal|The reference value| 
-|double *pDispersion|Pointer to receive the measured value dispersion| 
- 
- 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_DMM_MEASUREDISPERSION|0xF1|The measurement dispersion exceeds accepted range| 
- 
-=== Description:​ ===  
-This function checks if the  measurement dispersion exceeds the accepted range.\\ ​ 
-The dispersion is computed as the difference of the measured and reference values, divided by the scale range.\\  ​ 
-The positive dispersion is checked to be smaller than parameter calibAcceptP of the scale configuration data.\\ ​ 
-The range of accepted values for dispersion is specific to each scale and it's defined in dmmcfg array.\\ ​ 
-The positive values of dispersion are checked to be smaller than field calibAcceptP of dmmcfg.\\ ​ 
-The negative values of dispersion are checked to be smaller than field calibAcceptN of dmmcfg.\\ ​ 
-If dispersion is not in the accepted range then ERRVAL_DMM_MEASUREDISPERSION is returned and the error string is set to last error string in ERRORS module. This string can be later accessed with ERRORS_GetszLastError function.\\ ​ 
-If there is no valid current configuration selected, the function returns ERRVAL_DMM_IDXCONFIG.\\ ​ 
-When dispersion is in the accepted range, the function returns ERRVAL_SUCCESS. 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-bResult = DMM_CheckAcceptedMeasurementDispersion( *pMeasuredVal,​ dRefVal, pDispersion);​ 
- 
- 
-==== DMM_FormatValue ==== 
-=== Synopsis: ===  
-uint8_t DMM_FormatValue(double dVal, char *pString); 
- 
-=== Parameters: ===  
-|double dVal|The value to be formatted| 
-|char *pString|The string to get the formatted value| 
-|uint8_t fUnit|flag to indicate if unit information should be added\\ - not 0   - add unit / subunit\\ -     ​0 ​  - do not add unit| 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
- 
-=== Description:​ ===  
-The function formats a value according to the current selected scale.\\ ​ 
-The parameter value dVal must correspond to the base Unit (V, A or Ohm), mainly a measured value returned by [[#​dmm_getvalue|DMM_DGetValue]].\\ ​ 
-The function multiplies the value according to the scale specific multiple / submultiple.\\ ​ 
-It formats the value with 6 decimals. \\  
-If fUnit is not 0 it adds the measure unit text (including multiple / submultiple) corresponding to the scale.\\ ​ 
-If dVal is +/- INFINITY (converter values are outside expected range), then "​OVERLOAD"​ string is used for all scales except Continuity.\\ ​ 
-If dVal is +/- INFINITY (converter values are outside expected range), then "​OPEN"​ string is used for Continuity scale.\\ ​ 
-The function returns ERRVAL_DMM_IDXCONFIG if the current scale is not valid.\\ ​ 
-For example it formats the value 0.0245678912 into the "​24.678912 mV" if the current scale is VoltageDC50m. 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-DMM_FormatValue(dRefVal,​ szRefVal); 
- 
-==== DMM_InterpretValue ==== 
-=== Synopsis: ===  
-uint8_t DMM_InterpretValue(char *pString, double *pdVal); 
- 
-=== Parameters: ===  
-|char *pString|the string containing the value to be interpreted| 
-|double *pdVal|pointer to a double variable to get the value| 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_CMD_VALWRONGUNIT|0xF4|The provided value has a wrong measure unit.| 
-|ERRVAL_CMD_VALFORMAT|0xF2|The numeric value cannot be extracted from the provided string.| 
- 
-=== Description:​ ===  
-The function extracts a value from a string containing a value, eventually followed by a Unit.\\ ​ 
-The string Unit must match the current scale base Unit (V, A or Ohm), still different multiples / submultiples can be used.\\ ​ 
- The function returns in the variable pointed by pdVal the extracted value in the base Unit, regardless of the multiple / submultiple used in the input string, or the multiple / submultiple specific to the current scale.\\ ​ 
-If the string is "​OVERLOAD"​ or "​OPEN",​ then INFINITY value is returned.\\ ​ 
-If the measure unit is missing then the unit (with multiple / submultiple) corresponding to the current scale is used.\\ ​ 
-The function returns ERRVAL_DMM_IDXCONFIG if the current scale is not valid.\\ ​ 
-The function returns ERRVAL_CMD_VALWRONGUNIT if the measure unit does not match the current scale base Unit (V, A or Ohm).\\ ​ 
-The function returns ERRVAL_CMD_VALMISSINGUNIT if the measure unit is missing.\\ ​ 
-The function returns ERRVAL_CMD_VALFORMAT if the numeric value cannot be extracted from the provided string. 
-For example it interprets the string "​24.678912 mV" and returns the value 0.0245678912 if the current scale is any of the Voltage scales.\\ ​ 
- 
- 
- 
-=== Example: ===  
- 
-#include "​dmm.h"​\\ ​ 
-bErrCode = DMM_InterpretValue(szVal,​ &​dRefVal); ​     ​ 
- 
- 
- 
-===== CALIB module ===== 
- 
-CALIB module groups functions that implement calibration functionality of DMMShield. The functions are implemented in calib.c source file.\\ ​ 
-The DMMShield measuring hardware has errors due to DMM device and DMMShield additional electronics.\\ ​ 
-Calibration is the process of establishing some correction coefficients that, applied to the acquired values, allow more precise measurements. 
-Calibration is done for each scale (see [[#​dmm_module|DMM module]]).\\ ​ 
-For each scale, calibration is done in multiple points: positive, on short or negative, depending on scale). The positive / negative calibrations are done at a value close to the maximum / minimum scale value. The reference value is measured using a separate measuring device, as accurate as possible.\\ ​ 
-Basically calibration is done by calling calibration functions to inform the system that in a specific moment the reference values are applied to the DMMShield connectors. The library functions initiate a DMMShield measurement and then the measured value and reference value are stored, to be used when all the calibration data exists. 
- 
-Basically there are three groups of functions:​\\ ​ 
-- Initialization:​\\ ​ 
-  * [[#​calib_init|CALIB_Init]] \\  
-- Functions that implement calibration functionality:​ 
-  * [[#​calib_calibonpositive|CALIB_CalibOnPositive]] 
-  * [[#​calib_calibonnegative|CALIB_CalibOnNegative]] 
-  * [[#​calib_calibonshort|CALIB_CalibOnShort]] 
-  * [[#​calib_measureforcalibpositiveval|CALIB_MeasureForCalibPositiveVal]] 
-  * [[#​calib_measureforcalibnegativeval|CALIB_MeasureForCalibNegativeVal]] 
- 
-- Main functions that deal with EPROM calibration data: 
-  * [[#​calib_writeallcalibstoeprom_user|CALIB_WriteAllCalibsToEPROM_User]] 
-  * [[#​calib_readallcalibsfromeprom_user|CALIB_ReadAllCalibsFromEPROM_User]] 
-  * [[#​calib_restoreallcalibsfromeprom_factory|CALIB_RestoreAllCalibsFromEPROM_Factory]] 
- 
-- Auxiliary functions that deal with EPROM calibration data:: 
-  * [[#​calib_verifyeprom|CALIB_VerifyEPROM]] 
-  * [[#​calib_exportcalibs_user|CALIB_ExportCalibs_User]] 
-  * [[#​calib_exportcalibs_factory|CALIB_ExportCalibs_Factory]] 
-  * [[#​calib_importcalibcoefficients|CALIB_ImportCalibCoefficients]] 
- 
-Read Calibration chapter for more details about calibration.\\ ​ 
-The CALIB module maintains a data structure that stores the partial calibration data, called partCalibData,​ collecting (as a result of calls to calibration functions) all the necessary data until a calibration is complete. This has the following fields: 
-  * double Calib_Ms_Short;​ 
-  * double Calib_Ms_ValP;​ 
-  * double Calib_Ref_ValP;​ 
-  * double Calib_Ms_ValN;​ 
-  * double Calib_Ref_ValN;​ 
-These fields will be later used in the function description. 
- 
-==== CALIB_Init ==== 
-=== Synopsis: ===  
-uint8_t CALIB_Init();​ 
- 
-=== Parameters: ===  
- 
-<​none> ​                                                                                             ​ 
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_EPROM_MAGICNO|0xFD|wrong Magic No. when reading data from EPROM| 
-|ERRVAL_EPROM_CRC|0xFE|wrong CRC when reading data from EPROM| 
- 
- 
-=== Description:​ ===  
-This function initializes the calibration related data.\\ ​ 
-It initializes the EPROM module, the partial calibration data and reads all the calibration values from user calibration area of EPROM.\\ ​ 
-The return values are related to errors when calibration is read from user calibration area of EPROM.\\ ​ 
-The function returns ERRVAL_SUCCESS when success.\\ ​ 
-The function returns ERRVAL_EPROM_MAGICNO when a wrong magic number was detected in the data read from EPROM.\\ ​ 
-The function returns ERRVAL_EPROM_CRC when the checksum is wrong for the data read from EPROM.\\ ​ 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bResult = CALIB_Init();​ 
- 
- 
- 
-==== CALIB_CalibOnPositive ==== 
-=== Synopsis: ===  
-uint8_t CALIB_CalibOnPositive(double dRefVal, double *pMeasuredVal,​ uint8_t bEarlyMeasurement,​ double *pDispersion,​ uint8_t fIgnoreDispersion);​ 
- 
-=== Parameters: ===  
-| double dRefVal ​            | The reference value, to be used in the calibration procedure ​                                                                                                 | 
-| double *pMeasuredVal ​      | Pointer to a double variable that will store the measured value                                                                                               | 
-| uint8_t bEarlyMeasurement ​ | Parameter indicating if an early measurement was performed:​\\ - non 0  - An early measurement was performed.\\ - 0 - An early measurement was not performed. ​ | 
-| double *pDispersion ​       | Pointer to a double variable that will store the measured value dispersion ​                                                                                   | 
-| uint8_t fIgnoreDispersion ​ | Flag used to request the dispersion check to be ignored:\\ - non 0  - Skip the dispersion check.\\ - 0 - Perform the dispersion check. ​                       | 
- 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_DMM_VALIDDATATIMEOUT|0xFA|valid data DMM timeout| 
-|ERRVAL_CMD_VALMISSINGUNIT|0xF3|The provided value does not contain a measure unit.| 
-|ERRVAL_DMM_MEASUREDISPERSION|0xF1|The calibration measurement dispersion exceeds accepted range.| 
-|ERRVAL_CALIB_MISSINGMEASUREMENT|0xF0|A measurement must be performed before calling the finalize calibration function.|\\ ​ 
-=== Description:​ ===  
-This function implements the calibration on positive value procedure, for the currently selected scale.\\ ​ 
-It is possible that function CALIB_MeasureForCalibPositiveVal was previously called. This is considered early measurement,​ and in this case parameter bEarlyMeasurement must be set to a non 0 value.\\ ​ 
-If no early measurement was performed (bEarlyMeasurement parameter is 0), the function calls CALIB_MeasureForCalibPositiveVal in order to perform the measurement and provide the measured value.\\  ​ 
-If early measurement was performed (bEarlyMeasurement parameter is non 0), the measured value is copied from Calib_Ms_ValP field of partCalibData.\\ ​ 
-If early measurement was performed and Calib_Ms_ValP is not valid (no valid measurement was previously performed), the function returns ERRVAL_CALIB_MISSINGMEASUREMENT.\\ ​ 
-The dispersion is computed as the difference of the measured and reference values, divided by the scale range. The dispersion is checked to be in the accepted range using DMM_CheckAcceptedMeasurementDispersion function.\\ ​ 
-If the parameter fIgnoreDispersion is non 0, the dispersion check is skipped, meaning that all the values are accepted and ERRVAL_DMM_MEASUREDISPERSION error is never returned\\ . 
-Caution when calling the function with fIgnoreDispersion parameter with non 0 values, as calibration data can be seriously altered.\\ ​ 
-If dispersion is not in the accepted range then calibration is not finalized, partial calibration data is initialized and ERRVAL_DMM_MEASUREDISPERSION is returned.\\ ​ 
-When success, the reference value is stored in the Calib_Ref_ValP field of partCalibData.\\ ​ 
-When success, if the calibration process is complete then the calibration coefficients are computed.\\ ​ 
-If there is no valid current configuration selected, the function returns ERRVAL_DMM_IDXCONFIG and the measured value is set to NAN.\\  ​ 
-If a valid measurement cannot be performed, the function returns ERRVAL_DMM_VALIDDATATIMEOUT and the measured value is set to NAN. 
- 
- 
- 
- 
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bErrCode = CALIB_CalibOnPositive(dRefVal,​ &​dMeasuredVal,​ 0, &​dispersion,​ 0);      ​ 
-\\ \\  
- 
-==== CALIB_CalibOnNegative ==== 
-=== Synopsis: ===  
-uint8_t CALIB_CalibOnNegative(double dRefVal, double *pMeasuredVal,​ uint8_t bEarlyMeasurement,​ double *pDispersion,​ uint8_t fIgnoreDispersion);​ 
- 
-=== Parameters: ===  
-| double dRefVal ​            | The reference value, to be used in the calibration procedure ​                                                                                                 | 
-| double *pMeasuredVal ​      | Pointer to a double variable that will store the measured value                                                                                               | 
-| uint8_t bEarlyMeasurement ​ | Parameter indicating if an early measurement was performed:​\\ - non 0  - An early measurement was performed.\\ - 0 - An early measurement was not performed. ​ | 
-| double *pDispersion ​       | Pointer to a double variable that will store the measured value dispersion ​                                                                                   | 
-| uint8_t fIgnoreDispersion ​ | Flag used to request the dispersion check to be ignored:\\ - non 0  - Skip the dispersion check.\\ - 0 - Perform the dispersion check. ​                       | 
- 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_DMM_VALIDDATATIMEOUT|0xFA|valid data DMM timeout| 
-|ERRVAL_CMD_VALMISSINGUNIT|0xF3|The provided value does not contain a measure unit.| 
-|ERRVAL_DMM_MEASUREDISPERSION|0xF1|The calibration measurement dispersion exceeds accepted range.| 
-|ERRVAL_CALIB_MISSINGMEASUREMENT|0xF0|A measurement must be performed before calling the finalize calibration function.|\\ ​ 
-=== Description:​ ===  
-This function implements the calibration on negative value procedure, for the current selected scale.\\ ​ 
-It is possible that function CALIB_MeasureForCalibNegativeVal was previously called. This is considered early measurement,​ and in this case parameter bEarlyMeasurement must be set to any non 0 value.\\ ​ 
-If no early measurement was performed (bEarlyMeasurement parameter is 0), the function calls CALIB_MeasureForCalibNegativeVal in order to perform the measurement and provide the measured value.\\  ​ 
-If early measurement was performed (bEarlyMeasurement parameter is non 0), the measured value is copied from Calib_Ms_ValN field of partCalibData. 
-If early measurement was performed and Calib_Ms_ValP is not valid (no valid measurement was previously performed), the function returns ERRVAL_CALIB_MISSINGMEASUREMENT.\\  
-The dispersion is computed as the difference of the measured and reference values, divided by the scale range. The dispersion is checked to be in the accepted range using DMM_CheckAcceptedMeasurementDispersion function.\\ ​ 
-If parameter fIgnoreDispersion is non 0, the dispersion check is skipped, meaning that all the values are accepted and ERRVAL_DMM_MEASUREDISPERSION error is never returned.\\ ​ 
-Caution when calling the function with fIgnoreDispersion parameter with non 0 values, as calibration data can be seriously altered.\\ ​ 
-If dispersion is not in the accepted range then calibration is not finalized, partial calibration data is initialized and ERRVAL_DMM_MEASUREDISPERSION is returned.\\ ​ 
-When success, the reference value is stored in the Calib_Ref_ValN field of partCalibData.\\ ​ 
-When success, if the calibration process is complete then the calibration coefficients are computed.\\ 
-If there is no valid current configuration selected, the function returns ERRVAL_DMM_IDXCONFIG and the measured value is set to NAN.\\  ​ 
-If a valid measurement cannot be performed, the function returns ERRVAL_DMM_VALIDDATATIMEOUT and the measured value is set to NAN.\\  ​ 
-\\  ​ 
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bErrCode = CALIB_CalibOnNegative(dRefVal,​ &​dMeasuredVal,​ 0, &​dispersion,​ 0);      
- 
-\\ \\  
- 
- 
-==== CALIB_CalibOnShort ==== 
-=== Synopsis: ===  
-uint8_t CALIB_CalibOnShort(double *pMeasuredVal,​ double *pDispersion,​ uint8_t fIgnoreDispersion);​ 
- 
-=== Parameters: ===  
- 
-| double *pMeasuredVal ​      | Pointer to a double variable that will store the measured value| ​                                                                                               
-| double *pDispersion ​       | Pointer to a double variable that will store the measured value dispersion ​                                                                                   | 
-| uint8_t fIgnoreDispersion ​ | Flag used to request the dispersion check to be ignored:\\ - non 0  - Skip the dispersion check.\\ - 0 - Perform the dispersion check. ​                       | 
- 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_DMM_VALIDDATATIMEOUT|0xFA|valid data DMM timeout| 
-|ERRVAL_DMM_MEASUREDISPERSION|0xF1|The calibration measurement dispersion exceeds accepted range.|\\ ​ 
-=== Description:​ ===  
-This function implements the calibration on short procedure, for the currently selected scale.\\ ​ 
-The function performs the measurement and then if the calibration process is complete the calibration coefficients are computed.\\ ​ 
-The dispersion is computed as the difference between the measured and reference values, divided by the scale range.\\ ​ 
-The dispersion is checked to be in the accepted range if parameter fIgnoreDispersion 0.\\  
-If parameter fIgnoreDispersion is non 0, the dispersion check is skipped, meaning that all the values are accepted and ERRVAL_DMM_MEASUREDISPERSION error is never returned. Caution when calling the function with fIgnoreDispersion parameter having values different than 0, as calibration data can be seriously altered.\\ ​ 
-If dispersion is not in the accepted range then calibration is not finalized, and ERRVAL_DMM_MEASUREDISPERSION is returned.\\ ​ 
-If there is no valid current configuration selected, the function returns ERRVAL_DMM_IDXCONFIG and the measured value is set to NAN.\\ ​ 
-If a valid measurement cannot be performed, the function returns ERRVAL_DMM_VALIDDATATIMEOUT and the measured value is set to NAN.\\ ​ 
-\\  ​ 
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bErrCode = CALIB_CalibOnShort(&​dMeasuredVal,​ &​dispersion,​ 0);      
-\\ \\  
-==== CALIB_MeasureForCalibPositiveVal ==== 
-=== Synopsis: ===  
-uint8_t CALIB_MeasureForCalibPositiveVal(double *pMeasuredVal);​ 
- 
-=== Parameters: ===  
- 
-| double *pMeasuredVal ​      | Pointer to a double variable that will store the measured value| ​                                                                                               
- 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_DMM_VALIDDATATIMEOUT|0xFA|valid data DMM timeout| 
-\\  
-=== Description:​ ===  
-This function performs the measurement for the calibration on positive value procedure, for the currently selected scale.\\ ​ 
-The function calls the DMM_DGetAvgValue function in order to acquire the measured value without the calibration correction being applied. ​     ​ 
-When success, the measured value is stored in the Calib_Ms_ValP field of partCalibData structure, and it's set as measured value.\\ ​ 
-If there is no valid current configuration selected, the function returns ERRVAL_DMM_IDXCONFIG and the measured value is set to NAN.\\  ​ 
-If a valid measurement cannot be performed, the function returns ERRVAL_DMM_VALIDDATATIMEOUT and the measured value is set to NAN.\\  ​ 
-This function can be called by CALIB_CalibOnPositive or can be called directly, before CALIB_CalibOnPositive (this is considered early measurement).\\ ​ 
- ​\\ ​ 
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bResult = CALIB_MeasureForCalibPositiveVal(pMeasuredVal); ​   ​ 
-\\ \\  
-==== CALIB_MeasureForCalibNegativeVal ==== 
-=== Synopsis: ===  
-uint8_t CALIB_MeasureForCalibNegativeVal(double *pMeasuredVal);​ 
- 
-=== Parameters: ===  
- 
-| double *pMeasuredVal ​      | Pointer to a double variable that will store the measured value| ​                                                                                               
- 
- 
-=== Return value: ===  
-uint8_t 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
-|ERRVAL_DMM_VALIDDATATIMEOUT|0xFA|valid data DMM timeout| 
-\\  
-=== Description:​ ===  
-This function performs the measurement for the calibration on negative value procedure, for the currently selected scale.\\ ​ 
-The function calls the DMM_DGetAvgValue function in order to acquire the measured value without the calibration correction being applied. ​     ​ 
-When success, the measured value is stored in the Calib_Ms_ValN field of partCalibData structure, and it's set as measured value.\\ ​ 
-If there is no valid current configuration selected, the function returns ERRVAL_DMM_IDXCONFIG and the measured value is set to NAN.\\  ​ 
-If a valid measurement cannot be performed, the function returns ERRVAL_DMM_VALIDDATATIMEOUT and the measured value is set to NAN.\\  ​ 
-This function can be called by CALIB_CalibOnNegative or can be called directly, before CALIB_CalibOnNegative (this is considered early measurement).\\ ​ 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bResult = CALIB_MeasureForCalibNegativeVal(pMeasuredVal); ​   
- 
-==== CALIB_WriteAllCalibsToEPROM_User ==== 
-=== Synopsis: ===  
-uint8_t CALIB_WriteAllCalibsToEPROM_User();​ 
- 
-=== Parameters: ===  
- 
-<​none> ​                                                                                             ​ 
- 
- 
-=== Return value: ===  
-uint8_t - Number of modified calibrations or the error code: 
-|Positive value <  27|0|success,​ number of modified calibration since last save| 
-|ERRVAL_EPROM_WRTIMEOUT|0xFF|EPROM write data ready timeout| 
- 
-\\  
-=== Description:​ ===  
-This function writes calibration data in the user calibration area of EPROM.\\  ​ 
-This function should be called after changes are made in calibration data, in order to save them in the non-volatile memory.\\  ​ 
-In case of success the function returns the number of configurations that were modified since last save.\\ ​ 
-It returns ERRVAL_EPROM_WRTIMEOUT when calibration data write in EPROM is not properly performed.\\ ​ 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bErrCode = CALIB_WriteAllCalibsToEPROM_User(); ​ 
- 
-==== CALIB_ReadAllCalibsFromEPROM_User ==== 
-=== Synopsis: ===  
-uint8_t CALIB_ReadAllCalibsFromEPROM_User();​ 
- 
-=== Parameters: ===  
- 
-<​none> ​                                                                                             ​ 
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_EPROM_MAGICNO|0xFD|wrong Magic No. when reading data from EPROM| 
-|ERRVAL_EPROM_CRC|0xFE|wrong CRC when reading data from EPROM| 
- 
- 
-=== Description:​ ===  
-This function reads the user calibration data from EPROM.\\ ​ 
-It calls the local function CALIB_ReadAllCalibsFromEPROM_Raw function providing the address of user calibration area in EPROM, ​ 
-The function returns ERRVAL_SUCCESS for success.\\ ​ 
-The function returns ERRVAL_EPROM_MAGICNO when a wrong magic number was detected in the data read from EPROM.\\ ​ 
-The function returns ERRVAL_EPROM_CRC when the checksum is wrong for the data read from EPROM.\\ ​ 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bResult = CALIB_ReadAllCalibsFromEPROM_User();​ 
- 
-==== CALIB_RestoreAllCalibsFromEPROM_Factory ==== 
-=== Synopsis: ===  
-uint8_t CALIB_RestoreAllCalibsFromEPROM_Factory();​ 
- 
-=== Parameters: ===  
- 
-<​none> ​                                                                                             ​ 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_EPROM_MAGICNO|0xFD|wrong Magic No. when reading data from EPROM| 
-|ERRVAL_EPROM_CRC|0xFE|wrong CRC when reading data from EPROM| 
-|ERRVAL_EPROM_WRTIMEOUT|0xFF|EPROM write data ready timeout| 
- 
- 
-=== Description:​ ===  
-This function restores the factory calibration data from EPROM.\\ ​ 
-This function reads factory calibration data from EPROM and writes the calibration data into the user calibration area of EPROM.\\ ​ 
-The function returns ERRVAL_SUCCESS for success.\\ ​ 
-It verifies the read factory calibration data from EPROM and detects the following errors: ERRVAL_EPROM_MAGICNO when a wrong magic number was detected, and ERRVAL_EPROM_CRC when the checksum is wrong.\\ ​ 
-It also returns ERRVAL_EPROM_WRTIMEOUT when calibration user data write in EPROM is not properly performed.\\ ​ 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bResult = CALIB_ReadAllCalibsFromEPROM_User();​ 
- 
-==== CALIB_VerifyEPROM ==== 
-=== Synopsis: ===  
-uint8_t CALIB_VerifyEPROM();​ 
- 
-=== Parameters: ===  
- 
-<​none> ​                                                                                             ​ 
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_EPROM_VERIFY|0xF7|EPROM verify error| 
-|ERRVAL_EPROM_MAGICNO|0xFD|wrong Magic No. when reading data from EPROM| 
-|ERRVAL_EPROM_CRC|0xFE|wrong CRC when reading data from EPROM| 
- 
- 
- 
-=== Description:​ ===  
-This function compares the user calibration data from EPROM with the current calibration data.\\  ​ 
-The function returns ERRVAL_SUCCESS for success, the user calibration data from EPROM is identical to the current calibration data.\\ ​ 
-The function returns ERRVAL_EPROM_VERIFY for mismatch values found when comparing the user calibration data from EPROM with the current calibration data.\\ ​ 
-The function returns ERRVAL_EPROM_MAGICNO when a wrong magic number was detected in the data read from EPROM.\\ ​ 
-The function returns ERRVAL_EPROM_CRC when the checksum is wrong for the data read from EPROM.\\ ​ 
- 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bErrCode = CALIB_VerifyEPROM();​ 
- 
-==== CALIB_ExportCalibs_User ==== 
-=== Synopsis: ===  
-uint8_t CALIB_ExportCalibs_User(char *pSzCalibs);​ 
- 
-=== Parameters: ===  
- 
-|char *pSzCalibs|pointer to a character string to hold the exported sequence| ​                                                                                             
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_EPROM_MAGICNO|0xFD|wrong Magic No. when reading data from EPROM| 
-|ERRVAL_EPROM_CRC|0xFE|wrong CRC when reading data from EPROM| 
- 
- 
- 
-=== Description:​ ===  
-This function exports user calibration data into a text.\\ ​   
-The export is performed by formatting the calibration values in a text, copied in pSzCalibs, one row for each Scale index.\\ ​ 
-Therefore is important that the caller of this function allocates enough space in pSzCalibs (750 characters).\\ ​ 
-The function returns ERRVAL_SUCCESS for success.\\ ​ 
-The function returns ERRVAL_EPROM_MAGICNO when a wrong magic number was detected in the data read from EPROM.\\ ​ 
-The function returns ERRVAL_EPROM_CRC when the checksum is wrong for the data read from EPROM.\\ ​ 
- 
- 
-  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-char calExp[1024];​\\ ​ 
-bErrCode = CALIB_ExportCalibs_User(calExp);​ 
- 
-==== CALIB_ExportCalibs_Factory ==== 
-=== Synopsis: ===  
-uint8_t CALIB_ExportCalibs_Factory(char *pSzCalibs);​ 
- 
-=== Parameters: ===  
- 
-|char *pSzCalibs|pointer to a character string to hold the exported sequence| ​                                                                                             
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_EPROM_MAGICNO|0xFD|wrong Magic No. when reading data from EPROM| 
-|ERRVAL_EPROM_CRC|0xFE|wrong CRC when reading data from EPROM| 
- 
- 
- 
-=== Description:​ ===  
-This function exports factory calibration data into a text.\\ ​ 
-The export is performed by formatting the calibration values in a text, copied in pSzCalibs, one row for each Scale index.\\ ​ 
-Therefore is important that the caller of this function allocates enough space in pSzCalibs (750 characters).\\ ​ 
-The function returns ERRVAL_SUCCESS for success.\\ ​ 
-The function returns ERRVAL_EPROM_MAGICNO when a wrong magic number was detected in the data read from EPROM.\\ ​ 
-The function returns ERRVAL_EPROM_CRC when the checksum is wrong for the data read from EPROM.\\ ​ 
-\\ \\  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-char calExp[1024];​\\ ​ 
-bErrCode = CALIB_ExportCalibs_Factory(calExp);​ 
- 
-==== CALIB_ImportCalibCoefficients ==== 
-=== Synopsis: ===  
-uint8_t CALIB_ImportCalibCoefficients(int idxScale, float fMult, float fAdd); 
- 
-=== Parameters: ===  
- 
-|int idxScale|the Scale index| 
-|float fMult|the calibration MULT coefficient| 
-|float fAdd|the calibration ADD coefficient| ​                                                   
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS|0|success| 
-|ERRVAL_DMM_IDXCONFIG|0xFC|wrong scale index| 
- 
-=== Description:​ ===  
-This function imports the MULT and ADD calibration coefficients,​ for the provided Scale.\\ ​ 
-On success, the coefficients are copied in the calibration data corresponding to the provided Scale.\\ ​ 
-The function copies the calibration coefficients into the calibration data and marks the calibration for the provided Scale as dirty (needs to be written in EPROM).\\ ​ 
-The function returns ERRVAL_DMM_IDXCONFIG if the provided Scale is not valid.\\ ​ 
-\\ \\  
-=== Example: ===  
- 
-#include "​calib.h"​\\ ​ 
-bErrCode = CALIB_ImportCalibCoefficients(10,​ 0.021222, -0.000125); 
-===== EPROM module ===== 
-The DMMShield provides a non-volatile EEPROM memory 93LC66BT, having 512 bytes (4kbits).\\ ​ 
-It is accessed over a custom SPI protocol, using digital IO pins exposed in the DMMSHield connector: CS_EEPROM (EPROM SPI chip select), DO (SPI MISO), DI (SPI MOSI) and CLK (SPI CLK).\\ ​ 
-While the chip select is specific to EPROM, the SPI lines (data and clock) are shared with DMM device (see [[#​dmm_module|DMM module]]). 
-The EPROM is used to store the following system information:​ 
-  * Serial number: 
-    * 12 bytes payload (see [[#​serial_number|Serial Number]]) 
-    * 2 extra bytes: magic number, checksum 
-    * Total 14 bytes, see the address space table below. 
-  * User Calibration:​ 
-    * 27*2*4 bytes payload (2 values of 4 byes (float) for 27 scales) 
-    * 2 extra bytes: magic number, checksum 
-    * Total 218 bytes, see the address space table below. 
-  * Factory Calibration:​ 
-    * 27*2*4 bytes payload (2 values of 4 byes (float) for 27 scales) 
-    * 2 extra bytes: magic number, checksum 
-    * Total 218 bytes, see the address space table below. 
-Note that the structure of User Calibration area is identical to the structure of Factory Calibration area.\\ ​ 
-For more details about Calibration process, read more on [[#​calib_module|CALIB module]].\\ ​ 
-Each of the tree above mentioned sections contains, for safety reasons, additional information:​ 
-  * a byte containing a specific number called magic number (0x23) 
-  * a byte containing the checksum of all the bytes written in the specific section 
-When reading a section content from EPROM, these two security bytes are checked, returning errors when mismatches are found. \\  
-The following table details the address space: 
-^ Addresses (words) ^ Addresses (bytes) ​ ^ Size ^ Content ^ 
-| 0x93 – 0xFF | 0x0126 – 0x01FF | 109 words /\\  218 bytes | Factory calibration data | 
-| 0x8C – 0x92 | 0x0118 – 0x0125 | 7 words /\\  14 bytes | Serial Number | 
-| 0x1F – 0x8B | 0x003E – 0x0117 | 109 words /\\  218 bytes | User calibration data | 
-| 0x00 – 0x1E | 0x0000 – 0x003D | 31 words /\\  62 bytes | Unused Memory | 
-The addressing unit of the memory is 16 bit word. As the memory capacity is 256 words, the word addresses are implemented using 8 bit byte type.\\ ​ 
-Apart from this system information stored in EPROM, applications can be implemented to store specific user data using write functions from EPROM module, to access the unused memory starting a address 0. These functions are protected against writing over the system areas detailed above. 
- 
- 
-==== Serial number ==== 
-Each board has a unique SerialNo, built as follows:​\\ ​ 
-  * 6 characters DMMShield prefix (Digilent ID + Schematic ID): “210356”\\ ​ 
-  * 6 characters unique serial of each board (read from the barcode label, after ‘D’): for example “A76C0C”\\ ​ 
-Example of DMM Shield SerialNo: “210356A76C0C”\\ ​ 
-This is written in the EPROM during the manufacturing procedure and shouldn’t be altered by the user. For more details see [[#​eprom_module|EPROM module]]. 
- 
-==== EPROM_Init ==== 
-=== Synopsis: ===  
-void EPROM_Init();​ 
- 
-=== Parameters: ===  
- 
-<​none>​ 
- 
-=== Return value: ===  
- 
-<​none>​ 
-=== Description:​ ===  
-This function initializes the EPROM module.\\ ​ 
-It calls the SPI_Init() function to initialize the digital pins used by DMMShield.\\ ​ 
-This function is called by CALIB_Init() and SERIALNO_Init().\\ ​ 
-The function guards against multiple calls using a static flag variable. 
- 
- 
-=== Example: ===  
- 
-#include "​eprom.h"​\\ ​ 
-EPROM_Init();​ 
- 
-==== EPROM_ReadWords ==== 
-=== Synopsis: ===  
-void EPROM_ReadWords(uint8_t bAddress, uint16_t *prgVals, int cwVals) 
- 
-=== Parameters: ===  
- 
-|uint8_t bAddress|the word address of the EPROM memory location to be read| 
-|uint16_t *prgVals|pointer to an array of 16 bits values, to store the values read from EPROM| 
-|int cwVals|number of 16 bits values to be read in EPROM| 
- 
- 
-=== Return value: ===  
-<​none>​ 
- 
-=== Description:​ ===  
-This function reads the specified number of words (16 bit values) from the specified EPROM word address into the specified buffer. 
- 
-=== Example: ===  
- 
-#include "​eprom.h"​\\ ​ 
-EPROM_ReadWords(0,​ (uint16_t *)&​pUserData,​ 31); 
- 
-==== EPROM_WriteWords ==== 
-=== Synopsis: ===  
-uint8_t EPROM_WriteWords(uint8_t bAddress, uint16_t *prgVals, int cwVals); 
- 
-=== Parameters: ===  
- 
-|uint8_t bAddress|the word address of the EPROM memory location to be written| 
-|uint16_t *prgVals|pointer to an array of words (16 bits values), to be written in EPROM| 
-|int cwVals|number of words to be written in EPROM| 
- 
- 
-=== Return value: ===  
-uint8_t - The error code: 
-|ERRVAL_SUCCESS| 0|success| 
-|ERRVAL_EPROM_ADDR_VIOLATION| 0xF6 |EPROM write address violation: attempt to write over system data| 
-|ERRVAL_EPROM_WRTIMEOUT| 0xFF |EPROM write data ready timeout| 
- 
-=== Description:​ ===  
-This function writes the specified number of words (16-bit values) in EPROM, at the specified word address.\\ ​ 
-It is mandatory to enable the write operation before sending the data to EPROM, by calling the EPROM_WriteEnable() function.\\ ​ 
-The function returns ​ ERRVAL_EPROM_ADDR_VIOLATION if write is attempted over the system reserved areas of EPROM.\\ ​ 
-Otherwise, the function returns ERRVAL_SUCCESS for success or ERRVAL_EPROM_WRTIMEOUT when EPROM is not answering with the write successful message. 
- 
-=== Example: ===  
- 
-#include "​eprom.h"​\\ ​ 
-bErrorCode = EPROM_WriteWords(0,​ (uint16_t *)&​pUserData,​ 31); 
- 
-==== EPROM_WriteEnable ==== 
-=== Synopsis: ===  
-void EPROM_WriteEnable();​ 
- 
-=== Parameters: ===  
-<​none>​ 
- 
-=== Return value: ===  
-<​none>​ 
- 
-=== Description:​ ===  
-This function implements the EWEN (Write Enable) EPROM instruction.\\ ​ 
-Call this function before any EPROM write operations. 
- 
-=== Example: ===  
- 
-#include "​eprom.h"​\\ ​ 
-EPROM_WriteEnable();​ 
- 
-==== EPROM_WriteDisable ==== 
-=== Synopsis: ===  
-void EPROM_WriteDisable();​ 
- 
-=== Parameters: ===  
-<​none>​ 
- 
-=== Return value: ===  
-<​none>​ 
- 
-=== Description:​ ===  
-This function implements the EWDS (Write Disable) EPROM instruction.\\ ​ 
-Use this function to protect the values written in EPROM against subsequent writes. 
- 
-=== Example: ===  
- 
-#include "​eprom.h"​\\ ​ 
-EPROM_WriteDisable();​ 
- 
-==== EPROM_Erase ==== 
-=== Synopsis: ===  
-void EPROM_Erase(uint8_t bAddress); 
- 
-=== Parameters: ===  
- 
-|uint8_t bAddress|the word address of the EPROM memory location to be erased| 
- 
- 
- 
-=== Return value: ===  
-<​none>​ 
- 
-=== Description:​ ===  
-This function implements the ERASE EPROM instruction that erases one word.\\ ​ 
-Call this function in order to force all 16 bits of the specified address to 1. 
- 
-=== Example: ===  
- 
-#include "​eprom.h"​\\ ​ 
-EPROM_Erase(0x10);​ 
-===== SPI module ===== 
-The SPI module implements the SPI communication needed for [[#​dmmcmd_module|DMMCMD module]] and [[#​eprom_module|EPROM module]].\\ ​ 
-It uses the [[#​gpio_module|GPIO module]] for configuring and accessing the output digital lines SPI clock and SPI data out, and the input digital line SPI data in.\\  
-The functions of this module allow the transfer of any number of bits, needed in order to implement the communication protocols with the above mentioned modules.\\ ​ 
-The module should only be accessed through the functions from upper level modules. 
- 
-===== GPIO module ===== 
-The GPIO module provides the lowest level, the hardware access level to the digital lines. \\  
-Basically it configures the required digital lines as output or input digital line, provides the possibility to set a specific output digital line to 0 or 1 value, and to read the value of a digital input line.\\ ​ 
-It is accessed by [[#​spi_module|SPI module]] in order to implement the custom SPI access, by [[#​dmm_module|DMM module]] that accesses DMM SPI chip select and relays digital lines and by [[#​eprom_module|EPROM module]] that accesses EPROM SPI chip select digital line.\\ ​ 
-This module is the only module dependent to the hardware.\\ ​ 
-The module should only be accessed through the functions from upper level modules. 
- 
-===== UART module ===== 
-The UART module implements the functionality needed to communicate on UART1 hardware interface of the uC32 board, connected to the USB - UART.\\ ​ 
-For example, using this module, UART communcation between uC32 and PC can be implemented over USB cable. Connecting the uC32 to the PC creates a new COM port which can be used in a simple terminal application.\\ ​ 
-The module initializes the UART to generate interrupt when a character is received. In the interrupt handler, the array of characters are stored as commands, using a circular buffer.\\ ​ 
-This module has no DMM functionality. It is just included to provide communication capabilities. It doesn'​t have to included in an application that doesn'​t need communication (for example an application that uses a LCD connected to uC32 board using the shield connector.\\ ​ 
-The module is only accessed by [[#​dmmcmd_module|DMMCMD module]].\\ ​ 
-The module provides: 
-- Initialization function:​\\ ​ 
-  * [[#​uart_init|UART_Init]] \\  
-- Character string transmit function:​\\ ​ 
-  * [[#​uart_putstring|UART_PutString]] \\  
-- Character string receive function:​\\ ​ 
-  * [[#​uart_getstring|UART_GetString]] \\  
- 
-==== UART_Init ==== 
-=== Synopsis: ===  
-void UART_Init(unsigned int baud); 
- 
-=== Parameters: ===  
- 
-|unsigned int baud|UART baud rate\\ for example 9600 corresponds to 9600 baud| 
- 
-=== Return value: ===  
- 
-<​none>​ 
-=== Description:​ ===  
-This function initializes the UART1 hardware interface involved in the UART module, in the UART receive with interrupt mode.\\ ​ 
-The UART_TX digital pin is configured as digital output.\\ ​ 
-The UART_RX digital pin is configured as digital input.\\ ​ 
-The UART_TX and UART_RX are mapped over the UART1 interface.\\ ​ 
-The UART1 module of PIC32 is configured to work at the specified baud, no parity and 1 stop bit. 
- 
-=== Example: ===  
- 
-#include "​uart.h"​\\ ​ 
-UART_Init(9600);​ 
- 
-==== UART_PutString ==== 
-=== Synopsis: ===  
-void UART_PutString(char szData[]) 
- 
-=== Parameters: ===  
- 
-|char szData[]|the zero terminated string containing characters to be transmitted over UART| 
- 
-=== Return value: ===  
- 
-<​none>​ 
-=== Description:​ ===  
-This function transmits all the characters from a zero terminated string over UART1.\\ The terminator character is not sent.\\ ​ 
- 
-=== Example: ===  
- 
-#include "​uart.h"​\\ ​ 
-UART_PutString("​Hello World\r\n"​);​ 
- 
- 
- 
-==== UART_GetString ==== 
-=== Synopsis: ===  
-uint8_t UART_GetString(char* pchBuff, int cchBuff) 
- 
-=== Parameters: ===  
- 
-|char* pchBuff|pointer to a char buffer to hold the received zero terminated string| 
-|int cchBuff|size of the buffer to hold the zero terminated string| 
- 
- 
- 
-=== Return value: ===  
- 
-<​none>​ 
-=== Description:​ ===  
-This function provides a zero terminated string received over UART1 which was placed in the circular buffer by the UART interrupt handler.\\ ​ 
-If a received string is available in the circular buffer, the string is copied in the pchBuff string and its length is returned.\\ ​ 
-Otherwise, the function returns 0. 
- 
-=== Example: ===  
- 
-#include "​uart.h"​\\ ​ 
-cchi = UART_GetString(uartCmd,​ 0x40); 
- 
-===== Appendix: DMM Scales ===== 
-DMMShield allows selecting one from the following set of scales. ​ 
-The following table shows all the scales, together with 2 extra columns: corresponding Base measure unit and the Measure unit used when formatting the value. See [[#​dmm_measured_values|DMM Measured Values]] for these columns. 
-^No.^ Scale  ^Formatted values (provided by [[#​dmm_formatvalue|DMM_FormatValue]] function) ^^^Values provided by [[#​dmm_dgetvalue|DMM_DGetValue]] function^ 
-^:::​^:::​^Valid values^Unit^Out of scale^:::^ 
-|1| Resistance50M |Signed value, 6 decimals|MOhm|"​OVERLOAD"​|Valid values: corresponding to the Ohm unit\\ Out of scale values: INFINITY| 
-|2| Resistance5M |:::​|MOhm|:::​|:::​| 
-|3| Resistance500k |:::​|kOhm|:::​|:::​| 
-|4| Resistance50k |:::​|kOhm|:::​|:::​| 
-|5| Resistance5k |:::​|kOhm|:::​|:::​| 
-|6| Resistance500 |:::​|Ohm|:::​|:::​| 
-|7| Resistance50 |:::​|Ohm|:::​|:::​| 
-|8| VoltageDC50 |Signed value, 6 decimals|V|"​OVERLOAD"​|Valid values: corresponding to the V unit\\ Out of scale values: INFINITY| 
-|9| VoltageDC5 |:::​|V|:::​|:::​| 
-|10| VoltageDC500m |:::​|mV|:::​|:::​| 
-|11| VoltageDC50m |:::​|mV|:::​|:::​| 
-|12| VoltageAC50 |:::​|V|:::​|:::​| 
-|13| VoltageAC5 |:::​|V|:::​|:::​| 
-|14| VoltageAC500m |:::​|mV|:::​|:::​| 
-|15| VoltageAC50m |:::​|mV|:::​|:::​| 
-|19| Diode |:::​|V|:::​|:::​| 
-|18| Continuity |Signed value, 6 decimals <when contact exists on probes>​\\ This is similar to a resistance scale.|Ohm|“OPEN” <when no contact on probes>​|Valid values (contact on probes): corresponding to the Ohm unit\\ Out of scale values (no contact on probes): INFINITY| 
-|16| CurrentDC5 |Signed value, 6 decimals|A|"​OVERLOAD"​|Valid values: corresponding to the A unit\\ Out of scale values: INFINITY| 
-|17| CurrentAC5 |:::​|A|:::​|:::​| 
-|20| CurrentDC500m |:::​|mA|:::​|:::​| 
-|21| CurrentDC50m |:::​|mA|:::​|:::​| 
-|22| CurrentDC5m |:::​|mA|:::​|:::​| 
-|23| CurrentDC500u |:::​|uA|:::​|:::​| 
-|24| CurrentAC5 |:::​|A|:::​|:::​| 
-|25| CurrentAC500m |:::​|mA|:::​|:::​| 
-|26| CurrentAC50m |:::​|mA|:::​|:::​| 
-|27| CurrentAC5m |:::​|mA|:::​|:::​| 
-|28| CurrentAC500u |:::​|uA|:::​|:::​| 
- 
- 
- 
- 
-