Skip to content

Commit d07d852

Browse files
Jimmy Luo(罗杨杨)Jimmy Luo(罗杨杨)
authored andcommitted
increase 600U/200U SD card(SDIO interface) instruction
1 parent 257373c commit d07d852

File tree

2 files changed

+215
-4
lines changed

2 files changed

+215
-4
lines changed

en-us/api/pythonStdlib.md

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ b'\xb3\xc9Y\x1b\xe9'
204204

205205

206206

207-
##### Initialize SD card driver
207+
##### Initialize SD card driver(SPI mode)
208208

209209
At present, it is only supported by ec600n / ec800n platforms.
210210

@@ -257,7 +257,7 @@ Mount the underlying file system to VFS.
257257
>>> uos.mount(cdev, '/sd')
258258
```
259259

260-
-SD card usage example
260+
-SD card usage example(SPI mode)
261261

262262
At present, it is only supported by ec600n / ec800n platforms.
263263

@@ -275,6 +275,111 @@ Mount the underlying file system to VFS.
275275

276276

277277

278+
##### Initialize SD card driver(SDIO mode)
279+
280+
At present,it is only supported by EC600U/EC200U platforms.
281+
282+
> **VfsSd(str)**
283+
284+
Initialize SD card Use SDIO interface.
285+
286+
* Parameter
287+
288+
| Parameter | Type | Description |
289+
| ---- | -------- | ----------------------------------- |
290+
| str | str | pass "sd_fs" |
291+
292+
* Return Value
293+
Return vfs object if the execution is successful, otherwise report error.
294+
295+
- Pin Correspondence
296+
297+
| platform | |
298+
| ------ | ------------------------------------------------------------ |
299+
| EC600U | CMD:Pin number 48<br />DATA0:Pin number 39<br />DATA1:Pin number 40<br />DATA2:Pin number 49<br />DATA3:Pin number 号50<br />CLK:Pin number 132 |
300+
| EC200U | CMD:Pin number 33<br />DATA0:Pin number 31<br />DATA1:Pin number 30<br />DATA2:Pin number 29<br />DATA3:Pin number 28<br />CLK:Pin number 32 |
301+
302+
* Exmaple
303+
304+
```python
305+
>>> from uos import VfsSd
306+
>>> udev = VfsSd("sd_fs")
307+
```
308+
309+
##### Set detection pin
310+
311+
> **set_det(vfs_obj.GPIOn,mode)**
312+
313+
Set the detection pin and mode of SD card insert and plug out detection.
314+
315+
* Parameter
316+
317+
| Parameter | Type | Description |
318+
| ------------- | -------- | ------------------------------------------------------------ |
319+
| vfs_obj.GPIOn | int | GPIO pin number for SD card insert and plug out detection, refer to the definition of Pin module |
320+
| mode | int | 0: when inserte the SD card, the detection port is at low level; when plug out the SD card, the detection port is at high level<br />1:when inserte the SD card, the detection port is at high level;when plug out the SD card, the detection port is at low level |
321+
322+
* Return Value
323+
324+
Return 0 if the execution is successful, otherwise return -1.
325+
326+
* Exmaple
327+
328+
```python
329+
>>> from uos import VfsSd
330+
>>> udev = VfsSd("sd_fs")
331+
>>> uos.mount(udev, '/sd')
332+
>>> udev.set_det(udev.GPIO10,0)#Use gpio10 as the card detection pin, insert the SD card, the detection port is low level, plug out the SD card, the detection port is high level(the actual use depends on the hardware).
333+
```
334+
335+
##### Setting the card insertion and removal callback function
336+
337+
> **set_callback(fun)**
338+
339+
Set the user callback function in case of card insert and plug out event.
340+
341+
* Parameter
342+
343+
| Parameter | Type | Description |
344+
| ---- | -------- | ------------------------------------------------------------ |
345+
| fun | function | insertion and removal callback function [ind_type]<br />ind_type: event type,0:plug out 1:insert |
346+
347+
* Return Value
348+
349+
Return 0 if the execution is successful, otherwise return -1.
350+
351+
352+
SD card usage example(SDIO mode)
353+
354+
At present,it is only supported by EC600U/EC200U platforms.
355+
356+
```python
357+
from uos import VfsSd
358+
import ql_fs
359+
udev = VfsSd("sd_fs")
360+
uos.mount(udev, '/sd')
361+
udev.set_det(udev.GPIO10,0)
362+
#file read / write
363+
f = open('/sd/test.txt','w+')
364+
f.write('1234567890abcdefghijkl')
365+
f.close()
366+
uos.listdir('/sd')
367+
f = open('/sd/test.txt','r')
368+
f.read()
369+
f.close()
370+
#card insertion and removal callback function
371+
def call_back(para):
372+
if(para == 1):
373+
print("insert")
374+
print(uos.listdir('/usr'))
375+
print(ql_fs.file_copy('/usr/1.txt','/sd/test.txt'))#copy the test.Txt under SD card to 1.txt under usr partition
376+
print(uos.listdir('/usr'))
377+
elif(para == 0):
378+
print("plug out")
379+
380+
udev.set_callback(call_back)
381+
```
382+
278383
#### gc - Control the Garbage Collector
279384

280385
This module provides an interface to the optional garbage collector. This module implements a subset of the corresponding [CPython](https://docs.micropython.org/en/latest/reference/glossary.html#term-CPython) module, as described below. For more information, refer to the original CPython documentation: [gc](https://docs.python.org/3.5/library/gc.html#module-gc)

zh-cn/api/pythonStdlib.md

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ b'\xb3\xc9Y\x1b\xe9'
201201

202202

203203

204-
##### 初始化SD卡驱动
204+
##### 初始化SD卡驱动(SPI接口)
205205

206206
目前仅EC600N/EC800N平台支持。
207207

@@ -254,7 +254,7 @@ b'\xb3\xc9Y\x1b\xe9'
254254
>>> uos.mount(cdev, '/sd')
255255
```
256256

257-
- SD卡使用示例
257+
- SD卡(SPI接口)使用示例
258258

259259
目前仅EC600N/EC800N平台支持。
260260

@@ -272,6 +272,112 @@ b'\xb3\xc9Y\x1b\xe9'
272272

273273

274274

275+
##### 初始化SD卡驱动(SDIO接口)
276+
277+
目前仅EC600U/EC200U平台支持。
278+
279+
> **VfsSd(str)**
280+
281+
初始化SD卡,使用SDIO通信方式。
282+
283+
* 参数
284+
285+
| 参数 | 参数类型 | 参数说明 |
286+
| ---- | -------- | ----------------------------------- |
287+
| str | str | 传入"sd_fs" |
288+
289+
* 返回值
290+
291+
成功则返回vfs object,失败则会报错。
292+
293+
- 引脚说明
294+
295+
| 平台 | 引脚 |
296+
| ------ | ------------------------------------------------------------ |
297+
| EC600U | CMD:引脚号48<br />DATA0:引脚号39<br />DATA1:引脚号40<br />DATA2:引脚号49<br />DATA3:引脚号50<br />CLK:引脚号132 |
298+
| EC200U | CMD:引脚号33<br />DATA0:引脚号31<br />DATA1:引脚号30<br />DATA2:引脚号29<br />DATA3:引脚号28<br />CLK:引脚号32 |
299+
300+
* 示例
301+
302+
```python
303+
>>> from uos import VfsSd
304+
>>> udev = VfsSd("sd_fs")
305+
```
306+
307+
##### 设置检测管脚
308+
309+
> **set_det(vfs_obj.GPIOn,mode)**
310+
311+
指定sd卡插拔卡的检测管脚和模式。
312+
313+
* 参数
314+
315+
| 参数 | 参数类型 | 参数说明 |
316+
| ------------- | -------- | ------------------------------------------------------------ |
317+
| vfs_obj.GPIOn | int | 用于sd卡插拔卡检测的GPIO引脚号,参照Pin模块的定义 |
318+
| mode | int | 0:sd卡插上后,检测口为低电平;sd卡取出后,检测口为高电平<br />1:sd卡插上后,检测口为高电平;sd卡取出后,检测口为低电平 |
319+
320+
* 返回值
321+
322+
成功返回0,失败返回-1。
323+
324+
* 示例
325+
326+
```python
327+
>>> from uos import VfsSd
328+
>>> udev = VfsSd("sd_fs")
329+
>>> uos.mount(udev, '/sd')
330+
>>> udev.set_det(udev.GPIO10,0)#使用GPIO10作为卡检测管脚,sd卡插上,检测口为低电平,sd卡取出,检测口为高电平(实际使用根据硬件)
331+
```
332+
333+
##### 设置插拔卡回调函数
334+
335+
> **set_callback(fun)**
336+
337+
设定发生插拔卡事件时的用户回调函数。
338+
339+
* 参数
340+
341+
| 参数 | 参数类型 | 参数说明 |
342+
| ---- | -------- | ------------------------------------------------------------ |
343+
| fun | function | 插拔卡回调 [ind_type]<br />ind_type: 事件类型,0:拔卡 1:插卡 |
344+
345+
* 返回值
346+
347+
成功返回0,失败返回-1。
348+
349+
350+
SD卡使用示例(SDIO接口)
351+
352+
目前仅EC600U/EC200U平台支持。
353+
354+
```python
355+
from uos import VfsSd
356+
import ql_fs
357+
udev = VfsSd("sd_fs")
358+
uos.mount(udev, '/sd')
359+
udev.set_det(udev.GPIO10,0)
360+
#文件读写
361+
f = open('/sd/test.txt','w+')
362+
f.write('1234567890abcdefghijkl')
363+
f.close()
364+
uos.listdir('/sd')
365+
f = open('/sd/test.txt','r')
366+
f.read()
367+
f.close()
368+
#插拔卡回调函数
369+
def call_back(para):
370+
if(para == 1):
371+
print("insert")
372+
print(uos.listdir('/usr'))
373+
print(ql_fs.file_copy('/usr/1.txt','/sd/test.txt'))#复制sd卡里的test.txt内容到usr下的1.txt中
374+
print(uos.listdir('/usr'))
375+
elif(para == 0):
376+
print("plug out")
377+
378+
udev.set_callback(call_back)
379+
```
380+
275381
#### gc - 内存碎片回收
276382

277383
gc 模块实现内存垃圾回收机制,该模块实现了CPython模块相应模块的子集。更多信息请参阅阅CPython文档:[gc](https://docs.python.org/3.5/library/gc.html#module-gc)

0 commit comments

Comments
 (0)