???????!STM32?е?λ??(bit-band)????
?????λ??????????????????????/?洢????????????????ж?д???? CM3 ?У????????????????λ????????????? SRAM ??????? 1MB ??Χ????????????????????????? 1MB??Χ???????????е????????????????? RAM ??????????????????????“λ????????”??λ????????????????????????? 32 λ????????????λ??????????????Щ??????????????????????????
λ?????????????? 30 ???????????????8051 ??????????????????CM3 ???????????????????λ???????? 8051 λ?????????????????档
CM3 ????????????????λ???洢?????????
λ?????????λ????????????
λ??????????????????????????????λ???????????(???????????????????)
??λ?????У????????????????????????????——??????? LSB ??Ч???????????????????????????????????任??λ?????????????????????λ??????е???????????????λ????? LSB?????? LSB ?????????д???????????д??λ???????????λ???????????????????“??-??-д”?????



???λ????????????????????Χ???
0x2000_0000?\0x200F_FFFF(SRAM ???е???? 1MB)
0x4000_0000?\0x400F_FFFF(??????????е???? 1MB)
?? SRAM λ???????????????????????????? A,λ???? n(0<=n<=7)??????????????????????
AliasAddr=0x22000000+((A-0x20000000)*8+n)*4=0x22000000+(A-0x20000000)*32+n*4
???????????λ????????????????????????????? A,λ???? n(0<=n<=7)??????????????????????
AliasAddr=0x42000000+((A-0x40000000)*8+n)*4=0x42000000+(A-0x40000000)*32+n*4
????У?“*4”????????? 4 ??????“*8”????????????? 8 ???????
??????????????????????
1. ???? 0x20000000 ??д?? 0x3355AACC
2. ??????0x22000008?????ζ????????? 0x20000000??????????? 2???? 1??
3. ????? 0x22000008 ??д 0?????β?????????????? 0x20000000 ??“??-??-д”????(????)???????2 ?? 0??
4. ???????? 0x20000000???????? 0x3355AAC8(bit[2]??????)??
λ??????????????? LSB ?????塣?????????λ?????????????????????????????????????(??/????/???)????????????????????????????????????????
[cpp] view plain copy///////////////////////////////////////////////////////////////
//λ??????,???51?????GPIO???????
//??????????,?ο?<>??????(87?~92?).
//IO?????????
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
//IO???????
#define GPIOA_ODR_Addr (GPIOA_BASE+12) //0x4001080C
#define GPIOB_ODR_Addr (GPIOB_BASE+12) //0x40010C0C
#define GPIOC_ODR_Addr (GPIOC_BASE+12) //0x4001100C
#define GPIOD_ODR_Addr (GPIOD_BASE+12) //0x4001140C
#define GPIOE_ODR_Addr (GPIOE_BASE+12) //0x4001180C
#define GPIOF_ODR_Addr (GPIOF_BASE+12) //0x40011A0C
#define GPIOG_ODR_Addr (GPIOG_BASE+12) //0x40011E0C
#define GPIOA_IDR_Addr (GPIOA_BASE+8) //0x40010808
#define GPIOB_IDR_Addr (GPIOB_BASE+8) //0x40010C08
#define GPIOC_IDR_Addr (GPIOC_BASE+8) //0x40011008
#define GPIOD_IDR_Addr (GPIOD_BASE+8) //0x40011408
#define GPIOE_IDR_Addr (GPIOE_BASE+8) //0x40011808
#define GPIOF_IDR_Addr (GPIOF_BASE+8) //0x40011A08
#define GPIOG_IDR_Addr (GPIOG_BASE+8) //0x40011E08
//IO?????,???????IO??!
//???n???С??16!
#define PAout(n) BIT_ADDR(GPIOA_ODR_Addr,n) //???
#define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) //????
#define PBout(n) BIT_ADDR(GPIOB_ODR_Addr,n) //???
#define PBin(n) BIT_ADDR(GPIOB_IDR_Addr,n) //????
#define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) //???
#define PCin(n) BIT_ADDR(GPIOC_IDR_Addr,n) //????
#define PDout(n) BIT_ADDR(GPIOD_ODR_Addr,n) //???
#define PDin(n) BIT_ADDR(GPIOD_IDR_Addr,n) //????
#define PEout(n) BIT_ADDR(GPIOE_ODR_Addr,n) //???
#define PEin(n) BIT_ADDR(GPIOE_IDR_Addr,n) //????
#define PFout(n) BIT_ADDR(GPIOF_ODR_Addr,n) //???
#define PFin(n) BIT_ADDR(GPIOF_IDR_Addr,n) //????
#define PGout(n) BIT_ADDR(GPIOG_ODR_Addr,n) //???
#define PGin(n) BIT_ADDR(GPIOG_IDR_Addr,n) //????

????admin ?????????2018-05-18