📄 common.h
字号:
#ifndef COMMON_H
#define COMMON_H
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include <util/twi.h>
#include <avr/pgmspace.h>
#include <string.h>
#include <stdio.h>
#include <compat/deprecated.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long int
#define FREQ 1
#define SER_PORT PORTD
#define SER_DAT PD4
#define SER_RCK PD5
#define SER_SCK PD6
//液晶
#define LCD_CS PORTC &=~_BV(PC2)
#define LCD_CS_OFF PORTC |= _BV(PC2)
uchar Pin;
// K_Line使用
uchar g_bTxdPos;
uchar g_bTxdLen;
uchar g_bRxdPos;
uchar g_bRxdLen ;
uchar g_aSendBuf[16];
uchar g_aRecvBuf[16];
//
//Blue_Tootle使用
uchar Blue_g_bTxdPos;
uchar Blue_g_bTxdLen;
uchar Blue_g_bRxdPos;
uchar Blue_g_bRxdLen ;
uchar Blue_g_aSendBuf[16];
uchar Blue_g_aRecvBuf[16];
//
//CAN使用
//===========================================================
// -------------- MCU LIB CONFIGURATION
#define FOSC 8000 // 8 MHz External cristal
#define F_CPU (FOSC*1000) // Need for AVR GCC
//===========================================================
typedef unsigned char Bool;
typedef unsigned char U8 ;
typedef unsigned short U16;
typedef unsigned long U32;
typedef unsigned long long U64;
typedef signed char S8 ;
typedef signed short S16;
typedef signed long S32;
typedef signed long long S64;
typedef union
{
U16 h ; // h as HALF-WORD
U8 b[2]; // b as BYTE
} Union16;
typedef union
{
U32 w ; // w as WORD
U16 h[2]; // h as HALF-WORD
U8 b[4]; // b as BYTE
} Union32;
typedef union
{
U64 d ; // d as DOUBLE-WORD
U32 w[2]; // w as WORD
U16 h[4]; // h as HALF-WORD
U8 b[8]; // b as BYTE
} Union64;
//_____ M A C R O S ____________________________________________________________
#define Max(a, b) ( (a)>(b) ? (a) : (b) )
#define Min(a, b) ( (a)<(b) ? (a) : (b) )
#define Align_up(val, n) ( ((val)+(n)-1) & ~((n)-1) )
#define Align_down(val, n) ( (val) & ~((n)-1) )
//! Bit and bytes manipulations
#define Low(data_w) ((U8)data_w)
#define High(data_w) ((U8)(data_w>>8))
#define Tst_bit_x(addrx,mask) (*addrx & mask)
#define Set_bit_x(addrx,mask) (*addrx = (*addrx | mask))
#define Clr_bit_x(addrx,mask) (*addrx = (*addrx & ~mask))
//! The default value to initialise pointers
#define NULL ((void *)0)
//! Constants
#define ENABLE 1
#define ENABLED 1
#define DISABLED 0
#define DISABLE 0
#define FALSE (0==1)
#define TRUE (1==1)
#define KO 0
#define OK 1
#define CLR 0
#define SET 1
#define OFF 0
#define ON 1
// -------------- CAN LIB CONFIGURATION
#define CAN_BAUDRATE 500 // in kBit
//#define CAN_BAUDRATE CAN_AUTOBAUD
// -------------- MISCELLANEOUS
// Using TIMER_2 as RTC
#define USE_TIMER8 TIMER8_2
//==============================================================
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -