HPM SDK
HPMicro Software Development Kit
hpm_enet_soc_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_ENET_SOC_DRV_H
8 #define HPM_ENET_SOC_DRV_H
9 
10 #include "hpm_soc.h"
11 
12 #if defined __cplusplus
13 extern "C" {
14 #endif
15 
16 static inline hpm_stat_t enet_intf_selection(ENET_Type *ptr, uint8_t inf_type)
17 {
19 
20  if (ptr == HPM_ENET0) {
23  } else if (ptr == HPM_ENET1) {
26  } else {
28  }
29 
30  return stat;
31 }
32 
34 {
36 
37  if (ptr == HPM_ENET0) {
39  } else if (ptr == HPM_ENET1) {
41  } else {
43  }
44 
45  return stat;
46 }
47 
49 {
51 
52  if (ptr == HPM_ENET0) {
54  } else if (ptr == HPM_ENET1) {
56  } else {
58  }
59 
60  return stat;
61 }
62 
63 static inline hpm_stat_t enet_rgmii_set_clock_delay(ENET_Type *ptr, uint8_t tx_delay, uint8_t rx_delay)
64 {
66 
67  if (ptr == HPM_ENET0) {
70  } else if (ptr == HPM_ENET1) {
73  } else {
75  }
76 
77  return stat;
78 }
79 
80 static inline hpm_stat_t enet_rmii_enable_clock(ENET_Type *ptr, bool internal)
81 {
83 
84  /* use an internal PLL clock as reference clock for rmii mode */
85  if (ptr == HPM_ENET0) {
86  if (internal == true) {
87  /* use a pll clock */
89  } else {
90  /* use an external clock as reference clock for rmii mode */
91  HPM_CONCTL->CTRL2 |= CONCTL_CTRL2_ENET0_RMII_TXCLK_SEL_MASK; /* use an external clock */
92  }
93  } else if (ptr == HPM_ENET1) {
94  if (internal == true) {
95  /* use a pll clock */
97  } else {
98  /* use an external clock as reference clock for rmii mode */
99  HPM_CONCTL->CTRL3 |= CONCTL_CTRL3_ENET1_RMII_TXCLK_SEL_MASK; /* use an external clock */
100  }
101  } else {
103  }
104 
105  return stat;
106 }
107 
109 {
110  hpm_stat_t stat = status_success;
111 
112  if (ptr == HPM_ENET0) {
113  /* use an internal PLL clock for rgmii mode */
115  } else if (ptr == HPM_ENET1) {
116  /* use an internal PLL clock for rgmii mode */
118  } else {
120  }
121 
122  return stat;
123 }
124 
125 #if defined __cplusplus
126 } /* __cplusplus */
127 #endif
128 
129 #endif /* HPM_ENET_SOC_DRV_H */
#define HPM_ENET0
Definition: hpm_soc_ip.h:374
static hpm_stat_t enet_rmii_enable_clock(ENET_Type *ptr, bool internal)
Definition: hpm_enet_soc_drv.h:80
static hpm_stat_t enet_disable_lpi_interrupt(ENET_Type *ptr)
Definition: hpm_enet_soc_drv.h:48
static hpm_stat_t enet_intf_selection(ENET_Type *ptr, uint8_t inf_type)
Definition: hpm_enet_soc_drv.h:16
static hpm_stat_t enet_rgmii_set_clock_delay(ENET_Type *ptr, uint8_t tx_delay, uint8_t rx_delay)
Definition: hpm_enet_soc_drv.h:63
static hpm_stat_t enet_rgmii_enable_clock(ENET_Type *ptr)
Definition: hpm_enet_soc_drv.h:108
static hpm_stat_t enet_enable_lpi_interrupt(ENET_Type *ptr)
Definition: hpm_enet_soc_drv.h:33
#define HPM_CONCTL
Definition: hpm_soc_ip.h:522
#define HPM_ENET1
Definition: hpm_soc_ip.h:446
uint32_t hpm_stat_t
Definition: hpm_common.h:135
@ status_invalid_argument
Definition: hpm_common.h:191
@ status_success
Definition: hpm_common.h:189
#define CONCTL_CTRL3_ENET1_LPI_IRQ_EN_MASK
Definition: hpm_conctl_regs.h:120
#define CONCTL_CTRL3_ENET1_PHY_INTF_SEL_SET(x)
Definition: hpm_conctl_regs.h:140
#define CONCTL_CTRL2_ENET0_REFCLK_OE_MASK
Definition: hpm_conctl_regs.h:74
#define CONCTL_CTRL0_ENET1_RXCLK_DLY_SEL_SET(x)
Definition: hpm_conctl_regs.h:29
#define CONCTL_CTRL2_ENET0_RMII_TXCLK_SEL_MASK
Definition: hpm_conctl_regs.h:109
#define CONCTL_CTRL2_ENET0_PHY_INTF_SEL_MASK
Definition: hpm_conctl_regs.h:87
#define CONCTL_CTRL2_ENET0_LPI_IRQ_EN_MASK
Definition: hpm_conctl_regs.h:65
#define CONCTL_CTRL3_ENET1_REFCLK_OE_MASK
Definition: hpm_conctl_regs.h:129
#define CONCTL_CTRL0_ENET0_RXCLK_DLY_SEL_MASK
Definition: hpm_conctl_regs.h:45
#define CONCTL_CTRL3_ENET1_RMII_TXCLK_SEL_MASK
Definition: hpm_conctl_regs.h:156
#define CONCTL_CTRL0_ENET0_TXCLK_DLY_SEL_SET(x)
Definition: hpm_conctl_regs.h:56
#define CONCTL_CTRL0_ENET1_TXCLK_DLY_SEL_SET(x)
Definition: hpm_conctl_regs.h:38
#define CONCTL_CTRL0_ENET0_RXCLK_DLY_SEL_SET(x)
Definition: hpm_conctl_regs.h:47
#define CONCTL_CTRL0_ENET0_TXCLK_DLY_SEL_MASK
Definition: hpm_conctl_regs.h:54
#define CONCTL_CTRL2_ENET0_PHY_INTF_SEL_SET(x)
Definition: hpm_conctl_regs.h:89
#define CONCTL_CTRL0_ENET1_TXCLK_DLY_SEL_MASK
Definition: hpm_conctl_regs.h:36
#define CONCTL_CTRL3_ENET1_PHY_INTF_SEL_MASK
Definition: hpm_conctl_regs.h:138
#define CONCTL_CTRL0_ENET1_RXCLK_DLY_SEL_MASK
Definition: hpm_conctl_regs.h:27
Definition: hpm_enet_regs.h:12