Skip to content

Commit 32c7efc

Browse files
TinyuZhaolbuque
authored andcommitted
docs: Fix hardware.CAN docs.
Signed-off-by: tinyu <tinyu.zhao@gmail.com>
1 parent dadb0af commit 32c7efc

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

docs/en/hardware/can.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ Methods
102102

103103
Return the state of the controller. The return value can be one of:
104104

105-
- ``CAN.STOPPED`` -- the controller is completely off and reset;
106-
- ``CAN.RUNNING`` -- The controller can transmit and receive messages;
107-
- ``CAN.BUS_OFF`` -- the controller is on but not participating in bus activity
105+
- ``0`` -- ``CAN.STOPPED`` : the controller is completely off and reset;
106+
- ``4`` -- ``CAN.BUS_OFF`` : the controller is on but not participating in bus activity
108107
(TEC overflowed beyond 255);
109-
- ``RECOVERING`` -- The controller is undergoing bus recovery.
108+
- ``5`` -- ``CAN.RECOVERING`` -- The controller is undergoing bus recovery.
109+
- ``6`` -- ``CAN.RUNNING`` : The controller can transmit and receive messages;
110110

111111
UIFLOW2:
112112

m5stack/cmodules/m5can/modcan.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
#define DEBUG 1
2323
#if DEBUG
24-
#define DEBUG_printf(...) mp_printf(&mp_plat_print, __VA_ARGS__)
24+
#define DEBUG_printf(...) mp_printf(&mp_plat_print, __VA_ARGS__)
2525
#else
26-
#define DEBUG_printf(...) (void)0
26+
#define DEBUG_printf(...) (void)0
2727
#endif
2828

2929
// Default timings; 125Kbps
@@ -301,10 +301,10 @@ static mp_obj_t pyb_can_init_helper(pyb_can_obj_t *self, size_t n_args, const mp
301301

302302
if (args[ARG_baudrate].u_int != 0) {
303303
int xtal = esp_clk_xtal_freq() / 1000000;
304-
DEBUG_printf("XTAL frequency: %d MHz\n", xtal);
305-
DEBUG_printf("find_timing_config: xtal=%d MHz, baudrate=%d kbps\n", xtal, args[ARG_baudrate].u_int);
304+
// DEBUG_printf("XTAL frequency: %d MHz\n", xtal);
305+
// DEBUG_printf("find_timing_config: xtal=%d MHz, baudrate=%d kbps\n", xtal, args[ARG_baudrate].u_int);
306306
if (find_timing_config(xtal, args[ARG_baudrate].u_int, &self->t_config) != 0) {
307-
DEBUG_printf("Timing config not found for baudrate %d kbps\n", args[ARG_baudrate].u_int);
307+
// DEBUG_printf("Timing config not found for baudrate %d kbps\n", args[ARG_baudrate].u_int);
308308
mp_raise_msg_varg(&mp_type_ValueError,
309309
MP_ERROR_TEXT("Unsupported baudrate %d kbps for %d MHz crystal. Supported: 25, 50, 100, "
310310
"125, 250, 500, 800, 1000"),
@@ -316,10 +316,10 @@ static mp_obj_t pyb_can_init_helper(pyb_can_obj_t *self, size_t n_args, const mp
316316
uint32_t xtal_apb_freq_hz;
317317

318318
esp_clk_tree_src_get_freq_hz(CAN_DEFAULT_CLK_SRC, ESP_CLK_TREE_SRC_FREQ_PRECISION_EXACT, &xtal_apb_freq_hz);
319-
DEBUG_printf("XTAL APB frequency: %d MHz\n", xtal_apb_freq_hz / 1000000);
319+
// DEBUG_printf("XTAL APB frequency: %d MHz\n", xtal_apb_freq_hz / 1000000);
320320
args[ARG_quanta_resolution_hz].u_int = xtal_apb_freq_hz / args[ARG_brp].u_int;
321-
DEBUG_printf("Using quanta_resolution_hz=%u based on brp=%u\n", args[ARG_quanta_resolution_hz].u_int,
322-
args[ARG_brp].u_int);
321+
// DEBUG_printf("Using quanta_resolution_hz=%u based on brp=%u\n", args[ARG_quanta_resolution_hz].u_int,
322+
// args[ARG_brp].u_int);
323323
args[ARG_brp].u_int = 0;
324324
}
325325
self->t_config.quanta_resolution_hz = args[ARG_quanta_resolution_hz].u_int;
@@ -330,10 +330,10 @@ static mp_obj_t pyb_can_init_helper(pyb_can_obj_t *self, size_t n_args, const mp
330330
self->t_config.triple_sampling = args[ARG_triple_sampling].u_bool;
331331
}
332332

333-
DEBUG_printf("tx=%u, rx=%u, mode=%u\n", self->g_config.tx_io, self->g_config.rx_io, self->g_config.mode);
334-
DEBUG_printf("quanta_resolution_hz=%u brp=%u, tseg_1=%u, tseg_2=%u, sjw=%u, triple_sampling=%u\n",
335-
self->t_config.quanta_resolution_hz, self->t_config.brp, self->t_config.tseg_1, self->t_config.tseg_2,
336-
self->t_config.sjw, self->t_config.triple_sampling);
333+
// DEBUG_printf("tx=%u, rx=%u, mode=%u\n", self->g_config.tx_io, self->g_config.rx_io, self->g_config.mode);
334+
// DEBUG_printf("quanta_resolution_hz=%u brp=%u, tseg_1=%u, tseg_2=%u, sjw=%u, triple_sampling=%u\n",
335+
// self->t_config.quanta_resolution_hz, self->t_config.brp, self->t_config.tseg_1,
336+
// self->t_config.tseg_2, self->t_config.sjw, self->t_config.triple_sampling);
337337

338338
check_esp_err(twai_driver_install(&self->g_config, &self->t_config, &self->f_config));
339339
check_esp_err(twai_start());
@@ -449,6 +449,7 @@ static mp_obj_t pyb_can_state(mp_obj_t self_in) {
449449
if (self->is_enabled) {
450450
twai_status_info_t status_info;
451451
check_esp_err(twai_get_status_info(&status_info));
452+
// DEBUG_printf("get status %d\n", status_info.state);
452453
if (status_info.state == TWAI_STATE_STOPPED) {
453454
state = CAN_STATE_STOPPED;
454455
} else if (status_info.state == TWAI_STATE_RUNNING) {

0 commit comments

Comments
 (0)