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.
In commit
40e1997d45
[1] GS_CAN_FEATURE_GET_STATE has been added to the Linux driver.
Document this bit here accordingly.
The new feature ("GS_CAN_FEATURE_GET_STATE") indicates that the state
of the CAN controller can be queried with the new
GS_USB_BREQ_GET_STATE control message.
[1] https://git.kernel.org/torvalds/c/40e1997d4551e6053fc2f61959628da474775dc5
In commit
1f1835264d
[1] Bus Error Reporting has been added to the Linux driver. Document
this bit here accordingly.
The new feature ("GS_CAN_FEATURE_BERR_REPORTING") indicates that the
bus error reporting in the CAN controller can switched on and off with
the GS_CAN_MODE_BERR_REPORTING mode bit in the GS_USB_BREQ_MODE
control message.
[1] https://git.kernel.org/torvalds/c/1f1835264d81da03fcd05646542a622678b379d6
The GS_USB_BREQ_HOST_FORMAT has never been supported by the
candleLight firmware, and since Linux v5.10 the gs_usb driver works on
Big Endian Linux systems, too.
So remove host_config handling from the firmware. This saves some
bytes:
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16 (-16)
| Function old new delta
| USBD_GS_CAN_EP0_RxReady 640 624 -16
| Total: Before=17382, After=17366, chg -0.09%
Check the code formatting of a PR by looking up the files in git diff HEAD^
If the uncrustify config sees a change, yell about it.
Signed-off-by: Daniel Trevitz <daniel.trevitz@wika.com>
The gusb-interface can report completely weird error-frames,
like being in error-ative (based on counters), and error-warning,
and bus-off at the same time.
To fix this:
- only send state changes once.
- don't send LEC / err counters in bus-off (invalid anyway).
- don't send empty error frames.
Since all bit errors already trigger sending a error msg,
remove the code triggering on counters going upwards, since they
are send anyway. See [1] "This if statement doesn't normally do
anything", get rid of it.
[1] https://github.com/candle-usb/candleLight_fw/pull/61
Add a USB message which controls a GPIO for a specified CAN bus.
The GPIO activates a SSR to connect a 120Ohm terminating resistor
to the specified CAN bus.
Signed-off-by: Daniel Trevitz <daniel.trevitz@wika.com>
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.
This saves a few bytes:
before:
| create and sign dfu bin file: candleLight_fw
| text data bss dec hex filename
| 15708 192 1976 17876 45d4 candleLight_fw
after:
| create and sign dfu bin file: candleLight_fw
| text data bss dec hex filename
| 15712 184 1976 17872 45d0 candleLight_fw
Signed-off-by: Marc Kleine-Budde <mkl@blackshift.org>
Make sure the CAN-bus state and associated error counters are
also reset in can_enable.
Writing to the ESR won't help, only the LEC field is writable, the rest
is read-only. The only reported way to make that work is by issuing an
RCC reset.
In addition, socketcan requires the CAN interface to be in active-error
state after open.
Use tabs for leading whitespace and spaces for continuation lines.
Besides that inconsistent whitespace looks odd, it causes unnecessary
merge conflicts.
commit 46b01339f5eeab1157d "Add new mode to pad output usb packets
to max packet size for better ..." introduced the never used global
variable received_count, so get rid of it again.
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.
Functions in c which are declared as f() accept any argument. Declare
them as f(void) instead to declare that no arguments are allowed and
add uint32_t sysmem_base to dfu_jump_to_bootloader.
Since commit b5cc61b3317e "fix critical section handling", there are two
versions of enable_irq, enable_irq(void) as used by queue.c and
enable_irq(int primask) as used by usbd_gs_can.c. As a consequence
interrupts might be re-enabled too early in case of nested disable calls.
To prevent this, declared enable_irq as void, since it doesn't accept an
argument and add restore_irq which requires an argument and adjust users
of it.
The "install toolchain" step is very slow, and needed to run for each
target part of the build matrix. There is no obvious way to "cache" the
runner environment just before running cmake. Uploading artifacts
separately may be possible but I couldn't find how to do that with a
build matrix or arrays/maps.
Weekly builds, or push/ pullrequest triggered builds, now generate different
names.
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.
After the host reboots, the USBD_GS_CAN_Start function is called, In that
we take a pointer out of frame pool and never pushes it back, So every
time the host reboot, we leak a pointer one by one