Lines Matching refs:hal_ctx

27 bool twai_hal_init(twai_hal_context_t *hal_ctx)  in twai_hal_init()  argument
30 hal_ctx->dev = &TWAI; in twai_hal_init()
31 hal_ctx->state_flags = 0; in twai_hal_init()
33 twai_ll_enter_reset_mode(hal_ctx->dev); in twai_hal_init()
34 …if (!twai_ll_is_in_reset_mode(hal_ctx->dev)) { //Must enter reset mode to write to config regis… in twai_hal_init()
38 …twai_ll_enable_extended_reg_layout(hal_ctx->dev); //Changes the address layout of the regis… in twai_hal_init()
40 twai_ll_set_mode(hal_ctx->dev, TWAI_MODE_LISTEN_ONLY); //Freeze REC by changing to LOM mode in twai_hal_init()
42 twai_ll_set_tec(hal_ctx->dev, TWAI_HAL_INIT_TEC); in twai_hal_init()
43 twai_ll_set_rec(hal_ctx->dev, TWAI_HAL_INIT_REC); in twai_hal_init()
44 twai_ll_set_err_warn_lim(hal_ctx->dev, TWAI_HAL_INIT_EWL); //Set default value of for EWL in twai_hal_init()
48 void twai_hal_deinit(twai_hal_context_t *hal_ctx) in twai_hal_deinit() argument
51 (void) twai_ll_get_and_clear_intrs(hal_ctx->dev); in twai_hal_deinit()
52 twai_ll_set_enabled_intrs(hal_ctx->dev, 0); in twai_hal_deinit()
53 twai_ll_clear_arb_lost_cap(hal_ctx->dev); in twai_hal_deinit()
54 twai_ll_clear_err_code_cap(hal_ctx->dev); in twai_hal_deinit()
55 hal_ctx->dev = NULL; in twai_hal_deinit()
58 void twai_hal_configure(twai_hal_context_t *hal_ctx, const twai_timing_config_t *t_config, const tw… in twai_hal_configure() argument
61 …twai_ll_set_bus_timing(hal_ctx->dev, t_config->brp, t_config->sjw, t_config->tseg_1, t_config->tse… in twai_hal_configure()
62 …twai_ll_set_acc_filter(hal_ctx->dev, f_config->acceptance_code, f_config->acceptance_mask, f_confi… in twai_hal_configure()
63 twai_ll_set_clkout(hal_ctx->dev, clkout_divider); in twai_hal_configure()
64 twai_ll_set_enabled_intrs(hal_ctx->dev, intr_mask); in twai_hal_configure()
65 (void) twai_ll_get_and_clear_intrs(hal_ctx->dev); //Clear any latched interrupts in twai_hal_configure()
70 void twai_hal_start(twai_hal_context_t *hal_ctx, twai_mode_t mode) in twai_hal_start() argument
72 twai_ll_set_mode(hal_ctx->dev, mode); //Set operating mode in twai_hal_start()
73 (void) twai_ll_get_and_clear_intrs(hal_ctx->dev); //Clear any latched interrupts in twai_hal_start()
74 TWAI_HAL_SET_BITS(hal_ctx->state_flags, TWAI_HAL_STATE_FLAG_RUNNING); in twai_hal_start()
75 twai_ll_exit_reset_mode(hal_ctx->dev); in twai_hal_start()
78 void twai_hal_stop(twai_hal_context_t *hal_ctx) in twai_hal_stop() argument
80 twai_ll_enter_reset_mode(hal_ctx->dev); in twai_hal_stop()
81 (void) twai_ll_get_and_clear_intrs(hal_ctx->dev); in twai_hal_stop()
82 twai_ll_set_mode(hal_ctx->dev, TWAI_MODE_LISTEN_ONLY); //Freeze REC by changing to LOM mode in twai_hal_stop()
84 …TWAI_HAL_CLEAR_BITS(hal_ctx->state_flags, TWAI_HAL_STATE_FLAG_TX_BUFF_OCCUPIED | TWAI_HAL_STATE_FL… in twai_hal_stop()