From 2ca5c57f368104b0112035403e52710504d63040 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Fri, 26 Jun 2020 13:51:36 -0600 Subject: [PATCH 01/10] Create keywords.txt --- keywords.txt | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 keywords.txt diff --git a/keywords.txt b/keywords.txt new file mode 100644 index 00000000..b4bd5ad9 --- /dev/null +++ b/keywords.txt @@ -0,0 +1,39 @@ +####################################### +# Syntax Coloring Map For Wire +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +enableBurstMode KEYWORD2 +disableBurstMode KEYWORD2 +getCpuFreqMHz KEYWORD2 + +getInternalTemp KEYWORD2 + +analogWriteResolution KEYWORD2 +analogWriteFrameWidth KEYWORD2 +analogWriteFrequency KEYWORD2 +servoWrite KEYWORD2 + +enableFastShift KEYWORD2 +fastShiftOut KEYWORD2 +fastShiftIn KEYWORD2 + +secs KEYWORD2 +systicks KEYWORD2 +sysoverflows KEYWORD2 + +####################################### +# Instances (KEYWORD2) +####################################### + +####################################### +# Constants (LITERAL1) +####################################### + From 9072743637d085c4f272d17cf83377aeb49fa1a5 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Fri, 10 Jul 2020 16:19:03 -0600 Subject: [PATCH 02/10] Correct typo in HAL --- cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h b/cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h index 6e515f57..4bb78a8e 100644 --- a/cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h +++ b/cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h @@ -172,8 +172,8 @@ am_hal_uart_transfer_t; // Flow control #define AM_HAL_UART_FLOW_CTRL_NONE 0 -#define AM_HAL_UART_FLOW_CTRL_CTS_ONLY UART_CR_CTSEN_Msk -#define AM_HAL_UART_FLOW_CTRL_RTS_ONLY UART_CR_RTSEN_Msk +#define AM_HAL_UART_FLOW_CTRL_CTS_ONLY UART0_CR_CTSEN_Msk +#define AM_HAL_UART_FLOW_CTRL_RTS_ONLY UART0_CR_RTSEN_Msk #define AM_HAL_UART_FLOW_CTRL_RTS_CTS (UART0_CR_CTSEN_Msk | \ UART0_CR_RTSEN_Msk) // FIFO enable/disable. From ddda09eda92c339e8e6c0737cefaf4ab0d1ffbec Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Fri, 10 Jul 2020 16:19:39 -0600 Subject: [PATCH 03/10] Add checking of RTS/CTS pins to enable flow control. Fix typo in _begin(). --- cores/arduino/ard_sup/uart/ap3_uart.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cores/arduino/ard_sup/uart/ap3_uart.cpp b/cores/arduino/ard_sup/uart/ap3_uart.cpp index 0724371a..2ba32cd5 100644 --- a/cores/arduino/ard_sup/uart/ap3_uart.cpp +++ b/cores/arduino/ard_sup/uart/ap3_uart.cpp @@ -296,6 +296,22 @@ ap3_err_t Uart::set_config(HardwareSerial_Config_e HWSconfig) retval = AP3_INVALID_ARG; break; } + + //Setup flow control + _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_NONE; + if(_pinRTS != AP3_UART_PIN_UNUSED && _pinCTS != AP3_UART_PIN_UNUSED) + { + _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_RTS_CTS; + } + else if(_pinRTS != AP3_UART_PIN_UNUSED) + { + _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_RTS_ONLY; + } + else if(_pinCTS != AP3_UART_PIN_UNUSED) + { + _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_CTS_ONLY; + } + return retval; } @@ -375,7 +391,7 @@ ap3_err_t Uart::_begin(void) if (_pinRTS != AP3_UART_PIN_UNUSED) { - retval = ap3_uart_pad_funcsel(_instance, AP3_UART_TX, ap3_gpio_pin2pad(_pinRTS), &funcsel); + retval = ap3_uart_pad_funcsel(_instance, AP3_UART_RTS, ap3_gpio_pin2pad(_pinRTS), &funcsel); if (retval != AP3_OK) { return retval; @@ -391,7 +407,7 @@ ap3_err_t Uart::_begin(void) if (_pinCTS != AP3_UART_PIN_UNUSED) { - retval = ap3_uart_pad_funcsel(_instance, AP3_UART_RX, ap3_gpio_pin2pad(_pinCTS), &funcsel); + retval = ap3_uart_pad_funcsel(_instance, AP3_UART_CTS, ap3_gpio_pin2pad(_pinCTS), &funcsel); if (retval != AP3_OK) { return retval; From ece522dd49b016d16cf14f736b1682c3cc08c9a1 Mon Sep 17 00:00:00 2001 From: stephenf7072 <57785167+stephenf7072@users.noreply.github.com> Date: Fri, 24 Jul 2020 09:36:28 +1000 Subject: [PATCH 04/10] Removed code using non-core library (ie. Epoch stuff) I hate to undo even a little bit of Adam's good work, but in the interests of a robust core, I think it's best the references to time.h are removed, and the Epoch set/get along with it. RTC.cpp included , which caused a compilation error when these are also included in code: #include #include Some possible issues with Window lack of case sensitivity, refer here: https://forum.arduino.cc/index.php?topic=451360.0 Also with time.h (or Time.h?) being an optional extra install library to the Arduino IDE, best to leave it out of the core, especially if it can cause compilation errors. --- .../Example4_Set_Epoch/Example4_Set_Epoch.ino | 41 ------------------- libraries/RTC/keywords.txt | 2 - libraries/RTC/src/RTC.cpp | 41 ------------------- libraries/RTC/src/RTC.h | 2 - 4 files changed, 86 deletions(-) delete mode 100644 libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino diff --git a/libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino b/libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino deleted file mode 100644 index 04dd33d5..00000000 --- a/libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino +++ /dev/null @@ -1,41 +0,0 @@ -/* - Author: Adam Garbo and Nathan Seidle - Created: June 3rd, 2020 - License: MIT. See SparkFun Arduino Apollo3 Project for more information - - This example demonstrates how to set the RTC using UNIX Epoch time. -*/ - -#include "RTC.h" // Include RTC library included with the Aruino_Apollo3 core -APM3_RTC myRTC; // Create instance of RTC class - -void setup() -{ - Serial.begin(115200); - Serial.println("SparkFun RTC Set UNIX Epoch Time Example"); - - // Set the RTC time using UNIX Epoch time - myRTC.setEpoch(1591185600); // E.g. 12:00:00, June 3rd, 2020 -} - -void loop() -{ - // Print UNIX Epoch timestamp - Serial.print("Epoch time: "); Serial.println(myRTC.getEpoch()); - - // Print RTC's date and time - Serial.print("Timestamp: "); printDateTime(); - - delay(1000); -} - -// Print the RTC's current date and time -void printDateTime() -{ - myRTC.getTime(); - char dateTime[20]; - sprintf(dateTime, "20%02d-%02d-%02d %02d:%02d:%02d", - myRTC.year, myRTC.month, myRTC.dayOfMonth, - myRTC.hour, myRTC.minute, myRTC.seconds); - Serial.println(dateTime); -} diff --git a/libraries/RTC/keywords.txt b/libraries/RTC/keywords.txt index 6b719deb..e6831ec9 100644 --- a/libraries/RTC/keywords.txt +++ b/libraries/RTC/keywords.txt @@ -13,11 +13,9 @@ RTC KEYWORD1 ####################################### getTime KEYWORD2 -getEpoch KEYWORD2 setTime KEYWORD2 setTimeToCompiler KEYWORD2 -setEpoch KEYWORD2 getAlarm KEYWORD2 setAlarm KEYWORD2 diff --git a/libraries/RTC/src/RTC.cpp b/libraries/RTC/src/RTC.cpp index c15eec3c..6ec16a53 100644 --- a/libraries/RTC/src/RTC.cpp +++ b/libraries/RTC/src/RTC.cpp @@ -3,7 +3,6 @@ */ #include "RTC.h" -#include am_hal_rtc_time_t hal_time; am_hal_rtc_time_t alm_time; @@ -89,28 +88,6 @@ void APM3_RTC::setToCompilerTime() getTime(); } -void APM3_RTC::setEpoch(uint32_t ts) -{ - if (ts < EPOCH_TIME) { - ts = EPOCH_TIME; - } - - struct tm tm; - - time_t t = ts; - struct tm* tmp = gmtime(&t); - hal_time.ui32Weekday = 0; - hal_time.ui32Century = 0; - hal_time.ui32Year = tmp->tm_year - 100; - hal_time.ui32Month = tmp->tm_mon + 1; - hal_time.ui32DayOfMonth = tmp->tm_mday; - hal_time.ui32Hour = tmp->tm_hour; - hal_time.ui32Minute = tmp->tm_min; - hal_time.ui32Second = tmp->tm_sec; - hal_time.ui32Hundredths = 0; - - am_hal_rtc_time_set(&hal_time); //Initialize the RTC with this date/time -} void APM3_RTC::getTime() { @@ -127,24 +104,6 @@ void APM3_RTC::getTime() hundredths = hal_time.ui32Hundredths; } -uint32_t APM3_RTC::getEpoch() -{ - am_hal_rtc_time_get(&hal_time); - - struct tm tm; - - tm.tm_isdst = -1; - tm.tm_yday = 0; - tm.tm_wday = 0; - tm.tm_year = hal_time.ui32Year + 100; //Number of years since 1900. - tm.tm_mon = hal_time.ui32Month - 1; //mktime is expecting 0 to 11 months - tm.tm_mday = hal_time.ui32DayOfMonth; - tm.tm_hour = hal_time.ui32Hour; - tm.tm_min = hal_time.ui32Minute; - tm.tm_sec = hal_time.ui32Second; - - return mktime(&tm); -} void APM3_RTC::getAlarm() { diff --git a/libraries/RTC/src/RTC.h b/libraries/RTC/src/RTC.h index 93cede37..f52cbee6 100644 --- a/libraries/RTC/src/RTC.h +++ b/libraries/RTC/src/RTC.h @@ -9,12 +9,10 @@ class APM3_RTC APM3_RTC(); void getTime(); //Query the RTC for the current time/date - uint32_t getEpoch(); //Return the current RTC time/date as UNIX Epoch time void setTime(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month, uint16_t year); //Set current time to provided hundredths/seconds/etc void setToCompilerTime(); //Set to time when sketch was compiled - void setEpoch(uint32_t ts); //Set current time to provided UNIX Epoch time void getAlarm(); //Query the RTC for the current alarm time/date void setAlarm(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month); //Set alarm time to provided hundredths/seconds/etc From 847eb3d6dd3ee33e2b3ea506d95056bf23d64dc8 Mon Sep 17 00:00:00 2001 From: stephenf7072 <57785167+stephenf7072@users.noreply.github.com> Date: Fri, 24 Jul 2020 11:32:07 +1000 Subject: [PATCH 05/10] Create Example8_ResetsAndWatchdog.ino --- .../Example8_ResetsAndWatchdog.ino | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 libraries/Examples/examples/Example8_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino diff --git a/libraries/Examples/examples/Example8_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino b/libraries/Examples/examples/Example8_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino new file mode 100644 index 00000000..81a1e0d5 --- /dev/null +++ b/libraries/Examples/examples/Example8_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino @@ -0,0 +1,196 @@ +/* Author: Stephen Fordyce (adapted from WDT example code by Adam Garbo - https://forum.sparkfun.com/viewtopic.php?f=169&t=52431&p=213296&hilit=watchdog#p213296) + Created: 24th July 2020 + License: MIT. See SparkFun Arduino Apollo3 Project for more information + + This example demonstrates use of the watchdog timer, also different ways of resetting the Artemis as well as how to determine the last reset type +*/ + +// Global variables +volatile uint8_t watchdogCounter = 0; // Watchdog interrupt counter +uint32_t resetStatus = 0; // Reset status register +bool testWatchdogResetFlag = false; +bool watchdogInterruptCallsEmergencyReset = false; +bool resetWDTEveryLoop = true; + +// Watchdog timer configuration structure. +am_hal_wdt_config_t g_sWatchdogConfig = { + //Substitude other values for AM_HAL_WDT_LFRC_CLK_16HZ to increase/decrease the range + .ui32Config = AM_HAL_WDT_LFRC_CLK_16HZ | AM_HAL_WDT_ENABLE_RESET | AM_HAL_WDT_ENABLE_INTERRUPT, // Configuration values for generated watchdog timer event. + //****** EVEN THOUGH THESE IMPLY 16-BIT, THEY ARE ONLY 8-BIT - 255 MAX! + .ui16InterruptCount = 120, //MAX 255! // Set WDT interrupt timeout for 5 seconds (120 / 16 = 8). // Number of watchdog timer ticks allowed before a watchdog interrupt event is generated. + .ui16ResetCount = 160 //MAX 255! // Set WDT reset timeout for 15 seconds (160 / 16 = 10). // Number of watchdog timer ticks allowed before the watchdog will issue a system reset. +}; + +void setup(void) +{ + pinMode(LED_BUILTIN, OUTPUT); + Serial.begin(115200); delay(10); + Serial.println();Serial.println(); + Serial.println("****Artemis Reset & Watchdog Reset Example****"); + + printResetReason(); //Explain reason for reset + am_hal_reset_control(AM_HAL_RESET_CONTROL_STATUSCLEAR, 0); // Clear reset status register for next time we reset. + delay(1000); + + startWatchdogTimer(); //Initialise and start the watchdog timer, in case the program gets stuck in a while loop or waiting for user input + printWatchdogDetails(); + delay(2000); + + Serial.println("\nRunning a time-consuming loop with watchdog running"); + for(int i=0; i<5; i++) + { + delay(1000); //Phew, a bunch of hard processing + printWatchdogValue(); + } + Serial.println("Yikes, the time kept increasing, even though we were doing legitimate work\n"); + + Serial.println("\nRunning a time-consuming loop that restarts the watchdog timer each loop"); + for(int i=0; i<5; i++) + { + delay(1000); //Phew, a bunch of hard processing + printWatchdogValue(); + am_hal_wdt_restart(); // "Pet" the dog. // Restart the watchdog. + } + Serial.println("Plenty of time, but the watchdog timer will still catch a freeze\n"); + delay(2000); +} + +void loop(void) +{ + Serial.println("Start of loop()"); + if(resetWDTEveryLoop) + am_hal_wdt_restart(); // "Pet" the dog. // Restart the watchdog. (every loop run seems good) + + if(resetWDTEveryLoop) + { + Serial.println("Enter 'r' to do a scheduled software reset"); + Serial.println("Enter 's' to stop resetting the watchdog timer each loop"); + delay(1000); + char option = Serial.read(); + if(option == 'r') + myScheduledReset(); + if(option == 's') + { + Serial.println("I take no responsibility for the consequences!"); + Serial.println("(the watchdog interrupt routine when triggered will reset the timer 3 times, watch the timer values to see when it's reset by the ISR)"); + delay(2000); + resetWDTEveryLoop = false; + } + } + + if(resetWDTEveryLoop == false) + { + Serial.println("Enter 'e' to let the watchdog interrupt call emergencyReset()"); + delay(1000); + char option = Serial.read(); + if(option == 'e') + { + Serial.println("Cool, that'll happen in a sec"); delay(20); + watchdogInterruptCallsEmergencyReset = true; + } + } + + if(testWatchdogResetFlag) + { + Serial.println("Just about to go down the rabbit hole..."); + delay(20); //Let serial buffer clear + while(1); //Intentionally get stuck, and hope that the watchdog timer saves the day + } + + printWatchdogValue(); + Serial.println(); + delay(10); + + //Optional code for sleeping - just halt the WDT before you disable everything, then re-initialise the WDT after waking up. Tested elsewhere, and does not have any appreciable impact on sleep currents or performance + //am_hal_wdt_halt(); + //sleepForABit(); + //startWatchdog(); +} + +// Interrupt handler for the watchdog. +extern "C" void am_watchdog_isr(void) +{ + am_hal_wdt_int_clear(); // Clear the watchdog interrupt. + if(watchdogInterruptCallsEmergencyReset) + emergencyReset(); + + if ( watchdogCounter < 3 ) // Catch the first three watchdog interrupts, but let the fourth through untouched. + { + digitalWrite(LED_BUILTIN, LOW); + am_hal_wdt_restart(); // "Pet" the dog (reset the timer) + } + else + { + digitalWrite(LED_BUILTIN, HIGH); // Indicator that a reset will occur. + testWatchdogResetFlag = true; + } + + watchdogCounter++; // Increment the number of watchdog interrupts. +} + +void startWatchdogTimer() +{ + am_hal_clkgen_control(AM_HAL_CLKGEN_CONTROL_LFRC_START, 0); // LFRC must be turned on for this example as the watchdog only runs off of the LFRC. + am_hal_wdt_init(&g_sWatchdogConfig); // Configure the watchdog. + NVIC_EnableIRQ(WDT_IRQn); // Enable the interrupt for the watchdog in the NVIC. + am_hal_interrupt_master_enable(); + am_hal_wdt_start(); // Enable the watchdog. +} + +//IMPORTANT: IF THIS IS CALLED BY THE WATCHDOG TIMER INTERRUPT ROUTINE, IT NEEDS TO BE QUICK (NO PRINTING TO SERIAL OR DELAYS) +void emergencyReset() +{ + //Optional: write some bits to flash/EEPROM to help with recovery + + am_hal_reset_control(AM_HAL_RESET_CONTROL_SWPOI,0); //Reset with option "Software Power On Initialization" SWPOI +// am_hal_reset_control(AM_HAL_RESET_CONTROL_SWPOR,0); //Reset with option SWPOR (same as SWPOI but different am_hal_reset_status bit) +} + +void myScheduledReset() +{ + //Optional: write some bits to flash/EEPROM to help with recovery + +// am_hal_reset_control(AM_HAL_RESET_CONTROL_SWPOI,0); //Reset with option "Software Power On Initialization" SWPOI + am_hal_reset_control(AM_HAL_RESET_CONTROL_SWPOR,0); //Reset with option SWPOR (same as SWPOI but different am_hal_reset_status bit) +} + +void printWatchdogDetails() +{ + Serial.print("Interrupt Count = "); Serial.print(g_sWatchdogConfig.ui16InterruptCount ); Serial.println(" ticks"); + Serial.print("Reset Count = "); Serial.print(g_sWatchdogConfig.ui16ResetCount); Serial.println(" ticks"); + + // Print out reset status register. + am_hal_reset_status_t sStatus; // (Note: See am_hal_reset.h for RESET status structure) + am_hal_reset_status_get(&sStatus); + resetStatus = sStatus.eStatus; + char rStatus[30]; + sprintf(rStatus, "Reset Status Register = 0x%x", resetStatus); // (Note: Watch Dog Timer reset = 0x40) + Serial.println(rStatus); +} + +void printWatchdogValue() +{ + Serial.print("Watchdog timer:"); + Serial.println(am_hal_wdt_counter_get()); +} + +void printResetReason() +{ + am_hal_reset_status_t resetResult; + uint32_t resultOk = am_hal_reset_status_get(&resetResult); + Serial.print("Reset reason: "); + if(resultOk == AM_HAL_STATUS_FAIL) Serial.println("Failed to get reset status"); + if(resetResult.bEXTStat) Serial.println("External reset"); + if(resetResult.bPORStat) Serial.println("Power-On reset"); + if(resetResult.bBODStat) Serial.println("Brown-Out reset"); + if(resetResult.bSWPORStat) Serial.println("SW Power-On reset or AIRCR reset - in this example, indicates reset by myScheduledReset()"); + if(resetResult.bSWPOIStat) Serial.println("SW Power On Initialization reset - in this example, indicates reset by emergencyReset()"); + if(resetResult.bDBGRStat) Serial.println("Debugger reset"); + if(resetResult.bWDTStat) Serial.println("Watch Dog Timer reset - nothing in the Watchdog Timer Interrupt routine got to restarting the Watchdog Timer"); + if(resetResult.bBOUnregStat) Serial.println("Unregulated Supply Brownout event"); + if(resetResult.bBOCOREStat) Serial.println("Core Regulator Brownout event"); + if(resetResult.bBOMEMStat) Serial.println("Memory Regulator Brownout event"); + if(resetResult.bBOBLEStat) Serial.println("BLE/Burst Regulator Brownout event"); +// am_hal_reset_control(AM_HAL_RESET_CONTROL_STATUSCLEAR, 0); // (do this in setup() Clear reset status register for next time we reset. + Serial.println(); +} From 57c81bdb20f211b6943cf811c964f6b8e4e1e2e8 Mon Sep 17 00:00:00 2001 From: stephenf7072 <57785167+stephenf7072@users.noreply.github.com> Date: Thu, 30 Jul 2020 13:56:53 +1000 Subject: [PATCH 06/10] Revert "Removed code using non-core library (ie. Epoch stuff)" This reverts commit ece522dd49b016d16cf14f736b1682c3cc08c9a1. --- .../Example4_Set_Epoch/Example4_Set_Epoch.ino | 41 +++++++++++++++++++ libraries/RTC/keywords.txt | 2 + libraries/RTC/src/RTC.cpp | 41 +++++++++++++++++++ libraries/RTC/src/RTC.h | 2 + 4 files changed, 86 insertions(+) create mode 100644 libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino diff --git a/libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino b/libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino new file mode 100644 index 00000000..04dd33d5 --- /dev/null +++ b/libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino @@ -0,0 +1,41 @@ +/* + Author: Adam Garbo and Nathan Seidle + Created: June 3rd, 2020 + License: MIT. See SparkFun Arduino Apollo3 Project for more information + + This example demonstrates how to set the RTC using UNIX Epoch time. +*/ + +#include "RTC.h" // Include RTC library included with the Aruino_Apollo3 core +APM3_RTC myRTC; // Create instance of RTC class + +void setup() +{ + Serial.begin(115200); + Serial.println("SparkFun RTC Set UNIX Epoch Time Example"); + + // Set the RTC time using UNIX Epoch time + myRTC.setEpoch(1591185600); // E.g. 12:00:00, June 3rd, 2020 +} + +void loop() +{ + // Print UNIX Epoch timestamp + Serial.print("Epoch time: "); Serial.println(myRTC.getEpoch()); + + // Print RTC's date and time + Serial.print("Timestamp: "); printDateTime(); + + delay(1000); +} + +// Print the RTC's current date and time +void printDateTime() +{ + myRTC.getTime(); + char dateTime[20]; + sprintf(dateTime, "20%02d-%02d-%02d %02d:%02d:%02d", + myRTC.year, myRTC.month, myRTC.dayOfMonth, + myRTC.hour, myRTC.minute, myRTC.seconds); + Serial.println(dateTime); +} diff --git a/libraries/RTC/keywords.txt b/libraries/RTC/keywords.txt index e6831ec9..6b719deb 100644 --- a/libraries/RTC/keywords.txt +++ b/libraries/RTC/keywords.txt @@ -13,9 +13,11 @@ RTC KEYWORD1 ####################################### getTime KEYWORD2 +getEpoch KEYWORD2 setTime KEYWORD2 setTimeToCompiler KEYWORD2 +setEpoch KEYWORD2 getAlarm KEYWORD2 setAlarm KEYWORD2 diff --git a/libraries/RTC/src/RTC.cpp b/libraries/RTC/src/RTC.cpp index 6ec16a53..c15eec3c 100644 --- a/libraries/RTC/src/RTC.cpp +++ b/libraries/RTC/src/RTC.cpp @@ -3,6 +3,7 @@ */ #include "RTC.h" +#include am_hal_rtc_time_t hal_time; am_hal_rtc_time_t alm_time; @@ -88,6 +89,28 @@ void APM3_RTC::setToCompilerTime() getTime(); } +void APM3_RTC::setEpoch(uint32_t ts) +{ + if (ts < EPOCH_TIME) { + ts = EPOCH_TIME; + } + + struct tm tm; + + time_t t = ts; + struct tm* tmp = gmtime(&t); + hal_time.ui32Weekday = 0; + hal_time.ui32Century = 0; + hal_time.ui32Year = tmp->tm_year - 100; + hal_time.ui32Month = tmp->tm_mon + 1; + hal_time.ui32DayOfMonth = tmp->tm_mday; + hal_time.ui32Hour = tmp->tm_hour; + hal_time.ui32Minute = tmp->tm_min; + hal_time.ui32Second = tmp->tm_sec; + hal_time.ui32Hundredths = 0; + + am_hal_rtc_time_set(&hal_time); //Initialize the RTC with this date/time +} void APM3_RTC::getTime() { @@ -104,6 +127,24 @@ void APM3_RTC::getTime() hundredths = hal_time.ui32Hundredths; } +uint32_t APM3_RTC::getEpoch() +{ + am_hal_rtc_time_get(&hal_time); + + struct tm tm; + + tm.tm_isdst = -1; + tm.tm_yday = 0; + tm.tm_wday = 0; + tm.tm_year = hal_time.ui32Year + 100; //Number of years since 1900. + tm.tm_mon = hal_time.ui32Month - 1; //mktime is expecting 0 to 11 months + tm.tm_mday = hal_time.ui32DayOfMonth; + tm.tm_hour = hal_time.ui32Hour; + tm.tm_min = hal_time.ui32Minute; + tm.tm_sec = hal_time.ui32Second; + + return mktime(&tm); +} void APM3_RTC::getAlarm() { diff --git a/libraries/RTC/src/RTC.h b/libraries/RTC/src/RTC.h index f52cbee6..93cede37 100644 --- a/libraries/RTC/src/RTC.h +++ b/libraries/RTC/src/RTC.h @@ -9,10 +9,12 @@ class APM3_RTC APM3_RTC(); void getTime(); //Query the RTC for the current time/date + uint32_t getEpoch(); //Return the current RTC time/date as UNIX Epoch time void setTime(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month, uint16_t year); //Set current time to provided hundredths/seconds/etc void setToCompilerTime(); //Set to time when sketch was compiled + void setEpoch(uint32_t ts); //Set current time to provided UNIX Epoch time void getAlarm(); //Query the RTC for the current alarm time/date void setAlarm(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month); //Set alarm time to provided hundredths/seconds/etc From 453196de0ab15c53297eb8100b605061d93c8c8b Mon Sep 17 00:00:00 2001 From: oclyke Date: Thu, 30 Jul 2020 09:17:42 -0600 Subject: [PATCH 07/10] rename example this keeps room around for the legacy BLE led example --- .../Example8_ResetsAndWatchdog.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libraries/Examples/examples/{Example8_ResetsAndWatchdog => Example9_ResetsAndWatchdog}/Example8_ResetsAndWatchdog.ino (100%) diff --git a/libraries/Examples/examples/Example8_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino b/libraries/Examples/examples/Example9_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino similarity index 100% rename from libraries/Examples/examples/Example8_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino rename to libraries/Examples/examples/Example9_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino From 03ae6404db944a241a8c2edf14614ec88ae35a2b Mon Sep 17 00:00:00 2001 From: oclyke Date: Thu, 30 Jul 2020 09:19:58 -0600 Subject: [PATCH 08/10] rename the actual file --- ...mple8_ResetsAndWatchdog.ino => Example9_ResetsAndWatchdog.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libraries/Examples/examples/Example9_ResetsAndWatchdog/{Example8_ResetsAndWatchdog.ino => Example9_ResetsAndWatchdog.ino} (100%) diff --git a/libraries/Examples/examples/Example9_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino b/libraries/Examples/examples/Example9_ResetsAndWatchdog/Example9_ResetsAndWatchdog.ino similarity index 100% rename from libraries/Examples/examples/Example9_ResetsAndWatchdog/Example8_ResetsAndWatchdog.ino rename to libraries/Examples/examples/Example9_ResetsAndWatchdog/Example9_ResetsAndWatchdog.ino From 0e1f5c2f6a02cba00b4a32c7a6ca7b14da4d76de Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Thu, 27 Aug 2020 11:06:40 -0600 Subject: [PATCH 09/10] Add Print::write to get write(buf, size) A few libraries rely on this ability. --- cores/arduino/ard_sup/ard_supers/HardwareSerial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/arduino/ard_sup/ard_supers/HardwareSerial.h b/cores/arduino/ard_sup/ard_supers/HardwareSerial.h index 66c4bc64..3b032dab 100644 --- a/cores/arduino/ard_sup/ard_supers/HardwareSerial.h +++ b/cores/arduino/ard_sup/ard_supers/HardwareSerial.h @@ -68,6 +68,7 @@ class HardwareSerial : public Stream virtual int read(void) = 0; virtual void flush(void) = 0; virtual size_t write(uint8_t) = 0; + using Print::write; // pull in write(str) and write(buf, size) from Print virtual operator bool() = 0; }; From 3bdee385536194cc0800ebc7141acafc2f3362f9 Mon Sep 17 00:00:00 2001 From: oclyke Date: Thu, 27 Aug 2020 14:10:51 -0600 Subject: [PATCH 10/10] Merge branch 'release-candidate' --- cores/arduino/ard_sup/analog/ap3_analog.cpp | 28 +++++++-- .../ard_sup/analog/ap3_analog_structures.c | 6 +- cores/arduino/ard_sup/ap3_analog_types.h | 2 +- cores/arduino/ard_sup/ap3_gpio.h | 25 ++++---- cores/arduino/ard_sup/gpio/ap3_gpio.cpp | 10 ++++ .../Differential_ADC/Differential_ADC.ino | 58 +++++++++++++++++++ .../artemis_thing_plus/config/variant.cpp | 1 + variants/artemis_thing_plus/config/variant.h | 2 + variants/redboard_artemis/config/variant.cpp | 2 + variants/redboard_artemis/config/variant.h | 4 ++ .../redboard_artemis_atp/config/variant.cpp | 2 + .../redboard_artemis_atp/config/variant.h | 4 ++ .../redboard_artemis_nano/config/variant.cpp | 1 + .../redboard_artemis_nano/config/variant.h | 2 + 14 files changed, 128 insertions(+), 19 deletions(-) create mode 100644 libraries/Examples/examples/Advanced/Differential_ADC/Differential_ADC.ino diff --git a/cores/arduino/ard_sup/analog/ap3_analog.cpp b/cores/arduino/ard_sup/analog/ap3_analog.cpp index accfd13b..628f7868 100644 --- a/cores/arduino/ard_sup/analog/ap3_analog.cpp +++ b/cores/arduino/ard_sup/analog/ap3_analog.cpp @@ -159,7 +159,27 @@ uint16_t analogRead(uint8_t pinNumber) { if (ap3_analog_configure_map[indi].isAnalog == false) { - if (ap3_set_pin_to_analog(pinNumber) != AP3_OK) + if (padNumber == AP3_ADC_DIFF0_PAD) + { + ap3_err_t retval = AP3_ERR; + retval = ap3_set_pin_to_analog(ap3_gpio_pad2pin(12)); + retval = ap3_set_pin_to_analog(ap3_gpio_pad2pin(13)); + if (retval != AP3_OK) + { + return 0; //Error + } + } + else if (padNumber == AP3_ADC_DIFF1_PAD) + { + ap3_err_t retval = AP3_ERR; + retval = ap3_set_pin_to_analog(ap3_gpio_pad2pin(14)); + retval = ap3_set_pin_to_analog(ap3_gpio_pad2pin(15)); + if (retval != AP3_OK) + { + return 0; //Error + } + } + else if (ap3_set_pin_to_analog(pinNumber) != AP3_OK) { //Serial.println("Error - set pin to analog"); return 0; //Error @@ -335,13 +355,12 @@ ap3_err_t ap3_adc_setup() } //Set function of pin to analog input -//TODO Support differential pairs 0/1 ap3_err_t ap3_set_pin_to_analog(uint8_t pinNumber) { ap3_err_t retval = AP3_ERR; - uint8_t funcsel = 0; am_hal_gpio_pincfg_t pincfg = AP3_PINCFG_INPUT; + retval = ap3_analog_pad_funcsel(ap3_gpio_pin2pad(pinNumber), &funcsel); if (retval != AP3_OK) @@ -350,10 +369,11 @@ ap3_err_t ap3_set_pin_to_analog(uint8_t pinNumber) } pincfg.uFuncSel = funcsel; // set the proper function select option for this instance/pin/type combination pinMode(pinNumber, pincfg, &retval); + return retval; } -//Given pin number, assign ADC function +//Given pad number, get ADC function ap3_err_t ap3_analog_pad_funcsel(ap3_gpio_pad_t padNumber, uint8_t *funcsel) { ap3_err_t retval = AP3_ERR; diff --git a/cores/arduino/ard_sup/analog/ap3_analog_structures.c b/cores/arduino/ard_sup/analog/ap3_analog_structures.c index bb15a211..1a871690 100644 --- a/cores/arduino/ard_sup/analog/ap3_analog_structures.c +++ b/cores/arduino/ard_sup/analog/ap3_analog_structures.c @@ -28,6 +28,8 @@ const ap3_analog_pad_map_elem_t ap3_analog_map[AP3_ANALOG_PADS] = { {.pad = 11, .funcsel = AM_HAL_PIN_11_ADCSE2}, {.pad = 12, .funcsel = AM_HAL_PIN_12_ADCD0NSE9}, {.pad = 13, .funcsel = AM_HAL_PIN_13_ADCD0PSE8}, + {.pad = 14, .funcsel = AM_HAL_PIN_14_ADCD1P}, + {.pad = 15, .funcsel = AM_HAL_PIN_15_ADCD1N}, {.pad = 16, .funcsel = AM_HAL_PIN_16_ADCSE0}, {.pad = 29, .funcsel = AM_HAL_PIN_29_ADCSE1}, {.pad = 31, .funcsel = AM_HAL_PIN_31_ADCSE3}, @@ -50,8 +52,8 @@ ap3_analog_configure_map_elem_t ap3_analog_configure_map[AP3_ANALOG_CHANNELS] = {.pad = 33, .isAnalog = false}, {.pad = 34, .isAnalog = false}, {.pad = 35, .isAnalog = false}, - {.pad = AP3_ADC_DIFF0_PAD, .isAnalog = true}, - {.pad = AP3_ADC_DIFF1_PAD, .isAnalog = true}, + {.pad = AP3_ADC_DIFF0_PAD, .isAnalog = false}, + {.pad = AP3_ADC_DIFF1_PAD, .isAnalog = false}, {.pad = AP3_ADC_TEMP_PAD, .isAnalog = true}, {.pad = AP3_ADC_DIV3_PAD, .isAnalog = true}, {.pad = AP3_ADC_VSS_PAD, .isAnalog = true}, diff --git a/cores/arduino/ard_sup/ap3_analog_types.h b/cores/arduino/ard_sup/ap3_analog_types.h index b08e690e..56c37d66 100644 --- a/cores/arduino/ard_sup/ap3_analog_types.h +++ b/cores/arduino/ard_sup/ap3_analog_types.h @@ -23,7 +23,7 @@ SOFTWARE. #ifndef _AP3_ANALOG_TYPES_H_ #define _AP3_ANALOG_TYPES_H_ -#define AP3_ANALOG_PADS 10 +#define AP3_ANALOG_PADS 12 #define AP3_ANALOG_CHANNELS 15 enum EXTRA_ADC_PADS diff --git a/cores/arduino/ard_sup/ap3_gpio.h b/cores/arduino/ard_sup/ap3_gpio.h index 7f1601bb..ec01a5bb 100644 --- a/cores/arduino/ard_sup/ap3_gpio.h +++ b/cores/arduino/ard_sup/ap3_gpio.h @@ -35,25 +35,26 @@ extern const am_hal_gpio_pincfg_t g_AM_HAL_GPIO_OPEN_DRAIN_WITH_READ_12; extern const am_hal_gpio_pincfg_t g_AM_HAL_GPIO_INPUT_PULLDOWN; // macros pointing to internal apollo3 GPIO pincfg structures -#define AP3_PINCFG_INPUT (g_AM_HAL_GPIO_INPUT) -#define AP3_PINCFG_OUTPUT (g_AM_HAL_GPIO_OUTPUT_WITH_READ_12) -#define AP3_PINCFG_INPUT_PULLUP (g_AM_HAL_GPIO_INPUT_PULLUP) -#define AP3_PINCFG_INPUT_PULLDOWN (g_AM_HAL_GPIO_INPUT_PULLDOWN) -#define AP3_PINCFG_OPEN_DRAIN (g_AM_HAL_GPIO_OPEN_DRAIN_WITH_READ_12) -#define AP3_PINCFG_TRISTATE (g_AM_HAL_GPIO_TRISTATE) +#define AP3_PINCFG_INPUT (g_AM_HAL_GPIO_INPUT) +#define AP3_PINCFG_OUTPUT (g_AM_HAL_GPIO_OUTPUT_WITH_READ_12) +#define AP3_PINCFG_INPUT_PULLUP (g_AM_HAL_GPIO_INPUT_PULLUP) +#define AP3_PINCFG_INPUT_PULLDOWN (g_AM_HAL_GPIO_INPUT_PULLDOWN) +#define AP3_PINCFG_OPEN_DRAIN (g_AM_HAL_GPIO_OPEN_DRAIN_WITH_READ_12) +#define AP3_PINCFG_TRISTATE (g_AM_HAL_GPIO_TRISTATE) // constants for Arduino pin modes -#define INPUT (0x00) -#define OUTPUT (0x01) -#define INPUT_PULLUP (0x02) -#define INPUT_PULLDOWN (0x03) -#define OPEN_DRAIN (0x04) -#define TRISTATE (0x05) +#define INPUT (0x00) +#define OUTPUT (0x01) +#define INPUT_PULLUP (0x02) +#define INPUT_PULLDOWN (0x03) +#define OPEN_DRAIN (0x04) +#define TRISTATE (0x05) #define AP3_GPIO_MAX_PADS (50) #define AP3_GPIO_IS_VALID(pad) ((pad >= 0) && (pad < AP3_GPIO_MAX_PADS)) extern ap3_gpio_pad_t ap3_gpio_pin2pad(ap3_gpio_pin_t pin); +extern ap3_gpio_pin_t ap3_gpio_pad2pin(ap3_gpio_pad_t pad); #define AP3_GPIO_PAD_UNUSED (255) #define AP3_GPIO_DEFAULT_PINCFG AP3_GPIO_PINCFG_NULL diff --git a/cores/arduino/ard_sup/gpio/ap3_gpio.cpp b/cores/arduino/ard_sup/gpio/ap3_gpio.cpp index 1ce8b078..ab349991 100644 --- a/cores/arduino/ard_sup/gpio/ap3_gpio.cpp +++ b/cores/arduino/ard_sup/gpio/ap3_gpio.cpp @@ -41,6 +41,16 @@ ap3_gpio_pad_t ap3_gpio_pin2pad(ap3_gpio_pin_t pin) return ap3_variant_pinmap[pin]; } +ap3_gpio_pin_t ap3_gpio_pad2pin(ap3_gpio_pad_t pad) +{ + for (int x = 0; x < AP3_VARIANT_NUM_PINS; x++) + { + if (ap3_variant_pinmap[x] == pad) + return (x); + } + return (AP3_GPIO_PAD_UNUSED); +} + typedef void (*voidFuncPtr)(void); typedef void (*voidFuncPtrArg)(void *); typedef struct diff --git a/libraries/Examples/examples/Advanced/Differential_ADC/Differential_ADC.ino b/libraries/Examples/examples/Advanced/Differential_ADC/Differential_ADC.ino new file mode 100644 index 00000000..2946f11f --- /dev/null +++ b/libraries/Examples/examples/Advanced/Differential_ADC/Differential_ADC.ino @@ -0,0 +1,58 @@ +/* + Using the differential ADC + By: Nathan Seidle + SparkFun Electronics + Date: July 17th, 2020 + License: This code is public domain. Based on deepsleep.c from Ambiq SDK v2.2.0. + + There are two differential ADC ports on the Artemis. These are located + on pads 12/13 (DIFF0N/DIFF0P) and 14/15 (DIFF1P/DIFF10). + + A differential ADC port measures -1.0V to 1.0V with + 0 = -1.0V, 8192 = 0V, and 16383 = 1.0V when the ADC is in 14-bit mode. + + Using a trimpot, attach DIFF- to GND and DIFF+ to the center pin of the trimpot. + Connect the outer pins of the trimpot to 3.3V and GND. + Twisting the trimpot you should see the voltage change from 0 to 1.0V. + Switching DIFF-/+ you should see -1.0V to 0V. + + SparkFun labored with love to create this code. Feel like supporting open source hardware? + Buy a board from SparkFun! https://www.sparkfun.com/products/15376 +*/ + +#define ANALOG_RESOLUTION 14 //Artemis has 14 bit ADC but can range from 8 to 14 bit + +int maxADCValue = pow(2, ANALOG_RESOLUTION); + +void setup() +{ + Serial.begin(115200); + Serial.println("Differential analog conversion example"); + + pinMode(LED_BUILTIN, OUTPUT); + + analogReadResolution(ANALOG_RESOLUTION); //Default is 10 bit. Increase to 14 bit. +} + +void loop() +{ + int myAnalog0 = analogRead(ADIFF0); //Pads 12/13. Pins 9/10 on RedBoard Artemis. + //int myAnalog0 = analogRead(ADIFF1); //Pads 14/15 + float myVoltage0 = mapfloat(myAnalog0, 0, maxADCValue, -1.0, 1.0); + Serial.print("Diff0 voltage: "); + Serial.print(myVoltage0, 3); + Serial.println(); + + digitalWrite(LED_BUILTIN, HIGH); + delay(25); + digitalWrite(LED_BUILTIN, LOW); + delay(25); +} + +float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) +{ + if (x > in_max) + x = in_max; + + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} \ No newline at end of file diff --git a/variants/artemis_thing_plus/config/variant.cpp b/variants/artemis_thing_plus/config/variant.cpp index aba19adf..8f1f40c1 100644 --- a/variants/artemis_thing_plus/config/variant.cpp +++ b/variants/artemis_thing_plus/config/variant.cpp @@ -70,3 +70,4 @@ const ap3_gpio_pin_t ap3_analog_A4 = 23; const ap3_gpio_pin_t ap3_analog_A5 = 24; const ap3_gpio_pin_t ap3_analog_A6 = 3; const ap3_gpio_pin_t ap3_analog_A7 = 9; +const ap3_gpio_pin_t ap3_analog_DIFF0 = AP3_ADC_DIFF0_PAD; diff --git a/variants/artemis_thing_plus/config/variant.h b/variants/artemis_thing_plus/config/variant.h index 1d170d90..44cf137f 100644 --- a/variants/artemis_thing_plus/config/variant.h +++ b/variants/artemis_thing_plus/config/variant.h @@ -57,6 +57,7 @@ extern Uart Serial1; #define A5 ap3_analog_A5 #define A6 ap3_analog_A6 #define A7 ap3_analog_A7 +#define ADIFF0 ap3_analog_DIFF0 // Promise the existence of analog pin names extern const ap3_gpio_pin_t ap3_analog_A0; @@ -67,6 +68,7 @@ extern const ap3_gpio_pin_t ap3_analog_A4; extern const ap3_gpio_pin_t ap3_analog_A5; extern const ap3_gpio_pin_t ap3_analog_A6; extern const ap3_gpio_pin_t ap3_analog_A7; +extern const ap3_gpio_pin_t ap3_analog_DIFF0; #define LED_BUILTIN 18 diff --git a/variants/redboard_artemis/config/variant.cpp b/variants/redboard_artemis/config/variant.cpp index e7d22c6c..0892ef02 100644 --- a/variants/redboard_artemis/config/variant.cpp +++ b/variants/redboard_artemis/config/variant.cpp @@ -76,3 +76,5 @@ const ap3_gpio_pin_t ap3_analog_A6 = 2; const ap3_gpio_pin_t ap3_analog_A8 = 8; const ap3_gpio_pin_t ap3_analog_A9 = 9; const ap3_gpio_pin_t ap3_analog_A10 = 10; +const ap3_gpio_pin_t ap3_analog_DIFF0 = AP3_ADC_DIFF0_PAD; +const ap3_gpio_pin_t ap3_analog_DIFF1 = AP3_ADC_DIFF1_PAD; diff --git a/variants/redboard_artemis/config/variant.h b/variants/redboard_artemis/config/variant.h index 5f62ad53..5c2e278c 100644 --- a/variants/redboard_artemis/config/variant.h +++ b/variants/redboard_artemis/config/variant.h @@ -72,6 +72,8 @@ extern Uart Serial1; #define A8 ap3_analog_A8 #define A9 ap3_analog_A9 #define A10 ap3_analog_A10 +#define ADIFF0 ap3_analog_DIFF0 +#define ADIFF1 ap3_analog_DIFF1 // Promise the existence of analog pin names extern const ap3_gpio_pin_t ap3_analog_A0; @@ -85,6 +87,8 @@ extern const ap3_gpio_pin_t ap3_analog_A6; extern const ap3_gpio_pin_t ap3_analog_A8; extern const ap3_gpio_pin_t ap3_analog_A9; extern const ap3_gpio_pin_t ap3_analog_A10; +extern const ap3_gpio_pin_t ap3_analog_DIFF0; +extern const ap3_gpio_pin_t ap3_analog_DIFF1; #define LED_BUILTIN 13 diff --git a/variants/redboard_artemis_atp/config/variant.cpp b/variants/redboard_artemis_atp/config/variant.cpp index a7a3d0c9..885939d4 100644 --- a/variants/redboard_artemis_atp/config/variant.cpp +++ b/variants/redboard_artemis_atp/config/variant.cpp @@ -92,3 +92,5 @@ extern const ap3_gpio_pin_t ap3_analog_A12 = 12; extern const ap3_gpio_pin_t ap3_analog_A32 = 32; extern const ap3_gpio_pin_t ap3_analog_A33 = 33; extern const ap3_gpio_pin_t ap3_analog_A35 = 35; +extern const ap3_gpio_pin_t ap3_analog_DIFF0 = AP3_ADC_DIFF0_PAD; +extern const ap3_gpio_pin_t ap3_analog_DIFF1 = AP3_ADC_DIFF1_PAD; diff --git a/variants/redboard_artemis_atp/config/variant.h b/variants/redboard_artemis_atp/config/variant.h index fd08ff6d..9babc53c 100644 --- a/variants/redboard_artemis_atp/config/variant.h +++ b/variants/redboard_artemis_atp/config/variant.h @@ -58,6 +58,8 @@ extern Uart Serial1; #define A32 ap3_analog_A32 #define A33 ap3_analog_A33 #define A35 ap3_analog_A35 +#define ADIFF0 ap3_analog_DIFF0 +#define ADIFF1 ap3_analog_DIFF1 // Promise the existence of analog pin names extern const ap3_gpio_pin_t ap3_analog_A29; @@ -70,6 +72,8 @@ extern const ap3_gpio_pin_t ap3_analog_A12; extern const ap3_gpio_pin_t ap3_analog_A32; extern const ap3_gpio_pin_t ap3_analog_A33; extern const ap3_gpio_pin_t ap3_analog_A35; +extern const ap3_gpio_pin_t ap3_analog_DIFF0; +extern const ap3_gpio_pin_t ap3_analog_DIFF1; #define LED_BUILTIN 5 diff --git a/variants/redboard_artemis_nano/config/variant.cpp b/variants/redboard_artemis_nano/config/variant.cpp index 188e2470..e18f7730 100644 --- a/variants/redboard_artemis_nano/config/variant.cpp +++ b/variants/redboard_artemis_nano/config/variant.cpp @@ -65,3 +65,4 @@ const ap3_gpio_pin_t ap3_analog_A5 = 5; const ap3_gpio_pin_t ap3_analog_A14 = 14; const ap3_gpio_pin_t ap3_analog_A15 = 15; const ap3_gpio_pin_t ap3_analog_A16 = 16; +const ap3_gpio_pin_t ap3_analog_DIFF0 = AP3_ADC_DIFF0_PAD; diff --git a/variants/redboard_artemis_nano/config/variant.h b/variants/redboard_artemis_nano/config/variant.h index 37f10bec..1212dbf0 100644 --- a/variants/redboard_artemis_nano/config/variant.h +++ b/variants/redboard_artemis_nano/config/variant.h @@ -56,6 +56,7 @@ extern Uart Serial1; #define A14 ap3_analog_A14 #define A15 ap3_analog_A15 #define A16 ap3_analog_A16 +#define ADIFF0 ap3_analog_DIFF0 // Promise the existence of analog pin names extern const ap3_gpio_pin_t ap3_analog_A0; @@ -66,6 +67,7 @@ extern const ap3_gpio_pin_t ap3_analog_A5; extern const ap3_gpio_pin_t ap3_analog_A14; extern const ap3_gpio_pin_t ap3_analog_A15; extern const ap3_gpio_pin_t ap3_analog_A16; +extern const ap3_gpio_pin_t ap3_analog_DIFF0; #define LED_BUILTIN 19