-
Notifications
You must be signed in to change notification settings - Fork 2
/
mcpDAC.h
91 lines (67 loc) · 2.62 KB
/
mcpDAC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// mcpDAC.h
// Library for MCP4801 to MCP4922 use at AVR Atmega
//
// Created by Michael Köhler on 18.11.18.
// Copyright © 2018 Michael Köhler. All rights reserved.
//
#ifndef mcpDAC_h
#define mcpDAC_h
#ifdef __cplusplus
extern "C" {
#endif
#include <avr/io.h>
/**********************************************
Public Function: mcpDACInit
Purpose: Initialise SPI interface
Input Parameter:
-volatile uint8_t *cPort: Pointer to PORT-register of CS-pin
-volatile uint8_t *cDDR: Pointer to DDR-register of CS-pin
- uint8_t cPin: Portpin of CS-pin
Return Value: none
**********************************************/
void mcpDACInit(volatile uint8_t *cPort, volatile uint8_t *cDDR, uint8_t cPin);
/**********************************************
Public Function: setCSMCPDAC
Purpose: set CS of MCPDAC
Input Parameter:
-volatile uint8_t *cPort: Pointer to PORT-register of CS-pin
- uint8_t cPin: Portpin of CS-pin
Return Value: none
**********************************************/
void setCSMCPDAC(volatile uint8_t *cPort, uint8_t cPin);
/**********************************************
Public Function: unSetCSMCPADC
Purpose: clear CS of MCPADC
Input Parameter:
-volatile uint8_t *cPort: Pointer to PORT-register of CS-pin
- uint8_t cPin: Portpin of CS-pin
Return Value: none
**********************************************/
void unSetCSMCPDAC(volatile uint8_t *cPort, uint8_t cPin);
/**********************************************
Public Function: spiSendByteMCPDAC
Purpose: send byte to MCPDAC
Input Parameter:
-volatile uint8_t valueToSend: value to send to MCPDAC
Return Value: none
**********************************************/
void spiSendByteMCPDAC(uint8_t valueToSend);
/**********************************************
Public Function: setMCPDAC
Purpose: set designated outputport to value with gain or deactivate/power down chip
Input Parameter:
-volatile uint8_t *cPort: Pointer to PORT-register of CS-pin
-uint8_t cPin: Portpin of CS-pin
-uint8_t resolution: Resolution of Chip in bit
-uint16_t valueToSet: value for output
-uint8_t channel: outputport, 1 for port a, 2 for port b
-uint8_t gain: gain for designated port, 1 for 1x, 2 for 2x
-uint8_t shutdown: 0 for activate chip, 1 for power down chip
Return Value: none
**********************************************/
void setMCPDAC(volatile uint8_t *cPort, uint8_t cPin, uint8_t resolution, uint16_t valueToSet, uint8_t channel, uint8_t gain, uint8_t shutdown);
#ifdef __cplusplus
}
#endif
#endif /* mcpDAC_h */