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.
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().
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.
Having two writes to clean and set COUNTn_RX and NUM_BLOCK results in
a small windows in which COUNTn_RX and NUM_BLOCK are zero.
This results in a stall as the buffer is empty (ready to receive) but
also has no space to receive the package into.
Signed-off-by: Jonas Martin <j.martin@pengutronix.de>
The binary inverse of 0x1 is 0xfe not 0x0. Fix this by using a logic
negation instead.
Fixes: f4f1586dbf56 ("can.c: use GPIO_INIT_STATE to set CANSTBY pin")
startup files generated by stm32cubeIDE do this. Mostly useless since
none of our code uses that; the linking step gets rid of those sections
anyway.
objdump before:
200000a8 l .data 00000000 __fini_array_end
200000a4 l .data 00000000 __fini_array_start
200000a4 l .data 00000000 __init_array_end
200000a0 l .data 00000000 __preinit_array_end
200000a0 l .data 00000000 __init_array_start
200000a0 l .data 00000000 __preinit_array_start
after:
0800419c l .fini_array 00000000 __fini_array_end
08004198 l .fini_array 00000000 __fini_array_start
08004198 l .init_array 00000000 __init_array_end
08004194 l .preinit_array 00000000 __preinit_array_end
08004194 l .init_array 00000000 __init_array_start
08004194 l .preinit_array 00000000 __preinit_array_start
This allows a much lighter implementation of led_indicate_trx(), which
is called for every frame !
Test with 'cangen -L0 -g0 -p10 can0'
After : 13174 frames/sec
Not necessary to spam it every mainloop. Currently throughputs of 17-18k
frames per second is realistic, which means function calls from mainloop
are very frequent and must be "short" compared to the processing time
for each frame.
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.