Make the baud rate of the CAN bus car-specific.
This commit is contained in:
parent
c673326928
commit
dd14a9447a
|
@ -17,7 +17,6 @@ const int IRQ_PIN = 9;
|
||||||
|
|
||||||
const long QUARTZ_CLOCK_FREQUENCY = 16 * 1E6; // 16 MHz.
|
const long QUARTZ_CLOCK_FREQUENCY = 16 * 1E6; // 16 MHz.
|
||||||
const uint32_t SPI_FREQUENCY = 10 * 1E6; // 10 MHz.
|
const uint32_t SPI_FREQUENCY = 10 * 1E6; // 10 MHz.
|
||||||
const long BAUD_RATE = 500 * 1E3; // 500k.
|
|
||||||
|
|
||||||
bool isCanBusReaderActive = false;
|
bool isCanBusReaderActive = false;
|
||||||
long lastCanMessageReceivedMs;
|
long lastCanMessageReceivedMs;
|
||||||
|
|
10
config.h
10
config.h
|
@ -1,7 +1,7 @@
|
||||||
#if !defined(RACECHRONO_BIY_BLE_DEVICE_CONFIG_H)
|
#if !defined(RACECHRONO_BIY_BLE_DEVICE_CONFIG_H)
|
||||||
#define 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"
|
#define DEVICE_NAME "BLE CAN device demo"
|
||||||
|
|
||||||
// We use RaceChronoPidMap to keep track of stuff for each CAN ID.
|
// We use RaceChronoPidMap to keep track of stuff for each CAN ID.
|
||||||
|
@ -11,13 +11,19 @@
|
||||||
const uint8_t DEFAULT_UPDATE_RATE_DIVIDER = 10;
|
const uint8_t DEFAULT_UPDATE_RATE_DIVIDER = 10;
|
||||||
|
|
||||||
// You need to pick one of the provided configurations below, or define your own
|
// 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.
|
// 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
|
// If the value is N, only every Nth message received from the CAN bus will be
|
||||||
// communicated to RaceChrono via BLE.
|
// communicated to RaceChrono via BLE.
|
||||||
uint8_t getUpdateRateDivider(uint32_t can_id);
|
uint8_t getUpdateRateDivider(uint32_t can_id);
|
||||||
|
|
||||||
|
|
||||||
// Here are some configurations you can pick from by uncommenting one of the
|
// Here are some configurations you can pick from by uncommenting one of the
|
||||||
// following lines:
|
// following lines:
|
||||||
//#include "configs/ft86_gen1.h"
|
//#include "configs/ft86_gen1.h"
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
// (2013-2020 model years).
|
// (2013-2020 model years).
|
||||||
|
|
||||||
#if !defined(RACECHRONO_BIY_BLE_DEVICE_FT86_GEN1_H)
|
#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) {
|
uint8_t getUpdateRateDivider(uint32_t can_id) {
|
||||||
switch (can_id) {
|
switch (can_id) {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
// (2022+ model years).
|
// (2022+ model years).
|
||||||
|
|
||||||
#if !defined(RACECHRONO_BIY_BLE_DEVICE_FT86_GEN2_H)
|
#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) {
|
uint8_t getUpdateRateDivider(uint32_t can_id) {
|
||||||
// This is sent over the CAN bus 50 times per second and includes brake
|
// This is sent over the CAN bus 50 times per second and includes brake
|
||||||
|
|
Loading…
Reference in New Issue