Skip to content

Commit 5315348

Browse files
authored
Merge pull request #5425 from maholli/samd-sleep
functioning samd deep sleep ('alarm.time' & 'alarm.pin')
2 parents e049db7 + 339cf5e commit 5315348

File tree

25 files changed

+1092
-46
lines changed

25 files changed

+1092
-46
lines changed

locale/circuitpython.pot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,7 @@ msgstr ""
17271727
msgid "Only connectable advertisements can be directed"
17281728
msgstr ""
17291729

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

1754+
#: ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c
17531755
#: ports/espressif/common-hal/alarm/time/TimeAlarm.c
17541756
#: ports/nrf/common-hal/alarm/time/TimeAlarm.c
17551757
#: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c
@@ -2070,6 +2072,7 @@ msgstr ""
20702072
msgid "Size not supported"
20712073
msgstr ""
20722074

2075+
#: ports/atmel-samd/common-hal/alarm/SleepMemory.c
20732076
#: ports/raspberrypi/common-hal/alarm/SleepMemory.c
20742077
msgid "Sleep Memory not available"
20752078
msgstr ""
@@ -2224,6 +2227,7 @@ msgstr ""
22242227
msgid "Total data to write is larger than %q"
22252228
msgstr ""
22262229

2230+
#: ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c
22272231
#: ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c
22282232
#: ports/stm/common-hal/alarm/touch/TouchAlarm.c
22292233
msgid "Touch alarms not available"

ports/atmel-samd/boards/pycubed/board.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,12 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
28-
#include <string.h>
29-
3027
#include "supervisor/board.h"
31-
#include "py/mpconfig.h"
32-
#include "shared-bindings/nvm/ByteArray.h"
28+
#include "mpconfigboard.h"
3329
#include "common-hal/microcontroller/Pin.h"
3430
#include "hal/include/hal_gpio.h"
3531
#include "shared-bindings/pwmio/PWMOut.h"
3632

37-
nvm_bytearray_obj_t bootcnt = {
38-
.base = {
39-
.type = &nvm_bytearray_type
40-
},
41-
.len = (uint32_t)8192,
42-
.start_address = (uint8_t *)(0x00080000 - 8192)
43-
};
44-
45-
4633
void board_init(void) {
4734
pwmio_pwmout_obj_t pwm;
4835
common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
@@ -54,8 +41,7 @@ bool board_requests_safe_mode(void) {
5441
}
5542

5643
void reset_board(void) {
57-
uint8_t value_out = 0;
58-
common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out);
59-
++value_out;
60-
common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1);
44+
}
45+
46+
void board_deinit(void) {
6147
}

ports/atmel-samd/boards/pycubed/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// External flash W25Q80DV
1616
#define EXTERNAL_FLASH_QSPI_DUAL
1717

18+
#define CIRCUITPY_DRIVE_LABEL "PYCUBED"
19+
#define CIRCUITPY_BOOT_COUNTER 1
20+
1821
#define BOARD_HAS_CRYSTAL 1
1922

2023
#define DEFAULT_I2C_BUS_SCL (&pin_PB13)

ports/atmel-samd/boards/pycubed/mpconfigboard.mk

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = W25Q80DV
1111
LONGINT_IMPL = MPZ
1212

13-
CIRCUITPY_DRIVE_LABEL = "PYCUBED"
13+
CIRCUITPY_ULAB = 1
14+
CIRCUITPY_BINASCII = 1
15+
CIRCUITPY_SDCARDIO = 1
16+
CIRCUITPY_JSON = 1
17+
CIRCUITPY_MSGPACK = 1
18+
CIRCUITPY_ALARM = 1
1419

15-
# Not needed.
20+
# no SAMD51 support... yet ;)
21+
# CIRCUITPY_DUALBANK=1
22+
23+
# Not needed
1624
CIRCUITPY_AUDIOBUSIO = 0
17-
CIRCUITPY_BITMAPTOOLS = 0
1825
CIRCUITPY_DISPLAYIO = 0
1926
CIRCUITPY_FRAMEBUFFERIO = 0
2027
CIRCUITPY_KEYPAD = 0
2128
CIRCUITPY_RGBMATRIX = 0
2229
CIRCUITPY_PS2IO = 0
30+
CIRCUITPY_BLEIO_HCI=0
31+
CIRCUITPY_BLEIO=0
2332

2433
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
2534
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
26-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD

ports/atmel-samd/boards/pycubed_mram/board.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,12 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
28-
#include <string.h>
29-
3027
#include "supervisor/board.h"
31-
#include "py/mpconfig.h"
32-
#include "shared-bindings/nvm/ByteArray.h"
28+
#include "mpconfigboard.h"
3329
#include "common-hal/microcontroller/Pin.h"
3430
#include "hal/include/hal_gpio.h"
3531
#include "shared-bindings/pwmio/PWMOut.h"
3632

37-
nvm_bytearray_obj_t bootcnt = {
38-
.base = {
39-
.type = &nvm_bytearray_type
40-
},
41-
.len = (uint32_t)8192,
42-
.start_address = (uint8_t *)(0x00080000 - 8192)
43-
};
44-
45-
4633
void board_init(void) {
4734
pwmio_pwmout_obj_t pwm;
4835
common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
@@ -54,8 +41,7 @@ bool board_requests_safe_mode(void) {
5441
}
5542

5643
void reset_board(void) {
57-
uint8_t value_out = 0;
58-
common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out);
59-
++value_out;
60-
common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1);
44+
}
45+
46+
void board_deinit(void) {
6147
}

ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
1717

18+
#define CIRCUITPY_DRIVE_LABEL "PYCUBED"
19+
#define CIRCUITPY_BOOT_COUNTER 1
20+
1821
#define BOARD_HAS_CRYSTAL 1
1922

2023
#define DEFAULT_I2C_BUS_SCL (&pin_PB13)

ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = MR2xH40
1111
LONGINT_IMPL = MPZ
1212

13-
CIRCUITPY_DRIVE_LABEL = "PYCUBED"
13+
CIRCUITPY_ULAB = 1
14+
CIRCUITPY_BINASCII = 1
15+
CIRCUITPY_SDCARDIO = 1
16+
CIRCUITPY_JSON = 1
17+
CIRCUITPY_MSGPACK = 1
18+
CIRCUITPY_ALARM = 1
1419

15-
# Not needed.
20+
# no SAMD51 support... yet ;)
21+
# CIRCUITPY_DUALBANK=1
22+
23+
# Not needed
1624
CIRCUITPY_AUDIOBUSIO = 0
17-
CIRCUITPY_BITMAPTOOLS = 0
1825
CIRCUITPY_DISPLAYIO = 0
1926
CIRCUITPY_FRAMEBUFFERIO = 0
2027
CIRCUITPY_KEYPAD = 0
2128
CIRCUITPY_RGBMATRIX = 0
2229
CIRCUITPY_PS2IO = 0
30+
CIRCUITPY_BLEIO_HCI=0
31+
CIRCUITPY_BLEIO=0
2332

2433
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
2534
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
26-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD

ports/atmel-samd/boards/pycubed_mram_v05/board.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ bool board_requests_safe_mode(void) {
4242

4343
void reset_board(void) {
4444
}
45+
46+
void board_deinit(void) {
47+
}

ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ CIRCUITPY_BINASCII = 1
1515
CIRCUITPY_SDCARDIO = 1
1616
CIRCUITPY_JSON = 1
1717
CIRCUITPY_MSGPACK = 1
18+
CIRCUITPY_ALARM = 1
1819

1920
# no SAMD51 support... yet ;)
20-
# CIRCUITPY_ALARM = 1
2121
# CIRCUITPY_DUALBANK=1
2222

2323
# Not needed

ports/atmel-samd/boards/pycubed_v05/board.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ bool board_requests_safe_mode(void) {
4242

4343
void reset_board(void) {
4444
}
45+
46+
void board_deinit(void) {
47+
}

ports/atmel-samd/boards/pycubed_v05/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ CIRCUITPY_BINASCII = 1
1616
CIRCUITPY_SDCARDIO = 1
1717
CIRCUITPY_JSON = 1
1818
CIRCUITPY_MSGPACK = 1
19+
CIRCUITPY_ALARM = 1
1920

2021
# no SAMD51 support... yet ;)
21-
# CIRCUITPY_ALARM = 1
2222
# CIRCUITPY_DUALBANK=1
2323

2424
# Not needed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 Lucian Copeland for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <string.h>
28+
29+
#include "py/runtime.h"
30+
#include "common-hal/alarm/SleepMemory.h"
31+
#include "shared-bindings/nvm/ByteArray.h"
32+
33+
void alarm_sleep_memory_reset(void) {
34+
35+
}
36+
37+
uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) {
38+
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
39+
return 0;
40+
}
41+
42+
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) {
43+
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
44+
return false;
45+
}
46+
47+
void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) {
48+
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
49+
return;
50+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 Lucian Copeland for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H
28+
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H
29+
30+
#include "py/obj.h"
31+
32+
typedef struct {
33+
mp_obj_base_t base;
34+
uint8_t *start_address;
35+
uint8_t len;
36+
} alarm_sleep_memory_obj_t;
37+
38+
extern void alarm_sleep_memory_reset(void);
39+
40+
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H

0 commit comments

Comments
 (0)