f4.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * at32/f4.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_M3 1
  12. /* C pointer types */
  13. #define BKP volatile struct bkp * const
  14. #define AFIO volatile struct afio * const
  15. #define DMA_CHN volatile struct dma_chn * const
  16. /* C-accessible registers. */
  17. static STK stk = (struct stk *)STK_BASE;
  18. static SCB scb = (struct scb *)SCB_BASE;
  19. static NVIC nvic = (struct nvic *)NVIC_BASE;
  20. static DBG dbg = (struct dbg *)DBG_BASE;
  21. static FLASH flash = (struct flash *)FLASH_BASE;
  22. static PWR pwr = (struct pwr *)PWR_BASE;
  23. static BKP bkp = (struct bkp *)BKP_BASE;
  24. static RCC rcc = (struct rcc *)RCC_BASE;
  25. static IWDG iwdg = (struct iwdg *)IWDG_BASE;
  26. static GPIO gpioa = (struct gpio *)GPIOA_BASE;
  27. static GPIO gpiob = (struct gpio *)GPIOB_BASE;
  28. static GPIO gpioc = (struct gpio *)GPIOC_BASE;
  29. static GPIO gpiod = (struct gpio *)GPIOD_BASE;
  30. static GPIO gpioe = (struct gpio *)GPIOE_BASE;
  31. static GPIO gpiof = (struct gpio *)GPIOF_BASE;
  32. static GPIO gpiog = (struct gpio *)GPIOG_BASE;
  33. static AFIO afio = (struct afio *)AFIO_BASE;
  34. static EXTI exti = (struct exti *)EXTI_BASE;
  35. static DMA dma1 = (struct dma *)DMA1_BASE;
  36. static DMA dma2 = (struct dma *)DMA2_BASE;
  37. static TIM tim1 = (struct tim *)TIM1_BASE;
  38. static TIM tim2 = (struct tim *)TIM2_BASE;
  39. static TIM tim3 = (struct tim *)TIM3_BASE;
  40. static TIM tim4 = (struct tim *)TIM4_BASE;
  41. static TIM tim5 = (struct tim *)TIM5_BASE;
  42. static TIM tim6 = (struct tim *)TIM6_BASE;
  43. static TIM tim7 = (struct tim *)TIM7_BASE;
  44. static SPI spi1 = (struct spi *)SPI1_BASE;
  45. static SPI spi2 = (struct spi *)SPI2_BASE;
  46. static SPI spi3 = (struct spi *)SPI3_BASE;
  47. static I2C i2c1 = (struct i2c *)I2C1_BASE;
  48. static I2C i2c2 = (struct i2c *)I2C2_BASE;
  49. static USART usart1 = (struct usart *)USART1_BASE;
  50. static USART usart2 = (struct usart *)USART2_BASE;
  51. static USART usart3 = (struct usart *)USART3_BASE;
  52. static SER_ID ser_id = (uint32_t *)0x1ffff7e8;
  53. #define AT32F403 0x02
  54. #define AT32F413 0x04
  55. #define AT32F415 0x05
  56. #define AT32F403A 0x07
  57. #define AT32F407 0x08
  58. extern unsigned int at32f4_series;
  59. void identify_board_config(void);
  60. /* On reset, SYSCLK=HSI at 8MHz. SYSCLK runs at 1MHz. */
  61. void early_fatal(int blinks) __attribute__((noreturn));
  62. #define early_delay_ms(ms) (delay_ticks((ms)*1000))
  63. #define early_delay_us(us) (delay_ticks((us)*1))
  64. #define SYSCLK_MHZ 144
  65. #define AHB_MHZ (SYSCLK_MHZ / 1) /* 144MHz */
  66. #define APB1_MHZ (SYSCLK_MHZ / 2) /* 72MHz */
  67. #define APB2_MHZ (SYSCLK_MHZ / 2) /* 72MHz */
  68. extern unsigned int FLASH_PAGE_SIZE;
  69. /* No delay required after enabling a peripheral clock, before accessing it. */
  70. #define peripheral_clock_delay() ((void)0)
  71. /* No secondary RAM region */
  72. #define section_ext_ram
  73. extern unsigned int sram_kb;
  74. enum {
  75. F4SM_v4 = 0,
  76. F4SM_v4_slim,
  77. };
  78. /* Core floppy pin assignments vary between F4 submodels (except INDEX, RDATA,
  79. * and WDATA). All the following assignments are within GPIOB. */
  80. struct core_floppy_pins {
  81. uint8_t trk0;
  82. uint8_t wrprot;
  83. uint8_t dir;
  84. uint8_t step;
  85. uint8_t wgate;
  86. uint8_t head;
  87. };
  88. extern const struct core_floppy_pins *core_floppy_pins;
  89. /*
  90. * Local variables:
  91. * mode: C
  92. * c-file-style: "Linux"
  93. * c-basic-offset: 4
  94. * tab-width: 4
  95. * indent-tabs-mode: nil
  96. * End:
  97. */