10 extern const struct adc_ops mcp320x_adc_ops;
11 struct adc_mcp320x_controller {
13 struct adc_mcp320x *channels[16];
14 struct spi_slave *slave;
19 struct adc_mcp320x_controller *adcc;
25 bool (*callback)(
struct adc *adc, uint32_t channel, int32_t value,
void *data);
29 #define ADD_MCP320X_CHANNEL(ID, _channelID) \
30 struct adc_mcp320x mcp320x_##ID##_##_channelID = { \
31 ADC_INIT_DEV(mcp320x) \
32 HAL_NAME("TI MCP320x " #ID "Channel " #_channelID) \
33 .adcc = &mcp320x_##ID, \
34 .channelID = _channelID, \
36 ADC_ADDDEV(mcp320x, mcp320x_##ID##_##_channelID)
40 int32_t
mcp320x_connect(
void *ac,
struct spi *spi, uint8_t cs, uint16_t gpio, uint32_t baudrate);
42 #define ADD_MCP320X(ID) \
43 extern struct adc_mcp320x_controller mcp320x_##ID;\
44 ADD_MCP320X_CHANNEL(ID, 0); \
45 ADD_MCP320X_CHANNEL(ID, 1); \
46 ADD_MCP320X_CHANNEL(ID, 2); \
47 ADD_MCP320X_CHANNEL(ID, 3); \
48 ADD_MCP320X_CHANNEL(ID, 4); \
49 ADD_MCP320X_CHANNEL(ID, 5); \
50 ADD_MCP320X_CHANNEL(ID, 6); \
51 ADD_MCP320X_CHANNEL(ID, 7); \
52 ADD_MCP320X_CHANNEL(ID, 8); \
53 ADD_MCP320X_CHANNEL(ID, 9); \
54 ADD_MCP320X_CHANNEL(ID, 10); \
55 ADD_MCP320X_CHANNEL(ID, 11); \
56 ADD_MCP320X_CHANNEL(ID, 12); \
57 ADD_MCP320X_CHANNEL(ID, 13); \
58 ADD_MCP320X_CHANNEL(ID, 14); \
59 ADD_MCP320X_CHANNEL(ID, 15); \
60 struct adc_mcp320x_controller mcp320x_##ID = { \
61 HAL_NAME("TI MCP320x " #ID) \
81 HAL_ADDDEV(hal, mcp320x, mcp320x_##ID)
83 #define MCP320X_ID(ID) HAL_GET_ID(hal, mcp320x, mcp320x_##ID)
84 #define MCP320X_ID_CHANNEL(ID, _channelID) HAL_GET_ID(adc, mcp320x, mcp320x_##ID##_##_channelID)