Commit Graph

472 Commits

Author SHA1 Message Date
Dan Halbert ded134c346 store wake_alarm in a static object 2022-10-29 16:26:36 -04:00
Dan Halbert 9307b62ad5 wip 2022-10-27 22:42:04 -04:00
microDev b33a2b45dc
add coproc alarm 2022-10-20 18:38:20 +05:30
Jeff Epler f7d39ceae4
comment on the revised algorithm 2022-10-12 16:25:09 -05:00
Jeff Epler a943167d69
samd: Reduce a further 48 bytes for non-full builds
Another reduction of -48 bytes can be had if the fine calculation
step is skipped. The worst difference compared to the old reference
code with my calibration values in the 0° to 60° was 2°C,
and the difference at 25°C is 1°C.

The final size decrease for non-full builds like Trinket M0 is 268
bytes.
2022-10-12 15:53:44 -05:00
Jeff Epler b251e78ac5
samd: size-optimize microcontroller temp calc
Perform most arithmetic with scaled integer values.
For my calibration values
```
const uint32_t NVMCTRL_TEMP_LOG[]={0xfc05511e, 0xcc7ac0f7};
```
the maximum difference between the old and new calculation is 0.50°C.
The difference is smallest (0.13°) at 25.87°C in the old scale.

This reduces mcu_processor_get_temperature from 568 bytes to 348 bytes
(-220 bytes)
2022-10-12 15:44:14 -05:00
Dan Halbert 86a0f9a861 save about 112 bytes 2022-10-09 19:22:39 -04:00
Dan Halbert 90f6096955 fix ai-thinker creation ids; fix some typos elsewhere 2022-10-03 15:29:03 -04:00
Jeff Epler 346fff2e7c
cyw43 basic gpio support, hwaddr in boot_out 2022-09-28 10:06:33 -05:00
Dan Halbert 60f43b1703 allow preserving pin state during deep sleep 2022-09-15 17:35:14 -04:00
Dan Halbert 84807cd6eb Change I2C terminology from "peripheral" to "target" 2022-08-09 13:13:19 -04:00
Dan Halbert 9baa2724a7 code formatting suggestion 2022-08-01 00:27:25 -04:00
Dan Halbert 1348cb435b Fix SAMD I2C frequency check 2022-07-29 19:07:33 -04:00
Scott Shawcroft 6d3698848c
Fix PDMIn.c formatting 2022-06-01 11:04:33 -07:00
Scott Shawcroft 9d10a3da66
Conditionalize LTO 2022-05-27 12:59:54 -07:00
George White 8539d6518e flip CTS and RTS pinmux to match RX and TX 2022-05-26 00:06:00 +00:00
George White 99b23b96d9 fix comment typo and mention datasheet 2022-05-26 00:03:46 +00:00
George White fb3077ccc2 Implement UART hardware flow control on SAMD chips 2022-05-25 21:34:06 +00:00
Paint Your Dragon eefba16644
Correctly scale analog reading per issue #4794 2022-05-24 08:40:51 -07:00
Dan Halbert f63b26c534 address jepler's comments and further squeezes 2022-05-20 10:10:55 -04:00
Dan Halbert a01dec1df9 message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
Michael Wisslead e63a327107 Bound PulseIn start indexes to maxlen. 2022-04-28 02:28:34 +00:00
Dan Halbert 6b25ccf1a4 remove stray space 2022-04-26 14:26:42 -04:00
Dan Halbert 63abd9a9cf
Merge pull request #6312 from dhalbert/adjust-neopixel-timings
test and adjust NeoPixel timings on multiple ports
2022-04-26 13:18:47 -04:00
Dan Halbert 4eeaf41edc test and adjust NeoPixel timings on multiple products 2022-04-25 23:12:24 -04:00
Jeff Epler f7be4345d9
Merge remote-tracking branch 'origin/main' into floppy 2022-04-07 08:37:46 -05:00
Radomir Dopieralski b69a06b2ed Also fix the read pin in the atmel and rp2040 ports 2022-03-06 11:33:07 +01:00
Tsutomu IKEGAMI 6499d18bb8 Remove board_deep_sleep_hook, which should be done in board_deinit. 2022-02-21 19:21:42 +09:00
Tsutomu IKEGAMI bd9dd3dc63 Fix atmel-samd alarm module. 2022-02-17 23:00:26 +09:00
Scott Gauche a8d8651873 Canonical C style for half_duplex = true/false 2022-02-08 23:13:22 -05:00
Scott Gauche 89ad767b8f add half_duplex to spi constructs in other ports but raise not implemented errors 2022-02-08 22:25:23 -05:00
Jeff Epler 07e710b0a0
Merge remote-tracking branch 'origin/main' into floppy 2022-02-04 09:01:36 -06:00
Dan Halbert cc410ad6a3 common-hal I2C combined write_read 2022-01-31 22:03:30 -05:00
Scott Shawcroft 13db65566d
ESP NeoPixel fixes
This tweaks the RMT timing to better match the 1/3 and 2/3 of 800khz
guideline for timing. It also ensures a delay of 300 microseconds
with the line low before reset.

Pin reset is now changed to the IDF default which pulls the pin up
rather than CircuitPython's old behavior of floating the pin.

Fixes #5679
2022-01-19 16:29:07 -08:00
Jeff Epler d816a4f19d
Add floppyio
Initially enabled for samd51, this enables reading raw flux data as well
as DOS/MFM formatted media.

This is only the low-level code for reading & decoding flux pulses from a floppy drive.
high level details will live in a Python library.

adafruit-circuitpython-floppy will take care of details like stepping
from track to track, etc.
2022-01-13 15:37:36 -06:00
Jeff Epler db5f99c63e
Add a function to get low level register access
The port is free to return NULL for any/all of these, and the caller has
to check.

This will be used in the floppy code, because aside from getting the
registers, it looks like all is independent of MCU.
2022-01-13 15:29:03 -06:00
Dan Halbert dd54e8f657 PDMIn: enable IRQ; need a volatile; call pdmin_reset()
enable IRQ for PDMIn
2022-01-12 11:44:43 -05:00
Dan Halbert 9d2a32d07e countio: add selectable rise and fall detection, pulls 2021-12-31 16:34:58 -05:00
Dan Halbert bbe30514ef Fix other INTENCLR and INTENSET to write whole reg 2021-12-12 22:25:44 -05:00
Dan Halbert c06eee9841 Clear TAMPER interrupt properly; make keypad module table const 2021-12-12 22:00:08 -05:00
Dan Halbert e0e3224253 forgot a check for BOARD_HAS_CRYSTAL 2021-12-07 15:42:31 -05:00
Dan Halbert 7e21344cf0 fix FrequencyIn for crystalless boards and simplify clock logic 2021-12-07 13:12:24 -05:00
Dan Halbert 92bb909bf0 add a frequencyin_reset() for VM restart 2021-12-05 17:06:42 -05:00
Dan Halbert e8ea9c75a1 check for missing pins; deinit txrx leds 2021-11-30 19:16:21 -05:00
Timon a1052d5f73
Initial broadcom port for Raspberry Pi
This targets the 64-bit CPU Raspberry Pis. The BCM2711 on the Pi 4
and the BCM2837 on the Pi 3 and Zero 2W. There are 64-bit fixes
outside of the ports directory for it.

There are a couple other cleanups that were incidental:
* Use const mcu_pin_obj_t instead of omitting the const. The structs
  themselves are const because they are in ROM.
* Use PTR <-> OBJ conversions in more places. They were found when
  mp_obj_t was set to an integer type rather than pointer.
* Optimize submodule checkout because the Pi submodules are heavy
  and unnecessary for the vast majority of builds.

Fixes #4314
2021-11-22 14:54:44 -08:00
Jeff Epler cd6599ce65
A few more missing-prototypes fixes 2021-11-11 08:42:30 -06:00
Jeff Epler 340d6b9213
more missing-prototypes fixes 2021-11-10 21:00:17 -06:00
Jeff Epler 621953c960
Additional missing-prototypes fixes
I think this correctly enables missing-prototypes in atmel-samd
and raspberrypi ports.
2021-11-10 10:55:53 -06:00
Jeff Epler 43b593725b atmel-samd: Fix converting watchdog seconds to cycles
It's intended that the actual timeout always be at least the requested
timeout.  However, due to multiplying by the wrong factor to get from
seconds to cycles, a timeout request of e.g., 8.1s (which is less than
8.192s) would give an actual timeout of 8, not 16 as it should.
2021-11-05 11:40:08 -05:00
Jeff Epler a8614a61dc ParallelImageCapture: Add continuous capture on espressif
By having a pair of buffers, the capture hardware can fill one buffer while
Python code (including displayio, etc) operates on the other buffer.  This
increases the responsiveness of camera-using code.

On the Kaluga it makes the following improvements:
 * 320x240 viewfinder at 30fps instead of 15fps using directio
 * 240x240 animated gif capture at 10fps instead of 7.5fps

As discussed at length on Discord, the "usual end user" code will look like
this:

    camera = ...

    with camera.continuous_capture(buffer1, buffer2) as capture:
        for frame in capture:
            # Do something with frame

However, rather than presenting a context manager, the core code consists of
three new functions to start & stop continuous capture, and to get the next
frame.  The reason is twofold.  First, it's simply easier to implement the
context manager object in pure Python.  Second, for more advanced usage, the
context manager may be too limiting, and it's easier to iterate on the right
design in Python code.  In particular, I noticed that adapting the
JPEG-capturing programs to use continuous capture mode needed a change in
program structure.

The camera app was structured as
```python
while True:
    if shutter button was just pressed:
        capture a jpeg frame
    else:
        update the viewfinder
```

However, "capture a jpeg frame" needs to (A) switch the camera settings and (B)
capture into a different, larger buffer then (C) return to the earlier
settings. This can't be done during continuous capture mode. So just
restructuring it as follows isn't going to work:

```python
with camera.continuous_capture(buffer1, buffer2) as capture:
    for frame in capture:
        if shutter button was just pressed:
            capture a jpeg frame, without disturbing continuous capture mode
        else:
            update the viewfinder
```

The continuous mode is only implemented in the espressif port; others
will throw an exception if the associated methods are invoked.  It's not
impossible to implement there, just not a priority, since these micros don't
have enough RAM for two framebuffer copies at any resonable sizes.

The capture code, including single-shot capture, now take mp_obj_t in the
common-hal layer, instead of a buffer & length.  This was done for the
continuous capture mode because it has to identify & return to the user the
proper Python object representing the original buffer.  In the Espressif port,
it was convenient to implement single capture in terms of a multi-capture,
which is why I changed the singleshot routine's signature too.
2021-11-03 11:02:46 -05:00