?? software.h
字號(hào):
/*********************************************************************
微 雪 電 子 WaveShare http://www.waveShare.net
目 的: 建立AVR的軟件提取庫,增加各類補(bǔ)丁,方便系統(tǒng)程序移植
目標(biāo)系統(tǒng): 基于AVR單片機(jī)
應(yīng)用軟件: ICCAVR
版 本: Version 1.0
圓版時(shí)間: 2005-06-25
開發(fā)人員: SEE
說 明: 若用于商業(yè)用途,請(qǐng)保留此段文字或注明代碼來源
深 圳 微 雪 電 子 保 留 所 有 的 版 權(quán)
*********************************************************************/
/*01010101010101010101010101010101010101010101010101010101010101010101
----------------------------------------------------------------------
版本更新記錄:
----------------------------------------------------------------------
入口參數(shù)說明:
----------------------------------------------------------------------
待定參數(shù)說明:
----------------------------------------------------------------------
對(duì)外變量說明:
----------------------------------------------------------------------
對(duì)外函數(shù)說明:
----------------------------------------------------------------------
10101010101010101010101010101010101010101010101010101010101010101010*/
#ifndef Software_H
#define Software_H
#include <math.h>
#include <string.h>
/* 兼容一般程序員的常用寫法 */
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef signed char schar;
typedef signed int sint;
typedef signed long slong;
/* 為方便移植,建議使用下面寫法 */
typedef unsigned char bool;
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;
typedef signed char sint8;
typedef signed int sint16;
typedef signed long sint32;
typedef signed char int8;
typedef signed int int16;
typedef signed long int32;
/* 下面寫法一般不推薦 */
//typedef unsigned char ubyte;
//typedef unsigned int uword;
//typedef unsigned long udword;
//typedef signed char sbyte;
//typedef signed int sword;
//typedef signed long sdword;
/* 一般程序定義的默認(rèn)值 */
//#define NULL 0
//#define EOF -1
//#define TRUE 1
//#define FALSE 0
//#define YES 1
//#define NO 0
//#define ON 1
//#define OFF 0
//#define ENABLE 1
//#define DISABLE 0
//#define CRR 1
//#define ERR 0
//#define RIGHT 1
//#define WRONG 0
//#define SUCCESS 1
//#define FAILURE 0
//#define PI 3.1415926 //3.1415926535897932
/* 如果你手頭上的RAM實(shí)在很緊,不如嘗試下面的define~ */
//#define _CALLOC(a) ( (a *)calloc(n,sizeof(a)) )
//#define _MALLOC(a) ( (a *)malloc(sizeof(a)) )
//#define _MIN(a,b) ( (a) < (b) ? (a) : (b) )
//#define _MAX(a,b) ( (a) > (b) ? (a) : (b) )
//#define _EXCHANGE(a,b) { int t; t=a; a=b; b=t; }
//#define _TOLOWER(c) ( (c)+32 )
//#define _TOUPPER(c) ( (c)-32 )
//#ifndef BIT
//#define BIT(x) ( 1<<(x) )
//#endif
/*--------------------------------------------------------------------
函數(shù)全稱:數(shù)據(jù)拆字
函數(shù)功能:
注意事項(xiàng):D<=999999,C<=6
提示說明:調(diào)用speaData(12,2),得到dataElem[0]=2,dataElem[1]=1
輸 入:
返 回:無
--------------------------------------------------------------------*/
uint8 dataElem[6];
void speaData(uint32 dat,sint8 len)
{
uint8 i;
uint32 j,y;
for(i=0,j=1;i<len;i++)
{
y=dat/j;
dataElem[i]=y%10;
j*=10;
}
}
/*--------------------------------------------------------------------
函數(shù)全稱:十進(jìn)制強(qiáng)制轉(zhuǎn)換為十六進(jìn)制
函數(shù)功能:
注意事項(xiàng):
提示說明:調(diào)用changeIntToHex(33),return 0x33
輸 入:
返 回:
--------------------------------------------------------------------*/
#define changeIntToHex(dec) ( ( ((dec)/10) <<4 ) + ((dec)%10) )
/*--------------------------------------------------------------------
函數(shù)全稱:十進(jìn)制化為十六進(jìn)制,并以十進(jìn)制格式返回
函數(shù)功能:
注意事項(xiàng):傳參必須為 unsigned 類型,否則移位結(jié)果可能嚇你一跳
提示說明:調(diào)用converseIntToHex(33),return 21
輸 入:
返 回:
--------------------------------------------------------------------*/
#define converseIntToHex(dec) ( ( ((dec)>>4) *10 ) + ((dec)%16) )
/*--------------------------------------------------------------------
函數(shù)全稱:十六進(jìn)制強(qiáng)制轉(zhuǎn)換為十進(jìn)制
函數(shù)功能:
注意事項(xiàng):傳參必須為 unsigned 類型,否則移位結(jié)果可能嚇你一跳
提示說明:調(diào)用changeHexToInt(0x33),return 33
輸 入:
返 回:
--------------------------------------------------------------------*/
#define changeHexToInt(hex) ( ( ((hex)>>4) *10 ) + ((hex)%16) )
/*--------------------------------------------------------------------
函數(shù)全稱:十六進(jìn)制化為十進(jìn)制,,并以十六進(jìn)制格式返回
函數(shù)功能:
注意事項(xiàng):
提示說明:調(diào)用converseHexToInt(0x33),return 0x51
輸 入:
返 回:
--------------------------------------------------------------------*/
#define converseHexToInt(hex) ( ( ((hex)/10) <<4 ) + ((hex)%10) )
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -