◆ adc_in_out()
Definition at line 98 of file mcp3208.cpp.
98 {
99
100
101
102 int result =
state->results[0];
103
104
105 unsigned r = 0;
106
107
108
109
110
111
112
113
114
115
116
117
119
121
123 print("ch0=%d adj %d ", f0, f0 * 5000 / 4096);
125 print("ch1=%d adj %d\r\n", f1, f1 * 5000 / 4096);
126}
static int adcEventCounter
static int adcErrorCounter
static int getValue(McpAdcState *state, int channel)
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
◆ createRequest()
static void createRequest |
( |
McpAdcState * |
state, |
|
|
int |
channel |
|
) |
| |
|
static |
◆ getMcp3208adc()
int getMcp3208adc |
( |
int |
channel | ) |
|
◆ getNextChannel()
static int getNextChannel |
( |
void |
| ) |
|
|
static |
◆ getValue()
static int getValue |
( |
McpAdcState * |
state, |
|
|
int |
channel |
|
) |
| |
|
static |
◆ init_adc_mcp3208()
void init_adc_mcp3208 |
( |
McpAdcState * |
state, |
|
|
SPIDriver * |
driver |
|
) |
| |
Definition at line 128 of file mcp3208.cpp.
128 {
129 state->driver = driver;
130 state->tx_buff[2] = 0;
131
133
134 todo: convert to new API, todo: array of CS
135 mySetPadMod("ext adc chip select", MCP3208_CS_PORT, MCP3208_CS_PIN, PAL_STM32_MODE_OUTPUT);
136
137
138 spiStart(driver, &
spicfg);
139}
static const SPIConfig spicfg
◆ requestAdcValue()
void requestAdcValue |
( |
McpAdcState * |
state, |
|
|
int |
channel |
|
) |
| |
Definition at line 82 of file mcp3208.cpp.
82 {
84
85 spiSelect(
state->driver);
87
88}
static void createRequest(McpAdcState *state, int channel)
◆ requestAdcValueI()
void requestAdcValueI |
( |
McpAdcState * |
state, |
|
|
int |
channel |
|
) |
| |
◆ spiCallback()
static void spiCallback |
( |
SPIDriver * |
spip | ) |
|
|
static |
Definition at line 35 of file mcp3208.cpp.
35 {
36 spiUnselectI(spip);
38
40
41 int withError = 0;
42
43 if (
state->rx_buff[0] != 255) {
44 withError = 1;
45
46 }
47
48 if ((
state->rx_buff[1] & 0xE0) != 0xE0) {
49 withError = 1;
50
51 }
52
53 if (!withError) {
54
56 state->results[
state->requestedChannel] = result;
57 } else {
59 }
60
62}
void requestAdcValueI(McpAdcState *state, int channel)
static int getNextChannel(void)
MCP3208 ADC chip driver structure.
◆ adcErrorCounter
◆ adcEventCounter
◆ hack
◆ spicfg
Initial value:
MCP3208_CS_PORT,
MCP3208_CS_PIN,
SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2
}
static void spiCallback(SPIDriver *spip)
Definition at line 64 of file mcp3208.cpp.
65
66MCP3208_CS_PORT,
67MCP3208_CS_PIN,
68
69 SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2
70
71 };
Referenced by init_adc_mcp3208().
Go to the source code of this file.