code ax12 petit robot 12/05/2017

Fork of command_AX12_petit_robot_V3 by CRAC Team

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BusInOut.h Source File

BusInOut.h

00001 /* mbed Microcontroller Library - BusInOut
00002  * Copyright (c) 2009 ARM Limited. All rights reserved.
00003  */
00004  
00005 #ifndef MBED_BUSINOUT_H
00006 #define MBED_BUSINOUT_H
00007 
00008 #include "platform.h" 
00009 #include "PinNames.h"
00010 #include "PeripheralNames.h"
00011 #include "Base.h"
00012 #include "DigitalInOut.h"
00013 
00014 namespace mbed {
00015 
00016 /* Class: BusInOut
00017  *  A digital input output bus, used for setting the state of a collection of pins
00018  */
00019 class BusInOut : public Base {
00020 
00021 public:
00022 
00023     /* Group: Configuration Methods */
00024     
00025     /* Constructor: BusInOut
00026      *  Create an BusInOut, connected to the specified pins
00027      *
00028      * Variables:
00029      *  p<n> - DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
00030      *
00031      * Note:
00032      *  It is only required to specify as many pin variables as is required
00033      *  for the bus; the rest will default to NC (not connected)
00034      */ 
00035     BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
00036              PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
00037              PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
00038              PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC, 
00039              const char *name = NULL);
00040 
00041     BusInOut(PinName pins[16], const char *name = NULL);
00042 
00043     virtual ~BusInOut();
00044 
00045     /* Group: Access Methods */
00046         
00047     /* Function: write
00048      *  Write the value to the output bus
00049      *
00050      * Variables:
00051      *  value - An integer specifying a bit to write for every corresponding DigitalInOut pin
00052      */
00053     void write(int value);
00054 
00055         
00056     /* Function: read
00057      *  Read the value currently output on the bus
00058      *
00059      * Variables:
00060      *  returns - An integer with each bit corresponding to associated DigitalInOut pin setting
00061      */
00062     int read();
00063 
00064     /* Function: output
00065      *  Set as an output
00066      */
00067     void output();
00068 
00069     /* Function: input
00070      *  Set as an input
00071      */
00072     void input();
00073 
00074     /* Function: mode
00075      *  Set the input pin mode
00076      *
00077      * Variables:
00078      *  mode - PullUp, PullDown, PullNone
00079      */
00080     void mode(PinMode pull);
00081  
00082 #ifdef MBED_OPERATORS
00083     /* Group: Access Method Shorthand */
00084        
00085     /* Function: operator=
00086      *  A shorthand for <write>
00087      */
00088     BusInOut& operator= (int v);
00089     BusInOut& operator= (BusInOut& rhs);
00090 
00091     /* Function: operator int()
00092      *  A shorthand for <read>
00093      */
00094     operator int();
00095 #endif
00096 
00097 #ifdef MBED_RPC
00098     virtual const struct rpc_method *get_rpc_methods();
00099     static struct rpc_class *get_rpc_class();
00100 #endif
00101 
00102 protected:
00103 
00104     DigitalInOut* _pin[16];
00105 
00106 #ifdef MBED_RPC
00107     static void construct(const char *arguments, char *res);
00108 #endif
00109             
00110 };
00111 
00112 } // namespace mbed
00113 
00114 #endif
00115