From a8f5d15fc6f2ee988e028ce8a5fc9f50c17309f4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 18 Apr 2014 22:48:59 +0100 Subject: [PATCH] stmhal: Update help and comments re gpio changing to Pin. --- stmhal/help.c | 11 +++++------ stmhal/modpyb.c | 1 - stmhal/pin.c | 12 ++++++------ stmhal/qstrdefsport.h | 3 --- stmhal/usrsw.c | 4 +--- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/stmhal/help.c b/stmhal/help.c index 76dcb2f4e..1dabd9cc8 100644 --- a/stmhal/help.c +++ b/stmhal/help.c @@ -21,21 +21,20 @@ STATIC const char *help_text = " pyb.switch(f) -- call the given function when the switch is pressed\n" " pyb.Led(n) -- create Led object for LED n (n=1,2,3,4)\n" " Led methods: on(), off(), toggle(), intensity()\n" +" pyb.Pin(pin) -- get a pin\n" +" pyb.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p\n" +" Pin methods: value([v]), high(), low()\n" " pyb.Servo(n) -- create Servo object for servo n (n=1,2,3,4)\n" " Servo methods: calibrate(...), pulse_width([p]), angle([x, [t]]), speed([x, [t]])\n" " pyb.Accel() -- create an Accelerometer object\n" " Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()\n" " pyb.rng() -- get a 30-bit hardware random number\n" -" pyb.gpio_in(port, [m]) -- set IO port to input, mode m\n" -" pyb.gpio_out(port, [m]) -- set IO port to output, mode m\n" -" pyb.gpio(port) -- get digital port value\n" -" pyb.gpio(port, val) -- set digital port value, True or False, 1 or 0\n" " pyb.ADC(port) -- make an analog port object\n" " ADC methods: read()\n" "\n" "Ports are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name\n" -"Port input modes are: pyb.PULL_NONE, pyb.PULL_UP, pyb.PULL_DOWN\n" -"Port output modes are: pyb.PUSH_PULL, pyb.OPEN_DRAIN\n" +"Port IO modes are: pyb.Pin.IN, pyb.Pin.OUT_PP, pyb.Pin.OUT_OD\n" +"Port pull modes are: pyb.Pin.PULL_NONE, pyb.Pin.PULL_UP, pyb.Pin.PULL_DOWN\n" "\n" "Control commands:\n" " CTRL-A -- on a blank line, enter raw REPL mode\n" diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index bb41f3e35..c17c64202 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -13,7 +13,6 @@ #include "pybstdio.h" #include "pyexec.h" #include "led.h" -#include "gpio.h" #include "pin.h" #include "extint.h" #include "usrsw.h" diff --git a/stmhal/pin.c b/stmhal/pin.c index ed5865d79..ce66a7ad6 100644 --- a/stmhal/pin.c +++ b/stmhal/pin.c @@ -18,7 +18,7 @@ // // x1_pin = pyb.Pin.board.X1 // -// g = pyb.gpio(pyb.Pin.board.X1, 0) +// g = pyb.Pin(pyb.Pin.board.X1, pyb.Pin.IN) // // CPU pins which correspond to the board pins are available // as pyb.cpu.Name. For the CPU pins, the names are the port letter @@ -27,16 +27,16 @@ // // You can also use strings: // -// g = pyb.gpio('X1', 0) +// g = pyb.Pin('X1', pyb.Pin.OUT_PP) // // Users can add their own names: // -// pyb.Pin("LeftMotorDir", pyb.Pin.cpu.C12) -// g = pyb.gpio("LeftMotorDir", 0) +// pyb.Pin.dict["LeftMotorDir"] = pyb.Pin.cpu.C12 +// g = pyb.Pin("LeftMotorDir", pyb.Pin.OUT_OD) // // and can query mappings // -// pin = pyb.Pin("LeftMotorDir"); +// pin = pyb.Pin("LeftMotorDir") // // Users can also add their own mapping function: // @@ -46,7 +46,7 @@ // // pyb.Pin.mapper(MyMapper) // -// So, if you were to call: pyb.gpio("LeftMotorDir", 0) +// So, if you were to call: pyb.Pin("LeftMotorDir", pyb.Pin.OUT_PP) // then "LeftMotorDir" is passed directly to the mapper function. // // To summarize, the following order determines how things get mapped into diff --git a/stmhal/qstrdefsport.h b/stmhal/qstrdefsport.h index f2ba3669e..e77f85bff 100644 --- a/stmhal/qstrdefsport.h +++ b/stmhal/qstrdefsport.h @@ -34,9 +34,6 @@ Q(rng) Q(LCD) Q(SD) Q(SDcard) -Q(gpio) -Q(gpio_in) -Q(gpio_out) Q(FileIO) // Entries for sys.path Q(0:/) diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c index 6e73cf69b..0d5d7e9b0 100644 --- a/stmhal/usrsw.c +++ b/stmhal/usrsw.c @@ -6,12 +6,10 @@ #include "qstr.h" #include "obj.h" #include "runtime.h" -#include "usrsw.h" - #include "extint.h" -#include "gpio.h" #include "pin.h" #include "genhdr/pins.h" +#include "usrsw.h" // Usage Model: //