UVic Assistive Technology Lab / Mbed 2 deprecated DSLR_Camera_Gimbal

Dependencies:   mbed ros_lib_kinetic

Committer:
group-UVic-Assistive-Technolog
Date:
Wed Jan 31 05:24:12 2018 +0000
Revision:
0:3a767f41cf04
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-UVic-Assistive-Technolog 0:3a767f41cf04 1 /* mbed Microcontroller Library
group-UVic-Assistive-Technolog 0:3a767f41cf04 2 * Copyright (c) 2006-2013 ARM Limited
group-UVic-Assistive-Technolog 0:3a767f41cf04 3 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 4 * Licensed under the Apache License, Version 2.0 (the "License");
group-UVic-Assistive-Technolog 0:3a767f41cf04 5 * you may not use this file except in compliance with the License.
group-UVic-Assistive-Technolog 0:3a767f41cf04 6 * You may obtain a copy of the License at
group-UVic-Assistive-Technolog 0:3a767f41cf04 7 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 8 * http://www.apache.org/licenses/LICENSE-2.0
group-UVic-Assistive-Technolog 0:3a767f41cf04 9 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 10 * Unless required by applicable law or agreed to in writing, software
group-UVic-Assistive-Technolog 0:3a767f41cf04 11 * distributed under the License is distributed on an "AS IS" BASIS,
group-UVic-Assistive-Technolog 0:3a767f41cf04 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
group-UVic-Assistive-Technolog 0:3a767f41cf04 13 * See the License for the specific language governing permissions and
group-UVic-Assistive-Technolog 0:3a767f41cf04 14 * limitations under the License.
group-UVic-Assistive-Technolog 0:3a767f41cf04 15 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 16 #ifndef MBED_PORTOUT_H
group-UVic-Assistive-Technolog 0:3a767f41cf04 17 #define MBED_PORTOUT_H
group-UVic-Assistive-Technolog 0:3a767f41cf04 18
group-UVic-Assistive-Technolog 0:3a767f41cf04 19 #include "platform.h"
group-UVic-Assistive-Technolog 0:3a767f41cf04 20
group-UVic-Assistive-Technolog 0:3a767f41cf04 21 #if DEVICE_PORTOUT
group-UVic-Assistive-Technolog 0:3a767f41cf04 22
group-UVic-Assistive-Technolog 0:3a767f41cf04 23 #include "port_api.h"
group-UVic-Assistive-Technolog 0:3a767f41cf04 24
group-UVic-Assistive-Technolog 0:3a767f41cf04 25 namespace mbed {
group-UVic-Assistive-Technolog 0:3a767f41cf04 26 /** A multiple pin digital out
group-UVic-Assistive-Technolog 0:3a767f41cf04 27 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 28 * Example:
group-UVic-Assistive-Technolog 0:3a767f41cf04 29 * @code
group-UVic-Assistive-Technolog 0:3a767f41cf04 30 * // Toggle all four LEDs
group-UVic-Assistive-Technolog 0:3a767f41cf04 31 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 32 * #include "mbed.h"
group-UVic-Assistive-Technolog 0:3a767f41cf04 33 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 34 * // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23
group-UVic-Assistive-Technolog 0:3a767f41cf04 35 * #define LED_MASK 0x00B40000
group-UVic-Assistive-Technolog 0:3a767f41cf04 36 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 37 * PortOut ledport(Port1, LED_MASK);
group-UVic-Assistive-Technolog 0:3a767f41cf04 38 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 39 * int main() {
group-UVic-Assistive-Technolog 0:3a767f41cf04 40 * while(1) {
group-UVic-Assistive-Technolog 0:3a767f41cf04 41 * ledport = LED_MASK;
group-UVic-Assistive-Technolog 0:3a767f41cf04 42 * wait(1);
group-UVic-Assistive-Technolog 0:3a767f41cf04 43 * ledport = 0;
group-UVic-Assistive-Technolog 0:3a767f41cf04 44 * wait(1);
group-UVic-Assistive-Technolog 0:3a767f41cf04 45 * }
group-UVic-Assistive-Technolog 0:3a767f41cf04 46 * }
group-UVic-Assistive-Technolog 0:3a767f41cf04 47 * @endcode
group-UVic-Assistive-Technolog 0:3a767f41cf04 48 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 49 class PortOut {
group-UVic-Assistive-Technolog 0:3a767f41cf04 50 public:
group-UVic-Assistive-Technolog 0:3a767f41cf04 51
group-UVic-Assistive-Technolog 0:3a767f41cf04 52 /** Create an PortOut, connected to the specified port
group-UVic-Assistive-Technolog 0:3a767f41cf04 53 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 54 * @param port Port to connect to (Port0-Port5)
group-UVic-Assistive-Technolog 0:3a767f41cf04 55 * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
group-UVic-Assistive-Technolog 0:3a767f41cf04 56 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 57 PortOut(PortName port, int mask = 0xFFFFFFFF) {
group-UVic-Assistive-Technolog 0:3a767f41cf04 58 port_init(&_port, port, mask, PIN_OUTPUT);
group-UVic-Assistive-Technolog 0:3a767f41cf04 59 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 60
group-UVic-Assistive-Technolog 0:3a767f41cf04 61 /** Write the value to the output port
group-UVic-Assistive-Technolog 0:3a767f41cf04 62 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 63 * @param value An integer specifying a bit to write for every corresponding PortOut pin
group-UVic-Assistive-Technolog 0:3a767f41cf04 64 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 65 void write(int value) {
group-UVic-Assistive-Technolog 0:3a767f41cf04 66 port_write(&_port, value);
group-UVic-Assistive-Technolog 0:3a767f41cf04 67 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 68
group-UVic-Assistive-Technolog 0:3a767f41cf04 69 /** Read the value currently output on the port
group-UVic-Assistive-Technolog 0:3a767f41cf04 70 *
group-UVic-Assistive-Technolog 0:3a767f41cf04 71 * @returns
group-UVic-Assistive-Technolog 0:3a767f41cf04 72 * An integer with each bit corresponding to associated PortOut pin setting
group-UVic-Assistive-Technolog 0:3a767f41cf04 73 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 74 int read() {
group-UVic-Assistive-Technolog 0:3a767f41cf04 75 return port_read(&_port);
group-UVic-Assistive-Technolog 0:3a767f41cf04 76 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 77
group-UVic-Assistive-Technolog 0:3a767f41cf04 78 /** A shorthand for write()
group-UVic-Assistive-Technolog 0:3a767f41cf04 79 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 80 PortOut& operator= (int value) {
group-UVic-Assistive-Technolog 0:3a767f41cf04 81 write(value);
group-UVic-Assistive-Technolog 0:3a767f41cf04 82 return *this;
group-UVic-Assistive-Technolog 0:3a767f41cf04 83 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 84
group-UVic-Assistive-Technolog 0:3a767f41cf04 85 PortOut& operator= (PortOut& rhs) {
group-UVic-Assistive-Technolog 0:3a767f41cf04 86 write(rhs.read());
group-UVic-Assistive-Technolog 0:3a767f41cf04 87 return *this;
group-UVic-Assistive-Technolog 0:3a767f41cf04 88 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 89
group-UVic-Assistive-Technolog 0:3a767f41cf04 90 /** A shorthand for read()
group-UVic-Assistive-Technolog 0:3a767f41cf04 91 */
group-UVic-Assistive-Technolog 0:3a767f41cf04 92 operator int() {
group-UVic-Assistive-Technolog 0:3a767f41cf04 93 return read();
group-UVic-Assistive-Technolog 0:3a767f41cf04 94 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 95
group-UVic-Assistive-Technolog 0:3a767f41cf04 96 private:
group-UVic-Assistive-Technolog 0:3a767f41cf04 97 port_t _port;
group-UVic-Assistive-Technolog 0:3a767f41cf04 98 };
group-UVic-Assistive-Technolog 0:3a767f41cf04 99
group-UVic-Assistive-Technolog 0:3a767f41cf04 100 } // namespace mbed
group-UVic-Assistive-Technolog 0:3a767f41cf04 101
group-UVic-Assistive-Technolog 0:3a767f41cf04 102 #endif
group-UVic-Assistive-Technolog 0:3a767f41cf04 103
group-UVic-Assistive-Technolog 0:3a767f41cf04 104 #endif