diff options
author | Daniel Leung <daniel.leung@intel.com> | 2016-01-29 13:51:58 -0800 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2016-02-05 20:25:29 -0500 |
commit | ed98af00e0275228203efc83ebd581d57dcc04de (patch) | |
tree | 56107e8f3d163748e607889d8adc7d07c82a6a0f /samples | |
parent | a8a5597e9437864713a665e8cd9f30e87df183a1 (diff) |
samples: gpio: extends to support gpio_atmel_sam3 driver
This adds code to the gpio sample apps to run on Arduino due,
using the gpio_atmel_sam3 driver.
Change-Id: Ida16ceeabf55eb7efedc94c56ff875d8fad6456d
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/nanokernel/apps/gpio/Makefile | 4 | ||||
-rw-r--r-- | samples/nanokernel/apps/gpio/prj_arm.conf | 6 | ||||
-rw-r--r-- | samples/nanokernel/apps/gpio/src/main.c | 45 |
3 files changed, 46 insertions, 9 deletions
diff --git a/samples/nanokernel/apps/gpio/Makefile b/samples/nanokernel/apps/gpio/Makefile index b0c7d951f..567da028a 100644 --- a/samples/nanokernel/apps/gpio/Makefile +++ b/samples/nanokernel/apps/gpio/Makefile @@ -1,8 +1,12 @@ ifeq ($(ARCH),arc) BOARD ?= arduino_101_sss else +ifeq ($(ARCH),arm) +BOARD ?= arduino_due +else BOARD ?= arduino_101 endif +endif KERNEL_TYPE ?= nano CONF_FILE = prj_$(ARCH).conf diff --git a/samples/nanokernel/apps/gpio/prj_arm.conf b/samples/nanokernel/apps/gpio/prj_arm.conf new file mode 100644 index 000000000..a036c67a3 --- /dev/null +++ b/samples/nanokernel/apps/gpio/prj_arm.conf @@ -0,0 +1,6 @@ +CONFIG_STDOUT_CONSOLE=y +CONFIG_PRINTK=y +CONFIG_NANO_TIMERS=y +CONFIG_NANO_TIMEOUTS=y +CONFIG_GPIO=y +CONFIG_GPIO_ATMEL_SAM3=y diff --git a/samples/nanokernel/apps/gpio/src/main.c b/samples/nanokernel/apps/gpio/src/main.c index 7cefa8875..1688812aa 100644 --- a/samples/nanokernel/apps/gpio/src/main.c +++ b/samples/nanokernel/apps/gpio/src/main.c @@ -15,15 +15,15 @@ */ /** - * @file Sample app to utilize GPIO on Arduino 101. + * @file Sample app to utilize GPIO on Arduino 101 and Arduino Due. * - * x86 + * Arduino 101 - x86 * -------------------- * * On x86 side of Arduino 101: * 1. GPIO_16 is on IO8 * 2. GPIO_19 is on IO4 - + * * The gpio_dw driver is being used. * * This sample app toggles GPIO_16/IO8. It also waits for @@ -38,8 +38,8 @@ * GPIO_19 triggered * " * - * Sensor Subsystem - * -------------------- + * Arduino 101 - Sensor Subsystem + * ------------------------------ * * On Sensor Subsystem of Arduino 101: * 1. GPIO_SS[ 2] is on A00 @@ -69,6 +69,27 @@ * Toggling GPIO_SS_2 * GPIO_SS_3 triggered * " + * + * Arduino Due + * ----------- + * + * On Arduino Due: + * 1. IO_2 is PB25 + * 2. IO_13 is PB27 (linked to the LED marked "L") + * + * The gpio_atmel_sam3 driver is being used. + * + * This sample app toggles IO_2. It also waits for + * IO_13 to go high and display a message. + * + * If IO_2 and IO_13 are connected together, the GPIO should + * triggers every 2 seconds. And you should see this repeatedly + * on console: + * " + * Toggling GPIO_25 + * Toggling GPIO_25 + * GPIO_27 triggered + * " */ #include <zephyr.h> @@ -87,20 +108,26 @@ #define SLEEPTICKS SECONDS(1) -#ifdef CONFIG_SOC_QUARK_SE_SS +#if defined(CONFIG_SOC_QUARK_SE_SS) #define GPIO_OUT_PIN 2 #define GPIO_INT_PIN 3 #define GPIO_NAME "GPIO_SS_" -#else +#elif defined(CONFIG_SOC_QUARK_SE) #define GPIO_OUT_PIN 16 #define GPIO_INT_PIN 19 #define GPIO_NAME "GPIO_" +#elif defined(CONFIG_SOC_ATMEL_SAM3) +#define GPIO_OUT_PIN 25 +#define GPIO_INT_PIN 27 +#define GPIO_NAME "GPIO_" #endif -#ifdef CONFIG_GPIO_DW_0 +#if defined(CONFIG_GPIO_DW_0) #define GPIO_DRV_NAME CONFIG_GPIO_DW_0_NAME -#elif CONFIG_GPIO_QMSI_0 +#elif defined(CONFIG_GPIO_QMSI_0) #define GPIO_DRV_NAME CONFIG_GPIO_QMSI_0_NAME +#elif defined(CONFIG_GPIO_ATMEL_SAM3) +#define GPIO_DRV_NAME CONFIG_GPIO_ATMEL_SAM3_PORTB_DEV_NAME #else #error "Unsupported GPIO driver" #endif |