1
1
/*
2
- * Copyright (C) 2014 -2016 Espressif System
2
+ * ESPRSSIF MIT License
3
+ *
4
+ * Copyright (c) 2015 <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.
3
22
*
4
23
*/
5
24
8
27
9
28
#include "gpio.h"
10
29
11
- void ICACHE_FLASH_ATTR
12
- gpio_config (GPIO_ConfigTypeDef * pGPIOConfig )
30
+ void gpio_config (GPIO_ConfigTypeDef * pGPIOConfig )
13
31
{
14
32
uint16 gpio_pin_mask = pGPIOConfig -> GPIO_Pin ;
15
33
uint32 io_reg ;
@@ -66,7 +84,6 @@ gpio_config(GPIO_ConfigTypeDef *pGPIOConfig)
66
84
} while (io_num < 16 );
67
85
}
68
86
69
-
70
87
/*
71
88
* Change GPIO pin output by setting, clearing, or disabling pins.
72
89
* In general, it is expected that a bit will be set in at most one
@@ -77,8 +94,7 @@ gpio_config(GPIO_ConfigTypeDef *pGPIOConfig)
77
94
* writes is significant, calling code should divide a single call
78
95
* into multiple calls.
79
96
*/
80
- void ICACHE_FLASH_ATTR
81
- gpio_output_conf (uint32 set_mask , uint32 clear_mask , uint32 enable_mask , uint32 disable_mask )
97
+ void gpio_output_conf (uint32 set_mask , uint32 clear_mask , uint32 enable_mask , uint32 disable_mask )
82
98
{
83
99
GPIO_REG_WRITE (GPIO_OUT_W1TS_ADDRESS , set_mask );
84
100
GPIO_REG_WRITE (GPIO_OUT_W1TC_ADDRESS , clear_mask );
@@ -89,8 +105,7 @@ gpio_output_conf(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32
89
105
/*
90
106
* Sample the value of GPIO input pins and returns a bitmask.
91
107
*/
92
- uint32 ICACHE_FLASH_ATTR
93
- gpio_input_get (void )
108
+ uint32 gpio_input_get (void )
94
109
{
95
110
return GPIO_REG_READ (GPIO_IN_ADDRESS );
96
111
}
@@ -106,17 +121,15 @@ gpio_input_get(void)
106
121
* application-specific handler may wish to use gpio_intr_pending
107
122
* to check for any additional pending interrupts before it returns.
108
123
*/
109
- void ICACHE_FLASH_ATTR
110
- gpio_intr_handler_register (void * fn )
124
+ void gpio_intr_handler_register (void * fn , void * arg )
111
125
{
112
- _xt_isr_attach (ETS_GPIO_INUM , fn );
126
+ _xt_isr_attach (ETS_GPIO_INUM , fn , arg );
113
127
}
114
128
115
129
/*
116
130
only highlevel and lowlevel intr can use for wakeup
117
131
*/
118
- void ICACHE_FLASH_ATTR
119
- gpio_pin_wakeup_enable (uint32 i , GPIO_INT_TYPE intr_state )
132
+ void gpio_pin_wakeup_enable (uint32 i , GPIO_INT_TYPE intr_state )
120
133
{
121
134
uint32 pin_reg ;
122
135
@@ -133,8 +146,7 @@ gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state)
133
146
}
134
147
}
135
148
136
- void ICACHE_FLASH_ATTR
137
- gpio_pin_wakeup_disable (void )
149
+ void gpio_pin_wakeup_disable (void )
138
150
{
139
151
uint8 i ;
140
152
uint32 pin_reg ;
@@ -151,8 +163,7 @@ gpio_pin_wakeup_disable(void)
151
163
}
152
164
}
153
165
154
- void ICACHE_FLASH_ATTR
155
- gpio_pin_intr_state_set (uint32 i , GPIO_INT_TYPE intr_state )
166
+ void gpio_pin_intr_state_set (uint32 i , GPIO_INT_TYPE intr_state )
156
167
{
157
168
uint32 pin_reg ;
158
169
@@ -166,8 +177,7 @@ gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state)
166
177
portEXIT_CRITICAL ();
167
178
}
168
179
169
- void ICACHE_FLASH_ATTR
170
- gpio16_output_conf (void )
180
+ void gpio16_output_conf (void )
171
181
{
172
182
WRITE_PERI_REG (PAD_XPD_DCDC_CONF ,
173
183
(READ_PERI_REG (PAD_XPD_DCDC_CONF ) & 0xffffffbc ) | (uint32 )0x1 ); // mux configuration for XPD_DCDC to output rtc_gpio0
@@ -179,15 +189,13 @@ gpio16_output_conf(void)
179
189
(READ_PERI_REG (RTC_GPIO_ENABLE ) & (uint32 )0xfffffffe ) | (uint32 )0x1 ); //out enable
180
190
}
181
191
182
- void ICACHE_FLASH_ATTR
183
- gpio16_output_set (uint8 value )
192
+ void gpio16_output_set (uint8 value )
184
193
{
185
194
WRITE_PERI_REG (RTC_GPIO_OUT ,
186
195
(READ_PERI_REG (RTC_GPIO_OUT ) & (uint32 )0xfffffffe ) | (uint32 )(value & 1 ));
187
196
}
188
197
189
- void ICACHE_FLASH_ATTR
190
- gpio16_input_conf (void )
198
+ void gpio16_input_conf (void )
191
199
{
192
200
WRITE_PERI_REG (PAD_XPD_DCDC_CONF ,
193
201
(READ_PERI_REG (PAD_XPD_DCDC_CONF ) & 0xffffffbc ) | (uint32 )0x1 ); // mux configuration for XPD_DCDC and rtc_gpio0 connection
@@ -199,9 +207,7 @@ gpio16_input_conf(void)
199
207
READ_PERI_REG (RTC_GPIO_ENABLE ) & (uint32 )0xfffffffe ); //out disable
200
208
}
201
209
202
- uint8 ICACHE_FLASH_ATTR
203
- gpio16_input_get (void )
210
+ uint8 gpio16_input_get (void )
204
211
{
205
212
return (uint8 )(READ_PERI_REG (RTC_GPIO_IN_DATA ) & 1 );
206
213
}
207
-
0 commit comments