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

Add support for multichanne, CAN-FD, and STM32G4 #176

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
026d695
main: prepare initialization of CAN for multichannel
marckleinebudde Nov 16, 2022
07ed8d9
usbd_gs_can: USBD_GS_CAN_DataOut(): add jump label to ignore the just…
marckleinebudde Nov 21, 2022
562d765
usbd_gs_can: move list_from_host from USBD_GS_CAN_HandleTypeDef to ca…
marckleinebudde Nov 16, 2022
3e4883c
usbd_gs_can: move send_to_host() to usbd_gs_can.c and rename it to US…
marckleinebudde Nov 18, 2022
c23453b
usbd_gs_can: clean up send to host path
marckleinebudde Nov 19, 2022
d5bdf74
usbd_gs_can: USBD_GS_CAN_ReceiveFromHost(): remove some levels of ind…
marckleinebudde Nov 20, 2022
f46333f
usbd_gs_can: USBD_GS_CAN_ReceiveFromHost(): call USBD_GS_CAN_PrepareR…
marckleinebudde Nov 20, 2022
ff9c6aa
usbd_gs_can: USBD_GS_CAN_SendFrame(): call USBD_GS_CAN_Transmit() wit…
marckleinebudde Nov 20, 2022
4f3b7b4
main: move per channel CAN handling code out of main loop into separa…
marckleinebudde Nov 19, 2022
39d357f
can_common: remove some levels of indention
marckleinebudde Nov 22, 2022
bce7bc6
main: make CAN handling multichannel capable
marckleinebudde Nov 19, 2022
773c3c1
can: rename can_data_t hcan -> channel
marckleinebudde Nov 20, 2022
250dbb4
usbd_gs_can: import struct gs_host_frame from kernel and adopt code
marckleinebudde Nov 21, 2022
ee814fc
usbd_gs_can: add support for CAN-FD to USB path
marckleinebudde Nov 21, 2022
f072e17
can: move bxcan code into separate file
lichtfeind Dec 15, 2022
17c16c7
can: move assignment of rx_frame::channel and ::flags into bxcan
marckleinebudde Jan 19, 2023
fa984cb
can: CAN_HandleError(): assign channel
marckleinebudde Jan 29, 2023
e4c80a6
can_common: CAN_SendFrame(): add support for CAN-FD
ghent360 Jan 29, 2023
a0c6af1
usbd_gs_can: USBD_GS_CAN_GetCfgDesc(): add comment why the USBD_GS_CA…
marckleinebudde Dec 15, 2022
f61fd9b
usbd_gs_can: USBD_GS_CAN_SendFrame(): disable pad_pkts_to_max_pkt_siz…
marckleinebudde Dec 15, 2022
7bd5a1e
led: use uppercase for defines
marckleinebudde Nov 27, 2022
9bb97c9
can: move RX timestamp into CAN driver
marckleinebudde Jan 20, 2023
5059f75
can: can_enable: move the mode flags evaluation into the CAN drivers
marckleinebudde Jan 19, 2023
e538b5c
bxcan: move CAN_btconst to CAN driver
marckleinebudde Jan 28, 2023
9c2de3f
bxcan: can_set_bittiming(): evaluate gs_device_bittiming in CAN driver
marckleinebudde Jan 28, 2023
312ee77
can: can_check_bittiming(): introduce function to check bittiming
marckleinebudde Jan 28, 2023
6ae1c35
usbd_gs_can: add support for GS_USB_BREQ_DATA_BITTIMING and GS_USB_BR…
ghent360 Jan 19, 2023
84fbc7e
m_can: add the base code for M_CAN
ryedwards Nov 16, 2022
70d29ff
m_can: add support for Error State Indicator
marckleinebudde Jan 19, 2023
5b471aa
m_can: add RX timestamp support
marckleinebudde Jan 20, 2023
9009702
usbd_gs_can: add USB defines for SMT32G0
ryedwards Nov 16, 2022
4f615d3
budgetcan: only 1 channel for now
marckleinebudde Jan 16, 2023
6b10677
boards: add NUCLEO-G0B1RE
marckleinebudde Dec 16, 2022
50ec558
stm32g0b1: PLL setup: use 40 MHz CAN clock, 64 MHz CPU clock
marckleinebudde Dec 17, 2022
5cfd848
dfu: add support for STM32G0B1
marckleinebudde Feb 11, 2023
a0292ff
CMakeLists.txt: switch on STM32G0B1
marckleinebudde Dec 15, 2022
03c6f0d
board: legacy: introduce legacy boards and move CAN_INTERFACE to it
lichtfeind Jan 23, 2023
67addfb
board: legacy: add support for PHY power switching
lichtfeind Jan 23, 2023
66a413c
board: legacy: PHY power switching: add silent pin support
lichtfeind Jan 23, 2023
9dff8a1
board: legacy: legacy_phy_power_set: turn on silent mode during shutdown
marckleinebudde Jan 24, 2023
a8f54c0
board: legacy: add GPIO setup
lichtfeind Jan 23, 2023
ad18508
termination: pass can_data_t instead of only the channel number
marckleinebudde Jan 24, 2023
7c1e58e
board: legacy: add support for termination_set
lichtfeind Jan 23, 2023
df11cf4
boards: move stm32g0b1 and CONVERTDEVICE_xCANFD to board files
marckleinebudde Jan 24, 2023
823bfac
re-work the led config
ghent360 Feb 13, 2023
074e2c8
boards: move LED config from config.h -> board files
marckleinebudde Jun 9, 2023
ce3b543
board: convert struct LEDConfig::port from void * to GPIO_TypeDef *
marckleinebudde Jun 16, 2023
57119e6
device_g0: Add clock config for candleLightFD
lichtfeind Jul 20, 2023
07a618c
boards: add CandleLightFD
lichtfeind Jun 20, 2023
f7c56e6
gitignore: add .ccls-cache
marckleinebudde Jun 17, 2023
ffa1f26
Return untransmitted message back to transmit queue, rather than free…
pgreenland Jan 21, 2024
9d7cf13
Call high rather than low level init call from start, to fetch frame …
pgreenland Jan 21, 2024
2459695
Replace double for loop with single for loop.
pgreenland Jan 14, 2024
9e12d40
Get both tx and rx driven by USB interrupt.
pgreenland Jan 21, 2024
a8b19b1
Prevent error frames from being generated and discarded on each main …
pgreenland Jan 14, 2024
6567cdd
Correct build warning from F4.
pgreenland Jan 21, 2024
75d21a5
Add support for Makerbase Canable2_MKS STM32G4 based CAN FD interface.
pgreenland Jan 14, 2024
04df70e
Contain init to device specific files.
pgreenland Jan 14, 2024
cb4bd41
Add bus-off recovery for m_can.
pgreenland Jan 15, 2024
b4dd771
Remove SOF interrupt.
pgreenland Jan 21, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.ccls-cache/
/.idea/
/.vscode/
/Debug/
Expand Down
45 changes: 42 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_compile_options(
set(CPUFLAGS_F0 -mcpu=cortex-m0)
set(CPUFLAGS_F4 -mcpu=cortex-m4)
set(CPUFLAGS_G0 -mcpu=cortex-m0)
set(CPUFLAGS_G4 -mcpu=cortex-m4)

add_link_options(
--specs=nano.specs
Expand Down Expand Up @@ -65,7 +66,9 @@ set(
include/usbd_gs_can.h src/usbd_gs_can.c
src/usbd_conf.c

include/can.h src/can.c
include/board.h
include/can.h
include/can_common.h src/can_common.c
include/device.h
include/dfu.h src/dfu.c
include/gpio.h src/gpio.c
Expand Down Expand Up @@ -200,6 +203,15 @@ populate_ldscript(CPU_FAMILY STM32G0B1XK
HEAP_SIZE 1k
)

populate_ldscript(CPU_FAMILY STM32G431X8
FLASH_START 0x08000000
FLASH_SIZE 64k
RAM_START 0x20000000
RAM_SIZE 32k
STACK_SIZE 2k
HEAP_SIZE 1k
)

######### commands for adding each target have a lot in common: make helper func.
# Split into two categories, F042-based and F072-based.

Expand All @@ -217,6 +229,8 @@ function(add_f042_target TGTNAME)
add_target_common(${TGTNAME} STM32F042X6)
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F0)
target_sources(${TGTNAME}_fw PRIVATE "src/boards/legacy.c")
target_sources(${TGTNAME}_fw PRIVATE "src/can/bxcan.c")
target_sources(${TGTNAME}_fw PRIVATE "src/device/device_f0.c")
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F042x6 STM32_USB_Device_Library_STM32F042x6)
Expand All @@ -226,6 +240,8 @@ function(add_f072_target TGTNAME)
add_target_common(${TGTNAME} STM32F072XB)
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F0)
target_sources(${TGTNAME}_fw PRIVATE "src/boards/legacy.c")
target_sources(${TGTNAME}_fw PRIVATE "src/can/bxcan.c")
target_sources(${TGTNAME}_fw PRIVATE "src/device/device_f0.c")
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F072xB STM32_USB_Device_Library_STM32F072xB)
Expand All @@ -236,6 +252,8 @@ function(add_f407_target TGTNAME)
add_target_common(${TGTNAME} STM32F407XE)
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F4)
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F4})
target_sources(${TGTNAME}_fw PRIVATE "src/boards/legacy.c")
target_sources(${TGTNAME}_fw PRIVATE "src/can/bxcan.c")
target_sources(${TGTNAME}_fw PRIVATE "src/device/device_f4.c")
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F4})
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F407xE STM32_USB_Device_Library_STM32F407xE)
Expand All @@ -245,17 +263,31 @@ function(add_g0b1_target TGTNAME)
add_target_common(${TGTNAME} STM32G0B1XK)
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32G0)
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_G0})
target_sources(${TGTNAME}_fw PRIVATE "src/boards/g0b1-${TGTNAME}.c")
target_sources(${TGTNAME}_fw PRIVATE "src/can/m_can.c")
target_sources(${TGTNAME}_fw PRIVATE "src/device/device_g0.c")
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_G0})
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32G0B1xK STM32_USB_Device_Library_STM32G0B1xK)
endfunction()

function(add_g431_target TGTNAME)
add_target_common(${TGTNAME} STM32G431X8)
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32G4)
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_G4})
target_sources(${TGTNAME}_fw PRIVATE "src/boards/g431-${TGTNAME}.c")
target_sources(${TGTNAME}_fw PRIVATE "src/can/m_can.c")
target_sources(${TGTNAME}_fw PRIVATE "src/device/device_g4.c")
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_G4})
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32G431x8 STM32_USB_Device_Library_STM32G431x8)
endfunction()

########## generate list of targets.
# the "_fw" part is appended automatically
set(TGTF042_LIST "cantact" "canalyze" "canable" "usb2can" "cannette")
set(TGTF072_LIST "candleLight" "CANable_MKS" "CONVERTDEVICE_xCAN" "DSD_TECH_SH_C30A" "FYSETC_UCAN")
set(TGTF407_LIST "STM32F4_DevBoard")
set(TGTG0B1_LIST "budgetcan" "CONVERTDEVICE_xCANFD")
set(TGTG0B1_LIST "budgetcan" "CONVERTDEVICE_xCANFD" "nucleo_g0b1re" "candleLightFD")
set(TGTG431_LIST "CANable2_MKS")

foreach (TGTNAME IN LISTS TGTF042_LIST)
option(BUILD_${TGTNAME} "Build firmware for \"${TGTNAME}\" (default=yes)" ON)
Expand All @@ -279,12 +311,19 @@ foreach (TGTNAME IN LISTS TGTF407_LIST)
endforeach()

foreach (TGTNAME IN LISTS TGTG0B1_LIST)
option(BUILD_${TGTNAME} "Build firmware for \"${TGTNAME}\" (default=yes)" OFF)
option(BUILD_${TGTNAME} "Build firmware for \"${TGTNAME}\" (default=yes)" ON)
if (BUILD_${TGTNAME})
add_g0b1_target(${TGTNAME})
endif()
endforeach()

foreach (TGTNAME IN LISTS TGTG431_LIST)
option(BUILD_${TGTNAME} "Build firmware for \"${TGTNAME}\" (default=yes)" ON)
if (BUILD_${TGTNAME})
add_g431_target(${TGTNAME})
endif()
endforeach()

message("*******************")
message("You may now:\n\t-compile all targets ('make')\n\t-compile a single target (e.g. 'make cantact_fw'")
message("\t-flash a device (e.g. 'make flash-cantact_fw'")
55 changes: 55 additions & 0 deletions include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

/*

The MIT License (MIT)

Copyright (c) 2023 Pengutronix,
Jonas Martin <kernel@pengutronix.de>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/

#include "usbd_gs_can.h"

struct LEDConfig {
GPIO_TypeDef *port;
uint16_t pin;
bool active_high;
};

struct BoardChannelConfig {
#if defined(STM32G0) || defined(STM32G4)
FDCAN_GlobalTypeDef *interface;
#else
CAN_TypeDef *interface;
#endif
struct LEDConfig leds[LED_MAX];
};

struct BoardConfig {
void (*setup)(USBD_GS_CAN_HandleTypeDef *hcan);
void (*phy_power_set)(can_data_t *channel, bool enable);
void (*termination_set)(can_data_t *channel, enum gs_can_termination_state state);

struct BoardChannelConfig channels[NUM_CAN_CHANNEL];
};

extern const struct BoardConfig config;
72 changes: 58 additions & 14 deletions include/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,83 @@ THE SOFTWARE.
#include <stdint.h>
#include <stdbool.h>

#include "config.h"
#include "gs_usb.h"
#include "hal_include.h"
#include "led.h"
#include "list.h"

typedef struct {
#if defined(STM32G0) || defined(STM32G4)
FDCAN_HandleTypeDef channel;
#else
CAN_TypeDef *instance;
#endif
struct list_head list_from_host;
led_data_t leds;
uint32_t reg_esr_old;
uint32_t last_err;
uint16_t brp;
uint8_t phase_seg1;
uint8_t phase_seg2;
uint8_t sjw;
uint8_t nr;
} can_data_t;

void can_init(can_data_t *hcan, CAN_TypeDef *instance);
bool can_set_bittiming(can_data_t *hcan, uint16_t brp, uint8_t phase_seg1, uint8_t phase_seg2, uint8_t sjw);
void can_enable(can_data_t *hcan, bool loop_back, bool listen_only, bool one_shot);
void can_disable(can_data_t *hcan);
bool can_is_enabled(can_data_t *hcan);
extern const struct gs_device_bt_const CAN_btconst;
extern const struct gs_device_bt_const_extended CAN_btconst_ext;

bool can_receive(can_data_t *hcan, struct gs_host_frame *rx_frame);
bool can_is_rx_pending(can_data_t *hcan);
#if defined(STM32G0) || defined(STM32G4)
void can_init(can_data_t *channel, FDCAN_GlobalTypeDef *instance);
#else
void can_init(can_data_t *channel, CAN_TypeDef *instance);
#endif
void can_set_bittiming(can_data_t *channel, const struct gs_device_bittiming *timing);

bool can_send(can_data_t *hcan, struct gs_host_frame *frame);
#ifdef CONFIG_CANFD
void can_set_data_bittiming(can_data_t *channel, const struct gs_device_bittiming *timing);
#else
static inline bool can_set_data_bittiming(can_data_t *channel,
const struct gs_device_bittiming *timing)
{
(void)channel;
(void)timing;

/** return CAN->ESR register which contains tx/rx error counters and
return false;
}
#endif

void can_enable(can_data_t *channel, uint32_t mode);
void can_disable(can_data_t *channel);
bool can_is_enabled(can_data_t *channel);

bool can_receive(can_data_t *channel, struct gs_host_frame *rx_frame);
bool can_is_rx_pending(can_data_t *channel);

bool can_send(can_data_t *channel, struct gs_host_frame *frame);

/** return error status register which contains tx/rx error counters and
* LEC (last error code).
*/
uint32_t can_get_error_status(can_data_t *hcan);
uint32_t can_get_error_status(can_data_t *channel);

/** Manage controller bus-off recovery (if required)
* @param channel : Can channel to manage
* @param err : current channel error status
*/
void can_manage_bus_off_recovery(can_data_t *channel, uint32_t err);

/** Check if error status has changed, filtering the LEC field
* @param last_err : holds the contents of the error status register
* @param curr_err : holds the contents of the error status register
* @return true when status field has changed and should be parsed
*/
bool can_has_error_status_changed(uint32_t last_err, uint32_t curr_err);

/** parse status value returned by can_get_error_status().
* @param channel : Can channel status is associated with
* @param frame : will hold the generated error frame
* @param err : holds the contents of the ESR register
* @return 1 when status changes (if any) need a new error frame sent
* @param last_err : holds the contents of the error status register
* @param curr_err : holds the contents of the error status register
* @return true when status changes (if any) need a new error frame sent
*/
bool can_parse_error_status(can_data_t *hcan, struct gs_host_frame *frame, uint32_t err);
bool can_parse_error_status(can_data_t *channel, struct gs_host_frame *frame, uint32_t last_err, uint32_t curr_err);
37 changes: 37 additions & 0 deletions include/can_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*

The MIT License (MIT)

Copyright (c) 2016 Hubert Denkmair

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/

#pragma once

#include <stdint.h>

#include "can.h"
#include "usbd_gs_can.h"

int can_check_bittiming(const struct can_bittiming_const *btc, const struct gs_device_bittiming *timing);
void CAN_SendFrame(USBD_GS_CAN_HandleTypeDef *hcan, can_data_t *channel);
void CAN_ReceiveFrame(USBD_GS_CAN_HandleTypeDef *hcan, can_data_t *channel);
void CAN_HandleError(USBD_GS_CAN_HandleTypeDef *hcan, can_data_t *channel);
57 changes: 32 additions & 25 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ THE SOFTWARE.

#define TIM2_CLOCK_SPEED 64000000

#define CAN_INTERFACE FDCAN1
#define CAN_CLOCK_SPEED 64000000
#define CAN_CLOCK_SPEED 40000000
#define NUM_CAN_CHANNEL 1
#define CANFD_SUPPORT
#define CONFIG_CANFD 1

#define LEDRX_GPIO_Port GPIOA
#define LEDRX_Pin GPIO_PIN_0
Expand Down Expand Up @@ -332,34 +331,31 @@ THE SOFTWARE.

#define TIM2_CLOCK_SPEED 64000000

#define CAN_INTERFACE FDCAN1
#define CAN_INTERFACE2 FDCAN2
#define CAN_CLOCK_SPEED 64000000
#define CAN_CLOCK_SPEED 40000000
#define NUM_CAN_CHANNEL 2
#define CANFD_SUPPORT
#define CONFIG_CANFD 1

#define nCANSTBY_Port GPIOA
#define nCANSTBY_Pin GPIO_PIN_0 /* control xceiver standby, active low */
#define nCANSTBY_Active_High 0
#elif defined(BOARD_nucleo_g0b1re)
#define USBD_PRODUCT_STRING_FS (uint8_t *)"NUCLEO-G0B1RE gs_usb"
#define USBD_MANUFACTURER_STRING (uint8_t *)"STMicroelectronics"
#define DFU_INTERFACE_STRING_FS (uint8_t *)"NUCLEO-G0B1RE firmware upgrade interface"

#define LEDRX_GPIO_Port GPIOB
#define LEDRX_Pin GPIO_PIN_4
#define LEDRX_Mode GPIO_MODE_OUTPUT_PP
#define LEDRX_Active_High 1
#define TIM2_CLOCK_SPEED 64000000

#define LEDTX_GPIO_Port GPIOB
#define LEDTX_Pin GPIO_PIN_3
#define LEDTX_Mode GPIO_MODE_OUTPUT_PP
#define LEDTX_Active_High 1
#define CAN_CLOCK_SPEED 40000000
#define NUM_CAN_CHANNEL 2
#define CONFIG_CANFD 1

#define USB_GPIO_Port GPIOA
#define USB_Pin_DM GPIO_PIN_11
#define USB_Pin_DP GPIO_PIN_12
#elif defined(BOARD_candleLightFD)
#define USBD_PRODUCT_STRING_FS (uint8_t*) "candleLightFD gs_usb"
#define USBD_MANUFACTURER_STRING (uint8_t*) "candleLightFD"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "candleLightFD firmware upgrade interface"

#define TERM_GPIO_Port GPIOA
#define TERM_Pin GPIO_PIN_1
#define TERM_Mode GPIO_MODE_OUTPUT_PP
#define TERM_Active_High 1
#define TIM2_CLOCK_SPEED 64000000

#define CAN_CLOCK_SPEED 40000000
#define NUM_CAN_CHANNEL 1
#define CONFIG_CANFD 1

#elif defined(BOARD_STM32F4_DevBoard)
#define USBD_PRODUCT_STRING_FS (uint8_t*) "STM32F4VE Dev Board"
Expand Down Expand Up @@ -394,6 +390,17 @@ THE SOFTWARE.
#define TERM_Mode GPIO_MODE_OUTPUT_PP
#define TERM_Active_High 1

#elif defined(BOARD_CANable2_MKS)
#define USBD_PRODUCT_STRING_FS (uint8_t*) "CANable2-MKS gs_usb"
#define USBD_MANUFACTURER_STRING (uint8_t*) "CANable2-MKS"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "CANable2-MKS firmware upgrade interface"

#define TIM2_CLOCK_SPEED 160000000

#define CAN_CLOCK_SPEED 80000000
#define NUM_CAN_CHANNEL 1
#define CONFIG_CANFD 1

#else
#error please define BOARD
#endif
Loading