rusefi-1/firmware/hw_layer/mcp3208.h

47 lines
891 B
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/*
* @file mcp3208.h
*
* @date Aug 12, 2013
2017-01-03 03:05:22 -08:00
* @author Andrey Belomutskiy, (c) 2012-2017
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
*
*/
#ifndef MCP3208_H_
#define MCP3208_H_
#include "main.h"
#if EFI_MCP_3208 || defined(__DOXYGEN__)
#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 */
#endif /* MCP3208_H_ */