summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/machine_signal.c
Commit message (Collapse)AuthorAge
* extmod/modmachine: Add MICROPY_PY_MACHINE_SIGNAL configuration option.Damien George2024-03-15
| | | | | | Enabled by default. Signed-off-by: Damien George <damien@micropython.org>
* all: Remove the "STATIC" macro and just use "static" instead.Angus Gratton2024-03-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The STATIC macro was introduced a very long time ago in commit d5df6cd44a433d6253a61cb0f987835fbc06b2de. 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>
* extmod/modmachine: Consolidate simple machine headers into modmachine.h.Damien George2023-10-26
| | | | | | | The contents of machine_bitstream.h, machine_pinbase.h, machine_pulse.h and machine_signal.h have been moved into extmod/modmachine.h. Signed-off-by: Damien George <damien@micropython.org>
* py/obj: Convert make_new into a mp_obj_type_t slot.Jim Mussared2022-09-19
| | | | | | | | | | | 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>
* py/obj: Add accessors for type slots and use everywhere.Jim Mussared2022-09-19
| | | | | | | This is a no-op, but sets the stage for changing the mp_obj_type_t representation. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Remove unnecessary locals_dict cast.Jim Mussared2022-09-19
| | | | Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.Jim Mussared2022-09-19
| | | | | | In preparation for upcoming rework of mp_obj_type_t layout. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Use mp_obj_malloc everywhere it's applicable.Jim Mussared2022-05-03
| | | | | | | | | | | | | | | This replaces occurences of foo_t *foo = m_new_obj(foo_t); foo->base.type = &foo_type; with foo_t *foo = mp_obj_malloc(foo_t, &foo_type); Excludes any places where base is a sub-field or when new0/memset is used. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Reformat C and Python source code with tools/codeformat.py.Damien George2020-02-28
| | | | This is run with uncrustify 0.70.1, and black 19.10b0.
* extmod/machine_signal: Fix fault when no args are passed to Signal().Damien George2019-04-26
|
* extmod: Convert legacy uppercase macro names to lowercase.Damien George2019-02-12
|
* extmod/machine_signal: Change VLA to use new scoped allocation API.Damien George2017-12-11
|
* extmod/machine_signal: Fix parsing of invert arg when Pin is first arg.Damien George2017-07-26
|
* extmod/machine_signal: Rename "inverted" arg to "invert", it's shorter.Damien George2017-04-15
| | | | | | | A shorter name takes less code size, less room in scripts and is faster to type at the REPL. Tests and HW-API examples are updated to reflect the change.
* extmod/machine_signal: Support all Pin's arguments to the constructor.Paul Sokolovsky2017-04-11
| | | | | | | | | | | | | | | | | This implements the orginal idea is that Signal is a subclass of Pin, and thus can accept all the same argument as Pin, and additionally, "inverted" param. On the practical side, it allows to avoid many enclosed parenses for a typical declararion, e.g. for Zephyr: Signal(Pin(("GPIO_0", 1))). Of course, passing a Pin to Signal constructor is still supported and is the most generic form (e.g. Unix port will only support such form, as it doesn't have "builtin" Pins), what's introduces here is just practical readability optimization. "value" kwarg is treated as applying to a Signal (i.e. accounts for possible inversion).
* extmod/machine_signal: Implement Signal .on() and .off() methods.Paul Sokolovsky2017-02-08
| | | | | | | Each method asserts and deasserts signal respectively. They are equivalent to .value(1) and .value(0) but conceptually simpler (and may help to avoid confusion with inverted signals, where "asserted" state means logical 0 output).
* extmod/machine_signal: Implement "signal" abstraction for machine module.Paul Sokolovsky2017-01-29
A signal is like a pin, but ca also be inverted (active low). As such, it abstracts properties of various physical devices, like LEDs, buttons, relays, buzzers, etc. To instantiate a Signal: pin = machine.Pin(...) signal = machine.Signal(pin, inverted=True) signal has the same .value() and __call__() methods as a pin.