Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# ABC-fw
Firmware for the ABC board
## Installation and usage

To build, use the command "west build -p auto -b nrf52840_ble_cell abc_fw/samples/hello_world/"
How to get an ABC board working:

Do this one level above this directory, if you have used the yaml script ("west init -m https://github.com/ChrisGammell/ABC-fw.git")
1. Install Zephyr stuff (steps 1-4): https://buff.ly/3ohvK42
2. west init -m https://github.com/ContextualElectronics/ABC-fw.git
3. west update
4. west build -p auto -b contextualelectronics_abc abc_fw/samples/blinky/
5. west flash
6. Revel in an ABC board happily blinking at you

Note: This can be installed in a "fw" directory at the top level of an "ABC" directory, or similar. A normal directory looks like this

* ABC
* fw
* hw
7 changes: 7 additions & 0 deletions samples/blinky/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(blinky)

target_sources(app PRIVATE src/main.c)
44 changes: 44 additions & 0 deletions samples/blinky/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. _blinky-sample:

Blinky
######

Overview
********

Blinky is a simple application which blinks an LED forever using the :ref:`GPIO
API <gpio_api>`. The source code shows how to configure GPIO pins as outputs,
then turn them on and off.

See :ref:`pwm-blinky-sample` for a sample which uses the PWM API to blink an
LED.

.. _blinky-sample-requirements:

Requirements
************

You will see this error if you try to build Blinky for an unsupported board:

.. code-block:: none

Unsupported board: led0 devicetree alias is not defined

The board must have an LED connected via a GPIO pin. These are called "User
LEDs" on many of Zephyr's :ref:`boards`. The LED must be configured using the
``led0`` :ref:`devicetree <dt-guide>` alias. This is usually done in the
:ref:`BOARD.dts file <devicetree-in-out-files>` or a :ref:`devicetree overlay
<set-devicetree-overlays>`.

Building and Running
********************

Build and flash Blinky as follows, changing ``reel_board`` for your board:

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: reel_board
:goals: build flash
:compact:

After flashing, the LED starts to blink. Blinky does not print to the console.
1 change: 1 addition & 0 deletions samples/blinky/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_GPIO=y
10 changes: 10 additions & 0 deletions samples/blinky/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sample:
name: Blinky Sample
tests:
sample.basic.blinky:
tags: LED gpio
filter: dt_compat_enabled_with_alias("gpio-leds", "led0")
depends_on: gpio
harness: led
integration_platforms:
- frdm_k64f
51 changes: 51 additions & 0 deletions samples/blinky/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS 1000

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)

#if DT_NODE_HAS_STATUS(LED0_NODE, okay)
#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios)
#define PIN DT_GPIO_PIN(LED0_NODE, gpios)
#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios)
#else
/* A build error here means your board isn't set up to blink an LED. */
#error "Unsupported board: led0 devicetree alias is not defined"
#define LED0 ""
#define PIN 0
#define FLAGS 0
#endif

void main(void)
{
const struct device *dev;
bool led_is_on = true;
int ret;

dev = device_get_binding(LED0);
if (dev == NULL) {
return;
}

ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
if (ret < 0) {
return;
}

while (1) {
gpio_pin_set(dev, PIN, (int)led_is_on);
led_is_on = !led_is_on;
k_msleep(SLEEP_TIME_MS);
}
}
8 changes: 8 additions & 0 deletions samples/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world)

target_sources(app PRIVATE src/main.c)
33 changes: 33 additions & 0 deletions samples/hello_world/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. _hello_world:

Hello World
###########

Overview
********

A simple sample that can be used with any :ref:`supported board <boards>` and
prints "Hello World" to the console.

Building and Running
********************

This application can be built and executed on QEMU as follows:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:host-os: unix
:board: qemu_x86
:goals: run
:compact:

To build for another board, change "qemu_x86" above to that board's name.

Sample Output
=============

.. code-block:: console

Hello World! x86

Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
1 change: 1 addition & 0 deletions samples/hello_world/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# nothing here
16 changes: 16 additions & 0 deletions samples/hello_world/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sample:
description: Hello World sample, the simplest Zephyr
application
name: hello world
common:
tags: introduction
integration_platforms:
- native_posix
harness: console
harness_config:
type: one_line
regex:
- "Hello World! (.*)"
tests:
sample.basic.helloworld:
tags: introduction
13 changes: 13 additions & 0 deletions samples/hello_world/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <sys/printk.h>

void main(void)
{
printk("Hello World! %s\n", CONFIG_BOARD);
}
11 changes: 6 additions & 5 deletions west.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# The west manifest file for Zephyr based ABC board.

manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
url-base: https://github.com/bwasim
- name: ABC-fw
url-base: https://github.com/ContextualElectronics

defaults:
remote: ABC-fw
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v2.0.0
revision: ble-cell
import: true
self:
path: abc_fw