📄 card.h
字号:
//card.h : header file for the card project
//
#ifndef _CARD_H_
#define _CARD_H_
#include <io.h>
#include <wdt.h>
#include <sleep.h>
#include <Interrupt.h>
#include <inttypes.h>
#include <stdbool.h>
#define ATMEG16
//#define FM_CUP 1
//#define FM_CUP_RECORD 1
#define FM_CUP_BLUETOOTH 1
//#define FM_CUP_RECORD_BLUETOOTH 1
//#define AUTH_PROT_VER10
#define AUTH_PROT_VER20
/////////////////////////////////////////////////////////////////////////////
//card
//Time constant define
#define MS_10 1
#define MS_20 2
#define MS_30 3
#define MS_70 7
#define MS_80 8
#define MS_50 5
#define MS_60 6
#define MS_100 10
#define MS_110 11
#define MS_120 12
#define MS_150 15
#define MS_200 20
#define MS_300 30
#define MS_400 40
#define MS_410 41
#define MS_430 43
#define MS_500 50
#define MS_600 60
#define MS_800 80
#define MS_1000 100
//#define MS_1300 130
#define MS_1500 150
#define MS_2000 200
#define MS_2200 220
#define MS_2500 250
#define MS_3000 300
#define MS_4000 400
#define MS_5000 500
#define MS_6000 600
#define MS_20000 2000
#define MS_30000 3000
#define MS_45000 4500
#define MS_55000 5500
#define MS_60000 6000
//Logic value define
#define TRUE 1
#define FALSE 0
#define UART_RECEIVE 0x10
//#define UART_WAIT_RECEIVE 0x20
#define UART_IS_RECEIVING 0x20
#define UART_RECEIVE_ONE_PACKET 0x40
#define UART_RECEIVE_ERROR_PACKET 0x80
//UART bit define
//UCSRA define
#define RE_RXC0 0x80
#define RE_TXC0 0x40
#define RE_UDRE0 0x20
//UCSRB bit define
#define RE_RXEN0 0x10
#define RE_RXCIE0 0x80
#define RE_TXEN0 0x08
#define RE_TXCIE0 0x40
#define RE_UDRIE0 0x20
#if defined(AUTH_PROT_VER10)
#define TX_BUFF_LEN 65
#endif
#if defined(AUTH_PROT_VER20)
#define TX_BUFF_LEN 515
#endif
#define RX_BUFF_LEN 7
#define RX_BUFF1_LEN 25
#define TX_BUFF1_EMPTY 0x10
#define TX_BUFF1_FULL 0x20
#define TX_BUFF2_EMPTY 0x10
#define TX_BUFF2_FULL 0x20
#define TX_RETRY_COUNTS 0x04
#define IDENTIFY_RETRY_COUNTS 0x04
#define ACK_AUTHENTICATION_STATUS_COUNTS 2
#define BT_RX_BUFF_LENG 20
#define BT_TX_BUFF_LENG 5
#define ADC_DATA_LEN 5
#define ADC_DATA 240
#define ADC_DATA1 0x69
#define ADC_DATA2 0x4d
#define ADC_DATA3 0x33
#define ADC_DATA4 0x17
#define ADC_DATA5 0
#define KEY_CODE 0
#define KEY_CODE1 1
#define KEY_CODE2 2
#define KEY_CODE3 3
#define KEY_CODE4 4
#define KEY_CODE5 5
#define KEY_CODE6 6
#define KEY_CODE7 7
#define KEY_CODE8 8
#define KEY_CODE9 9
#define KEY_CODE10 10
#define KEY_CODE11 11
#define KEY_CODE12 12
#define KEY_CODE13 13
#define KEY_CODE14 14
#define KEY_CODE15 15
#define KEY_CODE16 16
#define KEY_CODE17 17
#define KEY_CODE18 18
#define KEY_CODE19 19
#define KEY_CODE20 20
#define KEY_CODE21 21
#define KEY_CODE22 22
#define KEY_CODE23 23
//Key const define
#define KEY_MASK 0x38
#define KEY_PRIVACY KEY_CODE1
#define KEY_UP KEY_CODE2
#define KEY_DOWN KEY_CODE3
#define KEY_RECORD KEY_CODE4
#define KEY_PLAY_PAUSE KEY_CODE5
/////
////FM KEY STATUS
#define KEY_FQ_MODE_SET KEY_CODE6
#define KEY_ON_OFF KEY_CODE7
#define KEY_HAND_UP KEY_CODE8
#define KEY_HAND_DOWN KEY_CODE9
#define KEY_FM_UP KEY_CODE10
#define KEY_FM_DOWN KEY_CODE11
#define KEY_COMM_ON KEY_CODE12
#define KEY_PRIVACY_ON KEY_CODE13
#define KEY_MODE_CHANGE KEY_CODE14
#define KEY_OFF_BLUETOOTH KEY_CODE15
#define KEY_MCU_OFF KEY_CODE16
//// IPOD KEY SATUS
#define KEY_IPOD_NEXT KEY_CODE17
#define KEY_IPOD_BACK KEY_CODE18
#define KEY_IPOD_DOWNP KEY_CODE19
#define KEY_IPOD_UP KEY_CODE20
#define KEY_IPOD_STAUS KEY_CODE21
#define KEY_IPOD_ENTER KEY_CODE22
#define KEY_IPOD_MENU KEY_CODE23
///////////
#define NEXT_TRACK 0x00000008 //0x08000000
#define PREVIOUS_TRACK 0x00000001 //0x10000000
#define UP_ARROW 0x00010000 //0x00000100
#define DOWN_ARROW 0x02000000 //0x00000002
#define MENU 0x00020000 //0x00000200
#define PLAY 0x00000100 //0x00010000
#define PAUSE 0x00000200 //0x00020000
//iPod power status
#define LIGHT_SLEEP 0x03
#define POWER_ON 0x04
//ADC channal define
#define ADC_CHANNAL_7 0x07
/*
extern unsigned char bGetMonoImageLimits;
extern unsigned char UartReceive;
extern unsigned char UDRBuff;
extern unsigned char TxBuff[TX_BUFF_LEN];
extern volatile unsigned int wTxByteNumber;
extern volatile unsigned int wTxByteCounts;
extern volatile unsigned char TxBuffCounts;
extern volatile unsigned char TxCheckSum;
extern volatile unsigned char TxBuff1State;
extern volatile unsigned char TxBuff2State;
//extern volatile unsigned char TxBuffEmpty;
extern unsigned char RxBuff[RX_BUFF_LEN];
extern unsigned char RxBuff1[RX_BUFF1_LEN];
extern unsigned char RxPayloadLength;
extern unsigned char RxByteCounts;
extern unsigned char RxCheckSum;
extern volatile unsigned char KeyValue;
extern volatile unsigned char bKeyUse;
extern unsigned char KeyBuff;
extern volatile unsigned char bPressKey;
extern unsigned char bReleaseKey;
extern unsigned char bFastChange;
extern unsigned char FastChangeTime;
extern volatile unsigned int ImageDisplayTime;
extern volatile unsigned char RxTimeOut;
extern volatile unsigned char WriteFMControlDelay;
extern volatile unsigned char iPodPowerStatus;
*/
//Argument of write-uart define
#define UN_WAIT_TX 0x00
#define WAIT_TX 0x01
//Picture define
#define MAX_DIGITAL_NUMBER 10
#define DIGITAL_IMAGE_CODE_LEN 48
#define DIGITAL_IMAGE_PIXEL_WIDTH 16
#define DIGITAL_IMAGE_PIXEL_HEIGTH 24
//Event define
#define NO_EVENT 0x00
#define UART_RECEIVE 0x10
#define UART_TIMEOUT 0x20
#define PRESS_KEY 0x30
//Lingo ID define
#define GENERAL_LINGO 0x00
#define MICROPHONE_LINGO 0x01
#define DISPLAY_REMOTE_LINGO 0x03
#define EXTENDED_INTERFACE_LINGO 0x04
#define RF_TRANSMITTER_LINGO 0x05
//Command ID define
//General command ID define
#define REQUEST_IDENTIFY 0x00
#define GET_DEV_AUTHENTICATION_INFO 0x14
#define ACK_DEV_AUTHENTICATION_INFO 0x16
#define GET_DEV_AUTHENTICATION_SIGNATURE 0x17
#define ACK_AUTHENTICATION_STATUS 0x19
#define GET_ACCESSORY_INFO 0x27
#define IDENTIFY_DEVICE_LINGO 0x13
#define NOTIFY_IPOD_STATE_CHANGE 0x23
#define REQUEST_IDENTIFY 0x00
#define ACK 0x02
#define ENTER_REMOTE_UI_MODE 0x05
#define EXIT_REMOTE_UI_MODE 0x06
//Display remote lingo ID define
#define LINGO3_ACK 0x00
#define SET_IPOD_STATE_INFO 0x0e
#define RET_IPOD_STATE_INFO 0x0d
#define RET_PLAY_STATUS 0x10
//Extended interface ID define
#define SET_DISPLAY_IMAGE 0x3200
#define RET_MONO_DISPLAY_IMAGE_LIMIT 0x3400
#define EXTENDED_INTERFACE_LINGO_ACK 0x0100
#define GET_PLAY_STATUS 0x1c00
#define PLAY_CONTROL 0x2900
//#define RET_PLAY_STATUS 0x1d00
//RF lingo ID define
#define BEGIN_TRANSMISSION 0x02
#define END_TRANSMISSION 0x03
//Microphone command ID define
#define GET_DEV_ACK 0x05
#define IPOD_MODE_CHANGE 0x06
#define GET_DEV_CAPS 0x07
//Command result define
#define ACK_OK 0x00
#define ACK_PENDING 0x06
#define LINGO3_ACK_OK 0x00
//Accessory information type define
#define ACCESSORY_CAPABILITIES 0x00
#define ACCESSORY_NAME 0x01
#define ACCESSORY_SUPPORTED_FIRMWARE_VERSION 0x02
#define ACCESSORY_SUPPORTED_LINGO_VERSION 0x03
#define ACCESSORY_FIRMARE_VERSION 0x04
#define ACCESSORY_HARDWARE_VERSION 0x05
#define ACCESSORY_MANUFACTURE 0x06
//MCU power bit define
#define RE_SE 0x01
#define RE_SM0 0x02
#define RE_SM1 0x04
#define RE_SM2 0x08
//FM control define
#define FM_PRESET_FREQUENCE_L 0x71
#define FM_PRESET_FREQUENCE_H 0x3
#define FM_PRESET_FREQUENCE 0x371
#define FM_MAX_FREQUENCE 1079
#define FM_MIN_FREQUENCE 0x371 //881
#define FM_FREQUENCE_MODE1 0x371
#define FM_FREQUENCE_MODE1L 0x71
#define FM_FREQUENCE_MODE1H 0x03
#define FM_FREQUENCE_MODE2 0x3ad
#define FM_FREQUENCE_MODE2L 0xad
#define FM_FREQUENCE_MODE2H 0x3
#define FM_FREQUENCE_MODE3 0x3e9
#define FM_FREQUENCE_MODE3L 0xe9
#define FM_FREQUENCE_MODE3H 0x3
#define FM_FREQUENCE_MODE 0x000
#define FM_FREQUENCE_MODEL 0x00
#define FM_FREQUENCE_MODEH 0x0
#define FM_FREQUENCE_MODE4 0x425
#define FM_FREQUENCE_MODE4L 0x25
#define FM_FREQUENCE_MODE4H 0x4
#define FM_FREQUENCE_MODE1_MAX 0xad
#define FM_FREQUENCE_MODE2_MAX 0x3e9
#define FM_FREQUENCE_MODE3_MAX 0x425
#define FM_FREQUENCE_MODE4_MAX 0x437
//#define EEPROM_CHECKSUM FM_PRESET_FREQUENCE_L + FM_PRESET_FREQUENCE_H
#define EEPROM_MEMORY_LEN 255
#define EEPROM_ADDRESS_DATA_LEN 4
#define EEPROM_FREQUENCE_DATA_LEN 14
#define EEPROM_RW_RETRY_COUNTS 3
#define FM_CONTROL_MASK 0x7ff
#define STEREO 0x800
#define PLL_OUTPUT_HIGH_IMPEDANCE 0x3000
#define PLL_OUTPUT_USUAL 0x0000
#define COMPULSION_BY_LOW 0x2000
#define COMPULSION_BY_HIGH 0x1000
#define HIGH_IMPEDANCE 0x3000
#define FM_TEST 0x4000
//#define FM_POWER PC0
//#define FM_MUTE 0x20
//#define FM_CE 0x40
//#define FM_CLK 0x80
//#define FM_DATA 0x01
#define nSHDN 0x40
//iPod play status define
#define PLAY_STOP 0x00
#define PLAY_PAUSE 0x02
#define PLAYING 0x01
//Botton key value define
#define RELEASE_ALL_KEY 0x00000000
#define PRESS_PAUSE_KEY 0x0200
#define RELEASE_PAUSE_KEY 0x00000000
#define PRESS_PLAY_PAUSE_KEY 0x0001
#define RELEASE_PLAY_PAUSE_KEY 0x00000000
#define FAST_CHANGE_COUNT 0x05
#define RET_LAST_MENU_LEVEL 0x04
//FM Tx status define
//#define NO_FM_TX_STATUS 0x00
#define NO_IPOD_CONNECT_STATUS 0x00
//#define GET_IPOD_STATUS_INFO_STATUS 0x03
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -