mirror of
https://github.com/candle-usb/candleLight_fw.git
synced 2025-01-28 06:02:52 +08:00
usbd_gs_can: place USBD_GS_CAN_HandleTypeDef in BSS
Get rid of the first calloc().
This commit is contained in:
parent
e739f60960
commit
1c9f2e7384
@ -83,7 +83,7 @@ typedef struct {
|
||||
# define USB_RX_FIFO_SIZE ((256U / 4U) + 1U)
|
||||
#endif
|
||||
|
||||
uint8_t USBD_GS_CAN_Init(USBD_HandleTypeDef *pdev, queue_t *q_frame_pool, queue_t *q_from_host, led_data_t *leds);
|
||||
uint8_t USBD_GS_CAN_Init(USBD_GS_CAN_HandleTypeDef *hcan, USBD_HandleTypeDef *pdev, queue_t *q_frame_pool, queue_t *q_from_host, led_data_t *leds);
|
||||
void USBD_GS_CAN_SetChannel(USBD_HandleTypeDef *pdev, uint8_t channel, can_data_t* handle);
|
||||
void USBD_GS_CAN_SuspendCallback(USBD_HandleTypeDef *pdev);
|
||||
void USBD_GS_CAN_ResumeCallback(USBD_HandleTypeDef *pdev);
|
||||
|
@ -50,6 +50,7 @@ static bool send_to_host_or_enqueue(struct gs_host_frame *frame);
|
||||
static void send_to_host(void);
|
||||
|
||||
static can_data_t hCAN = {0};
|
||||
static USBD_GS_CAN_HandleTypeDef hGS_CAN;
|
||||
static USBD_HandleTypeDef hUSB = {0};
|
||||
static led_data_t hLED = {0};
|
||||
|
||||
@ -97,7 +98,7 @@ int main(void)
|
||||
|
||||
USBD_Init(&hUSB, (USBD_DescriptorsTypeDef*)&FS_Desc, DEVICE_FS);
|
||||
USBD_RegisterClass(&hUSB, &USBD_GS_CAN);
|
||||
USBD_GS_CAN_Init(&hUSB, q_frame_pool, q_from_host, &hLED);
|
||||
USBD_GS_CAN_Init(&hGS_CAN, &hUSB, q_frame_pool, q_from_host, &hLED);
|
||||
USBD_GS_CAN_SetChannel(&hUSB, 0, &hCAN);
|
||||
USBD_Start(&hUSB);
|
||||
|
||||
|
@ -280,12 +280,8 @@ static inline uint8_t USBD_GS_CAN_PrepareReceive(USBD_HandleTypeDef *pdev)
|
||||
* within other calls, which means the USB interrupt is already disabled and we
|
||||
* don't have any other interrupts to worry about. */
|
||||
|
||||
uint8_t USBD_GS_CAN_Init(USBD_HandleTypeDef *pdev, queue_t *q_frame_pool, queue_t *q_from_host, led_data_t *leds)
|
||||
uint8_t USBD_GS_CAN_Init(USBD_GS_CAN_HandleTypeDef *hcan, USBD_HandleTypeDef *pdev, queue_t *q_frame_pool, queue_t *q_from_host, led_data_t *leds)
|
||||
{
|
||||
USBD_GS_CAN_HandleTypeDef *hcan = calloc(1, sizeof(USBD_GS_CAN_HandleTypeDef));
|
||||
|
||||
assert_basic(hcan);
|
||||
|
||||
hcan->q_frame_pool = q_frame_pool;
|
||||
hcan->q_from_host = q_from_host;
|
||||
hcan->leds = leds;
|
||||
|
Loading…
x
Reference in New Issue
Block a user