• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HPMicro
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _HPM_BOARD_H
17 #define _HPM_BOARD_H
18 #include <stdio.h>
19 #include "hpm_common.h"
20 #include "hpm_clock_drv.h"
21 #include "hpm_soc.h"
22 #include "hpm_soc_feature.h"
23 
24 #define BOARD_CPU_FREQ (648000000UL)
25 
26 #define GPIOA(pin) (pin)
27 #define GPIOB(pin) (pin + 32)
28 #define GPIOC(pin) (pin + 32 * 2)
29 #define GPIOD(pin) (pin + 32 * 3)
30 #define GPIOE(pin) (pin + 32 * 4)
31 #define GPIOF(pin) (pin + 32 * 5)
32 #define GPIOY(pin) (pin + 32 * 14)
33 #define GPIOZ(pin) (pin + 32 * 15)
34 
35 /* enet section */
36 #define BOARD_ENET_RGMII_RST_GPIO       HPM_GPIO0
37 #define BOARD_ENET_RGMII_RST_GPIO_INDEX GPIO_DO_GPIOF
38 #define BOARD_ENET_RGMII_RST_GPIO_PIN   (0U)
39 #define BOARD_ENET_RGMII                HPM_ENET0
40 #define BOARD_ENET_RGMII_TX_DLY         (0U)
41 #define BOARD_ENET_RGMII_RX_DLY         (7U)
42 
43 #define BOARD_ENET_RGMII_PTP_CLOCK      (clock_ptp0)
44 
45 
46 #define BOARD_ENET_RMII_RST_GPIO        HPM_GPIO0
47 #define BOARD_ENET_RMII_RST_GPIO_INDEX  GPIO_DO_GPIOE
48 #define BOARD_ENET_RMII_RST_GPIO_PIN    (26U)
49 #define BOARD_ENET_RMII                 HPM_ENET1
50 #define BOARD_ENET_RMII_INT_REF_CLK     (1U)
51 
52 #define BOARD_ENET_RMII_PTP_CLOCK       (clock_ptp1)
53 
54 #define TEST_APP_I2C_CLK_NAME clock_i2c0
55 
56 #define BOARD_GPIO_IN_IRQ_TASK_GPIO1 GPIOZ(2)
57 #define BOARD_GPIO_IN_IRQ_TASK_GPIO2 GPIOZ(3)
58 
59 #define BOARD_GPIO_OUT_TASK_GPIO1 GPIOB(11)
60 #define BOARD_GPIO_OUT_TASK_GPIO2 GPIOB(12)
61 #define BOARD_GPIO_OUT_TASK_GPIO3 GPIOB(13)
62 
63 #define spi_device_num (2)
64 #define I2C_BUS_NUM (0)
65 #define TEST_I2C_CLOCK_NAME clock_i2c0
66 
67 void board_init(void);
68 void board_print_clock_freq(void);
69 void board_print_banner(void);
70 
71 hpm_stat_t board_reset_enet_phy(ENET_Type *ptr);
72 hpm_stat_t board_init_enet_pins(ENET_Type *ptr);
73 hpm_stat_t board_init_enet_rmii_reference_clock(ENET_Type *ptr, bool internal);
74 hpm_stat_t board_init_enet_rgmii_clock_delay(ENET_Type *ptr);
75 hpm_stat_t board_init_enet_ptp_clock(ENET_Type *ptr);
76 void init_gpio_pins(void);
77 void init_gpio_out_task_pins(void);
78 void init_i2c_pins(I2C_Type *ptr);
79 void init_spi_pins(SPI_Type *ptr);
80 
81 #if defined(__cplusplus)
82 }
83 #endif /* __cplusplus */
84 #endif /* _HPM_BOARD_H */
85