📄 letextdef.h
字号:
/* +-------------------------------------------------------------------+ */
/* | Project : 1910.001 441GA01-T (External Reader RFID 125KHz) | */
/* | Module : LetExtDef.h | */
/* | Author : Lucio Faustinelli | */
/* | Company : AVE S.p.A. | */
/* | Released: June, 27 2008 | */
/* | Revision: YZ060.01 (FW - Revised) | */
/* | Revision: YZ062.00 (EEPROM - First Official Release) | */
/* | Revised : September, 04 2008 | */
/* | Revisor : AVE S.p.A. (Lucio FAUSTINELLI) | */
/* | Notes : -------------- | */
/* +-------------------------------------------------------------------+ */
/* | Purpose : This module contains definitions and all the function | */
/* | prototypes of the funtions used in this project | */
/* +-------------------------------------------------------------------+ */
/* | Functions: ----- | */
/* +-------------------------------------------------------------------+ */
/* +-------------------------------------------------------------------+ */
/* | I N C L U D E S | */
/* +-------------------------------------------------------------------+ */
// G L O B A L
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
/* +-------------------------------------------------------------------+ */
/* | D E F I N E S | */
/* +-------------------------------------------------------------------+ */
// C P U C l o c k
#ifndef F_CPU
#define F_CPU 11059200L
#endif
#define false 0
#define true ~false
#define PIN_CODE_AVE 0x815B24C8
#define CPU_SLEEP 1 /* put into power_down the CPU */
#define RF_POWER_DOWN 1 /* if one power down the RF when not used */
#define RF_ON_CARD 1 /* if zero card reader off */
#define PIN_DEBUG 1 /* if one setup pin output for debug */
#define RFBUFFER_SIZE 30 /* Buffer size for card reader (Max 31). Bits are 8 * RFBUFFER_SIZE */
// T I M E O U T S L A V E S
#define TIMEOUT_SLAVES 25
// L E D s & B U Z Z E R D E F I N I T I O N S
#define BUZZE 0x01 /* PC0 Buzzer pin on port B */
#define LED_BG 0x04 /* PA6 Bicolor LED (GREEN) - use "<< 4" */
#define LED_BR 0x08 /* PA7 Bicolor LED (RED) - use "<< 4" */
#define LED_Y 0x02 /* PB6 YELLOW LED pin on port B */
#define LED_R 0x01 /* PB7 RED LED pin on port B */
#define LED_L 0x80 /* PB5 Backlight LED for card zone on port B */
// O U T P U T D E F I N I T I O N S
#define OUT_ELETT 0x20 /* PA5 position (electro lock system), 1 = active */
#define OUT_LUCIC 0x10 /* PA4 position (courtesy light), 1 = active */
#define OUT_RING 0x08 /* PA3 position (Door bell), 1 = active */
#define OUT_INCLIE 0x02 /* PC1 position (DoNotDisturb repeater), 1 = active */
// I N P U T D E F I N I T I O N S
#define IN_STATOCAM 0x01 /* PA0 position (Room status) */
#define IN_LUCECORT 0x02 /* PA1 position (Courtesy button) */
#define IN_SUONE 0x04 /* PA2 position (Door bell button) */
// R S - 4 8 5 A D D R E S S E S
#define ADD_BROAD 0xFF /* Broadcast Address - All devices are selected */
#define ADD_PROGR 0x01 /* Programmaer Address */
#define ADD_CENTR 0x08 /* Room control unit Address */
#define ADD_LETEX 0x10 /* External Card Reader Address (myself) */
#define ADD_LETIN 0x20 /* Internal Card Reader Address */
#define ADD_TERMO 0x30 /* First Thermostat Address - Last one is 0x37 */
#define BUS_CMD_0 0x00
#define BUS_CMD_1 0x02
#define MY_485_ADD ADD_LETEX /* My Address - First byte in RX/TX frame */
// C O M P U T A B L E A D D R E S S E S
#define IS_M_PC_ADD 0x80 /* PC Address when is MASTER */
#define IS_M_CE_ADD 0x40 /* Room Control Unit Address when is MASTER */
#define IS_M_LE_ADD 0x10 /* External Card Reader Address when is MASTER (myself) */
// C A R D F I E L D S ( W o r d 1 9 - 4 3 r d B y t e )
#define CIS_NULL 0x00 /* No card detected */
#define CIS_CLIENTE 0x01 /* Cliente */
#define CIS_SUPERCLI 0x81 /* Cliente - Forza il numero nel lettore */
#define CIS_CAMERIR 0x02 /* Cameriera */
#define CIS_MANUTEN 0x03 /* Manutentore */
#define CIS_PASSEPA 0x04 /* Passe-partout */
#define CIS_SUPERGU 0x05 /* Super-guest */
#define CIS_MASTER 0x06 /* Master */
#define CIS_SUBMAST 0x07 /* Submaster o "Copia di Master" */
#define CIS_ERASER 0x08 /* Eraser */
// H A N D L E D R O O M T Y P E S ( O T H E R T H A N B E D R O O M S )
#define AREA_INIZIO_ACCSCA 24
#define NUM_AREA_ACCSCA 7
// E E P R O M D E F A U L T V A L U E S
#define EVEletOffOn 50
#define EVRFCardTOut 30
#define EVDlyRunTime 10
#define EVLuciOffOut 60
#define EVToutDoorbell 10
#define EVAlwaysDoorbell 1
#define EVMyAddress 0
/* +-------------------------------------------------------------------+ */
/* | M A C R O S | */
/* +-------------------------------------------------------------------+ */
/***********************************************************************
* \brief Send the login password to the transponder
* \param password The 32 bit password
* \return ERR_OK, ERR_LIW, ERR_N
***********************************************************************/
#define login_4550(password) sendWord_4550(password, 0x01)
/* +-------------------------------------------------------------------+ */
/* | E N U M E R A T I O N S | */
/* +-------------------------------------------------------------------+ */
typedef enum {
LD00 = 0, LD01, LD02, LD03, LD04, LD05, LD06, LD07, LD08, LD09,
LD10, LD11, LD12, LD13, LD14, LD15, LD16, LD17, LD18, LD19,
LD20, LD21, LD22, LD23, LD24, LD25, LD26, LD27, LD28, LD29,
LD30, LD31, LD32, LD33, LD34, LD35, LD36, LD37, LD38, LD39,
LD40, LD41, LD42, LD43
} led_num;
// RC_LI define some costand used in the system
enum RC_LI {
LI_IS_HIG = 1, /* received frame is from higt level, down me to slave */
LI_IS_LOW, /* frame is from lower level, other is master */
LI_IS_SLA, /* frame is a response form slave */
LI_IS_MY, /* frame is for me, down to slave mode */
IS_MASTER, /* when module is master */
IS_SLAVE, /* when module is slave and controlled from other master */
RF_IDLE, /* 07 - Card is present, read it */
RF_PRES, /* 08 - card read, analyze it */
RF_WAIT, /* 09 - wait action .. to be continue in the future */
RF_OKCK, /* 10 - card is correct and utente .. */
RF_CAMERIERA, /* 11 - card is cameriera .. */
RF_IS_C, /* 12 - card is validation "C" .. */
RF_MASTER, /* 13 - card is MASTER .. */
RF_AREECO, /* 14 - controlla accessi ad aree comuni */
RF_ACCSCA, /* 15 - controlla accessi a scalare */
RF_ERASER, /* 16 - card is ERASER */
MS_ONE, /* 17 - MASTER mode, create client, next 2 */
MS_TWO, /* 18 - MASTER mode, create cameriera, next 3 */
MS_THR, /* 19 - MASTER mode, create manutentore, next 4 */
MS_FOU, /* 20 - MASTER mode, create passepartout, next 5 */
MS_FIV, /* 21 - MASTER mode, create superguest, next 1 */
MS_SIX, /* 22 - MASTER mode, create master, next 7 */
MS_SEV, /* 23 - MASTER mode, create sub master, next 8*/
MS_EIG, /* 24 - MASTER mode, create eraser, next 6 */
MS_NIN, /* 25 - MASTER mode, mode camera, next 10 */
MS_TEN, /* 26 - MASTER mode, mode loc. serv., next 11 */
MS_ELE, /* 27 - MASTER mode, mode aree comuni, next 12 */
MS_TWE, /* 28 - MASTER mode, mode accessi scalare, next 9 */
MS_EXI, /* 29 - MASTER more, exit status. */
MO_CAMERA, /* 30 - MODE is camera */
MO_LOCSER, /* 31 - MODE is Locale servizi */
MO_AREECO, /* 32 - MODE is Aree Comuni */
MO_ACCSCA, /* 33 - MODE is Accesso Scalare */
IS_END_CODE
};
/* +-------------------------------------------------------------------+ */
/* | S T R U C T U R E S | */
/* +-------------------------------------------------------------------+ */
typedef struct {
uint8_t tm_sec; /* seconds after the minute - [0,59] */
uint8_t tm_min; /* minutes after the hour - [0,59] */
uint8_t tm_hour; /* hours since midnight - [0,23] */
uint8_t tm_mday; /* day of the month - [1,31] */
uint8_t tm_mon; /* months since January - [0,11] */
uint8_t tm_year; /* years since 2000 */
uint8_t tm_wday; /* days since Sunday - [0,6] */
} _TM_;
typedef struct {
unsigned RcardOK : 1; /* one when remote card is ok */
unsigned LcardOK : 1; /* one when local card is recognized */
unsigned cardON : 1; /* one when card is present */
unsigned cardUNK : 1; /* one when card is not recognized */
unsigned NonDist : 1; /* one when remote non disturbare is on */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -