samples/gpio_dw: extends the app for GPIOs on quark_se_ss
The basic is the same for both architecture, but using different GPIO controller and pins. Change-Id: Ie021461858736d90a47bdef2c9d5e655e2efa473 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
5aab5ccbad
commit
6a869058ff
5 changed files with 81 additions and 24 deletions
|
@ -1,5 +1,10 @@
|
|||
ifeq ($(ARCH),arc)
|
||||
PLATFORM_CONFIG ?= quark_se_ss
|
||||
else
|
||||
PLATFORM_CONFIG ?= arduino_101
|
||||
endif
|
||||
|
||||
KERNEL_TYPE ?= nano
|
||||
CONF_FILE = prj.conf
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
||||
|
|
9
samples/nanokernel/apps/gpio_dw/prj_arc.conf
Normal file
9
samples/nanokernel/apps/gpio_dw/prj_arc.conf
Normal file
|
@ -0,0 +1,9 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_GPIO_DW=y
|
||||
CONFIG_GPIO_DW_0=y
|
||||
CONFIG_GPIO_DW_0_BITS=8
|
||||
CONFIG_NANO_TIMERS=y
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_DEBUG=y
|
|
@ -15,12 +15,15 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @file Sample app to utilize GPIO on Arduino 101, x86 side.
|
||||
* @file Sample app to utilize GPIO on 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
|
||||
|
@ -32,7 +35,39 @@
|
|||
* "
|
||||
* Toggling GPIO_16
|
||||
* Toggling GPIO_16
|
||||
* GPIO 19 triggered
|
||||
* GPIO_19 triggered
|
||||
* "
|
||||
*
|
||||
* Sensor Subsystem
|
||||
* --------------------
|
||||
*
|
||||
* On Sensor Subsystem of Arduino 101:
|
||||
* 1. GPIO_SS[ 2] is on A00
|
||||
* 2. GPIO_SS[ 3] is on A01
|
||||
* 3. GPIO_SS[ 4] is on A02
|
||||
* 4. GPIO_SS[ 5] is on A03
|
||||
* 5. GPIO_SS[10] is on IO3
|
||||
* 6. GPIO_SS[11] is on IO5
|
||||
* 7. GPIO_SS[12] is on IO6
|
||||
* 8. GPIO_SS[13] is on IO9
|
||||
*
|
||||
* There are two 8-bit GPIO controllers on the sensor subsystem.
|
||||
* GPIO_SS[0-7] are on GPIO_0 while GPIO_SS[8-15] are on GPIO_1.
|
||||
*
|
||||
* The gpio_dw driver is being used. The first GPIO controller
|
||||
* is mapped to device "GPIO_0", and the second GPIO controller
|
||||
* is mapped to device "GPIO_1".
|
||||
*
|
||||
* This sample app toggles GPIO_SS_2/A0. It also waits for
|
||||
* GPIO_SS_3/A1 to go high and display a message.
|
||||
*
|
||||
* If A0 and A1 are connected together, the GPIO should
|
||||
* triggers every 2 seconds. And you should see this repeatedly
|
||||
* on console (via ipm_console0):
|
||||
* "
|
||||
* Toggling GPIO_SS_2
|
||||
* Toggling GPIO_SS_2
|
||||
* GPIO_SS_3 triggered
|
||||
* "
|
||||
*/
|
||||
|
||||
|
@ -52,58 +87,66 @@
|
|||
|
||||
#define SLEEPTICKS SECONDS(1)
|
||||
|
||||
#ifdef CONFIG_PLATFORM_QUARK_SE_SS
|
||||
#define GPIO_OUT_PIN 2
|
||||
#define GPIO_INT_PIN 3
|
||||
#define GPIO_NAME "GPIO_SS_"
|
||||
#else
|
||||
#define GPIO_OUT_PIN 16
|
||||
#define GPIO_INT_PIN 19
|
||||
#define GPIO_NAME "GPIO_"
|
||||
#endif
|
||||
|
||||
void gpio_callback(struct device *port, uint32_t pin)
|
||||
{
|
||||
PRINT("GPIO %d triggered\n", pin);
|
||||
PRINT(GPIO_NAME "%d triggered\n", pin);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
struct nano_timer timer;
|
||||
void *timer_data[1];
|
||||
struct device *gpio_dw;
|
||||
struct device *gpio_dev;
|
||||
int ret;
|
||||
int toggle = 1;
|
||||
|
||||
nano_timer_init(&timer, timer_data);
|
||||
|
||||
gpio_dw = device_get_binding(CONFIG_GPIO_DW_0_NAME);
|
||||
if (!gpio_dw) {
|
||||
PRINT("Cannot find GPIO_DW_0!\n");
|
||||
gpio_dev = device_get_binding(CONFIG_GPIO_DW_0_NAME);
|
||||
if (!gpio_dev) {
|
||||
PRINT("Cannot find %s!\n", CONFIG_GPIO_DW_0_NAME);
|
||||
}
|
||||
|
||||
/* Setup GPIO_16/IO8 to be output */
|
||||
ret = gpio_pin_configure(gpio_dw, 16, (GPIO_DIR_OUT));
|
||||
/* Setup GPIO output */
|
||||
ret = gpio_pin_configure(gpio_dev, GPIO_OUT_PIN, (GPIO_DIR_OUT));
|
||||
if (ret) {
|
||||
PRINT("Error configuring GPIO_16!\n");
|
||||
PRINT("Error configuring " GPIO_NAME "%d!\n", GPIO_OUT_PIN);
|
||||
}
|
||||
|
||||
/* Setup GPIO_19/IO4 to be input,
|
||||
* and triggers on rising edge.
|
||||
*/
|
||||
ret = gpio_pin_configure(gpio_dw, 19,
|
||||
/* Setup GPIO input, and triggers on rising edge. */
|
||||
ret = gpio_pin_configure(gpio_dev, GPIO_INT_PIN,
|
||||
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
|
||||
| GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE));
|
||||
if (ret) {
|
||||
PRINT("Error configuring GPIO_16!\n");
|
||||
PRINT("Error configuring " GPIO_NAME "%d!\n", GPIO_INT_PIN);
|
||||
}
|
||||
|
||||
ret = gpio_set_callback(gpio_dw, gpio_callback);
|
||||
ret = gpio_set_callback(gpio_dev, gpio_callback);
|
||||
if (ret) {
|
||||
PRINT("Cannot setup callback!\n");
|
||||
}
|
||||
|
||||
ret = gpio_pin_enable_callback(gpio_dw, 19);
|
||||
ret = gpio_pin_enable_callback(gpio_dev, GPIO_INT_PIN);
|
||||
if (ret) {
|
||||
PRINT("Error enabling callback!\n");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
PRINT("Toggling GPIO_16\n");
|
||||
PRINT("Toggling " GPIO_NAME "%d\n", GPIO_OUT_PIN);
|
||||
|
||||
ret = gpio_pin_write(gpio_dw, 16, toggle);
|
||||
ret = gpio_pin_write(gpio_dev, GPIO_OUT_PIN, toggle);
|
||||
if (ret) {
|
||||
PRINT("Error set GPIO_16!\n");
|
||||
PRINT("Error set " GPIO_NAME "%d!\n", GPIO_OUT_PIN);
|
||||
}
|
||||
|
||||
if (toggle) {
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
build_only = true
|
||||
tags = drivers
|
||||
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = quark_se arduino_101
|
||||
arch_whitelist = x86 arc
|
||||
platform_whitelist = quark_se arduino_101 quark_se_ss
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue