blob: b43c4b019c73a652c297760d6169b6c1b5ef110b [file] [log] [blame]
Brian Silverman0aa48a92014-01-25 17:10:17 -08001#include "bbb/gpo.h"
Daniel Pettid6ff3d52014-01-02 11:24:39 -08002
3#include <stdio.h>
Brian Silverman0aa48a92014-01-25 17:10:17 -08004#include <errno.h>
5#include <string.h>
Daniel Pettid6ff3d52014-01-02 11:24:39 -08006
7#include "aos/common/logging/logging.h"
8
9namespace bbb {
10
Brian Silverman0aa48a92014-01-25 17:10:17 -080011Gpo::Gpo(int bank, int pin, bool initial_value)
12 : GpioPin(bank, pin, false, initial_value) {}
13
14void Gpo::Set(bool high) {
15 if (fputc(high ? '1' : '0', value_handle_) < 0) {
16 LOG(FATAL, "fputc(%c, %p) for pin (%d,%d) failed with %d: %s\n",
17 high ? '1': '0', value_handle_, bank_, pin_, errno, strerror(errno));
Daniel Pettid6ff3d52014-01-02 11:24:39 -080018 }
Daniel Pettid6ff3d52014-01-02 11:24:39 -080019}
20
Daniel Pettife475252014-01-05 14:15:16 -080021} // namespace bbb