mirror of
https://github.com/candle-usb/candleLight_fw.git
synced 2025-01-14 05:42:53 +08:00
usbd_gs_can: move send_to_host() to usbd_gs_can.c and rename it to USBD_GS_CAN_SendToHost()
Since USBD_GS_CAN_SendFrame() isn't used anymore outside of usbd_gs_can.c, mark it as static.
This commit is contained in:
parent
562d765c3c
commit
3e4883c74f
@ -99,8 +99,8 @@ uint8_t USBD_GS_CAN_Init(USBD_GS_CAN_HandleTypeDef *hcan, USBD_HandleTypeDef *pd
|
||||
void USBD_GS_CAN_SuspendCallback(USBD_HandleTypeDef *pdev);
|
||||
void USBD_GS_CAN_ResumeCallback(USBD_HandleTypeDef *pdev);
|
||||
bool USBD_GS_CAN_TxReady(USBD_HandleTypeDef *pdev);
|
||||
void USBD_GS_CAN_SendToHost(USBD_HandleTypeDef *pdev);
|
||||
bool USBD_GS_CAN_CustomDeviceRequest(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
bool USBD_GS_CAN_CustomInterfaceRequest(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
|
||||
bool USBD_GS_CAN_DfuDetachRequested(USBD_HandleTypeDef *pdev);
|
||||
uint8_t USBD_GS_CAN_SendFrame(USBD_HandleTypeDef *pdev, struct gs_host_frame *frame);
|
||||
|
25
src/main.c
25
src/main.c
@ -46,7 +46,6 @@ THE SOFTWARE.
|
||||
|
||||
void HAL_MspInit(void);
|
||||
static void SystemClock_Config(void);
|
||||
static void send_to_host(void);
|
||||
|
||||
static USBD_GS_CAN_HandleTypeDef hGS_CAN;
|
||||
static USBD_HandleTypeDef hUSB = {0};
|
||||
@ -128,7 +127,7 @@ int main(void)
|
||||
}
|
||||
|
||||
if (USBD_GS_CAN_TxReady(&hUSB)) {
|
||||
send_to_host();
|
||||
USBD_GS_CAN_SendToHost(&hUSB);
|
||||
}
|
||||
|
||||
if (can_is_rx_pending(channel)) {
|
||||
@ -213,25 +212,3 @@ void SystemClock_Config(void)
|
||||
{
|
||||
device_sysclock_config();
|
||||
}
|
||||
|
||||
void send_to_host(void)
|
||||
{
|
||||
struct gs_host_frame_object *frame_object;
|
||||
|
||||
bool was_irq_enabled = disable_irq();
|
||||
frame_object = list_first_entry_or_null(&hGS_CAN.list_to_host,
|
||||
struct gs_host_frame_object,
|
||||
list);
|
||||
if (!frame_object) {
|
||||
restore_irq(was_irq_enabled);
|
||||
return;
|
||||
}
|
||||
list_del(&frame_object->list);
|
||||
restore_irq(was_irq_enabled);
|
||||
|
||||
if (USBD_GS_CAN_SendFrame(&hUSB, &frame_object->frame) == USBD_OK) {
|
||||
list_add_tail_locked(&frame_object->list, &hGS_CAN.list_frame_pool);
|
||||
} else {
|
||||
list_add_locked(&frame_object->list, &hGS_CAN.list_to_host);
|
||||
}
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ static uint8_t USBD_GS_CAN_Transmit(USBD_HandleTypeDef *pdev, uint8_t *buf, uint
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t USBD_GS_CAN_SendFrame(USBD_HandleTypeDef *pdev, struct gs_host_frame *frame)
|
||||
static uint8_t USBD_GS_CAN_SendFrame(USBD_HandleTypeDef *pdev, struct gs_host_frame *frame)
|
||||
{
|
||||
uint8_t buf[CAN_DATA_MAX_PACKET_SIZE],*send_addr;
|
||||
|
||||
@ -767,6 +767,29 @@ uint8_t USBD_GS_CAN_SendFrame(USBD_HandleTypeDef *pdev, struct gs_host_frame *fr
|
||||
return result;
|
||||
}
|
||||
|
||||
void USBD_GS_CAN_SendToHost(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_GS_CAN_HandleTypeDef *hcan = (USBD_GS_CAN_HandleTypeDef*)pdev->pClassData;
|
||||
struct gs_host_frame_object *frame_object;
|
||||
|
||||
bool was_irq_enabled = disable_irq();
|
||||
frame_object = list_first_entry_or_null(&hcan->list_to_host,
|
||||
struct gs_host_frame_object,
|
||||
list);
|
||||
if (!frame_object) {
|
||||
restore_irq(was_irq_enabled);
|
||||
return;
|
||||
}
|
||||
list_del(&frame_object->list);
|
||||
restore_irq(was_irq_enabled);
|
||||
|
||||
if (USBD_GS_CAN_SendFrame(pdev, &frame_object->frame) == USBD_OK) {
|
||||
list_add_tail_locked(&frame_object->list, &hcan->list_frame_pool);
|
||||
} else {
|
||||
list_add_locked(&frame_object->list, &hcan->list_to_host);
|
||||
}
|
||||
}
|
||||
|
||||
bool USBD_GS_CAN_DfuDetachRequested(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_GS_CAN_HandleTypeDef *hcan = (USBD_GS_CAN_HandleTypeDef*)pdev->pClassData;
|
||||
|
Loading…
x
Reference in New Issue
Block a user