ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
ets_sys.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2008 - 2011 Espressif System
3  *
4  * Define user specified Event signals and Task priorities here
5  *
6  */
7 
8 #ifndef _ETS_SYS_H
9 #define _ETS_SYS_H
10 
11 #include "c_types.h"
12 #include "eagle_soc.h"
13 #include "stdarg.h"
14 
17 
18 typedef struct ETSEventTag ETSEvent;
19 
20 struct ETSEventTag {
23 };
24 
25 typedef void (*ETSTask)(ETSEvent *e);
26 
27 /* timer related */
29 typedef void ETSTimerFunc(void *timer_arg);
30 
31 typedef struct _ETSTIMER_ {
36  void *timer_arg;
37 } ETSTimer;
38 
39 /* interrupt related */
40 
41 typedef void (*int_handler_t)(void*);
42 
43 #define ETS_SLC_INUM 1
44 #define ETS_SPI_INUM 2
45 #define ETS_GPIO_INUM 4
46 #define ETS_UART_INUM 5
47 #define ETS_UART1_INUM 5
48 #define ETS_CCOMPARE0_INUM 6
49 #define ETS_SOFT_INUM 7
50 #define ETS_WDT_INUM 8
51 #define ETS_FRC_TIMER1_INUM 9 /* use edge*/
52 
53 #define ETS_INTR_LOCK() \
54  ets_intr_lock()
55 
56 #define ETS_INTR_UNLOCK() \
57  ets_intr_unlock()
58 
59 #define ETS_INTR_ENABLE(inum) \
60  ets_isr_unmask((1<<inum))
61 
62 #define ETS_INTR_DISABLE(inum) \
63  ets_isr_mask((1<<inum))
64 
65 inline bool ETS_INTR_WITHINISR()
66 {
67  uint32_t ps;
68  __asm__ __volatile__("rsr %0,ps":"=a" (ps));
69  // PS.INTLEVEL check
70  return ((ps & 0x0f) != 0);
71 }
72 
74 {
75  uint32_t enabled;
76  __asm__ __volatile__("esync; rsr %0,intenable":"=a" (enabled));
77  return enabled;
78 }
79 
81 {
82  uint32_t pending;
83  __asm__ __volatile__("esync; rsr %0,interrupt":"=a" (pending));
84  return pending;
85 }
86 
87 #define ETS_CCOMPARE0_INTR_ATTACH(func, arg) \
88  ets_isr_attach(ETS_CCOMPARE0_INUM, (int_handler_t)(func), (void *)(arg))
89 
90 #define ETS_CCOMPARE0_ENABLE() \
91  ETS_INTR_ENABLE(ETS_CCOMPARE0_INUM)
92 
93 #define ETS_CCOMPARE0_DISABLE() \
94  ETS_INTR_DISABLE(ETS_CCOMPARE0_INUM)
95 
96 
97 #define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
98  ets_isr_attach(ETS_FRC_TIMER1_INUM, (int_handler_t)(func), (void *)(arg))
99 
100 #define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \
101  NmiTimSetFunc(func)
102 
103 #define ETS_GPIO_INTR_ATTACH(func, arg) \
104  ets_isr_attach(ETS_GPIO_INUM, (int_handler_t)(func), (void *)(arg))
105 
106 #define ETS_GPIO_INTR_ENABLE() \
107  ETS_INTR_ENABLE(ETS_GPIO_INUM)
108 
109 #define ETS_GPIO_INTR_DISABLE() \
110  ETS_INTR_DISABLE(ETS_GPIO_INUM)
111 
112 
113 #define ETS_UART_INTR_ATTACH(func, arg) \
114  ets_isr_attach(ETS_UART_INUM, (int_handler_t)(func), (void *)(arg))
115 
116 #define ETS_UART_INTR_ENABLE() \
117  ETS_INTR_ENABLE(ETS_UART_INUM)
118 
119 #define ETS_UART_INTR_DISABLE() \
120  ETS_INTR_DISABLE(ETS_UART_INUM)
121 
122 #define ETS_FRC1_INTR_ENABLE() \
123  ETS_INTR_ENABLE(ETS_FRC_TIMER1_INUM)
124 
125 #define ETS_FRC1_INTR_DISABLE() \
126  ETS_INTR_DISABLE(ETS_FRC_TIMER1_INUM)
127 
128 
129 #define ETS_SPI_INTR_ATTACH(func, arg) \
130  ets_isr_attach(ETS_SPI_INUM, (int_handler_t)(func), (void *)(arg))
131 
132 #define ETS_SPI_INTR_ENABLE() \
133  ETS_INTR_ENABLE(ETS_SPI_INUM)
134 
135 #define ETS_SPI_INTR_DISABLE() \
136  ETS_INTR_DISABLE(ETS_SPI_INUM)
137 
138 
139 #define ETS_SLC_INTR_ATTACH(func, arg) \
140  ets_isr_attach(ETS_SLC_INUM, (int_handler_t)(func), (void *)(arg))
141 
142 #define ETS_SLC_INTR_ENABLE() \
143  ETS_INTR_ENABLE(ETS_SLC_INUM)
144 
145 #define ETS_SLC_INTR_DISABLE() \
146  ETS_INTR_DISABLE(ETS_SLC_INUM)
147 
148 
149 void *pvPortMalloc(size_t xWantedSize) __attribute__((malloc, alloc_size(1)));
150 void *pvPortRealloc(void* ptr, size_t xWantedSize) __attribute__((alloc_size(2)));
151 void pvPortFree(void *ptr);
152 void *vPortMalloc(size_t xWantedSize) __attribute__((malloc, alloc_size(1)));
153 void vPortFree(void *ptr);
154 void *ets_memcpy(void *dest, const void *src, size_t n);
155 void *ets_memset(void *s, int c, size_t n);
156 void ets_timer_arm_new(ETSTimer *a, int b, int c, int isMstimer);
157 void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg);
158 void ets_timer_disarm(ETSTimer *a);
159 int atoi(const char *nptr);
160 int ets_strncmp(const char *s1, const char *s2, int len);
161 int ets_strcmp(const char *s1, const char *s2);
162 int ets_strlen(const char *s);
163 char *ets_strcpy(char *dest, const char *src);
164 char *ets_strncpy(char *dest, const char *src, size_t n);
165 char *ets_strstr(const char *haystack, const char *needle);
166 int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
167 int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
168 int ets_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
169 void ets_install_putc1(void* routine);
170 void uart_div_modify(int no, int freq);
171 void ets_isr_mask(int intr);
172 void ets_isr_unmask(int intr);
173 void ets_isr_attach(int intr, int_handler_t handler, void *arg);
174 void ets_intr_lock();
175 void ets_intr_unlock();
176 int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));
177 int ets_vprintf(const char * format, va_list arg) __attribute__ ((format (printf, 1, 0)));
178 
179 #endif /* _ETS_SYS_H */
void * timer_arg
Definition: ets_sys.h:36
void * pvPortMalloc(size_t xWantedSize) __attribute__((malloc
void * ets_memset(void *s, int c, size_t n)
void ets_isr_unmask(int intr)
void ets_isr_attach(int intr, int_handler_t handler, void *arg)
int ets_strcmp(const char *s1, const char *s2)
uint32_t timer_period
Definition: ets_sys.h:34
void ets_intr_unlock()
cont_t g_cont __attribute__((aligned(16)))
bool ETS_INTR_WITHINISR()
Definition: ets_sys.h:65
void ETSTimerFunc(void *timer_arg)
Definition: ets_sys.h:29
uint32_t ETS_INTR_PENDING(void)
Definition: ets_sys.h:80
struct _ETSTIMER_ * timer_next
Definition: ets_sys.h:32
char * ets_strcpy(char *dest, const char *src)
int atoi(const char *nptr)
Convert ASCII string to number in base 10.
Definition: mathio.c:281
unsigned int uint32_t
Definition: send.c:19
char * ets_strstr(const char *haystack, const char *needle)
uint32_t ETS_INTR_ENABLED(void)
Definition: ets_sys.h:73
ETSParam par
Definition: ets_sys.h:22
int int int void ets_install_putc1(void *routine)
struct _ETSTIMER_ ETSTimer
void alloc_size(1)))
uint32_t timer_expire
Definition: ets_sys.h:33
uint32_t ETSParam
Definition: ets_sys.h:16
uint32_t ETSHandle
Definition: ets_sys.h:28
void pvPortFree(void *ptr)
uint32_t ETSSignal
Definition: ets_sys.h:15
void(* int_handler_t)(void *)
Definition: ets_sys.h:41
int ets_strncmp(const char *s1, const char *s2, int len)
ETSSignal sig
Definition: ets_sys.h:21
MEMSPACE void * malloc(size_t size)
malloc buffer POSIX function
Definition: system.c:51
void * vPortMalloc(size_t xWantedSize) __attribute__((malloc
void ets_isr_mask(int intr)
void * ets_memcpy(void *dest, const void *src, size_t n)
int int ets_vprintf(const char *format, va_list arg) __attribute__((format(printf
void ets_timer_disarm(ETSTimer *a)
int ets_vsnprintf(char *s, size_t n, const char *format, va_list arg) __attribute__((format(printf
void * pvPortRealloc(void *ptr, size_t xWantedSize) __attribute__((alloc_size(2)))
MEMSPACE int printf(const char *format,...)
void(* ETSTask)(ETSEvent *e)
Definition: ets_sys.h:25
void uart_div_modify(int no, int freq)
char * ets_strncpy(char *dest, const char *src, size_t n)
void ets_intr_lock()
void vPortFree(void *ptr)
int ets_sprintf(char *str, const char *format,...) __attribute__((format(printf
int int int ets_printf(const char *format,...) __attribute__((format(printf
void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg)
ETSTimerFunc * timer_func
Definition: ets_sys.h:35
int int os_snprintf(char *str, size_t size, const char *format,...) __attribute__((format(printf
void ets_timer_arm_new(ETSTimer *a, int b, int c, int isMstimer)
int ets_strlen(const char *s)