Skip to content

Commit c3b559b

Browse files
author
ficeto
committed
Merge pull request #8 from esp8266/esp8266
pull todays OneWire fix
2 parents f437db3 + 2ea70fc commit c3b559b

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

cores/esp8266/Arduino.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,11 @@ void loop(void);
180180

181181
// Get the bit location within the hardware port of the given virtual pin.
182182
// This comes from the pins_*.c file for the active board configuration.
183-
184-
uint32_t digitalPinToPort(uint32_t pin);
185-
uint32_t digitalPinToBitMask(uint32_t pin);
186-
volatile uint32_t* portOutputRegister(uint32_t port);
187-
volatile uint32_t* portInputRegister(uint32_t port);
188-
volatile uint32_t* portModeRegister(uint32_t port);
183+
#define digitalPinToPort(pin) (0)
184+
#define digitalPinToBitMask(pin) (1UL << (pin))
185+
#define portOutputRegister(port) ((volatile uint32_t*) GPO)
186+
#define portInputRegister(port) ((volatile uint32_t*) GPI)
187+
#define portModeRegister(port) ((volatile uint32_t*) GPE)
189188

190189
#define NOT_A_PIN -1
191190
#define NOT_A_PORT -1

cores/esp8266/core_esp8266_wiring_digital.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@
2525
#include "eagle_soc.h"
2626
#include "ets_sys.h"
2727

28-
uint32_t digitalPinToPort(uint32_t pin) {
29-
return 0;
30-
}
31-
32-
uint32_t digitalPinToBitMask(uint32_t pin) {
33-
return 1 << pin;
34-
}
35-
36-
volatile uint32_t* portOutputRegister(uint32_t port) {
37-
return (volatile uint32_t*)GPO;
38-
}
39-
40-
volatile uint32_t* portInputRegister(uint32_t port) {
41-
return (volatile uint32_t*)GPI;
42-
}
43-
44-
volatile uint32_t* portModeRegister(uint32_t port) {
45-
return (volatile uint32_t*)GPE;
46-
}
47-
4828
extern void __pinMode(uint8_t pin, uint8_t mode) {
4929
if(pin < 16){
5030
if(mode == SPECIAL){

libraries/OneWire/OneWire.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,15 @@
105105
#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28
106106

107107
#elif defined(ARDUINO_ARCH_ESP8266)
108-
#define PIN_TO_BASEREG(pin) (portOutputRegister(digitalPinToPort(pin)))
109-
#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin))
108+
#define PIN_TO_BASEREG(pin) ((volatile uint32_t*) GPO)
109+
#define PIN_TO_BITMASK(pin) (1 << pin)
110110
#define IO_REG_TYPE uint32_t
111111
#define IO_REG_ASM
112-
#define DIRECT_READ(base, mask) (((*(base+6)) & (mask)) ? 1 : 0) //GPIO_IN_ADDRESS
113-
#define DIRECT_MODE_INPUT(base, mask) ((*(base+5)) = (mask)) //GPIO_ENABLE_W1TC_ADDRESS
114-
#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+4)) = (mask)) //GPIO_ENABLE_W1TS_ADDRESS
115-
#define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) = (mask)) //GPIO_OUT_W1TC_ADDRESS
116-
#define DIRECT_WRITE_HIGH(base, mask) ((*(base+1)) = (mask)) //GPIO_OUT_W1TS_ADDRESS
117-
112+
#define DIRECT_READ(base, mask) ((GPI & (mask)) ? 1 : 0) //GPIO_IN_ADDRESS
113+
#define DIRECT_MODE_INPUT(base, mask) (GPE &= ~(mask)) //GPIO_ENABLE_W1TC_ADDRESS
114+
#define DIRECT_MODE_OUTPUT(base, mask) (GPE |= (mask)) //GPIO_ENABLE_W1TS_ADDRESS
115+
#define DIRECT_WRITE_LOW(base, mask) (GPOC = (mask)) //GPIO_OUT_W1TC_ADDRESS
116+
#define DIRECT_WRITE_HIGH(base, mask) (GPOS = (mask)) //GPIO_OUT_W1TS_ADDRESS
118117

119118
#else
120119
#error "Please define I/O register types here"

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ compiler.tools.path={runtime.ide.path}/hardware/tools/esp8266/
1212
compiler.path={compiler.tools.path}xtensa-lx106-elf/bin/
1313
compiler.sdk.path={compiler.tools.path}sdk/
1414

15-
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH "-I{compiler.sdk.path}/include"
15+
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include"
1616

1717
compiler.c.cmd=xtensa-lx106-elf-gcc
1818
compiler.c.flags=-c -Os -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -MMD -std=c99

0 commit comments

Comments
 (0)