rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
drv8860.cpp File Reference

Enumerations

enum  drv8860_drv_state { DRV8860_DISABLED = 0 , DRV8860_WAIT_INIT , DRV8860_READY , DRV8860_FAILED }
 

Functions

 SEMAPHORE_DECL (drv8860_wake, 10)
 
static THD_WORKING_AREA (drv8860_thread_1_wa, 256)
 
static THD_FUNCTION (drv8860_driver_thread, p)
 
int drv8860_add (brain_pin_e base, unsigned int index, const drv8860_config *cfg)
 DRV8860 driver add.
 

Variables

static bool drv_task_ready = false
 
static Drv8860 chips [BOARD_DRV8860_COUNT]
 
static const chardrv8860_pin_names [DRV8860_OUTPUTS]
 

Enumeration Type Documentation

◆ drv8860_drv_state

Enumerator
DRV8860_DISABLED 
DRV8860_WAIT_INIT 
DRV8860_READY 
DRV8860_FAILED 

Definition at line 30 of file drv8860.cpp.

30 {
drv8860_drv_state
Definition drv8860.cpp:30
@ DRV8860_FAILED
Definition drv8860.cpp:34
@ DRV8860_WAIT_INIT
Definition drv8860.cpp:32
@ DRV8860_READY
Definition drv8860.cpp:33
@ DRV8860_DISABLED
Definition drv8860.cpp:31

Function Documentation

◆ drv8860_add()

int drv8860_add ( brain_pin_e  base,
unsigned int  index,
const drv8860_config cfg 
)

DRV8860 driver add.

Checks for valid config

Definition at line 235 of file drv8860.cpp.

235 {
236 int ret;
237
238 /* no config or no such chip */
239 if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_DRV8860_COUNT))
240 return -1;
241
242 /* check for valid cs.
243 * TODO: remove this check? CS can be driven by SPI */
244 //if (cfg->spi_config.ssport == NULL)
245 // return -1;
246
247 auto& chip = chips[index];
248
249 /* already initted? */
250 if (!chip.cfg)
251 return -1;
252
253 chip.cfg = cfg;
254 chip.o_state = 0;
255 chip.o_state_cached = 0;
256 chip.drv_state = DRV8860_WAIT_INIT;
257
258 /* register, return gpio chip base */
259 ret = gpiochip_register(base, DRIVER_NAME, chip, DRV8860_OUTPUTS);
260 if (ret < 0)
261 return ret;
262
263 /* set default pin names, board init code can rewrite */
265
266 return ret;
267}
int gpiochip_register(brain_pin_e base, const char *name, GpioChip &gpioChip, size_t size)
Register gpiochip.
Definition core.cpp:186
int gpiochips_setPinNames(brain_pin_e base, const char **names)
Set pins names for registered gpiochip.
Definition core.cpp:266
static const char * drv8860_pin_names[DRV8860_OUTPUTS]
Definition drv8860.cpp:75
static Drv8860 chips[BOARD_DRV8860_COUNT]
Definition drv8860.cpp:73
SPIDriver * spi_bus
Definition drv8860.h:24

Referenced by initSmartGpio().

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

◆ SEMAPHORE_DECL()

SEMAPHORE_DECL ( drv8860_wake  ,
10   
)

◆ THD_FUNCTION()

static THD_FUNCTION ( drv8860_driver_thread  ,
 
)
static

Definition at line 156 of file drv8860.cpp.

156 {
157 int i;
158 msg_t msg;
159
160 (void)p;
161
162 chRegSetThreadName(DRIVER_NAME);
163
164 while (1) {
165 msg = chSemWaitTimeout(&drv8860_wake, TIME_MS2I(DRV8860_POLL_INTERVAL_MS));
166
167 /* should we care about msg == MSG_TIMEOUT? */
168 (void)msg;
169
170 for (i = 0; i < BOARD_DRV8860_COUNT; i++) {
171 auto chip = &chips[i];
172 if ((chip->cfg == NULL) ||
173 (chip->drv_state == DRV8860_DISABLED) ||
174 (chip->drv_state == DRV8860_FAILED))
175 continue;
176
177 chip->update_outputs();
178 }
179 }
180}

◆ THD_WORKING_AREA()

static THD_WORKING_AREA ( drv8860_thread_1_wa  ,
256   
)
static

Variable Documentation

◆ chips

Drv8860 chips[BOARD_DRV8860_COUNT]
static

Definition at line 73 of file drv8860.cpp.

Referenced by drv8860_add(), and THD_FUNCTION().

◆ drv8860_pin_names

const char* drv8860_pin_names[DRV8860_OUTPUTS]
static
Initial value:
= {
"drv8860.OUT1", "drv8860.OUT2", "drv8860.OUT3", "drv8860.OUT4",
"drv8860.OUT5", "drv8860.OUT6", "drv8860.OUT7", "drv8860.OUT8",
"drv8860.OUT9", "drv8860.OUT10", "drv8860.OUT11", "drv8860.OUT12",
"drv8860.OUT13", "drv8860.OUT14", "drv8860.OUT15", "drv8860.OUT16",
}

Definition at line 75 of file drv8860.cpp.

75 {
76 "drv8860.OUT1", "drv8860.OUT2", "drv8860.OUT3", "drv8860.OUT4",
77 "drv8860.OUT5", "drv8860.OUT6", "drv8860.OUT7", "drv8860.OUT8",
78 "drv8860.OUT9", "drv8860.OUT10", "drv8860.OUT11", "drv8860.OUT12",
79 "drv8860.OUT13", "drv8860.OUT14", "drv8860.OUT15", "drv8860.OUT16",
80};

Referenced by drv8860_add().

◆ drv_task_ready

bool drv_task_ready = false
static

Definition at line 28 of file drv8860.cpp.

Go to the source code of this file.