当前位置: 首页>>代码示例>>C++>>正文


C++ PHAL_RUART_OP::HalRuartInit方法代码示例

本文整理汇总了C++中PHAL_RUART_OP::HalRuartInit方法的典型用法代码示例。如果您正苦于以下问题:C++ PHAL_RUART_OP::HalRuartInit方法的具体用法?C++ PHAL_RUART_OP::HalRuartInit怎么用?C++ PHAL_RUART_OP::HalRuartInit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHAL_RUART_OP的用法示例。


在下文中一共展示了PHAL_RUART_OP::HalRuartInit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: serial_baud

void serial_baud(serial_t *obj, int baudrate) {
    PHAL_RUART_ADAPTER pHalRuartAdapter;
    PHAL_RUART_OP      pHalRuartOp;

    pHalRuartAdapter = &(obj->hal_uart_adp);
    pHalRuartOp = &(obj->hal_uart_op);

    pHalRuartAdapter->BaudRate = baudrate;
    pHalRuartOp->HalRuartInit(pHalRuartAdapter);
}
开发者ID:eggman,项目名称:arm-gcc-blink-example,代码行数:10,代码来源:serial_api.c

示例2: serial_init

void serial_init(serial_t *obj, PinName tx, PinName rx) 
{
    uint32_t uart_tx, uart_rx;
    uint32_t uart_sel;
    uint8_t uart_idx;
    PHAL_RUART_OP      pHalRuartOp;
    PHAL_RUART_ADAPTER pHalRuartAdapter;
    
    // Determine the UART to use (UART0, UART1, or UART3)
    uart_tx = pinmap_peripheral(tx, PinMap_UART_TX);
    uart_rx = pinmap_peripheral(rx, PinMap_UART_RX);

    uart_sel = pinmap_merge(uart_tx, uart_rx);
    uart_idx = RTL_GET_PERI_IDX(uart_sel);
    if (unlikely(uart_idx == (uint8_t)NC)) {
        DBG_UART_ERR("%s: Cannot find matched UART\n", __FUNCTION__);
        return;
    }

    pHalRuartOp = &(obj->hal_uart_op);
    pHalRuartAdapter = &(obj->hal_uart_adp);

    if ((NULL == pHalRuartOp) || (NULL == pHalRuartAdapter)) {
        DBG_UART_ERR("%s: Allocate Adapter Failed\n", __FUNCTION__);
        return;
    }
    
    HalRuartOpInit((VOID*)pHalRuartOp);

    pHalRuartOp->HalRuartAdapterLoadDef(pHalRuartAdapter, uart_idx);
    pHalRuartAdapter->PinmuxSelect = RTL_GET_PERI_SEL(uart_sel);
    pHalRuartAdapter->BaudRate = 9600;
    
    // Configure the UART pins
    // TODO:
//    pinmap_pinout(tx, PinMap_UART_TX);
//    pinmap_pinout(rx, PinMap_UART_RX);
//    pin_mode(tx, PullUp);
//    pin_mode(rx, PullUp);
    
    pHalRuartOp->HalRuartInit(pHalRuartAdapter);
    pHalRuartOp->HalRuartRegIrq(pHalRuartAdapter);    
    pHalRuartOp->HalRuartIntEnable(pHalRuartAdapter);

#ifdef CONFIG_MBED_ENABLED
    // For stdio management
    if (uart_idx == STDIO_UART) {
        stdio_uart_inited = 1;
        memcpy(&stdio_uart, obj, sizeof(serial_t));
    }
#endif
}
开发者ID:eggman,项目名称:arm-gcc-blink-example,代码行数:52,代码来源:serial_api.c

示例3: serial_format

void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) 
{
    PHAL_RUART_ADAPTER pHalRuartAdapter;
    PHAL_RUART_OP      pHalRuartOp;

    pHalRuartAdapter = &(obj->hal_uart_adp);
    pHalRuartOp = &(obj->hal_uart_op);
    
    if (data_bits == 8) {
        pHalRuartAdapter->WordLen = RUART_WLS_8BITS;
    } else {
        pHalRuartAdapter->WordLen = RUART_WLS_7BITS;
    }


    switch (parity) {
        case ParityOdd:
        case ParityForced0:
            pHalRuartAdapter->Parity = RUART_PARITY_ENABLE;
            pHalRuartAdapter->ParityType = RUART_ODD_PARITY;
            break;
        case ParityEven:
        case ParityForced1:
            pHalRuartAdapter->Parity = RUART_PARITY_ENABLE;
            pHalRuartAdapter->ParityType = RUART_EVEN_PARITY;
            break;
        default: // ParityNone
            pHalRuartAdapter->Parity = RUART_PARITY_DISABLE;
            break;
    }

    if (stop_bits == 1) {
        pHalRuartAdapter->StopBit = RUART_1_STOP_BIT;
    } else {
        pHalRuartAdapter->StopBit = RUART_NO_STOP_BIT;
    }

    pHalRuartOp->HalRuartInit(pHalRuartAdapter);
}
开发者ID:eggman,项目名称:arm-gcc-blink-example,代码行数:39,代码来源:serial_api.c


注:本文中的PHAL_RUART_OP::HalRuartInit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。