351 Commits

Author SHA1 Message Date
Marc Kleine-Budde
eab3d53d10 config: uncrustify 2024-06-04 20:55:17 +02:00
Marc Kleine-Budde
031ca1acd7 config: add "1" to CONFIG_CANFD define
This way uncrustify produces better indention.
2024-06-04 20:55:17 +02:00
Marc Kleine-Budde
beb27bdb92 config: remove comments about not connected silent pin
This way uncrustify produces better indention.
2024-06-04 20:55:17 +02:00
Marc Kleine-Budde
8fe56214b4 config: usb2can: remove unused LED3 and LED4 defines
Fixes: 89c44fe3f137 ("correct LED initialization for canable interfaces")
2024-06-04 20:55:14 +02:00
Marc Kleine-Budde
98b95a9baf include/*.h: uncrustify 2024-06-04 15:36:22 +02:00
Marc Kleine-Budde
c2a913c44c uncrustify: upgrade to 0.78.1_f 2024-06-04 15:33:29 +02:00
Sebastian Kuzminsky
7fb46a8b34 README: note that CANable-MKS 1.0 is supported, not 2.0
This clarification would have helped me avoid confusion leading to issue
180 <https://github.com/candle-usb/candleLight_fw/issues/180>
2024-05-22 09:16:52 -06:00
Sebastian Kuzminsky
8c63bcf98c README: fix markdown url markup, no content changes 2024-05-22 09:13:29 -06:00
Marc Kleine-Budde
b1e557b0cd bxcan: can_set_bittiming(): evaluate gs_device_bittiming in CAN driver 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
ad72111d65 bxcan: move CAN_btconst to CAN driver 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
206de0067a can: can_enable: move the mode flags evaluation into the CAN drivers
...having so many arguments doesn't scale.
2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
45424cf541 can: move RX timestamp into CAN driver 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
51e155073b led: use uppercase for defines 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
5a0b687bef usbd_gs_can: USBD_GS_CAN_SendFrame(): disable pad_pkts_to_max_pkt_size feature for CAN-FD frames 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
65c6eefc8b usbd_gs_can: USBD_GS_CAN_GetCfgDesc(): add comment why the USBD_GS_CAN_CfgDesc is copied to RAM 2024-01-30 11:48:52 +01:00
Venelin Efremov
fe0eef5e8f can_common: CAN_SendFrame(): add support for CAN-FD 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
d31be9d3e0 can: CAN_HandleError(): assign channel 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
3a9e42a242 can: move assignment of rx_frame::channel and ::flags into bxcan 2024-01-30 11:48:52 +01:00
Jonas Martin
067be8321a can: move bxcan code into separate file 2024-01-30 11:48:52 +01: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
84ec4d5501 can: rename can_data_t hcan -> channel
No functional change.
2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
fd1c0c8471 main: make CAN handling multichannel capable 2024-01-30 11:48:52 +01:00
Marc Kleine-Budde
7f037fc7d6 can_common: remove some levels of indention 2024-01-30 11:48:52 +01:00
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