Skip to content

functioning samd deep sleep ('alarm.time' & 'alarm.pin') #5425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d536be7
working samd deep sleep timealarm and pinalarm (sketchy)
maholli Sep 29, 2021
cd28d50
Merge branch 'adafruit:main' into samd-sleep-v1
maholli Oct 1, 2021
79cd10a
cleaning up TimeAlarm and PinAlarm
maholli Oct 1, 2021
433a901
Merge branch 'adafruit:main' into samd-sleep-v1
maholli Oct 2, 2021
7a703aa
adding comments
maholli Oct 2, 2021
f748d66
Setup outline for SAMD alarm module
hierophect Jul 23, 2021
b95325e
Merge branch 'samd-sleep' into samd-sleep-v1
maholli Oct 3, 2021
9f0cb0e
Merge pull request #6 from maholli/samd-sleep-v1
maholli Oct 3, 2021
5ceb720
fixed c formating for pre-commit check
maholli Oct 4, 2021
6a8b4f5
fixed c formating
maholli Oct 4, 2021
2ff038f
fixing c formatting
maholli Oct 4, 2021
286b1a5
fixing radom changes (from cherry-pick?)
maholli Oct 4, 2021
0dd276b
c formatting
maholli Oct 4, 2021
6811c5e
c formatting...
maholli Oct 4, 2021
8486502
reworked fake sleep. functional for pin and time
maholli Oct 9, 2021
d66d7d4
Update ports/atmel-samd/mpconfigport.mk
maholli Oct 9, 2021
112739e
minor tweaks
maholli Oct 9, 2021
9e26820
re-adding samd messages
maholli Oct 9, 2021
238b07c
Fixed merge conflict for circuitpython.pot
maholli Oct 9, 2021
5a83581
Merge branch 'adafruit-main' into samd-sleep
maholli Oct 9, 2021
4f631f2
fixing nina-fw certs maybe?
maholli Oct 9, 2021
752bf6e
correcting which nina-fw commit to use
maholli Oct 9, 2021
dcb5fd2
alarm.wake_alarm works for pin and time. Pin & time can both be set a…
maholli Oct 10, 2021
e136cbd
forgot to commit port.c
maholli Oct 10, 2021
e7324fa
fixing pre-commit stuff
maholli Oct 10, 2021
5c4f903
rearranging port.c include order for common-hal/alarm
maholli Oct 11, 2021
37bddec
adding CIRCUITPY_ALARM checks to port.c
maholli Oct 11, 2021
7cbcc2f
updating pycubed board defs & including
maholli Oct 11, 2021
8811d22
Merge branch 'adafruit:main' into samd-sleep
maholli Oct 11, 2021
e74a8e3
Merge branch 'adafruit:main' into samd-sleep
maholli Oct 21, 2021
397b2f6
pin alarm configures pins again before deep sleep
maholli Oct 21, 2021
f7ba711
Merge branch 'adafruit:main' into samd-sleep
maholli Oct 22, 2021
943f2b2
remove interrupt_char.h
maholli Oct 23, 2021
e45fe3d
Merge branch 'adafruit:main' into samd-sleep
maholli Oct 24, 2021
339cf5e
staying caught up with runtime changes
maholli Oct 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,7 @@ msgstr ""
msgid "Only connectable advertisements can be directed"
msgstr ""

#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c
#: ports/stm/common-hal/alarm/pin/PinAlarm.c
msgid "Only edge detection is available on this hardware"
msgstr ""
Expand All @@ -1750,6 +1751,7 @@ msgstr ""
msgid "Only one address is allowed"
msgstr ""

#: ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c
#: ports/espressif/common-hal/alarm/time/TimeAlarm.c
#: ports/nrf/common-hal/alarm/time/TimeAlarm.c
#: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c
Expand Down Expand Up @@ -2070,6 +2072,7 @@ msgstr ""
msgid "Size not supported"
msgstr ""

#: ports/atmel-samd/common-hal/alarm/SleepMemory.c
#: ports/raspberrypi/common-hal/alarm/SleepMemory.c
msgid "Sleep Memory not available"
msgstr ""
Expand Down Expand Up @@ -2224,6 +2227,7 @@ msgstr ""
msgid "Total data to write is larger than %q"
msgstr ""

#: ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c
#: ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c
#: ports/stm/common-hal/alarm/touch/TouchAlarm.c
msgid "Touch alarms not available"
Expand Down
22 changes: 4 additions & 18 deletions ports/atmel-samd/boards/pycubed/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,12 @@
* THE SOFTWARE.
*/


#include <string.h>

#include "supervisor/board.h"
#include "py/mpconfig.h"
#include "shared-bindings/nvm/ByteArray.h"
#include "mpconfigboard.h"
#include "common-hal/microcontroller/Pin.h"
#include "hal/include/hal_gpio.h"
#include "shared-bindings/pwmio/PWMOut.h"

nvm_bytearray_obj_t bootcnt = {
.base = {
.type = &nvm_bytearray_type
},
.len = (uint32_t)8192,
.start_address = (uint8_t *)(0x00080000 - 8192)
};


void board_init(void) {
pwmio_pwmout_obj_t pwm;
common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
Expand All @@ -54,8 +41,7 @@ bool board_requests_safe_mode(void) {
}

void reset_board(void) {
uint8_t value_out = 0;
common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out);
++value_out;
common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1);
}

void board_deinit(void) {
}
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/pycubed/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// External flash W25Q80DV
#define EXTERNAL_FLASH_QSPI_DUAL

#define CIRCUITPY_DRIVE_LABEL "PYCUBED"
#define CIRCUITPY_BOOT_COUNTER 1

#define BOARD_HAS_CRYSTAL 1

#define DEFAULT_I2C_BUS_SCL (&pin_PB13)
Expand Down
16 changes: 12 additions & 4 deletions ports/atmel-samd/boards/pycubed/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICES = W25Q80DV
LONGINT_IMPL = MPZ

CIRCUITPY_DRIVE_LABEL = "PYCUBED"
CIRCUITPY_ULAB = 1
CIRCUITPY_BINASCII = 1
CIRCUITPY_SDCARDIO = 1
CIRCUITPY_JSON = 1
CIRCUITPY_MSGPACK = 1
CIRCUITPY_ALARM = 1

# Not needed.
# no SAMD51 support... yet ;)
# CIRCUITPY_DUALBANK=1

# Not needed
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BITMAPTOOLS = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_KEYPAD = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_BLEIO_HCI=0
CIRCUITPY_BLEIO=0

FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD
22 changes: 4 additions & 18 deletions ports/atmel-samd/boards/pycubed_mram/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,12 @@
* THE SOFTWARE.
*/


#include <string.h>

#include "supervisor/board.h"
#include "py/mpconfig.h"
#include "shared-bindings/nvm/ByteArray.h"
#include "mpconfigboard.h"
#include "common-hal/microcontroller/Pin.h"
#include "hal/include/hal_gpio.h"
#include "shared-bindings/pwmio/PWMOut.h"

nvm_bytearray_obj_t bootcnt = {
.base = {
.type = &nvm_bytearray_type
},
.len = (uint32_t)8192,
.start_address = (uint8_t *)(0x00080000 - 8192)
};


void board_init(void) {
pwmio_pwmout_obj_t pwm;
common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
Expand All @@ -54,8 +41,7 @@ bool board_requests_safe_mode(void) {
}

void reset_board(void) {
uint8_t value_out = 0;
common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out);
++value_out;
common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1);
}

void board_deinit(void) {
}
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)

#define CIRCUITPY_DRIVE_LABEL "PYCUBED"
#define CIRCUITPY_BOOT_COUNTER 1

#define BOARD_HAS_CRYSTAL 1

#define DEFAULT_I2C_BUS_SCL (&pin_PB13)
Expand Down
16 changes: 12 additions & 4 deletions ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICES = MR2xH40
LONGINT_IMPL = MPZ

CIRCUITPY_DRIVE_LABEL = "PYCUBED"
CIRCUITPY_ULAB = 1
CIRCUITPY_BINASCII = 1
CIRCUITPY_SDCARDIO = 1
CIRCUITPY_JSON = 1
CIRCUITPY_MSGPACK = 1
CIRCUITPY_ALARM = 1

# Not needed.
# no SAMD51 support... yet ;)
# CIRCUITPY_DUALBANK=1

# Not needed
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BITMAPTOOLS = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_KEYPAD = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_BLEIO_HCI=0
CIRCUITPY_BLEIO=0

FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/pycubed_mram_v05/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ bool board_requests_safe_mode(void) {

void reset_board(void) {
}

void board_deinit(void) {
}
2 changes: 1 addition & 1 deletion ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ CIRCUITPY_BINASCII = 1
CIRCUITPY_SDCARDIO = 1
CIRCUITPY_JSON = 1
CIRCUITPY_MSGPACK = 1
CIRCUITPY_ALARM = 1

# no SAMD51 support... yet ;)
# CIRCUITPY_ALARM = 1
# CIRCUITPY_DUALBANK=1

# Not needed
Expand Down
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/pycubed_v05/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ bool board_requests_safe_mode(void) {

void reset_board(void) {
}

void board_deinit(void) {
}
2 changes: 1 addition & 1 deletion ports/atmel-samd/boards/pycubed_v05/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ CIRCUITPY_BINASCII = 1
CIRCUITPY_SDCARDIO = 1
CIRCUITPY_JSON = 1
CIRCUITPY_MSGPACK = 1
CIRCUITPY_ALARM = 1

# no SAMD51 support... yet ;)
# CIRCUITPY_ALARM = 1
# CIRCUITPY_DUALBANK=1

# Not needed
Expand Down
50 changes: 50 additions & 0 deletions ports/atmel-samd/common-hal/alarm/SleepMemory.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Lucian Copeland 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 <string.h>

#include "py/runtime.h"
#include "common-hal/alarm/SleepMemory.h"
#include "shared-bindings/nvm/ByteArray.h"

void alarm_sleep_memory_reset(void) {

}

uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) {
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return 0;
}

bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t *values, uint32_t len) {
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return false;
}

void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) {
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return;
}
40 changes: 40 additions & 0 deletions ports/atmel-samd/common-hal/alarm/SleepMemory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 Lucian Copeland 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.
*/

#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H

#include "py/obj.h"

typedef struct {
mp_obj_base_t base;
uint8_t *start_address;
uint8_t len;
} alarm_sleep_memory_obj_t;

extern void alarm_sleep_memory_reset(void);

#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H
Loading