[ÅŻҹ©ºî]
http://www.slideshare.net/hktechno/micro-python-python
¥á¥¤¥ó¥µ¥¤¥È¤Ï¤³¤³
http://micropython.org/
¥½¡¼¥¹¤½¤Î¤Û¤«¤Ï¤³¤³
https://github.com/micropython
https://github.com/micropython/micropython/wiki/Board-STM32F407-Discovery
¿ä¾©¥Ä¡¼¥ë¥Á¥§¥¤¥ó¤Ï¤³¤³
https://launchpad.net/gcc-arm-embedded
make BOARD=STM32F4DISC
¤Ç STM32F4 Discovery ÍÑ¥¤¥á¡¼¥¸¤¬¤Ç¤¤ë
¤ª¤½¤é¤¯¤³¤ÎÌäÂê
https://github.com/micropython/micropython/issues/587
MicroPython ¥µ¥ó¥×¥ë½¸
https://github.com/dhylands/upy-examples
¤Ë¤¢¤ë¡¢boot.py ¤ò USB-MSC ¥É¥é¥¤¥Ö¤Ë¾å½ñ¤¥³¥Ô¡¼¤·¤Æ¡¢
def init(): if False:¡¡¡ã¡Ý¡¡¤³¤³¤ò False ¤«¤é True ¤Ë uart = pyb.UART(6,115200) pyb.repl_uart(uart) print("REPL is also on UART 6 (Y1=Tx Y2=Rx)")
¾åµ¤Î²Õ½ê¤ò False ¤«¤é True ¤Ë¤·¤Æ¤ª¤¯¤È¡¢
UART6 ¤¬¥³¥ó¥½¡¼¥ë¤È¤·¤Æ»È¤¨¤Þ¤¹¡£
STM32F4DISC ¤Ç¤Ï¡¢UART6 ¤Ï PC6(TX),PC7(RX) ¤È¤Ê¤Ã¤Æ¤¤¤Æ¡¢
USB ¥³¥Í¥¯¥¿(STM32 ËÜÂΤÎ)¤Î±¦¡¢GND ¤Î¤¹¤°¤½¤Ð¤Ë½Ð¤Æ¤¤¤ë¤Î¤Ç¡¢
¤³¤³¤Ë TTL-Serial ¥É¥ó¥°¥ë¤òÀܳ¤¹¤ë¤È¥³¥ó¥½¡¼¥ë¤È¤·¤Æ»È¤¨¤Þ¤¹¡£
¤Þ¤À¤Þ¤À¥À¥¤¥Ê¥ß¥Ã¥¯¤ËÊѹ¹¤¬¤¢¤ë¤È»×¤¤¤Þ¤¹¤Î¤Ç¥á¥âÄøÅ٤ˡ£
¥â¥¸¥å¡¼¥ë¥Õ¥¡¥¤¥ë¤Î¥µ¥ó¥×¥ë¤Ï¡¢extmod ¤Î¤â¤Î¤¬¤ï¤«¤ê¤ä¤¹¤¤¤È»×¤¤¤Þ¤¹¡£
¤È¤ê¤¢¤¨¤ºÀâÌÀÍѤΥÀ¥ß¡¼¥â¥¸¥å¡¼¥ë testmod.zip(531) ¤ò $(TOP)/testmod ¤ËÃÖ¤¤Þ¤¹¡£
¡ã¥×¥é¥Ã¥È¥Õ¥©¡¼¥àÈó°Í¸¥â¥¸¥å¡¼¥ë¤Î¾ì¹ç¡ä
¡úpy/builtin.h ¤Î¤½¤ì¤Ã¤Ý¤¤¾ì½ê¤Ë
// extmod modules extern const mp_obj_module_t mp_module_test;
¡úpy/builtintables.c ¤Î¤½¤ì¤Ã¤Ý¤¤¾ì½ê¤Ë
// extmod modules #if MICROPY_PY_TESTMOD { MP_OBJ_NEW_QSTR(MP_QSTR_testmod),(mp_obj_t)&mp_module_test }, #endif
¡ã¥×¥é¥Ã¥È¥Õ¥©¡¼¥à°Í¸¤Î¾ì¹ç¡ä
¡ústmhal/mpconfigport.h ¤Î¤½¤ì¤Ã¤Ý¤¤¾ì½ê¤Ë
extern const struct _mp_obj_module_t mp_module_test;
#define MICROPY_PORT_BUILTIN_MODULES \ ¡ÊÃæά¡Ë { MP_OBJ_NEW_QSTR(MP_QSTR_testmod), (mp_obj_t)&mp_module_test }, \
¤½¤ì¤Ã¤Ý¤¤¾ì½ê¤òõ¤·¤Æ
¡ú¥·¥ó¥Ü¥ë¡¢¥Ï¥Ã¥·¥å(qstr)´ØÏ¢¤ÎÁÞÆþ
# qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h ../testmod/testqstr.h
¡ú¥â¥¸¥å¡¼¥ë¤Î¥Ó¥ë¥ÉÀßÄê¤òÁÞÆþ
# for test module MICROPY_PY_TESTMOD = 1¡¡¢«¤³¤ì¤Ï¤¤¤ó¤Á¤¡£ ifeq ($(MICROPY_PY_TESTMOD),1) TESTMOD_DIR=testmod INC += -I$(TOP)/testmod CFLAGS_MOD += -DMICROPY_PY_TESTMOD=1 SRC_MOD += $(addprefix $(TESTMOD_DIR)/,\ modtest.c \ ) endif
Micro Python inchiki on 2014-10-05; F4DISC with STM32F407 Type "help()" for more information. >>> import testmod >>> dir(testmod) ['__name__', 'hello1'] >>> testmod.hello1([1,2,3]) '[1, 2, 3]' >>>
¡¦¥Ó¥ë¥É
make V=1 BOARD=STM32F4DISC MICROPY_PY_CC3K=1
¡¦¤³¤ó¤Ê´¶¤¸¤Ç¤¹
>>> import network >>> dir(network) ['__name__', 'CC3k', 'route'] >>> dir(network.CC3k) ['connect', 'disconnect', 'is_connected', 'ifconfig', 'patch_version', 'patch_program', 'WEP', 'WPA', 'WPA2'] ### CC3k(spi, pin_cs, pin_en, pin_irq) ### B13=SCK, B14=MISO, B15=MOSI >>> a = network.CC3k(pyb.SPI(2), pyb.Pin.cpu.A15, pyb.Pin.cpu.B10, pyb.Pin.cpu.B11) #¤Ê¤¼¤« E15 ¤Ç¤Ï¥À¥á #>>> a = network.CC3k(pyb.SPI(2), pyb.Pin.cpu.E15, pyb.Pin.cpu.B10, #pyb.Pin.cpu.B11) >>> dir(a) ['connect', 'disconnect', 'is_connected', 'ifconfig', 'patch_version', 'patch_program', 'WEP', 'WPA', 'WPA2'] >>> a.patch_version() (1, 24) >>> a.is_connected() False >>> a.connect('SSID','password') >>> a.is_connected() True >>> a.ifconfig() IP:192.168.1.16 Mask:255.255.255.0 GW:192.168.1.1 DHCP:192.168.1.1 DNS:192.168.1.1 MAC:ho:ge:ho:ge:fu:ga SSID: SSID >>>
¡¡¥«¥Æ¥´¥ê¡¡¡§¡¡¤â¤¯¤·¤¤¡Ã¥²¡¼¥à¡Ã¥ì¥·¥Ô¡Ã¥³¥ó¥Ô¥å¡¼¥¿¡Ã»¨Ê¸¡ÃÀ¸³è¡ÃÅŻҹ©ºî¡Ã¤ª¤¤¤·¤¤Å¹¥Þ¥Ã¥×
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Top¥Ú¡¼¥¸¤Ø¡¡|¡¡¤â¤Æ¤Ê¤¤SNS¡Ö¤â¤¯¤·¤¤¡×