AnsweredAssumed Answered

JN5168 UART vAHI_Uart0RegisterCallback() Using

Question asked by JiWei Gao on Oct 12, 2017
Latest reply on Aug 14, 2018 by wenjiu Zhong
I added UART0 operations in JN-AN-1229-ZBPro-Application-Template-v1002, but UART0 is always unable to receive data, only send data, the callback function does not seem to work, I do not know where to set the wrong, how to set up to enter the callback function to process the receiving data, thank you!
PUBLIC void UART_vInit(void)
{
    /* Enable UART 0 */
    vAHI_UartEnable(UART);
    vAHI_UartReset(UART, TRUE, TRUE);
    vAHI_UartReset(UART, FALSE, FALSE);
    /* Set the clock divisor register to give required buad, this has to be done
       directly as the normal routines (in ROM) do not support all baud rates */
    UART_vSetBaudRate(UART_BAUD_RATE);
    vAHI_UartSetRTSCTS(UART, TRUE);
    vAHI_UartSetControl(UART, FALSE, FALSE, E_AHI_UART_WORD_LEN_8, TRUE, FALSE); /* [I SP001222_P1 279] */
    vAHI_UartSetInterrupt(UART, FALSE, FALSE, FALSE, TRUE, E_AHI_UART_FIFO_LEVEL_1);    // No TX ints!
    vAHI_Uart0RegisterCallback(APP_isrUart);
}
PUBLIC void APP_isrUart(uint32 u32Device, uint32 u32ItemBitmap)
{
 DBG_vPrintf(TRACE_UART, "isrUart\n");
 unsigned int irq = ((*((volatile uint32 *)(UART_START_ADR + 0x08))) >> 1) & 0x0007;
    uint8 u8Byte;
    if (irq & E_AHI_UART_INT_RXDATA) {
        uint8 u8Byte = u8AHI_UartReadData(UART);
        if(ZQ_bQueueSend(&APP_msgSerialRx, &u8Byte) == FALSE)
        {
            /* Failed to send the message to queue */
        }
    }
    if (irq & E_AHI_UART_INT_TX) {
        if(ZQ_bQueueReceive(&APP_msgSerialTx, &u8Byte) == TRUE)
        {
            vAHI_UartWriteData(UART, u8Byte);
            /* decrement activity counter for dequeued data */
        } else {
            /* disable tx interrupt as nothing to send */
            UART_vSetTxInterrupt(FALSE);
        }
    }
}
PRIVATE void vInitialiseApp(void)
{
    /* Initialise JenOS modules. Initialise Power Manager even on non-sleeping nodes
     * as it allows the device to doze when in the idle task
     */
    PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON);
    /*
     *  Initialise the PDM, use an application supplied key (g_sKey),
     *  The key value can be set to the desired value here, or the key in eFuse can be used.
     *  To use the key stored in eFuse set the pointer to the key to Null, and remove the
     *  key structure here.
     */
#ifdef PDM_EEPROM
 PDM_eInitialise(63);
 PDM_vRegisterSystemCallback(vPdmEventHandlerCallback);
#else
 PDM_vInit(7, 1, 64 * 1024 , NULL, NULL, NULL, &g_sKey);
#endif
    /* Initialise Protocol Data Unit Manager */
    PDUM_vInit();
    UART_vInit();
    /* Register callback that provides information about stack errors */
    ZPS_vExtendedStatusSetCallback(vfExtendedStatusCallBack);
    /* initialise application */
    APP_vInitResources();
    APP_vSetUpHardware();
    /* initialise application */
    APP_vInitialiseRouter();
    app_vMainloop();
}

}

Outcomes