-
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 2 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,29 @@ 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 | ||
// hardware: TX0=1, TX1=2, RX0=3, MISO=12, MOSI=13, SCLK=14, CS=15, A0=17 | ||
// board depended defaults: LED_BUILTIN, SDA, SCL | ||
// 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 1 | ||
#define TOTAL_PINS 18 // 11 digital + 1 analog + 6 inaccessible | ||
#define VERSION_BLINK_PIN LED_BUILTIN | ||
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. Remove 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. will be removed with next commit |
||
#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 PIN_SERIAL1_TX 2 | ||
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 think Firmata Serial supports just a TX pin without the RX pair. 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 thought so and that is way I choose to set |
||
#define IS_PIN_DIGITAL(p) (((p) >= 0 && (p) <= 5) || ((p) >= 12 && (p) <= 16)) | ||
#define IS_PIN_ANALOG(p) ((p) == A0) | ||
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. What about the wifio?
? 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. Please tell me where these constants are needed for. A0 = 17 is already in use in the esp8266/Arduino project for the one and only analog input pin. 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. OK, found it myself. For this board probably a separate definition is needed in Board.h and that may not be enough to make it work. 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. 👍 |
||
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(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) >= 12 && (p) <= 15) | ||
#define IS_PIN_INTERRUPT(p) (((p) >= 0 && (p) <= 5) || ((p) >= 12 && (p) <= 15)) | ||
#define IS_PIN_SERIAL(p) ((p) == 1 || (p) == 3) | ||
#define PIN_TO_DIGITAL(p) (p) | ||
#define PIN_TO_ANALOG(p) ((p) - 17) | ||
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) | ||
#define PIN_TO_SERVO(p) p | ||
#define PIN_TO_SERVO(p) (p) | ||
|
||
|
||
// anything else | ||
|
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.