board.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef CLOCK_PERIOD
  10. #define CLOCK_PERIOD (1e9/BOARD_PLL_FREQUENCY)
  11. #endif
  12. #ifndef RTC_PERIOD
  13. #define RTC_PERIOD (1e9f/BOARD_RTC_FREQUENCY)
  14. #endif
  15. #ifndef FPGA_ADDR
  16. #define FPGA_ADDR 0x80027000
  17. #endif
  18. #define MMIO_BASE (0x60000000)
  19. #define LED_GPIO GPIO4
  20. #define LED_GPIO_MASK APB_MASK_GPIO4
  21. #define LED_GPIO_BITS (1 << 4) // LED 4
  22. #define BUT_GPIO GPIO6
  23. #define BUT_GPIO_MASK APB_MASK_GPIO6
  24. #define BUT_GPIO_BITS (0x14) // Bits 2 & 4
  25. #define BUT_GPIO_IRQ GPIO6_IRQn
  26. #define EXT_GPIO GPIO4
  27. #define EXT_GPIO_MASK APB_MASK_GPIO4
  28. #define EXT_GPIO_BITS 0b1110
  29. SYS_HSE_BypassTypeDef board_hse_source(void);
  30. RTC_ClkSourceTypeDef board_rtc_source(void);
  31. uint32_t board_lse_freq(void);
  32. uint32_t board_pll_clkin_freq(void);
  33. void board_init(void);
  34. void board_led_write(bool state);
  35. uint32_t board_button_read(void);
  36. int board_uart_read(uint8_t *buf, int len);
  37. int board_uart_write(void const *buf, int len);
  38. uint32_t board_millis(void);
  39. static inline void HardFault_Handler(void) { asm("ebreak"); }
  40. MAC_MediaInterfaceTypeDef board_mac_media(void);
  41. uint8_t board_mac_phy_addr(void);
  42. void board_init_mac(void);
  43. void board_init_phy(MAC_HandleTypeDef *hmac);
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif