From bf37f1a4134192e788b7b1288e3c7dc2c3edf1d0 Mon Sep 17 00:00:00 2001 From: Lukasz Juranek Date: Thu, 27 Apr 2017 15:03:08 +0200 Subject: [PATCH] Added CAN closing on VCOM closing --- .settings/language.settings.xml | 2 +- Src/slcan/slcan.c | 9 +++++++++ Src/slcan/slcan.h | 1 + Src/usbd_cdc_if.c | 5 +++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 3ec131e..38f269d 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -4,7 +4,7 @@ - + diff --git a/Src/slcan/slcan.c b/Src/slcan/slcan.c index dcfbe33..ce4bfe4 100644 --- a/Src/slcan/slcan.c +++ b/Src/slcan/slcan.c @@ -85,6 +85,14 @@ extern USBD_HandleTypeDef hUsbDeviceFS; uint8_t frameBuffer[FRAME_BUFFER_SIZE]; uint32_t dataToSend = 0; +void slcanClose() +{ + HAL_NVIC_DisableIRQ(CEC_CAN_IRQn); + dataToSend = 0; +// todo into slleep + state = STATE_CONFIG; +} + int slcanFlushUSBBuffer() { if (dataToSend != 0) @@ -352,6 +360,7 @@ void slCanCheckCommand() // if (state != STATE_CONFIG) { HAL_NVIC_DisableIRQ(CEC_CAN_IRQn); + dataToSend = 0; // todo into slleep state = STATE_CONFIG; result = terminator; diff --git a/Src/slcan/slcan.h b/Src/slcan/slcan.h index a5a52fe..f1d0d8d 100644 --- a/Src/slcan/slcan.h +++ b/Src/slcan/slcan.h @@ -32,6 +32,7 @@ //ex TZ12020506 +void slcanClose(); int slcanFlushUSBBuffer(); uint8_t slcanReciveCanFrame(CanRxMsgTypeDef *pRxMsg); int slCanProccesInput(uint8_t ch); diff --git a/Src/usbd_cdc_if.c b/Src/usbd_cdc_if.c index da541c9..53a1211 100644 --- a/Src/usbd_cdc_if.c +++ b/Src/usbd_cdc_if.c @@ -178,6 +178,7 @@ static int8_t CDC_DeInit_FS(void) * @param length: Number of data to be sent (in bytes) * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL */ + static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length) { /* USER CODE BEGIN 5 */ @@ -229,11 +230,11 @@ static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length) break; case CDC_SET_CONTROL_LINE_STATE: - + slcanClose();//ll break; case CDC_SEND_BREAK: - + break; default: