1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "soc/emac_reg_v2.h"
25 #define EMAC_INTR_ENABLE_BIT (EMAC_TRANSMIT_INTERRUPT_ENABLE | EMAC_RECEIVE_INTERRUPT_ENABLE | EMAC_RECEIVE_BUFFER_UNAVAILABLE_ENABLE | EMAC_NORMAL_INTERRUPT_SUMMARY_ENABLE)
34 struct dma_extended_desc {
35 struct dma_desc basic;
42 void emac_enable_clk(bool enable);
43 void emac_set_clk_rmii(void);
44 void emac_set_clk_mii(void);
45 void emac_reset(void);
46 void emac_set_gpio_pin_rmii(void);
47 void emac_set_gpio_pin_mii(void);
48 uint32_t emac_read_mac_version(void);
49 void emac_dma_init(void);
50 void emac_mac_init(void);
51 void emac_enable_dma_tx(void);
52 void emac_enable_dma_rx(void);
53 void emac_disable_dma_tx(void);
54 void emac_disable_dma_rx(void);
56 uint32_t inline emac_read_tx_cur_reg(void)
58 return REG_READ(EMAC_DMATXCURRDESC_REG);
61 uint32_t inline emac_read_rx_cur_reg(void)
63 return REG_READ(EMAC_DMARXCURRDESC_REG);
66 void inline emac_poll_tx_cmd(void)
68 //write any to wake up dma
69 REG_WRITE(EMAC_DMATXPOLLDEMAND_REG, 1);
72 void inline emac_poll_rx_cmd(void)
74 //write any to wake up dma
75 REG_WRITE(EMAC_DMARXPOLLDEMAND_REG, 1);
78 void inline emac_disable_rx_intr(void)
80 REG_CLR_BIT(EMAC_DMAINTERRUPT_EN_REG,EMAC_RECEIVE_INTERRUPT_ENABLE);
83 void inline emac_enable_rx_intr(void)
85 REG_SET_BIT(EMAC_DMAINTERRUPT_EN_REG,EMAC_RECEIVE_INTERRUPT_ENABLE);
88 void inline emac_disable_rx_unavail_intr(void)
90 REG_CLR_BIT(EMAC_DMAINTERRUPT_EN_REG,EMAC_RECEIVE_BUFFER_UNAVAILABLE_ENABLE);
93 void inline emac_enable_rx_unavail_intr(void)
95 REG_SET_BIT(EMAC_DMAINTERRUPT_EN_REG,EMAC_RECEIVE_BUFFER_UNAVAILABLE_ENABLE);