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.
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.
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