rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions
poten.h File Reference

Detailed Description

MCP42010 digital potentiometer driver.

Date
Mar 16, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file poten.h.

Data Structures

struct  Mcp42010Driver
 

Functions

void initPotentiometers ()
 
void setPotResistance (Mcp42010Driver *driver, int channel, int resistance)
 

Function Documentation

◆ initPotentiometers()

void initPotentiometers ( )

Definition at line 90 of file poten.cpp.

90 {
91#if EFI_POTENTIOMETER
93 efiPrintf("digiPot spi disabled");
94 return;
95 }
96 // todo: we have centralized SPI management see other usages of 'turnOnSpi'
97 //turnOnSpi(engineConfiguration->digitalPotentiometerSpiDevice);
98
99 for (int i = 0; i < DIGIPOT_COUNT; i++) {
101 if (!isBrainPinValid(csPin)) {
102 continue;
103 }
104
106 if (driver == NULL) {
107 // error already reported
108 return;
109 }
110
111 initPotentiometer(&potConfig[i], driver, csPin);
112 }
113
115
117
118 setPotResistance(&potConfig[0], 0, 3000);
119 setPotResistance(&potConfig[0], 1, 7000);
120#endif
121}
void addConsoleActionII(const char *token, VoidIntInt callback)
Register a console command with two Integer parameters.
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
static constexpr engine_configuration_s * engineConfiguration
SPIDriver * getSpiDevice(spi_device_e spiDevice)
Definition hardware.cpp:149
bool isBrainPinValid(brain_pin_e brainPin)
void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, brain_pin_e csPin)
Definition poten.cpp:52
void setPotResistance(Mcp42010Driver *driver, int channel, int resistance)
Definition poten.cpp:73
static void setPotResistanceCommand(int index, int value)
Definition poten.cpp:80
static Mcp42010Driver potConfig[DIGIPOT_COUNT]
Definition poten.cpp:50
static void setPotValue1(int value)
Definition poten.cpp:84

Referenced by initEngineEmulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPotResistance()

void setPotResistance ( Mcp42010Driver driver,
int  channel,
int  resistance 
)

Definition at line 73 of file poten.cpp.

73 {
74 int value = getPotStep(resistance);
75
76 efiPrintf("Sending to potentiometer%d: %d for R=%d", channel, value, resistance);
77 sendToPot(driver, channel, value);
78}
uint16_t channel
Definition adc_inputs.h:104
static int getPotStep(int resistanceWA)
Definition poten.cpp:58
static void sendToPot(Mcp42010Driver *driver, int channel, int value)
Definition poten.cpp:62

Referenced by initPotentiometers(), and setPotResistanceCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.