rusefi-1/firmware/hw_layer/mcp3208.h

45 lines
820 B
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/*
* @file mcp3208.h
*
* @date Aug 12, 2013
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*
*
* MCP3208 pins:
* pin10 CS Chip Select
* pin11 Din Data In (MOSI)
* pin12 Dout Data Out (MISO)
* pin13 CLK spi CLoCk
*
*/
2020-02-18 05:16:19 -08:00
#pragma once
2015-07-10 06:01:56 -07:00
2018-09-16 19:26:57 -07:00
#include "global.h"
2015-07-10 06:01:56 -07:00
2019-04-12 17:52:51 -07:00
#if EFI_MCP_3208
2015-07-10 06:01:56 -07:00
#define MCP3208_CS_PORT GPIOD
#define MCP3208_CS_PIN 11
/**
* @brief MCP3208 ADC chip driver structure
*/
typedef struct {
SPIDriver *driver;
unsigned char tx_buff[3];
unsigned char rx_buff[3];
int requestedChannel;
int results[8];
} McpAdcState;
void init_adc_mcp3208(McpAdcState *state, SPIDriver *driver);
void requestAdcValue(McpAdcState *state, int channel);
void requestAdcValueI(McpAdcState *state, int channel);
void adc_in_out(McpAdcState *state);
int getMcp3208adc(int channel);
#endif /* EFI_MCP_3208 */