diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2020-04-30 15:24:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-30 15:24:03 -0700 |
| commit | b3b6a64ed7fb10ffb61bc1b71ba4083bca3ada30 (patch) | |
| tree | 706a8a6007251af6eb996a710423c8cf4de1480c /shared-module | |
| parent | 10c5bf666e09226817a70651b1bf8c4e55c6e36e (diff) | |
| parent | a863b0a3490c55b0e7e1321d9ac9cf249a6addd5 (diff) | |
Merge pull request #2685 from tannewt/lower_power
Lower power by using the Wait for Interrupt (WFI) instruction
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/displayio/Display.c | 2 | ||||
| -rw-r--r-- | shared-module/displayio/EPaperDisplay.c | 2 | ||||
| -rw-r--r-- | shared-module/displayio/FourWire.c | 2 | ||||
| -rw-r--r-- | shared-module/displayio/I2CDisplay.c | 2 | ||||
| -rw-r--r-- | shared-module/displayio/display_core.c | 2 | ||||
| -rw-r--r-- | shared-module/framebufferio/FramebufferDisplay.c | 2 | ||||
| -rw-r--r-- | shared-module/time/__init__.c | 45 | ||||
| -rw-r--r-- | shared-module/usb_hid/Device.c | 2 |
8 files changed, 46 insertions, 13 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index aaddbb471..da5713f8c 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -41,8 +41,6 @@ #include <stdint.h> #include <string.h> -#include "tick.h" - void common_hal_displayio_display_construct(displayio_display_obj_t* self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 5b4a8f916..6a55687b9 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -42,8 +42,6 @@ #include <stdint.h> #include <string.h> -#include "tick.h" - void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t* self, mp_obj_t bus, uint8_t* start_sequence, uint16_t start_sequence_len, uint8_t* stop_sequence, uint16_t stop_sequence_len, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c index fe7234aa7..17e8cfa1d 100644 --- a/shared-module/displayio/FourWire.c +++ b/shared-module/displayio/FourWire.c @@ -36,8 +36,6 @@ #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/display_core.h" -#include "tick.h" - void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self, busio_spi_obj_t* spi, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* reset, uint32_t baudrate, diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/displayio/I2CDisplay.c index 280476f19..0c8f2e69a 100644 --- a/shared-module/displayio/I2CDisplay.c +++ b/shared-module/displayio/I2CDisplay.c @@ -38,8 +38,6 @@ #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/display_core.h" -#include "tick.h" - void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self, busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset) { diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 4cc7564d0..d01100f7f 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -40,8 +40,6 @@ #include <stdint.h> #include <string.h> -#include "tick.h" - void displayio_display_core_construct(displayio_display_core_t* self, mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word) { diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c index 13fbb2629..2a88b5307 100644 --- a/shared-module/framebufferio/FramebufferDisplay.c +++ b/shared-module/framebufferio/FramebufferDisplay.c @@ -40,8 +40,6 @@ #include <stdint.h> #include <string.h> -#include "tick.h" - void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t* self, mp_obj_t framebuffer, uint16_t rotation, diff --git a/shared-module/time/__init__.c b/shared-module/time/__init__.c new file mode 100644 index 000000000..347e68ae0 --- /dev/null +++ b/shared-module/time/__init__.c @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/mphal.h" +#include "supervisor/port.h" +#include "supervisor/shared/tick.h" + +uint64_t common_hal_time_monotonic(void) { + return supervisor_ticks_ms64(); +} + +uint64_t common_hal_time_monotonic_ns(void) { + uint8_t subticks = 0; + uint64_t ticks = port_get_raw_ticks(&subticks); + // A tick is 976562.5 nanoseconds so multiply it by the base and add half instead of doing float + // math. + return 976562 * ticks + ticks / 2 + 30518 * subticks; +} + +void common_hal_time_delay_ms(uint32_t delay) { + mp_hal_delay_ms(delay); +} diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 8744f2ed3..8e9df6f04 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -25,7 +25,7 @@ */ #include <string.h> -#include "tick.h" + #include "py/runtime.h" #include "shared-bindings/usb_hid/Device.h" #include "shared-module/usb_hid/Device.h" |
