Skip to content

Commit

Permalink
[NUCLEO_F103RB] Added CAN support
Browse files Browse the repository at this point in the history
Added CAN API support for NUCLEO_F103RB target.

Change-Id: Ib5dac8023917afef683ba0703d732bbf53efdcd9
  • Loading branch information
BartSX committed Jun 6, 2016
1 parent 8b44c0d commit 6e77543
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ typedef enum {
PWM_4 = (int)TIM4_BASE
} PWMName;

typedef enum {
CAN_1 = (int)CAN1_BASE
} CANName;

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,15 @@ const PinMap PinMap_SPI_SSEL[] = {
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_RD[] = {
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)},
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_TD[] = {
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)},
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)},
{NC, NC, 0}
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@



#define DEVICE_CAN 1

//=======================================

#define DEVICE_ID_LENGTH 24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ struct pwmout_s {
uint32_t pulse;
};

struct can_s {
CANName can;
int index;
};

#include "gpio_object.h"

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions libraries/tests/mbed/can/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CAN can1(PD_0, PD_1);
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
defined(TARGET_DISCO_F429ZI)
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB)
CAN can1(PA_11, PA_12);
#elif defined(TARGET_DISCO_F469NI)
CAN can1(PB_8, PB_9);
Expand Down Expand Up @@ -63,7 +63,7 @@ int main() {
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
!defined(TARGET_NUCLEO_F302R8))
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
printf("loop()\n");
if(can2.read(msg)) {
printmsg("Rx message:", &msg);
Expand Down
6 changes: 3 additions & 3 deletions libraries/tests/mbed/can_interrupt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CAN can1(PD_0, PD_1);
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
defined(TARGET_DISCO_F429ZI)
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB)
CAN can1(PA_11, PA_12);
#elif defined(TARGET_DISCO_F469NI)
CAN can1(PB_8, PB_9);
Expand Down Expand Up @@ -58,7 +58,7 @@ void send() {
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
!defined(TARGET_NUCLEO_F302R8))
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
void read() {
CANMessage msg;
printf("rx()\n");
Expand All @@ -76,7 +76,7 @@ int main() {
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
!defined(TARGET_NUCLEO_F302R8))
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
can2.attach(&read);
#endif
while(1) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/tests/mbed/can_loopback/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CAN can1(P5_9, P5_10);
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
defined(TARGET_DISCO_F429ZI)
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB)
CAN can1(PA_11, PA_12);
#elif defined(TARGET_DISCO_F469NI)
CAN can1(PB_8, PB_9);
Expand Down
7 changes: 4 additions & 3 deletions workspace_tools/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
* NUCLEO_F446RE: (RX=PA_11, TX=PA_12)
* DISCO_F469NI: (RX=PB_8, TX=PB_9)
* DISCO_F4269ZI: (RX=PA_11, TX=PA_12)
* NUCLEO_F103RB: (RX=PA_11, TX=PA_12)
"""
TESTS = [
Expand Down Expand Up @@ -309,7 +310,7 @@
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE",
"DISCO_F469NI", "DISCO_F429ZI"],
"DISCO_F469NI", "DISCO_F429ZI", "NUCLEO_F103RB"],
},
{
"id": "MBED_BLINKY", "description": "Blinky",
Expand Down Expand Up @@ -583,7 +584,7 @@
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE", "DISCO_F469NI",
"DISCO_F429ZI"]
"DISCO_F429ZI", "NUCLEO_F103RB"]
},
{
"id": "MBED_30", "description": "CAN network test using interrupts",
Expand All @@ -592,7 +593,7 @@
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE", "DISCO_F469NI",
"DISCO_F429ZI"]
"DISCO_F429ZI", "NUCLEO_F103RB"]
},
{
"id": "MBED_31", "description": "PWM LED test",
Expand Down

0 comments on commit 6e77543

Please sign in to comment.