您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

67 行
2.2 KiB

  1. #ifndef _system_H
  2. #define _system_H
  3. #include "stm32f4xx.h"
  4. /* include C standard library file */
  5. #include <stdint.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdarg.h>
  9. /* include third party subassembly library file */
  10. #include "../../uc_os2/uC-OS2/Source/os.h"
  11. #include "../../uc_os2/uC-CPU/cpu_core.h"
  12. /* include system hardware resource init file */
  13. #include "./SysTick.h"
  14. #define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
  15. #define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
  16. #define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
  17. //IO口地址映射
  18. #define GPIOA_ODR_Addr (GPIOA_BASE+12) //0x4001080C
  19. #define GPIOB_ODR_Addr (GPIOB_BASE+12) //0x40010C0C
  20. #define GPIOC_ODR_Addr (GPIOC_BASE+12) //0x4001100C
  21. #define GPIOD_ODR_Addr (GPIOD_BASE+12) //0x4001140C
  22. #define GPIOE_ODR_Addr (GPIOE_BASE+12) //0x4001180C
  23. #define GPIOF_ODR_Addr (GPIOF_BASE+12) //0x40011A0C
  24. #define GPIOG_ODR_Addr (GPIOG_BASE+12) //0x40011E0C
  25. #define GPIOA_IDR_Addr (GPIOA_BASE+8) //0x40010808
  26. #define GPIOB_IDR_Addr (GPIOB_BASE+8) //0x40010C08
  27. #define GPIOC_IDR_Addr (GPIOC_BASE+8) //0x40011008
  28. #define GPIOD_IDR_Addr (GPIOD_BASE+8) //0x40011408
  29. #define GPIOE_IDR_Addr (GPIOE_BASE+8) //0x40011808
  30. #define GPIOF_IDR_Addr (GPIOF_BASE+8) //0x40011A08
  31. #define GPIOG_IDR_Addr (GPIOG_BASE+8) //0x40011E08
  32. //IO口操作,只对单一的IO口!
  33. //确保n的值小于16!
  34. #define PAout(n) BIT_ADDR(GPIOA_ODR_Addr,n) //输出
  35. #define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) //输入
  36. #define PBout(n) BIT_ADDR(GPIOB_ODR_Addr,n) //输出
  37. #define PBin(n) BIT_ADDR(GPIOB_IDR_Addr,n) //输入
  38. #define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) //输出
  39. #define PCin(n) BIT_ADDR(GPIOC_IDR_Addr,n) //输入
  40. #define PDout(n) BIT_ADDR(GPIOD_ODR_Addr,n) //输出
  41. #define PDin(n) BIT_ADDR(GPIOD_IDR_Addr,n) //输入
  42. #define PEout(n) BIT_ADDR(GPIOE_ODR_Addr,n) //输出
  43. #define PEin(n) BIT_ADDR(GPIOE_IDR_Addr,n) //输入
  44. #define PFout(n) BIT_ADDR(GPIOF_ODR_Addr,n) //输出
  45. #define PFin(n) BIT_ADDR(GPIOF_IDR_Addr,n) //输入
  46. #define PGout(n) BIT_ADDR(GPIOG_ODR_Addr,n) //输出
  47. #define PGin(n) BIT_ADDR(GPIOG_IDR_Addr,n) //输入
  48. void system_hardware_init(void);
  49. #endif