Skip to content

Commit

Permalink
4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz-Juranek committed Aug 3, 2019
1 parent ede72e0 commit c3ce16b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
17 changes: 8 additions & 9 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int main(void)
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CAN_Init();
MX_USART2_UART_Init();
// MX_USART2_UART_Init();
MX_USB_DEVICE_Init();
MX_IWDG_Init();
/* USER CODE BEGIN 2 */
Expand All @@ -157,9 +157,9 @@ int main(void)
}
// UART RX
{
HAL_UART_Receive_IT(&huart2, &Uart2RxFifo, UART_RX_FIFO_SIZE);
HAL_NVIC_SetPriority(USART2_IRQn, 3, 3);
NVIC_EnableIRQ(USART2_IRQn);
// HAL_UART_Receive_IT(&huart2, &Uart2RxFifo, UART_RX_FIFO_SIZE);
// HAL_NVIC_SetPriority(USART2_IRQn, 3, 3);
// NVIC_EnableIRQ(USART2_IRQn);
}
/* Enable USART1 global interrupt */

Expand All @@ -174,7 +174,6 @@ int main(void)
slcanReciveCanFrame(hcan.pRxMsg);
canRxFlags.flags.fifo1 = 0;
HAL_CAN_Receive_IT(&hcan, CAN_FIFO0);
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
}
/* USER CODE END WHILE */

Expand Down Expand Up @@ -257,7 +256,7 @@ static void MX_CAN_Init(void)
hcan.Init.BS2 = CAN_BS2_4TQ;
hcan.Init.TTCM = DISABLE;
hcan.Init.ABOM = ENABLE;
hcan.Init.AWUM = DISABLE;
hcan.Init.AWUM = ENABLE;
hcan.Init.NART = DISABLE;
hcan.Init.RFLM = DISABLE;
hcan.Init.TXFP = DISABLE;
Expand Down Expand Up @@ -341,9 +340,9 @@ void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan) {
}

void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart) {
slCanProccesInput(Uart2RxFifo);
__HAL_UART_FLUSH_DRREGISTER(huart);
HAL_UART_Receive_IT(huart, &Uart2RxFifo, UART_RX_FIFO_SIZE);
// slCanProccesInput(Uart2RxFifo);
// __HAL_UART_FLUSH_DRREGISTER(huart);
// HAL_UART_Receive_IT(huart, &Uart2RxFifo, UART_RX_FIFO_SIZE);
}

/* USER CODE END 4 */
Expand Down
9 changes: 4 additions & 5 deletions Src/slcan/slcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@ void slcanOutputFlush(void)
{
if (sl_frame_len > 0)
{
if (hUsbDeviceFS.dev_state != USBD_STATE_CONFIGURED) // use auxiliary uart only if usb not connected
HAL_UART_Transmit(&huart2,sl_frame,sl_frame_len,100); //ll todo figure out time
else {
// addToUSBBuffer(sl_frame, sl_frame_len);
// if (hUsbDeviceFS.dev_state != USBD_STATE_CONFIGURED) // use auxiliary uart only if usb not connected
// HAL_UART_Transmit(&huart2,sl_frame,sl_frame_len,100); //ll todo figure out time
// else
{
while (((USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData)->TxState){;} //should change by hardware
while (CDC_Transmit_FS(sl_frame, sl_frame_len) != USBD_OK);

}
sl_frame_len = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions Src/slcan/slcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include "stm32f0xx_hal_can.h"


#define VERSION_FIRMWARE_MAJOR 3
#define VERSION_FIRMWARE_MINOR 3
#define VERSION_FIRMWARE_MAJOR 4
#define VERSION_FIRMWARE_MINOR 0

#define VERSION_HARDWARE_MAJOR 1
#define VERSION_HARDWARE_MINOR 1
Expand Down
3 changes: 2 additions & 1 deletion Src/usbd_cdc_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
if (hcdc->TxState != 0){
return USBD_BUSY;
}
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
memcpy(UserTxBufferFS, Buf, Len);
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
/* USER CODE END 7 */
return result;
Expand Down

0 comments on commit c3ce16b

Please sign in to comment.