Add GPIO HAL example
This commit is contained in:
parent
df0659cd1a
commit
b9a321d602
@ -99,9 +99,18 @@
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_RED (1 << 5) /**< LED3 (Red) -> PD5 */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
@ -99,9 +99,18 @@
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_RED (1 << 5) /**< LED3 (Red) -> PD5 */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
@ -68,9 +68,18 @@
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_RED (1 << 5) /**< LED3 (Red) -> PD5 */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
@ -103,9 +103,18 @@
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_RED (1 << 5) /**< LED3 (Red) -> PD5 */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
|
@ -106,15 +106,18 @@
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_RED 1 /**< LED1 (Red) -> PD4 */
|
||||
#define LEDS_RED_PIN_MASK (1 << 4)
|
||||
#define LEDS_RED_PIN 4
|
||||
#define LEDS_RED_PIN_MASK (1 << LEDS_RED_PIN)
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_GREEN 2 /**< LED2 (Green) -> PB7 */
|
||||
#define LEDS_GREEN_PIN_MASK (1 << 7)
|
||||
#define LEDS_GREEN_PIN 7
|
||||
#define LEDS_GREEN_PIN_MASK (1 << LEDS_GREEN_PIN)
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_B_BASE
|
||||
|
||||
#define LEDS_BLUE 4 /**< LED3 (Blue) -> PB6 */
|
||||
#define LEDS_BLUE_PIN_MASK (1 << 6)
|
||||
#define LEDS_BLUE_PIN 6
|
||||
#define LEDS_BLUE_PIN_MASK (1 << LEDS_BLUE_PIN)
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_B_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED) /* 7 */
|
||||
|
10
examples/dev/gpio-hal/Makefile
Normal file
10
examples/dev/gpio-hal/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
CONTIKI_PROJECT = gpio-hal-example
|
||||
CONTIKI = ../../..
|
||||
|
||||
include $(CONTIKI)/Makefile.identify-target
|
||||
|
||||
MODULES_REL += $(TARGET)
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
36
examples/dev/gpio-hal/README.md
Normal file
36
examples/dev/gpio-hal/README.md
Normal file
@ -0,0 +1,36 @@
|
||||
# GPIO HAL Example
|
||||
This example demonstrates and tests the functionality of the GPIO HAL. You can
|
||||
use it to:
|
||||
|
||||
* Understand the logic of the GPIO HAL.
|
||||
* Test your implementation of arch-specific GPIO HAL components if you are
|
||||
developing a new port.
|
||||
|
||||
This example assumes a device with:
|
||||
|
||||
* 3 output pins (e.g. LEDs).
|
||||
* 1 button.
|
||||
|
||||
# Supported devices
|
||||
This example is expected to work off-the-shelf on the following boards:
|
||||
|
||||
* All CC13xx/CC26xx devices
|
||||
* All CC2538 devices
|
||||
|
||||
# Extending for other platforms
|
||||
Create a sub-directory with the same name as your platform. For example, for
|
||||
platform `my-new-platform` create a subdirectory called `my-new-platform`.
|
||||
Source files in this directory will be compiled automatically. In the most
|
||||
simple case, all you will need is a source file called e.g. `pins.c` (it's OK
|
||||
to use a different filename). In this file, you will need to provide
|
||||
definitions of the variables used by the example to manipulate pins. These
|
||||
variables are:
|
||||
|
||||
* `out_pin1`, `out_pin2` and `out_pin3` for output pins.
|
||||
* `btn_pin` for the button pin.
|
||||
|
||||
Assign to those variables a value that corresponds to the output pin in your
|
||||
board that you wish to test with the example. For example, if you have a LED
|
||||
connected to pin 20, then you will need to
|
||||
|
||||
gpio_hal_pin_t out_pin1 = 20;
|
51
examples/dev/gpio-hal/cc2538dk/pins.c
Normal file
51
examples/dev/gpio-hal/cc2538dk/pins.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* LEDs on the SmartRF06 (EB and BB) are connected as follows:
|
||||
* - LED1 (Red) -> PC0
|
||||
* - LED2 (Yellow) -> PC1 (gpio_hal_pin_t 17)
|
||||
* - LED3 (Green) -> PC2 (gpio_hal_pin_t 18)
|
||||
* - LED4 (Orange) -> PC3 (gpio_hal_pin_t 19)
|
||||
*
|
||||
* LED1 shares the same pin with the USB pullup, so here we'll use PC1, PC2
|
||||
* and PC3.
|
||||
*/
|
||||
gpio_hal_pin_t out_pin1 = 17;
|
||||
gpio_hal_pin_t out_pin2 = 18;
|
||||
gpio_hal_pin_t out_pin3 = 19;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Button pin: Button select, PA3 */
|
||||
gpio_hal_pin_t btn_pin = 3;
|
||||
/*---------------------------------------------------------------------------*/
|
139
examples/dev/gpio-hal/gpio-hal-example.c
Normal file
139
examples/dev/gpio-hal/gpio-hal-example.c
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern gpio_hal_pin_t out_pin1, out_pin2, out_pin3;
|
||||
extern gpio_hal_pin_t btn_pin;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
static uint8_t counter;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(gpio_hal_example, "GPIO HAL Example");
|
||||
AUTOSTART_PROCESSES(&gpio_hal_example);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(gpio_hal_example, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
counter = 0;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_YIELD();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER && data == &et) {
|
||||
if((counter & 7) == 0) {
|
||||
/* Set output and test write, high */
|
||||
gpio_hal_arch_pin_set_output(out_pin1);
|
||||
gpio_hal_arch_pin_set_output(out_pin2);
|
||||
gpio_hal_arch_pin_set_output(out_pin3);
|
||||
|
||||
gpio_hal_arch_write_pin(out_pin1, 1);
|
||||
gpio_hal_arch_write_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3),
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 1) {
|
||||
/* Test write, low */
|
||||
gpio_hal_arch_write_pin(out_pin1, 0);
|
||||
gpio_hal_arch_write_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3), 0);
|
||||
} else if((counter & 7) == 2) {
|
||||
/* Test set */
|
||||
gpio_hal_arch_set_pin(out_pin1);
|
||||
gpio_hal_arch_set_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 3) {
|
||||
/* Test clear */
|
||||
gpio_hal_arch_clear_pin(out_pin1);
|
||||
gpio_hal_arch_clear_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 4) {
|
||||
/* Test toggle (should go high) */
|
||||
gpio_hal_arch_toggle_pin(out_pin1);
|
||||
gpio_hal_arch_toggle_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 5) {
|
||||
/* Test toggle (should go low) */
|
||||
gpio_hal_arch_toggle_pin(out_pin1);
|
||||
gpio_hal_arch_toggle_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 6) {
|
||||
/* Set to input and then set. Should stay off */
|
||||
gpio_hal_arch_pin_set_input(out_pin1);
|
||||
gpio_hal_arch_pin_set_input(out_pin2);
|
||||
gpio_hal_arch_pin_set_input(out_pin3);
|
||||
gpio_hal_arch_set_pin(out_pin1);
|
||||
gpio_hal_arch_set_pins(
|
||||
gpio_hal_pin_to_mask(out_pin2) | gpio_hal_pin_to_mask(out_pin3));
|
||||
} else if((counter & 7) == 7) {
|
||||
/* Toggle button interrupt */
|
||||
gpio_hal_pin_cfg_t interrupt;
|
||||
|
||||
interrupt = gpio_hal_arch_pin_cfg_get(btn_pin) &
|
||||
GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
|
||||
if(interrupt == 0) {
|
||||
printf("Enabling button interrupt\n");
|
||||
gpio_hal_arch_interrupt_enable(btn_pin);
|
||||
} else {
|
||||
printf("Disabling button interrupt\n");
|
||||
gpio_hal_arch_interrupt_disable(btn_pin);
|
||||
}
|
||||
}
|
||||
|
||||
/* Test read */
|
||||
printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08lx\n", counter & 7,
|
||||
gpio_hal_arch_read_pin(out_pin1),
|
||||
gpio_hal_arch_read_pin(out_pin2),
|
||||
gpio_hal_arch_read_pin(out_pin3),
|
||||
gpio_hal_arch_read_pins(gpio_hal_pin_to_mask(out_pin1) |
|
||||
gpio_hal_pin_to_mask(out_pin2) |
|
||||
gpio_hal_pin_to_mask(out_pin3)));
|
||||
|
||||
counter++;
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
} else if(ev == sensors_event && data == &button_sensor) {
|
||||
printf("Button event\n");
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
48
examples/dev/gpio-hal/openmote-cc2538/pins.c
Normal file
48
examples/dev/gpio-hal/openmote-cc2538/pins.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* LEDs on the OpenMote-CC2538 are connected as follows:
|
||||
* - LED1 (Red) -> PC4 (gpio_hal_pin_t 20)
|
||||
* - LED2 (Yellow) -> PC6 (gpio_hal_pin_t 22)
|
||||
* - LED3 (Green) -> PC7 (gpio_hal_pin_t 23)
|
||||
* - LED4 (Orange) -> PC5
|
||||
*/
|
||||
gpio_hal_pin_t out_pin1 = 20;
|
||||
gpio_hal_pin_t out_pin2 = 22;
|
||||
gpio_hal_pin_t out_pin3 = 23;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Button pin: PC3 */
|
||||
gpio_hal_pin_t btn_pin = 19;
|
||||
/*---------------------------------------------------------------------------*/
|
45
examples/dev/gpio-hal/srf06-cc26xx/pins.c
Normal file
45
examples/dev/gpio-hal/srf06-cc26xx/pins.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if CONTIKI_BOARD_SENSORTAG_CC1350
|
||||
#define PINS2_AND_3 BOARD_IOID_LED_1
|
||||
#else
|
||||
#define PINS2_AND_3 BOARD_IOID_LED_2
|
||||
#endif
|
||||
gpio_hal_pin_t out_pin1 = BOARD_IOID_LED_1;
|
||||
gpio_hal_pin_t out_pin2 = PINS2_AND_3;
|
||||
gpio_hal_pin_t out_pin3 = PINS2_AND_3;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_t btn_pin = BOARD_IOID_KEY_LEFT;
|
||||
/*---------------------------------------------------------------------------*/
|
42
examples/dev/gpio-hal/zoul/pins.c
Normal file
42
examples/dev/gpio-hal/zoul/pins.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BASE_TO_PORT_NUM(base) (((base) - GPIO_A_BASE) >> 12)
|
||||
|
||||
gpio_hal_pin_t out_pin1 = (BASE_TO_PORT_NUM(LEDS_GREEN_PORT_BASE) << 3) + LEDS_GREEN_PIN;
|
||||
gpio_hal_pin_t out_pin2 = (BASE_TO_PORT_NUM(LEDS_BLUE_PORT_BASE) << 3) + LEDS_BLUE_PIN;
|
||||
gpio_hal_pin_t out_pin3 = (BASE_TO_PORT_NUM(LEDS_RED_PORT_BASE) << 3) + LEDS_RED_PIN;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_t btn_pin = (BUTTON_USER_PORT << 3) + BUTTON_USER_PIN;
|
||||
/*---------------------------------------------------------------------------*/
|
Loading…
Reference in New Issue
Block a user