Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ static void MX_GPIO_Init(void)

/* USER CODE BEGIN 4 */

void uart_clear_overrun_flag (void){
huart1.Instance->ICR |= (1 << 3);
}

/* USER CODE END 4 */

/**
Expand Down
6 changes: 6 additions & 0 deletions Src/xmodem.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ static uint16_t xmodem_calc_crc(uint8_t *data, uint16_t length);
static xmodem_status xmodem_handle_packet(uint8_t size);
static xmodem_status xmodem_error_handler(uint8_t *error_number, uint8_t max_error_number);

/* externs */
extern void uart_clear_overrun_flag (void);

/**
* @brief This function is the base of the Xmodem protocol.
* When we receive a header from UART, it decides what action it shall take.
Expand Down Expand Up @@ -102,6 +105,9 @@ void xmodem_receive(void)
}
break;
}

/*Prevent an overrun error after stop/cancel in the middle of a pack transference*/
uart_clear_overrun_flag();
}
}

Expand Down