Quick Links:
Architecture:
It would make sense to keep the firmware of this board pretty simple, the board does not need to know about the car's power states. It can simply receive CAN messages and act upon them.
Modules:
- front_power_distribution_can_rx_event_mapper
- Receives can messages and raises events.
- front_power_distribution_gpio
- Receives GPIO events and sets the corresponding GPIO pin states.
- front_power_distribution_current_measurement
- methods:
- front_power_distribution_current_measurement_init()
- Periodically Reads current values from all the load switches in some period of time
- will use 4 instances of bts_7200_current_sense
- will have a timer, every time the timer goes off, it'll read from all 4 storages.
- raise a FRONT_POWER_DISTRIBUTION_CURRENT_SENSE_DATA_READY
- front_power_distribution_storage_global()
- simply returns the storage.
- front_power_distribution_current_measurement_init()
- methods:
- front_power_distribution_publish_data
- Periodically broadcasts the gathered data from front_power_distribution_current_measurement
- main
- initializes the modules, processes the event queue and passes it into the other modules.
Libraries
- bts_7200_current_sense
- methods:
- bts_7200_init(configuration)
- configuration
- Select Pin Address
- Sense Pin Address
- callback
- initialize select pin as GPIO Output
- initialize sense pin as GPIO Input, (adc)
- periodically set up timers
- every time timer goes off, we'll
- measure with sel 1
- measure with sel 2
- update storage with that measurement
- every time timer goes off, we'll
- configuration
- bts_7200_get_measurement()
- returns whatever measurement is in its storage
- bts_7200_init(configuration)
- methods:
- lights_signal_fsm
- Uses blinkers to repeatedly raise events
- Has a state machine implementing the.
- inputs:
- event names: signal_left_fsm_input, signal_right_fsm_input, hazard_fsm_input, sync
- outputs:
- signal_left_fsm_output
- signal_right_fsm_output
- signal_both_output, or you can raise a left_output and right_output...
- blink_event_generator
- uses soft_timers to repeatedly raise an event with a data field
- inputs:
- event_id
- outputs:
- raising that event_id with alternating data fields.
Events:
event | source | destination | data |
---|---|---|---|
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_DRIVER_DISPLAY | front_power_distribution_can_rx_event_mapper | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_STEERING | front_power_distribution_can_rx_event_mapper | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_CENTRE_CONSOLE | front_power_distribution_can_rx_event_mapper | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_HEADLIGHTS | front_power_distribution_can_rx_event_mapper | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_SIGNAL_LEFT | blink_event_generator | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_SIGNAL_RIGHT | blink_event_generator | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_GPIO_EVENT_SIGNAL_HAZARD | blink_event_generator | front_power_distribution_gpio | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_SIGNAL_EVENT_LEFT | front_power_distribution_can_rx_event_mapper | lights_signal_fsm | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_SIGNAL_EVENT_RIGHT | front_power_distribution_can_rx_event_mapper | lights_signal_fsm | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_SIGNAL_EVENT_HAZARD | front_power_distribution_can_rx_event_mapper | lights_signal_fsm | 1: on, 0: off |
FRONT_POWER_DISTRIBUTION_CURRENT_SENSE_EVENT_DATA_READY | front_power_distribution_current_measurement | front_power_distribution_publish_data | empty |
Incoming CAN Messages:
Message ID | Data Fields | Exported Enums |
---|---|---|
SYSTEM_CAN_MESSAGE_FRONT_POWER | uint16_t output_bitset, uint16_t state_bitset | EEFrontPowerDistributionOutput, EEFrontPowerDistributionOutputState |
SYSTEM_CAN_MESSAGE_LIGHTS | uint16_t light_type_bitset, uint16_t state_bitset | EELightType, EELightState |
SYSTEM_CAN_MESSAGE_LIGHTS_SYNC | empty | |
SYSTEM_CAN_MESSAGE_HORN | uint8_t horn_state | EEHornState |
- front_power_distribution
- lights_states
- lights_sync
Outgoing CAN Messages:
Message ID | Data Fields | Exported Enums |
---|---|---|
SYSTEM_CAN_MESSAGE_FRONT_POWER_CURRENT_DATA | uint16_t output_bitset, uint16_t current_data_0, uint16_t current_data_1, uint16_t current_data_2 | EEFrontPowerDistributionOutput |
GPIO Outputs:
# | Output | PCA9539R I2C address (likely) | Pin |
---|---|---|---|
1 | Driver Display | 0x74 | IO0_7 |
2 | Steering | 0x76 | IO1_3 |
3 | Centre Console | 0x76 | IO1_5 |
4 | Pedal | 0x76 | IO1_1 |
5 | Front Headlights | ? | ? |
6 | Signal Left | 0x76 | IO0_4 |
7 | Signal Right | 0x76 | IO0_2 |
8 | Strobe Light | ? | ? |
9 | Horn | 0x74 | IO1_7 |
10 | Driver Fan | ? | ? |
11 | Daytime Running Lights | 0x76 | IO0_5 |
12 | Speaker | 0x76 | IO1_0 |
13 | |||
14 |