samples: gpio_counter: remove obsolete sample

Board specific sample that only works with certain revisions of the
hardware requiring special BIOS settings.

Fixes #58057

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2024-04-10 11:06:53 +00:00 committed by Fabio Baltieri
parent b89a7203e2
commit 132cbdf27a
6 changed files with 0 additions and 284 deletions

View file

@ -3237,7 +3237,6 @@ Intel Platforms (X86):
- soc/intel/atom/
- soc/intel/lakemont/
- soc/intel/*_lake/
- samples/boards/up_squared/
labels:
- "platform: X86"

View file

@ -1,8 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(gpio_counter)
target_sources(app PRIVATE src/main.c)

View file

@ -1,94 +0,0 @@
.. _up_squared gpio_counter:
UP Squared GPIO Counter
#######################
Overview
********
This sample provides an example of how to configure GPIO input and output to
the UP Squared board.
The sample enables a pin as GPIO input (active high) that triggers the increment
of a counter (range is 0x0 to 0xf). The counter increments for
each change from 0 to 1 on HAT Pin 16 (BIOS Pin 19). The value of the counter is
represented on GPIO output (active high) as a 4-bit value
(bin 0, 1, 2, 3 -> HAT Pin 35, 37, 38, 40).
+------------+-----------------------------+
| Element | Mapping (by column) |
+============+=====+=====+=====+=====+=====+
| Bit (bin) | n/a | 3 | 2 | 1 | 0 |
+------------+-----+-----+-----+-----+-----+
| HAT Pin | 16 | 40 | 39 | 37 | 35 |
+------------+-----+-----+-----+-----+-----+
| BIOS Pin | 19 | 38 | 27 | 15 | 14 |
+------------+-----+-----+-----+-----+-----+
| Direction | IN | OUT | OUT | OUT | OUT |
+------------+-----+-----+-----+-----+-----+
| Active | H | H | H | H | H |
+------------+-----+-----+-----+-----+-----+
For example, a counter value of 0xc (hex) is represented in 0b1100 (binary)
on the GPIO output pins.
Requirements
************
The application requires an UP Squared board connected to the PC through USB
for serial console. The BIOS settings must be updated as specified in the
source code comments for HAT Configurations (see table above).
References
**********
- :ref:`up_squared` board documentation
Building and Running
********************
Build the sample in the following way:
.. zephyr-app-commands::
:zephyr-app: samples/boards/up_squared/gpio_counter
:board: up_squared
:goals: build
Prepare the boot device (USB storage drive) as described for the :ref:`UP Squared <up_squared>`
board. Insert the USB boot device containing the prepared software binary of the sample.
Connect the board to a host computer and open a serial connection for serial
console interface::
$ minicom -D <tty_device> -b 115200
Replace :code:`<tty_device>` with the port where the UP Squared board
can be found. For example, under Linux, :code:`/dev/ttyUSB0`.
The ``-b`` option sets baud rate.
Power On the board. The board will boot then enter GRUB boot loader unless BIOS
option is selected. Enter the BIOS configuration menu, modify the required HAT
configurations (above) and then select to save the BIOS settings and reset.
The board will reboot and then enter GRUB boot loader. Select to boot Zephyr and
the board will start to execute the sample. Apply input to trigger the increment
of the value of the counter.
There are several ways to observe the sample behavior in addition to serial
console display of the counter value. For example, the input signal can be
implemented with an analog button on a breakout breadboard, or with a basic pulse
provided by a GPIO output (active High) pin of another GPIO device (eg Arduino
Uno). The Up Squared GPIO output signals can each be connected to a simple LED
circuit on a breakout breadboard to illuminate the 4-bit counter value, as
shown in the example below::
o----> to Up Squared
| GPIO Output Pin
_|_
\ /
---
|
R1
|
+---> GND

View file

@ -1 +0,0 @@
CONFIG_GPIO=y

View file

@ -1,9 +0,0 @@
sample:
description: Example of using GPIOs on UP Squared board
name: Example of using GPIOs on UP Squared board
tests:
sample.board.up_squared.gpio_counter:
platform_allow: up_squared
tags: gpio
integration_platforms:
- up_squared

View file

@ -1,171 +0,0 @@
/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <board.h>
#include <soc.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/util.h>
/**
* @file
*
* @brief Example of using GPIOs on UP Squared board
*
* This example outputs the value of a counter via 4 GPIO lines
* as a 4-bit value (bin 0, 1, 2, 3 -> HAT Pin 35, 37, 38, 40).
* The counter increments for each change from 0 to 1 on HAT Pin 16.
*
* Note:
* Need to change the BIOS settings:
* () Advanced -> HAT Configurations:
* - HD-Audio / I2S6 Selec -> Disabled
* - GPIO / PWM3 Selection -> GPIO
* - GPIO / I2S2 Selection -> GPIO
*
* - GPIO 19 (Pin16) Confi -> Input
*
* - GPIO 14 (Pin35) Confi -> Output
* - GPIO 15 (Pin37) Confi -> Output
* - GPIO 27 (Pin38) Confi -> Output
* - GPIO 28 (Pin40) Confi -> Output
*/
struct _pin {
uint32_t hat_num;
uint32_t pin;
const struct device *gpio_dev;
};
struct _pin counter_pins[] = {
{
.hat_num = 35,
.pin = UP2_HAT_PIN_35,
.gpio_dev = DEVICE_DT_GET(UP2_HAT_PIN_35_DEV),
},
{
.hat_num = 37,
.pin = UP2_HAT_PIN_37,
.gpio_dev = DEVICE_DT_GET(UP2_HAT_PIN_37_DEV),
},
{
.hat_num = 38,
.pin = UP2_HAT_PIN_38,
.gpio_dev = DEVICE_DT_GET(UP2_HAT_PIN_38_DEV),
},
{
.hat_num = 40,
.pin = UP2_HAT_PIN_40,
.gpio_dev = DEVICE_DT_GET(UP2_HAT_PIN_40_DEV),
},
};
struct _pin intr_pin = {
.hat_num = 16,
.pin = UP2_HAT_PIN_16,
.gpio_dev = DEVICE_DT_GET(UP2_HAT_PIN_16_DEV),
};
static struct gpio_callback gpio_cb;
static volatile uint32_t counter;
K_SEM_DEFINE(counter_sem, 0, 1);
#define NUM_PINS ARRAY_SIZE(counter_pins)
#define MASK (BIT(NUM_PINS) - 1)
void button_cb(const struct device *gpiodev, struct gpio_callback *cb,
uint32_t pin)
{
counter++;
k_sem_give(&counter_sem);
}
int get_gpio_dev(struct _pin *pin)
{
if (!device_is_ready(pin->gpio_dev)) {
printk("ERROR: GPIO device is not ready for %s\n", pin->gpio_dev->name);
return -1;
}
return 0;
}
int main(void)
{
uint32_t val;
int i, ret;
for (i = 0; i < NUM_PINS; i++) {
if (get_gpio_dev(&counter_pins[i]) != 0) {
return 0;
}
}
if (get_gpio_dev(&intr_pin) != 0) {
return 0;
}
/* Set pins to output */
for (i = 0; i < NUM_PINS; i++) {
ret = gpio_pin_configure(counter_pins[i].gpio_dev,
counter_pins[i].pin,
GPIO_OUTPUT_LOW);
if (ret) {
printk("ERROR: cannot set HAT pin %d to OUT (%d)\n",
counter_pins[i].hat_num, ret);
return 0;
}
}
/* Setup input pin */
ret = gpio_pin_configure(intr_pin.gpio_dev, intr_pin.pin,
GPIO_INPUT);
if (ret) {
printk("ERROR: cannot set HAT pin %d to IN (%d)\n",
intr_pin.hat_num, ret);
return 0;
}
/* Callback uses pin_mask, so need bit shifting */
gpio_init_callback(&gpio_cb, button_cb, (1 << intr_pin.pin));
gpio_add_callback(intr_pin.gpio_dev, &gpio_cb);
/* Setup input pin for interrupt */
ret = gpio_pin_interrupt_configure(intr_pin.gpio_dev, intr_pin.pin,
GPIO_INT_EDGE_RISING);
if (ret) {
printk("ERROR: cannot config interrupt on HAT pin %d (%d)\n",
intr_pin.hat_num, ret);
return 0;
}
/* main loop */
val = 0U;
while (1) {
printk("counter: 0x%x\n", val);
for (i = 0; i < NUM_PINS; i++) {
ret = gpio_pin_set(counter_pins[i].gpio_dev,
counter_pins[i].pin,
(val & BIT(i)));
if (ret) {
printk("ERROR: cannot set HAT pin %d value (%d)\n",
counter_pins[i].hat_num, ret);
return 0;
}
}
k_sem_take(&counter_sem, K_FOREVER);
val = counter & MASK;
}
return 0;
}