Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Pin.h Source File

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