Skip to content

Commit

Permalink
Add direct I/O code for ESP8266
Browse files Browse the repository at this point in the history
  • Loading branch information
UnicronNL committed Apr 25, 2015
1 parent 7684dff commit b1b1d7f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CapacitiveSensor.h
Expand Up @@ -64,6 +64,17 @@
#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24
#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28

#elif defined(ARDUINO_ARCH_ESP8266)
#define PIN_TO_BASEREG(pin) (portOutputRegister(digitalPinToPort(pin)))
#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin))
#define IO_REG_TYPE uint32_t
#define IO_REG_ASM
#define DIRECT_READ(base, mask) (((*(base+6)) & (mask)) ? 1 : 0) //GPIO_IN_ADDRESS
#define DIRECT_MODE_INPUT(base, mask) ((*(base+5)) = (mask)) //GPIO_ENABLE_W1TC_ADDRESS
#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+4)) = (mask)) //GPIO_ENABLE_W1TS_ADDRESS
#define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) = (mask)) //GPIO_OUT_W1TC_ADDRESS
#define DIRECT_WRITE_HIGH(base, mask) ((*(base+1)) = (mask)) //GPIO_OUT_W1TS_ADDRESS

#endif

// some 3.3V chips with 5V tolerant pins need this workaround
Expand Down

5 comments on commit b1b1d7f

@develpr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i hate to ask a silly question, but I see you made a change here for the esp8266, but I didn't see it reflected anywhere in the docs, nor can I find reference to your library + the esp8266. I have an esp-12E which has an exposed ADC pin, but I'm not sure exactly how to actually implement your library with this. Any chance you'd update the docs or provide a quick example?

@Idan-BM
Copy link

@Idan-BM Idan-BM commented on b1b1d7f Apr 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im using WEMOS D1 mini and i cant seem to use this library at all, even with your modification.
any Ideas?

@PaulStoffregen
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno. I haven't used ESP8266. I'm relying on community contributions. If you find the answer elsewhere, maybe post a followup here? Or if something needs fixing, I'm depending on the ESP community to submit good pull requests to solve these sorts of issues.

@Idan-BM
Copy link

@Idan-BM Idan-BM commented on b1b1d7f Apr 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My wemos is not responding.
I can't upload any code since I ran your example ):
I dont know what to do!
Its dead...

@PaulStoffregen
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ask Wemos for help?

Please sign in to comment.