Wykres commitów

37 Commity (master)

Autor SHA1 Wiadomość Data
Angus Gratton decf8e6a8b all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-07 14:20:42 +11:00
Damien George 30a63a204d extmod/modmachine: Provide common Python bindings for machine.idle().
And use it in all ports.  The ports are unchanged, except esp8266 which now
just returns None from this function instead of the time elapsed (to match
other ports), and qemu-arm which gains this function.

Signed-off-by: Damien George <damien@micropython.org>
2023-11-30 16:11:11 +11:00
Damien George 5b4a2baff6 extmod/machine_uart: Factor ports' UART Python bindings to common code.
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings.  For all ports except the two listed
below there is no functional change.

The nrf port has UART.sendbreak() removed, but this method previously did
nothing.

The zephyr port has the following methods added:
- UART.init(): supports setting timeout and timeout_char.
- UART.deinit(): does nothing, just returns None.
- UART.flush(): raises OSError(EINVAL) because it's not implemented.
- UART.any() and UART.txdone(): raise NotImplementedError.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-26 10:46:42 +11:00
Jim Mussared 0ceccd4cf8 all: Rename *umodule*.h to remove the "u" prefix.
This work was funded through GitHub Sponsors.

Also updates #includes.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:14 +10:00
Jim Mussared 7f5d5c7271 all: Rename mod_umodule*, ^umodule* to remove the "u" prefix.
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:07 +10:00
Jim Mussared 1bf2dcb15e all: Rename mp_umodule*, mp_module_umodule* to remove the "u" prefix.
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:04 +10:00
Damien George 9955553001 extmod/modutime: Provide a generic time module.
Based on extmod/utime_mphal.c, with:
- a globals dict added
- time.localtime wrapper added
- time.time wrapper added
- time.time_ns function added

New configuration options are added for this module:
- MICROPY_PY_UTIME (enabled at basic features level)
- MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME
- MICROPY_PY_UTIME_TIME_TIME_NS

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:09:56 +10:00
Jim Mussared 7d40317a4a stm32: Add a default implementation of pyb.country.
This is for boards without networking support so that the default boot.py
continues to work.

Also update boot.py to use network.country and network.hostname instead.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-03-01 01:28:12 +11:00
Jim Mussared a377302623 extmod/modnetwork: Add network.hostname() and network.country().
This provides a standard interface to setting the global networking config
for all interfaces and interface types.

For ports that already use either a static hostname (mimxrt, rp2) they will
now use the configured value. The default is configured by the port
(or optionally the board).

For interfaces that previously supported .config(hostname), this is still
supported but now implemented using the global network.hostname.

Similarly, pyb.country and rp2.country are now deprecated, but the methods
still exist (and forward to network.hostname).

Because ESP32/ESP8266 do not use extmod/modnetwork.c they are not affected
by this commit.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-03-01 01:26:17 +11:00
robert-hh 2426ddb575 stm32/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:57:46 +11:00
Damien George efe23aca71 all: Remove third argument to MP_REGISTER_MODULE.
It's no longer needed because this macro is now processed after
preprocessing the source code via cpp (in the qstr extraction stage), which
means unused MP_REGISTER_MODULE's are filtered out by the preprocessor.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 16:31:37 +10:00
Jim Mussared 0a92469c10 stm32: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:56:30 +10:00
Damien George 11b77263ef stm32/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George 136369d72f all: Update to point to files in new shared/ directory.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 17:08:10 +10:00
Damien George 5f3c2f1fa8 stm32/irq: Clean up irq.h so it does not depend on core uPy defines.
The irq.h file now just provides low-level IRQ definitions and priorities.
All Python binding definitions are moved to modmachine.h, with some
renaming of pyb -> machine, and also the machine_idle definition (was
pyb_wfi) is moved to modmachine.c.

The cc3200 and teensy ports are updated to build with these changes.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 13:47:15 +10:00
Jim Mussared def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Yonatan Goldschmidt 61d2b40ad5 lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.
For the 3 ports that already make use of this feature (stm32, nrf and
teensy) this doesn't make any difference, it just allows to disable it from
now on.

For other ports that use pyexec, this decreases code size because the debug
printing code is dead (it can't be enabled) but the compiler can't deduce
that, so code is still emitted.
2019-12-28 00:05:39 +11:00
Frederic.Pierson 28062b5108 stm32/accel: Add support for KXTJ3. 2019-10-18 11:41:22 +11:00
Damien George ba607809f2 stm32/modpyb: Support building with PY_PYB_LEGACY on and HW_USB_HID off. 2019-08-15 12:03:32 +10:00
Damien George f302f784e9 stm32/usb: Add config options to disable USB MSC and/or HID.
The new configurations MICROPY_HW_USB_MSC and MICROPY_HW_USB_HID can be
used by a board to enabled or disable MSC and/or HID.  They are both
enabled by default.
2019-07-16 14:39:21 +10:00
Damien George 345e9864aa stm32/modpyb: Add pyb.country() function to set the country.
To be used for peripherals (like radio) that must be location aware.
2019-06-03 16:47:35 +10:00
Damien George 7ce2a08231 stm32: Add support for MMC driver, exposed via pyb.MMCard class.
Enable it via MICROPY_HW_ENABLE_MMCARD.
2019-04-01 17:04:43 +11:00
Damien George 9670b26526 stm32: Rename MICROPY_HW_HAS_SDCARD to MICROPY_HW_ENABLE_SDCARD.
For consistency with the majority of other MICROPY_HW_ENABLE_xxx macros.
2019-04-01 15:21:26 +11:00
Damien George 285d265eee stm32: Implement machine.lightsleep(). 2019-01-27 11:13:32 +11:00
Damien George e1ae9939ac stm32: Support compiling with object representation D.
With this and previous patches the stm32 port can now be compiled using
object representation D (nan boxing).  Note that native code and frozen mpy
files with float constants are currently not supported with this object
representation.
2018-07-08 23:25:11 +10:00
Damien George fb25c81062 stm32/modpyb: Remove unused includes and clean up comments.
The documentation (including the examples) for elapsed_millis and
elapsed_micros can be found in docs/library/pyb.rst so doesn't need to be
written in full in the source code.
2018-05-14 14:01:50 +10:00
Damien George 88c26a48b4 stm32/pyb_i2c: Put pyb.I2C under MICROPY_PY_PYB_LEGACY setting.
When disabled, the pyb.I2C class saves around 8k of code space and 172
bytes of RAM.  The same functionality is now available in machine.I2C
(for F4 and F7 MCUs).

It is still enabled by default.
2018-05-14 13:53:46 +10:00
Damien George 92c5e2708d stm32/modpyb: Introduce MICROPY_PY_PYB_LEGACY config option for pyb mod.
This is enabled by default.  When it is disabled all legacy functions and
classes in the pyb module are excluded from the build.
2018-05-14 13:49:22 +10:00
Damien George a60efa8202 stm32/uart: Allow ctrl-C to work with UARTs put on REPL via os.dupterm. 2018-04-23 20:44:30 +10:00
Damien George 60b0982bb2 stm32: Add board config option to enable/disable the ADC.
The new option is MICROPY_HW_ENABLE_ADC and is enabled by default.
2018-02-22 14:22:45 +11:00
Damien George 5c320bd0b0 stm32: Introduce MICROPY_HW_ENABLE_USB and clean up USB config.
This patch allows to completely compile-out support for USB, and no-USB is
now the default.  If a board wants to enable USB it should define:

    #define MICROPY_HW_ENABLE_USB (1)

And then one or more of the following to select the USB PHY:

    #define MICROPY_HW_USB_FS (1)
    #define MICROPY_HW_USB_HS (1)
    #define MICROPY_HW_USB_HS_IN_FS (1)
2018-02-13 18:51:08 +11:00
Damien George efdda2c62d stm32: Add support for DHT11/DHT22 sensors. 2018-01-31 18:12:53 +11:00
Damien George c73360bfdb stm32: Allow to build a board without any hardware I2C ports defined.
This patch adds in internal config value MICROPY_HW_ENABLE_HW_I2C that is
automatically configured, and enabled only if one or more hardware I2C
ports are defined in the mpconfigboard.h file.  If none are defined then
the pyb.I2C class is excluded from the build, along with all supporting
code.  The machine.I2C class will still be available for software I2C.

Disabling all hardware I2C on an F4 board saves around 10,000 bytes of code
and 200 bytes of RAM.
2017-12-22 15:20:42 +11:00
Damien George d6bf3658f4 stm32: Make uos.dupterm() conform to specs by using extmod version.
The legacy function pyb.repl_uart() is still provided and retains its
original behaviour (it only accepts a UART object).  uos.dupterm() will now
accept any object with write/readinto methods.  At the moment there is just
1 dupterm slot.
2017-10-19 14:16:42 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George 01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
2017-09-06 13:40:51 +10:00