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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? pio.c

?? AT91SAM9263的USB Device端口驅(qū)動
?? C
字號:
/* ----------------------------------------------------------------------------
 *         ATMEL Microcontroller Software Support  -  ROUSSET  -
 * ----------------------------------------------------------------------------
 * Copyright (c) 2006, Atmel Corporation

 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the disclaimer below.
 *
 * - Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the disclaimer below in the documentation and/or
 * other materials provided with the distribution.
 *
 * Atmel's name may not be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ----------------------------------------------------------------------------
 */

//------------------------------------------------------------------------------
//         Headers
//------------------------------------------------------------------------------

#include "pio.h"
#include <board.h>

//------------------------------------------------------------------------------
//         Internal definitions
//------------------------------------------------------------------------------
/// \internal Returns the current value of a register.
#define READ(peripheral, register)          (peripheral->register)
/// \internal Modifies the current value of a register.
#define WRITE(peripheral, register, value)  (peripheral->register = value)

//------------------------------------------------------------------------------
//         Internal functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Configures one or more pin(s) of a PIO controller as being controlled by
/// peripheral A. Optionally, the corresponding internal pull-up(s) can be
/// enabled.
/// \param pio  Pointer to a PIO controller.
/// \param mask  Bitmask of one or more pin(s) to configure.
/// \param enablePullUp  Indicates if the pin(s) internal pull-up shall be
///                      configured.
//------------------------------------------------------------------------------
static void PIO_SetPeripheralA(AT91S_PIO *pio,
                               unsigned int mask,
                               unsigned char enablePullUp)
{
    // Disable interrupts on the pin(s)
    WRITE(pio, PIO_IDR, mask);

    // Enable the pull-up(s) if necessary
    if (enablePullUp) {

        WRITE(pio, PIO_PPUER, mask);
    }
    else {

        WRITE(pio, PIO_PPUDR, mask);
    }

    // Configure pin
    WRITE(pio, PIO_ASR, mask);
    WRITE(pio, PIO_PDR, mask);
}

//------------------------------------------------------------------------------
/// Configures one or more pin(s) of a PIO controller as being controlled by
/// peripheral A. Optionally, the corresponding internal pull-up(s) can be
/// enabled.
/// \param pio  Pointer to a PIO controller.
/// \param mask  Bitmask of one or more pin(s) to configure.
/// \param enablePullUp  Indicates if the pin(s) internal pull-up shall be
///                      configured.
//------------------------------------------------------------------------------
static void PIO_SetPeripheralB(AT91S_PIO *pio,
                               unsigned int mask,
                               unsigned char enablePullUp)
{
    // Disable interrupts on the pin(s)
    WRITE(pio, PIO_IDR, mask);

    // Enable the pull-up(s) if necessary
    if (enablePullUp) {

        WRITE(pio, PIO_PPUER, mask);
    }
    else {

        WRITE(pio, PIO_PPUDR, mask);
    }

    // Configure pin
    WRITE(pio, PIO_BSR, mask);
    WRITE(pio, PIO_PDR, mask);
}

//------------------------------------------------------------------------------
/// Configures one or more pin(s) or a PIO controller as inputs. Optionally,
/// the corresponding internal pull-up(s) and glitch filter(s) can be
/// enabled.
/// \param pio  Pointer to a PIO controller.
/// \param mask  Bitmask indicating which pin(s) to configure as input(s).
/// \param enablePullUp  Indicates if the internal pull-up(s) must be enabled.
/// \param enableFilter  Indicates if the glitch filter(s) must be enabled.
//------------------------------------------------------------------------------
static void PIO_SetInput(AT91S_PIO *pio,
                         unsigned int mask,
                         unsigned char enablePullUp,
                         unsigned char enableFilter)
{
    // Disable interrupts
    WRITE(pio, PIO_IDR, mask);

    // Enable pull-up(s) if necessary
    if (enablePullUp) {
    
        WRITE(pio, PIO_PPUER, mask);
    }
    else {
    
        WRITE(pio, PIO_PPUDR, mask);
    }

    // Enable filter(s) if necessary
    if (enableFilter) {
    
        WRITE(pio, PIO_IFER, mask);
    }
    else {
    
        WRITE(pio, PIO_IFDR, mask);
    }

    // Configure pin as input
    WRITE(pio, PIO_ODR, mask);
    WRITE(pio, PIO_PER, mask);
}

//------------------------------------------------------------------------------
/// Configures one or more pin(s) of a PIO controller as outputs, with the
/// given default value. Optionally, the multi-drive feature can be enabled
/// on the pin(s).
/// \param pio  Pointer to a PIO controller.
/// \param mask  Bitmask indicating which pin(s) to configure.
/// \param defaultValue  Default level on the pin(s).
/// \param enableMultiDrive  Indicates if the pin(s) shall be configured as
///                          open-drain.
/// \param enablePullUp  Indicates if the pin shall have its pull-up activated.
//------------------------------------------------------------------------------
static void PIO_SetOutput(AT91S_PIO *pio,
                          unsigned int mask,
                          unsigned char defaultValue,
                          unsigned char enableMultiDrive,
                          unsigned char enablePullUp)
{
    // Disable interrupts
    WRITE(pio, PIO_IDR, mask);

    // Enable pull-up(s) if necessary
    if (enablePullUp) {
    
        WRITE(pio, PIO_PPUER, mask);
    }
    else {
    
        WRITE(pio, PIO_PPUDR, mask);
    }

    // Enable multi-drive if necessary
    if (enableMultiDrive) {
    
        WRITE(pio, PIO_MDER, mask);
    }
    else {
    
        WRITE(pio, PIO_MDDR, mask);
    }

    // Set default value
    if (defaultValue) {

        WRITE(pio, PIO_SODR, mask);
    }
    else {

        WRITE(pio, PIO_CODR, mask);
    }

    // Configure pin(s) as output(s)
    WRITE(pio, PIO_OER, mask);
    WRITE(pio, PIO_PER, mask);
}

//------------------------------------------------------------------------------
//         Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Configures a list of Pin instances, which can either hold a single pin or a 
/// group of pins, depending on the mask value; all pins are configured by this 
/// function.
/// Returns 1 if the configuration has been performed successfully; otherwise 0.
/// \param list  Pointer to a list of Pin instances.
/// \param size  Size of the Pin list (see <PIO_LISTSIZE>).
//------------------------------------------------------------------------------
unsigned char PIO_Configure(const Pin *list, unsigned int size)
{
    // Configure pins
    while (size > 0) {
    
        switch (list->type) {
    
            case PIO_PERIPH_A:
                PIO_SetPeripheralA(list->pio,
                                   list->mask,
                                   (list->attribute & PIO_PULLUP) ? 1 : 0);
                break;
    
            case PIO_PERIPH_B:
                PIO_SetPeripheralB(list->pio,
                                   list->mask,
                                   (list->attribute & PIO_PULLUP) ? 1 : 0);
                break;
    
            case PIO_INPUT:
                AT91C_BASE_PMC->PMC_PCER = 1 << list->id;
                PIO_SetInput(list->pio,
                             list->mask,
                             (list->attribute & PIO_PULLUP) ? 1 : 0,
                             (list->attribute & PIO_DEGLITCH)? 1 : 0);
                break;
    
            case PIO_OUTPUT_0:
            case PIO_OUTPUT_1:
                PIO_SetOutput(list->pio,
                              list->mask,
                              (list->type == PIO_OUTPUT_1),
                              (list->attribute & PIO_OPENDRAIN) ? 1 : 0,
                              (list->attribute & PIO_PULLUP) ? 1 : 0);
                break;
    
            default: return 0;
        }

        list++;
        size--;
    }

    return 1;
}

//------------------------------------------------------------------------------
/// Sets a high output level on one or more pin(s) (if configured as output(s)).
/// \param pin  Pointer to a Pin instance describing one or more pins.
//------------------------------------------------------------------------------
void PIO_Set(const Pin *pin)
{
    WRITE(pin->pio, PIO_SODR, pin->mask);
}

//------------------------------------------------------------------------------
/// Sets a low output level on one or more pin(s) (if configured as output(s)).
/// \param pin  Pointer to a Pin instance describing one or more pins.
//------------------------------------------------------------------------------
void PIO_Clear(const Pin *pin)
{
    WRITE(pin->pio, PIO_CODR, pin->mask);
}

//------------------------------------------------------------------------------
/// Returns 1 if one or more PIO of the given Pin instance currently have a high
/// level; otherwise returns 0.
/// \param pin  Pointer to a Pin instance describing one or more pins.
//------------------------------------------------------------------------------
unsigned char PIO_Get(const Pin *pin)
{
    unsigned int reg;
    if ((pin->type == PIO_OUTPUT_0) || (pin->type == PIO_OUTPUT_1)) {

        reg = READ(pin->pio, PIO_ODSR);
    }
    else {

        reg = READ(pin->pio, PIO_PDSR);
    }

    if ((reg & pin->mask) == 0) {

        return 0;
    }
    else {

        return 1;
    }
}


//------------------------------------------------------------------------------
/// Returns 1 if one or more PIO of the given Pin data to be driven on the I/O line
/// level; otherwise returns 0.
/// \param pin  Pointer to a Pin instance describing one or more pins.
//------------------------------------------------------------------------------
unsigned char PIO_GetOutputDataStatus(const Pin *pin)
{
    if ((READ(pin->pio, PIO_ODSR) & pin->mask) == 0) {

        return 0;
    }
    else {

        return 1;
    }
}

//------------------------------------------------------------------------------
/// Returns the value of ISR for the PIO controller of the pin.
/// Reading this register acknoledges all the ITs.
/// \param pin  Pointer to a Pin instance describing one or more pins.
//------------------------------------------------------------------------------
unsigned int PIO_GetISR(const Pin *pin)
{
    return (READ(pin->pio, PIO_ISR));
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美三区在线观看| 一本色道综合亚洲| 精品91自产拍在线观看一区| 日本美女一区二区三区| 欧美一级国产精品| 黄一区二区三区| 国产清纯美女被跳蛋高潮一区二区久久w| 另类欧美日韩国产在线| www国产成人| 成人高清视频在线| 自拍偷拍国产精品| 在线国产电影不卡| 性做久久久久久免费观看欧美| 欧美日韩精品免费观看视频 | 麻豆成人在线观看| 2021久久国产精品不只是精品| 国产精品中文字幕欧美| 一色屋精品亚洲香蕉网站| 91啪亚洲精品| 天天综合日日夜夜精品| 精品成人佐山爱一区二区| 国产91露脸合集magnet| 亚洲伦理在线精品| 91精品视频网| 国产精品自拍在线| 亚洲欧美另类图片小说| 欧美一区二区二区| 99免费精品视频| 五月天丁香久久| 久久精品在线观看| 欧美日韩电影在线播放| 乱中年女人伦av一区二区| 欧美高清在线一区二区| 在线观看一区不卡| 久88久久88久久久| 亚洲免费在线观看| 欧美tickling挠脚心丨vk| 99久久精品久久久久久清纯| 亚洲一二三区视频在线观看| 久久综合精品国产一区二区三区| 色婷婷激情一区二区三区| 美女在线观看视频一区二区| 亚洲精品网站在线观看| 精品国产乱码久久久久久图片| 色88888久久久久久影院野外| 久久er99热精品一区二区| 亚洲综合小说图片| 中文乱码免费一区二区| 欧美二区乱c少妇| 成人综合婷婷国产精品久久免费| 日日摸夜夜添夜夜添精品视频| 中文字幕av免费专区久久| 欧美一区二区视频在线观看2020| 99久久国产免费看| 国产精品1区2区| 全国精品久久少妇| 亚洲v精品v日韩v欧美v专区| 亚洲欧洲日韩在线| 国产午夜精品久久久久久久| 精品剧情在线观看| 91精品国产综合久久精品性色| 成人av综合一区| 国产成人a级片| 久久激情五月婷婷| 三级成人在线视频| 亚洲午夜电影在线| 一区二区三区欧美视频| 国产精品国产a级| 日本一二三四高清不卡| 久久嫩草精品久久久精品| 欧美一区二区三区在线电影| 欧美日韩精品一区二区天天拍小说 | 久久久精品免费观看| 91精品国产综合久久精品| 欧美日韩在线直播| 欧美亚洲综合久久| 91福利国产成人精品照片| 91丝袜高跟美女视频| 91蜜桃网址入口| 91麻豆视频网站| 色综合天天综合狠狠| 91色.com| 欧美系列亚洲系列| 欧美综合一区二区| 欧美色图免费看| 欧美精品aⅴ在线视频| 欧美一区中文字幕| 精品欧美黑人一区二区三区| 日韩女优电影在线观看| 欧美精品一区二区久久久 | 精品sm捆绑视频| 久久亚洲一区二区三区明星换脸| 精品国产污网站| ww亚洲ww在线观看国产| 欧美激情综合五月色丁香小说| 中文字幕av一区二区三区免费看 | 天堂午夜影视日韩欧美一区二区| 亚洲一线二线三线久久久| 亚洲成人av一区二区三区| 日韩av中文在线观看| 精品一区二区日韩| 国产成人av电影免费在线观看| 成人h动漫精品一区二区| 色婷婷综合久久久久中文| 欧美精品视频www在线观看| 日韩免费一区二区三区在线播放| 久久综合五月天婷婷伊人| 国产精品电影一区二区| 亚洲高清免费视频| 国产一区二区成人久久免费影院| 国产91精品精华液一区二区三区| 91麻豆swag| 欧美一级日韩免费不卡| 亚洲国产岛国毛片在线| 亚洲一区二区视频| 国产一区亚洲一区| 日本精品一区二区三区四区的功能| 欧美剧在线免费观看网站| 2020国产精品自拍| 亚洲国产成人精品视频| 国产伦精一区二区三区| 色94色欧美sute亚洲线路一ni | 中文字幕一区二区三区在线播放| 亚洲精品免费电影| 麻豆视频一区二区| 91首页免费视频| 精品久久久久久久久久久久久久久 | 亚洲人成在线播放网站岛国 | 一区二区三区高清在线| 韩国视频一区二区| 欧美三级一区二区| 国产欧美日韩不卡免费| 婷婷久久综合九色综合绿巨人| 国产乱子伦一区二区三区国色天香| 一本到三区不卡视频| wwww国产精品欧美| 五月天中文字幕一区二区| 国产精品2024| 日韩你懂的在线播放| 亚洲国产日日夜夜| 99精品国产91久久久久久| 日韩欧美一级在线播放| 亚洲柠檬福利资源导航| 国产99一区视频免费 | 99视频有精品| 亚洲精品一区二区三区精华液| 亚洲国产视频网站| 91在线视频播放地址| 国产午夜精品久久| 精品在线播放免费| 91精品国产综合久久久久久| 亚洲精品视频一区二区| 99re这里只有精品6| 中文字幕国产一区| 国产黄色91视频| 精品国产一二三| 日韩精品亚洲一区二区三区免费| 91麻豆精品秘密| 国产精品国产自产拍高清av | www激情久久| 久久av老司机精品网站导航| 4438x成人网最大色成网站| 亚洲网友自拍偷拍| 欧美午夜一区二区三区免费大片| 国产精品久久国产精麻豆99网站| 国产成人免费视频网站| 国产欧美日韩在线观看| 国产精品影视在线观看| 亚洲精品一区二区三区四区高清| 青青草原综合久久大伊人精品 | 中文字幕一区二区在线观看| 国产成人在线看| 国产精品色呦呦| 成人一区二区视频| 国产精品久99| 色婷婷精品久久二区二区蜜臂av| 最近中文字幕一区二区三区| 一本一道波多野结衣一区二区 | 婷婷中文字幕综合| 欧美酷刑日本凌虐凌虐| 日本va欧美va精品发布| 日韩欧美一区二区免费| 国产精品伊人色| 国产精品视频一二三| 色综合久久中文字幕综合网 | 国产精品伦理一区二区| 91麻豆福利精品推荐| 亚洲一二三专区| 欧美一区二区三区日韩视频| 久久91精品国产91久久小草| 久久久蜜桃精品| av在线播放成人| 亚洲动漫第一页| 精品国产三级电影在线观看| 国产福利精品一区| 一区二区三区精品视频| 日韩视频一区二区三区| 丁香另类激情小说| 一区二区在线免费| 欧美电视剧免费观看|