f7.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * stm32/f7.h
  3. *
  4. * Core and peripheral registers.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. #define CORTEX_M7 1
  12. /* C pointer types */
  13. #define CPUFEAT volatile struct cpufeat * const
  14. #define CACHE volatile struct cache * const
  15. #define SYSCFG volatile struct syscfg * const
  16. #define DMA_STR volatile struct dma_str * const
  17. #define HSPHYC volatile struct hsphyc * const
  18. /* C-accessible registers. */
  19. static STK stk = (struct stk *)STK_BASE;
  20. static SCB scb = (struct scb *)SCB_BASE;
  21. static NVIC nvic = (struct nvic *)NVIC_BASE;
  22. static DBG dbg = (struct dbg *)DBG_BASE;
  23. static CPUFEAT cpufeat = (struct cpufeat *)CPUFEAT_BASE;
  24. static CACHE cache = (struct cache *)CACHE_BASE;
  25. static FLASH flash = (struct flash *)FLASH_BASE;
  26. static PWR pwr = (struct pwr *)PWR_BASE;
  27. static RCC rcc = (struct rcc *)RCC_BASE;
  28. static IWDG iwdg = (struct iwdg *)IWDG_BASE;
  29. static GPIO gpioa = (struct gpio *)GPIOA_BASE;
  30. static GPIO gpiob = (struct gpio *)GPIOB_BASE;
  31. static GPIO gpioc = (struct gpio *)GPIOC_BASE;
  32. static GPIO gpiod = (struct gpio *)GPIOD_BASE;
  33. static GPIO gpioe = (struct gpio *)GPIOE_BASE;
  34. static GPIO gpiof = (struct gpio *)GPIOF_BASE;
  35. static GPIO gpiog = (struct gpio *)GPIOG_BASE;
  36. static GPIO gpioh = (struct gpio *)GPIOH_BASE;
  37. static GPIO gpioi = (struct gpio *)GPIOI_BASE;
  38. static SYSCFG syscfg = (struct syscfg *)SYSCFG_BASE;
  39. static EXTI exti = (struct exti *)EXTI_BASE;
  40. static DMA dma1 = (struct dma *)DMA1_BASE;
  41. static DMA dma2 = (struct dma *)DMA2_BASE;
  42. static TIM tim1 = (struct tim *)TIM1_BASE;
  43. static TIM tim2 = (struct tim *)TIM2_BASE;
  44. static TIM tim3 = (struct tim *)TIM3_BASE;
  45. static TIM tim4 = (struct tim *)TIM4_BASE;
  46. static TIM tim5 = (struct tim *)TIM5_BASE;
  47. static TIM tim6 = (struct tim *)TIM6_BASE;
  48. static TIM tim7 = (struct tim *)TIM7_BASE;
  49. static TIM tim8 = (struct tim *)TIM8_BASE;
  50. static TIM tim9 = (struct tim *)TIM9_BASE;
  51. static TIM tim10 = (struct tim *)TIM10_BASE;
  52. static TIM tim11 = (struct tim *)TIM11_BASE;
  53. static TIM tim12 = (struct tim *)TIM12_BASE;
  54. static TIM tim13 = (struct tim *)TIM13_BASE;
  55. static TIM tim14 = (struct tim *)TIM14_BASE;
  56. static SPI spi1 = (struct spi *)SPI1_BASE;
  57. static SPI spi2 = (struct spi *)SPI2_BASE;
  58. static SPI spi3 = (struct spi *)SPI3_BASE;
  59. static SPI spi4 = (struct spi *)SPI4_BASE;
  60. static SPI spi5 = (struct spi *)SPI5_BASE;
  61. static I2C i2c1 = (struct i2c *)I2C1_BASE;
  62. static I2C i2c2 = (struct i2c *)I2C2_BASE;
  63. static I2C i2c3 = (struct i2c *)I2C3_BASE;
  64. static USART usart1 = (struct usart *)USART1_BASE;
  65. static USART usart2 = (struct usart *)USART2_BASE;
  66. static USART usart3 = (struct usart *)USART3_BASE;
  67. static USART usart4 = (struct usart *)USART4_BASE;
  68. static USART usart5 = (struct usart *)USART5_BASE;
  69. static USART usart6 = (struct usart *)USART6_BASE;
  70. static HSPHYC hsphyc = (struct hsphyc *)HSPHYC_BASE;
  71. static SER_ID ser_id = (uint32_t *)0x1ff07a10;
  72. #define SYSCLK_MHZ 216
  73. #define AHB_MHZ 216
  74. #define APB1_MHZ 54
  75. #define APB2_MHZ 108
  76. #define FLASH_PAGE_SIZE 16384
  77. /* Delay after enabling peripheral clock, before accessing peripheral
  78. * (Ref STMicro RM0431, Section 5.2.12) */
  79. void peripheral_clock_delay(void);
  80. void gpio_set_af(GPIO gpio, unsigned int pin, unsigned int af);
  81. #define section_ext_ram __attribute__((section(".ext_ram")))
  82. enum {
  83. F7SM_v1 = 0,
  84. F7SM_ant_goffart_f7_plus_v1,
  85. F7SM_lightning,
  86. F7SM_v2,
  87. F7SM_ant_goffart_f7_plus_v2,
  88. F7SM_lightning_plus,
  89. F7SM_slim,
  90. F7SM_v3,
  91. };
  92. void identify_board_config(void);
  93. /* On reset, SYSCLK=HSI at 16MHz. SYSCLK runs at 2MHz. */
  94. void early_fatal(int blinks) __attribute__((noreturn));
  95. #define early_delay_ms(ms) (delay_ticks((ms)*2000))
  96. #define early_delay_us(us) (delay_ticks((us)*2))
  97. /*
  98. * Local variables:
  99. * mode: C
  100. * c-file-style: "Linux"
  101. * c-basic-offset: 4
  102. * tab-width: 4
  103. * indent-tabs-mode: nil
  104. * End:
  105. */