From 20da9064d7492b2f37a2140c17e468fb5785a593 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 4 Sep 2016 21:13:55 +0300 Subject: docs/esp8266/quickref: Update information on SPI classes. SPI(1) is not used for hardware SPI. Few more details are provided. --- docs/esp8266/quickref.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/esp8266/quickref.rst b/docs/esp8266/quickref.rst index d20987136..ae7a8f724 100644 --- a/docs/esp8266/quickref.rst +++ b/docs/esp8266/quickref.rst @@ -165,7 +165,8 @@ Use the ``machine.ADC`` class:: SPI bus ------- -There are two SPI drivers. One is implemented in software and works on all pins:: +There are two SPI drivers. One is implemented in software (bit-banging) +and works on all pins:: from machine import Pin, SPI @@ -194,14 +195,15 @@ Hardware SPI ------------ The hardware SPI is faster (up to 80Mhz), but only works on following pins: -``MISO`` is gpio12, ``MOSI`` is gpio13, and ``SCK`` is gpio14. It has the same +``MISO`` is GPIO12, ``MOSI`` is GPIO13, and ``SCK`` is GPIO14. It has the same methods as SPI, except for the pin parameters for the constructor and init (as those are fixed). from machine import Pin, SPI - hspi = SPI(0, baudrate=80000000, polarity=0, phase=0) + hspi = SPI(1, baudrate=80000000, polarity=0, phase=0) +(SPI(0) is used for FlashROM and not available to users.) I2C bus ------- -- cgit v1.2.3 From b4df3e74e15ac1658c125b13bbaca5203bab5505 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 4 Sep 2016 23:31:05 +0300 Subject: docs/esp8266/quickref: Further improvements for SPI subsections. Consistency and formatting. --- docs/esp8266/quickref.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/esp8266/quickref.rst b/docs/esp8266/quickref.rst index ae7a8f724..d06fe5a6f 100644 --- a/docs/esp8266/quickref.rst +++ b/docs/esp8266/quickref.rst @@ -162,8 +162,8 @@ Use the ``machine.ADC`` class:: adc = ADC(0) # create ADC object on ADC pin adc.read() # read value, 0-1024 -SPI bus -------- +Software SPI bus +---------------- There are two SPI drivers. One is implemented in software (bit-banging) and works on all pins:: @@ -191,19 +191,19 @@ and works on all pins:: spi.write_readinto(buf, buf) # write buf to MOSI and read MISO back into buf -Hardware SPI ------------- +Hardware SPI bus +---------------- The hardware SPI is faster (up to 80Mhz), but only works on following pins: ``MISO`` is GPIO12, ``MOSI`` is GPIO13, and ``SCK`` is GPIO14. It has the same -methods as SPI, except for the pin parameters for the constructor and init -(as those are fixed). +methods as the bitbanging SPI class above, except for the pin parameters for the +constructor and init (as those are fixed):: from machine import Pin, SPI hspi = SPI(1, baudrate=80000000, polarity=0, phase=0) -(SPI(0) is used for FlashROM and not available to users.) +(``SPI(0)`` is used for FlashROM and not available to users.) I2C bus ------- -- cgit v1.2.3 From 4a9542c0c0319ac268d227ea8daf4c36ac7e870d Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 6 Sep 2016 14:20:52 +1000 Subject: docs/library/machine.WDT: Add that WDT is available on pyboard. --- docs/library/machine.WDT.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/library/machine.WDT.rst b/docs/library/machine.WDT.rst index ff534fd9b..1d79b4c4e 100644 --- a/docs/library/machine.WDT.rst +++ b/docs/library/machine.WDT.rst @@ -14,7 +14,7 @@ Example usage:: wdt = WDT(timeout=2000) # enable it with a timeout of 2s wdt.feed() -Availability of this class: WiPy. +Availability of this class: pyboard, WiPy. Constructors ------------ -- cgit v1.2.3 From dab0f316d26f4c77c94d9e51c35d5f63ed118d3c Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Tue, 6 Sep 2016 11:20:22 +0100 Subject: docs/reference/isr_rules.rst: Two minor additions to docs for using ISR. - Refers to the technique of instantiating an object for use in an ISR by specifying it as a default argument. - Footnote detailing the fact that interrupt handlers continue to be executed at the REPL. --- docs/reference/isr_rules.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'docs') diff --git a/docs/reference/isr_rules.rst b/docs/reference/isr_rules.rst index b33e4dd6f..23dcfd01f 100644 --- a/docs/reference/isr_rules.rst +++ b/docs/reference/isr_rules.rst @@ -110,6 +110,19 @@ the flag. The memory allocation occurs in the main program code when the object The MicroPython library I/O methods usually provide an option to use a pre-allocated buffer. For example ``pyb.i2c.recv()`` can accept a mutable buffer as its first argument: this enables its use in an ISR. +A means of creating an object without employing a class or globals is as follows: + +.. code:: python + + def set_volume(t, buf=bytearray(3)): + buf[0] = 0xa5 + buf[1] = t >> 4 + buf[2] = 0x5a + return buf + +The compiler instantiates the default ``buf`` argument when the function is +loaded for the first time (usually when the module it's in is imported). + Use of Python objects ~~~~~~~~~~~~~~~~~~~~~ @@ -300,3 +313,20 @@ that access to the critical variables is denied. A simple example of a mutex may but only for the duration of eight machine instructions: the benefit of this approach is that other interrupts are virtually unaffected. +Interrupts and the REPL +~~~~~~~~~~~~~~~~~~~~~~~ + +Interrupt handlers, such as those associated with timers, can continue to run +after a program terminates. This may produce unexpected results where you might +have expected the object raising the callback to have gone out of scope. For +example on the Pyboard: + +.. code:: python + + def bar(): + foo = pyb.Timer(2, freq=4, callback=lambda t: print('.', end='')) + + bar() + +This continues to run until the timer is explicitly disabled or the board is +reset with ``ctrl D``. -- cgit v1.2.3 From f3b5480be7243684e31e4631e3da49c725fa7234 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 8 Sep 2016 12:50:38 +1000 Subject: stmhal,cc3200,esp8266: Consistently use PWRON_RESET constant. machine.POWER_ON is renamed to machine.PWRON_RESET to match other reset-cause constants that all end in _RESET. The cc3200 port keeps a legacy definition of POWER_ON for backwards compatibility. --- cc3200/mods/modmachine.c | 3 ++- docs/library/machine.rst | 2 +- esp8266/modmachine.c | 2 +- stmhal/modmachine.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/cc3200/mods/modmachine.c b/cc3200/mods/modmachine.c index 704defb33..410d5b944 100644 --- a/cc3200/mods/modmachine.c +++ b/cc3200/mods/modmachine.c @@ -198,7 +198,8 @@ STATIC const mp_map_elem_t machine_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_IDLE), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_ACTIVE) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SLEEP), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_LPDS) }, { MP_OBJ_NEW_QSTR(MP_QSTR_DEEPSLEEP), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_HIBERNATE) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_POWER_ON), MP_OBJ_NEW_SMALL_INT(PYB_SLP_PWRON_RESET) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_POWER_ON), MP_OBJ_NEW_SMALL_INT(PYB_SLP_PWRON_RESET) }, // legacy constant + { MP_OBJ_NEW_QSTR(MP_QSTR_PWRON_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_PWRON_RESET) }, { MP_OBJ_NEW_QSTR(MP_QSTR_HARD_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_HARD_RESET) }, { MP_OBJ_NEW_QSTR(MP_QSTR_WDT_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_WDT_RESET) }, { MP_OBJ_NEW_QSTR(MP_QSTR_DEEPSLEEP_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_HIB_RESET) }, diff --git a/docs/library/machine.rst b/docs/library/machine.rst index 0f361a7cb..46d8eea71 100644 --- a/docs/library/machine.rst +++ b/docs/library/machine.rst @@ -125,7 +125,7 @@ Constants irq wake values -.. data:: machine.POWER_ON +.. data:: machine.PWRON_RESET .. data:: machine.HARD_RESET .. data:: machine.WDT_RESET .. data:: machine.DEEPSLEEP_RESET diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c index a8d2de8bb..b0b7f3a1a 100644 --- a/esp8266/modmachine.c +++ b/esp8266/modmachine.c @@ -260,7 +260,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DEEPSLEEP), MP_ROM_INT(MACHINE_WAKE_DEEPSLEEP) }, // reset causes - { MP_ROM_QSTR(MP_QSTR_PWR_ON_RESET), MP_ROM_INT(REASON_DEFAULT_RST) }, + { MP_ROM_QSTR(MP_QSTR_PWRON_RESET), MP_ROM_INT(REASON_DEFAULT_RST) }, { MP_ROM_QSTR(MP_QSTR_HARD_RESET), MP_ROM_INT(REASON_EXT_SYS_RST) }, { MP_ROM_QSTR(MP_QSTR_DEEPSLEEP_RESET), MP_ROM_INT(REASON_DEEP_SLEEP_AWAKE) }, { MP_ROM_QSTR(MP_QSTR_WDT_RESET), MP_ROM_INT(REASON_WDT_RST) }, diff --git a/stmhal/modmachine.c b/stmhal/modmachine.c index dbeabec55..ca17eff80 100644 --- a/stmhal/modmachine.c +++ b/stmhal/modmachine.c @@ -543,7 +543,7 @@ STATIC const mp_map_elem_t machine_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_SLEEP), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_LPDS) }, { MP_OBJ_NEW_QSTR(MP_QSTR_DEEPSLEEP), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_HIBERNATE) }, #endif - { MP_OBJ_NEW_QSTR(MP_QSTR_POWER_ON), MP_OBJ_NEW_SMALL_INT(PYB_RESET_POWER_ON) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PWRON_RESET), MP_OBJ_NEW_SMALL_INT(PYB_RESET_POWER_ON) }, { MP_OBJ_NEW_QSTR(MP_QSTR_HARD_RESET), MP_OBJ_NEW_SMALL_INT(PYB_RESET_HARD) }, { MP_OBJ_NEW_QSTR(MP_QSTR_WDT_RESET), MP_OBJ_NEW_SMALL_INT(PYB_RESET_WDT) }, { MP_OBJ_NEW_QSTR(MP_QSTR_DEEPSLEEP_RESET), MP_OBJ_NEW_SMALL_INT(PYB_RESET_DEEPSLEEP) }, -- cgit v1.2.3 From 3611dcc260cef08eaa497cea4e3ca17977848b6c Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 9 Sep 2016 14:07:09 +1000 Subject: docs: Bump version to 1.8.4. --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/conf.py b/docs/conf.py index fbc89afc6..a737e43ef 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -99,7 +99,7 @@ copyright = '2014-2016, Damien P. George and contributors' # The short X.Y version. version = '1.8' # The full version, including alpha/beta/rc tags. -release = '1.8.3' +release = '1.8.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit v1.2.3 From a2391b5a74ff771e2bfc7529aed2f7717309c448 Mon Sep 17 00:00:00 2001 From: juhasch Date: Mon, 22 Aug 2016 20:59:31 +0200 Subject: Small WiPy doc fixes --- docs/wipy/quickref.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/wipy/quickref.rst b/docs/wipy/quickref.rst index 3ce7e0132..ac7eec132 100644 --- a/docs/wipy/quickref.rst +++ b/docs/wipy/quickref.rst @@ -51,11 +51,10 @@ See :ref:`machine.Timer ` and :ref:`machine.Pin `. : tim = Timer(0, mode=Timer.PERIODIC) tim_a = tim.channel(Timer.A, freq=1000) - tim_a.time() # get the value in microseconds tim_a.freq(5) # 5 Hz p_out = Pin('GP2', mode=Pin.OUT) - tim_a.irq(handler=lambda t: p_out.toggle()) + tim_a.irq(trigger=Timer.TIMEOUT, handler=lambda t: p_out.toggle()) PWM (pulse width modulation) ---------------------------- @@ -135,10 +134,9 @@ Real time clock (RTC) See :ref:`machine.RTC ` :: - import machine from machine import RTC - rtc = machine.RTC() # init with default time and date + rtc = RTC() # init with default time and date rtc = RTC(datetime=(2015, 8, 29, 9, 0, 0, 0, None)) # init with a specific time and date print(rtc.now()) -- cgit v1.2.3 From 4ab3eef8d77c436e1ba27d6690cb9b505dd1c8ad Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 18 Sep 2016 21:41:21 +0300 Subject: docs/library/pyb.SPI: init(): Describe "bits" argument. Based on https://github.com/micropython/micropython/pull/2210 . --- docs/library/pyb.SPI.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/library/pyb.SPI.rst b/docs/library/pyb.SPI.rst index 54ecc65b6..fd110be19 100644 --- a/docs/library/pyb.SPI.rst +++ b/docs/library/pyb.SPI.rst @@ -68,6 +68,7 @@ Methods - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. - ``phase`` can be 0 or 1 to sample data on the first or second clock edge respectively. + - ``bits`` can be 8 or 16, and is the number of bits in each transferred word. - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. - ``crc`` can be None for no CRC, or a polynomial specifier. -- cgit v1.2.3