Make the baud rate of the CAN bus car-specific.

This commit is contained in:
Timur Iskhodzhanov 2022-08-13 21:52:00 -07:00
parent c673326928
commit dd14a9447a
4 changed files with 14 additions and 5 deletions

View File

@ -17,7 +17,6 @@ const int IRQ_PIN = 9;
const long QUARTZ_CLOCK_FREQUENCY = 16 * 1E6; // 16 MHz.
const uint32_t SPI_FREQUENCY = 10 * 1E6; // 10 MHz.
const long BAUD_RATE = 500 * 1E3; // 500k.
bool isCanBusReaderActive = false;
long lastCanMessageReceivedMs;

View File

@ -1,7 +1,7 @@
#if !defined(RACECHRONO_BIY_BLE_DEVICE_CONFIG_H)
#define RACECHRONO_BIY_BLE_DEVICE_CONFIG_H
// Change the value
// Change the value to customize the name of your device.
#define DEVICE_NAME "BLE CAN device demo"
// We use RaceChronoPidMap to keep track of stuff for each CAN ID.
@ -11,13 +11,19 @@
const uint8_t DEFAULT_UPDATE_RATE_DIVIDER = 10;
// You need to pick one of the provided configurations below, or define your own
// configuration. Your configuration should define the following two functions:
// configuration. Your configuration should define the following constant and
// function:
// Defines the baud rate to use for the CAN bus. For example, 500k baud rate
// should be written as 500 * 1e3.
extern const long BAUD_RATE; // 500k.
// Returns an "update rate divider for a given CAN ID.
// If the value is N, only every Nth message received from the CAN bus will be
// communicated to RaceChrono via BLE.
uint8_t getUpdateRateDivider(uint32_t can_id);
// Here are some configurations you can pick from by uncommenting one of the
// following lines:
//#include "configs/ft86_gen1.h"

View File

@ -2,7 +2,9 @@
// (2013-2020 model years).
#if !defined(RACECHRONO_BIY_BLE_DEVICE_FT86_GEN1_H)
#define RACECHRONO_BIY_BLE_DEVICE_FT86_GEN1_H)
#define RACECHRONO_BIY_BLE_DEVICE_FT86_GEN1_H
const long BAUD_RATE = 500 * 1e3; // 500k.
uint8_t getUpdateRateDivider(uint32_t can_id) {
switch (can_id) {

View File

@ -2,7 +2,9 @@
// (2022+ model years).
#if !defined(RACECHRONO_BIY_BLE_DEVICE_FT86_GEN2_H)
#define RACECHRONO_BIY_BLE_DEVICE_FT86_GEN2_H)
#define RACECHRONO_BIY_BLE_DEVICE_FT86_GEN2_H
const long BAUD_RATE = 500 * 1e3; // 500k.
uint8_t getUpdateRateDivider(uint32_t can_id) {
// This is sent over the CAN bus 50 times per second and includes brake