46 Commits

Author SHA1 Message Date
Ryan Edwards
4dad6a10d2 usbd_gs_can: add USB defines for SMT32G0 2024-06-06 09:56:12 +02:00
Marc Kleine-Budde
98b95a9baf include/*.h: uncrustify 2024-06-04 15:36:22 +02:00
Marc Kleine-Budde
34cbcf021c usbd_gs_can: add support for CAN-FD to USB path 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
f83fdd8371 usbd_gs_can: import struct gs_host_frame from kernel and adopt code 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
f418aa362c usbd_gs_can: clean up send to host path
The USBD_GS_CAN_SendToHost() function is used to send to struct
gs_host_frame_object to the host.

Until this patch, after the sending process has been started, the
outgoing frame object is already added to the list of free objects and
the variable USBD_GS_CAN_HandleTypeDef::TxState is used to track if
the transfer to the host is in progress.

Instead, hold the outgoing object in
USBD_GS_CAN_HandleTypeDef::to_host_buf and move it to the free list
after the transfer is finished in USBD_GS_CAN_DataIn(). Use this to
track if a transfer is ongoing.
2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
3e4883c74f usbd_gs_can: move send_to_host() to usbd_gs_can.c and rename it to USBD_GS_CAN_SendToHost()
Since USBD_GS_CAN_SendFrame() isn't used anymore outside of
usbd_gs_can.c, mark it as static.
2023-10-16 07:24:56 +02:00
Marc Kleine-Budde
562d765c3c usbd_gs_can: move list_from_host from USBD_GS_CAN_HandleTypeDef to can_data_t 2023-10-16 07:24:56 +02:00
Marc Kleine-Budde
3297e621a7 usbd_gs_can: move led_data_t into can_data_t 2023-10-16 07:24:56 +02:00
Marc Kleine-Budde
66f2f03d58 usbd_gs_can: USBD_GS_CAN_EP0_RxReady(): no need to copy hcan->ep0_buf to a locale variable
In GS_USB_BREQ_IDENTIFY and GS_USB_BREQ_SET_TERMINATION the received
data is copied to a locale variable. Remove this and cast
hcan->ep0_buf to the struct gs_identify_mode respectively struct
gs_identify_mode.

Mark USBD_GS_CAN_HandleTypeDef::ep0_buf as aligned, so that it can be
casted to others structs that then can be dereferenced without
problems.
2023-10-16 07:24:56 +02:00
Marc Kleine-Budde
1e2e7e226f usbd_gs_can: rename macro holding EP0 buffer size to avoid confusion
The size of the EP0 buffer is not related to the wMaxPacketSize of the
EP0. Rename to avoid confusion.
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
ea53735f4d usbd_gs_can: shrink CAN_CMD_PACKET_SIZE to minimal size
Since commit "usbd_gs_can: USBD_GS_CAN_Config_Request(): pass data
buffer to USBD_CtlSendData() directly" control frames from Device ->
Host are not copied to hcan->ep0_buf anymore. Shrink
CAN_CMD_PACKET_SIZE to minimal size.
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
fa7b91bcc5 usbd_gs_can: USBD_GS_CAN_Transmit(): mark as static 2023-10-13 08:24:14 +02:00
Marc Kleine-Budde
881f430c55 config: make NUM_CAN_CHANNEL a per board macro 2023-05-10 17:29:19 +02:00
Marc Kleine-Budde
35d6cb8941 queue: convert to Linux compatible list implementation
Convert from the queue implementation to a Linux compatible list
implementation. Get rid of This way we can avoid dynamic memory
allocation altogether.

As the struct gs_host_frame is not placed into the data segment,
requirements for the static memory grows. On the low end processors
the heap reserved in the linker file is too big, resulting in a linker
error. On STM32F042 and STM32F072 set a HEAP size of 0 bytes.
2022-11-24 10:24:36 +01:00
Marc Kleine-Budde
9e98f4b49a usbd_gs_can: move struct gs_host_frame msgbuf into USBD_GS_CAN_HandleTypeDef
Place the struct gs_host_frame msgbuf directly into
USBD_GS_CAN_HandleTypeDef. Get rid of another calloc().

This also requires a tweak to heap size in order to fit on the smaller
targets.
2022-11-17 13:41:13 -05:00
Marc Kleine-Budde
6123dbd115 usbd_gs_can: embed can_data_t in USBD_GS_CAN_HandleTypeDef
As USBD_GS_CAN_HandleTypeDef describes the whole device, place the
data structure describing the channels directly into it.
2022-11-17 13:20:19 -05:00
Marc Kleine-Budde
1c9f2e7384 usbd_gs_can: place USBD_GS_CAN_HandleTypeDef in BSS
Get rid of the first calloc().
2022-11-17 13:20:19 -05:00
Marc Kleine-Budde
e739f60960 usbd_gs_can: move USBD_GS_CAN_HandleTypeDef to header
Move USBD_GS_CAN_HandleTypeDef definition to header as a preparation
to place the USBD_GS_CAN_HandleTypeDef into the BSS in main.c
2022-11-17 13:20:19 -05:00
Marc Kleine-Budde
859b7e3717 usbd_gs_can: USBD_GS_CAN_PrepareReceive(): mark as static
USBD_GS_CAN_PrepareReceive() is only used in usbd_gs_can.c, remove
function prototype from usbd_gs_can.h, mark as static, and move in
front to avoid forward declaration.
2022-11-17 13:20:19 -05:00
Marc Kleine-Budde
e27abfe173 treewide: sort includes 2022-11-17 13:20:19 -05:00
Ryan Edwards
8a9cdf1076 config.h: move the CAN_INTERFACE and CAN_CLOCK_SPEED to the config.h
Move CAN_INTERFACE and CAN_CLOCK_SPEED to the config file as the CAN
clock can vary based on HW implementation.

Better to add it here than to keep adding defines into the
usbd_gs_can.h file.

CAN_INTERFACE can vary based on the number of channels you are using
so also makes sense to add here even though most chips use the same
interface ID.
2022-11-09 08:59:21 +01:00
fenugrec
f45060be53 rework some #include lines
with help from include-what-you-use (iwyu-tool). It's not quite clever
enough to understand our intent of including "hal_include.h" but still
offers good suggestions.
2022-10-12 17:28:50 -04:00
Daniel Trevitz
cfca364c2a Uncrustify the code 2022-10-11 19:27:57 -04:00
Marc Kleine-Budde
7860fef8fd USBD_GS_CAN_GetProtocolVersion(): remove unused function
Signed-off-by: Marc Kleine-Budde <mkl@blackshift.org>
2022-08-28 00:27:52 +02:00
Jeroen Hofstee
f1be957992 remove unused USBD_GS_CAN_GetPadPacketsToMaxPacketSize
commit 46b01339f5eeab1157d "Add new mode to pad output usb packets
to max packet size for better ..." introduced an unused function
USBD_GS_CAN_GetPadPacketsToMaxPacketSize, get rid of it.
2022-08-25 09:36:41 +02:00
mosu_195
5a90a192a1 Release resource on USB Resume callback
Needed for hcan->TxState to reset. In some cases when the host reboots, the TxState get locked forever and there's no way to recover other than resetting the controller.
2022-04-16 20:48:53 -04:00
fenugrec
1b1c3bb8ff usb RX_FIFO size: remove nonapplicable PMA comment
on F4 with the USB_OTG peripheral, the RX FIFO must be sized according
to different rules vs the USB_FS peripheral of the F0.
2022-01-06 17:42:50 -05:00
Ricky Lopez
d306798923 Add STM32F4 support
Specifically, the STM32F407VE.
Even more specifically, [this](https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0.html) dev board
2022-01-06 12:31:05 -05:00
Jeroen Hofstee
cd31acce28 use unix line endings
Some files have Windows line endings which is annoying, since pathes
won't apply, diffs looks ugly etc. So do convert the few files which
have Windows line endings to use Unix line endings as well.
2019-11-04 19:04:45 -05:00
Max Behensky
46b01339f5 Add new mode to pad output usb packets to max packet size for better WinUSB performance 2017-11-22 13:00:01 -08:00
Hubert Denkmair
f4f47116cd hardware timestamp support via mode 2016-05-13 21:59:31 +02:00
Hubert Denkmair
56192e76f6 implement hardware timestamps on bulk pipes 2016-05-04 21:14:33 +02:00
Hubert Denkmair
3f06d8b5cf USB DFU run-time support 2016-04-22 11:47:25 +02:00
Hubert Denkmair
6269866806 get rid of CAN_HAL data structure 2016-04-20 22:18:23 +02:00
Hubert Denkmair
5b35bc5bec add MS DeviceInterfaceGUIDs {c15b4308-04d3-11e6-b3ea-6057189e6443} 2016-04-17 22:24:28 +02:00
Hubert Denkmair
aa2537801b implement WCID Feature Descriptor 2016-04-17 17:00:38 +02:00
Hubert Denkmair
990c08cd2d add license info 2016-04-16 22:13:47 +02:00
Hubert Denkmair
d47a8b7c2a add led state & traffic indication 2016-04-15 13:56:37 +02:00
Hubert Denkmair
b3c89ee20b workaround usb bug, when bulk out packages are not received any more 2016-04-14 21:12:18 +02:00
Hubert Denkmair
b0d10b7369 cleanup 2016-04-10 11:29:13 +02:00
Hubert Denkmair
f5c4316e07 usb communication works (incl. echo) 2016-04-09 22:31:38 +02:00
Hubert Denkmair
b52e20ecb6 implement can settings 2016-04-08 22:57:28 +02:00
Hubert Denkmair
c729d1fe34 cleanup 2016-04-08 21:28:15 +02:00
Hubert Denkmair
70c41d0296 usb communication seems to work 2016-04-08 19:34:59 +02:00
Hubert Denkmair
5d44a5e026 respond to config requests 2016-04-08 10:52:40 +02:00
Hubert Denkmair
e3a2a26851 initial checkin 2016-04-08 10:52:20 +02:00