...

  • charger_controller: This module is effectively a wrapper around mcp2515 that manages communication explicitly with the charger. It can be thought of as the ‘driver’ for the charger.

    • uses mcp2515’s driver to send charging messages

      • methods:

        • charger_controller_init

        • charger_controller_activate

        • charger_controller_deactivate

    • charger_contoller_fault_monitor (merged into charger_controller)

      • registers can rx callbacks to find faults.

      • in case of a fault, broadcasts it to the rest of the car.

  • charger_control_pilot_monitor

    • when PWM_READING_REQUEST is raised, it will use PWM to do a reading for max current.

    • raises a PWM_READING event with the max current reading.

  • charger_connection_sense

    • sets up the interrupt for when the charger gets powered from AC.

    • raises a CHARGER_CONNECTED, CHARGER_DISCONNECTED, event when the interrupt triggers.

  • permission_resolver

    • once the charger connects, it sends a permission request to centre console, here’s two cases:

      • centre console will grant permission

        • it starts the begin_charge_fsm

      • centre console won’t grant permission

        • charger does nothing, and waits for a disconnect and connect.

  • begin_charge_fsm

    • it begins PWM reading by raising a PWM_READING_REQUEST

    • then it will wait for MAX_CURRENT_AVAILABLE

    • then it will set the state of the control pilot

    • then it activates charger_controller and charging begins.

    • it will also handle relay controls

  • stop_charge_fsm

    • it will stop the charger_controller

    • it will set the control pilot pin

    • it will broadcast a CHARGER_DISCONNECTED CAN message. So centre console can allow for power state transitions.

    • it will also handle relay controls

  • battery_voltage_monitor

    • repeatedly receives CAN_(battery_voltage)

    • if more than a threshold, begins the stop_charge_fsm

...