| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #ifndef BOARD_H
- #define BOARD_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdint.h>
- #include <stdbool.h>
- #include "alta.h"
- // #include "timer.h"
- #ifndef CLOCK_PERIOD
- #define CLOCK_PERIOD (1e9/BOARD_PLL_FREQUENCY)
- #endif
- #ifndef RTC_PERIOD
- #define RTC_PERIOD (1e9f/BOARD_RTC_FREQUENCY)
- #endif
- #ifndef FPGA_ADDR
- #define FPGA_ADDR 0x80027000
- #endif
- #define MMIO_BASE (0x60000000)
- #define SIM_RST_G0_GPIO GPIO1
- #define SIM_RST_G0_GPIO_MASK APB_MASK_GPIO1
- #define SIM_RST_G0_BITS ( 0b11111111 )
- #define SIM_RST_G1_GPIO GPIO2
- #define SIM_RST_G1_GPIO_MASK APB_MASK_GPIO2
- #define SIM_RST_G1_BITS ( 0b11111111 )
- #define LED_GPIO GPIO6
- #define LED_GPIO_MASK APB_MASK_GPIO6
- #define LED_0_BIT (1 << 0)
- #define LED_1_BIT (1 << 2)
- #define LED_GPIO_BITS (LED_0_BIT | LED_1_BIT)
- #define IOEX_I2C_GPIO GPIO6
- #define IOEX_I2C_GPIO_MASK APB_MASK_GPIO6
- #define IOEX_I2C_SCL_BIT (1 << 4)
- #define IOEX_I2C_SDA_BIT (1 << 6)
- #define IOEX_I2C_BITS (IOEX_I2C_SCL_BIT | IOEX_I2C_SDA_BIT)
- #define SIM_TXEN_GPIO GPIO8
- #define SIM_TXEN_GPIO_MASK APB_MASK_GPIO8
- #define SIM_12_TXEN_BIT (1<<1) // 控制 MCU的Uart的收发切换
- #define SIM_13_TXEN_BIT (1<<3) // 控制 MCU的Uart的收发切换
- #define SIM_14_TXEN_BIT (1<<5) // 控制 MCU的Uart的收发切换
- #define SIM_15_TXEN_BIT (1<<7) // 控制 MCU的Uart的收发切换
- #define SIM_TXEN_BITS (SIM_12_TXEN_BIT|SIM_13_TXEN_BIT|SIM_14_TXEN_BIT|SIM_15_TXEN_BIT)
- #define EEPROM_GPIO GPIO9
- #define EEPROM_GPIO_MASK APB_MASK_GPIO9
- #define EEPROM_SCL_BIT (1 << 0)
- #define EEPROM_SDA_BIT (1 << 1)
- #define EEPROM_WP_BIT (1 << 2)
- #define EEPROM_BITS (EEPROM_SCL_BIT | EEPROM_SDA_BIT | EEPROM_WP_BIT)
- #define SIM_VCC_EN_GPIO GPIO9
- #define SIM_VCC_EN_GPIO_MASK APB_MASK_GPIO9
- #define SIM_VCC_EN_BIT (1 << 3)
- #define WIFI_OUT_GPIO GPIO9
- #define WIFI_OUT_GPIO_MASK APB_MASK_GPIO9
- #define WIFI_OUT_NRESET_BIT (1 << 4)
- #define WIFI_OUT_RELOAD_BIT (1 << 5)
- #define WIFI_OUT_BITS (WIFI_OUT_NRESET_BIT | WIFI_OUT_RELOAD_BIT)
- #define NE2_OUT_GPIO GPIO9
- #define NE2_OUT_GPIO_MASK APB_MASK_GPIO9
- #define NE2_OUT_NRESET_BIT (1 << 6)
- #define NE2_OUT_RELOAD_BIT (1 << 7)
- #define NE2_OUT_BITS (NE2_OUT_NRESET_BIT | NE2_OUT_RELOAD_BIT)
- #define IOINT_GPIO GPIO3
- #define IOINT_GPIO_MASK APB_MASK_GPIO3
- #define IOINT_GPIO_IRQ GPIO3_IRQn
- #define IOINT_BUT_INT_BIT (1 << 0)
- #define IOINT_TCA9535_INT_BIT (1 << 1)
- #define IOINT_WIFI_W_INT_BIT (1 << 2)
- #define IOINT_WIFI_I_INT_BIT (1 << 3)
- #define IOINT_WIFI_S_INT_BIT (1 << 4)
- #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)
- #define SIM_IO_INT_G0_GPIO GPIO4
- #define SIM_IO_INT_G0_GPIO_MASK APB_MASK_GPIO4
- #define SIM_IO_INT_G0_GPIO_IRQ GPIO4_IRQn
- #define SIM_IO_INT_G0_BITS ( 0b00111111 )
- #define SIM_IO_INT_G1_GPIO GPIO5
- #define SIM_IO_INT_G1_GPIO_MASK APB_MASK_GPIO5
- #define SIM_IO_INT_G1_GPIO_IRQ GPIO5_IRQn
- #define SIM_IO_INT_G1_BITS ( 0b00111111 )
- SYS_HSE_BypassTypeDef board_hse_source(void);
- RTC_ClkSourceTypeDef board_rtc_source(void);
- uint32_t board_lse_freq(void);
- uint32_t board_pll_clkin_freq(void);
- void board_init(void);
- void board_led_write(bool state);
- uint32_t board_button_read(void);
- int board_uart_read(uint8_t *buf, int len);
- int board_uart_write(void const *buf, int len);
- uint32_t board_millis(void);
- static inline void HardFault_Handler(void) { asm("ebreak"); }
- MAC_MediaInterfaceTypeDef board_mac_media(void);
- uint8_t board_mac_phy_addr(void);
- void board_init_mac(void);
- void board_init_phy(MAC_HandleTypeDef *hmac);
- #ifdef __cplusplus
- }
- #endif
- #endif
|