43 if (
state->rx_buff[0] != 255) {
48 if ((
state->rx_buff[1] & 0xE0) != 0xE0) {
56 state->results[
state->requestedChannel] = result;
69 SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2
74 efiAssertVoid(ObdCode::CUSTOM_ERR_6680,
channel < 8,
"Invalid ADC channel");
85 spiSelect(
state->driver);
93 spiSelectI(
state->driver);
102 int result =
state->results[0];
123 print(
"ch0=%d adj %d ", f0, f0 * 5000 / 4096);
125 print(
"ch1=%d adj %d\r\n", f1, f1 * 5000 / 4096);
129 state->driver = driver;
130 state->tx_buff[2] = 0;
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);
138 spiStart(driver, &
spicfg);
static void spiCallback(SPIDriver *spip)
static int adcEventCounter
void requestAdcValueI(McpAdcState *state, int channel)
int getMcp3208adc(int channel)
static int getNextChannel(void)
void adc_in_out(McpAdcState *state)
void requestAdcValue(McpAdcState *state, int channel)
static int adcErrorCounter
static void createRequest(McpAdcState *state, int channel)
static const SPIConfig spicfg
static int getValue(McpAdcState *state, int channel)
void init_adc_mcp3208(McpAdcState *state, SPIDriver *driver)
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
MCP3208 ADC chip driver structure.