예제 #1
0
int serial_irq_handler_asynch(serial_t *obj)
{
    /* Sanity check arguments */
    MBED_ASSERT(obj);
    uint16_t interrupt_status;
    uint8_t *buf = obj->tx_buff.buffer;

    interrupt_status = _USART(obj).INTFLAG.reg;
    interrupt_status &= _USART(obj).INTENSET.reg;

    if (pUSART_S(obj)) {
        if (interrupt_status & SERCOM_USART_INTFLAG_DRE) {
            /* Interrupt has another TX source */
            if(obj->tx_buff.pos >= obj->tx_buff.length) {
                /* Transfer complete. Switch off interrupt and return event. */
                _USART(obj).INTENCLR.reg = SERCOM_USART_INTFLAG_DRE;
                _USART(obj).INTENSET.reg = SERCOM_USART_INTFLAG_TXC;
            } else {
                while((serial_writable(obj)) && (obj->tx_buff.pos <= (obj->tx_buff.length - 1))) {
                    _USART(obj).DATA.reg = buf[obj->tx_buff.pos];
                    obj->tx_buff.pos++;
                }
            }
        }
        if (interrupt_status & SERCOM_USART_INTFLAG_TXC) {
            return serial_tx_irq_handler_asynch(obj);
        }
        if (interrupt_status & SERCOM_USART_INTFLAG_RXC) {
            return serial_rx_irq_handler_asynch(obj);
        }
    }
    return 0;
}
예제 #2
0
파일: serial_api.c 프로젝트: pan-/mbed
void serial_putc(serial_t *obj, int c) 
{
#ifdef CONFIG_MBED_ENABLED
    if (obj->index == UART_3) {
        log_uart_putc(&stdio_uart_log, (char)c);

        // UnMask LOG_UART TX FIFO empty IRQ
        if (serial_log_irq_en & SERIAL_TX_IRQ_EN) {
            log_uart_t *log_obj = &stdio_uart_log;
            HAL_LOG_UART_ADAPTER *pUartAdapter=(PHAL_LOG_UART_ADAPTER)&(log_obj->log_hal_uart);
            pUartAdapter->IntEnReg |= IER_ETBEI;
            HalLogUartSetIntEn(pUartAdapter);
        }
        return;
    }
#endif
    PHAL_RUART_ADAPTER pHalRuartAdapter=(PHAL_RUART_ADAPTER)&(obj->hal_uart_adp);
    u8  uart_idx = pHalRuartAdapter->UartIndex;
    
    while (!serial_writable(obj));
    HAL_RUART_WRITE32(uart_idx, RUART_TRAN_HOLD_REG_OFF, (c & 0xFF));

    if (serial_irq_en[uart_idx] & SERIAL_TX_IRQ_EN) {
        // UnMask TX FIFO empty IRQ
        pHalRuartAdapter->Interrupts |= RUART_IER_ETBEI;
        HalRuartSetIMRRtl8195a (pHalRuartAdapter);
    }
}
예제 #3
0
파일: serial_api.c 프로젝트: Josnaky/mbed
int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint)
{
    int i;
    buffer_t *buf = &obj->tx_buff;
    struct serial_global_data_s *data = uart_data + obj->serial.index;
    
    if (tx_length == 0) {
        return 0;
    }
    
    buf->buffer = (void *)tx;
    buf->length = tx_length * tx_width / 8;
    buf->pos = 0;
    buf->width = tx_width;
    data->tranferring_obj = obj;
    data->async_tx_callback = handler;
    serial_irq_set(obj, TxIrq, 1);
    
    while (!serial_writable(obj));
    i = buf->length;
    if (serial_available_buffer(obj) < i) {
        i = serial_available_buffer(obj);
    }
    do {
        uint8_t c = *(uint8_t *)buf->buffer;
        obj->tx_buff.buffer = (uint8_t *)obj->tx_buff.buffer + 1;
        ++buf->pos;
        obj->serial.uart->SCFTDR = c;
    } while (--i);
    serial_put_done(obj);
    
    return buf->length;
}
예제 #4
0
void serial_putc(serial_t *obj, int c)
{
    /* Sanity check arguments */
    MBED_ASSERT(obj);
    while (!serial_writable(obj));
    _USART(obj)->US_THR = US_THR_TXCHR(c);
}
예제 #5
0
void serial_putc(serial_t *obj, int c) {
    uint16_t dummy_read;
    int was_masked;

#if defined ( __ICCARM__ )
    was_masked = __disable_irq_iar();
#else
    was_masked = __disable_irq();
#endif /* __ICCARM__ */
    obj->uart->SCSCR |= 0x0080;     // Set TIE
    if (!was_masked) {
        __enable_irq();
    }
    while (!serial_writable(obj));
    obj->uart->SCFTDR = c;
#if defined ( __ICCARM__ )
    was_masked = __disable_irq_iar();
#else
    was_masked = __disable_irq();
#endif /* __ICCARM__ */
    dummy_read = obj->uart->SCFSR;
    obj->uart->SCFSR = (dummy_read & 0xff9f);  // Clear TEND/TDFE
    if (!was_masked) {
        __enable_irq();
    }
    uart_data[obj->index].count++;
}
예제 #6
0
void serial_putc(serial_t *obj, int c)
{
    while (serial_writable(obj)) {
        /* NOP */
    }
    obj->uart->DATA = c;
}
예제 #7
0
파일: serial_api.c 프로젝트: ElAbbassi/mbed
void serial_putc(serial_t *obj, int c) {
    obj->uart->TXD = (uint8_t)c;
    
    while (!serial_writable(obj));
    
    obj->uart->EVENTS_TXDRDY =0;
}
예제 #8
0
파일: serial_api.c 프로젝트: oscarh/mbed-os
/** Send a character. This is a blocking call, waiting for a peripheral to be available
 *  for writing
 *
 * @param obj The serial object
 * @param c   The character to be sent
 */
void serial_putc(serial_t *obj, int c)
{
    struct serial_s *p_obj = GET_SERIAL_S(obj);

    while (!serial_writable(obj));
    usart_data_transmit(p_obj->uart, (int)((c) & BITS(0, 7 + (p_obj->databits >> 12))));
}
예제 #9
0
void BufferedSerial::txIrq(void)
{
    // see if there is room in the hardware fifo and if something is in the software fifo
    while (serial_writable(&_serial) && _txbuf.available()) {
        serial_putc(&_serial, (int)_txbuf.get());
        --_buffered_bytes;
    }
}
예제 #10
0
void serial_putc(serial_t *obj, int c)
{
    struct serial_s *obj_s = SERIAL_S(obj);
    UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
    
    while (!serial_writable(obj));
    huart->Instance->DR = (uint32_t)(c & 0x1FF);
}
void UARTClass::flush( void )
{
	UARTName uart = UART_0;
	serial_t obj;
	
	obj.uart = (NRF_UART_Type *)uart;	
	/* Wait EVENTS_TXDRDY = 1 */
	while( !(serial_writable(&obj)) );
}
예제 #12
0
void BufferedSerial::prime(void)
{
    // if already busy then the irq will pick this up
    if (serial_writable(&_serial)) {
        RawSerial::attach(NULL, RawSerial::TxIrq);    // make sure not to cause contention in the irq
        BufferedSerial::txIrq();                // only write to hardware in one place
        RawSerial::attach(this, &BufferedSerial::txIrq, RawSerial::TxIrq);
    }
}
예제 #13
0
void serial_putc(serial_t *obj, int c)
{
    /* Sanity check arguments */
    MBED_ASSERT(obj);
    uint16_t q = (c & SERCOM_USART_DATA_MASK);
    while (!serial_writable(obj));
    _USART(obj).DATA.reg = q;
    while (!(_USART(obj).INTFLAG.reg & SERCOM_USART_INTFLAG_TXC));  // wait till data is sent
}
예제 #14
0
void serial_putc(serial_t *obj, int c)
{
    USART_TypeDef *uart = (USART_TypeDef *)(obj->uart);
    while (!serial_writable(obj));
    if (obj->databits == UART_WORDLENGTH_8B) {
        uart->TDR = (uint8_t)(c & (uint8_t)0xFF);
    } else {
        uart->TDR = (uint16_t)(c & (uint16_t)0x1FF);
    }
}
예제 #15
0
void serial_putc(serial_t *obj, int c)
{
    struct serial_s *obj_s = SERIAL_S(obj);
    UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];

    while (!serial_writable(obj));
    if (obj_s->databits == UART_WORDLENGTH_8B) {
        huart->Instance->TDR = (uint8_t)(c & (uint8_t)0xFF);
    } else {
        huart->Instance->TDR = (uint16_t)(c & (uint16_t)0x1FF);
    }
}
예제 #16
0
void serial_putc(serial_t *obj, int c) 
{
    PHAL_RUART_ADAPTER pHalRuartAdapter=(PHAL_RUART_ADAPTER)&(obj->hal_uart_adp);
    u8  uart_idx = pHalRuartAdapter->UartIndex;
    
    while (!serial_writable(obj));
    HAL_RUART_WRITE32(uart_idx, RUART_TRAN_HOLD_REG_OFF, (c & 0xFF));

    if (serial_irq_en & SERIAL_TX_IRQ_EN) {
        // UnMask TX FIFO empty IRQ
        pHalRuartAdapter->Interrupts |= RUART_IER_ETBEI;
        HalRuartSetIMRRtl8195a (pHalRuartAdapter);
    }
}
예제 #17
0
void BufferedSerial::txIrq(void)
{
    // see if there is room in the hardware fifo and if something is in the software fifo
    while(serial_writable(&_serial)) {
        if(_txbuf.available()) {
            serial_putc(&_serial, (int)_txbuf.get());
        } else {
            // disable the TX interrupt when there is nothing left to send
            RawSerial::attach(NULL, RawSerial::TxIrq);
            break;
        }
    }

    return;
}
예제 #18
0
void serial_putc(serial_t *obj, int c)
{
    UART_HandleTypeDef *handle = &UartHandle[obj->serial.module];
    while (!serial_writable(obj));
    handle->Instance->DR = (uint32_t)(c & 0x1FF);
}
예제 #19
0
파일: serial_api.c 프로젝트: Josnaky/mbed
void serial_putc(serial_t *obj, int c) {
    while (!serial_writable(obj));
    obj->serial.uart->SCFTDR = c;
    serial_put_done(obj);
}
예제 #20
0
void serial_putc(serial_t *obj, int c)
{
    USART_TypeDef *uart = (USART_TypeDef *)(SERIAL_OBJ(uart));
    while (!serial_writable(obj));
    uart->DR = (uint32_t)(c & 0x1FF);
}
예제 #21
0
void serial_putc(serial_t *obj, int c) {
    USART_TypeDef *usart = (USART_TypeDef *)(obj->uart);
    while (!serial_writable(obj));
    USART_SendData(usart, (uint16_t)c);
}
예제 #22
0
파일: serial_api.c 프로젝트: pan-/mbed
void serial_putc(serial_t *obj, int c)
{
    while (!serial_writable(obj));
    LPUART_WriteByte(uart_addrs[obj->index], (uint8_t)c);
}
예제 #23
0
void serial_putc(serial_t *obj, int c)
{
    UART_HandleTypeDef *handle = &UartHandle[SERIAL_OBJ(index)];
    while (!serial_writable(obj));
    handle->Instance->DR = (uint32_t)(c & 0x1FF);
}
예제 #24
0
int SerialBase::writeable() {
    lock();
    int ret = serial_writable(&_serial);
    unlock();
    return ret;
}
예제 #25
0
파일: serial_api.c 프로젝트: GvoOjeda/mbed
void serial_putc(serial_t *obj, int c) {
    USART_TypeDef *uart = (USART_TypeDef *)(obj->uart);
    while (!serial_writable(obj));
    uart->TDR = (uint32_t)(c & (uint16_t)0xFF);
}
예제 #26
0
파일: serial_api.c 프로젝트: Babody/mbed
void serial_putc(serial_t *obj, int c) {
    while (!serial_writable(obj));
    uint32_t uart_addrs[] = UART_BASE_ADDRS;
    UART_HAL_Putchar(uart_addrs[obj->index], (uint8_t)c);
}
예제 #27
0
파일: serial_api.c 프로젝트: Fadis/lpc810
void serial_putc(serial_t *obj, int c) {
    while (!serial_writable(obj));
    obj->uart->TXDATA = c;
}
예제 #28
0
파일: Serial.cpp 프로젝트: teddokano/mbed
int Serial::writeable() {
    return serial_writable(&_serial);
}
예제 #29
0
void UARTClass1::flush( void )
{

  while ( serial_writable(&(this->sobj)) != 1 );
}