Commit Graph

179 Commits

Author SHA1 Message Date
Andrey G 10cab3390a
L9779: update (#3899)
* L9779: update

* L9779: cleanup macro
2022-02-06 17:47:53 -05:00
rusefi a1ccdb1bd9 unused code? 2022-02-06 17:44:58 -05:00
Andrey G c53fd0eaf9
L9779: update driver (#3898)
* L9779: update driver

* L9779: missed chip_init

* L9779: signature
2022-02-06 11:39:37 -05:00
Andrey G a50f848857
L9779: initial driver (#3897)
* smart_gpio.cpp: glue to L9779

* L9779: fill with some code

* L9779: missed getDiag

* L9779: no l9779 on subaru-eg33 board
2022-02-06 09:47:18 -05:00
Matthew Kennedy 5865f65e1e
remove getDebugChannels (#3850) 2022-01-27 19:21:05 -05:00
rusefillc d0d8e95bd3 L9779WD driver #3768 2022-01-10 19:15:36 -05:00
rusefillc 373d619c16 L9779WD driver #3768 2022-01-10 16:53:38 -05:00
Andrey G 020727d65b
TLE8888: do not allow direct gpio drive for Push Pull outputs (#3748)
Some register settings also needs to be changed. Change of direct
drive input is not enought.
2022-01-07 14:11:21 -05:00
rusefillc 914deedb0f TLE8888 diag says OK on disconnected pins and bench test #3737 2022-01-03 20:33:51 -05:00
rusefillc 47444519d6 typo 2022-01-03 03:09:14 -05:00
rusefillc 53d50b5076 doc 2021-12-03 09:57:15 -05:00
Scott Smith 823d9a07e0
Programmatically replace ENGINE() and CONFIG() with engine-> etc (#3565)
git grep -l -w ENGINE | xargs sed -i -r "s/ENGINE\(([]a-zA-Z_0-9.[]+)\)/engine->\1/g"

git grep -l -w CONFIG | xargs sed -i -r "s/([^a-zA-Z_])CONFIG\(([]a-zA-Z_0-9.[]+)\)/\1engineConfiguration->\2/g"
2021-11-17 03:54:21 -05:00
Andrey G 780e91f38a
Bunch of small fixes related to EG33 board (#3188)
* Typo fix

* flash_main: always allow to write settings to ext NOR while running

* mc33810: do not enable outputs right after undervoltage

Wait for next active signal

* QSPI flash: set correct dummy cycles for fast read command

* board subaru: fix connector pinout. again.

* board subaru: fix SDMMC pin configuration

* board subaru: fix DMA conflict SPI4_RX vs SDMMC2
2021-08-24 07:39:03 +03:00
Matthew Kennedy d24f1462e2
even more pch (#3112)
* s

* more

* s

* f7
2021-08-04 19:30:52 -04:00
Matthew Kennedy 25414ebdad
yet more pch (#3068)
* big pch energy

* put back ramdisk stub

* tests are happy

* h743 nucleo

* kinetis

* I love deleting code!

* make stepper happy

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
2021-08-03 22:05:01 -04:00
Matthew Kennedy 2ce7777865
don't require EXTERN_ENGINE in every file (#2969)
* move enginePins

* no more extern engine

* uses

* more

* extern config too

* put this where it belongs

* include correct header

* merge
2021-07-16 18:13:33 -04:00
Andrey G a1387d3bd2
Fixes (#2807)
* tle6240: fix Matt's trap

* map: report some default value if no map sensor configured

Othervise user will get "unexpected MAP value" warning

Thread 2 hit Breakpoint 1, validateMap (mapKPa=3121.66162) at ./controllers/sensors/map.cpp:126
126		if (cisnan(mapKPa) || mapKPa < CONFIG(mapErrorDetectionTooLow) || mapKPa > CONFIG(mapErrorDetectionTooHigh)) {
(gdb) bt
 0  validateMap (mapKPa=3121.66162) at ./controllers/sensors/map.cpp:126
 1  0x002717dc in getMap () at ./controllers/engine_cycle/map_averaging.cpp:334
 2  0x0028175a in GetMapWrapper::getMap (this=0x2004214c <mapWrapper>) at ./init/sensor/init_map.cpp:12
 3  0x0028177c in operator() (__closure=0x0) at ./init/sensor/init_map.cpp:20
 4  0x002817a8 in _FUN () at ./init/sensor/init_map.cpp:21
 5  0x002811de in FunctionPointerSensor::get (this=0x20042150 <mapSensor>) at ./controllers/sensors/function_pointer_sensor.h:24
 6  0x002651c0 in SensorRegistryEntry::get (this=0x2003ddf0 <s_sensorRegistry+48>) at ./controllers/sensors/sensor.cpp:111
 7  0x002653e2 in Sensor::get (type=SensorType::Map) at ./controllers/sensors/sensor.cpp:208
 8  0x00261f38 in updateTunerStudioState (tsOutputChannels=0x2003d2e8 <tsOutputChannels>) at ./console/status_loop.cpp:637
 9  0x00262e48 in prepareTunerStudioOutputs () at ./console/status_loop.cpp:900
 10 0x00260914 in TunerStudio::cmdOutputChannels (this=0x20021a64 <tsInstance>, tsChannel=0x2003d4dc <usbChannel>, offset=0, count=340) at ./console/binary/tunerstudio_commands.cpp:24
 11 0x00260584 in TunerStudioBase::handleCrcCommand (this=0x20021a64 <tsInstance>, tsChannel=0x2003d4dc <usbChannel>, data=0x2003d4e1 <usbChannel+5> "", incomingPacketSize=5)
    at ./console/binary/tunerstudio.cpp:701
 12 0x0025fb3c in tsProcessOne (tsChannel=0x2003d4dc <usbChannel>) at ./console/binary/tunerstudio.cpp:537
 13 0x0025fbe2 in TunerstudioThread::ThreadTask (this=0x2003d608 <usbConsole>) at ./console/binary/tunerstudio.cpp:554
 14 0x0025f094 in ThreadController<1200>::StaticThreadTaskAdapter (thread=0x2003d608 <usbConsole>) at ./controllers/system/thread_controller.h:37
 15 0x0020035e in _port_thread_start () at ChibiOS/os/common/ports/ARMCMx/compilers/GCC/chcoreasm_v7m.S:201
2021-06-10 19:39:48 -04:00
Matthew Kennedy a54a5e7f90
convert gpiochips to c++ (#2761)
* core

* basic header

* tests are happy

* tle6240

* tle8888

* 33972

* 33810

* tle8888_req_init

* unused warning

* warning

* unsigned

* 8888 debug

* fix

* don't qualify

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
2021-06-10 04:11:01 -04:00
Matthew Kennedy 526f1f97a0
Assorted todos (#2762)
* gpiochip todos

* fuel computer

* this was already done
2021-05-30 19:23:29 -04:00
Andrey G c81b01b47a
mc33810: set ignition outputs to GP mode (#2756)
IGN mode does not want to fire Subaru ignitor
2021-05-29 05:07:04 -04:00
Matthew Kennedy 0ea1f15ca3
compile gpiochips as cpp (#2702)
* rename

* core

* structing

* more

* makefile

* structing

* 6240 compiles

* explicit cast instead of implicit narrowing

* 8888

* no extern C

* fix tests build

* extern "C"

* 33810

* 8860

* 33810

* linker

* unbreak master

* don't need that if compiling as C++

* bump config

* fix test

* tests

* unit tests bad merge

* build

* move subaru logic to cpp file

* cpp goodness

* hpp include

* this is probably the right thing to do

* simulator
2021-05-17 08:42:56 +03:00
Andrey G 4178ac61c6
mc33810 (#2684)
* mc33810: ENABLE outputs

* mc33810: enable Dwell time control
2021-05-11 18:17:06 -04:00
Andrey G 8ba38a8a63
Mc33972 update (#2599)
* MC33972: update

-per-instance thread
-enable pull-ups for enabled pins only

* smart-gpio: mc33972: uses 8-bit spi frames

3 bytes are sent to make 24-bit frame
2021-04-28 18:29:35 -04:00
Matthew Kennedy 3d17e62d65
finish off vbatt -> sensor model (#2433)
* more vbatt

* s

* goodbye voltage

* makefile

* apparently that part was in use

* include

* mocking
2021-03-07 20:18:32 -05:00
Matthew Kennedy b1873b3d8b
set all thread priorities in the same place (#2412)
* unify thread priority

* header

* mmc
2021-02-28 07:30:45 -05:00
Matthew Kennedy d933d18e29
use spiPolledExchange for small transfers (#2358)
* configure for no cache

* this doesn't need a setting

* now we don't need invalidate

* reorder and comment

* mmc

* sw knock

* use spiPolledExchange for small transfers

* mock spi

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
2021-02-17 14:48:21 -05:00
Andrey G 3166076839
Some fixes prior to board pull request (#2291)
* ChibiOS: add support for STM32F765

This chip is used on Subaru EG33 p'n'p RusEFI board from Dron_Gus

* drivers: gpio: mc33810: commulative update

- use BIT macro
- fix wake-up method
- fix order of arguments in _add function

* port: stm32f4/7: detectCanDevice check for enabled interfaces only

* ADC: fix internal array size

internalAdcIndexByHardwareIndex should be EFI_ADC_LAST_CHANNEL size
couse adc_channel_e is used as index

* status LEDs: support status LEDs that driven by low level
2021-02-06 12:22:57 -05:00
rusefillc ac6c8a6c9f let's build for h7 2021-02-05 21:37:33 -05:00
Andrey G f96ae7525f
Gpio cleanup #2 (#1530)
* pin repository: PIN_USED size in now equal to brain_pin_e enum size

expect special values...

* smart gpios: register gpio chip to given base (no auto-allocation)

* drivers: gpio: core: add gpiochip_unregister()

* drivers: gpio: MC33810 intergation

* smart_gpio.cpp: cleanup ifdef mess, minor cleanups

* gpio: core: additional check for gpio ranges overlaps

* unit test: gpio chip: fixed and extended
2021-01-06 18:29:47 -05:00
Andrey G cd546cf932
TLE8888: temp fix of #2065 (#2079) 2020-12-14 15:33:27 -05:00
Andrey G 7c6974ab43
Fixes after clenup (#2019)
* We still need consoleEventListener for boards with EFI_CONSOLE_SERIAL_DEVICE

* MC33810: add MC_ prefix for command defines

As CMD_PWM define is now used by console command
2020-12-05 11:54:09 -05:00
Matthew Kennedy f3b7a1d9da
Remove lockAnyContext, replace with CriticalSectionLocker (#1938)
* switch to CriticalSectionLocker

* that's just about all

* clean up last usage

* include hpp for sim

* need the cpp wrappers in the makefile too

* include dir

* include
2020-11-19 06:56:02 -05:00
Andrey G f48621e4c2
TLE8888: disable diagnostic for OUTPUT8..13 (#1956)
Enabled pull-down affects analog inputs that shares same pins.
Disable it.
DOTO: enable diagnostic if ouput requested through tle8888_setPadMode
2020-11-17 18:33:37 -05:00
Andrey G 62f441376c
Tle8888 stepper (#1936)
* TLE8888: enable PP mode for OUT21..24 in case of useTLE8888_stepper

* Lada Kalina is a test mule for stepper idle
2020-11-10 14:16:46 -05:00
Andrey G 63c25ab8a7
Tle8888 small update (#1908)
* TLE8888: add support MR switching from SW

Main Relay has limitation - it is always active while KEY=1. When
KEY=0 MR can be switched on from SW.

* TLE8888: support reading of KEY and WAKE inputs

* Rusefi enums: add new TLE8888 pins
2020-11-01 22:19:55 -05:00
Andrey G 8e11675afd
Tle8888 big update 1 (#1892)
* smart gpio: fix tle8888 direct pin mapping for MRE

* MRE: use TLE8888 pins instead of MCU gpios that drives TLE8888

* TLE8888: cleanup

* TLE8888: do not reset driver private data on WD/undervoltage reset

* TLE8888: diagnostic updates

* TLE8888 driver: BIG driver rework

* TLE8888: check SPI answers for abnormal states

Reply with other than requested register can be a sign of:
-Power-On-Reset, then OpStat0 will be replyed
-WatchDog reset, then FWDStat1 will be replyed
-Invalid communication frame, then Diag0 will be replyed

Keep tracking last accessed register and check with the next reply.

* TLE8888: debug clean-up

* TLE8888: implement spi array write

This reduce CS inactive state time between two consequent accesses
from 8.8 uS to 1.4 uS

* TLE8888: fix PP outputs in OD mode

* TLE8888: cleanup register definitions

* TLE8888: run separate driver thread for each chip instance

Calculating poll interval for few chips become more complex, avoid
this running thread for each device.

* TLE8888: fix cypress and kinetic compilation

Both platforms define its own MAX and cause redifination error if
common.h is included in driver.

* MRE: update mapping.yaml and fix direct pin mapping for TLE8888

* TLE8888: diagnnostic: disable switch off in case of overcurrent

For all output, use current limiting instead

* TLE8888: check for overvoltage on OUT8..OUT13

* TLE8888: add TODO note about how to recover from failure condition

Currently TLE8888 automaticly recovers only from overcurrent and
(may be) overtemperature conditions.
Short to bat cause output disable (bit in OECONFIG is reset) and
needs driver/host intervention.

* TLE8888: save few bytes of RAM

* TLE8888: Lada Kalina is test mule for IDLE stepper on TLE8888

Don't forget to enable PP mode for TLE8888 outputs 21..24:
uncomment line 1087 in tle8888.c

* TLE8888: reorder code, cleanup

* TLE8888: mode all debug/statisctic to per-chip struct

* TLE8888: rework poll interval calculation

* MRE: use TLE8888 pins instead of MCU gpios that drives TLE8888 #2
2020-10-23 12:25:30 -04:00
rusefi 02573713f3 Hellen says drivers 2020-09-07 12:00:16 -04:00
rusefi e3b41c2387 dead code 2020-08-31 20:52:25 -04:00
rusefi fc28692258 more readable error message thank you Matt! 2020-05-23 17:20:46 -04:00
rusefi 44b5e38d3a "TLE8888 SR Unexpected response" does not work as intended fix #1466 2020-05-22 22:56:19 -04:00
rusefi a0a1a9f9bb "TLE8888 SR Unexpected response" does not work as intended #1466 2020-05-22 08:23:49 -04:00
rusefi c95a4c552b more info into error message 2020-05-22 01:05:07 -04:00
dron0gus 7500e44c8c
tle6240: fix crash in driver wake routine (#1435) 2020-05-15 15:54:41 -04:00
rusefi 4e5a69891d new LED logic: constant WARNING if VBATT is below 7v 2020-05-13 01:52:27 -04:00
rusefi 257ed04fac new LED logic: constant WARNING if VBATT is below 7v 2020-05-13 01:17:48 -04:00
rusefi 52ad619b15 I think it's OK to crash very visibly if no proper SPI response 2020-05-13 01:07:11 -04:00
rusefi 75781f1262 hiding diag code which was messing with GP2/GP3 i.e. TLE8888_PIN_22 TLE8888_PIN_23 2020-05-11 00:53:50 -04:00
rusefi 633afc10c8 trying to guess 2020-05-09 20:45:20 -04:00
rusefi 19a1ad05b1 tle8888 restoration 2020-05-09 16:59:54 -04:00
rusefi b88b1e4aa5 mre 050 compromise 2020-05-09 09:40:00 -04:00