?? rd_usevirtualport.h
字號(hào):
#ifndef _USE_VIRTUAL_PORT_H_
#define _USE_VIRTUAL_PORT_H_
/***********************************************************
* 函數(shù)說明:硬件SPI虛擬端口底層驅(qū)動(dòng)函數(shù)庫 *
* 版本: v1.00 *
* 作者: 王卓然 *
* 創(chuàng)建日期:2006年7月30日 *
* -------------------------------------------------------- *
* [支持庫] *
* 支持庫名稱:RD_MacroAndConst.h *
* 需要版本: v0.04 &abv *
* 函數(shù)庫說明:系統(tǒng)常用宏定義庫 *
* -------------------------------------------------------- *
* [版本更新] *
* -------------------------------------------------------- *
* [版本歷史] *
* v1.00 支持595和165成隊(duì)及聯(lián),支持硬件SPI傳輸模式, *
* 支持通過宏定義設(shè)定虛擬端口數(shù)量;虛擬端口同 *
* 時(shí)支持讀取和寫兩種模式,并且兼容AVR普通端 *
* 口的操作方式,支持虛擬端口位操作。 *
* -------------------------------------------------------- *
* [使用說明] *
* 1、調(diào)用該頭文件之前,可以通過宏VP_PORT_COUNT *
* 來設(shè)定虛擬端口的數(shù)目,這里的數(shù)目8個(gè)引腳算 *
* 一個(gè)端口。 *
* 2、通過宏VP_SS來設(shè)定SS腳,這里需要位操作支持。 *
* 3、將宏VIRTUALPORT_INSERT_SPI_STC_ISR_CODE插 *
* 入到SPI通訊完成中斷處理程序中。 *
* 4、虛擬端口從PORTH和PINH開始,每次需要刷新端 *
* 口時(shí)只需要調(diào)用宏REFRESH_VIRTUAL_PORT,特別 *
* 說明,在中斷處理程序里面調(diào)用該宏時(shí)要打開全 *
* 局中斷SEI(); *
***********************************************************/
# include <RD_MacroAndConst.h>
/********************
* 系 統(tǒng) 宏 定 義 *
********************/
/*------------------*
* 常 數(shù) 宏 定 義 *
*------------------*/
#ifndef VP_PORT_COUNT
#define VP_PORT_COUNT 2
#endif
#if VP_PORT_COUNT-1 >= 0
# define PORTH (*((volatile unsigned char *)&VP_PORTx[0]))
# define PINH (*((volatile unsigned char *)&VP_PINx[0]))
#endif
#if VP_PORT_COUNT-2 >= 0
# define PORTI (*((volatile unsigned char *)&VP_PORTx[1]))
# define PINI (*((volatile unsigned char *)&VP_PINx[1]))
#endif
#if VP_PORT_COUNT-3 >= 0
# define PORTJ (*((volatile unsigned char *)&VP_PORTx[2]))
# define PINJ (*((volatile unsigned char *)&VP_PINx[2]))
#endif
#if VP_PORT_COUNT-4 >= 0
# define PORTK (*((volatile unsigned char *)&VP_PORTx[3]))
# define PINK (*((volatile unsigned char *)&VP_PINx[3]))
#endif
#if VP_PORT_COUNT-5 >= 0
# define PORTL (*((volatile unsigned char *)&VP_PORTx[4]))
# define PINL (*((volatile unsigned char *)&VP_PINx[4]))
#endif
#if VP_PORT_COUNT-6 >= 0
# define PORTM (*((volatile unsigned char *)&VP_PORTx[5]))
# define PINM (*((volatile unsigned char *)&VP_PINx[5]))
#endif
#if VP_PORT_COUNT-7 >= 0
# define PORTN (*((volatile unsigned char *)&VP_PORTx[6]))
# define PINN (*((volatile unsigned char *)&VP_PINx[6]))
#endif
#if VP_PORT_COUNT-8 >= 0
# define PORTO (*((volatile unsigned char *)&VP_PORTx[7]))
# define PINO (*((volatile unsigned char *)&VP_PINx[7]))
#endif
#if VP_PORT_COUNT-9 >= 0
# define PORTP (*((volatile unsigned char *)&VP_PORTx[8]))
# define PINP (*((volatile unsigned char *)&VP_PINx[8]))
#endif
#if VP_PORT_COUNT-10 >= 0
# define PORTQ (*((volatile unsigned char *)&VP_PORTx[9]))
# define PINQ (*((volatile unsigned char *)&VP_PINx[9]))
#endif
#if VP_PORT_COUNT-11 >= 0
# define PORTR (*((volatile unsigned char *)&VP_PORTx[10]))
# define PINR (*((volatile unsigned char *)&VP_PINx[10]))
#endif
#if VP_PORT_COUNT-12 >= 0
# define PORTS (*((volatile unsigned char *)&VP_PORTx[11]))
# define PINS (*((volatile unsigned char *)&VP_PINx[11]))
#endif
#if VP_PORT_COUNT-13 >= 0
# define PORTT (*((volatile unsigned char *)&VP_PORTx[12]))
# define PINT (*((volatile unsigned char *)&VP_PINx[12]))
#endif
#if VP_PORT_COUNT-14 >= 0
# define PORTU (*((volatile unsigned char *)&VP_PORTx[13]))
# define PINU (*((volatile unsigned char *)&VP_PINx[13]))
#endif
#if VP_PORT_COUNT-15 >= 0
# define PORTV (*((volatile unsigned char *)&VP_PORTx[14]))
# define PINV (*((volatile unsigned char *)&VP_PINx[14]))
#endif
#if VP_PORT_COUNT-16 >= 0
# define PORTW (*((volatile unsigned char *)&VP_PORTx[15]))
# define PINW (*((volatile unsigned char *)&VP_PINx[15]))
#endif
#if VP_PORT_COUNT-17 >= 0
# define PORTX (*((volatile unsigned char *)&VP_PORTx[16]))
# define PINX (*((volatile unsigned char *)&VP_PINx[16]))
#endif
#if VP_PORT_COUNT-18 >= 0
# define PORTY (*((volatile unsigned char *)&VP_PORTx[17]))
# define PINY (*((volatile unsigned char *)&VP_PINx[17]))
#endif
#if VP_PORT_COUNT-19 >= 0
# define PORTZ (*((volatile unsigned char *)&VP_PORTx[18]))
# define PINZ (*((volatile unsigned char *)&VP_PINx[18]))
#endif
#ifdef PORTH
# define PORTH_BIT SET_BIT8_FORMAT(PORTH)
#endif
#ifdef PORTI
# define PORTI_BIT SET_BIT8_FORMAT(PORTI)
#endif
#ifdef PORTJ
# define PORTJ_BIT SET_BIT8_FORMAT(PORTJ)
#endif
#ifdef PORTK
# define PORTK_BIT SET_BIT8_FORMAT(PORTK)
#endif
#ifdef PORTL
# define PORTL_BIT SET_BIT8_FORMAT(PORTL)
#endif
#ifdef PORTM
# define PORTM_BIT SET_BIT8_FORMAT(PORTM)
#endif
#ifdef PORTN
# define PORTN_BIT SET_BIT8_FORMAT(PORTN)
#endif
#ifdef PORTO
# define PORTO_BIT SET_BIT8_FORMAT(PORTO)
#endif
#ifdef PORTP
# define PORTP_BIT SET_BIT8_FORMAT(PORTP)
#endif
#ifdef PORTQ
# define PORTQ_BIT SET_BIT8_FORMAT(PORTQ)
#endif
#ifdef PORTR
# define PORTR_BIT SET_BIT8_FORMAT(PORTR)
#endif
#ifdef PORTS
# define PORTS_BIT SET_BIT8_FORMAT(PORTS)
#endif
#ifdef PORTT
# define PORTT_BIT SET_BIT8_FORMAT(PORTT)
#endif
#ifdef PORTU
# define PORTU_BIT SET_BIT8_FORMAT(PORTU)
#endif
#ifdef PORTV
# define PORTV_BIT SET_BIT8_FORMAT(PORTV)
#endif
#ifdef PORTW
# define PORTW_BIT SET_BIT8_FORMAT(PORTW)
#endif
#ifdef PORTX
# define PORTX_BIT SET_BIT8_FORMAT(PORTX)
#endif
#ifdef PORTY
# define PORTY_BIT SET_BIT8_FORMAT(PORTY)
#endif
#ifdef PORTZ
# define PORTZ_BIT SET_BIT8_FORMAT(PORTZ)
#endif
#ifdef PINH
# define PINH_BIT SET_BIT8_FORMAT(PINH)
#endif
#ifdef PINI
# define PINI_BIT SET_BIT8_FORMAT(PINI)
#endif
#ifdef PINJ
# define PINJ_BIT SET_BIT8_FORMAT(PINJ)
#endif
#ifdef PINK
# define PINK_BIT SET_BIT8_FORMAT(PINK)
#endif
#ifdef PINL
# define PINL_BIT SET_BIT8_FORMAT(PINL)
#endif
#ifdef PINM
# define PINM_BIT SET_BIT8_FORMAT(PINM)
#endif
#ifdef PINN
# define PINN_BIT SET_BIT8_FORMAT(PINN)
#endif
#ifdef PINO
# define PINO_BIT SET_BIT8_FORMAT(PINO)
#endif
#ifdef PINP
# define PINP_BIT SET_BIT8_FORMAT(PINP)
#endif
#ifdef PINQ
# define PINQ_BIT SET_BIT8_FORMAT(PINQ)
#endif
#ifdef PINR
# define PINR_BIT SET_BIT8_FORMAT(PINR)
#endif
#ifdef PINS
# define PINS_BIT SET_BIT8_FORMAT(PINS)
#endif
#ifdef PINT
# define PINT_BIT SET_BIT8_FORMAT(PINT)
#endif
#ifdef PINU
# define PINU_BIT SET_BIT8_FORMAT(PINU)
#endif
#ifdef PINV
# define PINV_BIT SET_BIT8_FORMAT(PINV)
#endif
#ifdef PINW
# define PINW_BIT SET_BIT8_FORMAT(PINW)
#endif
#ifdef PINX
# define PINX_BIT SET_BIT8_FORMAT(PINX)
#endif
#ifdef PINY
# define PINY_BIT SET_BIT8_FORMAT(PINY)
#endif
#ifdef PINZ
# define PINZ_BIT SET_BIT8_FORMAT(PINZ)
#endif
#ifdef PORTH
# define _PH0 PORTH_BIT.BIT0
# define _PH1 PORTH_BIT.BIT1
# define _PH2 PORTH_BIT.BIT2
# define _PH3 PORTH_BIT.BIT3
# define _PH4 PORTH_BIT.BIT4
# define _PH5 PORTH_BIT.BIT5
# define _PH6 PORTH_BIT.BIT6
# define _PH7 PORTH_BIT.BIT7
#endif
#ifdef PORTI
# define _PI0 PORTI_BIT.BIT0
# define _PI1 PORTI_BIT.BIT1
# define _PI2 PORTI_BIT.BIT2
# define _PI3 PORTI_BIT.BIT3
# define _PI4 PORTI_BIT.BIT4
# define _PI5 PORTI_BIT.BIT5
# define _PI6 PORTI_BIT.BIT6
# define _PI7 PORTI_BIT.BIT7
#endif
#ifdef PORTJ
# define _PJ0 PORTJ_BIT.BIT0
# define _PJ1 PORTJ_BIT.BIT1
# define _PJ2 PORTJ_BIT.BIT2
# define _PJ3 PORTJ_BIT.BIT3
# define _PJ4 PORTJ_BIT.BIT4
# define _PJ5 PORTJ_BIT.BIT5
# define _PJ6 PORTJ_BIT.BIT6
# define _PJ7 PORTJ_BIT.BIT7
#endif
#ifdef PORTK
# define _PK0 PORTK_BIT.BIT0
# define _PK1 PORTK_BIT.BIT1
# define _PK2 PORTK_BIT.BIT2
# define _PK3 PORTK_BIT.BIT3
# define _PK4 PORTK_BIT.BIT4
# define _PK5 PORTK_BIT.BIT5
# define _PK6 PORTK_BIT.BIT6
# define _PK7 PORTK_BIT.BIT7
#endif
#ifdef PORTL
# define _PL0 PORTL_BIT.BIT0
# define _PL1 PORTL_BIT.BIT1
# define _PL2 PORTL_BIT.BIT2
# define _PL3 PORTL_BIT.BIT3
# define _PL4 PORTL_BIT.BIT4
# define _PL5 PORTL_BIT.BIT5
# define _PL6 PORTL_BIT.BIT6
# define _PL7 PORTL_BIT.BIT7
#endif
#ifdef PORTM
# define _PM0 PORTM_BIT.BIT0
# define _PM1 PORTM_BIT.BIT1
# define _PM2 PORTM_BIT.BIT2
# define _PM3 PORTM_BIT.BIT3
# define _PM4 PORTM_BIT.BIT4
# define _PM5 PORTM_BIT.BIT5
# define _PM6 PORTM_BIT.BIT6
# define _PM7 PORTM_BIT.BIT7
#endif
#ifdef PORTN
# define _PN0 PORTN_BIT.BIT0
# define _PN1 PORTN_BIT.BIT1
# define _PN2 PORTN_BIT.BIT2
# define _PN3 PORTN_BIT.BIT3
# define _PN4 PORTN_BIT.BIT4
# define _PN5 PORTN_BIT.BIT5
# define _PN6 PORTN_BIT.BIT6
# define _PN7 PORTN_BIT.BIT7
#endif
#ifdef PORTO
# define _PO0 PORTO_BIT.BIT0
# define _PO1 PORTO_BIT.BIT1
# define _PO2 PORTO_BIT.BIT2
# define _PO3 PORTO_BIT.BIT3
# define _PO4 PORTO_BIT.BIT4
# define _PO5 PORTO_BIT.BIT5
# define _PO6 PORTO_BIT.BIT6
# define _PO7 PORTO_BIT.BIT7
#endif
#ifdef PORTP
# define _PP0 PORTP_BIT.BIT0
# define _PP1 PORTP_BIT.BIT1
# define _PP2 PORTP_BIT.BIT2
# define _PP3 PORTP_BIT.BIT3
# define _PP4 PORTP_BIT.BIT4
# define _PP5 PORTP_BIT.BIT5
# define _PP6 PORTP_BIT.BIT6
# define _PP7 PORTP_BIT.BIT7
#endif
#ifdef PORTQ
# define _PQ0 PORTQ_BIT.BIT0
# define _PQ1 PORTQ_BIT.BIT1
# define _PQ2 PORTQ_BIT.BIT2
# define _PQ3 PORTQ_BIT.BIT3
# define _PQ4 PORTQ_BIT.BIT4
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -