diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp b/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp deleted file mode 100644 index 44e75da4f..000000000 --- a/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp +++ /dev/null @@ -1,769 +0,0 @@ -//************************************************************************ -//* Arduino Test Suite -//* (C) 2010 by Mark Sproul -//* (C) 2011 by Matthew Murdoch -//* Open source as per standard Arduino code -//* -//* This library is free software; you can redistribute it and/or -//* modify it under the terms of the GNU Lesser General Public -//* License as published by the Free Software Foundation; either -//* version 2.1 of the License, or (at your option) any later version. -//* -//* This library is distributed in the hope that it will be useful, -//* but WITHOUT ANY WARRANTY; without even the implied warranty of -//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//* Lesser General Public License for more details. -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//* Oct 18, 2010 Added memory testing -//* Jun 10, 2011 Added free list to memory usage calculation -//************************************************************************ - -#include -#include -#include - - - -#include "ArduinoTestSuite.h" - - -#include "avr_cpunames.h" - -#if defined(USART3_RX_vect) - #define SERIAL_PORT_COUNT 4 -#elif defined(USART1_RX_vect) - #define SERIAL_PORT_COUNT 2 -#else - #define SERIAL_PORT_COUNT 1 -#endif - - - - -//************************************************************************ -enum -{ - ATS_Manufacturer = 1, - ATS_CPU, - ATS_GCC_version, - ATS_LIBC_version, - ATS_CompiledDate, - ATS_TestSuiteName, - ATS_FreeMemory, - - -}; -unsigned long gTestStartTime; -unsigned long gTestTotalElapsedTime; -short gTagIndent; -int gYotalErrors; -int gTestCount; - - - -prog_char gTextMsg_Manufacturer[] PROGMEM = "MANUFACTURER"; -prog_char gTextMsg_CPUname[] PROGMEM = "CPU-NAME"; -prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC-Version"; -prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR-LibC-Ver"; -prog_char gTextMsg_COMPILED_DATE[] PROGMEM = "Compiled-date"; -prog_char gTextMsg_TEST_SUITE_NAME[] PROGMEM = "Test-Suite-Name"; -prog_char gTextMsg_memoryUsage[] PROGMEM = "Free-memory"; -prog_char gTextMsg_dotdotdot[] PROGMEM = "... "; -prog_char gTextMsg_ok[] PROGMEM = "ok"; -prog_char gTextMsg_FAIL[] PROGMEM = "FAIL"; -prog_char gTextMsg_spaceEqual[] PROGMEM = " = "; -prog_char gTextMsg_info[] PROGMEM = "info."; -prog_char gTextMsg_dashLine[] PROGMEM = "--------------------------"; -prog_char gTextMsg_DigitalRW[] PROGMEM = "DigitalReadWrite_"; -prog_char gTextMsg_PWMoutput[] PROGMEM = "PWMoutput_"; -prog_char gTextMsg_AnalogInput[] PROGMEM = "AnalogInput_"; - -//************************************************************************ -void Serial_print_P(prog_char *flashMemStr) -{ -char theChar; -int ii; - - ii = 0; -#if (FLASHEND > 0x10000) - while (theChar = pgm_read_byte_far(flashMemStr + ii++)) -#else - while (theChar = pgm_read_byte_near(flashMemStr + ii++)) -#endif - { - Serial.print(theChar); - } -} - -//************************************************************************ -void Serial_println_P(prog_char *flashMemStr) -{ - Serial_print_P(flashMemStr); - Serial.println(); -} - -//************************************************************************ -//* this is for internal use only, not made pubic to the API -static void ATS_PrintProperty( int propertyTagNum, - char *propertyName, - char *propertyValue) -{ -char lineBuffer[64]; - - strcpy_P(lineBuffer, gTextMsg_info); - switch(propertyTagNum) - { - case 0: - strcat(lineBuffer, propertyName); - break; - - case ATS_Manufacturer: - strcat_P(lineBuffer, gTextMsg_Manufacturer); - break; - - case ATS_CPU: - strcat_P(lineBuffer, gTextMsg_CPUname); - break; - - case ATS_GCC_version: - strcat_P(lineBuffer, gTextMsg_GCC_VERSION); - break; - - case ATS_LIBC_version: - strcat_P(lineBuffer, gTextMsg_AVR_LIBC); - break; - - case ATS_CompiledDate: - strcat_P(lineBuffer, gTextMsg_COMPILED_DATE); - break; - - case ATS_TestSuiteName: - strcat_P(lineBuffer, gTextMsg_TEST_SUITE_NAME); - break; - - case ATS_FreeMemory: - strcat_P(lineBuffer, gTextMsg_memoryUsage); - break; - } - - while (strlen(lineBuffer) < 20) - { - strcat(lineBuffer, " "); - } - - strcat_P(lineBuffer, gTextMsg_spaceEqual); - if (propertyValue != 0) - { - strcat(lineBuffer, propertyValue); - } - Serial.println(lineBuffer); - -} - - - - -//************************************************************************ -void ATS_begin(char *manufName, char *testSuiteName) -{ -int freeMemory; -char memoryMsg[48]; - - gYotalErrors = 0; - gTestCount = 0; - - Serial.begin(9600); - delay(100); - - gTestTotalElapsedTime = 0; - - Serial.println(); - Serial.println(); - Serial.println(); - - ATS_PrintProperty(ATS_Manufacturer, 0, manufName); - ATS_PrintProperty(ATS_CPU, 0, _AVR_CPU_NAME_); - ATS_PrintProperty(ATS_GCC_version, 0, __VERSION__); - ATS_PrintProperty(ATS_LIBC_version, 0, __AVR_LIBC_VERSION_STRING__); - ATS_PrintProperty(ATS_CompiledDate, 0, __DATE__); - ATS_PrintProperty(ATS_TestSuiteName, 0, testSuiteName); - - freeMemory = ATS_GetFreeMemory(); - sprintf(memoryMsg, "%d bytes", freeMemory); - ATS_PrintProperty(ATS_FreeMemory, 0, memoryMsg); - - randomSeed(analogRead(0)); - - gTestStartTime = micros(); -} - -//************************************************************************ -void ATS_end() -{ -unsigned long seconds; -unsigned long microSecs; -char buf[8]; - - gTestTotalElapsedTime += (micros() - gTestStartTime); - - Serial_println_P(gTextMsg_dashLine); - - // Ran 4 tests in 0.000s - Serial.print("Ran "); - Serial.print(gTestCount); - Serial.print(" tests in "); - - seconds = gTestTotalElapsedTime / 1000000; - microSecs = gTestTotalElapsedTime % 1000000; - - Serial.print(seconds); - ultoa(microSecs + 1000000, buf, 10); // add forces leading zeros - buf[0] = '.'; // replace leading '1' with decimal point - Serial.print(buf); - Serial.print('s'); - Serial.println(); - - int used = ATS_GetMaximumMemoryAllocated(); - if (used >= 0) { - Serial.print("Maximum heap memory: "); - Serial.println(used); - } - Serial.println(); - - if (gYotalErrors == 0) - { - Serial.print("OK"); - } - else - { - Serial.print("FAILED (failures="); - Serial.print(gYotalErrors); - Serial.print(")"); - } - Serial.println(); - - //* send control D to terminate (End Of File) - Serial.write(0x04); -} - - - -//************************************************************************ -void ATS_PrintTestStatus(char *testString, boolean passed) -{ -int sLen; - - // do not include time printing status in total test time - gTestTotalElapsedTime += (micros() - gTestStartTime); - - Serial.print(testString); - sLen = strlen(testString); - while (sLen < 60) - { - Serial.print(' '); - sLen++; - } - Serial_print_P(gTextMsg_dotdotdot); - if (passed) - { - Serial_print_P(gTextMsg_ok); - } - else - { - Serial_print_P(gTextMsg_FAIL); - gYotalErrors++; - } - Serial.println(); - - gTestCount++; - - // begin counting total test time again - gTestStartTime = micros(); -} - - - -//************************************************************************ -//* returns true if no errors, false if there is an error -int ATS_Test_DigitalPinWithHelper(uint8_t digitalPinToTest, uint8_t helperpin) -{ -boolean passedOK; -int pinValue; -char testName[64]; -char numString[32]; - - strcpy_P(testName, gTextMsg_DigitalRW); - sprintf(numString, "%02d", digitalPinToTest); - strcat(testName, numString); - - passedOK = true; - - //* test senario 1 - pinMode(digitalPinToTest, OUTPUT); - pinMode(helperpin, INPUT); - - digitalWrite(digitalPinToTest, HIGH); - pinValue = digitalRead(helperpin); - if (pinValue != HIGH) - { - passedOK = false; - } - - digitalWrite(digitalPinToTest, LOW); - pinValue = digitalRead(helperpin); - if (pinValue != LOW) - { - passedOK = false; - } - - - //* now reverse the input/output - pinMode(digitalPinToTest, INPUT); - pinMode(helperpin, OUTPUT); - - digitalWrite(helperpin, HIGH); - pinValue = digitalRead(digitalPinToTest); - if (pinValue != HIGH) - { - passedOK = false; - } - - digitalWrite(helperpin, LOW); - pinValue = digitalRead(digitalPinToTest); - if (pinValue != LOW) - { - passedOK = false; - } - - - if (! passedOK) - { - sprintf(numString, " (helper pin=%02d)", helperpin); - strcat(testName, numString); - } - ATS_PrintTestStatus(testName, passedOK); - return(passedOK); -} - -//************************************************************************ -boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest) -{ -boolean passedOK; -uint8_t helperpin; - - if ((digitalPinToTest % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = digitalPinToTest + 1; - } - else - { - //* if its ODD - helperpin = digitalPinToTest - 1; - } - passedOK = ATS_Test_DigitalPinWithHelper(digitalPinToTest, helperpin); - return(passedOK); -} - - - -//************************************************************************ -//* returns true if no errors, false if there is an error -int ATS_TestTimer( uint8_t timerPinNumber, - uint8_t inputPin, - char *statusString, - char *errorString) -{ -boolean passedOK; -unsigned long loopCounter; -unsigned long lowCount; -unsigned long highCount; -unsigned long startTime; -int percentLow; -int percentHigh; -int pinValue; -char numString[48]; -int pwmValue; - - pwmValue = 128; - loopCounter = 0; - lowCount = 0; - highCount = 0; - passedOK = true; - - startTime = millis(); - pinMode(inputPin, INPUT); - analogWrite(timerPinNumber, pwmValue); - while ((millis() - startTime) < 500) - { - pinValue = digitalRead(inputPin); - if (pinValue == HIGH) - { - highCount++; - } - else - { - lowCount++; - } - } - analogWrite(timerPinNumber, 0); - - //* the difference should be about 50% - percentLow = lowCount / ((lowCount + highCount) / 100); - percentHigh = highCount / ((lowCount + highCount) / 100); - if ((percentLow > 45) && (percentLow < 55)) - { - passedOK = true; - } - else - { - passedOK = false; - strcat(errorString, " PWM ERROR"); - } - sprintf(numString, " (PWM=%02d %d%% LOW %d%% HIGH)", pwmValue, percentLow, percentHigh); - strcat(statusString, numString); - - return(passedOK); -} - - -//************************************************************************ -//* returns true if no errors, false if there is an error -boolean ATS_Test_PWMPinWithHelper(uint8_t pwmPinToTest, uint8_t helperpin) -{ -boolean passedOK; -char testName[64]; -char errorString[48]; -char numString[8]; -uint8_t timerNumber; - - - - strcpy_P(testName, gTextMsg_PWMoutput); - sprintf(numString, "%02d", pwmPinToTest); - strcat(testName, numString); - - passedOK = true; - errorString[0] = 0; - - - //* is pin1 a timer? - timerNumber = digitalPinToTimer(pwmPinToTest); - if (timerNumber != NOT_ON_TIMER) - { - passedOK = ATS_TestTimer(pwmPinToTest, helperpin, testName, errorString); - } - else - { - //* we should not get here - passedOK = false; - } - - ATS_PrintTestStatus(testName, passedOK); - - - return(passedOK); -} - -//************************************************************************ -boolean ATS_Test_PWM_Pin(uint8_t pwmPinToTest) -{ -boolean passedOK; -uint8_t helperpin; - - if ((pwmPinToTest % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = pwmPinToTest + 1; - } - else - { - //* if its ODD - helperpin = pwmPinToTest - 1; - } - passedOK = ATS_Test_PWMPinWithHelper(pwmPinToTest, helperpin); - return(passedOK); -} - - -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - #define kAnalogPinOffset 54 - #define DIGITAL_ANAPIN(a) ((a) + kAnalogPinOffset) -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) - #define kAnalogPinOffset 38 - #define DIGITAL_ANAPIN(a) ((a) + kAnalogPinOffset) -#elif defined(__AVR_ATmega32U4__) - #define DIGITAL_ANAPIN(a) ((a) < 11 ? 21 - (a) : 22) -#else - #define kAnalogPinOffset 14 - #define DIGITAL_ANAPIN(a) ((a) + kAnalogPinOffset) -#endif - - -//************************************************************************ -boolean ATS_Test_AnalogInputWithHelper(uint8_t analogPintoTest, uint8_t helperPin) -{ -boolean passedOK; -char testName[64]; -char infoString[48]; -int analogValueHigh; -int analogValueLow; - - - //* first we have to set the ANALOG pin to INPUT - pinMode(DIGITAL_ANAPIN(analogPintoTest), INPUT); - - passedOK = true; - - strcpy_P(testName, gTextMsg_AnalogInput); - sprintf(infoString, "%02d", analogPintoTest); - strcat(testName, infoString); - - - pinMode(helperPin, OUTPUT); - - digitalWrite(helperPin, LOW); - analogValueLow = analogRead(analogPintoTest); - if (analogValueLow > 100) - { - passedOK = false; - } - - - digitalWrite(helperPin, HIGH); - analogValueHigh = analogRead(analogPintoTest); - if (analogValueHigh < 1000) - { - passedOK = false; - } - - - sprintf(infoString, " (Low=%4d High=%4d helper pin=%d)", analogValueLow, analogValueHigh, helperPin); - strcat(testName, infoString); - - ATS_PrintTestStatus(testName, passedOK); - - return(passedOK); -} - - -//************************************************************************ -boolean ATS_Test_AnalogInput(uint8_t analogPinToTest) -{ -boolean passedOK; -uint8_t helperpin; - - if ((DIGITAL_ANAPIN(analogPinToTest) % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = DIGITAL_ANAPIN(analogPinToTest) + 1; - } - else - { - //* if its ODD - helperpin = DIGITAL_ANAPIN(analogPinToTest) - 1; - } - passedOK = ATS_Test_AnalogInputWithHelper(analogPinToTest, helperpin); - return(passedOK); -} - - -#define kSerialTestBaudRate 9600 -#define kSerialTestDelay 3 - - -#if (SERIAL_PORT_COUNT > 1) -//************************************************************************ -//* retunrs 0 if no errors, 1 if an error occured -short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName) -{ -char xmitChar; -char rcvChar; -short ii; -short serialErrCt; -short timeOutLoopCtr; - - - serialErrCt = 1; - if (theSerialPort != 0) - { - serialErrCt = 0; - theSerialPort->begin(kSerialTestBaudRate); - - for (ii=0; ii<150; ii++) - { - xmitChar = ii; - theSerialPort->print(xmitChar); - - timeOutLoopCtr = 0; - //* wait for data to come back or timeout - while (!theSerialPort->available() && (timeOutLoopCtr < kSerialTestDelay)) - { - delay(1); - timeOutLoopCtr++; - } - - if (theSerialPort->available()) - { - //* get the char - rcvChar = theSerialPort->read(); - if (rcvChar != xmitChar) - { - serialErrCt = 1; - } - } - else - { - serialErrCt = 1; - } - } - theSerialPort->end(); - - if (serialErrCt == 0) - { - ATS_PrintTestStatus(serialPortName, PASSED); - } - else - { - ATS_PrintTestStatus(serialPortName, FAILED); - } - } - - return(serialErrCt); -} -#endif - - -//************************************************************************ -boolean ATS_Test_EEPROM(void) -{ -boolean passedOK; -uint8_t dataByte; -uint8_t dataByteRead; -uint16_t dataWord; -uint16_t dataWordRead; -uint32_t dataLongWord; -uint32_t dataLongWordRead; -int addressPtr; -char reportString[48]; - - passedOK = true; - //* test BYTE read/write - addressPtr = random(E2END); - dataByte = 0x5A; - eeprom_write_byte((uint8_t *)addressPtr, dataByte); - dataByteRead = eeprom_read_byte((uint8_t *)addressPtr); - - sprintf(reportString, "EEPROM_byte_rw (addr= 0x%04X)", addressPtr); - if (dataByteRead == dataByte) - { - ATS_PrintTestStatus(reportString, PASSED); - } - else - { - ATS_PrintTestStatus(reportString, FAILED); - passedOK = false; - } - - - //* test WORD read/write - addressPtr = random(E2END); - dataWord = 0xA55A; - eeprom_write_word((uint16_t *)addressPtr, dataWord); - dataWordRead = eeprom_read_word((uint16_t *)addressPtr); - - sprintf(reportString, "EEPROM_word_rw (addr= 0x%04X)", addressPtr); - if (dataWordRead == dataWord) - { - ATS_PrintTestStatus(reportString, PASSED); - } - else - { - ATS_PrintTestStatus(reportString, FAILED); - passedOK = false; - } - - - //* test Long WORD read/write - addressPtr = random(E2END); - dataLongWord = 0x5AA5A55A; - eeprom_write_dword((uint32_t *)addressPtr, dataLongWord); - dataLongWordRead = eeprom_read_dword((uint32_t *)addressPtr); - - sprintf(reportString, "EEPROM_dword_rw (addr= 0x%04X)", addressPtr); - if (dataLongWordRead == dataLongWord) - { - ATS_PrintTestStatus(reportString, PASSED); - } - else - { - ATS_PrintTestStatus(reportString, FAILED); - passedOK = false; - } - - - return(passedOK); -} - - - -//************************************************************************ -extern unsigned int __data_start; -extern unsigned int __data_end; -extern unsigned int __bss_start; -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; -char *__brkval_maximum __attribute__((weak)); - -/* - * The free list structure as maintained by the avr-libc memory allocation routines. - */ -struct __freelist { - size_t sz; - struct __freelist *nx; -}; - -/* The head of the free list structure */ -extern struct __freelist *__flp; - -/* Calculates the size of the free list */ -int ATS_FreeListSize() -{ -struct __freelist* current; -int total = 0; - - for (current = __flp; current; current = current->nx) { - total += 2; /* Add two bytes for the memory block's header */ - total += (int) current->sz; - } - - return total; -} - -//************************************************************************ -int ATS_GetFreeMemory() -{ -int free_memory; - - if((int)__brkval == 0) - { - free_memory = ((int)&free_memory) - ((int)&__heap_start); - } - else - { - free_memory = ((int)&free_memory) - ((int)__brkval); - free_memory += ATS_FreeListSize(); - } - return free_memory; -} - -int ATS_GetMaximumMemoryAllocated() -{ - if (__brkval_maximum) { - return (int)__brkval_maximum - (int)&__heap_start; - } - return -1; -} - diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.h b/libraries/ArduinoTestSuite/ArduinoTestSuite.h deleted file mode 100644 index f2f00ca89..000000000 --- a/libraries/ArduinoTestSuite/ArduinoTestSuite.h +++ /dev/null @@ -1,74 +0,0 @@ -//************************************************************************ -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//************************************************************************ - -#if defined(ARDUINO) && ARDUINO >= 100 -#include "Arduino.h" -#include "pins_arduino.h" -#else -#include "WProgram.h" -#include "pins_arduino.h" -#endif - - -#if defined(USART3_RX_vect) - #define SERIAL_PORT_COUNT 4 -#elif defined(USART1_RX_vect) - #define SERIAL_PORT_COUNT 2 -#else - #define SERIAL_PORT_COUNT 1 -#endif - - -void ATS_begin(char *manufName, char *testSuiteName); -void ATS_end(); - -void ATS_PrintTestStatus(char *testString, boolean passed); -boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest); -boolean ATS_Test_PWM_Pin(uint8_t digitalPinToTest); -boolean ATS_Test_AnalogInput(uint8_t analogPintoTest); -boolean ATS_Test_EEPROM(void); - -short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName); - - -int ATS_GetFreeMemory(); -int ATS_GetMaximumMemoryAllocated(); - - -//************************************************************************ -//* this has to be an inline function because calling subroutines affects free memory -inline void ATS_ReportMemoryUsage(int _memoryUsageAtStart) __attribute__((always_inline, unused)); -inline void ATS_ReportMemoryUsage(int _memoryUsageAtStart) -{ -int freeMemoryAtEnd; -int lostMemory; -boolean memoryOK; -char memoryUsage[48]; - - freeMemoryAtEnd = ATS_GetFreeMemory(); - lostMemory = _memoryUsageAtStart - freeMemoryAtEnd; - if (lostMemory == 0) - { - strcpy(memoryUsage, "Memory Usage"); - memoryOK = true; - } - else - { - sprintf(memoryUsage, "Memory Usage (lost %d bytes)", lostMemory); - memoryOK = false; - } - ATS_PrintTestStatus(memoryUsage, memoryOK); -} - - - -extern unsigned long gTestStartTime; -extern int gYotalErrors; -extern int gTestCount; - - -#define PASSED true -#define FAILED false - diff --git a/libraries/ArduinoTestSuite/avr_cpunames.h b/libraries/ArduinoTestSuite/avr_cpunames.h deleted file mode 100644 index 80832164c..000000000 --- a/libraries/ArduinoTestSuite/avr_cpunames.h +++ /dev/null @@ -1,186 +0,0 @@ -//************************************************************************************************** -//* -//* Atmel AVR CPU name strings -//* -//************************************************************************************************** -//* Sep 19, 2010 Started on avr_cpunames.h -//************************************************************************************************** - -//#include "avr_cpunames.h" - -//************************************************************************************************** - - -#if defined (__AVR_AT94K__) - #define _AVR_CPU_NAME_ "AT94k" -#elif defined (__AVR_AT43USB320__) -#elif defined (__AVR_AT43USB355__) -#elif defined (__AVR_AT76C711__) -#elif defined (__AVR_AT86RF401__) -#elif defined (__AVR_AT90PWM1__) -#elif defined (__AVR_AT90PWM2__) -#elif defined (__AVR_AT90PWM2B__) -#elif defined (__AVR_AT90PWM3__) -#elif defined (__AVR_AT90PWM3B__) -#elif defined (__AVR_AT90PWM216__) -#elif defined (__AVR_AT90PWM316__) -#elif defined (__AVR_ATmega32C1__) -#elif defined (__AVR_ATmega32M1__) -#elif defined (__AVR_ATmega32U4__) - #define _AVR_CPU_NAME_ "ATmega32U4" -#elif defined (__AVR_ATmega32U6__) - #define _AVR_CPU_NAME_ "ATmega32U6" -#elif defined (__AVR_ATmega128__) - #define _AVR_CPU_NAME_ "Atmega128" -#elif defined (__AVR_ATmega1280__) - #define _AVR_CPU_NAME_ "ATmega1280" -#elif defined (__AVR_ATmega1281__) - #define _AVR_CPU_NAME_ "ATmega1281" -#elif defined (__AVR_ATmega1284P__) - #define _AVR_CPU_NAME_ "ATmega1284" -#elif defined (__AVR_ATmega2560__) - #define _AVR_CPU_NAME_ "ATmega2560" -#elif defined (__AVR_ATmega2561__) - #define _AVR_CPU_NAME_ "ATmega2561" -#elif defined (__AVR_AT90CAN32__) - #define _AVR_CPU_NAME_ "AT90CAN32" -#elif defined (__AVR_AT90CAN64__) - #define _AVR_CPU_NAME_ "AT90CAN64" -#elif defined (__AVR_AT90CAN128__) - #define _AVR_CPU_NAME_ "AT90CAN128" -#elif defined (__AVR_AT90USB82__) - #define _AVR_CPU_NAME_ "AT90USB82" -#elif defined (__AVR_AT90USB162__) - #define _AVR_CPU_NAME_ "AT90USB162" -#elif defined (__AVR_AT90USB646__) - #define _AVR_CPU_NAME_ "AT90USB646" -#elif defined (__AVR_AT90USB647__) - #define _AVR_CPU_NAME_ "AT90USB647" -#elif defined (__AVR_AT90USB1286__) - #define _AVR_CPU_NAME_ "AT90USB1286" -#elif defined (__AVR_AT90USB1287__) - #define _AVR_CPU_NAME_ "AT90USB1287" -#elif defined (__AVR_ATmega64__) - #define _AVR_CPU_NAME_ "ATmega64" -#elif defined (__AVR_ATmega640__) - #define _AVR_CPU_NAME_ "ATmega640" -#elif defined (__AVR_ATmega644__) - #define _AVR_CPU_NAME_ "ATmega644" -#elif defined (__AVR_ATmega644P__) - #define _AVR_CPU_NAME_ "ATmega644P" -#elif defined (__AVR_ATmega645__) - #define _AVR_CPU_NAME_ "ATmega645" -#elif defined (__AVR_ATmega6450__) - #define _AVR_CPU_NAME_ "ATmega6450" -#elif defined (__AVR_ATmega649__) - #define _AVR_CPU_NAME_ "ATmega649" -#elif defined (__AVR_ATmega6490__) - #define _AVR_CPU_NAME_ "ATmega6490" -#elif defined (__AVR_ATmega103__) - #define _AVR_CPU_NAME_ "ATmega103" -#elif defined (__AVR_ATmega32__) - #define _AVR_CPU_NAME_ "Atmega32" -#elif defined (__AVR_ATmega323__) - #define _AVR_CPU_NAME_ "ATmega323" -#elif defined (__AVR_ATmega324P__) - #define _AVR_CPU_NAME_ "ATmega324P" -#elif defined (__AVR_ATmega325__) - #define _AVR_CPU_NAME_ "ATmega325" -#elif defined (__AVR_ATmega325P__) - #define _AVR_CPU_NAME_ "ATmega325P" -#elif defined (__AVR_ATmega3250__) - #define _AVR_CPU_NAME_ "ATmega3250" -#elif defined (__AVR_ATmega3250P__) - #define _AVR_CPU_NAME_ "ATmega3250P" -#elif defined (__AVR_ATmega328P__) - #define _AVR_CPU_NAME_ "ATmega328P" -#elif defined (__AVR_ATmega329__) - #define _AVR_CPU_NAME_ "ATmega329" -#elif defined (__AVR_ATmega329P__) - #define _AVR_CPU_NAME_ "ATmega329P" -#elif defined (__AVR_ATmega3290__) - #define _AVR_CPU_NAME_ "ATmega3290" -#elif defined (__AVR_ATmega3290P__) - #define _AVR_CPU_NAME_ "ATmega3290P" -#elif defined (__AVR_ATmega32HVB__) - #define _AVR_CPU_NAME_ "ATmega32HVB" -#elif defined (__AVR_ATmega406__) - #define _AVR_CPU_NAME_ "ATmega406" -#elif defined (__AVR_ATmega16__) - #define _AVR_CPU_NAME_ "Atmega16" -#elif defined (__AVR_ATmega161__) - #define _AVR_CPU_NAME_ "ATmega161" -#elif defined (__AVR_ATmega162__) - #define _AVR_CPU_NAME_ "ATmega162" -#elif defined (__AVR_ATmega163__) - #define _AVR_CPU_NAME_ "ATmega163" -#elif defined (__AVR_ATmega164P__) - #define _AVR_CPU_NAME_ "ATmega164P" -#elif defined (__AVR_ATmega165__) - #define _AVR_CPU_NAME_ "ATmega165" -#elif defined (__AVR_ATmega165P__) - #define _AVR_CPU_NAME_ "ATmega165P" -#elif defined (__AVR_ATmega168__) - #define _AVR_CPU_NAME_ "ATmega168" -#elif defined (__AVR_ATmega168P__) - #define _AVR_CPU_NAME_ "ATmega168P" -#elif defined (__AVR_ATmega169__) - #define _AVR_CPU_NAME_ "Atmega169" -#elif defined (__AVR_ATmega169P__) - #define _AVR_CPU_NAME_ "ATmega169P" -#elif defined (__AVR_ATmega8HVA__) - #define _AVR_CPU_NAME_ "ATmega8HVA" -#elif defined (__AVR_ATmega16HVA__) - #define _AVR_CPU_NAME_ "ATmega16HVA" -#elif defined (__AVR_ATmega8__) - #define _AVR_CPU_NAME_ "ATmega8" -#elif defined (__AVR_ATmega48__) - #define _AVR_CPU_NAME_ "ATmega48" -#elif defined (__AVR_ATmega48P__) - #define _AVR_CPU_NAME_ "ATmega48P" -#elif defined (__AVR_ATmega88__) - #define _AVR_CPU_NAME_ "ATmega88" -#elif defined (__AVR_ATmega88P__) - #define _AVR_CPU_NAME_ "ATmega88P" -#elif defined (__AVR_ATmega8515__) - #define _AVR_CPU_NAME_ "ATmega8515" -#elif defined (__AVR_ATmega8535__) - #define _AVR_CPU_NAME_ "ATmega8535" -#elif defined (__AVR_AT90S8535__) -#elif defined (__AVR_AT90C8534__) -#elif defined (__AVR_AT90S8515__) -#elif defined (__AVR_AT90S4434__) -#elif defined (__AVR_AT90S4433__) -#elif defined (__AVR_AT90S4414__) -#elif defined (__AVR_ATtiny22__) -#elif defined (__AVR_ATtiny26__) -#elif defined (__AVR_AT90S2343__) -#elif defined (__AVR_AT90S2333__) -#elif defined (__AVR_AT90S2323__) -#elif defined (__AVR_AT90S2313__) -#elif defined (__AVR_ATtiny2313__) - #define _AVR_CPU_NAME_ "ATtiny2313" -#elif defined (__AVR_ATtiny13__) -#elif defined (__AVR_ATtiny13A__) -#elif defined (__AVR_ATtiny25__) -#elif defined (__AVR_ATtiny45__) -#elif defined (__AVR_ATtiny85__) -#elif defined (__AVR_ATtiny24__) -#elif defined (__AVR_ATtiny44__) -#elif defined (__AVR_ATtiny84__) -#elif defined (__AVR_ATtiny261__) -#elif defined (__AVR_ATtiny461__) -#elif defined (__AVR_ATtiny861__) -#elif defined (__AVR_ATtiny43U__) -#elif defined (__AVR_ATtiny48__) -#elif defined (__AVR_ATtiny88__) -#elif defined (__AVR_ATtiny167__) - -#else - #error cpu not defined -#endif - - -#if !defined (_AVR_CPU_NAME_) -// #define _AVR_CPU_NAME_ "UNKNOWN" -#endif diff --git a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.ino b/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.ino deleted file mode 100644 index fc3aab765..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.ino +++ /dev/null @@ -1,74 +0,0 @@ -//************************************************************************ -//* Arduino Test of Arduino Constants -//* (C) 2010 by Rick Anderson -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Oct 16, 2010 Test of Arduino Constants -//************************************************************************ - -#include - -//************************************************************************ -void setup() -{ - int startMemoryUsage; - - //Start memory usage must be site prior to ATS_begin - startMemoryUsage = ATS_GetFreeMemory(); - ATS_begin("Arduino", "Test of Arduino Constants"); - /* - * Test Run Start - */ - - - //test true constant - ATS_PrintTestStatus("1. Test of true constant", true == 1); - - //test false consts - ATS_PrintTestStatus( "2. Test of false constant", false == 0); - - //Test of HIGH == 1 - ATS_PrintTestStatus( "3. Test of HIGH == 1", HIGH == 1); - - //Test of LOW == 0 - ATS_PrintTestStatus( "4. Test of LOW == 0", LOW == 0); - - //Test of INPUT == 1 - ATS_PrintTestStatus( "5. Test of INPUT == 1", HIGH == 1); - - //Test of OUTPUT == 0 - ATS_PrintTestStatus( "6. Test of OUTPUT == 0", LOW == 0); - - //test decimal - ATS_PrintTestStatus( "7. Test of decimal constant", 101 == ((1 * pow(10,2)) + (0 * pow(10,1)) + 1)); - - //test binary - ATS_PrintTestStatus( "8. Test of binary constant", B101 == 5); - - //test octal - ATS_PrintTestStatus( "9. Test of octal constant", 0101 == 65); - - //test hexadecimal - ATS_PrintTestStatus( "7. Test of hexadecimal constant", (0x101 == 257)); - - /* - * Test Run End - */ - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.ino b/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.ino deleted file mode 100644 index 111302e38..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.ino +++ /dev/null @@ -1,101 +0,0 @@ -//************************************************************************ -//* Arduino Test Suite -//* ATS_ToneTest -//* -//* Copyright (c) 2010 Mark Sproul All right reserved. -//* -//* This library is free software; you can redistribute it and/or -//* modify it under the terms of the GNU Lesser General Public -//* License as published by the Free Software Foundation; either -//* version 2.1 of the License, or (at your option) any later version. -//* -//* This library is distributed in the hope that it will be useful, -//* but WITHOUT ANY WARRANTY; without even the implied warranty of -//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//* Lesser General Public License for more details. -//* -//* You should have received a copy of the GNU Lesser General Public -//* License along with this library; if not, write to the Free Software -//* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//* Oct 28, 2010 Started on Delay -//************************************************************************ - -#include - -//************************************************************************ -void setup() -{ -short ii; -short testNum; -int startMemoryUsage; -unsigned long startMillis; -unsigned long endMillis; -unsigned long deltaMillis; -unsigned long errMillis; -boolean passed; -char testNameString[80]; - - - startMemoryUsage = ATS_GetFreeMemory(); - - ATS_begin("Arduino", "DelayTest"); - - testNum = 1; - //* we start at 2 because 0/1 are RXD/TXD - for (ii=0; ii<1000; ii+= 15) - { - startMillis = millis(); - - delay(ii); - - endMillis = millis(); - - deltaMillis = endMillis - startMillis; - - if (deltaMillis >= ii) - { - errMillis = deltaMillis - ii; - } - else - { - errMillis = ii - deltaMillis; - } - - if (errMillis <= 1) - { - passed = true; - } - else - { - passed = false; - } - sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); - - ATS_PrintTestStatus(testNameString, passed); - - - testNum++; - } - - - - - ATS_ReportMemoryUsage(startMemoryUsage); - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.ino b/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.ino deleted file mode 100644 index 588342dca..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.ino +++ /dev/null @@ -1,95 +0,0 @@ -//************************************************************************ -//* Arduino Test Suite -//* (C) 2010 by Mark Sproul -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//* Oct 18, 2010 Added memory testing -//************************************************************************ - -#include - -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) -#define kBoard_PinCount 20 -#define kBoard_AnalogCount 6 -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define kBoard_PinCount 70 -#define kBoard_AnalogCount 16 - -#elif defined(CORE_TEENSY) -#define kBoard_PinCount CORE_NUM_TOTAL_PINS -#define kBoard_AnalogCount CORE_NUM_ANALOG -#define SERIAL_PORT_COUNT 2 -HardwareSerial Serial1 = HardwareSerial(); -#endif - - - - -//************************************************************************ -void setup() -{ - short ii; - uint8_t timerNumber; - int startMemoryUsage; - - startMemoryUsage = ATS_GetFreeMemory(); - - ATS_begin("Arduino", "general"); - - //* test digital pins - //* we start at 2 because 0/1 are RXD/TXD - for (ii=2; ii 1) - ATS_TestSerialLoopback(&Serial1, "Serial1"); -#endif -#if (SERIAL_PORT_COUNT > 2) - ATS_TestSerialLoopback(&Serial2, "Serial2"); -#endif -#if (SERIAL_PORT_COUNT > 3) - ATS_TestSerialLoopback(&Serial3, "Serial3"); -#endif - - ATS_Test_EEPROM(); - - - ATS_ReportMemoryUsage(startMemoryUsage); - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.ino b/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.ino deleted file mode 100644 index fefd6b07d..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.ino +++ /dev/null @@ -1,106 +0,0 @@ -// Tests writing to and reading from a file, in particular the -// the Stream implementation (e.g. read() and peek()). - -#include -#include - -void setup() -{ - int startMemoryUsage = ATS_GetFreeMemory(); - boolean b; - File f; - - ATS_begin("Arduino", "SD Test"); - - ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); - if (!b) goto done; - - SD.remove("test.txt"); - - f = SD.open("test.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - f.print("abc"); - f.print("de"); - f.close(); - - f = SD.open("test.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - f.print("fgh"); - f.close(); - - f = SD.open("test.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("read()", f.read() == 'a'); - ATS_PrintTestStatus("peek()", f.peek() == 'b'); - ATS_PrintTestStatus("read()", f.read() == 'b'); - ATS_PrintTestStatus("read()", f.read() == 'c'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("read()", f.read() == 'd'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("read()", f.read() == 'e'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("peek()", f.peek() == 'f'); - ATS_PrintTestStatus("read()", f.read() == 'f'); - ATS_PrintTestStatus("peek()", f.peek() == 'g'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("peek()", f.peek() == 'g'); - ATS_PrintTestStatus("read()", f.read() == 'g'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("peek()", f.peek() == 'h'); - ATS_PrintTestStatus("read()", f.read() == 'h'); - ATS_PrintTestStatus("available()", f.available() == 0); - ATS_PrintTestStatus("peek()", f.peek() == -1); - ATS_PrintTestStatus("read()", f.read() == -1); - ATS_PrintTestStatus("peek()", f.peek() == -1); - ATS_PrintTestStatus("read()", f.read() == -1); - - f.close(); - - SD.remove("test2.txt"); - - f = SD.open("test2.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - f.print("ABC"); - f.close(); - - f = SD.open("test.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("peek()", f.peek() == 'a'); - - f.close(); - - f = SD.open("test2.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("peek()", f.peek() == 'A'); - ATS_PrintTestStatus("read()", f.read() == 'A'); - - f.close(); - -done: - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - -void loop() {} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.ino b/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.ino deleted file mode 100644 index c3804f4de..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.ino +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - -void setup() -{ - int startMemoryUsage = ATS_GetFreeMemory(); - boolean b; - File f; - - ATS_begin("Arduino", "SD Files Test"); - - ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); - if (!b) goto done; - - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); - ATS_PrintTestStatus("SD.open()", f = SD.open("asdf.txt", FILE_WRITE)); f.close(); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf.txt")); - ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf.txt")); - ATS_PrintTestStatus("SD.remove()", SD.remove("asdf.txt")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); - - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - - ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("x/y/z")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("/x/y/z/")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/z")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("/x")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); - - ATS_PrintTestStatus("!SD.open()", !(f = SD.open("asdf/asdf.txt", FILE_WRITE))); f.close(); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.open()", f = SD.open("asdf/asdf.txt", FILE_WRITE)); f.close(); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("!SD.rmdir()", !SD.rmdir("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("SD.remove()", SD.remove("asdf/asdf.txt")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - -done: - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - -void loop() {} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.ino b/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.ino deleted file mode 100644 index 5b0916ca7..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.ino +++ /dev/null @@ -1,109 +0,0 @@ -// Tests writing to and reading from a file, in particular the -// the Stream implementation (e.g. read() and peek()). - -#include -#include - -void setup() -{ - int startMemoryUsage = ATS_GetFreeMemory(); - boolean b; - File f; - - ATS_begin("Arduino", "SD Test"); - - ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); - if (!b) goto done; - - SD.remove("test.txt"); - - f = SD.open("test.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("initial position", f.position() == 0); - ATS_PrintTestStatus("initial size", f.size() == 0); - - f.print("0123456789"); - - ATS_PrintTestStatus("position after writing", f.position() == 10); - ATS_PrintTestStatus("size after writing", f.size() == 10); - - f.seek(0); - - ATS_PrintTestStatus("size after seek", f.size() == 10); - ATS_PrintTestStatus("position after seek", f.position() == 0); - - f.seek(7); - - ATS_PrintTestStatus("position after seek", f.position() == 7); - ATS_PrintTestStatus("reading after seek", f.read() == '7'); - ATS_PrintTestStatus("position after reading after seeking", f.position() == 8); - ATS_PrintTestStatus("reading after reading after seeking", f.read() == '8'); - - f.seek(3); - - ATS_PrintTestStatus("position after seeking", f.position() == 3); - ATS_PrintTestStatus("peeking after seeking", f.peek() == '3'); - ATS_PrintTestStatus("position after peeking after seeking", f.position() == 3); - ATS_PrintTestStatus("peeking after peeking after seeking", f.peek() == '3'); - ATS_PrintTestStatus("position after peeking after seeking", f.position() == 3); - ATS_PrintTestStatus("peeking after peeking after seeking", f.read() == '3'); - ATS_PrintTestStatus("position after peeking after seeking", f.position() == 4); - - f.seek(1); - - ATS_PrintTestStatus("position after seeking", f.position() == 1); - ATS_PrintTestStatus("peeking after seeking", f.peek() == '1'); - - f.seek(4); - - ATS_PrintTestStatus("position after seeking", f.position() == 4); - ATS_PrintTestStatus("peeking after seeking", f.peek() == '4'); - - f.seek(7); - - ATS_PrintTestStatus("position()", f.position() == 7); - ATS_PrintTestStatus("read()", f.read() == '7'); - - f.seek(0); - f.peek(); - f.print("AB"); - - ATS_PrintTestStatus("position()", f.position() == 2); - ATS_PrintTestStatus("size()", f.size() == 10); - ATS_PrintTestStatus("read()", f.read() == '2'); - - f.seek(0); - - ATS_PrintTestStatus("read()", f.read() == 'A'); - ATS_PrintTestStatus("read()", f.read() == 'B'); - ATS_PrintTestStatus("read()", f.read() == '2'); - - f.close(); - - f = SD.open("test.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("position()", f.position() == 0); - ATS_PrintTestStatus("size()", f.size() == 10); - ATS_PrintTestStatus("peek()", f.peek() == 'A'); - ATS_PrintTestStatus("read()", f.read() == 'A'); - - f.seek(4); - - ATS_PrintTestStatus("position()", f.position() == 4); - ATS_PrintTestStatus("size()", f.size() == 10); - ATS_PrintTestStatus("peek()", f.peek() == '4'); - ATS_PrintTestStatus("read()", f.read() == '4'); - - f.close(); - -done: - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - -void loop() {} diff --git a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.ino b/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.ino deleted file mode 100644 index 58ecaff6c..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.ino +++ /dev/null @@ -1,50 +0,0 @@ -//************************************************************************ -//* Arduino Test Example Skeleton -//* (C) 2010 by Rick Anderson -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Oct 16, 2010 Started on String Test -//************************************************************************ - -#include - -//************************************************************************ -void setup() -{ - int startMemoryUsage; - - //startMemoryUsage must be set directly before ATS_begin - startMemoryUsage = ATS_GetFreeMemory(); - ATS_begin("Arduino", "Skeleton Test"); - /* - * Test Run Start - * Test one passes because result is set to true - * Test two fails becuase result is set to false - * You can test memory for any set of tests by using the ATS_ReportMemoryUsage test - * There is also a way to print current memeory for debugging - */ - ATS_PrintTestStatus("1. Test of true test status", true); - - ATS_PrintTestStatus("2. Test of false test status, this will fail.", false); - - ATS_ReportMemoryUsage(startMemoryUsage); - /* - * Test Run End - */ - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.ino b/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.ino deleted file mode 100644 index 2de273ece..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.ino +++ /dev/null @@ -1,104 +0,0 @@ -//************************************************************************ -//* Arduino Test Example Skeleton -//* (C) 2010 by Rick Anderson -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Oct 16, 2010 Started on String Test -//************************************************************************ - -#include - -//************************************************************************ - -void do_string_operations(int startMemoryUsage) -{ - String stringOne; - int firstClosingBracket; - int firstOpeningBracket; - int secondOpeningBracket; - int secondClosingBracket; - int bodyTag; - int firstListItem; - int secondListItem; - int lastOpeningBracket; - int lastListItem; - int lastParagraph; - int secondLastParagraph; - int thirdLastParagraph; - - // 1111111111 - // 01234567890123456789 - stringOne = ""; - firstClosingBracket = stringOne.indexOf('>'); - ATS_PrintTestStatus("firstClosingBracket", firstClosingBracket == 5); - - // 1111111111 - // 01234567890123456789 - stringOne = ""; - secondOpeningBracket = firstClosingBracket + 1; - secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); - ATS_PrintTestStatus("secondClosingBracket", secondClosingBracket == 11); - - // you can also use indexOf() to search for Strings: - // 1111111111 - // 01234567890123456789 - stringOne = ""; - bodyTag = stringOne.indexOf(""); - ATS_PrintTestStatus("bodyTag", bodyTag == 12); - - // 111111111122222222223333333333 - // 0123456789012345678901234567890123456789 - stringOne = "
  • item
  • item
  • item
"; - firstListItem = stringOne.indexOf("
  • "); - secondListItem = stringOne.indexOf("
  • ", firstListItem + 1 ); - - ATS_PrintTestStatus("firstListItem", firstListItem == 4); - ATS_PrintTestStatus("secondListItem", secondListItem == 12); - - // lastIndexOf() gives you the last occurrence of a character or string: - lastOpeningBracket = stringOne.lastIndexOf('<'); - ATS_PrintTestStatus("lastOpeningBracket", lastOpeningBracket == 28); - - lastListItem = stringOne.lastIndexOf("
  • "); - ATS_PrintTestStatus("lastListItem", lastListItem == 20); - - // lastIndexOf() can also search for a string: - // 11111111112222222222333333333344444444445555555555 - // 012345678901234567890123456789012345678901234567890123456789 - stringOne = "

    Lorem ipsum dolor sit amet

    Ipsem

    Quod

    "; - lastParagraph = stringOne.lastIndexOf(" Started on String Test -//************************************************************************ - -#include - -//************************************************************************ -void setup() -{ - - int startMemoryUsage; - - ATS_begin("Arduino", "Test of String Library"); - - /* - * Test Variable Setup - * Best practive set all your test variables prior to teseting. - * This is required for Memory tests. - */ - - String stringOne = String("stringThree = "); - String stringTwo = String("this string"); - String stringThree = String (); - char charResult[100]; - - - - /* - * Run the tests - */ - - // adding a constant integer to a string: - stringThree = stringOne + 123; - //strcpy(charResult, "\0"); - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("1. Adding a constant integer to a string:", strcmp(charResult,"stringThree = 123" ) == 0); - - // adding a constant long interger to a string: - stringThree = stringOne + 123456789; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("2. Adding a constant long interger to a string", strcmp(charResult,"stringThree = 123456789" ) == 0); - - - // adding a constant character to a string: - stringThree = stringOne + 'A'; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("3. Adding a constant character to a string", strcmp(charResult,"stringThree = A" ) == 0); - - - // adding a constant string to a string: - stringThree = stringOne + "abc"; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("4. Adding a constant string variable to a string", strcmp(charResult,"stringThree = abc" ) == 0); - - //"5. Adding a constant long interger to a string" - stringThree = stringOne + stringTwo; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("5. Adding a constant long interger to a string", strcmp(charResult,"stringThree = this string" ) == 0); - - - /* - * setup up String Comparison Operater Tests - */ - - stringOne = String("this"); - stringTwo = String("that"); - - // two strings equal: - ATS_PrintTestStatus("6. Two strings equal",stringOne == "this"); - - // two strings not equal: - ATS_PrintTestStatus("7. Two strings not equal",stringOne != stringTwo); - - // two strings not equal (case sensitivity matters): - stringOne = "This"; - stringTwo = "this"; - ATS_PrintTestStatus("8. Two strings not equal [case sensitivity matters]", stringOne != stringTwo); - - // you can also use equals() to see if two strings are the same: - stringOne = "this"; - stringTwo = "this"; - ATS_PrintTestStatus("9. Equals() method equals", stringOne.equals(stringTwo)); - - - // you can also use not equals() to see if two strings are not the same: - stringOne = String("This"); - stringTwo = String("this"); - ATS_PrintTestStatus("10. Not equals() method equals", !stringOne.equals(stringTwo)); - - // or perhaps you want to ignore case: - ATS_PrintTestStatus("11. EqualsIgnoreCase() method equals", stringOne.equalsIgnoreCase(stringTwo)); - -#if ARDUINO < 100 || defined(CORE_TEENSY) -// David Mellis decided not to keep implicit string to number comparison operators -// in Arduino 1.0. Only run this test on older version, or if using Teensy - // a numeric string compared to the number it represents: - stringOne = "1"; - int numberOne = 1; - ATS_PrintTestStatus("12. A numeric string compared to the number it represents", stringOne == numberOne); -#endif - - // two numeric strings compared: - stringOne = "2"; - stringTwo = "1"; - ATS_PrintTestStatus("13. Two numeric strings compared",stringOne >= stringTwo); - - - // comparison operators can be used to compare strings for alphabetic sorting too: - -/* - stringOne = String("Brown"); - ATS_PrintTestStatus("14. comparison operator < can be used to compare strings for alphabetic sorting ",stringOne < "Charles"); - ATS_PrintTestStatus("15. comparison operator > can be used to compare strings for alphabetic sorting ",stringOne > "Adams"); - ATS_PrintTestStatus("16. comparison operator <= can be used to compare strings for alphabetic sorting ",stringOne <= "Browne"); - ATS_PrintTestStatus("17. comparison operator >= can be used to compare strings for alphabetic sorting ",stringOne >= "Brow"); - */ - - - // the compareTo() operator also allows you to compare strings - stringOne = "Cucumber"; - stringTwo = "Cucuracha"; - - ATS_PrintTestStatus("18. The compareTo() operator also allows you to compare strings", stringOne.compareTo(stringTwo) < 0); - - // These two tests assume the string compare parses numbers - // within strings, but it does not actually do any such thing - // compareTo() String with numnber > String with number: - //stringOne = "Sensor: 50"; - //stringTwo= "Sensor: 150"; - //ATS_PrintTestStatus("19. The compareTo() String with integers", stringOne.compareTo(stringTwo) < 0); -// compareTo() String with numnber > String with number append integer, matches example code: - //stringOne = "Sensor: "; - //stringTwo= "Sensor: "; - //stringOne += 50; - //stringTwo += 150; - //ATS_PrintTestStatus("20. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); - - - /* - * setup up String Append Operation Tests - */ - // Serious awful problem here - stringOne = String("Sensor "); - stringTwo = String("value"); - - stringOne += stringTwo; - ATS_PrintTestStatus("21. Adding string to string += ", stringOne.equals("Sensor value")); - - ATS_PrintTestStatus("22. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); - /* - * Test complete - */ - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - - - - - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.ino b/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.ino deleted file mode 100644 index fc611bb67..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.ino +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include "Test_Equal.h" - -void setup() -{ - ATS_begin("Arduino", "String Addition Test"); - - String stringOne = String("string"); - String stringTwo = String("other"); - String stringThree = stringOne + stringTwo; - - Test_Equal("Add strings", "stringother", stringThree); - Test_Equal("Adding strings doesn't change them", "string", stringOne); - Test_Equal("Adding strings doesn't change them", "other", stringTwo); - Test_Equal("Add strings", "stringotherstringstringstringother", stringOne + stringTwo + stringOne + stringOne + stringOne + stringTwo); - Test_Equal("Add string to integer", "string12345", stringOne + 12345); - Test_Equal("Add string to negative integer", "string-12345", stringOne + -12345); - Test_Equal("Add integer to string", "123string", 123 + stringOne); - Test_Equal("Add string to integers", "string123456789", stringOne + 123 + 456 + 789); - Test_Equal("Add integer to string", "123string456789", 123 + stringOne + 456 + 789); - Test_Equal("Add string to long", "string123456789", stringOne + 123456789L); - Test_Equal("Add string to negative long", "string-123456789", stringOne + -123456789L); - Test_Equal("Add string to unsigned long", "string123456789", stringOne + 123456789UL); - Test_Equal("Add string to byte", "string123", stringOne + byte(123)); - Test_Equal("Add char", "stringA", stringOne + 'A'); - Test_Equal("Add char", "Astring", 'A' + stringOne); - Test_Equal("Add \"string\"", "stringabc", stringOne + "abc"); - Test_Equal("Add \"string\"", "abcstring", "abc" + stringOne); - Test_Equal("Add multiple \"string\"", "stringabcdef", stringOne + "abc" + "def"); - Test_Equal("Add multiple \"string\"", "abcstringdef", "abc" + stringOne + "def"); - Test_Equal("Add \"string\" and int", "bc", "abc" + 1); - - ATS_end(); -} - -void loop() {} - - - - - - - - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/Test_Equal.h b/libraries/ArduinoTestSuite/examples/ATS_String_Addition/Test_Equal.h deleted file mode 100644 index 80dbc848b..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/Test_Equal.h +++ /dev/null @@ -1,13 +0,0 @@ -void Test_Equal(char *testString, char *expected, const String &actual) -{ - char buf[100]; actual.toCharArray(buf, 100); - boolean b = (strcmp(buf, expected) == 0); - ATS_PrintTestStatus(testString, b); - if (!b) { - Serial.print("expected '"); - Serial.print(expected); - Serial.print("', actual '"); - Serial.print(actual); - Serial.println("'"); - } -} diff --git a/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.ino b/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.ino deleted file mode 100644 index 195a3ca18..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.ino +++ /dev/null @@ -1,248 +0,0 @@ -//************************************************************************ -//* Arduino Test Suite -//* ATS_ToneTest -//* -//* Copyright (c) 2010 Mark Sproul All right reserved. -//* -//* This library is free software; you can redistribute it and/or -//* modify it under the terms of the GNU Lesser General Public -//* License as published by the Free Software Foundation; either -//* version 2.1 of the License, or (at your option) any later version. -//* -//* This library is distributed in the hope that it will be useful, -//* but WITHOUT ANY WARRANTY; without even the implied warranty of -//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//* Lesser General Public License for more details. -//* -//* You should have received a copy of the GNU Lesser General Public -//* License along with this library; if not, write to the Free Software -//* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//* Oct 23, 2010 Started on ToneTest -//************************************************************************ - -#include - -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) - #define kBoard_PinCount 20 - #define kBoard_AnalogCount 6 -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - #define kBoard_PinCount 70 - #define kBoard_AnalogCount 16 -#elif defined(CORE_TEENSY) - #define kBoard_PinCount CORE_NUM_TOTAL_PINS - #define kBoard_AnalogCount CORE_NUM_ANALOG -#endif - -//************************************************************************ -void TestTonePin(uint8_t toneOutputPinNumber) -{ -uint8_t helperpin; -unsigned long startMilliSecs; -unsigned long highCount, lowCount; -int previousState; -int currentState; -char testNameString[80]; -long outputFreq; -long measuredFreq; -boolean passed; -long percentError; -long deltaFreq; - - if ((toneOutputPinNumber % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = toneOutputPinNumber + 1; - } - else - { - //* if its ODD - helperpin = toneOutputPinNumber - 1; - } - if (helperpin >= kBoard_PinCount) return; - - //* dont set the mode of the OUTPUT pin, the tone command does that - - pinMode(helperpin, INPUT); - - previousState = digitalRead(helperpin); - startMilliSecs = millis(); - highCount = 0; - lowCount = 0; - measuredFreq = 0; - //* we are going to watch for one second - outputFreq = random(200, 2000); - - tone(toneOutputPinNumber, outputFreq); - while ((millis() - startMilliSecs) < 1000) - { - currentState = digitalRead(helperpin); - if (currentState == HIGH) - { - highCount++; - } - else - { - lowCount++; - } - //* check to see if it changed state - if ((currentState == HIGH) && (previousState == LOW)) - { - measuredFreq++; - } - - previousState = currentState; - } - noTone(toneOutputPinNumber); - - deltaFreq = abs(measuredFreq - outputFreq); - - percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); - - sprintf(testNameString, "ToneTest.%02d (out freq= %4ld measured freq= %4ld err= %ld%%)", toneOutputPinNumber, outputFreq, measuredFreq, percentError); - if (percentError < 5) - { - passed = true; - } - else - { - passed = false; - } - - ATS_PrintTestStatus(testNameString, passed); -} - - -//************************************************************************ -//* this test to make sure the duration option works -void TestToneDuration(uint8_t toneOutputPinNumber) -{ -uint8_t helperpin; -unsigned long startMilliSecs; -unsigned long highCount, lowCount; -int previousState; -int currentState; -char testNameString[80]; -long outputFreq; -long measuredFreq; -boolean passed; -long percentError; -long deltaFreq; -long durationTime; - - if ((toneOutputPinNumber % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = toneOutputPinNumber + 1; - } - else - { - //* if its ODD - helperpin = toneOutputPinNumber - 1; - } - if (helperpin >= kBoard_PinCount) return; - - //* dont set the mode of the OUTPUT pin, the tone command does that - - pinMode(helperpin, INPUT); - - previousState = digitalRead(helperpin); - startMilliSecs = millis(); - highCount = 0; - lowCount = 0; - measuredFreq = 0; - durationTime = 0; - //* we are going to watch for one second - outputFreq = random(500, 2000); - - tone(toneOutputPinNumber, outputFreq, 1000); - while ((millis() - startMilliSecs) < 2000) - { - currentState = digitalRead(helperpin); - if (currentState == HIGH) - { - highCount++; - } - else - { - lowCount++; - } - //* count the freq - if ((currentState == HIGH) && (previousState == LOW)) - { - measuredFreq++; - } - - //* check to see if it changed state - if (currentState != previousState) - { - durationTime = millis() - startMilliSecs; - } - - previousState = currentState; - } - - deltaFreq = abs(measuredFreq - outputFreq); - - percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); - - sprintf(testNameString, "ToneTesDurationt.%02d (durationTime =%4ld/1000 freq err= %ld%%)", toneOutputPinNumber, durationTime, percentError); - if ((durationTime > 990) && (durationTime < 1010) && (percentError < 5)) - { - passed = true; - } - else - { - passed = false; - } - noTone(toneOutputPinNumber); - - ATS_PrintTestStatus(testNameString, passed); -} - - - -//************************************************************************ -void setup() -{ -short ii; -uint8_t timerNumber; -int startMemoryUsage; - - startMemoryUsage = ATS_GetFreeMemory(); - - ATS_begin("Arduino", "ToneTest"); - - - //* we start at 2 because 0/1 are RXD/TXD - for (ii=2; ii - -void Test_Equal(long actual, long expected) -{ - char buf[100]; - boolean b = expected == actual; - ATS_PrintTestStatus("", b); - if (!b) { - Serial.print("expected '"); - Serial.print(expected); - Serial.print("', actual '"); - Serial.print(actual); - Serial.println("'"); - } -} - -void setup() -{ - byte buf[5] = { 65, 66, 67, 0, 69 }; - ATS_begin("Arduino", "Write & Print Return Values Test"); - - Test_Equal(Serial.write('a'), 1); - Test_Equal(Serial.write(byte(0)), 1); - Test_Equal(Serial.write("abc"), 3); - Test_Equal(Serial.write(""), 0); - Test_Equal(Serial.write(buf, 5), 5); - Test_Equal(Serial.print(0), 1); - Test_Equal(Serial.print(""), 0); - Test_Equal(Serial.print("abc"), 3); - Test_Equal(Serial.print(0), 1); - Test_Equal(Serial.print(1), 1); - Test_Equal(Serial.print(11), 2); - Test_Equal(Serial.print(12345), 5); - Test_Equal(Serial.print(-1), 2); - Test_Equal(Serial.print(-123), 4); - Test_Equal(Serial.println(), 2); - Test_Equal(Serial.println(""), 2); - Test_Equal(Serial.println("abc"), 5); - Test_Equal(Serial.println(0), 3); - Test_Equal(Serial.println(1), 3); - Test_Equal(Serial.println(11), 4); - Test_Equal(Serial.println(12345), 7); - Test_Equal(Serial.println(-1), 4); - Test_Equal(Serial.println(-123), 6); - - ATS_end(); -} - -void loop() {} - - - - - - - - - - - -