flinklib
flinklib: flink C library for Linux
aout.c
Go to the documentation of this file.
1 /*******************************************************************
2  * _________ _____ _____ ____ _____ ___ ____ *
3  * |_ ___ | |_ _| |_ _| |_ \|_ _| |_ ||_ _| *
4  * | |_ \_| | | | | | \ | | | |_/ / *
5  * | _| | | _ | | | |\ \| | | __'. *
6  * _| |_ _| |__/ | _| |_ _| |_\ |_ _| | \ \_ *
7  * |_____| |________| |_____| |_____|\____| |____||____| *
8  * *
9  *******************************************************************
10  * *
11  * flink userspace library, subdevice type "analog output *
12  * *
13  *******************************************************************/
14 
24 #include "flinklib.h"
25 #include "types.h"
26 #include "error.h"
27 #include "log.h"
28 
29 #include <stdint.h>
30 
37 int flink_analog_out_get_resolution(flink_subdev* subdev, uint32_t* resolution){
38  uint32_t offset;
39  offset = HEADER_SIZE + SUBHEADER_SIZE;
40 
41  if(flink_read(subdev, offset, REGISTER_WITH, resolution) != REGISTER_WITH) {
42  libc_error();
43  return EXIT_ERROR;
44  }
45  return EXIT_SUCCESS;
46 }
47 
55 int flink_analog_out_set_value(flink_subdev* subdev, uint32_t channel, uint32_t value){
56  uint32_t offset;
57 
58  dbg_print("Get Value of analog out for channel %d on subdevice %d\n", subdev->id, channel);
60  dbg_print(" --> calculated offset is 0x%x!\n", offset);
61 
62  if(flink_write(subdev, offset, REGISTER_WITH, &value) != REGISTER_WITH) {
63  libc_error();
64  return EXIT_ERROR;
65  }
66  return EXIT_SUCCESS;
67 }
Data structures for flink devices and subdevices.
int flink_analog_out_get_resolution(flink_subdev *subdev, uint32_t *resolution)
Reads the resolution of a analog output subdevice.
Definition: aout.c:37
#define EXIT_ERROR
Definition: flinklib.h:129
ssize_t flink_read(flink_subdev *subdev, uint32_t offset, uint8_t size, void *rdata)
Read from a flink subdevice.
Definition: lowlevel.c:71
Error handling.
#define REGISTER_WITH
Definition: flinklib.h:50
#define HEADER_SIZE
Definition: flinklib.h:51
#define EXIT_SUCCESS
Definition: flinklib.h:128
int flink_analog_out_set_value(flink_subdev *subdev, uint32_t channel, uint32_t value)
Writes an analog output channel.
Definition: aout.c:55
#define SUBHEADER_SIZE
Definition: flinklib.h:52
void libc_error(void)
Definition: error.c:56
Debug utilities.
ssize_t flink_write(flink_subdev *subdev, uint32_t offset, uint8_t size, void *wdata)
Write to a flink subdevice.
Definition: lowlevel.c:110
#define dbg_print(fmt,...)
Definition: log.h:29
#define ANALOG_OUTPUT_FIRST_VALUE_OFFSET
Definition: flinklib.h:61