Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
518 views
in Technique[技术] by (71.8m points)

serial port - GPS callback interrupt?

I tried to capture RxBuffer, I'm using nRF52840 When I don't use call back, the buffer is clear, The RxBuffer is from UART1 and is displayed on UART0,

Code :

   `void uart_event_handler1(void * context, nrf_libuarte_async_evt_t * p_evt)
{
    nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
    ret_code_t ret;

    switch (p_evt->type)
    {
            case NRF_LIBUARTE_ASYNC_EVT_ERROR:
            bsp_board_led_invert(0);
            break;
        case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
                      
                    **//nrf_libuarte_async_tx(&libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);**
                    **GPS_CallBack();**
                   
                    //NRF_LOG_INFO("GPS CALLBACK  /n/r");
                        
            break;
        case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
            
            bsp_board_led_invert(2);
            break;
        default:
            break;
        }   ` 

enter image description here but when I use GPS_call back, GPS_CallBack(); Rxbuffer is cut, enter image description here What do I miss here ?

call back code :

`
typedef struct 
{
    uint8_t     rxBuffer[480];
    uint16_t    rxIndex;
    uint8_t     rxTmp;  
    uint32_t    LastTime;   
    
    GPGGA_t     GPGGA;
    
}GPS_t;
    void    GPS_CallBack(void)
{
    
    GPS.LastTime=nrf_systick_val_get(); //originally
    
    
    if(GPS.rxIndex < sizeof(GPS.rxBuffer)-2)
    {
        //p_evt->data.rxtx.p_data[GPS.rxIndex] = GPS.rxTmp;
        GPS.rxBuffer[GPS.rxIndex] = GPS.rxTmp; //originally
        GPS.rxIndex++;
        //memcpy((void *)line_buffer_GPS, GPS.rxBuffer, GPS.rxIndex); 
    }
   nrf_libuarte_async_rx_free(&libuarte1, (uint8_t *)&GPS.rxTmp, 1);
     
    
    //DEBUG
    //display to buffer
    nrf_libuarte_async_tx(&libuarte, GPS.rxBuffer, sizeof(GPS.rxBuffer));
    
}
`

Any ideas ?

Thanks

question from:https://stackoverflow.com/questions/66055677/gps-callback-interrupt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...