Sfoglia il codice sorgente

【优化】项目目录结构。

Signed-off-by: armink <armink.ztl@gmail.com>
armink 6 anni fa
parent
commit
20cd90ef98

+ 4 - 0
SConscript

@@ -9,6 +9,8 @@ src    += Glob('lib/mp-readline/*.c')
 src    += Glob('lib/utils/*.c')
 src    += Glob('extmod/*.c')
 src    += Glob('port/*.c')
+src    += Glob('port/modules/*.c')
+src    += Glob('port/modules/machine/*.c')
 src    += Glob('lib/netutils/*.c')
 src    += Glob('lib/timeutils/*.c')
 src    += Glob('drivers/bus/*.c')
@@ -16,6 +18,8 @@ src    += Glob('port/native/*.c')
 
 path    = [cwd + '/']
 path   += [cwd + '/port']
+path   += [cwd + '/port/modules']
+path   += [cwd + '/port/modules/machine']
 
 LOCAL_CCFLAGS = ''
 

+ 0 - 40
port/fdfile.h

@@ -1,40 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
-#ifndef MICROPY_INCLUDED_UNIX_FDFILE_H
-#define MICROPY_INCLUDED_UNIX_FDFILE_H
-
-#include "py/obj.h"
-
-typedef struct _mp_obj_fdfile_t {
-    mp_obj_base_t base;
-    int fd;
-} mp_obj_fdfile_t;
-
-extern const mp_obj_type_t mp_type_fileio;
-extern const mp_obj_type_t mp_type_textio;
-
-#endif // MICROPY_INCLUDED_UNIX_FDFILE_H

+ 0 - 40
port/help.c

@@ -1,40 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * 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.
- */
-
-#include "py/builtin.h"
-
-const char rtthread_help_text[] =
-"Welcome to MicroPython on RT-Thread!\n"
-"\n"
-"Control commands:\n"
-"  CTRL-A        -- on a blank line, enter raw REPL mode\n"
-"  CTRL-B        -- on a blank line, enter normal REPL mode\n"
-"  CTRL-C        -- interrupt a running program\n"
-"  CTRL-D        -- on a blank line, do a soft reset of the board\n"
-"  CTRL-E        -- on a blank line, enter paste mode\n"
-"\n"
-"For further help on a specific object, type help(obj)\n"
-;

+ 0 - 0
port/machine_adc.c → port/modules/machine/machine_adc.c


+ 0 - 0
port/machine_adc.h → port/modules/machine/machine_adc.h


+ 0 - 0
port/machine_hw_i2c.c → port/modules/machine/machine_hw_i2c.c


+ 0 - 0
port/machine_hw_spi.c → port/modules/machine/machine_hw_spi.c


+ 0 - 0
port/machine_lcd.c → port/modules/machine/machine_lcd.c


+ 0 - 0
port/machine_lcd.h → port/modules/machine/machine_lcd.h


+ 0 - 0
port/machine_pin.c → port/modules/machine/machine_pin.c


+ 0 - 0
port/machine_pwm.c → port/modules/machine/machine_pwm.c


+ 0 - 0
port/machine_pwm.h → port/modules/machine/machine_pwm.h


+ 0 - 0
port/machine_rtc.c → port/modules/machine/machine_rtc.c


+ 0 - 0
port/machine_rtc.h → port/modules/machine/machine_rtc.h


+ 0 - 0
port/machine_timer.c → port/modules/machine/machine_timer.c


+ 0 - 0
port/machine_timer.h → port/modules/machine/machine_timer.h


+ 0 - 0
port/machine_uart.c → port/modules/machine/machine_uart.c


+ 0 - 0
port/machine_uart.h → port/modules/machine/machine_uart.h


+ 0 - 0
port/machine_wdt.c → port/modules/machine/machine_wdt.c


+ 0 - 0
port/machine_wdt.h → port/modules/machine/machine_wdt.h


+ 0 - 0
port/modmachine.c → port/modules/machine/modmachine.c


+ 0 - 0
port/modmachine.h → port/modules/machine/modmachine.h


+ 0 - 0
port/modffi.c → port/modules/modffi.c


+ 5 - 2
port/file.c → port/modules/modfile.c

@@ -32,7 +32,6 @@
 #include "py/stream.h"
 #include "py/builtin.h"
 #include "py/mphal.h"
-#include "fdfile.h"
 
 #include <stdio.h>
 #include <unistd.h>
@@ -41,11 +40,15 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-
 #ifdef _WIN32
 #define fsync _commit
 #endif
 
+typedef struct _mp_obj_fdfile_t {
+    mp_obj_base_t base;
+    int fd;
+} mp_obj_fdfile_t;
+
 #ifdef MICROPY_CPYTHON_COMPAT
 STATIC void check_fd_is_open(const mp_obj_fdfile_t *o) {
     if (o->fd < 0) {

+ 0 - 0
port/modnetwork.c → port/modules/modnetwork.c


+ 0 - 0
port/modnetwork.h → port/modules/modnetwork.h


+ 0 - 0
port/network_wlan.c → port/modules/modnetwork_wlan.c


+ 0 - 1
port/modpyb.c → port/modules/modpyb.c

@@ -32,7 +32,6 @@
 #include "py/builtin.h"
 #include "py/mphal.h"
 #include "lib/utils/pyexec.h"
-#include "portmodules.h"
 #include "modmachine.h"
 #include "extmod/vfs.h"
 #include "extmod/utime_mphal.h"

+ 0 - 0
port/modrtthread.c → port/modules/modrtthread.c


+ 0 - 1
port/moduos.c → port/modules/moduos.c

@@ -38,7 +38,6 @@
 #include "lib/timeutils/timeutils.h"
 #include "extmod/misc.h"
 #include "genhdr/mpversion.h"
-#include "portmodules.h"
 
 #if !MICROPY_VFS
 #if MICROPY_PY_MODUOS_FILE

+ 0 - 0
port/moduos_file.c → port/modules/moduos_file.c


+ 0 - 0
port/moduos_file.h → port/modules/moduos_file.h


+ 0 - 0
port/modusocket.c → port/modules/modusocket.c


+ 0 - 0
port/modutils.c → port/modules/modutils.c


+ 0 - 0
port/modutime.c → port/modules/modutime.c


+ 13 - 1
port/mphalport.c

@@ -34,6 +34,19 @@
 #include "mpgetcharport.h"
 #include "mpputsnport.h"
 
+const char rtthread_help_text[] =
+"Welcome to MicroPython on RT-Thread!\n"
+"\n"
+"Control commands:\n"
+"  CTRL-A        -- on a blank line, enter raw REPL mode\n"
+"  CTRL-B        -- on a blank line, enter normal REPL mode\n"
+"  CTRL-C        -- interrupt a running program\n"
+"  CTRL-D        -- on a blank line, do a soft reset of the board\n"
+"  CTRL-E        -- on a blank line, enter paste mode\n"
+"\n"
+"For further help on a specific object, type help(obj)\n"
+;
+
 int mp_hal_stdin_rx_chr(void) {
     char ch;
     while (1) {
@@ -47,7 +60,6 @@ int mp_hal_stdin_rx_chr(void) {
     return ch;
 }
 
-
 // Send string of given length
 void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
     mp_putsn(str, len);

+ 0 - 36
port/portmodules.h

@@ -1,36 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * 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.
- */
-
-#ifndef _PORTMODULES_H
-#define _PORTMODULES_H
-
-MP_DECLARE_CONST_FUN_OBJ_1(time_sleep_ms_obj);
-MP_DECLARE_CONST_FUN_OBJ_1(time_sleep_us_obj);
-
-MP_DECLARE_CONST_FUN_OBJ_0(mod_os_sync_obj);
-MP_DECLARE_CONST_FUN_OBJ_KW(mp_os_mount_obj);
-
-#endif // _PORTMODULES_H