summaryrefslogtreecommitdiffstats
path: root/platforms/arm_atsam
diff options
context:
space:
mode:
Diffstat (limited to 'platforms/arm_atsam')
-rw-r--r--platforms/arm_atsam/bootloaders/md_boot.c (renamed from platforms/arm_atsam/bootloader.c)38
-rw-r--r--platforms/arm_atsam/eeprom_samd.c (renamed from platforms/arm_atsam/eeprom.c)6
-rwxr-xr-xplatforms/arm_atsam/eeprom_samd.h8
-rw-r--r--platforms/arm_atsam/gpio.h12
-rw-r--r--platforms/arm_atsam/suspend.c43
5 files changed, 40 insertions, 67 deletions
diff --git a/platforms/arm_atsam/bootloader.c b/platforms/arm_atsam/bootloaders/md_boot.c
index 9015b00aab..9cf16f3597 100644
--- a/platforms/arm_atsam/bootloader.c
+++ b/platforms/arm_atsam/bootloaders/md_boot.c
@@ -15,13 +15,17 @@
*/
#include "bootloader.h"
+
#include "samd51j18a.h"
-#include "md_bootloader.h"
-// Set watchdog timer to reset. Directs the bootloader to stay in programming mode.
+// WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support
+extern uint32_t _eram;
+#define BOOTLOADER_MAGIC 0x3B9ACA00
+#define MAGIC_ADDR (uint32_t *)((intptr_t)(&_eram) - 4)
+
+// CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method.
void bootloader_jump(void) {
#ifdef KEYBOARD_massdrop_ctrl
- // CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method.
uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; // The version to match (NULL terminated by compiler)
uint8_t *ver_check = ver_ram_method; // Pointer to version match string for traversal
uint8_t *ver_rom = (uint8_t *)0x21A0; // Pointer to address in ROM where this specific bootloader version would exist
@@ -34,24 +38,28 @@ void bootloader_jump(void) {
if (!*ver_check) { // If check version pointer is NULL, all characters have matched
*MAGIC_ADDR = BOOTLOADER_MAGIC; // Set magic number into RAM
NVIC_SystemReset(); // Perform system reset
- while (1) {
- } // Won't get here
+ while (1)
+ ; // Won't get here
}
#endif
+ // Set watchdog timer to reset. Directs the bootloader to stay in programming mode.
WDT->CTRLA.bit.ENABLE = 0;
- while (WDT->SYNCBUSY.bit.ENABLE) {
- }
- while (WDT->CTRLA.bit.ENABLE) {
- }
+
+ while (WDT->SYNCBUSY.bit.ENABLE)
+ ;
+ while (WDT->CTRLA.bit.ENABLE)
+ ;
+
WDT->CONFIG.bit.WINDOW = 0;
WDT->CONFIG.bit.PER = 0;
WDT->EWCTRL.bit.EWOFFSET = 0;
WDT->CTRLA.bit.ENABLE = 1;
- while (WDT->SYNCBUSY.bit.ENABLE) {
- }
- while (!WDT->CTRLA.bit.ENABLE) {
- }
- while (1) {
- } // Wait on timeout
+
+ while (WDT->SYNCBUSY.bit.ENABLE)
+ ;
+ while (!WDT->CTRLA.bit.ENABLE)
+ ;
+ while (1)
+ ; // Wait on timeout
}
diff --git a/platforms/arm_atsam/eeprom.c b/platforms/arm_atsam/eeprom_samd.c
index ff1a692623..beaffeec30 100644
--- a/platforms/arm_atsam/eeprom.c
+++ b/platforms/arm_atsam/eeprom_samd.c
@@ -18,11 +18,7 @@
#include "samd51j18a.h"
#include "core_cm4.h"
#include "component/nvmctrl.h"
-
-#ifndef EEPROM_SIZE
-# include "eeconfig.h"
-# define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
-#endif
+#include "eeprom_samd.h"
#ifndef MAX
# define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
diff --git a/platforms/arm_atsam/eeprom_samd.h b/platforms/arm_atsam/eeprom_samd.h
new file mode 100755
index 0000000000..7dbff9bfa1
--- /dev/null
+++ b/platforms/arm_atsam/eeprom_samd.h
@@ -0,0 +1,8 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifndef EEPROM_SIZE
+# include "eeconfig.h"
+# define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
+#endif
diff --git a/platforms/arm_atsam/gpio.h b/platforms/arm_atsam/gpio.h
index 915ed0ef4f..a42aaff54d 100644
--- a/platforms/arm_atsam/gpio.h
+++ b/platforms/arm_atsam/gpio.h
@@ -22,9 +22,9 @@
typedef uint8_t pin_t;
-#define SAMD_PORT(pin) ((pin & 0x20) >> 5)
-#define SAMD_PIN(pin) (pin & 0x1f)
-#define SAMD_PIN_MASK(pin) (1 << (pin & 0x1f))
+#define SAMD_PORT(pin) (((pin)&0x20) >> 5)
+#define SAMD_PIN(pin) ((pin)&0x1f)
+#define SAMD_PIN_MASK(pin) (1 << ((pin)&0x1f))
#define setPinInput(pin) \
do { \
@@ -48,12 +48,16 @@ typedef uint8_t pin_t;
PORT->Group[SAMD_PORT(pin)].PINCFG[SAMD_PIN(pin)].bit.PULLEN = 1; \
} while (0)
-#define setPinOutput(pin) \
+#define setPinOutputPushPull(pin) \
do { \
PORT->Group[SAMD_PORT(pin)].DIRSET.reg = SAMD_PIN_MASK(pin); \
PORT->Group[SAMD_PORT(pin)].OUTCLR.reg = SAMD_PIN_MASK(pin); \
} while (0)
+#define setPinOutputOpenDrain(pin) _Static_assert(0, "arm_atsam platform does not implement an open-drain output")
+
+#define setPinOutput(pin) setPinOutputPushPull(pin)
+
#define writePinHigh(pin) \
do { \
PORT->Group[SAMD_PORT(pin)].OUTSET.reg = SAMD_PIN_MASK(pin); \
diff --git a/platforms/arm_atsam/suspend.c b/platforms/arm_atsam/suspend.c
index e51426128d..de2285bc5f 100644
--- a/platforms/arm_atsam/suspend.c
+++ b/platforms/arm_atsam/suspend.c
@@ -3,25 +3,6 @@
#include "md_rgb_matrix.h"
#include "suspend.h"
-/** \brief Suspend idle
- *
- * FIXME: needs doc
- */
-void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */
-}
-
-/** \brief Run user level Power down
- *
- * FIXME: needs doc
- */
-__attribute__((weak)) void suspend_power_down_user(void) {}
-
-/** \brief Run keyboard level Power down
- *
- * FIXME: needs doc
- */
-__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
-
/** \brief Suspend power down
*
* FIXME: needs doc
@@ -34,30 +15,6 @@ void suspend_power_down(void) {
suspend_power_down_kb();
}
-__attribute__((weak)) void matrix_power_up(void) {}
-__attribute__((weak)) void matrix_power_down(void) {}
-bool suspend_wakeup_condition(void) {
- matrix_power_up();
- matrix_scan();
- matrix_power_down();
- for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
- if (matrix_get_row(r)) return true;
- }
- return false;
-}
-
-/** \brief run user level code immediately after wakeup
- *
- * FIXME: needs doc
- */
-__attribute__((weak)) void suspend_wakeup_init_user(void) {}
-
-/** \brief run keyboard level code immediately after wakeup
- *
- * FIXME: needs doc
- */
-__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
-
/** \brief run immediately after wakeup
*
* FIXME: needs doc