-
Notifications
You must be signed in to change notification settings - Fork 0
GPIO
You may configure a GPIO pin to only be input or output driven. Also, it is possible to do both.
To set a GPIO pin to input driven mode, please use the hwstl::make_ipin(pin_number)
function.
Example: configure pin D7 on an Arduino based board to be input driven.
auto [d7] = hwstl::make_ipin(
hwstl::target::pin::d7
);
To set a GPIO pin to output driven mode, please use the hwstl::make_opin(pin_number)
function.
Example: configure pin D13, in most cases the onboard LED, on an Arduino based board to be output driven.
auto [d13] = hwstl::make_opin(
hwstl::target::pin::d13
);
To set a GPIO pin to input/output driven, please use the hwstl::make_iopin(pin_number)
function.
Example: configure pin D13, in most cases the onboard LED, on an Arduino based board to be output driven.
auto [d5] = hwstl::make_iopin(
hwstl::target::pin::d5
);
You may initialize a sequence of pins at once. This will improve the performance of your application slightly. To initialize multiple pins you may use the hwstl::make_ipin
, hwstl::make_opin
and hwstl::make_iopin
as noted in the sections above.
Example:
auto [d5, d13] = hwstl::make_iopin(
hwstl::target::pin::d5
hwstl::target::pin::d7
);
Note that pins D5 and D7 are both in input/output mode.
If you've configured some GPIO pins, you may now proceed to do something with them.
You may get the level of a GPIO pin.
Example (D7 is configured to be input driven):
bool pin_val = d7.get();
You may set the level of a GPIO pin to HIGH or LOW.
High:
d5.set(1);
Low:
d5.set(0);
__ ___ _ ___ _ _ _
\ \ / (_) ___| |__ ___ ( _ ) | |_ _| (_) __ _ _ __
\ \ /\ / /| |/ _ \ '_ \ / _ \ / _ \/\ _ | | | | | | |/ _` | '_ \
\ V V / | | __/ |_) | __/ | (_> < | |_| | |_| | | | (_| | | | |
\_/\_/ |_|\___|_.__/ \___| \___/\/ \___/ \__,_|_|_|\__,_|_| |_|
_____ _ _ ____
| ____|_ __ __ _(_)_ __ ___ ___ _ __(_)_ __ __ _ / ___|___
| _| | '_ \ / _` | | '_ \ / _ \/ _ \ '__| | '_ \ / _` | | | / _ \
| |___| | | | (_| | | | | | __/ __/ | | | | | | (_| | | |__| (_) |
|_____|_| |_|\__, |_|_| |_|\___|\___|_| |_|_| |_|\__, | \____\___(_)
|___/ |___/
Copyright © 2019 Julian and Wiebe Engineering Co.