Wykres commitów

10 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 90023b4dcf extmod/modmachine: Clean up decls of machine types to use common ones.
The machine_i2c_type, machine_spi_type and machine_timer_type symbols are
already declared in extmod/modmachine.h and should not be declared anywhere
else.

Also move declarations of machine_pin_type and machine_rtc_type to the
common header in extmod.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-26 16:20:53 +11:00
Damien George 6f76d1c7fa rp2: Implement time.time_ns with time_us_64 so it has us resolution.
Currently on rp2 the time.time_ns() function has only seconds resolution.
This commit makes it have microsecond resolution, by using the output of
time_us_64() instead of the RTC.

Tested that it does not drift from the RTC over long periods of time.

Signed-off-by: Damien George <damien.p.george@gmail.com>
2023-10-05 21:24:47 +11:00
Jim Mussared 94beeabd2e py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other
methods.

This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:15 +10:00
Jim Mussared 9dce82776d all: Remove unnecessary locals_dict cast.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 662b9761b3 all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10: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
Krzysztof Adamski feb7e2e864 rp2/machine_rtc: In RTC.datetime, compute weekday automatically.
Calculating the weekday each time you want to set a date is error prone and
tiresome.  MicroPython can do it on its own - hardware on some ports do not
support storing weekday in hardware and always computes it on the fly,
ignoring the value given to the constructor.

During discussion for #7432 the conclusion was that there seems to be no
obvious reason to let user set the weekday to an incorrect value so it
makes sense to just ignore the provided weekday value and always compute
the correct value.  This patch introduces this change for the rp2 port.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-25 10:29:45 +10:00
Krzysztof Adamski e7f7094ef6 rp2/machine_rtc: Check return value from rtc_set_datetime.
The rtc_set_datetime() from pico-sdk will validate the values in the
datetime_t structure and refuse to set the time if they aren't valid. It
makes sense to raise an exception if this happens instead of failing
silently which might be confusing (as an example, see:
https://github.com/micropython/micropython/pull/6928#issuecomment-860166044
).
2021-06-15 00:06:26 +10:00
Krzysztof Adamski 37d01d4be3 rp2/machine_rtc: Add initial support for RTC.
Initial support for machine.RTC on rp2 port. It only supports datetime()
method and nothing else. The method gets/returns a tuple of 8 items, just
like esp32 port, for example, but the usec parameter is ignored as the RP2
RTC only works up to seconds precision.

The Pico RTC isn't very useful as the time is lost during reset and there
seems to be no way to easily power up just the RTC clock with a low current
voltage, but still there seems to be use-cases for that, see issues #6831,
and a Thonny issue #1592. It was also requested for inclusion on v1.15
roadmap on #6832.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-12 23:02:54 +10:00