Skip to content

Commit

Permalink
squash can_stm32: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Dupont committed Dec 15, 2016
1 parent ee338f4 commit ce3d86b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cpu/stm32_common/can/candev_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ static int _send(candev_t *candev, const struct can_frame *frame);
static int _abort(candev_t *candev, const struct can_frame *frame);
static int _set(candev_t *candev, canopt_t opt, void *value, size_t value_len);
static int _get(candev_t *candev, canopt_t opt, void *value, size_t max_len);
static int _set_filter(candev_t *candev, struct can_filter *filter);
static int _remove_filter(candev_t *candev, struct can_filter *filter);
static int _set_filter(candev_t *candev, const struct can_filter *filter);
static int _remove_filter(candev_t *candev, const struct can_filter *filter);
static int _power_up(candev_t *candev);
static int _power_down(candev_t *candev);

Expand Down Expand Up @@ -164,7 +164,8 @@ int candev_stm32_init(candev_stm32_t *dev, const candev_stm32_conf_t *conf)
{
dev->candev.driver = &candev_stm32_driver;

struct can_bittiming timing = { .bitrate = 500000, .sample_point = 875 };
struct can_bittiming timing = { .bitrate = CANDEV_STM32_DEFAULT_BITRATE,
.sample_point = CANDEV_STM32_DEFAULT_SPT };
can_device_calc_bittiming(CLOCK_APB1, &bittiming_const, &timing);

memcpy(&dev->candev.bittiming, &timing, sizeof(timing));
Expand Down Expand Up @@ -264,7 +265,6 @@ static int _init(candev_t *candev)
can->MCR |= mask_config;
can->MCR &= (mask_config | CAN_MCR_BIT_DONT_TOUCH);


_set_bit_timing(dev);

/* Loopback and/or silent mode */
Expand Down Expand Up @@ -630,7 +630,7 @@ static int _get(candev_t *candev, canopt_t opt, void *value, size_t max_len)
return res;
}

static int _set_filter(candev_t *candev, struct can_filter *filter)
static int _set_filter(candev_t *candev, const struct can_filter *filter)
{
candev_stm32_t *dev = (candev_stm32_t *)candev;

Expand All @@ -655,7 +655,7 @@ static int _set_filter(candev_t *candev, struct can_filter *filter)
return i - first_filter;
}

static int _remove_filter(candev_t *candev, struct can_filter *filter)
static int _remove_filter(candev_t *candev, const struct can_filter *filter)
{
candev_stm32_t *dev = (candev_stm32_t *)candev;

Expand Down
8 changes: 8 additions & 0 deletions cpu/stm32_common/include/candev_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ extern "C" {
#define CAN_STM32_NB_FILTER_CAN2 (CAN_STM32_NB_FILTER - CAN_STM32_NB_FILTER_CAN1)
#endif

#ifndef CANDEV_STM32_DEFAULT_BITRATE
#define CANDEV_STM32_DEFAULT_BITRATE 500000
#endif

#ifndef CANDEV_STM32_DEFAULT_SPT
#define CANDEV_STM32_DEFAULT_SPT 875
#endif

enum candev_stm32_channel {
CANDEV_STM32_CHANNEL_0 = 0,
#if defined(CPU_FAM_STM32F1) || defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4)
Expand Down

0 comments on commit ce3d86b

Please sign in to comment.