mbed-os/features/unsupported/tests/mbed/digitalinout/main.cpp

128 lines
2.8 KiB
C++
Raw Normal View History

#include "test_env.h"
2014-04-07 15:56:13 +00:00
#if defined(TARGET_LPC1114)
DigitalInOut d1(dp1);
DigitalInOut d2(dp2);
#elif defined(TARGET_LPC1549)
// TARGET_FF_ARDUINO cannot be used, because D0 is used as USBRX (USB serial
// port pin), D1 is used as USBTX
DigitalInOut d1(D2);
DigitalInOut d2(D7);
2016-10-12 08:07:27 +00:00
#elif defined(TARGET_STM) && defined(TARGET_FF_ARDUINO)
// TARGET_FF_ARDUINO cannot be used
// D0 is used as USBRX for some NUCLEO64
// D7 is not used for some NUCLEO32
DigitalInOut d1(D3);
2016-10-12 08:07:27 +00:00
DigitalInOut d2(D2);
2016-10-12 08:07:27 +00:00
#elif defined(TARGET_DISCO_L053C8) || \
defined(TARGET_DISCO_F334C8)
DigitalInOut d1(PA_15);
DigitalInOut d2(PA_8);
#elif defined(TARGET_DISCO_L476VG)
DigitalInOut d1(PA_1);
DigitalInOut d2(PA_2);
#elif defined(TARGET_ARCH_MAX) || \
defined(TARGET_DISCO_F407VG) || \
defined(TARGET_DISCO_F429ZI)|| \
defined(TARGET_DISCO_F401VC)
DigitalInOut d1(PC_12);
DigitalInOut d2(PD_0);
2014-04-07 15:56:13 +00:00
#elif defined(TARGET_FF_ARDUINO)
DigitalInOut d1(D0);
DigitalInOut d2(D7);
2014-10-09 16:54:03 +00:00
#elif defined(TARGET_MAXWSNENV)
DigitalInOut d1(TP3);
DigitalInOut d2(TP4);
#elif defined(TARGET_MAX32600MBED)
DigitalInOut d1(P1_0);
DigitalInOut d2(P4_7);
#elif defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32GG_STK3700) || defined(TARGET_EFM32WG_STK3800)
DigitalInOut d1(PD0);
2015-05-27 14:07:40 +00:00
DigitalInOut d2(PC3);
#elif defined(TARGET_EFM32ZG_STK3200)
DigitalInOut d1(PD7);
DigitalInOut d2(PC1);
#elif defined(TARGET_EFM32HG_STK3400)
DigitalInOut d1(PE10);
DigitalInOut d2(PC1);
2016-01-04 10:29:26 +00:00
#elif defined(TARGET_EFM32PG_STK3401)
DigitalInOut d1(PC6);
DigitalInOut d2(PA3);
2016-01-04 10:29:26 +00:00
#elif defined(TARGET_SAMR21G18A) || defined(TARGET_SAMD21J18A) || defined(TARGET_SAMD21G18A)
DigitalInOut d1(PB02);
DigitalInOut d2(PB03);
#elif defined(TARGET_SAML21J18A)
2015-09-23 08:18:08 +00:00
DigitalInOut d1(PA06);
DigitalInOut d2(PA07);
Added support for SAMG55 * * Base Commit for SAMG55J19. No errors and no implementations. * * Added gpio files. * * Added pinmap files. * * Base commit for usticker implementation. * * Added gcc_arm export functionality * * added files for usticker. * added template file for samd55j19 * * GPIO IRQ base commit. * * updated with changes in gpio irq driver. * * Reverted back unexpected commit in SAM0 gpio driver. * * updated gpio_irq driver. * * correction in gpio and gpio_irq drivers. * added support for some test for gpio. * * base commit for peripheralpins for usart. * update in serial apis. * * updated serial apis. * * updated serial apis and test. * * update serial apis for asynch apis. * * updated peripheral pins for i2c and spi. * added test support for serial flow control * * Base commit for low power ticker implementation. * * base commit for port apis. * update in lp ticker apis. * * Added test support for port. * * base commit for sleep apis. * * Base commit for spi. * * updated with corrections in gpio irq. * usticker file updated with latest source. * * updated with corrections for unexpected board reset. * updated gpio irq apis and added test for the same. * * updated sleep api for deepsleep. * * updated serial apis. * Added uc_ticker and SPI api implementations * Removed unused SPI pin map * Updated review feedback * * implemented lpticker with TC module. * updated files for KnR Coding Statndard. * updated serial and usticker apis. * * Base commit for AnalogueIn apis. * * RTC apis base commit without implementation. * * Updated with corrections in lpticker implementations. * * Added implementation for rtc apis. * * updated with implementations for pwm. * changed usticker from TC0 to TC1. * Added I2C support * * removed setvector usage from usticker and lpticker implementations * added tests for SAMG55J19 * * Removed unwanted .o and .d files. * Updated I2C files for KnR Coding Standards. * Update for reducing compiler warnings in peripheralpins,c * Updated with PWM free implementation. * * Removed unwanted headers file inclusion. * Compiler warning corrections in serial_api.c * * Updated ADC with 16 bit mode initialization and code refinements. * Updated PWM with code refinements. * Updated I2C review feedback and fixed style * Updated target name for SAMG55 * * Added Test Support for I2C with AT30TSE75X and Added Support for SAMG55J19 in atmelstudio project exporter * * Added Test Support for I2C with AT30TSE75X and Added Support for SAMG55J19 in atmelstudio project exporter * Used NVIC_SetVector for interrupt callback * Removed Target macro define in test * Updated test cases to have SAMG55 support * * Updated with corrections in Serial and SPI asynchronous implementations. * Updated deepsleep api implementation * Merged LP_Ticker with latest code from mbed 3.0 repository. * * updated with corrections in I2C Asynch implementation.
2016-04-05 17:05:59 +00:00
#elif defined(TARGET_SAMG55J19)
DigitalInOut d1(PA18);
DigitalInOut d2(PA17);
2016-03-31 07:28:43 +00:00
#elif defined(TARGET_VK_RZ_A1H)
DigitalInOut d1(P3_2);
DigitalInOut d2(P5_6);
2013-02-26 14:57:42 +00:00
#else
DigitalInOut d1(p5);
DigitalInOut d2(p25);
2013-02-26 14:57:42 +00:00
#endif
int main()
{
MBED_HOSTTEST_TIMEOUT(10);
MBED_HOSTTEST_SELECT(default_auto);
MBED_HOSTTEST_DESCRIPTION(DigitalInOut);
MBED_HOSTTEST_START("MBED_A6");
bool check = true;
d1.output();
d2.input();
d1 = 1;
wait(0.1);
if (d2 != 1) {
printf("MBED: First check failed! d2 is %d\n", (int)d2);
check = false;
}
d1 = 0;
wait(0.1);
if (d2 != 0) {
printf("MBED: Second check failed! d2 is %d\n", (int)d2);
check = false;
}
d1.input();
d2.output();
d2 = 1;
wait(0.1);
if (d1 != 1) {
printf("MBED: Third check failed! d1 is %d\n", (int)d1);
check = false;
}
d2 = 0;
wait(0.1);
if (d1 != 0) {
printf("MBED: Fourth check failed! d1 is %d\n", (int)d1);
check = false;
}
MBED_HOSTTEST_RESULT(check);
}