Skip to content

Firmware structure

Igor Kovalenko edited this page Jul 5, 2018 · 8 revisions

Defines

File bcomp.h:

  • VIRTUINO_SUPPORT - set to 1, for supporting Virtuino communication.
  • INSIDE_VERSION - set to 1, for setting inside version.
  • PAJERO_SPECIFIC - set to 1, for include specific functions for Mitsubishi Pajero Sport.
  • NISSAN_SPECIFIC - set to 1, for include specific functions for Nissan (CVT-transmission reading).
  • GRAPH_SUPPORT - set to 0, for disable OLED-screen support (only elog or Virtuino output data).
  • ELOG_SUPPORT - set to 1, for sending data to uart-logger device. Unsupport this option with VIRTUINO_SUPPORT.
  • WARNING_SUPPORT - set to 1, for supporting warnings (beep sygnals and show messages, if GRATH_SUPPORT).
  • NMEA_SUPPORT - set to 1, for minimal supporting NMEA protocol (decode RMC messages).
  • BUTTONS_ANALOG - support analog (resistive matrix) buttons.
  • OLED_SSD1306_SUPPORT - support OLED 128x64 screen on SSD1306.
  • OLED_SH1106_SUPPORT - support OLED 128x64 screen on SH1106.
  • WHELLS_DRAW_SUPPORT - support wheels screen.

File dbg.h:

  • _DBGOUT - define it for debug outputs via DBG() function to UART.

File event.h:

  • MAX_EVENT - maximum count of events process.
  • EVENT_64BIT - set to 1, for 64-bit ms count. It need, for corect work, if MCU will be work more 40 days without resets.
  • EVENTS_FREQ - count of calls SysTick_Handler() per second.

File buttons.h

  • BUTTONS_ANALOG - support analog (resistive matrix) buttons.
  • BUTTONS_SUPPORT_LONG - support long-time button press. For using only one button.

Project structure

File obd.c

This module realize transport for SAE J1979 and requests list of PIDs description in pids_list[] structure.

File obd_pids.h

This file consist PIDs defines, include vendor specific PIDs.

File bcomp_v2.c

Asynchronous functions:

  • bcomp_proc() calls from obd.c and decode necessary PID answers.
  • bcomp_raw() calls from obd.c and decode RAW data from CAN bus. This function vendor specific (now decode data for Mitsubishi Pajero Sport II).
  • bcomp_calc() call every 1 second for calculation and integration various parameters (distantions, fuel, trips, motohours).
  • bcomp_analog() call every 3 second for reading analog inputs. Now it read in Mitsubishi Pajero Sport II: external temperature, fuel level, onboard voltage.
  • bcomp_save() call every 30 second for saving parameters to external EEPROM.
  • bcomp_elog() call every 1 second, it setup flag for sending status to UART via elog.c module.

File bcomp.h

File bcomp.h contain key defines for configuration project and main structure defines, as bcomp_t with all parameters and calculations and bconfig_t this standart configuration (warning levels, OLED and EEPROM type, default settings for warning levels and etc.).

File virtuino.c

This module implements protocol with Virtuino

File warning.c

This module monitoring parameters and warning events, if parameters go over allowed values.

File elog.c

Logging module for transmit some parameters to UART. External device for saving it some as: UART Logger or OpenLog Blackbox.

Output format is CSV.

time;speed;rpm;trans;batt;fuel;dfuel;lon;lat;gtime;gdate;t_eng;t_akpp;t_ext;p_fu
1406835930;0;0;D2;0.0;71.91;0.00;W10035.9989;N3051.8007;19-45-30;31-07-2014;65535;65535;9;0;0;0;0;0;
1406835931;0;0;D2;0.0;71.91;0.00;W10035.9989;N3051.8007;19-45-31;31-07-2014;65535;65535;9;0;0;0;0;0;
etc...

The first string consist description of columns, the next strings sens every second and consist actual data.

File menu.c

Configuration menu file. It config some parameters of BCOMP firmware in graphical menu on OLED-display. List of available parameters desctiption on menu[] list.

File buttons.c

Module of buttons support. Support analog and digital buttons.

File nmea.c

Minimal support of NMEA protocol (GPS-receivers). It decode only RMC message. Function nmea_proc() calls from uart.c module for every receiving byte.

File event.c

Module for asynchronous function calls. It based on SysTick timer. Support up to MAX_EVENT functions simultaneously.