aboutsummaryrefslogtreecommitdiff
path: root/atmel-samd/common-hal/microcontroller/__init__.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2017-09-22 18:05:51 -0700
committerDan Halbert <halbert@halwitz.org>2017-09-22 21:05:51 -0400
commit6839fff31303463d5c7942387fa498895edf1abf (patch)
treef4c5b94c6534c8d5c65ea6b7209cd2d681508f5f /atmel-samd/common-hal/microcontroller/__init__.c
parent3ad01ddb04b160b74b4baee9fce043da17dbcef5 (diff)
Move to ASF4 and introduce SAMD51 support. (#258)3.0.0-alpha.0
* atmel-samd: Remove ASF3. This will break builds. * atmel-samd: Add ASF4 for the SAMD21 and SAMD51. * Introduce the supervisor concept to facilitate porting. The supervisor is the code which runs individual MicroPython VMs. By splitting it out we make it more consistent and easier to find. This also adds very basic SAMD21 and SAMD51 support using the supervisor. Only the REPL currently works. This begins the work for #178.
Diffstat (limited to 'atmel-samd/common-hal/microcontroller/__init__.c')
-rw-r--r--atmel-samd/common-hal/microcontroller/__init__.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/atmel-samd/common-hal/microcontroller/__init__.c b/atmel-samd/common-hal/microcontroller/__init__.c
index 84cea008b..5c119c439 100644
--- a/atmel-samd/common-hal/microcontroller/__init__.c
+++ b/atmel-samd/common-hal/microcontroller/__init__.c
@@ -26,6 +26,7 @@
#include "py/mphal.h"
#include "py/obj.h"
+#include "hal/include/hal_atomic.h"
#include "samd21_pins.h"
@@ -38,17 +39,13 @@ void common_hal_mcu_delay_us(uint32_t delay) {
// Interrupt flags that will be saved and restored during disable/Enable
// interrupt functions below.
-static irqflags_t irq_flags;
+volatile hal_atomic_t flags;
void common_hal_mcu_disable_interrupts(void) {
- // Disable all interrupt sources for timing critical sections.
- // Disable ASF-based interrupts.
- irq_flags = cpu_irq_save();
+ atomic_enter_critical(&flags);
}
void common_hal_mcu_enable_interrupts(void) {
- // Enable all interrupt sources after timing critical sections.
- // Restore ASF-based interrupts.
- cpu_irq_restore(irq_flags);
+ atomic_leave_critical(&flags);
}
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
@@ -62,13 +59,13 @@ mcu_processor_obj_t common_hal_mcu_processor_obj = {
// NVM is only available on Express boards for now.
#if CIRCUITPY_INTERNAL_NVM_SIZE > 0
// The singleton nvm.ByteArray object.
-nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
- .base = {
- .type = &nvm_bytearray_type,
- },
- .len = NVMCTRL_ROW_SIZE,
- .start_address = (uint8_t*) (FLASH_SIZE - NVMCTRL_ROW_SIZE)
-};
+// nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
+// .base = {
+// .type = &nvm_bytearray_type,
+// },
+// .len = NVMCTRL_ROW_SIZE,
+// .start_address = (uint8_t*) (FLASH_SIZE - NVMCTRL_ROW_SIZE)
+// };
#endif
// This maps MCU pin names to pin objects.