USART fix handle_tx_ready, tweak priority of the sample.

This commit is contained in:
NIIBE Yutaka
2017-12-16 14:33:40 +09:00
parent 72210e4250
commit 19b0590c1f
3 changed files with 16 additions and 8 deletions

View File

@@ -117,8 +117,9 @@ usart_config (uint8_t dev_no, uint32_t config_bits)
struct USART *USARTx = get_usart_dev (dev_no);
uint8_t baud_spec = (config_bits & MASK_BAUD);
int i;
uint32_t cr1_config = (USART_CR1_UE | USART_CR1_TXEIE | USART_CR1_RXNEIE
uint32_t cr1_config = (USART_CR1_UE | USART_CR1_RXNEIE
| USART_CR1_TE | USART_CR1_RE);
/* TXEIE will be enabled when putting char */
/* No CTSIE, PEIE, TCIE, IDLEIE, LBDIE */
if (USARTx == NULL)
return -1;
@@ -430,17 +431,24 @@ static int
handle_tx_ready (struct USART *USARTx, struct rb *rb2h,
struct usart_stat *stat)
{
int tx_ready = 1;
int c = rb_ll_get (rb2h);
if (c >= 0)
{
uint32_t r;
USARTx->DR = (c & 0xff);
USARTx->CR1 |= USART_CR1_TXEIE;
stat->tx++;
return 0;
r = USARTx->SR;
if ((r & USART_SR_TXE) == 0)
{
tx_ready = 0;
USARTx->CR1 |= USART_CR1_TXEIE;
}
}
return 1;
return tx_ready;
}
static void *

View File

@@ -27,9 +27,9 @@ blk (void *arg)
return NULL;
}
#define PRIO_USART 4
#define PRIO_CDC2USART 2
#define PRIO_USART2CDC 2
#define PRIO_USART 2
#define PRIO_CDC2USART 3
#define PRIO_USART2CDC 3
#define STACK_MAIN
#define STACK_PROCESS_2

View File

@@ -636,7 +636,7 @@ usb_rx_ready (uint8_t ep_num, uint16_t len)
static void *cdc_main (void *arg);
#define PRIO_CDC 3
#define PRIO_CDC 4
void