Skip to content

Commit 8061b9d

Browse files
committed
[embeddedpp] Create a gpio interface
1 parent 12fde52 commit 8061b9d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

lib/embeddedpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ target_sources(embeddedpp
1010
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
1111
FILES
1212
spi.hh
13+
gpio.hh
1314
helpers.hh
1415
)
1516

lib/embeddedpp/gpio.hh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright lowRISC contributors.
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
#pragma once
6+
7+
#include <concepts>
8+
#include <cstdint>
9+
#include "helpers.hh"
10+
11+
namespace embeddedpp {
12+
13+
template <typename T>
14+
concept Gpio = requires(T t, uint8_t pin, bool value) {
15+
{ t.set_pin(pin, value) } -> std::same_as<Status>;
16+
{ t.get_pin(pin) } -> std::same_as<Result<bool>>;
17+
};
18+
19+
} // namespace embeddedpp

0 commit comments

Comments
 (0)