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.
Fork of Smoothie by
Pin.h
00001 #ifndef PIN_H 00002 #define PIN_H 00003 00004 #include "mbed.h" 00005 00006 #include <stdlib.h> 00007 #include <stdio.h> 00008 #include <string> 00009 00010 class Pin { 00011 public: 00012 Pin(); 00013 00014 Pin* from_string(std::string value); 00015 00016 inline bool connected(){ 00017 return name != NC; 00018 } 00019 00020 inline Pin* as_output(){ 00021 gpio_dir(&pin, PIN_OUTPUT); 00022 return this; 00023 } 00024 00025 inline Pin* as_input(){ 00026 gpio_dir(&pin, PIN_INPUT); 00027 return this; 00028 } 00029 00030 Pin* as_open_drain(void); 00031 00032 Pin* as_repeater(void); 00033 00034 Pin* pull_up(void); 00035 00036 Pin* pull_down(void); 00037 00038 Pin* pull_none(void); 00039 00040 inline bool get(){ 00041 return this->inverting ^ gpio_read(&pin); 00042 } 00043 00044 inline void set(bool value) 00045 { 00046 gpio_write(&pin, value ^ this->inverting); 00047 } 00048 00049 PinName name; 00050 bool inverting; 00051 gpio_t pin; 00052 }; 00053 00054 00055 00056 00057 #endif
Generated on Tue Jul 12 2022 20:09:02 by
1.7.2
