[NUCLEO_F103RB] Added CAN support

Added CAN API support for NUCLEO_F103RB target.

Change-Id: Ib5dac8023917afef683ba0703d732bbf53efdcd9
pull/1772/head
Bartosz Szczepanski 2016-04-21 14:58:40 +02:00
parent 8b44c0d54b
commit 6e77543313
8 changed files with 33 additions and 9 deletions

View File

@ -67,6 +67,10 @@ typedef enum {
PWM_4 = (int)TIM4_BASE
} PWMName;
typedef enum {
CAN_1 = (int)CAN1_BASE
} CANName;
#ifdef __cplusplus
}
#endif

View File

@ -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}
};

View File

@ -41,6 +41,8 @@
#define DEVICE_CAN 1
//=======================================
#define DEVICE_ID_LENGTH 24

View File

@ -96,6 +96,11 @@ struct pwmout_s {
uint32_t pulse;
};
struct can_s {
CANName can;
int index;
};
#include "gpio_object.h"
#ifdef __cplusplus

View File

@ -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);
@ -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);

View File

@ -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);
@ -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");
@ -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) {

View File

@ -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);

View File

@ -101,6 +101,7 @@ Wiring:
* 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 = [
@ -309,7 +310,7 @@ TESTS = [
"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",
@ -583,7 +584,7 @@ TESTS = [
"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",
@ -592,7 +593,7 @@ TESTS = [
"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",