ets_sys.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * ESPRESSIF MIT License
  3. *
  4. * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
  5. *
  6. * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
  7. * it is free of charge, to any person obtaining a copy of this software and associated
  8. * documentation files (the "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
  11. * to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef _ETS_SYS_H
  25. #define _ETS_SYS_H
  26. #include "c_types.h"
  27. #include "eagle_soc.h"
  28. typedef uint32_t ETSSignal;
  29. typedef uint32_t ETSParam;
  30. typedef struct ETSEventTag ETSEvent;
  31. struct ETSEventTag {
  32. ETSSignal sig;
  33. ETSParam par;
  34. };
  35. typedef void (*ETSTask)(ETSEvent *e);
  36. /* timer related */
  37. typedef uint32_t ETSHandle;
  38. typedef void ETSTimerFunc(void *timer_arg);
  39. typedef struct _ETSTIMER_ {
  40. struct _ETSTIMER_ *timer_next;
  41. uint32_t timer_expire;
  42. uint32_t timer_period;
  43. ETSTimerFunc *timer_func;
  44. void *timer_arg;
  45. } ETSTimer;
  46. /* interrupt related */
  47. #define ETS_SDIO_INUM 1
  48. #define ETS_SPI_INUM 2
  49. #define ETS_GPIO_INUM 4
  50. #define ETS_UART_INUM 5
  51. #define ETS_UART1_INUM 5
  52. #define ETS_FRC_TIMER1_INUM 9 /* use edge*/
  53. typedef void (* ets_isr_t)(void *);
  54. void ets_intr_lock(void);
  55. void ets_intr_unlock(void);
  56. void ets_isr_attach(int i, ets_isr_t func, void *arg);
  57. void NmiTimSetFunc(void (*func)(void));
  58. #define ETS_INTR_LOCK() \
  59. ets_intr_lock()
  60. #define ETS_INTR_UNLOCK() \
  61. ets_intr_unlock()
  62. #define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
  63. ets_isr_attach(ETS_FRC_TIMER1_INUM, (func), (void *)(arg))
  64. #define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \
  65. NmiTimSetFunc(func)
  66. #define ETS_SDIO_INTR_ATTACH(func, arg)\
  67. ets_isr_attach(ETS_SDIO_INUM, (func), (void *)(arg))
  68. #define ETS_GPIO_INTR_ATTACH(func, arg) \
  69. ets_isr_attach(ETS_GPIO_INUM, (func), (void *)(arg))
  70. #define ETS_UART_INTR_ATTACH(func, arg) \
  71. ets_isr_attach(ETS_UART_INUM, (func), (void *)(arg))
  72. #define ETS_SPI_INTR_ATTACH(func, arg) \
  73. ets_isr_attach(ETS_SPI_INUM, (func), (void *)(arg))
  74. #define ETS_INTR_ENABLE(inum) \
  75. ets_isr_unmask((1<<inum))
  76. #define ETS_INTR_DISABLE(inum) \
  77. ets_isr_mask((1<<inum))
  78. #define ETS_UART_INTR_ENABLE() \
  79. ETS_INTR_ENABLE(ETS_UART_INUM)
  80. #define ETS_UART_INTR_DISABLE() \
  81. ETS_INTR_DISABLE(ETS_UART_INUM)
  82. #define ETS_FRC1_INTR_ENABLE() \
  83. ETS_INTR_ENABLE(ETS_FRC_TIMER1_INUM)
  84. #define ETS_FRC1_INTR_DISABLE() \
  85. ETS_INTR_DISABLE(ETS_FRC_TIMER1_INUM)
  86. #define ETS_GPIO_INTR_ENABLE() \
  87. ETS_INTR_ENABLE(ETS_GPIO_INUM)
  88. #define ETS_GPIO_INTR_DISABLE() \
  89. ETS_INTR_DISABLE(ETS_GPIO_INUM)
  90. #define ETS_SPI_INTR_ENABLE() \
  91. ETS_INTR_ENABLE(ETS_SPI_INUM)
  92. #define ETS_SPI_INTR_DISABLE() \
  93. ETS_INTR_DISABLE(ETS_SPI_INUM)
  94. #define ETS_SDIO_INTR_ENABLE() \
  95. ETS_INTR_ENABLE(ETS_SDIO_INUM)
  96. #define ETS_SDIO_INTR_DISABLE() \
  97. ETS_INTR_DISABLE(ETS_SDIO_INUM)
  98. #endif /* _ETS_SYS_H */