-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
55 lines (40 loc) · 1.6 KB
/
main.c
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
#include <stdint.h>
#include <stdio.h>
#include "ad5697r.h"
#define ad5697r_ADDR (0x6E)
int8_t usr_i2c_write(const uint8_t busAddr, const uint8_t *data, const uint32_t len) {
ad5697r_return_code_t ret = AD5697R_RET_OK;
// Transmit the data to the specified device from the provided
// data buffer.
return ret;
}
int8_t usr_i2c_read(const uint8_t busAddr, uint8_t *data, const uint32_t len) {
ad5697r_return_code_t ret = AD5697R_RET_OK;
// Received the specified amount of data from the device and store it
// in the data buffer
return ret;
}
void usr_delay_us(uint32_t period) {
// Delay for the requested period
}
int main(void) {
ad5697r_return_code_t ret = AD5697R_RET_OK;
// Create an instance of our ad5697r device
ad5697r_dev_t dev;
// Provide the hardware abstraction functions for
// I2c Read/Write and a micro-second delay function
dev.intf.i2c_addr = ad5697r_ADDR;
dev.intf.write = usr_i2c_write;
dev.intf.read = usr_i2c_read;
dev.intf.delay_us = usr_delay_us;
// Set the desired operation mode for our DAC outputs
// Enable channel A to run in normal operation
ret = ad5697r_setOperatingMode(&dev, AD5697R_OUTPUT_CH_A, AD5697R_OP_MODE_NORMAL);
// Disable channel B and put a 1K resistance to ground on the output
if( ret == AD5697R_RET_OK )
ret = ad5697r_setOperatingMode(&dev, AD5697R_OUTPUT_CH_B, AD5697R_OP_MODE_1K_TO_GND);
// Set the DAC output value to 50% of the reference voltage
if( ret == AD5697R_RET_OK )
ret = ad5697r_writeChannel(&dev, AD5697R_OUTPUT_CH_A, 0x00FF);
return ret;
}