Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #12104 (STM32 can_init_freq() ignores frequency) #12113

Merged
merged 3 commits into from
Dec 20, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 8 additions & 31 deletions targets/TARGET_STM/can_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void _can_init_direct(can_t *obj, const can_pinmap_t *pinmap)
CAN_INIT_FREQ_DIRECT(obj, pinmap, 100000);
}

void can_init(can_t *obj, PinName rd, PinName td)
void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
{
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
Expand All @@ -178,27 +178,14 @@ void can_init(can_t *obj, PinName rd, PinName td)

const can_pinmap_t static_pinmap = {peripheral, rd, function_rd, td, function_td};

/* default frequency is 100 kHz */
CAN_INIT_DIRECT(obj, &static_pinmap);
CAN_INIT_FREQ_DIRECT(obj, &static_pinmap, hz);
}



void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
void can_init(can_t *obj, PinName rd, PinName td)
{
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
int peripheral = (int) pinmap_merge(can_rd, can_td);

int function_rd = (int)pinmap_find_function(rd, PinMap_CAN_RD);
int function_td = (int)pinmap_find_function(td, PinMap_CAN_TD);

const can_pinmap_t static_pinmap = {peripheral, rd, function_rd, td, function_td};

CAN_INIT_FREQ_DIRECT(obj, &static_pinmap, 100000);
can_init_freq(obj, rd, td, 100000);
}


void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id)
{
irq_handler = handler;
Expand Down Expand Up @@ -666,7 +653,7 @@ static void _can_init_direct(can_t *obj, const can_pinmap_t *pinmap)
CAN_INIT_FREQ_DIRECT(obj, pinmap, 100000);
}

void can_init(can_t *obj, PinName rd, PinName td)
void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
{
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
Expand All @@ -677,22 +664,12 @@ void can_init(can_t *obj, PinName rd, PinName td)

const can_pinmap_t static_pinmap = {peripheral, rd, function_rd, td, function_td};

/* default frequency is 100 kHz */
CAN_INIT_DIRECT(obj, &static_pinmap);
CAN_INIT_FREQ_DIRECT(obj, &static_pinmap, hz);
}

void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
void can_init(can_t *obj, PinName rd, PinName td)
{
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
int peripheral = (int) pinmap_merge(can_rd, can_td);

int function_rd = (int)pinmap_find_function(rd, PinMap_CAN_RD);
int function_td = (int)pinmap_find_function(td, PinMap_CAN_TD);

const can_pinmap_t static_pinmap = {peripheral, rd, function_rd, td, function_td};

CAN_INIT_FREQ_DIRECT(obj, &static_pinmap, 100000);
can_init_freq(obj, rd, td, 100000);
}

void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id)
Expand Down