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 mbed by
PortOut.h
00001 /* mbed Microcontroller Library - PortOut 00002 * Copyright (c) 2006-2011 ARM Limited. All rights reserved. 00003 */ 00004 00005 #ifndef MBED_PORTOUT_H 00006 #define MBED_PORTOUT_H 00007 00008 #include "device.h" 00009 00010 #if DEVICE_PORTOUT 00011 00012 #include "platform.h" 00013 #include "PinNames.h" 00014 #include "Base.h" 00015 00016 #include "PortNames.h" 00017 00018 namespace mbed { 00019 /* Class: PortOut 00020 * A multiple pin digital out 00021 * 00022 * Example: 00023 * > // Toggle all four LEDs 00024 * > 00025 * > #include "mbed.h" 00026 * > 00027 * > // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23 00028 * > #define LED_MASK 0x00B40000 00029 * > 00030 * > PortOut ledport(Port1, LED_MASK); 00031 * > 00032 * > int main() { 00033 * > while(1) { 00034 * > ledport = LED_MASK; 00035 * > wait(1); 00036 * > ledport = 0; 00037 * > wait(1); 00038 * > } 00039 * > } 00040 */ 00041 class PortOut { 00042 public: 00043 00044 /* Constructor: PortOut 00045 * Create an PortOut, connected to the specified port 00046 * 00047 * Variables: 00048 * port - Port to connect to (Port0-Port5) 00049 * mask - A bitmask to identify which bits in the port should be included (0 - ignore) 00050 */ 00051 PortOut(PortName port, int mask = 0xFFFFFFFF); 00052 00053 /* Function: write 00054 * Write the value to the output port 00055 * 00056 * Variables: 00057 * value - An integer specifying a bit to write for every corresponding PortOut pin 00058 */ 00059 void write(int value); 00060 00061 /* Function: read 00062 * Read the value currently output on the port 00063 * 00064 * Variables: 00065 * returns - An integer with each bit corresponding to associated PortOut pin setting 00066 */ 00067 int read(); 00068 00069 /* Function: operator= 00070 * A shorthand for <write> 00071 */ 00072 PortOut& operator= (int value) { 00073 write(value); 00074 return *this; 00075 } 00076 00077 PortOut& operator= (PortOut& rhs) { 00078 write(rhs.read()); 00079 return *this; 00080 } 00081 00082 /* Function: operator int() 00083 * A shorthand for <read> 00084 */ 00085 operator int() { 00086 return read(); 00087 } 00088 00089 private: 00090 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) 00091 LPC_GPIO_TypeDef *_gpio; 00092 #endif 00093 PortName _port; 00094 uint32_t _mask; 00095 }; 00096 00097 } // namespace mbed 00098 00099 #endif 00100 00101 #endif
Generated on Wed Jul 13 2022 00:10:01 by
