コード例 #1
0
ファイル: app_uart_fifo.c プロジェクト: IOIOI/nRF51
uint32_t app_uart_put(uint8_t byte)
{
    uint32_t err_code;

    err_code = app_fifo_put(&m_tx_fifo, byte);
    if (err_code == NRF_SUCCESS)
    {
        // The new byte has been added to FIFO. It will be picked up from there
        // (in 'uart_event_handler') when all preceding bytes are transmitted.
        // But if UART is not transmitting anything at the moment, we must start
        // a new transmission here.
        if (!nrf_drv_uart_tx_in_progress())
        {
            // This operation should be almost always successful, since we've
            // just added a byte to FIFO, but if some bigger delay occurred
            // (some heavy interrupt handler routine has been executed) since
            // that time, FIFO might be empty already.
            if (app_fifo_get(&m_tx_fifo, tx_buffer) == NRF_SUCCESS)
            {
                err_code = nrf_drv_uart_tx(tx_buffer, 1);
            }
        }
    }

    return err_code;
}
コード例 #2
0
ファイル: qp.c プロジェクト: henrychoi/realtime
void QS_onFlush(void) {
    static uint16_t b;

    QF_INT_DISABLE();
    while ((b = QS_getByte()) != QS_EOD) {    /* while not End-Of-Data... */
        QF_INT_ENABLE();
        while (nrf_drv_uart_tx_in_progress()) { /* while TXE not empty */
        }
        //static uint8_t byte;
        //byte = b & 0xFF;
    	nrf_drv_uart_tx((const uint8_t*)&b, 1);
    }
    QF_INT_ENABLE();
}
コード例 #3
0
ファイル: qp.c プロジェクト: henrychoi/realtime
/*..........................................................................*/
void QV_onIdle(void) {  /* called with interrupts disabled, see NOTE01 */
#ifdef Q_SPY
#  if 0
    QS_rxParse();  /* parse all the received bytes */

    // Push out QS buffer to UART
    if (!nrf_drv_uart_tx_in_progress()) {  /* is TXE empty? */
        static uint16_t b;

        QF_INT_DISABLE();
        b = QS_getByte();
        QF_INT_ENABLE();

        if (b != QS_EOD) {  /* not End-Of-Data? */
        	nrf_drv_uart_tx((const uint8_t*)&b, 1);
        }
    }
#  else
    QF_INT_ENABLE();
    //sd_app_evt_wait();
    __WFE(); //__SEV();  __WFE();
#  endif
#elif defined NDEBUG
    /* Put the CPU and peripherals to the low-power mode.
    * you might need to customize the clock management for your application,
    * see the datasheet for your particular Cortex-M MCU.
    */
    /* !!!CAUTION!!!
    * The QF_CPU_SLEEP() contains the WFI instruction, which stops the CPU
    * clock, which unfortunately disables the JTAG port, so the ST-Link
    * debugger can no longer connect to the board. For that reason, the call
    * to QF_CPU_SLEEP() has to be used with CAUTION.
    */
    //QV_CPU_SLEEP(); //atomically go to SHALLOW sleep and enable interrupts
    __WFE();
    QF_INT_ENABLE(); /* for now, just enable interrupts */
#else
    QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
コード例 #4
0
ファイル: qp.c プロジェクト: henrychoi/realtime
void QS_onStartTX() {
    if (!nrf_drv_uart_tx_in_progress()) {
    	uart_tx1();
    }
}