board.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef BOARD_H
  2. #define BOARD_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. #include <stdbool.h>
  8. #include "alta.h"
  9. // #include "timer.h"
  10. #ifndef CLOCK_PERIOD
  11. #define CLOCK_PERIOD (1e9/BOARD_PLL_FREQUENCY)
  12. #endif
  13. #ifndef RTC_PERIOD
  14. #define RTC_PERIOD (1e9f/BOARD_RTC_FREQUENCY)
  15. #endif
  16. #ifndef FPGA_ADDR
  17. #define FPGA_ADDR 0x80027000
  18. #endif
  19. #define MMIO_BASE (0x60000000)
  20. #define SIM_RST_G0_GPIO GPIO1
  21. #define SIM_RST_G0_GPIO_MASK APB_MASK_GPIO1
  22. #define SIM_RST_G0_BITS ( 0b11111111 )
  23. #define SIM_RST_G1_GPIO GPIO2
  24. #define SIM_RST_G1_GPIO_MASK APB_MASK_GPIO2
  25. #define SIM_RST_G1_BITS ( 0b11111111 )
  26. #define LED_GPIO GPIO6
  27. #define LED_GPIO_MASK APB_MASK_GPIO6
  28. #define LED_0_BIT (1 << 0)
  29. #define LED_1_BIT (1 << 2)
  30. #define LED_GPIO_BITS (LED_0_BIT | LED_1_BIT)
  31. #define IOEX_I2C_GPIO GPIO6
  32. #define IOEX_I2C_GPIO_MASK APB_MASK_GPIO6
  33. #define IOEX_I2C_SCL_BIT (1 << 4)
  34. #define IOEX_I2C_SDA_BIT (1 << 6)
  35. #define IOEX_I2C_BITS (IOEX_I2C_SCL_BIT | IOEX_I2C_SDA_BIT)
  36. #define SIM_TXEN_GPIO GPIO8
  37. #define SIM_TXEN_GPIO_MASK APB_MASK_GPIO8
  38. #define SIM_12_TXEN_BIT (1<<1) // 控制 MCU的Uart的收发切换
  39. #define SIM_13_TXEN_BIT (1<<3) // 控制 MCU的Uart的收发切换
  40. #define SIM_14_TXEN_BIT (1<<5) // 控制 MCU的Uart的收发切换
  41. #define SIM_15_TXEN_BIT (1<<7) // 控制 MCU的Uart的收发切换
  42. #define SIM_TXEN_BITS (SIM_12_TXEN_BIT|SIM_13_TXEN_BIT|SIM_14_TXEN_BIT|SIM_15_TXEN_BIT)
  43. #define EEPROM_GPIO GPIO9
  44. #define EEPROM_GPIO_MASK APB_MASK_GPIO9
  45. #define EEPROM_SCL_BIT (1 << 0)
  46. #define EEPROM_SDA_BIT (1 << 1)
  47. #define EEPROM_WP_BIT (1 << 2)
  48. #define EEPROM_BITS (EEPROM_SCL_BIT | EEPROM_SDA_BIT | EEPROM_WP_BIT)
  49. #define SIM_VCC_EN_GPIO GPIO9
  50. #define SIM_VCC_EN_GPIO_MASK APB_MASK_GPIO9
  51. #define SIM_VCC_EN_BIT (1 << 3)
  52. #define WIFI_OUT_GPIO GPIO9
  53. #define WIFI_OUT_GPIO_MASK APB_MASK_GPIO9
  54. #define WIFI_OUT_NRESET_BIT (1 << 4)
  55. #define WIFI_OUT_RELOAD_BIT (1 << 5)
  56. #define WIFI_OUT_BITS (WIFI_OUT_NRESET_BIT | WIFI_OUT_RELOAD_BIT)
  57. #define NE2_OUT_GPIO GPIO9
  58. #define NE2_OUT_GPIO_MASK APB_MASK_GPIO9
  59. #define NE2_OUT_NRESET_BIT (1 << 6)
  60. #define NE2_OUT_RELOAD_BIT (1 << 7)
  61. #define NE2_OUT_BITS (NE2_OUT_NRESET_BIT | NE2_OUT_RELOAD_BIT)
  62. #define IOINT_GPIO GPIO3
  63. #define IOINT_GPIO_MASK APB_MASK_GPIO3
  64. #define IOINT_GPIO_IRQ GPIO3_IRQn
  65. #define IOINT_BUT_INT_BIT (1 << 0)
  66. #define IOINT_TCA9535_INT_BIT (1 << 1)
  67. #define IOINT_WIFI_W_INT_BIT (1 << 2)
  68. #define IOINT_WIFI_I_INT_BIT (1 << 3)
  69. #define IOINT_WIFI_S_INT_BIT (1 << 4)
  70. #define IOINT_BITS (IOINT_BUT_INT_BIT | IOINT_TCA9535_INT_BIT | IOINT_WIFI_W_INT_BIT | IOINT_WIFI_I_INT_BIT | IOINT_WIFI_S_INT_BIT)
  71. #define SIM_IO_INT_G0_GPIO GPIO4
  72. #define SIM_IO_INT_G0_GPIO_MASK APB_MASK_GPIO4
  73. #define SIM_IO_INT_G0_GPIO_IRQ GPIO4_IRQn
  74. #define SIM_IO_INT_G0_BITS ( 0b00111111 )
  75. #define SIM_IO_INT_G1_GPIO GPIO5
  76. #define SIM_IO_INT_G1_GPIO_MASK APB_MASK_GPIO5
  77. #define SIM_IO_INT_G1_GPIO_IRQ GPIO5_IRQn
  78. #define SIM_IO_INT_G1_BITS ( 0b00111111 )
  79. SYS_HSE_BypassTypeDef board_hse_source(void);
  80. RTC_ClkSourceTypeDef board_rtc_source(void);
  81. uint32_t board_lse_freq(void);
  82. uint32_t board_pll_clkin_freq(void);
  83. void board_init(void);
  84. void board_led_write(bool state);
  85. uint32_t board_button_read(void);
  86. int board_uart_read(uint8_t *buf, int len);
  87. int board_uart_write(void const *buf, int len);
  88. uint32_t board_millis(void);
  89. static inline void HardFault_Handler(void) { asm("ebreak"); }
  90. MAC_MediaInterfaceTypeDef board_mac_media(void);
  91. uint8_t board_mac_phy_addr(void);
  92. void board_init_mac(void);
  93. void board_init_phy(MAC_HandleTypeDef *hmac);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif