Hello
I am trying to interface the portenta h7 and breakout board with spi devices.. but I am not able to connect to them as expected..
How do I define the cs and Int pins when using the arduino ide?
The device is the longan labs canfd shield… I need to connect four of these to the portenta ..
The setup works well on a uno if I try a send example.. but won’t compile on the mbed board.
I am getting a compilation error when I use this code:
/*
MCP2517/8 send a CAN frame
CAN Bus baudrare for CAN2.0 as below,
CAN20_5KBPS
CAN20_10KBPS
CAN20_20KBPS
CAN20_25KBPS
CAN20_31K25BPS
CAN20_33KBPS
CAN20_40KBPS
CAN20_50KBPS
CAN20_80KBPS
CAN20_83K3BPS
CAN20_95KBPS
CAN20_100KBPS
CAN20_125KBPS
CAN20_200KBPS
CAN20_250KBPS
CAN20_500KBPS
CAN20_666KBPS
CAN20_800KBPS
CAN20_1000KBPS
CAN FD Shield - https://www.longan-labs.cc/1030012.html
CANBed FD - https://www.longan-labs.cc/1030009.html
*/
#include <SPI.h>
#include "mcp2518fd_can.h"
// pins for CAN-FD Shield
//const int SPI_CS_PIN = 9;
//const int CAN_INT_PIN = 2;
// pins for CANBed FD
const int PIN_SPI_SS = 7;
// const int CAN_INT_PIN = 7;
mcp2518fd CAN(PIN_SPI_SS); // Set CS pin
void setup() {
Serial.begin(115200);
while(!Serial);
while (CAN_OK != CAN.begin(CAN20_500KBPS)) { // init can bus : baudrate = 500k
Serial.println("CAN init fail, retry...");
delay(100);
}
Serial.println("CAN init ok!");
}
unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop() {
CAN.sendMsgBuf(0x01, 0, 8, stmp); // send a standard frame to id 0x01
delay(10);
CAN.sendMsgBuf(0x04, 1, 8, stmp); // send a extended frame to id 0x04
delay(100); // send data per 100ms
Serial.println("CAN BUS sendMsgBuf ok!");
}
// END FILE
Error:
In file included from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/stm32h7xx_hal_conf.h:402:0,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal.h:30,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7xx.h:223,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/cmsis.h:22,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/PinNamesTypes.h:33,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/variants/PORTENTA_H7_M7/pinmode_arduino.h:24,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/Arduino.h:26,
from /private/var/folders/1k/nvt5g3fn39lg04gqml_9csmh0000gn/T/arduino/sketches/CFE45A8F9137959CB84700EA2A10C3AF/sketch/CAN20_SEND.ino.cpp:1:
/Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_gpio.h:86:36: error: expected identifier before '(' token
#define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */
^
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:663:16: note: in expansion of macro 'GPIO_PIN_0'
typedef enum { GPIO_PIN_0, GPIO_PIN_1 } GPIO_PIN_POS;
^
/Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_gpio.h:86:36: error: expected '}' before '(' token
#define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */
^
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:663:16: note: in expansion of macro 'GPIO_PIN_0'
typedef enum { GPIO_PIN_0, GPIO_PIN_1 } GPIO_PIN_POS;
^
/Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_gpio.h:86:47: error: expected ')' before numeric constant
#define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */
^
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:663:16: note: in expansion of macro 'GPIO_PIN_0'
typedef enum { GPIO_PIN_0, GPIO_PIN_1 } GPIO_PIN_POS;
^
In file included from /Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can.h:6:0,
from /private/var/folders/1k/nvt5g3fn39lg04gqml_9csmh0000gn/T/.arduinoIDE-unsaved202515-48523-6l12ni.2xsp/CAN20_SEND/CAN20_SEND.ino:31:
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:663:41: error: 'GPIO_PIN_POS' does not name a type; did you mean 'GPIO_PIN_SET'?
typedef enum { GPIO_PIN_0, GPIO_PIN_1 } GPIO_PIN_POS;
^~~~~~~~~~~~
GPIO_PIN_SET
In file included from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7xx.h:136:0,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/cmsis.h:22,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/PinNamesTypes.h:33,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/variants/PORTENTA_H7_M7/pinmode_arduino.h:24,
from /Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/Arduino.h:26,
from /private/var/folders/1k/nvt5g3fn39lg04gqml_9csmh0000gn/T/arduino/sketches/CFE45A8F9137959CB84700EA2A10C3AF/sketch/CAN20_SEND.ino.cpp:1:
/Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h747xx.h:2698:43: error: expected ')' before '*' token
#define CRC ((CRC_TypeDef *) CRC_BASE)
^
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:1487:14: note: in expansion of macro 'CRC'
uint32_t CRC : 16;
^
/Users/user/Library/Arduino15/packages/arduino/hardware/mbed_portenta/4.2.1/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h747xx.h:2698:43: error: expected ')' before '*' token
#define CRC ((CRC_TypeDef *) CRC_BASE)
^
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:1487:14: note: in expansion of macro 'CRC'
uint32_t CRC : 16;
^
In file included from /Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can.h:6:0,
from /private/var/folders/1k/nvt5g3fn39lg04gqml_9csmh0000gn/T/.arduinoIDE-unsaved202515-48523-6l12ni.2xsp/CAN20_SEND/CAN20_SEND.ino:31:
/Users/user/Documents/Arduino/libraries/Longan_CANFD/src/mcp2518fd_can_dfs.h:1590:1: error: expected declaration before '}' token
}
^
exit status 1
Compilation error: exit status 1
