⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 Jan 04, 2007 1. Add SPI support, see spi.h and spi.c 2. Add driver.h 3. Modified keyboard modu
💻 H
字号:
/** * Copyright (c) 2006-2008 iWESUN (ShenZhen) Inf. * All rights reserved.  *  * Redistribution and use in source and binary forms, with or without modification,  * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimer. * 2. 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. * 3. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission.  * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * This file is part of the AvrcX MTOS *  * Author: Winter Hu  <winter.hu@gmail.com> * Create: Nov 25, 2006 */#ifndef __COMMON_H__#define __COMMON_H__#if defined __AVR__ && __GNUC__#include <avr/io.h>#include <avr/interrupt.h>#endif /* __AVR__ && __GNUC__ */#include "arch.h"#ifndef NULL#define NULL 0#define null 0#endif#ifndef TRUE#define TRUE  1#define true  1#endif#ifndef FALSE#define FALSE 0#define false 0#endif#if !defined(_BV)#define _BV(b) (1<<b)#endif#if !defined(LO8)#define LO8(w) ((w) & 0x00FF)#endif#if !defined(HI8)#define HI8(w) (((w)>>8) & 0x00FF)#endif#ifndef __ASSEMBLER__/* These only work in C program */#define FLASH  __attribute__ ((progmem))#define EEPROM __attribute__ ((section(".eeprom")))#define NAKED  __attribute__ ((naked))#define CTASK  __attribute__ ((noreturn))#define ISVR   __attribute__ ((signal, naked))#define INTERFACE#define NAKEDFUNC(F) NAKED void F(void);#define CTASKFUNC(F) CTASK void F(void);#define __clrbit(A, b) A &= ~_BV(b)#define __setbit(A, b) A |=  _BV(b)#define __abs(v) (((v) < 0) ? (-v) : (v))typedef union union16 {  unsigned short W;  unsigned char  b[2];} union16;typedef union union32 {  unsigned long  L;  union16  w[2];  unsigned char b[4];} union32;#define lo8 b[0]#define hi8 b[1]#define lo16 w[0]#define hi16 w[1]#define b0 b[0]#define b1 b[1]#define b2 b[2]#define b3 b[3]typedef unsigned char bool;#endif /* !__ASSEMBLER__ */// #if defined __GNUC__/* These work in ASM program */#define _GLOBAL(Label, Size) .comm Label, Size#define _STATIC(Label, Size) .lcomm Label, Size#define _DATASECTION#define _CODESECTION#define _FUNCTION(A) \        .global A $  \	.func   A#define _ENDFUNC .endfunc#define _PUBLIC(A) .global A#define _EXTERN(A) .extern A#define _MODULE(A) .section .text#define _ENDMOD    .end#define _DB .asciz#define MACRO .macro#define ENDM  .endm#define _EQU(A, B) .set A, B#define _ALIGN .balign 2#define Xl      26#define Xh      27#define Yl      28#define Yh      29#define Zl      30#define Zh      31#define _p1l    24#define _p1h    25#define _p2l    22#define _p2h    23#define _p3l    20#define _p3h    21#define _p4l    18#define _p4h    19#define _r1l    24#define _r1h    25#define _r2l    22#define _r2h    23#define _tmp1   18#define _tmp2   19#define _tmp3   20#define _tmp4   21#define __temp_reg__ 0    // R0 is a temp register in GCC#define __zero_reg__ 1    // R1 always is 0 in GCC// #endif /* __GNUC__ */#endif /* __COMMON_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -