1 Star 0 Fork 0

卖菇凉小蘑菇 / MpyOnRtt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

MicroPython port for RT-Thread

Tools

You can click here , and download the IDE under the Windows. Extract eclipse_gcc_arm.zip to the C root directory, then execute ‪C:\eclipse_gcc_arm\eclipse.exe.

Step by step

STEP 1

  • Clone & Import code to Eclipse
  • Build code

STEP 2

  • Connect the STM32F4 board by J-Link.
  • Secect Debug configurations->GDB SEGGER J-Link Debuging->Debug project on Eclipse. The firmware will be downloaded to board.

STEP 3

  • Open on serial terminal, such as putty, Xshell, B115200 8 1 N
  • Full speed run the firmware program
  • You can see the following information
 \ | /
- RT -     Thread Operating System
 / | \     3.0.0 build Nov  4 2017
 2006 - 2017 Copyright by rt-thread team
[Flash](../components/flash/src/ef_env.c:144) ENV start address is 0x08040000, size is 262144 bytes.
[Flash](../components/flash/src/ef_env.c:760) Calculate ENV CRC32 number is 0x02C0DB7B.
[Flash](../components/flash/src/ef_env.c:772) Verify ENV CRC32 result is OK.
[Flash]EasyFlash V3.0.3 is initialize success.
msh />I/elog            [16-01-01 13:06:09] EasyLogger V2.0.0 is initialize success.

STEP 4

  • input pyhton command will goto the MicroPython REPL(Read-Evaluate-Print-Loop)
msh />python

MicroPython v1.9.3-6-g1742ab26-dirty on 2017-11-04; RT-Thread Board with stm32f4
>>> 
>>> print('Hello World')
Hello World
  • Now you can iuput and run the python code on the terminal
  • If you want exit the python REPL. Please press CTRL + D .

Supported modules

RT-Thread

>>> import rtthread
>>> 
>>> rtthread.is_preempt_thread()       # determine if code is running in a preemptible thread
True
>>> rtthread.current_tid()             # current thread id
268464956
>>> rtthread.stacks_analyze()          # show thread information
thread     pri  status      sp     stack size max used left tick  error
---------- ---  ------- ---------- ----------  ------  ---------- ---
elog_async  31  suspend 0x000000a8 0x00000400    26%   0x00000003 000
tshell      20  ready   0x00000260 0x00001000    39%   0x00000003 000
tidle       31  ready   0x00000070 0x00000100    51%   0x0000000f 000
SysMonitor  30  suspend 0x000000a4 0x00000200    32%   0x00000005 000
timer        4  suspend 0x00000080 0x00000200    25%   0x00000009 000
>>> 

Delay and timing

Use the time module:

>>> import time
>>> 
>>> time.sleep(1)           # sleep for 1 second
>>> time.sleep_ms(500)      # sleep for 500 milliseconds
>>> time.sleep_us(10)       # sleep for 10 microseconds
>>> start = time.ticks_ms() # get value of millisecond counter
>>> delta = time.ticks_diff(time.ticks_ms(), start) # compute time difference

pyb - functions related to the board

See pyb.

>>> import pyb
>>>
>>> pyb.info()              # show information about the board
---------------------------------------------
RT-Thread
---------------------------------------------
total memory: 131048
used memory : 4920
maximum allocated memory: 5836
thread     pri  status      sp     stack size max used left tick  error
---------- ---  ------- ---------- ----------  ------  ---------- ---
elog_async  31  suspend 0x000000a8 0x00000400    26%   0x00000003 000
tshell      20  ready   0x0000019c 0x00001000    39%   0x00000006 000
tidle       31  ready   0x0000006c 0x00000100    50%   0x0000000b 000
SysMonitor  30  suspend 0x000000a8 0x00000200    32%   0x00000005 000
timer        4  suspend 0x0000007c 0x00000200    24%   0x00000009 000
---------------------------------------------
qstr:
  n_pool=0
  n_qstr=0
  n_str_data_bytes=0
  n_total_bytes=0
---------------------------------------------
GC:
  16064 total
  464 : 15600
  1=14 2=6 m=3
>>> pyb.enable_irq()        # enable interrupt
>>> pyb.disable_irq()       # disable interrupt, WARNING: this operation is dangerous
>>> time_start = pyb.millis()          # return the number of milliseconds
>>> pyb.elapsed_millis(time_start)     # calculate the elapsed time of milliseconds
2449
>>> time_start = pyb.micros()          # return the number of microseconds
>>> pyb.elapsed_micros(time_start)     # calculate the elapsed time of microseconds
1769000
>>> pyb.delay(1000)         # delay milliseconds
>>> pyb.udelay(1000*1000)   # delay microseconds
>>> pyb.hard_reset()        # hard reset, like push RESET button

Pins and GPIO

See pyb.Pin.

>>> from pyb import Pin
>>> 
>>> p_out = Pin(("X1", 33), Pin.OUT_PP)
>>> p_out.value(1)              # set io high
>>> p_out.value(0)              # set io low
>>> 
>>> p_in = Pin(("X2", 32), Pin.IN, Pin.PULL_UP)
>>> p_in.value()                # get value, 0 or 1

Coming soon

The MIT License (MIT) Copyright (c) 2017 Armink (armink.ztl@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

MicroPython port for RT-Thread on STM32F4 board 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qq1847123212/MpyOnRtt.git
git@gitee.com:qq1847123212/MpyOnRtt.git
qq1847123212
MpyOnRtt
MpyOnRtt
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891