October 17, 2018, 7:24am
if I want to using libcanard on chibios with stm32f103 how do I initialize canbus hardware
October 18, 2018, 11:38am
should I do some specific driver on chibios ? I mean when using libcanard on no rtos we should do hwInit(); which include RCC_APB1PeriphClockCmd() and GPIO_PinAFConfig. so on chibios what should we do like RCC_APB1PeriphClockCmd() or nothing to do
With ChibiOS you only need to enable the clock signal to the CAN controller, that’s it. Here are relevant examples:
* Enabling the CAN controllers, then configuring GPIO functions for CAN_TX.
* Order matters, otherwise the CAN_TX pins will twitch, disturbing the CAN bus.
* This is why we can't perform this initialization using ChibiOS GPIO configuration.
* NOTE: Check this - the problem may only appear when CAN pin remapping is used,
* because ChibiOS initializes AFIO after GPIO.
RCC->APB1ENR |= RCC_APB1ENR_CAN1EN;
palSetPadMode(GPIOB, 9, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
// Enabling CAN2 too, in order to avoid bus disruptions
RCC->APB1ENR |= RCC_APB1ENR_CAN2EN;
palSetPadMode(GPIOB, 13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
This file has been truncated.
* Copyright (C) 2017 Zubax Robotics <email@example.com>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Author: Pavel Kirienko <firstname.lastname@example.org>