69 Commits

Author SHA1 Message Date
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
Marc Kleine-Budde
b549cb768b gs_usb.h: document GS_CAN_FEATURE_BT_CONST_EXT and GS_USB_BREQ_BT_CONST_EXT
Some CAN-FD capable controllers have different bittiming constants for
arbitration phase and data phase to reach maximum performance at
higher speeds.
2022-01-12 09:21:30 -05:00
Marc Kleine-Budde
fea8b8603f gs_usb.h: document GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX
The documents a workaround for a NXP chip errata on LPC546xx
controllers (Errata sheet LPC546xx / USB.15).

According to the document corruption can occur when the following
conditions are met:
* A TX (IN) transfer happens after a RX (OUT) transfer.
* The RX (OUT) transfer length is 4 + N * 16 (N >= 0) bytes.

Even though the struct gs_host_frame has a size of 76 bytes for a FD
frame, which does not apply to the above rule, corruption could be
seen.

Adding a dummy byte to break the second condition also on transfer
lengths with 4 + N * 8 bytes reliably circumvents USB transfer data
corruption.

The firmware can now request this quirk by setting
GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX.
2022-01-12 09:21:30 -05:00
Marc Kleine-Budde
41f9e7d64f gs_usb.h: introduce CAN-FD support
The CANtact FD and other devices implement a gs-usb compatible USB
protocol. The protocol has been extended to support CAN-FD and the
changes on the Linux gs_usb driver will be mainlined soon.

This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_*,
GS_USB_BREQ_DATA_BITTIMING, and GS_CAN_FLAG_* bits as well as struct
gs_host_frame_canfd to the candlelight driver.

This is mainly for documentation purpose, as the STM32F042 and
STM32F072 don't support CAN-FD. But there are some ports to CAN-FD
capable STM32 µC that can make use of these definitions.

[1] https://github.com/linklayer/gs_usb_fd/issues/2
2022-01-12 09:21:30 -05:00
Marc Kleine-Budde
335dc50cd6 gs_usb.h: document used GS_CAN_MODE_* bits
The bits in GS_CAN_MODE_ correspond to the bits in GS_CAN_FEATURE_*.
This means the bits 5 and 6 of GS_CAN_MODE_ are not "free", document
this by adding a comment to the corresponding GS_CAN_FEATURE_*.
2022-01-12 09:21:30 -05:00
fenugrec
2df0d420e9 Simplify BOARD_XYZ macros (no more numeric values)
There is currently no reason to assign a numeric value to each BOARD_*
macro.
Fix #83 GH
2022-01-06 17:54:49 -05:00
fenugrec
f58de5e678 config.h : document CAN_S_PIN for silent mode
fix GH #81
2022-01-06 17:48:15 -05: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
fenugrec
d66fda39f8 Add git version string to USB config descriptor
There was already provisions for this in the code. Tweaked CMake to
generate version.h automatically every build.
2021-04-06 12:03:13 -04:00
fenugrec
138e6cb433 Add basic assert checks
Avoid using <assert.h> because the standard assert() pulls in
fprintf and its of dependencies, as well as including __FILE__:__LINE__
strings for each assert() call. All this has an unacceptable memory
cost, as well as being useless since there is nothing to printf *to*.

Currently assert_basic() was added to check calloc() return values;
in case of failure we simply halt the core with BKPT(0). This could be
improved and refined.
2021-02-17 16:00:09 -05:00
fenugrec
3d52db0a97 Add PR #63 comment, and __ISB() after disable_irq 2020-12-13 10:38:29 -05:00
Hubert Denkmair
b796282765 move USB descriptor callback table to ROM 2020-12-06 12:51:46 -05:00
Hubert Denkmair
f380b5eafd rename USBD_StrDesc to USBD_DescBuf
(will reuse not only for strings)
2020-12-06 12:51:46 -05:00
Hubert Denkmair
b5cc61b331 fix critical section handling
thanks to @ndushman for pointing this out
2020-12-06 12:51:46 -05:00
fenugrec
7f9a0ea331 CAN errors : comment some funcs + defines 2020-12-06 11:58:45 -05:00
Brian Silverman
ceeac236c4 Better bit error reporting
It reports more information with more accurate ordering with respect to
other frames sent and received.

Fixes candle-usb/candleLight_fw#59
2020-12-06 11:41:53 -05:00
fenugrec
9cf7eccf3d Add new boardtype : cannette
F042-based, galvanically isolated.
2020-10-30 21:55:27 -04:00
Ethan Zonca
465e957db9 Update CANable-specific LED initialization 2020-10-30 21:50:08 -04:00
fenugrec
4dac861b8c Set explicit LED polarity and invert canalyze
the canalyze has active-high LED signals
2019-11-11 16:21:15 -05:00
Brandon Ros
faa164055a CANAlyze support 2019-11-09 14:26:45 -05:00
nexulm
89c44fe3f1 correct LED initialization for canable interfaces 2019-11-04 19:14:58 -05:00
Jeroen Hofstee
7618128cf6 fix whitespace
The project uses tabs with a length of 4 spaces, and spaces for
continuation, so lets use that for the whole project. There are
many trailing whitespaces and empty lines here and there; get
rid of them as well.
2019-11-04 19:04:54 -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
fenugrec
0434e8eeec LED functions : support GPIO pins >= 8
this requires a uint16 to save the pin #
2019-11-04 18:56:35 -05:00
Hubert Denkmair
23ebdb8a78 convert to cmake 2019-10-26 16:53:43 +02: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
Florian Larysch
ea462f7251 usbd_desc: use device unique ID as serial number
Instead of hardcoding the serial number in the firmware, use the
device's manufacturer-provided UID as the serial number.

This makes it easier to distinguish between multiple adaptors plugged
into the same host without having to build a separate firmware for each
one.
2017-08-28 01:27:34 +02:00
Florian Larysch
7a011f5f0d util: add integer to hex formatting 2017-08-28 01:27:34 +02:00
Hubert Denkmair
2ebc665109 adapt to stm32f042 for candleZero 2017-05-12 23:31:39 +02:00
Hubert Denkmair
1453d70dc9 really implement write user_id to flash 2016-06-11 18:36:59 +02:00
Hubert Denkmair
37980fb2eb dummy implement user_id feature 2016-06-11 10:21:29 +02:00
Hubert Denkmair
6450f08b22 implement identify command 2016-06-03 15:02:24 +02:00
Hubert Denkmair
44431f4a43 use new feature bit and control request numbers for hardware timestamps 2016-05-14 21:49:56 +02: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
38512d1a11 implement timestamp usb control requests 2016-05-04 20:52:12 +02:00
Hubert Denkmair
e0e9e77225 prepare hardware timestamps: add a 100kHz timer 2016-05-02 21:55:26 +02:00
Hubert Denkmair
8a1a8d1f7d add WCID descriptor for DFU interface 2016-04-30 21:25:18 +02:00
Hubert Denkmair
3f06d8b5cf USB DFU run-time support 2016-04-22 11:47:25 +02:00
Hubert Denkmair
51b62b4559 prepare to implement DFU detach request 2016-04-22 01:03:54 +02:00
Hubert Denkmair
6269866806 get rid of CAN_HAL data structure 2016-04-20 22:18:23 +02:00
Hubert Denkmair
a02ec96b24 rewrote can functions to remove CAN_HAL calls and allow for peripheral reset during can_enable() 2016-04-19 21:44:44 +02:00
Hubert Denkmair
5b35bc5bec add MS DeviceInterfaceGUIDs {c15b4308-04d3-11e6-b3ea-6057189e6443} 2016-04-17 22:24:28 +02:00
Hubert Denkmair
8e048c6459 cleanup: remove auto-generated code 2016-04-17 19:42:55 +02:00
Hubert Denkmair
3bbe51725c cleanup: move auto-generated init functions to corresponding files 2016-04-17 19:40:05 +02:00
Hubert Denkmair
363341b129 remove unused header file 2016-04-17 17:39:31 +02:00
Hubert Denkmair
4cba340cc6 indent fix 2016-04-17 17:36:50 +02:00
Hubert Denkmair
bedf80fabb rewrite auto-generated header file 2016-04-17 17:34:51 +02:00
Hubert Denkmair
aa2537801b implement WCID Feature Descriptor 2016-04-17 17:00:38 +02:00