diff options
| author | Scott Shawcroft <scott@chickadee.tech> | 2016-09-19 13:32:29 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@chickadee.tech> | 2016-09-19 13:32:29 -0700 |
| commit | bb03afdb77c95b9cb23e531e5763167ccb09c8e4 (patch) | |
| tree | 509722778a03b10c933963a35c93eb5670a5cdb5 /docs | |
| parent | 345dd1484c4e68f53ea242c5778a2de99119db9a (diff) | |
| parent | 60592fd23c8acd4ed4f70d8fbe8f8b11ea58082c (diff) | |
Merge remote-tracking branch 'micropython/master'
Diffstat (limited to 'docs')
| -rwxr-xr-x | docs/conf.py | 2 | ||||
| -rw-r--r-- | docs/esp8266/quickref.rst | 20 | ||||
| -rw-r--r-- | docs/library/machine.WDT.rst | 2 | ||||
| -rw-r--r-- | docs/library/machine.rst | 2 | ||||
| -rw-r--r-- | docs/library/pyb.SPI.rst | 1 | ||||
| -rw-r--r-- | docs/reference/isr_rules.rst | 30 | ||||
| -rw-r--r-- | docs/wipy/quickref.rst | 6 |
7 files changed, 47 insertions, 16 deletions
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. diff --git a/docs/esp8266/quickref.rst b/docs/esp8266/quickref.rst index d20987136..d06fe5a6f 100644 --- a/docs/esp8266/quickref.rst +++ b/docs/esp8266/quickref.rst @@ -162,10 +162,11 @@ 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 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 @@ -190,18 +191,19 @@ There are two SPI drivers. One is implemented in software 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). +``MISO`` is GPIO12, ``MOSI`` is GPIO13, and ``SCK`` is GPIO14. It has the same +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(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 ------- 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 ------------ 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/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. 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``. 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 <machine.Timer>` and :ref:`machine.Pin <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 <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()) |
