Skip to content

Commit 30f0467

Browse files
fastbikeaentinger
authored andcommitted
Fix for #295 to allow flexible bit rate either one of the 4 predefined rates or a custom rate
1 parent 78b63e9 commit 30f0467

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: libraries/Arduino_CAN/src/R7FA4M1_CAN.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool R7FA4M1_CAN::begin(uint32_t const can_bitrate)
161161

162162
/* Calculate the CAN bitrate based on the value of this functions parameter.
163163
*/
164-
static uint32_t const F_CAN_CLK_Hz = 24*1000*1000UL;
164+
static uint32_t const F_CAN_CLK_Hz = 24*1000*1000UL;
165165
static uint32_t const TQ_MIN = 8;
166166
static uint32_t const TQ_MAX = 25;
167167
static uint32_t const TSEG_1_MIN = 4;
@@ -172,7 +172,7 @@ bool R7FA4M1_CAN::begin(uint32_t const can_bitrate)
172172
auto [is_valid_baudrate, baud_rate_prescaler, time_segment_1, time_segment_2] =
173173
util::calc_can_bit_timing(can_bitrate, F_CAN_CLK_Hz, TQ_MIN, TQ_MAX, TSEG_1_MIN, TSEG_1_MAX, TSEG_2_MIN, TSEG_2_MAX);
174174
init_ok &= is_valid_baudrate;
175-
175+
176176
if (is_valid_baudrate) {
177177
_can_bit_timing_cfg.baud_rate_prescaler = baud_rate_prescaler;
178178
_can_bit_timing_cfg.time_segment_1 = time_segment_1;
@@ -187,6 +187,7 @@ bool R7FA4M1_CAN::begin(uint32_t const can_bitrate)
187187
return init_ok;
188188
}
189189

190+
////////////////////////
190191
void R7FA4M1_CAN::end()
191192
{
192193
R_CAN_Close(&_can_ctrl);

0 commit comments

Comments
 (0)