blob: f02ded37bea9a0768041a37915530a12e40aceed [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) {
Brian Silverman04fac622014-01-26 18:32:15 -080015 rewind(value_handle_);
Brian Silverman0aa48a92014-01-25 17:10:17 -080016 if (fputc(high ? '1' : '0', value_handle_) < 0) {
17 LOG(FATAL, "fputc(%c, %p) for pin (%d,%d) failed with %d: %s\n",
18 high ? '1': '0', value_handle_, bank_, pin_, errno, strerror(errno));
Daniel Pettid6ff3d52014-01-02 11:24:39 -080019 }
Daniel Pettid6ff3d52014-01-02 11:24:39 -080020}
21
Daniel Pettife475252014-01-05 14:15:16 -080022} // namespace bbb