From 5b8cfb0b581533bf259ba0bb092579a53db641c9 Mon Sep 17 00:00:00 2001
From: Laurent Navet <laurent.navet@gmail.com>
Date: Sat, 10 Sep 2016 00:09:27 +0200
Subject: [PATCH] boards/arduino-common: use software interrupt for context
 swap

---
 boards/arduino-common/include/board.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/boards/arduino-common/include/board.h b/boards/arduino-common/include/board.h
index ea0b9d8403..fe84d1d286 100644
--- a/boards/arduino-common/include/board.h
+++ b/boards/arduino-common/include/board.h
@@ -53,6 +53,20 @@ extern "C" {
 #define LED0_TOGGLE         (PORTB ^=  LED0_MASK)
 /** @} */
 
+/**
+ ** Context swap defines
+ ** Setup to use PJ6 which is pin change interrupt 15 (PCINT15)
+ ** This emulates a software triggered interrupt
+ ***/
+#define AVR_CONTEXT_SWAP_INIT do { \
+            DDRC |= (1 << PC6); \
+            PCICR |= (1 << PCIE1); \
+            PCMSK1 |= (1 << PCINT14); \
+} while (0)
+#define AVR_CONTEXT_SWAP_INTERRUPT_VECT  PCINT1_vect
+#define AVR_CONTEXT_SWAP_TRIGGER   PORTC ^= (1 << PC6)
+
+
 /**
  * @brief xtimer configuration values
  * @{
-- 
GitLab