Skip to content

Commit

Permalink
cpu/samd5x: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
firas-hamdi committed Jun 21, 2023
1 parent 0bc7c21 commit 2c27655
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions boards/same54-xpro/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,23 @@ static const tc32_conf_t timer_config[] = {
* @name CAN configuration
* @{
*/
/** Available CAN interfaces */
static const can_conf_t candev_conf[] = {
{
.can = CAN1,
.rx_pin = GPIO_PIN(PB, 13),
.tx_pin = GPIO_PIN(PB, 12),
.mux = GPIO_MUX_H,
.tdc_ctrl = false,
.dar_ctrl = false,
.tx_fifo_queue_ctrl = false,
.global_filter_cfg = CAN_REJECT,
}
};

/* CAN 1 configuration */
/** CAN 1 configuration */
#define ISR_CAN1 isr_can1

/** Number of CAN interfaces */
#define CAN_NUMOF ARRAY_SIZE(candev_conf)
/** @} */

Expand Down
8 changes: 5 additions & 3 deletions cpu/samd5x/include/candev_samd5x.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ typedef struct {
Can *can; /**< CAN device handler */
gpio_t rx_pin; /**< CAN Rx pin */
gpio_t tx_pin; /**< CAN Tx pin */
gpio_mux_t mux;
bool tdc_ctrl; /**< Enable/Disable Transceiver Delay Compensation */
bool dar_ctrl; /**< Enable/Disable Automatic Retransmission */
bool tx_fifo_queue_ctrl; /**< False to use Tx FIFO operation
Expand All @@ -85,7 +84,7 @@ typedef struct {
* @brief CAN message RAM accessible to the CAN controller
*/
typedef struct {
/** Standard filters space in the CAN message RAM */
/** Standard filters space in the CAN message RAM */
CanMramSidfe std_filter[CANDEV_SAMD5X_DEFAULT_STD_FILTER_NUM];
/** Extended filters space in the CAN message RAM */
CanMramXifde ext_filter[CANDEV_SAMD5X_DEFAULT_EXT_FILTER_NUM];
Expand All @@ -105,8 +104,11 @@ typedef struct {
* @brief CAN device descriptor
*/
typedef struct {
/** Structure to hold driver state */
candev_t candev;
/** CAN device configuration descriptor */
const can_conf_t *conf;
/** CAN message RAM accessible to the CAN controller */
msg_ram_conf_t msg_ram_conf;
} can_t;
#define HAVE_CAN_T
Expand Down Expand Up @@ -151,4 +153,4 @@ void candev_samd5x_enter_sleep_mode(candev_t *candev);
*/
void candev_samd5x_exit_sleep_mode(candev_t *candev);

#endif
#endif /* CANDEV_SAMD5X_H */
13 changes: 11 additions & 2 deletions cpu/samd5x/periph/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,17 @@ void candev_samd5x_set_pins(can_t *dev)
gpio_init(dev->conf->tx_pin, GPIO_OUT);
gpio_init(dev->conf->rx_pin, GPIO_IN);

gpio_init_mux(dev->conf->tx_pin, dev->conf->mux);
gpio_init_mux(dev->conf->rx_pin, dev->conf->mux);
if (dev->conf->can == CAN0) {
gpio_init_mux(dev->conf->tx_pin, GPIO_MUX_I);
gpio_init_mux(dev->conf->rx_pin, GPIO_MUX_I);
}
else if (dev->conf->can == CAN1) {
gpio_init_mux(dev->conf->tx_pin, GPIO_MUX_H);
gpio_init_mux(dev->conf->rx_pin, GPIO_MUX_H);
}
else {
DEBUG_PUTS("Unsupported can channel");
}
}

void candev_samd5x_enter_sleep_mode(candev_t *candev)
Expand Down

0 comments on commit 2c27655

Please sign in to comment.