CC3200

2020年3月11日 (水)

Turtorial Examples for CC3200-MicroPython

2020/3/11

Turtorial Examples for CC3200-MicroPython

CC3200

LaunchPad CC3200 WiFi pinout
Ti/swru372c.pdf
Ti/cc3200.pdf

I2C pinout:

P1_xx Func
P1_01(3.3V) VCC
P1_09(P01/GP10) SCL
P1_10(P02/GP11) SDA
P2_xx Func
P2_20(GND) GND

SPI pinout:

P1_xx Func
P1_01(3.3V) VCC
P1_07(P05/GP14) CLK
P2_xx Func
P2_20(GND GND
P2_18(P08/GP17) CS
P2_15(P07/GP16) MOSI(DOUT)
P2_14(P06/GP15) MISO(DIN)

GPIO pinout:

P1_xx Func
P1_01(3.3V) VCC
P1_05(P61/GP06) GPIO
P1_08(P62/GP07) GPIO
P2_xx Func
P2_20(GND) GND
P2_19(P18/GP28) GPIO
P2_18(P08/GP17) CS
P2_15(P07/GP16) MOSI(DOUT)
P2_14(P06/GP15) MISO(DIN)
P2_12(P55/GP01) GPIO
P2_11(P15/GP22) GPIO

decimal numbers not supported

>>> a = 0.123 Traceback (most recent call last): File "<stdin>", line 1 SyntaxError: decimal numbers not supported >>>

Pin/GPIO

from machine import Pin # Orange LED - D6(GP10) on board gp10_out = Pin('GP10', mode=Pin.OUT) gp10_out.value(1) gp10_out.value(0) # Green LED - D5(GP11) on board gp11_out = Pin('GP11', mode=Pin.OUT) gp11_out.value(1) gp11_out.value(0)
from machine import Pin # SW2 GPIO22 # SW3 GPIO13 # make GP22 an input with the pull-up enabled gp22_in = Pin('GP22', mode=Pin.IN, pull=Pin.PULL_UP) gp22_in() # get value, 0 or 1 on SW2 # make GP13 an input with the pull-up enabled gp13_in = Pin('GP13', mode=Pin.IN, pull=Pin.PULL_UP) gp13_in() # get value, 0 or 1 on SW3

SW control LED

from machine import Pin ledOrange = Pin('GP10', mode=Pin.OUT) ledGreen = Pin('GP11', mode=Pin.OUT) sw2 = Pin('GP22', mode=Pin.IN, pull=Pin.PULL_UP) sw3 = Pin('GP13', mode=Pin.IN, pull=Pin.PULL_UP) while True: ledOrange.value(sw2()) ledGreen.value(sw3())

PWM

# make LEDs off from machine import Pin # Orange LED - D6(GP10) on board gp10_out = Pin('GP10', mode=Pin.OUT) gp10_out.value(0) # Green LED - D5(GP11) on board gp11_out = Pin('GP11', mode=Pin.OUT) gp11_out.value(0) # from machine import Timer # timer 3 in PWM mode and width must be 16 buts tim = Timer(3, mode=Timer.PWM, width=16) # enable channel A @1KHz with a 1.55% duty cycle tim_a = tim.channel(Timer.A, freq=1000, duty_cycle=0155) # p1(GP10): Orange LED on board # enable channel B @1KHz with a 30.55% duty cycle tim_b = tim.channel(Timer.B, freq=1000, duty_cycle=3055) # p2(GP11): Green LED on board

ADC

from time import sleep_ms # p57 GP2 a#0 # p58 GP3 a#1 # p59 GP4 a#2 # p60 GP5 a#3 # read value, 0-4095 from machine import ADC adc = ADC() a0in = adc.channel(pin='GP2') a1in = adc.channel(pin='GP3') a2in = adc.channel(pin='GP4') a3in = adc.channel(pin='GP5') while True: print('p57:'+str(a0in())) print('p58:'+str(a1in())) print('p59:'+str(a2in())) print('p60:'+str(a3in())) print('============') sleep_ms(1000)

SPI

SDCard(動作確認無し、ピン配置からの推測)

# SDCard from machine import SD, Pin import os # clock pin, cmd pin, data0 pin # 以下の2つの設定のうち1つを使用する # 設定#1 sd0_clk = Pin('GP10', mode=Pin.ALT, alt=6) sd0_cmd = Pin('GP11', mode=Pin.ALT, alt=6) sd0_dat0 = Pin('GP15', mode=Pin.ALT, alt=8) # 設定#2 sd0_clk = Pin('GP16', mode=Pin.ALT, alt=8) sd0_cmd = Pin('GP17', mode=Pin.ALT, alt=8) sd0_dat0 = Pin('GP15', mode=Pin.ALT, alt=8) sd = SD(pins=(sd0_clk, sd0_cmd, sd0_dat0) # SD0_CLK(SCL) SD0_CMD(MOSI) SD0_DAT0(MISO) os.mount(sd, '/sd')

another SPI sample:
see NeoPixel(are using SPI)

I2C

from machine import Pin, I2C scl0 = Pin('GP10', mode=Pin.ALT, alt=1) sda0 = Pin('GP11', mode=Pin.ALT, alt=1) i2c = I2C(0, scl=scl0, sda=sda0) i2c.scan() # [24, 65] (ボード上の以下のデバイスのアドレスが返る) # BMA222 (加速度センサ) 24(0x18) # TMP006 (温度センサ) 65(0x41)

RTC

from machine import RTC rtc = RTC() # init with default time and date rtc = RTC(datetime=(2020, 3, 11, 0, 21, 0, 0, None)) # init with a specific time and date print(rtc.now())

NeoPixel

module install:

git clone https://github.com/JanBednarik/micropython-ws2812.git cd micropython-ws2812 Patch ws2812.py to ws2812_cc3200.py as follows: patch#1: import pyb -> import machine as pyb patch#2: self.spi = pyb.SPI(spi_bus, pyb.SPI.MASTER, baudrate=3200000, polarity=0, phase=1) -> self.spi = pyb.SPI(spi_bus,baudrate=3200000, polarity=0, phase=1) patch#3: self.spi.send(self.buf) -> self.spi.write(self.buf) Put it in /flash ampy put ws2812_cc3200.py

demo sample:

# connect the following pin to DIN of nexpixels # P2_15(P07/GP16) (if spi_bus=0) from ws2812_cc3200 import WS2812 chain = WS2812(spi_bus=0, led_count=4) data = [ (255, 0, 0), # red (0, 255, 0), # greenp (0, 0, 255), # blue (85, 85, 85), # white ] chain.show(data)

Networking

以下の部分は自分のWiFi環境に合わせて変更すること:
MYSSID = "your_ssid"
MYKEY = "your_passwd"

IPを静的に与えるサンプルにもなっているので IPがかち合っていれば、IPも変更すること。

CC3200_starwars.py

MYSSID = "your_ssid" MYKEY = "your_passwd import machine from network import WLAN # configure the WLAN subsystem in station mode (the default is AP) wlan = WLAN(mode=WLAN.STA) # go for fixed IP settings wlan.ifconfig(config=('192.168.0.107', '255.255.255.0', '192.168.0.1', '8.8.8.8')) #wlan.scan() # scan for available networks wlan.connect(ssid=MYSSID, auth=(WLAN.WPA2, MYKEY)) while not wlan.isconnected(): pass print(wlan.ifconfig()) #========================================== # Star Wars ASCII Art (python3) import socket addr_info = socket.getaddrinfo("towel.blinkenlights.nl",23) addr = addr_info[0][-1] s = socket.socket() s.connect(addr) while True: data = s.recv(500) print(str(data, 'utf8'), end='') #=============================================

starwarsのASCII_Artのアニメが表示されればOKとなる。

Peformace Test

performanceTestCC3200.py

# Peformace Test for CC3200 from machine import RTC rtc = RTC(datetime=(2020, 2, 9, 10, 11, 0, 0, None)) def performanceTest(): secs = rtc.now()[5] endTime = secs + 10 count = 0 while rtc.now()[5] < endTime: count += 1 print("Count: ", count) performanceTest()

以上

続きを読む "Turtorial Examples for CC3200-MicroPython"

| | コメント (0)

2020年2月17日 (月)

CC3200のMicroPythonでOSC(Open Sound Control)受信する

2020/2/17

CC3200 MicroPython OSC recv

CC3200 MicroPython OSC recv

概要

CC3200のMicroPythonでOSC(Open Sound Control)で受信する方法について述べる。これはESP32のもの同様のものであるが、CC3200の場合、floatが実装されていないので、そこが差分になる。float32は、符号1ビット、指数部8ビット、仮数部23ビットで構成されるが、その32ビットが、そのまま整数32ビットに読み替えられる。

準備

ツールをインストール前に環境整備として以下を設定する:
(1)書き込みツール(esptool)のインストール
以下のURLの参照のこと;
esptool.py

(この記事のなかでは使用しない)

(2)ampyのインストール
AMPY_PORTは、自分の環境に合わせる。

pip install adafruit-ampy export AMPY_PORT=/dev/ttyUSB0 export AMPY_BAUD=115200

(3)picocomのインストール

sudo apt-get install picocom

以上のうち、exportしているものは、.bashrcに登録することを勧める。

送信側アプリの準備

ここでは、iPhoneのTouchOSCを使用する。
以下、インストール用URL:
iPhone/iPad TouchOSC
Android TouchOSC

OSCモジュールのインストール

以下の方法でインストールした:
(ホストPC上で以下を行なう)

# OSCモジュールのインストール git clone https://github.com/SpotlightKid/micropython-osc.git cd micropython-osc/uosc ampy mkdir /flash/lib ampy mkdir /flash/lib/uosc ampy put client.py /flash/lib/uosc/client.py ampy put server.py /flash/lib/uosc/server.py ampy put threadedclient.py /flash/lib/uosc/threadedclient.py ampy put common.py /flash/lib/uosc/common.py ampy put socketutil.py /flash/lib/uosc/socketutil.py # インストールしたモジュールの確認 ampy ls /flash/lib/uosc /flash/lib/uosc/client.py /flash/lib/uosc/common.py /flash/lib/uosc/server.py /flash/lib/uosc/socketutil.py /flash/lib/uosc/threadedclient.py

エラー回避した追加モジュールのインストール

# 追加モジュールのインストール ampy put socketutil.py /flash/lib/uosc/OSCmsg.py # インストールしたモジュールの確認 ampy ls /flash/lib/uosc /flash/lib/uosc/OSCmsg.py ...

実際のソース:
OSCmsg.py
(server.pyからエラー回避のためにlogging関連のコードなどを削除したもの)

# -*- coding: utf-8 -*- # # uosc/OSCmsg.py # 2020/2/9: forked from server.py # """ OSCmsg """ from ustruct import unpack from uosc.common import Impulse, to_time MAX_DGRAM_SIZE = 1472 def split_oscstr(msg, offset): end = msg.find(b'\0', offset) return msg[offset:end].decode('utf-8'), (end + 4) & ~0x03 def split_oscblob(msg, offset): start = offset + 4 size = unpack('>I', msg[offset:start])[0] return msg[start:start + size], (start + size + 4) & ~0x03 def parse_timetag(msg, offset): """Parse an OSC timetag from msg at offset.""" return to_time(unpack('>II', msg[offset:offset + 4])) def parse_message(msg, strict=False): args = [] addr, ofs = split_oscstr(msg, 0) if not addr.startswith('/'): raise ValueError("OSC address pattern must start with a slash.") # type tag string must start with comma (ASCII 44) if ofs < len(msg) and msg[ofs:ofs + 1] == b',': tags, ofs = split_oscstr(msg, ofs) tags = tags[1:] else: errmsg = "Missing/invalid OSC type tag string." if strict: raise ValueError(errmsg) else: tags = '' for typetag in tags: size = 0 if typetag in 'ifd': size = 8 if typetag == 'd' else 4 args.append(unpack('>' + typetag, msg[ofs:ofs + size])[0]) elif typetag in 'sS': s, ofs = split_oscstr(msg, ofs) args.append(s) elif typetag == 'b': s, ofs = split_oscblob(msg, ofs) args.append(s) elif typetag in 'rm': size = 4 args.append(unpack('BBBB', msg[ofs:ofs + size])) elif typetag == 'c': size = 4 args.append(chr(unpack('>I', msg[ofs:ofs + size])[0])) elif typetag == 'h': size = 8 args.append(unpack('>q', msg[ofs:ofs + size])[0]) elif typetag == 't': size = 8 args.append(parse_timetag(msg, ofs)) elif typetag in 'TFNI': args.append({'T': True, 'F': False, 'I': Impulse}.get(typetag)) else: raise ValueError("Type tag '%s' not supported." % typetag) ofs += size return (addr, tags, tuple(args)) def parse_bundle(bundle, strict=False): """Parse a binary OSC bundle. Returns a generator which walks over all contained messages and bundles recursively, depth-first. Each item yielded is a (timetag, message) tuple. """ if not bundle.startswith(b'#bundle\0'): raise TypeError("Bundle must start with b'#bundle\\0'.") ofs = 16 timetag = to_time(*unpack('>II', bundle[8:ofs])) while True: if ofs >= len(bundle): break size = unpack('>I', bundle[ofs:ofs + 4])[0] element = bundle[ofs + 4:ofs + 4 + size] ofs += size + 4 if element.startswith(b'#bundle'): for el in parse_bundle(element): yield el else: yield timetag, parse_message(element, strict) def handle_osc(data, src, dispatch=None, strict=False): try: head, _ = split_oscstr(data, 0) if head.startswith('/'): messages = [(-1, parse_message(data, strict))] elif head == '#bundle': messages = parse_bundle(data, strict) except Exception as exc: return try: for timetag, (oscaddr, tags, args) in messages: if dispatch: dispatch(timetag, (oscaddr, tags, args, src)) except Exception as exc: print("Exception in OSC handler: %s", exc)

受信テスト

送信側になるTouchOSCを起動してレイアウトSimpleのPanel#1を表示して 待ち受けにして以下のコマンドを実行する:

# プログラムを書き込む ampy put CC3200_OSCrecvBundled_test.py picocom /dev/ttyUSB0 -b115200 # REPLに入る import CC3200_OSCrecvBundled_test.py # WiFiが接続されIPアドレスが表示される # そのIPアドレスをTouchOSCのHostのIPアドレスとして設定する # TouchOSCの画面のfaderやtoggleを動かすと # そのOSCパケットを受信してREPL画面に表示される

実際のソース:
CC3200_OSCrecvBundled_test.py
以下の部分を自分の環境に合わせる;
MYSSID="your_ssid"
MYKEY="your_passwd"

# CC3200 WiFi setup MYSSID="your_ssid" MYKEY="your_passwd" import machine from network import WLAN # configure the WLAN subsystem in station mode (the default is AP) wlan = WLAN(mode=WLAN.STA) # go for fixed IP settings #wlan.ifconfig(config=('192.168.0.107', '255.255.255.0', '192.168.0.1', '8.8.8.8')) #wlan.scan() # scan for available networks wlan.connect(ssid=MYSSID, auth=(WLAN.WPA2, MYKEY)) while not wlan.isconnected(): pass print(wlan.ifconfig()) #----------------------------- from uosc.OSCmsg import parse_message, parse_bundle, split_oscstr import usocket as socket import network incoming_port = 8000 # get my IP myIP, netmask, gateway, dns = wlan.ifconfig() s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('0.0.0.0',incoming_port)) print('myIP:'+myIP) print('listening...') s.setblocking(True) while True: data,addr=s.recvfrom(1024) print('received:',data,'from',addr) head, _ = split_oscstr(data, 0) if head.startswith('/'): msg = parse_message(data) print(msg) # '#bundle' does not work # elif head == '#bundle': # for x in parse_bundle(data): # timetag, msg = x # print(msg) print('=======================')

REPL出力例:

>>> import CC3200_OSCrecvBundled_test ('192.168.0.23', '255.255.255.0', '192.168.0.1', '192.168.0.1') myIP:192.168.0.23 listening... received: b'/1/fader1\x00\x00\x00,f\x00\x00\x00\x00\x00\x00' from ('192.168.0.16', 9000) ('/1/fader1', 'f', (0,)) # 0 は、 0.0 に対応している ======================= received: b'/1/fader5\x00\x00\x00,f\x00\x00?\x80\x00\x00' from ('192.168.0.16', 9000) ('/1/fader5', 'f', (1065353216,)) # 1065353216 は、 1.0 に対応している =======================

参考情報

TouchOSC | Control reference
OpenSound Control
ESP32のMicroPythonでOSC(Open Sound Control)で通信する

CC3200 MicroPython examples
CC3200 MicroPython インストール
micropython - Quick reference for the WiPy

ampyを用いたMicroPythonのファイル操作とプログラム実行

以上

続きを読む "CC3200のMicroPythonでOSC(Open Sound Control)受信する"

| | コメント (0)

2020年2月14日 (金)

CC3200 MicroPython インストール

2020/2/14+

CC3200 MicroPython Install

CC3200 MicroPython Install

概要

以下のリンクにある「WiFi CC3200 Lauchpad」ボード用にMicroPythonをビルドして、そのfirewareを書き込む方法について述べる。 ここでは、linux環境でのインストール方法について説明する。

SimpleLink Wi-Fi CC3200 LaunchPad

準備

環境整備として以下をインストールする:
(1)書き込みツール(cc3200tool)のインストール

pip install git+git://github.com/ALLTERCO/cc3200tool.git

使い方は以下を参照のこと:
CC3200 Tool/README

(2)ampyのインストール
AMPY_PORTは、自分の環境に合わせる。

pip install adafruit-ampy export AMPY_PORT=/dev/ttyUSB0 export AMPY_BAUD=115200

(3)picocomのインストール

sudo apt-get install picocom

以上のうち、exportしているものは、.bashrcに登録することを勧める。

firewareのビルド

mkdir mp cd mp git clone https://github.com/micropython/micropython.git cd micropython cd mpy-cross make cd ports/cc3200 make BTARGET=bootloader BTYPE=release BOARD=LAUNCHXL make BTARGET=application BTYPE=release BOARD=LAUNCHXL # 以上で次の2つのbinが生成される # bootmgr/build/LAUNCHXL/release/bootloader.bin # build/LAUNCHXL/release/mcuimg.bin

firmwareの書き込み

書き込む前にボードのジャンパーが以下になっていることを確認する:
J6/J7:シリアルが有効(たぶん工場出荷時のまま)
SOP2: 100
以下の写真どおりになっていればOK.
J6/J7/SOP2設定写真

以下を実行する:

cd micropython/ports/cc3200 # format the flash, upload two binaries cc3200tool -p /dev/ttyUSB0 --sop2 ~rts --reset dtr \ format_flash --size=1M \ write_file bootmgr/build/LAUNCHXL/release/bootloader.bin /sys/mcuimg.bin \ write_file build/LAUNCHXL/release/mcuimg.bin /sys/factimg.bin #出力ログ: > format_flash --size=1M \ > write_file bootmgr/build/LAUNCHXL/release/bootloader.bin /sys/mcuimg.bin \ > write_file build/LAUNCHXL/release/mcuimg.bin /sys/factimg.bin 2020-02-13 21:15:25,487 -- Connecting to target... 2020-02-13 21:15:25,844 -- Connected, reading version... 2020-02-13 21:15:25,852 -- connected to target 2020-02-13 21:15:25,853 -- Version: CC3x00VersionInfo((0, 4, 1, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0)) 2020-02-13 21:15:25,853 -- This is a CC3200 device 2020-02-13 21:15:25,853 -- Switching to NWP bootloader... 2020-02-13 21:15:25,869 -- Switching UART to APPS... 2020-02-13 21:15:25,884 -- Resetting communications ... 2020-02-13 21:15:27,147 -- Uploading rbtl3100s.dll... 2020-02-13 21:15:27,149 -- Getting storage list... 2020-02-13 21:15:27,163 -- Getting storage info... 2020-02-13 21:15:27,179 -- storage #0 info bytes: 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0 2020-02-13 21:15:27,898 -- APPS version: CC3x00VersionInfo((0, 4, 0, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0)) 2020-02-13 21:15:27,898 -- Formatting flash with size=1024 2020-02-13 21:15:28,953 -- Uploading file bootmgr/build/LAUNCHXL/release/bootloader.bin -> /sys/mcuimg.bin [11672, disk=11672]... ... 2020-02-13 21:15:29,417 -- Uploading file build/LAUNCHXL/release/mcuimg.bin -> /sys/factimg.bin [186112, disk=186112]... .............................................. 2020-02-13 21:15:34,499 -- Getting storage info... 2020-02-13 21:15:34,515 -- storage #2 info bytes: 0x10, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0 2020-02-13 21:15:34,515 -- Getting storage list... 2020-02-13 21:15:34,531 -- Reading raw storage #2 start 0x0, size 0x2000... .. 2020-02-13 21:15:34,659 -- [0] detected a valid FAT revision: 4 2020-02-13 21:15:34,659 -- selected FAT revision: 4 (active) 2020-02-13 21:15:34,659 -- FAT r4, num files: 2, used/free blocks: 54/202 2020-02-13 21:15:34,659 -- All commands done, bye.

書き込みが完了したらSO2はジャンパーを外し[000]にする。
なお、cc3200toolを使用する際は、書き込み以外でもSO2は[100]にしないと動作しないようなので注意すること。

動作確認

(1)簡単な確認

picocom /dev/ttyUSB0 -b115200 MPY: soft reboot MicroPython v1.12-167-gf020eac on 2020-02-13; LaunchPad with CC3200 Type "help()" for more information. >>> >>> import os >>> os.uname() (sysname='WiPy', nodename='WiPy', release='1.2.0', version='v1.12-167-gf020eac on 2020-02-13', machine='LaunchPad with CC3200') # sysname='WiPy'とあるので、WiPyボードと同等とみなされている >>> >>> import gc >>> gc.collect() >>> gc.mem_free() 55376 >>> >>> >>> import sys >>> sys.path ['', '/flash', '/flash/lib'] >>> >>> list(5 * x + y for x in range(10) for y in [4, 2, 1]) [4, 2, 1, 9, 7, 6, 14, 12, 11, 19, 17, 16, 24, 22, 21, 29, 27, 26, 34, 32, 31, 39, 37, 36, 44, 42, 41, 49, 47, 46] >>> # 以下のようにfloatはサポートしていないので注意のこと >>> 12+34 46 >>> 0.12+0.34 Traceback (most recent call last): File "<stdin>", line 1 SyntaxError: decimal numbers not supported >>>

MicroPythonから抜けるには、強引なやり方になるが、USBケーブルをいったん抜いて電源を切る。

(2)プログラムの実行

ampy put CC3200_starwars.py picocom /dev/ttyUSB0 -b115200 import CC3200_starwars

実際に実行するプログラムは以下になる:

以下の部分は自分のWiFi環境に合わせて変更すること:
MYSSID = "your_ssid"
MYKEY = "your_passwd"

IPを静的に与えるサンプルにもなっているので IPがかち合っていれば、IPも変更すること。

CC3200_starwars.py

MYSSID = "your_ssid" MYKEY = "your_passwd import machine from network import WLAN # configure the WLAN subsystem in station mode (the default is AP) wlan = WLAN(mode=WLAN.STA) # go for fixed IP settings wlan.ifconfig(config=('192.168.0.107', '255.255.255.0', '192.168.0.1', '8.8.8.8')) #wlan.scan() # scan for available networks wlan.connect(ssid=MYSSID, auth=(WLAN.WPA2, MYKEY)) while not wlan.isconnected(): pass print(wlan.ifconfig()) #========================================== # Star Wars ASCII Art (python3) import socket addr_info = socket.getaddrinfo("towel.blinkenlights.nl",23) addr = addr_info[0][-1] s = socket.socket() s.connect(addr) while True: data = s.recv(500) print(str(data, 'utf8'), end='') #=============================================

starwarsのASCII_Artのアニメが表示されればOKとなる。

ボードにプログラムを書き込む(自動起動になる)

書き込みたいプログラムをxxxx.pyとすると 以下のようにする:

ampy put xxxx.py /flash/main.py # 実行したいプログラムをmain.pyとして書き込む # ボードの[reset]を押して起動する #以下で書き込んであるプログラムが確認できる ampy ls /flash /flash/boot.py /flash/cert /flash/lib /flash/main.py /flash/sys

コンソール(REPL)で実行したい場合

実行したいプログラムをCC3200_starwars.pyとすると 以下のようにする:

ampy put CC3200_starwars.py picocom /dev/ttyUSB0 -b115200 import CC3200_starwars

LEDs on board

MicroPythonから制御できるボード上のLEDとして以下の3つがある:
・Red LED - D7(GP09)
・Orange LED - D6(GP10)
・Green LED - D5(GP11)

以下のように制御できる(REPL):

picocom /dev/ttyUSB0 -b115200 # Red LED (hearbeat) on board D7(GP09) import wipy wipy.heartbeat(True) wipy.heartbeat(False) # Trueにすると4秒間隔で点滅する from machine import Pin # Orange LED - D6(GP10) on board p_out = Pin('GP10', mode=Pin.OUT) p_out.value(1) p_out.value(0) # Green LED - D5(GP11) on board p_out = Pin('GP11', mode=Pin.OUT) p_out.value(1) p_out.value(0)

参考情報

SimpleLink Wi-Fi CC3200 Module LaunchPad

micropython/Quick reference for the WiP
ampyを用いたMicroPythonのファイル操作とプログラム実行

User:Dbartlett/MicroPython CC3200
・役に立つ情報が多かったが、ここでのMicroPythonのバージョンが古いのでMicroPythonの部分は現状のものと異なる。
CC3200 Tool

補足(書き込み直後のファイル状況)

/flashにあるファイル内容:

$ ampy ls /flash /flash/boot.py /flash/cert /flash/lib /flash/main.py /flash/sys $ ampy get /flash/boot.py # boot.py -- run on boot-up # can run arbitrary Python, but best to keep it minimal import os, machine os.dupterm(machine.UART(0, 115200)) $ ampy get /flash/main.py # main.py -- put your code here! # 以下のものは空だった $ ampy ls /flash/cert $ ampy ls /flash/lib $ ampy ls /flash/sys

CC3200のシステム内部のファイル状況(/flashのものではない)

# ボードのジャンパーSOP2を[100]にすること $ cc3200tool -p /dev/ttyUSB0 list_filesystem 2020-02-14 09:48:23,790 -- Connecting to target... 2020-02-14 09:48:26,049 -- timed out while waiting for ack 2020-02-14 09:48:26,303 -- Connected, reading version... 2020-02-14 09:48:26,315 -- connected to target 2020-02-14 09:48:26,315 -- Version: CC3x00VersionInfo((0, 4, 1, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0)) 2020-02-14 09:48:26,316 -- This is a CC3200 device 2020-02-14 09:48:26,316 -- Switching to NWP bootloader... 2020-02-14 09:48:26,330 -- Switching UART to APPS... 2020-02-14 09:48:26,346 -- Resetting communications ... 2020-02-14 09:48:27,609 -- Uploading rbtl3100s.dll... 2020-02-14 09:48:27,611 -- Getting storage list... 2020-02-14 09:48:27,625 -- Getting storage info... 2020-02-14 09:48:27,640 -- storage #0 info bytes: 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0 2020-02-14 09:48:28,360 -- APPS version: CC3x00VersionInfo((0, 4, 0, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0)) 2020-02-14 09:48:28,360 -- Getting storage info... 2020-02-14 09:48:28,376 -- storage #2 info bytes: 0x10, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0 2020-02-14 09:48:28,376 -- Getting storage list... 2020-02-14 09:48:28,392 -- Reading raw storage #2 start 0x0, size 0x2000... .. 2020-02-14 09:48:28,520 -- [1] detected a valid FAT revision: 101 2020-02-14 09:48:28,520 -- selected FAT revision: 101 (active) 2020-02-14 09:48:28,521 -- Serial Flash block size: 4096 bytes 2020-02-14 09:48:28,521 -- Serial Flash capacity: 256 blocks 2020-02-14 09:48:28,522 -- 2020-02-14 09:48:28,522 -- file start size fail flags total size filename 2020-02-14 09:48:28,522 -- index block [BLKs] safe [BLKs] 2020-02-14 09:48:28,522 -- ---------------------------------------------------------------------------- 2020-02-14 09:48:28,522 -- N/A 0 5 N/A N/A 5 FATFS 2020-02-14 09:48:28,522 -- 0 5 3 no 0x4 3 /sys/mcuimg.bin 2020-02-14 09:48:28,522 -- 4 8 46 no 0xc 46 /sys/factimg.bin 2020-02-14 09:48:28,523 -- 6 54 5 yes 0x8 10 /tmp/phy.cal 2020-02-14 09:48:28,523 -- 7 64 1 yes 0x8 2 /sys/bootinfo.bin 2020-02-14 09:48:28,523 -- 8 66 2 yes 0x8 4 /sys/pref.net 2020-02-14 09:48:28,523 -- 9 70 1 yes 0x8 2 /sys/ipcfg.ini 2020-02-14 09:48:28,523 -- 10 72 1 yes 0x8 2 /sys/pmcfg.ini 2020-02-14 09:48:28,523 -- 11 74 1 yes 0x8 2 /sys/mdns.cfg 2020-02-14 09:48:28,524 -- 12 76 1 yes 0x8 2 /sys/mode.cfg 2020-02-14 09:48:28,524 -- 13 78 1 yes 0x8 2 /sys/ap.cfg 2020-02-14 09:48:28,524 -- 14 80 1 yes 0x8 2 /sys/dhcpsrv.cfg 2020-02-14 09:48:28,524 -- 15 82 1 yes 0x8 2 /sys/date_time.cfg 2020-02-14 09:48:28,524 -- 16 84 1 no 0xc 1 __000__.fsb 2020-02-14 09:48:28,524 -- 17 85 1 no 0xc 1 __001__.fsb ... 省略 ... 2020-02-14 09:48:28,528 -- 47 114 1 no 0xc 1 __030__.fsb 2020-02-14 09:48:28,528 -- 48 115 1 no 0xc 1 __031__.fsb 2020-02-14 09:48:28,529 -- 49 116 1 yes 0x8 2 /sys/stacfg.ini 2020-02-14 09:48:28,529 -- 50 118 1 yes 0x8 2 /tmp/fcon.frm 2020-02-14 09:48:28,529 -- 51 120 1 yes 0x8 2 /tmp/fcon.ssid 2020-02-14 09:48:28,529 -- 2020-02-14 09:48:28,529 -- Flash usage 2020-02-14 09:48:28,529 -- ------------------------- 2020-02-14 09:48:28,529 -- used space: 122 blocks 2020-02-14 09:48:28,530 -- free space: 134 blocks 2020-02-14 09:48:28,530 -- memory hole: [122-255] 2020-02-14 09:48:28,530 -- All commands done, bye. # ボードのジャンパーSOP2を元に戻すこと([000]にすること)

以上

続きを読む "CC3200 MicroPython インストール"

| | コメント (0)