Firmware API Reference ====================== This section documents the C firmware modules that make up the AddVantage PPG controller. .. contents:: Module Index :local: :depth: 1 Core Modules ------------ ProcessorExpert.c - Main Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The main application loop and state machine for the PPG controller. .. doxygenfile:: ProcessorExpert.c :project: addvantage :sections: briefdescription detaileddescription func Events.c - Calculation Engine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All fuel calculation functions including timing, pressure compensation, and map lookups. .. doxygenfile:: Events.c :project: addvantage :sections: briefdescription detaileddescription func Key Functions: - ``calculatePeriod()`` - Compute injector pulse width from fuel map - ``calculateBaseTiming()`` - Determine base injection timing - ``applyDiffPressInt()`` - Apply differential pressure correction - ``applyMapCorrection()`` - Apply manifold pressure correction - ``applyTempCorrection()`` - Apply coolant temperature correction - ``updatePPG()`` - Update pulse generator outputs CAN Bus Interface ----------------- can.c - J1939 Protocol Handler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Parses J1939 CAN messages from the engine ECU. .. doxygenfile:: can.c :project: addvantage :sections: briefdescription detaileddescription func Supported PGNs: - **EEC1 (61444)** - Engine RPM, Actual Torque - **ET1 (65262)** - Coolant Temperature - **LFE (65266)** - Fuel Economy (diesel rate) - **ETC2 (61445)** - Transmission data Storage and I/O --------------- flash.c - EEPROM Emulation ~~~~~~~~~~~~~~~~~~~~~~~~~~ Flash memory driver for configuration persistence. .. doxygenfile:: flash.c :project: addvantage :sections: briefdescription detaileddescription func Key Operations: - Read/write configuration parameters - Fuel map storage and retrieval - Temperature correction tables serial_io.c - UART Interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Serial communication for telemetry and configuration. .. doxygenfile:: serial_io.c :project: addvantage :sections: briefdescription detaileddescription func Features: - Telemetry output (1Hz) - VT100 terminal display - Password-protected configuration menu Hardware Control ---------------- solenoids.c - Actuator Control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Control of gas injectors and solenoid valves. .. doxygenfile:: solenoids.c :project: addvantage :sections: briefdescription detaileddescription func Outputs: - PPG1/PPG2 - Gas injector pulse generators - Tank solenoid - LPG tank shutoff - Reducer solenoid - Pressure reducer control adc.c - Analog Input Processing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ADC driver for pressure and level sensing. .. doxygenfile:: adc.c :project: addvantage :sections: briefdescription detaileddescription func Channels: - Channel 0: Gas pressure sensor - Channel 1: Manifold pressure sensor - Channel 2: Tank level sensor Header Files ------------ variables.h - Shared Variables API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Global variable declarations shared across modules. .. doxygenfile:: variables.h :project: addvantage :sections: briefdescription define var flash.h - Flash Memory Constants ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Flash address definitions and configuration constants. .. doxygenfile:: flash.h :project: addvantage :sections: briefdescription define Generated Code -------------- The ``Generated_Code/`` directory contains ProcessorExpert-generated drivers. These files should not be edited directly. Key Generated Modules: - **CAN1.c/h** - MSCAN peripheral driver - **AS1.c/h** - Asynchronous serial (UART) - **AD1.c/h** - ADC peripheral driver - **PPG1.c/h, PPG2.c/h** - Pulse generators - **FLASH1.c/h** - Flash programming interface - **WDog1.c/h** - Watchdog timer