f4.h 3.4 KB

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