Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DigitalInOut.h
00001 #ifndef _DIGITAL_IN_OUT_H_ 00002 #define _DIGITAL_IN_OUT_H_ 00003 00004 #include "BCM2835.h" 00005 00006 class DigitalInOut 00007 { 00008 public: 00009 DigitalInOut(PinName pin) : 00010 gpio(pin) 00011 { 00012 gpio_dir(gpio, PIN_INPUT); 00013 gpio_write(gpio, LOW); 00014 } 00015 00016 DigitalInOut(PinName pin, PinDirection direction, PinMode mode, int value) : 00017 gpio(pin) 00018 { 00019 if (direction == PIN_INPUT) { 00020 gpio_dir(gpio, PIN_INPUT); 00021 if (mode == PullUp) 00022 gpio_write(gpio, HIGH); 00023 else 00024 gpio_write(gpio, LOW); 00025 } 00026 else { 00027 gpio_dir(gpio, PIN_OUTPUT); 00028 gpio_write(gpio, value); 00029 } 00030 } 00031 00032 void write(int value) { gpio_write(gpio, value); } 00033 int read() { return gpio_read(gpio); } 00034 void output() { gpio_dir(gpio, PIN_OUTPUT); } 00035 void input() { gpio_dir(gpio, PIN_INPUT); } 00036 DigitalInOut &operator =(int value) { write(value); return *this; } 00037 operator int() { return read(); } 00038 protected: 00039 PinName gpio; 00040 }; 00041 00042 #endif // _DIGITAL_IN_OUT_H_ 00043
Generated on Tue Dec 20 2022 12:16:32 by
1.7.2