MeterLogger
ets_sys.h
Go to the documentation of this file.
1 /*
2  * ESPRSSIF 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 
25 #ifndef _ETS_SYS_H
26 #define _ETS_SYS_H
27 
28 #include "c_types.h"
29 #include "eagle_soc.h"
30 
31 typedef uint32_t ETSSignal;
32 typedef uint32_t ETSParam;
33 
34 typedef struct ETSEventTag ETSEvent;
35 
36 struct ETSEventTag {
39 };
40 
41 typedef void (*ETSTask)(ETSEvent *e);
42 
43 /* timer related */
44 typedef uint32_t ETSHandle;
45 typedef void ETSTimerFunc(void *timer_arg);
46 
47 typedef struct _ETSTIMER_ {
49  uint32_t timer_expire;
50  uint32_t timer_period;
52  void *timer_arg;
53 } ETSTimer;
54 
55 /* interrupt related */
56 #define ETS_SDIO_INUM 1
57 #define ETS_SPI_INUM 2
58 #define ETS_GPIO_INUM 4
59 #define ETS_UART_INUM 5
60 #define ETS_UART1_INUM 5
61 #define ETS_FRC_TIMER1_INUM 9 /* use edge*/
62 
63 #define ETS_INTR_LOCK() \
64  ets_intr_lock()
65 
66 #define ETS_INTR_UNLOCK() \
67  ets_intr_unlock()
68 
69 #define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
70  ets_isr_attach(ETS_FRC_TIMER1_INUM, (func), (void *)(arg))
71 
72 #define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \
73  NmiTimSetFunc(func)
74 
75 #define ETS_SDIO_INTR_ATTACH(func, arg)\
76  ets_isr_attach(ETS_SDIO_INUM, (func), (void *)(arg))
77 
78 #define ETS_GPIO_INTR_ATTACH(func, arg) \
79  ets_isr_attach(ETS_GPIO_INUM, (func), (void *)(arg))
80 
81 #define ETS_UART_INTR_ATTACH(func, arg) \
82  ets_isr_attach(ETS_UART_INUM, (func), (void *)(arg))
83 
84 #define ETS_SPI_INTR_ATTACH(func, arg) \
85  ets_isr_attach(ETS_SPI_INUM, (func), (void *)(arg))
86 
87 #define ETS_INTR_ENABLE(inum) \
88  ets_isr_unmask((1<<inum))
89 
90 #define ETS_INTR_DISABLE(inum) \
91  ets_isr_mask((1<<inum))
92 
93 #define ETS_UART_INTR_ENABLE() \
94  ETS_INTR_ENABLE(ETS_UART_INUM)
95 
96 #define ETS_UART_INTR_DISABLE() \
97  ETS_INTR_DISABLE(ETS_UART_INUM)
98 
99 #define ETS_FRC1_INTR_ENABLE() \
100  ETS_INTR_ENABLE(ETS_FRC_TIMER1_INUM)
101 
102 #define ETS_FRC1_INTR_DISABLE() \
103  ETS_INTR_DISABLE(ETS_FRC_TIMER1_INUM)
104 
105 #define ETS_GPIO_INTR_ENABLE() \
106  ETS_INTR_ENABLE(ETS_GPIO_INUM)
107 
108 #define ETS_GPIO_INTR_DISABLE() \
109  ETS_INTR_DISABLE(ETS_GPIO_INUM)
110 
111 #define ETS_SPI_INTR_ENABLE() \
112  ETS_INTR_ENABLE(ETS_SPI_INUM)
113 
114 #define ETS_SPI_INTR_DISABLE() \
115  ETS_INTR_DISABLE(ETS_SPI_INUM)
116 
117 #define ETS_SDIO_INTR_ENABLE() \
118  ETS_INTR_ENABLE(ETS_SDIO_INUM)
119 
120 #define ETS_SDIO_INTR_DISABLE() \
121  ETS_INTR_DISABLE(ETS_SDIO_INUM)
122 #endif /* _ETS_SYS_H */
ETSTimerFunc * timer_func
Definition: ets_sys.h:51
uint32_t timer_period
Definition: ets_sys.h:50
void ETSTimerFunc(void *timer_arg)
Definition: ets_sys.h:45
ETSSignal sig
Definition: ets_sys.h:37
ETSParam par
Definition: ets_sys.h:38
struct _ETSTIMER_ ETSTimer
uint32_t ETSParam
Definition: ets_sys.h:32
uint32_t ETSHandle
Definition: ets_sys.h:44
uint32_t ETSSignal
Definition: ets_sys.h:31
struct _ETSTIMER_ * timer_next
Definition: ets_sys.h:48
void * timer_arg
Definition: ets_sys.h:52
void(* ETSTask)(ETSEvent *e)
Definition: ets_sys.h:41
uint32_t timer_expire
Definition: ets_sys.h:49