我想要通过串口接收数据,使用UART_read()接收数据,则必须实时调用UART_read()才能收到数据,故想到使用Hwi_create()接口创建硬件中断,但是如何关联到串口的接收中断呢?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
void hwiFunc(UArg arg) { unsigned char rxData = 0; //在中断服务程序中清中断 //Hwi_clearInterrupt(7); /* Checking ths source of UART interrupt. */ int32_t intId = UARTIntIdentityGet(SOC_UART1_BASE); Log_print1(Diags_ENTRY, "UARTIsr: %d", intId); switch (intId) { case UART_INTID_TX_THRES_REACH: Log_print0(Diags_ENTRY, "UART_INTID_TX_THRES_REACH"); break; case UART_INTID_RX_THRES_REACH: rxData = UARTCharGetNonBlocking(SOC_UART1_BASE); //UARTCharPutNonBlocking(uartBaseAddr, rxByte); Log_print1(Diags_ENTRY, "Rx: %02x", rxData); break; case UART_INTID_RX_LINE_STAT_ERROR: case UART_INTID_CHAR_TIMEOUT: rxData = UARTCharGetNonBlocking(SOC_UART1_BASE); if(intId == UART_INTID_CHAR_TIMEOUT) Log_print1(Diags_ENTRY, "UART_INTID_CHAR_TIMEOUT: %02x", rxData); else Log_print1(Diags_ENTRY, "UART_INTID_RX_LINE_STAT_ERROR: %02x", rxData); break; default: break; } } void Hwi_Init(void) { Log_print0(Diags_ENTRY, "Hwi_Init"); //创建中断 Hwi_Handle hwi_uart1; //句柄 Hwi_Params hwi_params; //传入参数 Error_Block eb; //错误块 Error_init(&eb); //错误块初始化,注意必须初始化,否则易进入System_abort Hwi_Params_init(&hwi_params); //初始化传入参数 hwi_params.eventId = 43; hwi_params.enableInt = TRUE; //hwi_params.maskSetting = Hwi_MaskingOption_SELF; // don't allow this interrupt to nest itself hwi_uart1 = Hwi_create(7, hwiFunc, &hwi_params, &eb); //注意此处id是中断等级编号,如中断5,则id为5 if(hwi_uart1 == NULL) { System_abort("hwi_uart1 create failed"); } Hwi_enableInterrupt(7); //使能中断 }我创建中断后,一直不能进入中断服务函数,串口这边的配置应该如何设置呢?是调用 PDK_INSTALL_PATH\packages\ti\csl\src\ip\uart\V1\uart.h 还是使用
PDK_INSTALL_PATH\packages\ti\drv\uart\UART.h 的库函数配置串口?