-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pin functions based on board depended defaults #278
Changes from all commits
cefeaa3
fb243ce
a375d3a
e6a09e5
71af575
1f3527a
ec29b12
625cff9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -665,22 +665,26 @@ writePort(port, value, bitmask): Write an 8 bit port. | |
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) | ||
#define PIN_TO_SERVO(p) ((p) - 2) | ||
|
||
// ESP8266 generic | ||
// ESP8266 | ||
// note: boot mode GPIOs 0, 2 and 15 can be used as outputs, GPIOs 6-11 are in use for flash IO | ||
#elif defined(ESP8266) | ||
#define TOTAL_ANALOG_PINS 0 | ||
#define TOTAL_PINS 17 | ||
#define VERSION_BLINK_PIN 4 | ||
// #define IS_PIN_DIGITAL(p) ((p) == 0 || (p) == 1 || (p) == 2 || (p) == 3 || (p) == 4 || (p) == 5 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 || (p) == 16) //for wifi dont protect serial pins because these things only have 2 pins otherwise | ||
#define IS_PIN_DIGITAL(p) ((p) == 0 || (p) == 2 || (p) == 4 || (p) == 5 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 || (p) == 16) | ||
#define IS_PIN_ANALOG(p) (false) | ||
#define IS_PIN_PWM(p) (false) | ||
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) | ||
#define IS_PIN_I2C(p) (false) | ||
#define IS_PIN_SPI(p) (false) | ||
#define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS | ||
#define TOTAL_PINS A0 + NUM_ANALOG_INPUTS | ||
#define PIN_SERIAL_RX 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to verify - this maps to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin 3+1 are Serial (or port 0) and can be used for SerialFirmata. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. per this issue: #193 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot about this, cause I'm mixing Firmata, ConfigurableFirmata and my own mods of Firmata a lot. So this is for future use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do pins 3 and 1 appear to be common for RX and TX across all ESP8266 board variants? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serial has some special properties with the ESP8266. I don't think they can be completely described in a Boards.h approach (e.g. similar to the PWM resolution you can change the serial pin assignment and there is a Serial1 but you typically can't use the RX pin). The details are described here. All boards seem to have Serial in common and the default mapping for Serial is always pins 1 and 3. |
||
#define PIN_SERIAL_TX 1 | ||
#define IS_PIN_DIGITAL(p) (((p) >= 0 && (p) <= 5) || ((p) >= 12 && (p) < A0)) | ||
#define IS_PIN_ANALOG(p) ((p) >= A0 && (p) < A0 + NUM_ANALOG_INPUTS) | ||
#define IS_PIN_PWM(p) digitalPinHasPWM(p) | ||
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) | ||
#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is SDA and SCL defined for all ESP variants or only specific ones? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know all these boards myself, but I checked all the "variants...\pins_arduino.h" header files. They all have the pins defined, mostly on pins 4+5, but not all. Maybe the SDA/SCL pins are not always physically available to the user. From the project documentation I get the impression that I2C is always available. The pins in the header files are defaults but can be remapped to almost any other pins with Wire.begin(...) similar to SoftwareSerial. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Confirmed. Sparkfun Thing:
(The only exception) |
||
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK) | ||
#define IS_PIN_INTERRUPT(p) (digitalPinToInterrupt(p) > NOT_AN_INTERRUPT) | ||
#define IS_PIN_SERIAL(p) ((p) == PIN_SERIAL_RX || (p) == PIN_SERIAL_TX) | ||
#define PIN_TO_DIGITAL(p) (p) | ||
#define PIN_TO_ANALOG(p) ((p) - 17) | ||
#define PIN_TO_ANALOG(p) ((p) - A0) | ||
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) | ||
#define PIN_TO_SERVO(p) p | ||
#define PIN_TO_SERVO(p) (p) | ||
#define DEFAULT_PWM_RESOLUTION 10 | ||
|
||
|
||
// anything else | ||
|
@@ -697,6 +701,9 @@ writePort(port, value, bitmask): Write an 8 bit port. | |
#define IS_PIN_SERIAL(p) 0 | ||
#endif | ||
|
||
#ifndef DEFAULT_PWM_RESOLUTION | ||
#define DEFAULT_PWM_RESOLUTION 8 | ||
#endif | ||
|
||
/*============================================================================== | ||
* readPort() - Read an 8 bit port | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several different popular boards using this chip. We should include a comment that states which specific boards have been tested to work with this set of pin definitions.