forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ficeto
authored and
ficeto
committed
Apr 30, 2015
1 parent
cf9da93
commit fbec557
Showing
32 changed files
with
1,427 additions
and
1,224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
timer.c - Timer1 library for esp8266 | ||
Copyright (c) 2015 Hristo Gochkov. All rights reserved. | ||
This file is part of the esp8266 core for Arduino environment. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
#include "wiring_private.h" | ||
#include "pins_arduino.h" | ||
#include "c_types.h" | ||
|
||
void (*timer1_user_cb)(void); | ||
|
||
void timer1_isr_handler(void *para){ | ||
if((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable | ||
T1I = 0; | ||
if(timer1_user_cb) timer1_user_cb(); | ||
} | ||
|
||
void timer1_attachInterrupt(void (*userFunc)(void)) { | ||
timer1_user_cb = userFunc; | ||
ETS_FRC1_INTR_ENABLE(); | ||
} | ||
|
||
void timer1_detachInterrupt() { | ||
timer1_user_cb = 0; | ||
TEIE &= ~TEIE1;//edge int disable | ||
ETS_FRC1_INTR_DISABLE(); | ||
} | ||
|
||
void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload){ | ||
T1C = (1 << TCTE) | ((divider & 3) << TCPD) | ((int_type & 1) << TCIT) | ((reload & 1) << TCAR); | ||
T1I = 0; | ||
} | ||
|
||
void timer1_write(uint32_t ticks){ | ||
T1L = ((ticks) & 0x7FFFFF); | ||
if((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable | ||
} | ||
|
||
void timer1_disable(){ | ||
T1C = 0; | ||
T1I = 0; | ||
} | ||
|
||
void timer1_isr_init(){ | ||
ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,56 @@ | ||
/* | ||
core_esp8266_analog.c - an interface to the esp8266 ADC | ||
analog.c - analogRead implementation for esp8266 | ||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. | ||
This file is part of the esp8266 core for Arduino environment. | ||
Copyright (c) 2015 Hristo Gochkov. All rights reserved. | ||
This file is part of the esp8266 core for Arduino environment. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
#include "wiring_private.h" | ||
#include "pins_arduino.h" | ||
|
||
void analogReference(uint8_t mode) { | ||
} | ||
void analogReference(uint8_t mode) {} | ||
|
||
extern int __analogRead(uint8_t pin) { | ||
if(pin == 0) | ||
return system_adc_read(); | ||
|
||
return 0; | ||
if(pin == 17){ | ||
//return system_adc_read(); | ||
uint8_t i; | ||
uint16_t data[8]; | ||
|
||
rom_i2c_writeReg_Mask(0x6C,2,0,5,5,1); | ||
|
||
ESP8266_REG(0xD5C) |= (1 << 21); | ||
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0); | ||
ESP8266_REG(0xD50) &= ~(1 << 1); | ||
ESP8266_REG(0xD50) |= (1 << 1); | ||
delayMicroseconds(2); | ||
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0); | ||
|
||
read_sar_dout(data); | ||
rom_i2c_writeReg_Mask(0x6C,2,0,5,5,1); | ||
|
||
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0); | ||
ESP8266_REG(0xD5C) &= ~(1 << 21); | ||
ESP8266_REG(0xD60) |= (1 << 0); | ||
ESP8266_REG(0xD60) &= ~(1 << 0); | ||
|
||
uint16_t tout = 0; | ||
for (i = 0; i < 8; i++) tout += data[i]; | ||
return tout >> 4;//tout is 10 bits fraction | ||
} | ||
return digitalRead(pin) * 1023; | ||
} | ||
|
||
extern int analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead"))); |
Oops, something went wrong.