Hardware Abstraction Layer for FreeRTOS
mcp492x.h
Go to the documentation of this file.
1
#ifndef MCP492X_H_
2
#define MCP492X_H_
3
4
#include <
dac.h
>
5
#define DAC_PRV
6
#include <
dac_prv.h
>
7
#include <
spi.h
>
8
#include <FreeRTOS.h>
9
#include <task.h>
10
extern
const
struct
dac_ops mcp492x_dac_ops;
11
struct
dac_mcp492x_controller {
12
struct
hal
gen;
13
struct
dac_mcp492x *channels[2];
14
struct
spi_slave *slave;
15
struct
gpio_pin *lvdac;
16
};
17
struct
dac_mcp492x {
18
struct
dac_generic
gen;
19
struct
dac_mcp492x_controller *dacc;
20
uint32_t bits;
21
uint32_t channelID;
22
void
*data;
23
};
24
25
#define ADD_MCP492X_CHANNEL(ID, _channelID) \
26
struct dac_mcp492x mcp492x_##ID##_##_channelID = { \
27
DAC_INIT_DEV(mcp492x) \
28
HAL_NAME("TI MCP492x " #ID "Channel " #_channelID) \
29
.dacc = &mcp492x_##ID, \
30
.channelID = _channelID, \
31
};\
32
DAC_ADDDEV(mcp492x, mcp492x_##ID##_##_channelID)
33
35
void
*
mcp492x_controller_init
(uint32_t index);
36
int32_t
mcp492x_connect
(
void
*ac,
struct
spi *spi, uint8_t cs, uint16_t gpio, uint16_t lvdac, uint32_t baudrate);
37
38
#define ADD_MCP492X(ID) \
39
extern struct dac_mcp492x_controller mcp492x_##ID;\
40
ADD_MCP492X_CHANNEL(ID, 0); \
41
ADD_MCP492X_CHANNEL(ID, 1); \
42
struct dac_mcp492x_controller mcp492x_##ID = { \
43
HAL_NAME("TI MCP492x " #ID) \
44
.channels = { \
45
&mcp492x_##ID##_0, \
46
&mcp492x_##ID##_1, \
47
}, \
48
}; \
49
HAL_ADDDEV(hal, mcp492x, mcp492x_##ID)
50
51
#define MCP492X_ID(ID) HAL_GET_ID(hal, mcp492x, mcp492x_##ID)
52
#define MCP492X_ID_CHANNEL(ID, _channelID) HAL_GET_ID(dac, mcp492x, mcp492x_##ID##_##_channelID)
53
#endif
54
mcp492x_connect
int32_t mcp492x_connect(void *ac, struct spi *spi, uint8_t cs, uint16_t gpio, uint16_t lvdac, uint32_t baudrate)
spi.h
mcp492x_controller_init
void * mcp492x_controller_init(uint32_t index)
hal
Definition:
hal.h:48
dac_generic
Definition:
dac.h:42
dac.h
dac_prv.h
driver
include
mcp492x.h
Generated on Tue Aug 17 2021 15:19:23 for Hardware Abstraction Layer for FreeRTOS by
1.8.20