forked from xuos/xiuos
fix a bug of uart input problem for gap8
This commit is contained in:
@@ -111,7 +111,7 @@ struct gap8_udma_peripheral
|
||||
{
|
||||
/* Public */
|
||||
|
||||
udma_reg_t *regs; /* Hardware config regs */
|
||||
volatile udma_reg_t *regs; /* Hardware config regs */
|
||||
uint32_t id; /* GAP8_UDMA_ID_x */
|
||||
void (*on_tx)(void *arg); /* tx callback */
|
||||
void (*on_rx)(void *arg); /* rx callback */
|
||||
|
||||
@@ -101,7 +101,7 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
static char g_uart1rxbuffer[128];
|
||||
static uint32 SerialConfigure(struct SerialDriver *serial_drv, int serial_operation_cmd)
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
@@ -117,7 +117,7 @@ static uint32 SerialConfigure(struct SerialDriver *serial_drv, int serial_operat
|
||||
|
||||
gap8_udma_rx_setirq(uart_udma, 1);
|
||||
|
||||
gap8_udma_rx_start(uart_udma, serial_dev->serial_fifo.serial_rx->serial_rx_buffer, 1, 1);
|
||||
gap8_udma_rx_start(uart_udma, g_uart1rxbuffer, 1, 1);
|
||||
|
||||
ENABLE_INTERRUPT(lock);
|
||||
} else if (OPER_CLR_INT == serial_operation_cmd) {
|
||||
@@ -179,14 +179,17 @@ static int SerialGetChar(struct SerialHardwareDevice *serial_dev)
|
||||
struct gap8_udma_peripheral *uart_udma = (struct gap8_udma_peripheral *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
uint8_t rx_buf[4] = {0};
|
||||
uint8_t ch = rx_buf[0];
|
||||
uint8_t ch = g_uart1rxbuffer[0];
|
||||
|
||||
/* Then trigger another reception */
|
||||
gap8_udma_rx_setirq(uart_udma, 1);
|
||||
gap8_udma_rx_start(uart_udma, g_uart1rxbuffer, 1, 1);
|
||||
|
||||
gap8_udma_rx_start(uart_udma, rx_buf, 1, 1);
|
||||
if (ch == 0)
|
||||
return -ERROR;
|
||||
|
||||
memset(g_uart1rxbuffer,0,128);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -201,9 +204,9 @@ static const struct SerialDataCfg data_cfg_init =
|
||||
.serial_buffer_size = SERIAL_RB_BUFSZ,
|
||||
};
|
||||
|
||||
static struct gap8_udma_peripheral gap8_udma =
|
||||
static struct gap8_udma_peripheral gap8_udma =
|
||||
{
|
||||
.regs = (udma_reg_t *)UART,
|
||||
.regs = (volatile udma_reg_t *)UART,
|
||||
.id = GAP8_UDMA_ID_UART,
|
||||
.on_tx = NONE,//UartRxIsr??
|
||||
// .on_tx = UartTxIsr,//UartRxIsr??
|
||||
|
||||
@@ -309,6 +309,9 @@ int gap8_udma_rx_poll(struct gap8_udma_peripheral *instance)
|
||||
****************************************************************************/
|
||||
int gap8_udma_doirq(int irq, void *context, void *arg)
|
||||
{
|
||||
int oldstat;
|
||||
int newstat;
|
||||
|
||||
struct gap8_udma_peripheral *the_peripheral;
|
||||
uint32_t event = SOC_EVENTS->CURRENT_EVENT & 0xff;
|
||||
|
||||
@@ -383,5 +386,9 @@ int gap8_udma_doirq(int irq, void *context, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
asm volatile ("csrr %0, 0x300": "=r" (oldstat));
|
||||
newstat = oldstat | (0x80) ;
|
||||
asm volatile("csrw 0x300, %0" : /* no output */ : "r" (newstat));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user