Marc Kleine-Budde
78bafcf07b
main: move per channel CAN handling code out of main loop into separate functions
...
No functional change intended.
2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
844e6c31f4
usbd_gs_can: USBD_GS_CAN_SendFrame(): call USBD_GS_CAN_Transmit() with IRQs enabled
2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
7fba5612ae
usbd_gs_can: USBD_GS_CAN_ReceiveFromHost(): call USBD_GS_CAN_PrepareReceive() with IRQs enabled
2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
66a29998de
usbd_gs_can: USBD_GS_CAN_ReceiveFromHost(): remove some levels of indention
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
98ddbe33da
README: remove trailing whitespace
2024-01-24 10:46:19 -05:00
Marc Kleine-Budde
e1d078cb5a
README: add limitations section regarding STM32G0B1-based devices
2024-01-24 10:46:19 -05:00
fiurin
9eaafecdd4
README: add link to candleLight FD
...
There's also a candlLight version for CAN FD available.
2024-01-24 10:46:19 -05: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
07ed8d9966
usbd_gs_can: USBD_GS_CAN_DataOut(): add jump label to ignore the just received USB frame
...
This is a preparation patch, this label will be used several times in
the next patches.
2023-10-16 07:24:56 +02:00
Marc Kleine-Budde
026d695f2f
main: prepare initialization of CAN for multichannel
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
35fb74228b
compiler.h: add some min() and max() macros
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
7d23053caa
usbd_gs_can: USBD_GS_CAN_Config_Request(): pass data buffer to USBD_CtlSendData() directly
...
Do not copy the control data to the intermediate buffer hcan->ep0_buf,
but directly pass the pointer to the data to USBD_CtlSendData().
Some data is located in the ROM (USBD_GS_CAN_btconst,
USBD_GS_CAN_dconf) while other is located in BSS or stack.
Tested on STM32F072.
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
3d98b33f15
usbd_gs_can: USBD_GS_CAN_Config_Request(): check size
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
d678d47915
usbd_gs_can: USBD_GS_CAN_EP0_RxReady(): make use of USBD_GS_CAN_GetChannel()
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
61d366e7a4
usbd_gs_can: USBD_GS_CAN_Config_Request(): introduce USBD_GS_CAN_GetChannel() and make use of it
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
4dcd1c7319
usbd_gs_can: USBD_GS_CAN_EP0_RxReady(): limit scope of timing and mode
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
548bb6de6f
usbd_gs_can: USBD_GS_CAN_Config_Request(): make use of fallthrough
2023-10-15 19:03:14 +02:00
Marc Kleine-Budde
66aa53873f
usbd_gs_can: USBD_GS_CAN_Config_Request(), USBD_GS_CAN_Config_Request(): sort switch statements
...
In USBD_GS_CAN_Config_Request(), sort the switch statement by
GS_USB_BREQ vlaue as much as possible, but don't duplicate code.
First place the "Host -> Device" calls which use USBD_CtlPrepareRx().
Followed by the "Device -> Host" calls which are using
USBD_CtlSendData().
For USBD_GS_CAN_EP0_RxReady(), simply sort by GS_USB_BREQ value.
2023-10-15 19:02:44 +02:00
Marc Kleine-Budde
1c1cd11ac0
usbd_gs_can: bring callback functions into same order as assigned in USBD_ClassTypeDef USBD_GS_CAN
...
No functional change intended.
2023-10-13 08:24:14 +02:00
Marc Kleine-Budde
6fa452a310
usbd_gs_can: move init of USBD_ClassTypeDef USBD_GS_CAN to end
...
This avoids the forward declarations. No functional change intended.
2023-10-13 08:24: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
5b9c788ac6
main: can_parse_error_status(): move last_err into can_data_t
...
This is a preparation patch to support more then 1 channel.
2023-10-13 08:24:14 +02:00
Marc Kleine-Budde
226afd795d
usbd_gs_can: USBD_GS_CAN_SuspendCallback(): use ARRAY_SIZE(hcan->channels) instead of NUM_CAN_CHANNEL
2023-10-13 08:24:14 +02:00
Marc Kleine-Budde
85c92ee306
usbd_gs_can: USBD_GS_CAN_SuspendCallback(): remove not needed null pointer check for hcan
...
In main() the USBD_GS_CAN_Init() is called (which assigns
pdev->pClassData), before the USB is started. Remove not needed null
pointer check in USBD_GS_CAN_SuspendCallback().
2023-10-13 08:24:14 +02:00
Marc Kleine-Budde
1c386e89ce
compiler.h: add fallthrough
...
Import from FreeBSD.
2023-10-13 08:21:26 +02:00
Marc Kleine-Budde
26134e6a7e
compiler.h: add IS_ENABLED
...
Import from zephyr
2023-07-19 10:39:37 +02:00
Marc Kleine-Budde
0207095915
compiler.h: add DECLARE_FLEX_ARRAY and struct_size
...
Import from FreeBSD.
2023-05-10 17:29:19 +02:00
Marc Kleine-Budde
6af7be218a
treewide: sort includes
2023-05-10 17:29:19 +02:00
Venelin Efremov
7a4fcc16e8
usbd_gs_can: use NUM_CAN_CHANNEL to set USBD_GS_CAN_dconf::icount
...
...instead of hard coding 1 channel.
2023-05-10 17:29:19 +02:00
Marc Kleine-Budde
23f43f17e3
usbd_gs_can: use C99 initializers for USBD_GS_CAN_dconf and USBD_GS_CAN_btconst
2023-05-10 17:29:19 +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
5109196811
config: make CAN_QUEUE_SIZE depend on number of CAN channels
2023-05-10 17:29:19 +02:00
Marc Kleine-Budde
3b04c3f9e6
usbd_desc: remove unused and unreferenced USBD_FS_USRStringDesc
2023-05-10 17:29:18 +02:00
Marc Kleine-Budde
ab292f22e7
gpio: GPIO_INIT_STATE: use lower case for macro argument
2023-05-10 17:29:18 +02:00
Marc Kleine-Budde
dc1664779f
config: convertdevice xCANFD: remove unused CANFDIF_GPIO_Port, CANFDIFRX_Pin, CANFDIFTX_Pin
2023-05-10 17:29:18 +02:00
Marc Kleine-Budde
4cd86590d6
timer: run at 1 MHz for all clock speeds
...
The TIM2 timer is expected to run at 1 MHz, but it's clocked by the
CPU clock. The current code expects the CPU runs with 48 MHz.
Introduce TIM2_CLOCK_SPEED and calculate a proper divider.
2023-05-10 17:29:18 +02:00
Marc Kleine-Budde
cee17f3d0d
gcc-arm-none-eabi-8-2019-q3-update: remove trailing whitespace
2023-05-10 16:19:50 +02:00
Marc Kleine-Budde
3bbb594467
gs_usb.h: fix typo in GS_CAN_FEATURE_BERR_REPORTING
...
Fixes: ad2f13ace724 ("gs_usb.h: document GS_CAN_MODE_BERR_REPORTING")
2023-05-10 16:19:50 +02:00
Andras Gemes
ac71cb4126
CI: replace set-output
2023-04-25 22:06:14 +02:00
Andras Gemes
8d531f4afc
README: fix some typos
2023-04-22 10:58:24 -04:00
Andras Gemes
49eb5da92a
gitignore: add .idea/ to ignored files
2023-04-22 10:57:49 -04:00
Andras Gemes
ff6eb19b10
README: fix broken CANtact links
2023-04-22 16:18:25 +02:00
ConvertDevice
4dc288d174
feat: add convertdevice xCANFD config info
2023-04-22 09:27:07 -04:00
Chris Wilson
4d7abdf9fd
Add support for additional F072 boards
...
- DSD TECH SH-C30A: https://www.deshide.com/product-details.html?pid=384242&_t=1671089557
- FYSETC UCAN: https://www.fysetc.com/products/fysetc-ucan-board-based-on-stm32f072-usb-to-can-adapter-support-with-canable-candlelight-klipper-firmware
2023-04-19 22:16:22 -07:00