emac_dev.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _EMAC_DEV_H_
  14. #define _EMAC_DEV_H_
  15. #include <stdint.h>
  16. #include "soc/emac_reg_v2.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define EMAC_INTR_ENABLE_BIT (EMAC_TRANSMIT_INTERRUPT_ENABLE | EMAC_RECEIVE_INTERRUPT_ENABLE | EMAC_RECEIVE_BUFFER_UNAVAILABLE_ENABLE | EMAC_NORMAL_INTERRUPT_SUMMARY_ENABLE)
  21. struct dma_desc {
  22. uint32_t desc0;
  23. uint32_t desc1;
  24. uint32_t desc2;
  25. uint32_t desc3;
  26. };
  27. struct dma_extended_desc {
  28. struct dma_desc basic;
  29. uint32_t desc4;
  30. uint32_t desc5;
  31. uint32_t desc6;
  32. uint32_t desc7;
  33. };
  34. void emac_enable_clk(bool enable);
  35. void emac_set_clk_rmii(void);
  36. void emac_set_clk_mii(void);
  37. void emac_reset(void);
  38. void emac_set_gpio_pin_rmii(void);
  39. void emac_set_gpio_pin_mii(void);
  40. uint32_t emac_read_mac_version(void);
  41. void emac_dma_init(void);
  42. void emac_mac_init(void);
  43. void emac_enable_dma_tx(void);
  44. void emac_poll_tx_cmd(void);
  45. uint32_t emac_read_tx_cur_reg(void);
  46. void emac_enable_dma_rx(void);
  47. uint32_t emac_read_rx_cur_reg(void);
  48. void emac_poll_rx_cmd(void);
  49. void emac_disable_dma_tx(void);
  50. void emac_disable_dma_rx(void);
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif