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

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

?? atomic.h

?? 在WinAVR下的ST7565圖形點陣的驅(qū)動程序
?? H
字號:
/* Copyright (c) 2007 Dean Camera
   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 following disclaimer.

   * Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
     distribution.

   * Neither the name of the copyright holders nor the names of
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/

/* $Id: atomic.h,v 1.3 2007/12/20 14:17:56 joerg_wunsch Exp $ */

#ifndef _UTIL_ATOMIC_H_
#define _UTIL_ATOMIC_H_ 1

#include <avr/io.h>
#include <avr/interrupt.h>

#if !defined(__DOXYGEN__)
/* Internal helper functions. */
static __inline__ uint8_t __iSeiRetVal(void)
{
    sei();
    return 1;
}

static __inline__ uint8_t __iCliRetVal(void)
{
    cli();
    return 1;
}

static __inline__ void __iSeiParam(const uint8_t *__s)
{
    sei();
    __asm__ volatile ("" ::: "memory");
    (void)__s;
}

static __inline__ void __iCliParam(const uint8_t *__s)
{
    cli();
    __asm__ volatile ("" ::: "memory");
    (void)__s;
}

static __inline__ void __iRestore(const  uint8_t *__s)
{
    SREG = *__s;
    __asm__ volatile ("" ::: "memory");
}
#endif	/* !__DOXYGEN__ */

/** \file */
/** \defgroup util_atomic <util/atomic.h> Atomically and Non-Atomically Executed Code Blocks

    \code
    #include <util/atomic.h>
    \endcode

    \note The macros in this header file require the ISO/IEC 9899:1999
    ("ISO C99") feature of for loop variables that are declared inside
    the for loop itself.  For that reason, this header file can only
    be used if the standard level of the compiler (option --std=) is
    set to either \c c99 or \c gnu99.

    The macros in this header file deal with code blocks that are
    guaranteed to be excuted Atomically or Non-Atmomically.  The term
    "Atomic" in this context refers to the unability of the respective
    code to be interrupted.

    These macros operate via automatic manipulation of the Global
    Interrupt Status (I) bit of the SREG register. Exit paths from
    both block types are all managed automatically without the need
    for special considerations, i. e. the interrupt status will be
    restored to the same value it has been when entering the
    respective block.

    A typical example that requires atomic access is a 16 (or more)
    bit variable that is shared between the main execution path and an
    ISR.  While declaring such a variable as volatile ensures that the
    compiler will not optimize accesses to it away, it does not
    guarantee atomic access to it.  Assuming the following example:

    \code
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/io.h>

volatile uint16_t ctr;

ISR(TIMER1_OVF_vect)
{
  ctr--;
}

...
int
main(void)
{
   ...
   ctr = 0x200;
   start_timer();
   while (ctr != 0)
     // wait
       ;
   ...
}
    \endcode

    There is a chance where the main context will exit its wait loop
    when the variable \c ctr just reached the value 0xFF.  This happens
    because the compiler cannot natively access a 16-bit variable
    atomically in an 8-bit CPU.  So the variable is for example at
    0x100, the compiler then tests the low byte for 0, which succeeds.
    It then proceeds to test the high byte, but that moment the ISR
    triggers, and the main context is interrupted.  The ISR will
    decrement the variable from 0x100 to 0xFF, and the main context
    proceeds.  It now tests the high byte of the variable which is
    (now) also 0, so it concludes the variable has reached 0, and
    terminates the loop.

    Using the macros from this header file, the above code can be
    rewritten like:

    \code
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/atomic.h>

volatile uint16_t ctr;

ISR(TIMER1_OVF_vect)
{
  ctr--;
}

...
int
main(void)
{
   ...
   ctr = 0x200;
   start_timer();
   sei();
   uint16_t ctr_copy;
   do
   {
     ATOMIC_BLOCK(ATOMIC_FORCEON)
     {
       ctr_copy = ctr;
     }
   }
   while (ctr_copy != 0);
   ...
}
    \endcode

    This will install the appropriate interrupt protection before
    accessing variable \c ctr, so it is guaranteed to be consistently
    tested.  If the global interrupt state were uncertain before
    entering the ATOMIC_BLOCK, it should be executed with the
    parameter ATOMIC_RESTORESTATE rather than ATOMIC_FORCEON.

*/

/** \def ATOMIC_BLOCK(type)
    \ingroup util_atomic

    Creates a block of code that is guaranteed to be executed
    atomically. Upon entering the block the Global Interrupt Status
    flag in SREG is disabled, and re-enabled upon exiting the block
    from any exit path.

    Two possible macro parameters are permitted, ATOMIC_RESTORESTATE
    and ATOMIC_FORCEON.
*/
#if defined(__DOXYGEN__)
#define ATOMIC_BLOCK(type)
#else
#define ATOMIC_BLOCK(type) for ( type, __ToDo = __iCliRetVal(); \
	                       __ToDo ; __ToDo = 0 )
#endif	/* __DOXYGEN__ */

/** \def NONATOMIC_BLOCK(type)
    \ingroup util_atomic

    Creates a block of code that is executed non-atomically. Upon
    entering the block the Global Interrupt Status flag in SREG is
    enabled, and disabled upon exiting the block from any exit
    path. This is useful when nested inside ATOMIC_BLOCK sections,
    allowing for non-atomic execution of small blocks of code while
    maintaining the atomic access of the other sections of the parent
    ATOMIC_BLOCK.

    Two possible macro parameters are permitted,
    NONATOMIC_RESTORESTATE and NONATOMIC_FORCEOFF.
*/
#if defined(__DOXYGEN__)
#define NONATOMIC_BLOCK(type)
#else
#define NONATOMIC_BLOCK(type) for ( type, __ToDo = __iSeiRetVal(); \
	                          __ToDo ;  __ToDo = 0 )
#endif	/* __DOXYGEN__ */

/** \def ATOMIC_RESTORESTATE
    \ingroup util_atomic

    This is a possible parameter for ATOMIC_BLOCK. When used, it will
    cause the ATOMIC_BLOCK to restore the previous state of the SREG
    register, saved before the Global Interrupt Status flag bit was
    disabled. The net effect of this is to make the ATOMIC_BLOCK's
    contents guaranteed atomic, without changing the state of the
    Global Interrupt Status flag when execution of the block
    completes.
*/
#if defined(__DOXYGEN__)
#define ATOMIC_RESTORESTATE
#else
#define ATOMIC_RESTORESTATE uint8_t sreg_save \
	__attribute__((__cleanup__(__iRestore))) = SREG
#endif	/* __DOXYGEN__ */

/** \def ATOMIC_FORCEON
    \ingroup util_atomic

    This is a possible parameter for ATOMIC_BLOCK. When used, it will
    cause the ATOMIC_BLOCK to force the state of the SREG register on
    exit, enabling the Global Interrupt Status flag bit. This saves on
    flash space as the previous value of the SREG register does not
    need to be saved at the start of the block.

    Care should be taken that ATOMIC_FORCEON is only used when it is
    known that interrupts are enabled before the block's execution or
    when the side effects of enabling global interrupts at the block's
    completion are known and understood.
*/
#if defined(__DOXYGEN__)
#define ATOMIC_FORCEON
#else
#define ATOMIC_FORCEON uint8_t sreg_save \
	__attribute__((__cleanup__(__iSeiParam))) = 0
#endif	/* __DOXYGEN__ */

/** \def NONATOMIC_RESTORESTATE
    \ingroup util_atomic

    This is a possible parameter for NONATOMIC_BLOCK. When used, it
    will cause the NONATOMIC_BLOCK to restore the previous state of
    the SREG register, saved before the Global Interrupt Status flag
    bit was enabled. The net effect of this is to make the
    NONATOMIC_BLOCK's contents guaranteed non-atomic, without changing
    the state of the Global Interrupt Status flag when execution of
    the block completes.
*/
#if defined(__DOXYGEN__)
#define NONATOMIC_RESTORESTATE
#else
#define NONATOMIC_RESTORESTATE uint8_t sreg_save \
	__attribute__((__cleanup__(__iRestore))) = SREG
#endif	/* __DOXYGEN__ */

/** \def NONATOMIC_FORCEOFF
    \ingroup util_atomic

    This is a possible parameter for NONATOMIC_BLOCK. When used, it
    will cause the NONATOMIC_BLOCK to force the state of the SREG
    register on exit, disabling the Global Interrupt Status flag
    bit. This saves on flash space as the previous value of the SREG
    register does not need to be saved at the start of the block.

    Care should be taken that NONATOMIC_FORCEOFF is only used when it
    is known that interrupts are disabled before the block's execution
    or when the side effects of disabling global interrupts at the
    block's completion are known and understood.
*/
#if defined(__DOXYGEN__)
#define NONATOMIC_FORCEOFF
#else
#define NONATOMIC_FORCEOFF uint8_t sreg_save \
	__attribute__((__cleanup__(__iCliParam))) = 0
#endif	/* __DOXYGEN__ */

#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品中文字幕一区二区三区| 国产成人在线视频网站| 久久亚洲一区二区三区四区| av在线播放成人| 水野朝阳av一区二区三区| 国产日韩亚洲欧美综合| 欧美人伦禁忌dvd放荡欲情| 岛国av在线一区| 青草av.久久免费一区| 一区二区三区中文字幕电影| 国产欧美一区二区精品久导航| 91精品久久久久久久99蜜桃| 色狠狠一区二区三区香蕉| 国产成人激情av| 美女在线观看视频一区二区| 亚洲国产综合91精品麻豆| 国产精品国产三级国产普通话三级 | 91视频你懂的| 国产乱子伦一区二区三区国色天香 | 欧美精选一区二区| 99国产麻豆精品| 国产成人av一区二区| 国产在线精品国自产拍免费| 奇米精品一区二区三区四区| 亚洲不卡av一区二区三区| 亚洲精品免费在线观看| 国产精品美女久久久久av爽李琼| 久久久精品日韩欧美| 欧美xxxxx裸体时装秀| 91精品欧美久久久久久动漫 | 精品欧美一区二区在线观看| 欧美高清www午色夜在线视频| 色婷婷av一区二区三区软件| gogogo免费视频观看亚洲一| 成人av在线资源网站| 成人国产在线观看| 日韩精品一区二区三区在线| 欧美日本乱大交xxxxx| 欧美性xxxxxxxx| 在线精品视频一区二区三四| 欧美自拍偷拍午夜视频| 91久久国产综合久久| 欧美影院一区二区| 日本韩国欧美一区二区三区| 欧美在线你懂的| 欧美日韩成人综合天天影院| 欧美区视频在线观看| 欧美伦理影视网| 欧美一区二区在线不卡| 欧美电视剧免费全集观看| 精品处破学生在线二十三| 久久久午夜精品| 国产精品成人一区二区艾草| 亚洲精品视频在线| 亚洲一区二区美女| 天天色综合成人网| 久久精品99国产精品| 国产精品中文字幕欧美| 成人小视频在线| 91极品美女在线| 91精品国模一区二区三区| 精品国产乱码久久久久久久久| 久久理论电影网| 亚洲女同女同女同女同女同69| 亚洲一区二区三区四区的| 免费观看日韩电影| 国产寡妇亲子伦一区二区| 99视频精品全部免费在线| 欧美色中文字幕| 精品国精品国产| 国产精品久久久久一区二区三区共| 亚洲欧美日韩精品久久久久| 日韩在线a电影| 国产成人av一区二区三区在线观看| 91丝袜国产在线播放| 欧美一区二区三区免费大片| 中文字幕乱码亚洲精品一区| 国产成人精品亚洲777人妖| 91久久一区二区| 2020国产精品久久精品美国| 亚洲男人天堂av| 麻豆国产欧美一区二区三区| 99久久综合精品| 欧美一个色资源| 最新国产成人在线观看| 美国一区二区三区在线播放| 91麻豆国产福利在线观看| 日韩一区二区高清| 亚洲欧美日韩系列| 国内精品第一页| 欧美视频中文字幕| 国产亚洲欧美色| 视频一区中文字幕国产| 成人免费毛片app| 日韩一区二区三区在线| 国产精品久久久久久久久图文区| 蜜臀va亚洲va欧美va天堂| 色88888久久久久久影院按摩| 26uuuu精品一区二区| 爽好久久久欧美精品| av网站免费线看精品| 精品国产乱码久久久久久牛牛| 一区二区久久久久| 成人app网站| 久久蜜桃一区二区| 日韩制服丝袜av| 在线精品视频免费观看| 中文字幕欧美日韩一区| 久久 天天综合| 91精品国产综合久久婷婷香蕉| 亚洲精品国产高清久久伦理二区| 国产精品综合网| 一区二区三区成人在线视频| 国产成人久久精品77777最新版本| 91精品在线免费| 亚洲一区二区三区爽爽爽爽爽| a美女胸又www黄视频久久| 26uuu亚洲综合色欧美| 蜜臀a∨国产成人精品| 欧美伦理电影网| 亚洲尤物在线视频观看| 色久综合一二码| 亚洲日本一区二区| 大白屁股一区二区视频| 久久久精品欧美丰满| 韩日av一区二区| 欧美本精品男人aⅴ天堂| 蜜臀av性久久久久av蜜臀妖精 | 久久精品免视看| 久久99最新地址| 精品国产91乱码一区二区三区| 免费美女久久99| 日韩亚洲电影在线| 久久精品国内一区二区三区| 91精品国产高清一区二区三区| 石原莉奈一区二区三区在线观看 | 欧美一级午夜免费电影| 三级久久三级久久久| 欧美军同video69gay| 亚洲成人www| 欧美人与性动xxxx| 日韩av午夜在线观看| 日韩一级视频免费观看在线| 精品在线观看视频| 久久综合色天天久久综合图片| 久久97超碰色| 国产午夜三级一区二区三| 成人午夜激情在线| 亚洲视频狠狠干| 日本高清不卡视频| 大胆亚洲人体视频| 综合在线观看色| 欧美亚洲国产怡红院影院| 首页国产欧美久久| 2014亚洲片线观看视频免费| 国产激情91久久精品导航| 国产精品久久久久久久午夜片| 色婷婷综合久久久中文一区二区| 亚洲香蕉伊在人在线观| 欧美一级在线视频| 国产高清精品久久久久| 亚洲卡通欧美制服中文| 欧美日本一区二区| 国内精品免费**视频| 18成人在线观看| 欧美丰满美乳xxx高潮www| 国产在线播放一区二区三区| 一区二区中文视频| 在线播放/欧美激情| 国产福利一区二区三区| 亚洲综合一区二区三区| 精品日韩99亚洲| 99精品视频在线播放观看| 日韩高清不卡一区| 国产日韩影视精品| 欧美日韩和欧美的一区二区| 国内欧美视频一区二区| 亚洲精品国产一区二区精华液| 日韩色在线观看| 99精品久久99久久久久| 轻轻草成人在线| 最新国产精品久久精品| 日韩三级电影网址| 91麻豆国产福利在线观看| 精品一区二区三区免费观看| 自拍偷拍亚洲激情| 欧美xxxxxxxx| 欧美在线观看视频在线| 国产精品99精品久久免费| 亚洲福利一区二区| 国产精品理论片在线观看| 欧美猛男gaygay网站| 福利一区二区在线观看| 日韩电影在线观看电影| 亚洲免费观看高清完整版在线观看熊 | 欧美午夜精品久久久久久超碰| 国产精品一区免费视频| 日韩电影在线看| 亚洲综合视频在线| 亚洲欧洲日韩综合一区二区|