| 9 | |
| 10 | == XIAO RP2040 の動作ログ |
| 11 | * USBケーブルで接続し、!TeraTerm で開くと MicroPython が動作している |
| 12 | |
| 13 | {{{ |
| 14 | >>> help() |
| 15 | Welcome to MicroPython! |
| 16 | |
| 17 | For online help please visit https://micropython.org/help/. |
| 18 | |
| 19 | For access to the hardware use the 'machine' module. RP2 specific commands |
| 20 | are in the 'rp2' module. |
| 21 | |
| 22 | Quick overview of some objects: |
| 23 | machine.Pin(pin) -- get a pin, eg machine.Pin(0) |
| 24 | machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p |
| 25 | methods: init(..), value([v]), high(), low(), irq(handler) |
| 26 | machine.ADC(pin) -- make an analog object from a pin |
| 27 | methods: read_u16() |
| 28 | machine.PWM(pin) -- make a PWM object from a pin |
| 29 | methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d]) |
| 30 | machine.I2C(id) -- create an I2C object (id=0,1) |
| 31 | methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True) |
| 32 | readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg) |
| 33 | machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1) |
| 34 | methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf) |
| 35 | machine.Timer(freq, callback) -- create a software timer object |
| 36 | eg: machine.Timer(freq=1, callback=lambda t:print(t)) |
| 37 | |
| 38 | Pins are numbered 0-29, and 26-29 have ADC capabilities |
| 39 | Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT |
| 40 | Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN |
| 41 | |
| 42 | Useful control commands: |
| 43 | CTRL-C -- interrupt a running program |
| 44 | CTRL-D -- on a blank line, do a soft reset of the board |
| 45 | CTRL-E -- on a blank line, enter paste mode |
| 46 | |
| 47 | For further help on a specific object, type help(obj) |
| 48 | For a list of available modules, type help('modules') |
| 49 | >>> |
| 50 | >>> help('modules') |
| 51 | __main__ gc uasyncio/event umachine |
| 52 | _boot lwip uasyncio/funcs uos |
| 53 | _boot_fat math uasyncio/lock urandom |
| 54 | _onewire micropython uasyncio/stream ure |
| 55 | _rp2 mip ubinascii urequests |
| 56 | _thread neopixel ucollections uselect |
| 57 | _uasyncio network ucryptolib usocket |
| 58 | _webrepl ntptime uctypes ussl |
| 59 | builtins onewire uerrno ustruct |
| 60 | cmath rp2 uhashlib usys |
| 61 | dht uarray uheapq utime |
| 62 | ds18x20 uasyncio/__init__ uio uwebsocket |
| 63 | framebuf uasyncio/core ujson uzlib |
| 64 | Plus any modules on the filesystem |
| 65 | >>> |
| 66 | >>> help(rp2) |
| 67 | object <module 'rp2' from 'rp2.py'> is of type module |
| 68 | country -- <function> |
| 69 | PIOASMEmit -- <class 'PIOASMEmit'> |
| 70 | __file__ -- rp2.py |
| 71 | asm_pio -- <function asm_pio at 0x20008580> |
| 72 | const -- <function> |
| 73 | PIOASMError -- <class 'PIOASMError'> |
| 74 | PIO -- <class 'PIO'> |
| 75 | __name__ -- rp2 |
| 76 | asm_pio_encode -- <function asm_pio_encode at 0x200085a0> |
| 77 | StateMachine -- <class 'StateMachine'> |
| 78 | Flash -- <class 'Flash'> |
| 79 | dht_readinto -- <function> |
| 80 | _pio_funcs -- {'in_': None, 'y_dec': 4, 'pin': 6, 'iffull': 64, 'gpio': 0, 'not_osre': 7, 'clear': 64, 'rel': <function <lambda> at 0x20008a50>, 'wrap': None, 'x_not_y': 5, 'word': None, 'out': None, 'push': None, 'noblock': 1, 'pull': None, 'wrap_target': None, 'x_dec': 2, 'mov': None, 'irq': None, 'set': None, 'y': 2, 'x': 1, 'null': 3, 'pc': 5, 'invert': <function <lambda> at 0x20008a30>, 'pins': 0, 'not_x': 1, 'not_y': 3, 'ifempty': 64, 'isr': 6, 'pindirs': 4, 'exec': 8, 'label': None, 'status': 5, 'nop': None, 'osr': 7, 'block': 33, 'reverse': <function <lambda> at 0x20008a40>, 'jmp': None, 'wait': None} |
| 81 | >>> |
| 82 | }}} |
| 83 | |
| 84 | [KhoPyboard PyBoard一覧に戻る] |