Wykres commitów

14 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
Paul Grayson fbf079d773 rp2: Add new NO_DEFAULT_PINS config options for i2c, spi, and uart.
Some boards have multiple options for these pins, and they don't want to
allow users to initialize a port without explicitly specifying pin numbers.

Signed-off-by: Paul Grayson <paul@pololu.com>
2023-12-18 14:07:03 +11:00
Damien George 3e2706a18d extmod/modmachine: Consolidate mem, i2c and spi headers to modmachine.h.
The contents of machine_mem.h, machine_i2c.h and machine_spi.h have been
moved into extmod/modmachine.h.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-26 17:40:22 +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
David (Pololu) bf3eb9dc39 rp2/machine_i2c: Add timeout parameter for machine.I2C().
This commit adds support for the `timeout` keyword argument to machine.I2C
on the rp2 port, following how it's done on other ports.

The main motivation here is avoid the interpreter crashing due to infinite
loops when SDA is stuck low, which is quite common if the board gets reset
while reading from an I2C device.

A default timeout of 50ms is chosen because it's consistent with:
- Commit a707fe50b0 which used a timeout of
  50,000us for zero-length writes on the rp2 port.
- The machine.SoftI2C class which uses 50,000us as the default timeout.
- The stm32 port's hardware I2C, which uses 50,000us for
  I2C_POLL_DEFAULT_TIMEOUT_US.

This commit also fixes the default timeout on the esp32 port to be
consistent with the above, and updates the documentation for machine.I2C to
document this keyword argument.
2023-04-21 18:03:33 +10:00
iabdalkader 22ad45fda6 rp2: Rename machine I2C type consistently across ports.
This renames:
- machine_hw_i2c_type -> machine_i2c_type
2022-10-22 12:56:58 +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
Jim Mussared 315e74236f rp2/machine_i2c: Use pico-sdk's default pins for I2C.
Inherits the default values for whichever instance is PICO_DEFAULT_I2C.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08 14:51:11 +10:00
Damien George a707fe50b0 rp2/machine_i2c: Use soft I2C only for len=0, and increase timeout.
The RP2040 I2C hardware can do writes of length 1 and 2, just not of length
0.  So only use software I2C for writes of length 0, to improve
performance.

Also increase the software I2C timeout for zero-length writes to
accommodate the behaviour of a wider range of I2C devices.

Fixes issue #8167.

Signed-off-by: Damien George <damien@micropython.org>
2022-01-21 15:10:29 +11:00
Damien George 7b0a42374e rp2/machine_i2c: Provide more specific error codes from I2C transfer.
Signed-off-by: Damien George <damien@micropython.org>
2022-01-20 16:43:55 +11:00
Mike Causer 79da7757cc rp2/machine_i2c: Allow boards to configure I2C pins using new macros. 2021-07-19 23:16:11 +10:00
Damien George 469345e728 rp2: Add new port to Raspberry Pi RP2 microcontroller.
This commit adds a new port "rp2" which targets the new Raspberry Pi RP2040
microcontroller.

The build system uses pure cmake (with a small Makefile wrapper for
convenience).  The USB driver is TinyUSB, and there is a machine module
with most of the standard classes implemented.  Some examples are provided
in the examples/rp2/ directory.

Work done in collaboration with Graham Sanderson.

Signed-off-by: Damien George <damien@micropython.org>
2021-01-30 00:42:29 +11:00