📄 common.h
字号:
#ifndef _commonH
#define _commonH
#include <targets/LPC2000.h>
#include <targets/liblpc2000.h>
#include <ctl_api.h>
// *****************************************************
// types
typedef signed char _s8;
typedef unsigned char _u8;
typedef signed short _s16;
typedef unsigned short _u16;
typedef signed long _s32;
typedef unsigned long _u32;
typedef signed long long _s64;
typedef unsigned long long _u64;
typedef unsigned char bool;
// *****************************************************
// constants
#define fosc OSCILLATOR_CLOCK_FREQUENCY
#define true 1
#define false 0
#define Bit0 (1 << 0)
#define Bit1 (1 << 1)
#define Bit2 (1 << 2)
#define Bit3 (1 << 3)
#define Bit4 (1 << 4)
#define Bit5 (1 << 5)
#define Bit6 (1 << 6)
#define Bit7 (1 << 7)
#define Bit8 (1 << 8)
#define Bit9 (1 << 9)
#define Bit10 (1 << 10)
#define Bit11 (1 << 11)
#define Bit12 (1 << 12)
#define Bit13 (1 << 13)
#define Bit14 (1 << 14)
#define Bit15 (1 << 15)
#define Bit16 (1 << 16)
#define Bit17 (1 << 17)
#define Bit18 (1 << 18)
#define Bit19 (1 << 19)
#define Bit20 (1 << 20)
#define Bit21 (1 << 21)
#define Bit22 (1 << 22)
#define Bit23 (1 << 23)
#define Bit24 (1 << 24)
#define Bit25 (1 << 25)
#define Bit26 (1 << 26)
#define Bit27 (1 << 27)
#define Bit28 (1 << 28)
#define Bit29 (1 << 29)
#define Bit30 (1 << 30)
#define Bit31 (1 << 31)
// *****************************************************
// I/O Pins
#define MMC_CS_BIT Bit17 // MMC chip-select pin/bit
#define MMC_CS_DIR IO0DIR // direction register
#define MMC_CS_CLR IO0CLR // clear register
#define MMC_CS_SET IO0SET // set register
#define MMC_CS_PIN IO0PIN // input register
#define MMC_SWITCH_BIT Bit30 // MMC card slot switch pin/bit
#define MMC_SWITCH_DIR IO0DIR // direction register
#define MMC_SWITCH_CLR IO0CLR // clear register
#define MMC_SWITCH_SET IO0SET // set register
#define MMC_SWITCH_PIN IO0PIN // input register
// *****************************************************
// ints
#define WDT_INT 0
#define SWI_INT 1
#define ARM_CORE0_INT 2
#define ARM_CORE1_INT 3
#define TIMER0_INT 4
#define TIMER1_INT 5
#define UART0_INT 6
#define UART1_INT 7
#define PWM0_INT 8
#define I2C0_INT 9
#define SPI0_INT 10
#define SPI1_INT 11
#define PLL_INT 12
#define RTC_INT 13
#define EINT0_INT 14
#define EINT1_INT 15
#define EINT2_INT 16
#define EINT3_INT 17
#define ADC0_INT 18
#define I2C1_INT 19
#define BOD_INT 20
#define ADC1_INT 21
//#define USB_INT 22
#define PWM0_Int_Priority 0
#define SPI0_Int_Priority 1
#define RTC_Int_Priority 2
#define UART0_Int_Priority 3
#define UART1_Int_Priority 4
#define TIMER0_Int_Priority 5
#define TIMER1_Int_Priority 6
#define EINT0_Int_Priority 7
#define EINT1_Int_Priority 8
#define EINT2_Int_Priority 9
#define EINT3_Int_Priority 10
// *****************************************************
// storage bits
extern _u32 cclk;
extern _u32 pclk;
extern volatile _u8 uart0_rxBuf[128];
extern volatile _u16 uart0_rxWr;
extern volatile _u16 uart0_rxRd;
// *****************************************************
void delay_us(_u32 us);
bool delay_ms(_u16 ms);
bool start_test_timer(void);
_u32 stop_test_timer(void);
_u32 SPI0_Initialize(_u32 freq, bool master, bool clk_edge_2, bool sclk_active_low, bool lsb_1st, bool use_SSEL, bool set_pins, CTL_ISR_FN_t isr);
void SPI0_Deinitialize(void);
void SPI0_SendByte(_u8 b);
_u8 SPI0_GetByte(_u8 b);
int SPI0_WaitForTx(void);
_u8 SPI0_WaitForTxGetRx(void);
_u8 SPI0_8(_u8 b);
_u16 SPI0_16(_u16 w);
_u32 UART0_Initialize(unsigned int baud, _u8 fifo_size, CTL_ISR_FN_t isr);
void UART0_Deinitialize(void);
void ClearRxUartFIFO(int uart);
void ClearTxUartFIFO(int uart);
bool WriteByte_uart0(_u8 ch, _s32 timeout);
bool WriteByte_uart1(_u8 ch, _s32 timeout);
bool WriteByte_uart2(_u8 ch, _s32 timeout);
void WriteStr_uart0(char *s);
// *****************************************************
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -