aboutsummaryrefslogtreecommitdiff
path: root/atmel-samd/common-hal/microcontroller/__init__.c
diff options
context:
space:
mode:
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.