📄 define.h
字号:
#ifndef DEFINE_H
#define DEFINE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SYSCFG
#define SYSCFG 0x03FF0000
#endif
#ifndef IOPMOD
#define IOPMOD (*((volatile unsigned *)(SYSCFG+0x5000)))
#endif
#ifndef IOPDATA
#define IOPDATA (*((volatile unsigned *)(SYSCFG+0x5008)))
#endif
#define UART0_BASE (SYSCFG + 0xD000)
#define UART1_BASE (SYSCFG + 0xE000)
#define IOPCON (*((volatile unsigned *)(SYSCFG+0x5004)))
#define INTPND (*((volatile unsigned *)(SYSCFG+0x4004)))
#define INTMSK (*((volatile unsigned *)(SYSCFG+0x4008)))
#define TMOD (*((volatile unsigned *)(SYSCFG+0x6000)))
#define TDATA0 (*((volatile unsigned *)(SYSCFG+0x6004)))
#define TCNT0 (*((volatile unsigned *)(SYSCFG+0x600c)))
/*
* Serial settings.......................
*/
#define ULCON 0x00
#define UCON 0x04
#define USTAT 0x08
#define UTXBUF 0x0C
#define URXBUF 0x10
#define UBRDIV 0x14
/*
* Line control register bits............
*/
#define ULCR8bits (3)
#define ULCRS1StopBit (0)
#define ULCRNoParity (0)
/*
* UART Control Register bits............
*/
#define UCRRxM (1)
#define UCRRxSI (1 << 2)
#define UCRTxM (1 << 3)
#define UCRLPB (1 << 7)
/*
* UART Status Register bits
*/
#define USROverrun (1 << 0)
#define USRParity (1 << 1)
#define USRFraming (1 << 2)
#define USRBreak (1 << 3)
#define USRDTR (1 << 4)
#define USRRxData (1 << 5)
#define USRTxHoldEmpty (1 << 6)
#define USRTxEmpty (1 << 7)
/* default baud rate value */
#define BAUD_9600 (162 << 4)
/* add 19200 for test uue */
#define BAUD_19200 (80 << 4)
#define BAUD_38400 (40 << 4)
#define BAUD_57600 (26 << 4)
/* add 115200 for download faster */
#define BAUD_115200 (13 << 4)
#define COM1_DEBUG (1)
#define COM0_USER (0)
// UART registers are on word aligned, D8
/* UART primitives */
#define GET_STATUS(p) (*(volatile unsigned *)((p) + USTAT))
#define RX_DATA(s) ((s) & USRRxData)
#define GET_CHAR(p) (*(volatile unsigned *)((p) + URXBUF))
#define TX_READY(s) ((s) & USRTxHoldEmpty)
#define PUT_CHAR(p,c) (*(unsigned *)((p) + UTXBUF) = (unsigned )(c))
#define UART_SELECT_CHANNEL 1
#define UART_SET_BAUDRATE 2
#define TIMER0_MASK (1 << 10)
#define INT0_MASK (1 << 0)
#define UART0_MASK (1 << 5)
#define UART1_MASK (1 << 7)
#define INT0_IO_ENABLE (1<<4)
#define INT0_IO_ACTIVE_HIGH (1<<3)
#define INT0_IO_RISING_EDGE (0x01)
#define LED_NUM 4
#define DIP_NUM 4
#define SEG7_BASE 0x03fdc000
#define SEG7 (*(unsigned *)(SEG7_BASE))
#define SEG_A 0x1
#define SEG_B 0x2
#define SEG_C 0x4
#define SEG_D 0x10
#define SEG_E 0x20
#define SEG_F 0x40
#define SEG_G 0x80
#define SEG_DP 0x8
#define DISP_0 (SEG_F|SEG_G|SEG_A|SEG_B|SEG_D|SEG_E)
#define DISP_1 (SEG_F|SEG_G)
#define DISP_2 (SEG_A|SEG_C|SEG_D|SEG_E|SEG_G)
#define DISP_3 (SEG_A|SEG_C|SEG_E|SEG_F|SEG_G)
#define DISP_4 (SEG_B|SEG_C|SEG_F|SEG_G)
#define DISP_5 (SEG_A|SEG_B|SEG_C|SEG_E|SEG_F)
#define DISP_6 (SEG_A|SEG_B|SEG_C|SEG_D|SEG_E|SEG_F)
#define DISP_7 (SEG_A|SEG_F|SEG_G)
#define DISP_8 (SEG_A|SEG_B|SEG_C|SEG_D|SEG_E|SEG_F|SEG_G)
#define DISP_9 (SEG_A|SEG_B|SEG_C|SEG_E|SEG_F|SEG_G)
#define DISP_A (SEG_A|SEG_B|SEG_C|SEG_D|SEG_F|SEG_G)
#define DISP_B (SEG_B|SEG_C|SEG_D|SEG_E|SEG_F)
#define DISP_C (SEG_A|SEG_B|SEG_D|SEG_E)
#define DISP_D (SEG_C|SEG_D|SEG_E|SEG_F|SEG_G)
#define DISP_E (SEG_A|SEG_B|SEG_C|SEG_D|SEG_E)
#define DISP_F (SEG_A|SEG_B|SEG_C|SEG_D)
#define DISP_INVALID (SEG_C)
#ifdef __cplusplus
}
#endif
#endif /* DEFINE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -