Modify uart
This commit is contained in:
parent
5e331e4c7c
commit
aca8486498
|
@ -26,12 +26,12 @@ extern x_ubase interrupt_new_task;
|
||||||
|
|
||||||
void sw_setpend(void)
|
void sw_setpend(void)
|
||||||
{
|
{
|
||||||
PFIC_SetPendingIRQ(SWI_IRQn);
|
SysTick->CNTFG |= (1 << 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sw_clearpend(void)
|
void sw_clearpend(void)
|
||||||
{
|
{
|
||||||
PFIC_ClearPendingIRQ(SWI_IRQn);
|
SysTick->CNTFG &= ~(1 << 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
x_base DisableLocalInterrupt()
|
x_base DisableLocalInterrupt()
|
||||||
|
|
|
@ -33,7 +33,7 @@ void InitBoardHardware()
|
||||||
SystemInit(FREQ_SYS);
|
SystemInit(FREQ_SYS);
|
||||||
Delay_Init(FREQ_SYS);
|
Delay_Init(FREQ_SYS);
|
||||||
|
|
||||||
SysTick_Config(FREQ_SYS / 8 / TICK_PER_SECOND);
|
SysTick_Config(FREQ_SYS / TICK_PER_SECOND);
|
||||||
PFIC_EnableIRQ(SWI_IRQn);
|
PFIC_EnableIRQ(SWI_IRQn);
|
||||||
|
|
||||||
/* initialize memory system */
|
/* initialize memory system */
|
||||||
|
|
|
@ -98,10 +98,8 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||||
// config serial receive sem timeout
|
// config serial receive sem timeout
|
||||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||||
|
|
||||||
|
// config serial reg
|
||||||
#if 1
|
|
||||||
struct uart_registers *uxreg = (struct uart_registers *)serial_cfg->hw_cfg.serial_register_base;
|
struct uart_registers *uxreg = (struct uart_registers *)serial_cfg->hw_cfg.serial_register_base;
|
||||||
|
|
||||||
union _uart_fcr fcr;
|
union _uart_fcr fcr;
|
||||||
union _uart_lcr lcr;
|
union _uart_lcr lcr;
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
|
@ -166,8 +164,6 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||||
/* TXD pin output enable */
|
/* TXD pin output enable */
|
||||||
uxreg->IER.txd_en = 1;
|
uxreg->IER.txd_en = 1;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,15 +232,12 @@ static int SerialPutChar(struct SerialHardwareDevice *serial_dev, char ch) {
|
||||||
static int SerialGetChar(struct SerialHardwareDevice *serial_dev) {
|
static int SerialGetChar(struct SerialHardwareDevice *serial_dev) {
|
||||||
int ch = -1;
|
int ch = -1;
|
||||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_dev->private_data;
|
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_dev->private_data;
|
||||||
|
volatile struct uart_registers *uxreg = (struct uart_registers *)serial_cfg->hw_cfg.serial_register_base;
|
||||||
|
|
||||||
if ( (UART1_GetLinSTA() & RB_LSR_DATA_RDY) == RB_LSR_DATA_RDY) {
|
if (1 == uxreg->LSR.data_rdy) {
|
||||||
ch = UART1_RecvByte();
|
/* UART_II_RECV_RDY is cleared by reading RBR */
|
||||||
|
ch = (uxreg->RFC > 0) ? uxreg->RBR : -1;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (RESET != USART_GetFlagStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_RXNE)) {
|
|
||||||
ch = USART_ReceiveData((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base) & 0xff;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
@ -326,9 +319,7 @@ struct SerialHardwareDevice serial_device_1;
|
||||||
|
|
||||||
void UART1_IRQHandler(void) __attribute__((interrupt()));
|
void UART1_IRQHandler(void) __attribute__((interrupt()));
|
||||||
void UART1_IRQHandler(void) {
|
void UART1_IRQHandler(void) {
|
||||||
#if 1
|
|
||||||
GET_INT_SP();
|
GET_INT_SP();
|
||||||
//isr_sp_enter();
|
|
||||||
x_base level;
|
x_base level;
|
||||||
level = DisableLocalInterrupt();
|
level = DisableLocalInterrupt();
|
||||||
isrManager.done->incCounter();
|
isrManager.done->incCounter();
|
||||||
|
@ -338,8 +329,6 @@ void UART1_IRQHandler(void) {
|
||||||
isrManager.done->decCounter();
|
isrManager.done->decCounter();
|
||||||
EnableLocalInterrupt(level);
|
EnableLocalInterrupt(level);
|
||||||
FREE_INT_SP();
|
FREE_INT_SP();
|
||||||
//isr_sp_leave();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -386,18 +375,11 @@ int InitHwUart(void) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Configure the serial port */
|
/* Configure the serial port */
|
||||||
GPIOA_SetBits(GPIO_Pin_8);
|
GPIOA_SetBits(GPIO_Pin_8);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_7, GPIO_ModeIN_PU_NSMT); // RXD-pull-up input
|
GPIOA_ModeCfg(GPIO_Pin_7, GPIO_ModeIN_PU_NSMT); // RXD-pull-up input
|
||||||
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_Slowascent_PP_8mA); // TXD-push-pull output
|
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_Slowascent_PP_8mA); // TXD-push-pull output
|
||||||
// UART1_DefInit();
|
UART1_DefInit();
|
||||||
/*
|
|
||||||
//Interrupt method
|
|
||||||
UART1_ByteTrigCfg( UART_1BYTE_TRIG );
|
|
||||||
UART1_INTCfg( ENABLE, RB_IER_RECV_RDY|RB_IER_LINE_STAT );
|
|
||||||
PFIC_EnableIRQ( UART1_IRQn );
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue