怎么说直接操作寄存器没有呢?
TI 原厂的驱动库,在底层就是直接操作寄存器,通过几个宏定义,还可以位带操作.
TI 的固件库就是最值得学习的资料. - //*****************************************************************************
- //
- // Macros for hardware access, both direct and via the bit-band region.
- //
- //*****************************************************************************
- #define HWREG(x) \
- (*((volatile unsigned long *)(x)))
- #define HWREGH(x) \
- (*((volatile unsigned short *)(x)))
- #define HWREGB(x) \
- (*((volatile unsigned char *)(x)))
- #define HWREGBITW(x, b) \
- HWREG(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \
- (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2))
- #define HWREGBITH(x, b) \
- HWREGH(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \
- (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2))
- #define HWREGBITB(x, b) \
- HWREGB(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \
- (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2))
复制代码 |