亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uart.c

?? 是一個手機功能的模擬程序
?? C
?? 第 1 頁 / 共 3 頁
字號:

#if ((CHIPSET != 5) && (CHIPSET != 6))
    /*
     * Enable sleep mode.
     */

    WRITE_UART_REGISTER (uart, IER, IER_SLEEP);
#endif
}


/*******************************************************************************
 *
 *                               UA_Init
 * 
 * Purpose  : Initializes the module and the UART.
 *
 * Arguments: In : uart_id : UART id.
 *                 baudrate: baud rate selected.
 *                 callback: user's function called characters are received.
 *            Out: none
 *
 * Returns: none
 *
 * Warning: Parameters are not verified.
 *
 ******************************************************************************/

void
UA_Init (T_tr_UartId uart_id,
         T_tr_Baudrate baudrate,
         void (callback_function (void)))
{
    t_uart *uart;
    int    index;

    for (index = 0; index < NUMBER_OF_TR_UART; index++)
        uart_parameter[index].base_address = base_address[index];
        
    uart = &(uart_parameter[uart_id]);

    uart->rx_in  = &(uart->rx_buffer[0]);
    uart->rx_out = &(uart->rx_buffer[0]);

    uart->callback_function = callback_function;

    uart->framing_error = 0;
    uart->parity_error  = 0;
    uart->overrun_error = 0;

    uart->dle_detected = 0;
    uart->inframe = 0;
    uart->encapsulation_flag = 0;
    uart->frame_length = 0;

    /*
     * Mask all interrupts causes and disable sleep mode.
     */

    WRITE_UART_REGISTER (uart, IER, 0x00);

    /*
     * Reset UART mode configuration.
     */
     
    WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE   |
                                     IR_SLEEP_DISABLED     |
                                     SIR_TX_WITHOUT_ACREG2 |
                                     FRAME_LENGTH_METHOD);

    /*
     * FIFO configuration.
     * EFR[4] = 1 to allow to program FCR[5:4] and MCR[7:5].
     */
     
    WRITE_UART_REGISTER (uart, LCR, 0xBF);
    SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT);

    /*
     * Select the word length, the number of stop bits , the parity and set
     * LCR[7] (DLAB) to allow to program FCR, DLL and DLM.
     */

    WRITE_UART_REGISTER (uart, LCR, WLS_8 | DLAB);

    /*
     * Program the trigger levels.
     * MCR[6] must be set to 1.
     */
     
    SET_BIT (uart, MCR, TCR_TLR_BIT);
    WRITE_UART_REGISTER (uart, TCR, 0x0F);
    WRITE_UART_REGISTER (
        uart, TLR, RX_FIFO_TRIGGER_LEVEL);
    
    /*
     * Program the FIFO control register. Bit 0 must be set when other FCR bits
     * are written to or they are not programmed.
     * FCR is a write-only register. It will not be modified.
     */

    WRITE_UART_REGISTER (uart, FCR, FIFO_ENABLE   |
                                    RX_FIFO_RESET | /* self cleared */
                                    TX_FIFO_RESET); /* self cleared */

    /*
     * Program the baud generator.
     */

    WRITE_UART_REGISTER (uart, DLL, dll[baudrate]);
    WRITE_UART_REGISTER (uart, DLM, dlh[baudrate]);

    
    /*
     * Reset LCR[7] (DLAB) to have access to the RBR, THR and IER registers.
     */

    WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB);


    /*
     * Select UART mode.
     */
     
    WRITE_UART_REGISTER (uart, MDR1, UART_MODE             |
                                     IR_SLEEP_DISABLED     |
                                     SIR_TX_WITHOUT_ACREG2 |
                                     FRAME_LENGTH_METHOD);

#if ((CHIPSET == 5) || (CHIPSET == 6))
    /*
     * Unmask RX interrupt
     */

    WRITE_UART_REGISTER (uart, IER, ERBI);
#else
    /*
     * Unmask RX interrupt and allow sleep mode.
     */

    WRITE_UART_REGISTER (uart, IER, ERBI | IER_SLEEP);
#endif
}

/*******************************************************************************
 *
 *                           UA_ReadNChars
 * 
 * Purpose  : Reads N characters from the RX buffer.
 *
 * Arguments: In : uart_id      : UART id.
 *                 buffer       : buffer address where the characters are
 *                                copied.
 *                 chars_to_read: number of characters to read.
 *            Out: none
 *
 * Returns  : The number of characters read.
 *
 * Warning: Parameters are not verified.
 *
 ******************************************************************************/

SYS_UWORD32
UA_ReadNChars (T_tr_UartId uart_id,
               char *buffer,
               SYS_UWORD32 chars_to_read)
{
    SYS_UWORD32 chars_in_rx_buffer;
    SYS_UWORD32 chars_to_copy;
    SYS_UWORD32 chars_written;
    char        *rx_in;
    t_uart      *uart;
    
    uart = &(uart_parameter[uart_id]);

    /*
     * A copy of the rx_in pointer is used because it may be updated by
     * the interrupt handler.
     * Get the number of bytes available in the RX buffer.
     */
         
    rx_in = uart->rx_in;

    if (uart->rx_out <= rx_in)
        chars_in_rx_buffer = (SYS_UWORD32) (rx_in - uart->rx_out);
    else
        chars_in_rx_buffer = (SYS_UWORD32) (rx_in - uart->rx_out + BUFFER_SIZE + 1);

    /*
     * No more bytes than those received may be written in the output buffer.
     */

    if (chars_in_rx_buffer >= chars_to_read)
        chars_to_copy = chars_to_read;
    else
        chars_to_copy = chars_in_rx_buffer;

    chars_written = chars_to_copy;

    /*
     * Write the received bytes in the output buffer.
     */

    while (chars_to_copy) {

        *(buffer++) = *(uart->rx_out++);
        chars_to_copy--;

        if (uart->rx_out == &(uart->rx_buffer[0]) + BUFFER_SIZE + 1)
            uart->rx_out = &(uart->rx_buffer[0]);
    }

    return (chars_written);
}

/*******************************************************************************
 *
 *                           UA_ReadNBytes
 * 
 * Purpose  : Reads and destuff N bytes from the RX buffer.
 *
 * Arguments: In : uart_id      : UART id.
 *                 buffer       : buffer address where the bytes are copied.
 *                 chars_to_read: number of bytes to read.
 *            Out: eof_detected : indicates if an EOF has been detected.
 *
 * Returns  : The number of bytes read.
 *
 * Warning: Parameters are not verified.
 *
 ******************************************************************************/

SYS_UWORD32
UA_ReadNBytes (T_tr_UartId uart_id,
               char *buffer,
               SYS_UWORD32 bytes_to_read,
               SYS_BOOL *eof_detected)
{
    SYS_UWORD32 bytes_in_rx_buffer;
    SYS_UWORD32 bytes_to_process;
    SYS_UWORD32 bytes_written;
    char        *rx_in;
    t_uart      *uart;
    
    bytes_written = 0;
    uart = &(uart_parameter[uart_id]);

    /*
     * A copy of the rx_in pointer is used because it may be updated by
     * the interrupt handler.
     * Get the number of bytes available in the RX buffer.
     */
         
    rx_in = uart->rx_in;

    if (uart->rx_out <= rx_in)
        bytes_in_rx_buffer = (SYS_UWORD32) (rx_in - uart->rx_out);
    else
        bytes_in_rx_buffer = (SYS_UWORD32) (rx_in - uart->rx_out + BUFFER_SIZE + 1);

    /*
     * No more bytes than those received may be processed and then written in
     * the output buffer.
     */

    if (bytes_in_rx_buffer >= bytes_to_read)
        bytes_to_process = bytes_to_read;
    else
        bytes_to_process = bytes_in_rx_buffer;

    /*
     * Perform the byte destuffing and then write the "valid" received bytes in
     * the output buffer.
     */

    while ((bytes_to_process) && !(*eof_detected)) {

        switch (*(uart->rx_out)) {                                                                       

            /*
             * Current byte is DLE.
             */  

            case DLE:
                                                        
                if (!uart->dle_detected) {

                    /*
                     * No DLE previously detected => 
                     * Skip the current byte and set the flag.
                     */

                    uart->dle_detected = 1;
                    bytes_to_process--;
                    uart->rx_out++;
                }

                else { /* if (uart->dle_detected) */

                    if (uart->inframe) {

                        /*
                         * DLE previously detected AND currently inside of a frame =>
                         * Copy the current byte in the output buffer, reset the flag
                         * and increase the frame length.
                         */

                        uart->dle_detected = 0;
                        bytes_to_process--;
                        uart->frame_length++;
                        *(buffer++) = *(uart->rx_out++);
                        bytes_written++;
                    }                                       

                    else { /* if (!uart->inframe) */

                        /*
                         * DLE previously detected AND currently outside of a frame =>
                         * Skip the current byte.
                         */

                        bytes_to_process--;
                        uart->rx_out++;
                    }
                }

            break; /* case DLE */
                                                                                
            /*
             * Current byte is STX.
             */  

            case STX:
                                                      
                if ((!uart->dle_detected) && (uart->inframe)) {

                    /*
                     * No DLE previously detected AND currently inside of a frame.
                     */

                    if (uart->frame_length) {

                        /*
                         * Frame length is not zero (End of Frame) => 
                         * Skip the current byte and set the flags (EOF).
                         */

                        uart->inframe = 0;
                        *eof_detected = 1;
                        uart->frame_length = 0;
                        bytes_to_process--;
                        uart->rx_out++;
                    }

                    else { /* if (!uart->frame_length) */

                        /*
                         * Frame length is zero (STX followed by another STX =
                         * Synchro lost but start of a new frame) =>
                         * Skip the current byte and keep the flag set.
                         */

                        bytes_to_process--;
                        uart->rx_out++;
                    }
                }

                else if ((!uart->dle_detected) && (!uart->inframe)) {

                    /*
                     * No DLE previously detected AND currently outside of a
                     * frame (Start of Frame) =>
                     * Skip the current byte and set the flag.
                     */

                    uart->inframe = 1;
                    bytes_to_process--;
                    uart->rx_out++;
                }

                else if ((uart->dle_detected) && (uart->inframe)) {

                    /*
                     * DLE previously detected AND currently inside of a frame =>
                     * Copy the current byte in the output buffer, reset the flag
                     * and increase the frame length.
                     */

                    uart->dle_detected = 0;
                    bytes_to_process--;
                    uart->frame_length++;
                    *(buffer++) = *(uart->rx_out++);
                    bytes_written++;
                }                                       

                else if ((uart->dle_detected) && (!uart->inframe)) {

                    /*
                     * DLE previously detected AND currently outside of a frame =>
                     * Skip the current byte and reset the flag.
                     */

                    uart->dle_detected = 0;
                    bytes_to_process--;
                    uart->rx_out++;
                }

            break; /* case STX */

            /*
             * Current byte is neither DLE nor STX.
             */  

            default:

                if (uart->inframe) {

                    /*
                     * Currently inside of a frame =>
                     * Copy the current byte in the output buffer and increase
                     * the frame length.
                     */

                    bytes_to_process--;
                    uart->frame_length++;
                    *(buffer++) = *(uart->rx_out++);
                    bytes_written++;
                }                                       

                else { /* if (!uart->inframe) */

                    /*
                     * Currently outside of a frame =>
                     * Skip the current byte.
                     */

                    bytes_to_process--;
                    uart->rx_out++;
                }

            break; /* default */
        }

        if (uart->rx_out == &(uart->rx_buffer[0]) + BUFFER_SIZE + 1)
            uart->rx_out = &(uart->rx_buffer[0]);
    }

    return (bytes_written);
}


/*******************************************************************************
 *
 *                           UA_WriteNChars
 * 
 * Purpose  : Writes N characters in the TX FIFO.
 *
 * Arguments: In : uart_id       : UART id.
 *                 buffer        : buffer address from which characters are
 *                                 written.
 *                 bytes_to_write: number of bytes to write.
 *            Out: none
 *
 * Returns  : Number of bytes written.
 *
 * Warning: Parameters are not verified.
 *
 ******************************************************************************/

SYS_UWORD32
UA_WriteNChars (T_tr_UartId uart_id,
                char *buffer,
                SYS_UWORD32 chars_to_write)
{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品免费丝袜| 国产精品成人免费精品自在线观看| 乱一区二区av| 国产精品欧美久久久久一区二区| 欧美丝袜自拍制服另类| 国产高清一区日本| 午夜一区二区三区视频| 欧美国产亚洲另类动漫| 日韩视频在线永久播放| 色一情一伦一子一伦一区| 国产精品一区二区在线看| 国产一区二区三区蝌蚪| 亚洲午夜电影在线观看| 国产精品电影一区二区三区| 精品国产精品网麻豆系列| 在线看国产一区| 本田岬高潮一区二区三区| 久久99精品国产麻豆婷婷洗澡| 亚洲午夜激情av| 亚洲精品美国一| 成人免费在线视频观看| 久久久青草青青国产亚洲免观| 欧美久久久久久久久久| 在线观看区一区二| 91小视频在线| 不卡免费追剧大全电视剧网站| 国产一区二区免费看| 日本欧美一区二区三区乱码| 亚洲欧美日本韩国| 中文字幕色av一区二区三区| 国产精品丝袜在线| 国产日产欧美一区| 久久精品在线观看| 日韩美女天天操| 精品噜噜噜噜久久久久久久久试看| 欧美剧情电影在线观看完整版免费励志电影 | 国产成人aaa| 国产原创一区二区三区| 国内精品久久久久影院色| 免费在线成人网| 日本vs亚洲vs韩国一区三区二区| 亚洲成av人**亚洲成av**| 一区二区三区久久久| 亚洲最新在线观看| 亚洲一区在线观看免费| 亚洲一区二区在线免费观看视频| 亚洲精品成a人| 亚洲男人电影天堂| 亚洲高清免费一级二级三级| 亚洲无人区一区| 日韩精品每日更新| 极品少妇xxxx精品少妇| 国产米奇在线777精品观看| 国产精品一品视频| www.亚洲色图.com| 9人人澡人人爽人人精品| 91在线国产福利| 欧美在线小视频| 欧美人妖巨大在线| 精品精品国产高清一毛片一天堂| 久久精品亚洲精品国产欧美| 国产精品无遮挡| 亚洲色图欧美激情| 亚洲第一二三四区| 久久精品国产**网站演员| 国产一区二区三区精品欧美日韩一区二区三区| 激情欧美一区二区三区在线观看| 国产aⅴ综合色| 在线免费亚洲电影| 欧美电影免费观看完整版| 国产女人aaa级久久久级| 亚洲精品免费一二三区| 免费国产亚洲视频| 懂色av一区二区在线播放| 日本韩国欧美一区二区三区| 欧美丰满嫩嫩电影| 国产日韩欧美不卡在线| 亚洲激情五月婷婷| 麻豆成人久久精品二区三区红 | 欧美午夜不卡视频| 日韩视频免费直播| 欧美国产1区2区| 午夜精品一区在线观看| 久久精品国产精品亚洲红杏| av午夜精品一区二区三区| 欧美猛男gaygay网站| 国产日韩欧美激情| 午夜精品成人在线视频| 国产suv精品一区二区6| 制服丝袜亚洲播放| 亚洲欧洲一区二区三区| 蜜桃视频一区二区三区在线观看| 成人综合在线观看| 欧美高清你懂得| 最新高清无码专区| 久久99精品国产91久久来源| 色婷婷久久久久swag精品| 欧美va亚洲va国产综合| 一区二区高清视频在线观看| 国产91丝袜在线播放0| 欧美一区二视频| 亚洲女人的天堂| 国产一区二区三区最好精华液| 在线观看日韩av先锋影音电影院| 欧美国产日韩精品免费观看| 欧美aⅴ一区二区三区视频| 一本久久a久久精品亚洲| 久久综合色综合88| 日本在线观看不卡视频| 色偷偷久久一区二区三区| 久久久国产精华| 日韩在线一二三区| 欧美在线视频全部完| 中文字幕一区二区三区不卡在线| 国产一区二区三区最好精华液 | 亚洲欧洲日韩综合一区二区| 国产九色精品成人porny| 欧美一区二区免费观在线| 一区二区在线观看av| 成人黄色片在线观看| 久久婷婷色综合| 免费高清在线一区| 91.成人天堂一区| 亚洲成人久久影院| 91久久精品一区二区| 综合欧美亚洲日本| av福利精品导航| 国产精品电影院| 99久久99久久精品免费观看| 精品久久99ma| 久久97超碰色| 日韩精品中文字幕在线一区| 美女视频黄久久| 欧美电影免费观看高清完整版| 美女www一区二区| 欧美成人性战久久| 免费成人在线影院| 精品国产一区二区三区久久影院| 久久精品国产亚洲aⅴ | 亚洲影视在线播放| 欧美中文字幕一区二区三区| 亚洲国产一二三| 欧美精品电影在线播放| 五月综合激情网| 欧美丰满高潮xxxx喷水动漫| 免费人成黄页网站在线一区二区| 日韩欧美中文字幕一区| 久久超碰97人人做人人爱| 欧美成人精品1314www| 黄色日韩网站视频| 国产欧美在线观看一区| av网站免费线看精品| 亚洲美女精品一区| 在线视频综合导航| 亚洲高清免费在线| 欧美成人一区二区三区在线观看| 国产乱码精品一品二品| 日本一区二区三区四区| 色综合久久久久久久久久久| 亚洲国产精品一区二区久久恐怖片| 3751色影院一区二区三区| 国产一区二区视频在线播放| 国产精品电影一区二区| 91国偷自产一区二区三区成为亚洲经典| 亚洲韩国精品一区| 日韩欧美一二三区| 成人福利视频在线| 亚洲一区免费在线观看| 日韩欧美的一区| 99麻豆久久久国产精品免费| 亚洲午夜一区二区三区| 精品国产一二三| 91浏览器在线视频| 日本中文字幕一区二区视频| 亚洲国产成人私人影院tom| 欧日韩精品视频| 韩国精品在线观看| 亚洲欧美日韩国产综合在线| 91精品蜜臀在线一区尤物| 国产精品中文欧美| 亚洲国产欧美日韩另类综合| 亚洲人成影院在线观看| 这里只有精品免费| 国产suv精品一区二区三区| 亚洲一区二区在线免费看| 26uuu国产一区二区三区| 色播五月激情综合网| 精品中文av资源站在线观看| 亚洲老司机在线| 欧美mv日韩mv| 在线视频欧美区| 国产精品一区二区三区99| 一区二区成人在线观看| 久久久夜色精品亚洲| 欧美体内she精视频| 国产精品一区免费在线观看| 亚洲成av人在线观看| 综合久久久久久| 精品国产一区二区三区av性色| 91极品视觉盛宴|