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

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

?? sdc.c

?? S3C2410平臺下藍牙編程與實驗
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*************************************************************************
*
*               Copyright Mentor Graphics Corporation 2003
*                         All Rights Reserved.
*
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
* SUBJECT TO LICENSE TERMS.
*
*************************************************************************/
/*************************************************************************
*
* FILE NAME                                     VERSION
*
*  sdc.c                                Nucleus PLUS\S3C2410X\ADS
*
* DESCRIPTION
*
*  This file contains the Serial Driver specific functions.
*
* DATA STRUCTURES
*
*  SD_PORT *       :   An array of pointers to serial port structures.
*
* FUNCTIONS
*
*  SDC_Init_Port
*  SDC_Date_Ready
*  SDC_Put_String
*  SDC_LISR
*  SDC_Get_Char
*  SDC_Put_Char
*  SDC_Set_Baud_Rate
*
* DEPENDENCIES
*
*  nucleus.h
*  sd_defs.h
*  sd_extr.h
*   target.h
* protocol.h
*  externs.h
*      ppp.h
*
*************************************************************************/
#include "sd_defs.h"
#include "sd_extr.h"
#include "def.h"


/* Define a small array to hold pointers to the two UART data
   structures. This is used by the LISR to find the correct
   data structure for the interrupt being handled. */
SD_PORT         *SDC_Port_List[SD_MAX_UARTS];

/* Define prototypes for functions local to this module. */
static  VOID    SDC_Set_Baud_Rate(UNSIGNED, SD_PORT *);

/************** Begin Board Specific Section ****************/

/************** End Board Specific Section **************/

/****************************************************************************
* FUNCTION
*
*    SDC_Init_Port
*
* DESCRIPTION
*
*    This function intializes the COM port that will be used for PPP
*    communications.
*
* CALLED BY
*
*    Application
*
* CALLS
*
*    NU_Local_Control_Interrupts
*    SDC_Set_Baud_Rate
*
* INPUTS
*
*    SD_PORT *     :   device initialization structure.
*
* OUTPUTS
*
*    STATUS        :   Returns NU_SUCCESS if successful initialization,
*                      else a negative value is returned.
*
****************************************************************************/
STATUS  SDC_Init_Port(SD_PORT *uart)
{


    STATUS      status = NU_SUCCESS;
    UINT32      temp32;
    UINT32      mode;
    UINT32      submsk;
    static INT  num_ports = 0;

    if (uart->communication_mode == SERIAL_MODE)
    {
        /* Check for max allowed UARTS. */
        if (num_ports >= SD_MAX_UARTS)

           /* We have already initialized the max allowed UARTS. */
           status = NU_UART_LIST_FULL;
    }

    if (status == NU_SUCCESS)
    {
        /* Check the supplied parity */
        if ((uart->parity != SD_PARITY_NONE) &&
             (uart->parity != SD_PARITY_EVEN) &&
             (uart->parity != SD_PARITY_ODD))

        /* The supplied parity is not valid */
        status = NU_INVALID_PARITY;

        /* Check the supplied number of data bits */
        else if ((uart->data_bits != SD_DATA_BITS_5) &&
                 (uart->data_bits != SD_DATA_BITS_6) &&
                 (uart->data_bits != SD_DATA_BITS_7) &&
                 (uart->data_bits != SD_DATA_BITS_8))

            /* The supplied data bits value is not valid */
            status = NU_INVALID_DATA_BITS;

        /* Check the supplied number of stop bits */
        else if ((uart->stop_bits != SD_STOP_BITS_1) &&
                 (uart->stop_bits != SD_STOP_BITS_2))

            /* The supplied stop bits value is not valid */
            status = NU_INVALID_STOP_BITS;

        /* Verify the baud rate is within acceptable range */
        else if ((uart->baud_rate < 1200) || (uart->baud_rate > 115200))

            /* The baud rate is out of range */
            status = NU_INVALID_BAUD;

    /************** Begin Board Specific Section ****************/

        /* Validate the com port. */
        else if ((uart->com_port == SD_UART0) ||
                 (uart->com_port == SD_UART1) ||
                 (uart->com_port == SD_UART2))
        {
            /* Handle UART0 */
            if (uart->com_port == SD_UART0)
            {
                /* Set the vector inside this structure */
                uart->vector = SD_UART0_VECTOR;

                /* Set the base address for this UART. */
                uart->base_address = SD_UART0_BASE;
            }
            /* Handle UART1. */
            else if (uart->com_port == SD_UART1)
            {
                /* Set the vector inside this structure */
                uart->vector = SD_UART1_VECTOR;

                /* Set the base address for this UART. */
                uart->base_address = SD_UART1_BASE;
            }
            /* Handle UART2. */
            else
            {
                /* Set the vector inside this structure */
                uart->vector = SD_UART2_VECTOR;

                /* Set the base address for this UART. */
                uart->base_address = SD_UART2_BASE;
            }

        }
        else

        /************** End Board Specific Section **************/

            /* Not a supported port. */
            status = NU_INVALID_COM_PORT;
    }

    if (uart->communication_mode == SERIAL_MODE)
    {
         /* Make sure all the above was completed. Then store off this
           UART stucture and initialize the chip. */
        if (status == NU_SUCCESS)
        {
            SDC_Port_List[num_ports++] = uart;

        }
    }

    if (status == NU_SUCCESS)
    {
        /* Allocate memory for the data buffers. PPP only requires a TX
           buffer so the allocation will be a little different for PPP mode. */
        if (status == NU_SUCCESS)
        {
            /* Setup the RX SD buffer */
            uart->rx_buffer_read = uart->rx_buffer_write = 0;

            uart->rx_buffer_status = NU_BUFFER_EMPTY;

          }
    }


    if (status == NU_SUCCESS)
    {
        /* Disable interrupts */
//        int_level = NU_Local_Control_Interrupts(NU_DISABLE_INTERRUPTS);

        /************** Begin Board Specific Section *************/

        /* Clear Control registers */
        SD_OUTDWORD (uart->base_address + SD_ULCON_OFFSET, 0);
        SD_OUTDWORD (uart->base_address + SD_UCON_OFFSET, 0);
        SD_OUTDWORD (uart->base_address + SD_UFCON_OFFSET, 0x00000000);
        SD_OUTDWORD (uart->base_address + SD_UMCON_OFFSET, 0x00000000);

        /* Setup baud rate */
        SDC_Set_Baud_Rate(uart->baud_rate, uart);

        /* Setup Mode, Parity, Stop Bits and Data Size in ULCON Reg. */
        SD_OUTBYTE (uart->base_address + SD_ULCON_OFFSET,
            (uart->parity | uart->data_bits | uart->stop_bits));

        /* Enable Rx and Tx in UCON register. */
        SD_OUTWORD (uart->base_address + SD_UCON_OFFSET,
            (SD_UCON_RX_ENABLE | SD_UCON_RX_INT_LEVEL | SD_UCON_TX_INT_LEVEL|SD_UCON_TX_ENABLE));

        /* Get characters from receiver until Receive Ready bit not set */
        do
        {
            temp32 = SD_INDWORD(uart->base_address + SD_URXH_OFFSET);

        /* Keep looping until RX ready bit not set */
        } while (SD_INDWORD(uart->base_address + SD_UTRSTAT_OFFSET) & SD_USTAT_RX_RDY);

        /* Get current interrupt controller mask register value */
        temp32 = SD_INDWORD (SD_INT_BASE + SD_INT_MSK_OFFSET);

        /* Get current interrupt controller mode register value */
        mode = SD_INDWORD (SD_INT_BASE + SD_INT_MOD_OFFSET);

        /* Get current interrupt sub mask register value */
        submsk = SD_INDWORD (SD_INT_BASE + SD_INT_SUBMSK_OFFSET);

        /* Unmask / set mode in interrupt controller */
        if (uart->com_port == SD_UART0)
        {
            /* Unmask UART0 interrupts (mask and submask) */
            temp32 &= ~SD_INT_UART0;
            submsk &=( ~(SD_INT_RXD0)|SD_INT_TXD0);

            /* Ensure mode bits are cleared first */
            mode &= ~SD_INT_UART0;

            /* Set mode bits based on define in SD_DEFS.H */
            mode |= (SD_INT_UART0 * SD_UART0_INT_MODE);
        }
        else if (uart->com_port == SD_UART1)   /* Otherwise handle UART1. */
        {
            /* Unmask UART1 interrupts */
            temp32 &= ~SD_INT_UART1;
            submsk &= (~(SD_INT_RXD1 )|SD_INT_TXD1);

            /* Ensure mode bits are cleared first */
            mode &= ~SD_INT_UART1;

            /* Set mode bits based on define in SD_DEFS.H */
            mode |= (SD_INT_UART1 * SD_UART1_INT_MODE);
        }
        else /* Otherwise handle UART2. */
        {
            /* Unmask Console UART interrupts */
            temp32 &= ~SD_INT_UART2;
            submsk &= (~(SD_INT_RXD2 )|SD_INT_TXD2);

            /* Ensure mode bits are cleared first */
            mode &= ~SD_INT_UART2;

            /* Set mode bits based on define in SD_DEFS.H */
            mode |= (SD_INT_UART2 * SD_UART2_INT_MODE);
        }

        /* Write updated mask register value back to interrupt controller */
        SD_OUTDWORD (SD_INT_BASE + SD_INT_MSK_OFFSET, temp32);

        /* Write updated mode register value back to interrupt controller */
        SD_OUTDWORD (SD_INT_BASE + SD_INT_MOD_OFFSET, mode);

        /* Write updated interrupt sub mask register value */
        SD_OUTDWORD (SD_INT_BASE + SD_INT_SUBMSK_OFFSET, submsk);

        /************** End Board Specific Section *************/

        /* Initialize the error counters. */
        SDC_Reset(uart);

    }



    /* Return status of initialization */
    return (status);
}


/****************************************************************************
* FUNCTION
*
*    SDC_Put_Char
*
* DESCRIPTION
*
*    This writes a character out to the serial port.
*
* CALLED BY
*
*    UART_Put_String
*    Application
*
* CALLS
*
*    Serial port macros
*
* INPUTS
*
*    UNSIGNED_CHAR :   Character to to be written to the serial port.
*    SD_PORT *     :   Serial port to send the char to.
*
* OUTPUTS
*
*    none
*
****************************************************************************/
VOID  SDC_Put_Char(UINT8 ch, SD_PORT *uart)
{
 
     /* Transmit the character */
    volatile int  status;
      SD_OUTDWORD (uart->base_address + SD_UTXH_OFFSET, ch);
      status = SD_INDWORD(uart->base_address + SD_UTRSTAT_OFFSET);
      while(!(status&0x4))
      {
      status = SD_INDWORD(uart->base_address + SD_UTRSTAT_OFFSET);
      }


}

/****************************************************************************
* FUNCTION
*
*    SDC_LISR
*
* DESCRIPTION
*
*    This is the entry function for the ISR that services the UART.
*
* CALLED BY
*
*    none
*
* CALLS
*
*    Serial port macros
*
* INPUTS
*
*    INT         :   Interrupt vector
*
* OUTPUTS
*
*    none
*
****************************************************************************/
VOID SDC_LISR(INT vector)
{
    SD_PORT         *uart;
    CHAR            receive;
    UINT32          status;
    INT             vector_found = NU_FALSE;
	
    	
    for(receive = 0 ; (SDC_Port_List[receive] != 0) &&
        (receive < SD_MAX_UARTS) && !vector_found ; receive++)
    {
        /* See if we found one. Better have since we got an interrupt
           from one. */
        if (SDC_Port_List[receive] -> vector == vector)
        {
            /* Point our local structure to it. */
            uart = SDC_Port_List[receive];
            vector_found =TRUE;
        }
    }

    /* Ensure vector was found */
    if (vector_found == TRUE)
    {
        /**************** Begin Board Specific Section **************/

        /* Get the uart status */
        status = SD_INDWORD(uart->base_address + SD_UTRSTAT_OFFSET);

        /* Check if receiver is ready - characters received */
        if (status & SD_USTAT_RX_RDY)
        {
            /* Get UART error status */
            status = SD_INDWORD (uart->base_address + SD_UERSTAT_OFFSET);

            /* Process every character in the receive FIFO */
            do
            {
                /* Clear any error bits */
                SD_OUTDWORD(uart->base_address + SD_UERSTAT_OFFSET,status);

                /* Get the received character from the receive holding register */
                receive = (UINT8)SD_INDWORD(uart->base_address + SD_URXH_OFFSET);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲激情在线激情| 国产99精品视频| 福利91精品一区二区三区| 欧美在线不卡视频| 中文幕一区二区三区久久蜜桃| 亚洲第一成年网| 91污片在线观看| 国产亚洲一本大道中文在线| 日韩不卡在线观看日韩不卡视频| 91亚洲永久精品| 欧美国产精品一区二区三区| 久久精品国产亚洲高清剧情介绍 | 久久精品国产免费| 在线观看日韩电影| 亚洲三级在线播放| 成人sese在线| 中文字幕久久午夜不卡| 国产精品影视网| 精品国产免费人成在线观看| 视频一区二区三区中文字幕| 欧美午夜在线观看| 一区二区三区精品视频| 99re热视频精品| 亚洲色图另类专区| 99re成人在线| 亚洲免费观看高清完整版在线| 99v久久综合狠狠综合久久| 国产精品视频麻豆| 99久久er热在这里只有精品15| 欧美激情在线看| 大胆亚洲人体视频| 国产精品视频九色porn| av高清久久久| 亚洲蜜臀av乱码久久精品蜜桃| 99国产一区二区三精品乱码| 亚洲男帅同性gay1069| 色综合久久88色综合天天| 一区二区三区欧美在线观看| 欧美在线你懂的| 香蕉久久一区二区不卡无毒影院 | 久久精品夜色噜噜亚洲aⅴ| 国产一区二区三区免费在线观看| 久久一区二区三区四区| 国产精品一区二区三区乱码| 国产欧美精品一区二区色综合朱莉| 国产在线精品不卡| 国产精品久久久久国产精品日日| jlzzjlzz国产精品久久| 亚洲综合色区另类av| 欧美日韩视频在线一区二区| 蜜桃久久久久久久| 久久久噜噜噜久久人人看| 不卡欧美aaaaa| 亚洲在线视频一区| 日韩免费高清av| 成人综合激情网| 亚洲一区二区欧美| 欧美变态口味重另类| 成人av在线电影| 亚洲国产精品一区二区久久恐怖片| 7777精品久久久大香线蕉| 国产一区二区三区精品欧美日韩一区二区三区 | 丝袜国产日韩另类美女| www国产精品av| 91女神在线视频| 免费精品视频在线| 国产精品美女视频| 7777精品伊人久久久大香线蕉超级流畅 | 日韩一区二区免费在线观看| 国产成人亚洲综合a∨婷婷| 一区二区三区**美女毛片| 日韩欧美一级二级| 一本大道久久a久久综合婷婷| 日本不卡视频一二三区| 亚洲欧美综合在线精品| 欧美一区二区三区视频在线观看| 成人午夜在线播放| 免费久久99精品国产| 亚洲精品videosex极品| 精品电影一区二区三区| 欧美在线观看视频在线| 国产麻豆精品95视频| 视频一区二区中文字幕| 亚洲精品老司机| 国产婷婷色一区二区三区| 欧美另类高清zo欧美| 99久久精品免费| 国产成人亚洲精品狼色在线 | 久久激情五月激情| 亚洲一区二区精品视频| 日韩一区在线免费观看| 久久久蜜桃精品| 欧美激情资源网| 欧美va在线播放| 91精品国产日韩91久久久久久| 91一区在线观看| thepron国产精品| 国产精品77777| 激情综合亚洲精品| 日韩国产在线一| 亚洲一区二三区| 一区二区理论电影在线观看| 亚洲人123区| 亚洲六月丁香色婷婷综合久久 | 亚洲国产综合色| 亚洲人亚洲人成电影网站色| 国产精品无人区| 中文字幕精品在线不卡| 国产欧美日韩精品a在线观看| 欧美精品一区二区三区高清aⅴ| 欧美日本一区二区在线观看| 欧美日韩在线播放一区| 欧美在线观看一区| 欧美日韩极品在线观看一区| 欧美性xxxxx极品少妇| 欧美午夜片在线看| 欧美日韩一级片在线观看| 欧美色涩在线第一页| 欧美日韩一级片在线观看| 欧美日韩在线播放一区| 5566中文字幕一区二区电影| 欧美一区二区三区视频在线| 欧美一区二区三区的| 精品久久久久久久久久久久包黑料| 日韩欧美精品在线| 欧美精品一区二区精品网| 久久综合久久综合亚洲| 日本一区二区视频在线观看| 国产精品美女久久久久久久网站| 亚洲人精品午夜| 婷婷国产在线综合| 另类小说视频一区二区| 国产精品一区二区果冻传媒| 成人av先锋影音| 欧美午夜影院一区| 欧美一区二区在线播放| 国产亚洲成av人在线观看导航| 国产精品丝袜一区| 亚洲mv大片欧洲mv大片精品| 精品一区二区三区视频在线观看| 粉嫩一区二区三区在线看| 日本乱人伦aⅴ精品| 91精品国产一区二区三区香蕉| 久久色.com| 亚洲激情欧美激情| 麻豆精品国产传媒mv男同| 91精品一区二区三区久久久久久| 日韩欧美色综合网站| 亚洲国产精品国自产拍av| 亚洲一区在线看| 国产中文字幕一区| 色婷婷av一区二区三区软件| 日韩欧美黄色影院| 亚洲色图欧洲色图婷婷| 蜜臀91精品一区二区三区| 99v久久综合狠狠综合久久| 日韩一区二区三区观看| 国产精品久久久久aaaa| 欧美a一区二区| 色综合色狠狠综合色| 精品久久久久99| 亚洲一区二区影院| 成人网在线播放| 日韩精品一区二区三区视频在线观看| 一区在线中文字幕| 国产一区在线看| 欧美亚洲国产bt| 国产精品理论片| 狠狠色丁香久久婷婷综合_中| 色菇凉天天综合网| 国产精品久久久久一区| 国产一区二区三区久久久| 欧美另类videos死尸| 亚洲欧洲精品一区二区三区不卡| 韩国视频一区二区| 777欧美精品| 亚洲成av人片观看| 91蜜桃免费观看视频| 国产欧美一区二区三区沐欲| 老司机一区二区| 欧美日高清视频| 亚洲一区av在线| 色偷偷久久人人79超碰人人澡 | 成人综合在线网站| 精品国产123| 久久精品国产亚洲aⅴ| 91精品国产综合久久小美女| 亚洲国产精品久久不卡毛片| 91亚洲精品久久久蜜桃网站 | www成人在线观看| 国内外精品视频| 日韩情涩欧美日韩视频| 日韩av一级电影| 欧美一区二区成人| 视频在线在亚洲| 欧美一卡2卡三卡4卡5免费| 日韩成人伦理电影在线观看| 7777精品久久久大香线蕉| 日本不卡的三区四区五区| 欧美一区二区三区视频|