This Ada library is designed to format messages for the SPI MCP4922 dual 12-bit DAC chip.
The formatted 2-byte message must be written to the chip by the calling program. This routine simply performs the message formatting function.
The public portion of the package spec is as follows:
package MCP4922 is
type Unit_Type is (
DAC_A,
DAC_B
);
type Value_Type is range 0 .. 2**12-1;
type Buffering_Type is
(Buffered, -- Requires assertion of /LDAC pin
Unbuffered -- /LDAC tied low
);
type Gain_Type is
(Gain_1X, -- 1X (Vout = Vref * D/4096)
Gain_2X -- 2X (Vout = 2 * Vref * D/4096)
);
------------------------------------------------------------------
-- Create a 2-byte message for the MCP4922 DAC
------------------------------------------------------------------
procedure Format
(Unit : in Unit_Type; -- DAC_A or DAC_B
Value : in Value_Type; -- Value to xmit
Buffer : out SPI_Data_Type; -- Buffer(1..2)
Buffering : in Buffering_Type := Unbuffered; -- /LDAC control
Gain : in Gain_Type := Gain_1X; -- 1X or 2X Gain
Shutdown : in Boolean := False -- /Shutdown control
);
end MCP4922;
This type is used to specify which DAC unit is being referenced in the dual DAC chip:
This procedure formats a byte message string to send to the MCP4922 chip, to change a DAC output value.
procedure Format
(Unit : in Unit_Type; -- DAC_A or DAC_B
Value : in Value_Type; -- Value to xmit
Buffer : out SPI_Data_Type; -- Buffer(1..2)
Buffering : in Buffering_Type := Unbuffered; -- /LDAC control
Gain : in Gain_Type := Gain_1X; -- 1X or 2X Gain
Shutdown : in Boolean := False -- /Shutdown control
);