summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)Author
2021-02-02examples/rp2: Add pio_uart_rx.py example.Tim Radvan
This was adapted from the `pio/uart_rx` example from the `pico-examples` repository: https://github.com/raspberrypi/pico-examples/blob/master/pio/uart_rx/uart_rx.pio It demonstrates the `jmp_pin` feature in action. Signed-off-by: Tim Radvan <tim@tjvr.org>
2021-01-30rp2: Add new port to Raspberry Pi RP2 microcontroller.Damien George
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>
2020-12-02examples/bluetooth: Add bonding/passkey demo.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Allow setting char/desc enc/auth options.Andrew Leech
This widens the characteristic/descriptor flags to 16-bit, to allow setting encryption/authentication requirements. Sets the required flags for NimBLE and btstack implementations. The BLE.FLAG_* constants will eventually be deprecated in favour of copy and paste Python constants (like the IRQs). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-10-29examples: Add example code for user C modules, both C and C++.stijn
Add working example code to provide a starting point for users with files that they can just copy, and include the modules in the coverage test to verify the complete user C module build functionality. The cexample module uses the code originally found in cmodules.rst, which has been updated to reflect this and partially rewritten with more complete information.
2020-09-26examples/bluetooth: Update to use positional-only args to irq().Jim Mussared
To match 6a6a5f9e151473bdcc1d14725d680691ff665a82.
2020-08-29all: Update Python code to conform to latest black formatting.Damien George
Updating to Black v20.8b1 there are two changes that affect the code in this repository: - If there is a trailing comma in a list (eg [], () or function call) then that list is now written out with one line per element. So remove such trailing commas where the list should stay on one line. - Spaces at the start of """ doc strings are removed. Signed-off-by: Damien George <damien@micropython.org>
2020-07-20extmod/modbluetooth: Add event for "indicate acknowledgement".Jim Mussared
This commit adds the IRQ_GATTS_INDICATE_DONE BLE event which will be raised with the status of gatts_indicate (unlike notify, indications require acknowledgement). An example of its use is added to ble_temperature.py, and to the multitests in ble_characteristic.py. Implemented for btstack and nimble bindings, tested in both directions between unix/btstack and pybd/nimble.
2020-07-18examples/bluetooth: Add simple UART demo with central and peripheral.Jim Mussared
2020-07-18examples/bluetooth: In ble_advertising.py, skip appearance if not set.Jim Mussared
2020-06-10examples/bluetooth: Fix event code in ble_temperature_central.py.Jim Mussared
2020-06-08extmod/ure: Use single function for match/search/sub.stijn
Saves about 500 bytes on unix x64 and enables CPython-conform usage of passing a re object to these functions.
2020-06-05examples/bluetooth: Fix incorrect value of BR/EDR flag in advertising.jxltom
According to Supplement to the Bluetooth Core Specification v8 Part A 1.3.1, to support BR/EDR the code should set the fifth bit (Simultaneous LE and BR/EDR to Same Device Capable (Controller)) and fourth bit (Simultaneous LE and BR/EDR to Same Device Capable (Host)) of the flag.
2020-06-05extmod/modbluetooth: Ensure status=0 always on success.Jim Mussared
This commit makes sure that all discovery complete and read/write status events set the status to zero on success. The status value will be implementation-dependent on non-success cases.
2020-06-05extmod/modbluetooth: Implement read done event.Jim Mussared
On btstack there's no status associated with the read result, it comes through as a separate event. This allows you to detect read failures or timeouts.
2020-06-05extmod/modbluetooth: Add discover complete events for svc/char/desc.Jim Mussared
Without this it's difficult to implement a state machine correctly if the desired services are not found.
2020-06-05extmod/modbluetooth: Make modbluetooth event not a bitfield.Jim Mussared
There doesn't appear to be any use for only triggering on specific events, so it's just easier to number them sequentially. This makes them smaller values so they take up only 1 byte in the ringbuf, only 1 byte for the opcode in the bytecode, and makes room for more events. Also add a couple of new event types that need to be implemented (to avoid re-numbering later). And rename _COMPLETE and _STATUS to _DONE for consistency. In the future the "trigger" keyword argument can be reinstated by requiring the user to compute the bitmask, eg: ble.irq(handler, 1 << _IRQ_SCAN_RESULT | 1 << _IRQ_SCAN_DONE)
2020-05-02extmod/modbtree: Retain reference to underlying stream so it's not GC'd.Damien George
For ports that have a system malloc which is not garbage collected (eg unix, esp32), the stream object for the DB must be retained separately to prevent it from being reclaimed by the MicroPython GC (because the berkeley-db library uses malloc to allocate the DB structure which stores the only reference to the stream). Although in some cases the user code will explicitly retain a reference to the underlying stream because it needs to call close() on it, this is not always the case, eg in cases where the DB is intended to live forever. Fixes issue #5940.
2020-04-30all: Fix auto-enable of MICROPY_GCREGS_SETJMP to select GC behaviour.Damien George
Only enable it if MICROPY_GCREGS_SETJMP is not already defined, and no supported architecture is defined.
2020-04-29all: Factor gchelper code to one place and use it for unix & ARM ports.Jim Mussared
No functionality change is intended with this commit, it just consolidates the separate implementations of GC helper code to the lib/utils/ directory as a general set of helper functions useful for any port. This reduces duplication of code, and makes it easier for future ports or embedders to get the GC implementation correct. Ports should now link against gchelper_native.c and either gchelper_m0.s or gchelper_m3.s (currently only Cortex-M is supported but other architectures can follow), or use the fallback gchelper_generic.c which will work on x86/x64/ARM. The gc_helper_get_sp function from gchelper_m3.s is not really GC related and was only used by cc3200, so it has been moved to that port and renamed to cortex_m3_get_sp.
2020-04-05all: Use MP_ERROR_TEXT for all error messages.Jim Mussared
2020-04-05py/dynruntime.mk: Set MICROPY_ENABLE_DYNRUNTIME instead of per module.Jim Mussared
So this setting could be used by other source files if needed.
2020-03-12examples/bluetooth: Replace "connectable" parameter with "adv_type".Thomas Friebel
Follow up to dd0bc26e65734b8a4fafa3769008e92e2ec6645d which changed the parameter list of the IRQ_SCAN_RESULT event. Adapt ble_temperature_central.py accordingly.
2020-03-03examples/natmod: Add .gitignore to ignore generated example .mpy files.Damien George
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28examples/bluetooth/ble_temperature_central.py: Shorten comment.Damien George
So the line length is less than 100 characters.
2020-02-28examples/accellog.py: Shift long comments to their own line.Damien George
To improve interaction with black formatter.
2019-12-19examples/natmod: Add very simple features0 example to compute factorial.Damien George
2019-12-18examples/network: Add testing key/cert to SSL HTTP server example.Damien George
This example will now work on all ports with networking and ssl support, with both axtls and mbedtls.
2019-12-13examples/natmod: Add urandom native module example.Damien George
2019-12-12examples/natmod: Add features1 and features2 examples.Damien George
2019-12-12examples/natmod: Add ure example.Damien George
2019-12-12examples/natmod: Add framebuf example.Damien George
2019-12-12examples/natmod: Add uzlib example.Damien George
2019-12-12examples/natmod: Add uheapq example.Damien George
2019-12-12examples/natmod: Add btree example.Damien George
2019-11-25examples/bluetooth: Add example for reading temperature sensor.Jim Mussared
2019-11-25examples/bluetooth: Add helpers for decoding advertising payloads.Jim Mussared
Extracts name and service UUID fields.
2019-11-11examples/embedding: Remove obsolete fatfs files from build.Damien George
2019-10-29examples/bluetooth/ble_uart_peripheral: Use append mode for RX char.Jim Mussared
2019-10-29examples/embedding: Replace symlink of mpconfigport.h with real file.Damien George
2019-10-22examples/bluetooth/ble_uart_peripheral.py: Add usage demo.Jim Mussared
2019-10-22examples/bluetooth: Use UUIDs directly to add services to adv payload.Jim Mussared
2019-10-18examples/bluetooth: Add basic BLE peripheral examples.Jim Mussared
Consisting of: - ble_advertising.py -- helper to generate advertising payload. - ble_temperature.py -- simple temperature device. - ble_uart_periperhal.py -- BLE UART wrapper. - ble_uart_repl.py -- dupterm-compatible uart.
2019-08-28py: Add global default_emit_opt variable to make emit kind persistent.Damien George
mp_compile no longer takes an emit_opt argument, rather this setting is now provided by the global default_emit_opt variable. Now, when -X emit=native is passed as a command-line option, the emitter will be set for all compiled modules (included imports), not just the top-level script. In the future there could be a way to also set this variable from a script. Fixes issue #4267.
2018-10-23examples/unix/ffi_example: Clean up and update the ffi example.Paul Sokolovsky
1. Use uctypes.bytearray_at(). Implementation of the "ffi" module predates that of "uctypes", so initially some convenience functions to access memory were added to ffi. Later, they landed in uctypes (which follows CPython's ctype module). So, replace undocumented experimental functions from ffi to documented ones from uctypes. 2. Use more suitable type codes for arguments (e.g. "P" (const void*) instead of "p" (void*). 3. Some better var naming. 4. Clarify some messages printed by the example.
2018-09-14examples/embedding: Fix hard-coded MP_QSTR_ value.Damien George
2018-09-14examples/embedding: Fix reference to freed memory, lexer src name.Dave Hylands
This issue was brought up by BramPeters in the forum: https://forum.micropython.org/viewtopic.php?p=30066
2018-06-18examples/embedding: Add code markup and fix typo in README.md.Damien George
2018-02-23examples/embedding: Don't prefix $(MPTOP) to ports/unix source files.Damien George
Otherwise the build process puts the corresponding output object files in two directories lower, not in build/ports/unix.