diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-10-02 17:13:22 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-10-02 17:13:22 -0400 |
| commit | e7baf2e96f1cec2071cb2e1e6a4735c36611bc26 (patch) | |
| tree | 98cc783b42aed7090680a158b00d5549233d3528 /fw/dac.h | |
| parent | 99be520563834d51eb3ddd32b757a3dcd2486632 (diff) | |
| download | can-gauge-interface-e7baf2e96f1cec2071cb2e1e6a4735c36611bc26.zip | |
dac fw module
Diffstat (limited to 'fw/dac.h')
| -rw-r--r-- | fw/dac.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fw/dac.h b/fw/dac.h new file mode 100644 index 0000000..7bbf66a --- /dev/null +++ b/fw/dac.h @@ -0,0 +1,36 @@ +/* Microchip MCP4912 10-bit DAC + * + * Device: PIC16F1459 + * Compiler: XC8 v3.00 + * + * Usage: + * + * #include <stdint.h> + * #include "types.h" + * #include "spi.h" + * #include "dac.h" + */ + +// Pin mapping +#define DAC1_CS_TRIS TRISBbits.TRISB7 +#define DAC1_CS LATBbits.LATB7 +#define DAC2_CS_TRIS TRISBbits.TRISB5 +#define DAC2_CS LATBbits.LATB5 + +void dacInit(void); + +// Set DAC1 VOUTA. +// Only the lower 10 bits are used. +void dacSet1a(U16 level); + +// Set DAC1 VOUTB. +// Only the lower 10 bits are used. +void dacSet1b(U16 level); + +// Set DAC2 VOUTA. +// Only the lower 10 bits are used. +void dacSet2a(U16 level); + +// Set DAC2 VOUTB. +// Only the lower 10 bits are used. +void dacSet2b(U16 level); |