Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e19c94d
gitignore: add LICENSE
marckleinebudde Jul 5, 2026
79dd53d
gitignore: cleanup and sort alphabetically
marckleinebudde May 23, 2026
92bf6ea
STM32_HAL: CMakeLists: add LICENSE
marckleinebudde Jul 4, 2026
e22bcdb
STM32_HAL: CMakeLists: INCLUDE_DIRS: remove not needed trailing /
marckleinebudde Mar 12, 2026
292715b
STM32_USB_Device_Library: CMakeLists: add LICENSE
marckleinebudde Jul 4, 2026
51a2572
STM32_USB_Device_Library: CMakeLists: fix indention
marckleinebudde Jul 4, 2026
ba33a5d
CMakeLists: CHECK_EXTRA_FILES: include .github/ subdir
marckleinebudde May 19, 2026
8ee4c93
CMakeLists: use find_program() to find dfu-util executable
marckleinebudde May 19, 2026
99e537b
CMakeLists: ADDITIONAL_CLEAN_FILES: add generated linker scripts
marckleinebudde May 18, 2026
87523b0
CMakeLists: CHECK_SOURCE_FILES: include hal_include.h and usbd_conf.h
marckleinebudde Jun 8, 2026
14454f7
usbd_conf: uncrustify
marckleinebudde Jul 4, 2026
d7dedfc
usbd_conf: use same license header in the whole project
marckleinebudde Jul 5, 2026
7c3e451
usbd_conf: USBD_LL_Init(): use GSUSB_ENDPOINT_{IN,OUT} instead of ope…
marckleinebudde Mar 19, 2026
1263ab9
src: replace: UNUSED -> __maybe_unused
marckleinebudde Mar 17, 2026
2368225
include: replace UNUSED() -> __maybe_unused
marckleinebudde Mar 17, 2026
6e0135a
src: rename u8 -> uint8_t
marckleinebudde Jul 4, 2026
2a46919
include: rename u8 -> uint8_t
marckleinebudde Jul 4, 2026
2aac112
usbd_gs_can: fix coding style
marckleinebudde Jul 4, 2026
a3e5464
usbd_gs_can: USBD_GS_CAN_EP0_RxReady(): remove not needed check for G…
marckleinebudde Mar 20, 2026
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
40 changes: 29 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
/.ccls-cache/
/.idea/
/.vscode/
/Debug/
/build/
*.asmo
*.bin
*.d
*.elf
*.launch
*.o
#
# The MIT License (MIT)
#
# Copyright (c) 2017 Max Behensky <maxb@twinlanes.com>
#
# 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.
#

*~
.cache/
.ccls-cache/
.cproject
.idea/
.project
.settings
.vscode/
Debug/
build*/
compile_commands.json
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
file(GLOB_RECURSE CHECK_SOURCE_FILES
"include/*.[ch]"
"src/*.[ch]"

"libs/STM32_HAL/config/hal_include.h"
"libs/STM32_USB_Device_Library/config/usbd_conf.h"
)

file(GLOB_RECURSE CHECK_EXTRA_FILES
".github/*"
"70-candle-usb.rules"
"LICENSE.md"
"README.md"
Expand Down Expand Up @@ -259,12 +263,12 @@ function(dfu_flash target)
)

add_custom_target(flash-${target}
dfu-util -a 0 -s 0x08000000:leave -D ${target}.dfu
${DFU_UTIL_EXECUTABLE} -a 0 -s 0x08000000:leave -D ${target}.dfu
DEPENDS ${target}.dfu
)
else()
add_custom_target(flash-${target}
dfu-util -d 1d50:606f -a 0 -s 0x08000000:leave -D ${target}.bin
${DFU_UTIL_EXECUTABLE} -d 1d50:606f -a 0 -s 0x08000000:leave -D ${target}.bin
DEPENDS ${target}.bin
)
endif()
Expand Down Expand Up @@ -367,7 +371,7 @@ function(add_target_common TGTNAME CPU_FAMILY)
)
target_link_options(${TGTNAME}_fw PRIVATE -T ${${CPU_FAMILY}_LINKER_SCRIPT} LINKER:-Map=${TGTNAME}_fw.map)
set_target_properties(${TGTNAME}_fw PROPERTIES
ADDITIONAL_CLEAN_FILES "${TGTNAME}_fw.map"
ADDITIONAL_CLEAN_FILES "${${CPU_FAMILY}_LINKER_SCRIPT};${TGTNAME}_fw.map"
)
make_bin_file(${TGTNAME}_fw)
dfu_flash(${TGTNAME}_fw)
Expand Down
10 changes: 9 additions & 1 deletion cmake/FindDFUSuffix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ find_program(DFU_SUFFIX_EXECUTABLE
DOC "dfu-suffix executable"
)

mark_as_advanced(DFU_SUFFIX_EXECUTABLE)
find_program(DFU_UTIL_EXECUTABLE
NAMES dfu-util
DOC "dfu-util executable"
)

mark_as_advanced(
DFU_SUFFIX_EXECUTABLE
DFU_UTIL_EXECUTABLE
)
10 changes: 4 additions & 6 deletions include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ static inline void board_phy_power_set(can_data_t *channel, bool enable)
}
#else
#define SET_PHY_POWER_FN(set_fn)
static inline void board_phy_power_set(can_data_t *channel, bool enable)
static inline void board_phy_power_set(can_data_t __maybe_unused *channel,
bool __maybe_unused enable)
{
UNUSED(channel);
UNUSED(enable);
}
#endif

Expand All @@ -76,9 +75,8 @@ static inline void board_termination_set(can_data_t *channel, enum gs_can_termin
}
#else
#define SET_TERMINATION_FN(set_fn)
static inline void board_termination_set(can_data_t *channel, enum gs_can_termination_state state)
static inline void board_termination_set(can_data_t __maybe_unused *channel,
enum gs_can_termination_state __maybe_unused state)
{
UNUSED(channel);
UNUSED(state);
}
#endif
11 changes: 3 additions & 8 deletions include/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,18 @@ void can_set_bittiming(can_data_t *channel, const struct gs_device_bittiming *ti
#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)
static inline bool can_set_data_bittiming(can_data_t __maybe_unused *channel,
const struct gs_device_bittiming __maybe_unused *timing)
{
(void)channel;
(void)timing;

return false;
}
#endif

#ifdef CONFIG_CAN_FILTER
void can_set_filter(can_data_t *channel, const struct gs_device_filter *filter);
#else
static inline void can_set_filter(can_data_t *channel, const struct gs_device_filter *filter)
static inline void can_set_filter(can_data_t __maybe_unused *channel, const struct gs_device_filter __maybe_unused *filter)
{
(void)channel;
(void)filter;
}
#endif

Expand Down
12 changes: 5 additions & 7 deletions include/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,28 @@ bool can_check_bittiming_ok(const struct can_bittiming_const *btc, const struct
#ifdef CONFIG_CAN_FILTER
bool can_check_filter_ok(const struct gs_device_filter *filter);
#else
static inline bool can_check_filter_ok(const struct gs_device_filter *filter)
static inline bool can_check_filter_ok(const struct gs_device_filter __maybe_unused *filter)
{
(void)filter;

return false;
}
#endif

#if (NUM_CAN_CHANNEL > 1)
static inline void can_channel_set_nr(can_data_t *channel, const u8 nr)
static inline void can_channel_set_nr(can_data_t *channel, const uint8_t nr)
{
channel->nr = nr;
}

static inline u8 can_channel_get_nr(const can_data_t *channel)
static inline uint8_t can_channel_get_nr(const can_data_t *channel)
{
return channel->nr;
}
#else
static inline void can_channel_set_nr(can_data_t __maybe_unused *channel, const u8 __maybe_unused nr)
static inline void can_channel_set_nr(can_data_t __maybe_unused *channel, const uint8_t __maybe_unused nr)
{
}

static inline u8 can_channel_get_nr(const can_data_t __maybe_unused *channel)
static inline uint8_t can_channel_get_nr(const can_data_t __maybe_unused *channel)
{
return 0;
}
Expand Down
7 changes: 2 additions & 5 deletions include/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ void set_term(can_data_t *channel, enum gs_can_termination_state state);
enum gs_can_termination_state get_term(can_data_t *channel);

#else
static inline void set_term(can_data_t *channel, enum gs_can_termination_state state)
static inline void set_term(can_data_t __maybe_unused *channel, enum gs_can_termination_state __maybe_unused state)
{
(void)channel;
(void)state;
}

static inline enum gs_can_termination_state get_term(can_data_t * channel)
static inline enum gs_can_termination_state get_term(can_data_t __maybe_unused *channel)
{
(void)channel;
return GS_CAN_TERMINATION_UNSUPPORTED;
}

Expand Down
4 changes: 2 additions & 2 deletions include/host_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "config.h"
#include "usbd_gs_can.h"

static inline u8
static inline uint8_t
gs_host_frame_object_get_channel_nr(const struct gs_host_frame_object *frame_object)
{
if (NUM_CAN_CHANNEL > 1)
Expand All @@ -42,7 +42,7 @@ static inline can_data_t *
gs_host_frame_object_get_channel(USBD_GS_CAN_HandleTypeDef *hcan,
const struct gs_host_frame_object *frame_object)
{
const u8 channel_nr = gs_host_frame_object_get_channel_nr(frame_object);
const uint8_t channel_nr = gs_host_frame_object_get_channel_nr(frame_object);

return &hcan->channels[channel_nr];
}
Expand Down
28 changes: 26 additions & 2 deletions libs/STM32_HAL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
#
# The MIT License (MIT)
#
# Copyright (c) 2019 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.
#

project(STM32_HAL)

set(STM32F0_HALDIR stm32f0xx-hal-driver)
Expand Down Expand Up @@ -176,10 +200,10 @@ set(STM32G0_SOURCES
)

set(INCLUDE_DIRS
include/
include
include/cmsis
include/cmsis/device
config/
config
)

add_library(STM32_HAL_STM32F042x6 STATIC ${STM32F0_SOURCES})
Expand Down
48 changes: 36 additions & 12 deletions libs/STM32_USB_Device_Library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
#
# The MIT License (MIT)
#
# Copyright (c) 2019 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.
#

project(STM32_USB_Device_Library)

set(SOURCES
Expand All @@ -16,21 +40,21 @@ set(INCLUDE_DIRS
)

add_library(STM32_USB_Device_Library_STM32F042x6 STATIC ${SOURCES})
target_include_directories(STM32_USB_Device_Library_STM32F042x6 PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32F042x6 PRIVATE ${CPUFLAGS_F0} -Wno-unused-parameter -DSTM32F0)
target_link_libraries(STM32_USB_Device_Library_STM32F042x6 PRIVATE STM32_HAL_STM32F042x6)
target_include_directories(STM32_USB_Device_Library_STM32F042x6 PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32F042x6 PRIVATE ${CPUFLAGS_F0} -Wno-unused-parameter -DSTM32F0)
target_link_libraries(STM32_USB_Device_Library_STM32F042x6 PRIVATE STM32_HAL_STM32F042x6)

add_library(STM32_USB_Device_Library_STM32F072xB STATIC ${SOURCES})
target_include_directories(STM32_USB_Device_Library_STM32F072xB PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32F072xB PRIVATE ${CPUFLAGS_F0} -Wno-unused-parameter -DSTM32F0)
target_link_libraries(STM32_USB_Device_Library_STM32F072xB PRIVATE STM32_HAL_STM32F072xB)
target_include_directories(STM32_USB_Device_Library_STM32F072xB PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32F072xB PRIVATE ${CPUFLAGS_F0} -Wno-unused-parameter -DSTM32F0)
target_link_libraries(STM32_USB_Device_Library_STM32F072xB PRIVATE STM32_HAL_STM32F072xB)

add_library(STM32_USB_Device_Library_STM32F407xE STATIC ${SOURCES})
target_include_directories(STM32_USB_Device_Library_STM32F407xE PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32F407xE PRIVATE ${CPUFLAGS_F4} -Wno-unused-parameter -DSTM32F4)
target_link_libraries(STM32_USB_Device_Library_STM32F407xE PRIVATE STM32_HAL_STM32F407xE)
target_include_directories(STM32_USB_Device_Library_STM32F407xE PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32F407xE PRIVATE ${CPUFLAGS_F4} -Wno-unused-parameter -DSTM32F4)
target_link_libraries(STM32_USB_Device_Library_STM32F407xE PRIVATE STM32_HAL_STM32F407xE)

add_library(STM32_USB_Device_Library_STM32G0B1xx STATIC ${SOURCES})
target_include_directories(STM32_USB_Device_Library_STM32G0B1xx PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32G0B1xx PRIVATE ${CPUFLAGS_G0} -Wno-unused-parameter -DSTM32G0)
target_link_libraries(STM32_USB_Device_Library_STM32G0B1xx PRIVATE STM32_HAL_STM32G0B1xx)
target_include_directories(STM32_USB_Device_Library_STM32G0B1xx PUBLIC ${INCLUDE_DIRS})
target_compile_options(STM32_USB_Device_Library_STM32G0B1xx PRIVATE ${CPUFLAGS_G0} -Wno-unused-parameter -DSTM32G0)
target_link_libraries(STM32_USB_Device_Library_STM32G0B1xx PRIVATE STM32_HAL_STM32G0B1xx)
57 changes: 28 additions & 29 deletions libs/STM32_USB_Device_Library/config/usbd_conf.h
Original file line number Diff line number Diff line change
@@ -1,38 +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.

*/
* 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 "hal_include.h"

#define USBD_MAX_NUM_INTERFACES 1
#define USBD_MAX_NUM_CONFIGURATION 1
#define USBD_DESC_BUF_SIZE 192
#define USBD_MAX_NUM_INTERFACES 1
#define USBD_MAX_NUM_CONFIGURATION 1
#define USBD_DESC_BUF_SIZE 192
#define USBD_SUPPORT_USER_STRING_DESC 1
#define USBD_SELF_POWERED 0
#define DEVICE_FS 0
#define USBD_SELF_POWERED 0
#define DEVICE_FS 0

#define USBD_ErrLog(...)
Loading
Loading