Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 /* mbed Microcontroller Library
switches 0:5c4d7b2438d3 2 * Copyright (c) 2006-2013 ARM Limited
switches 0:5c4d7b2438d3 3 *
switches 0:5c4d7b2438d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
switches 0:5c4d7b2438d3 5 * you may not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 6 * You may obtain a copy of the License at
switches 0:5c4d7b2438d3 7 *
switches 0:5c4d7b2438d3 8 * http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 9 *
switches 0:5c4d7b2438d3 10 * Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
switches 0:5c4d7b2438d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 13 * See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 14 * limitations under the License.
switches 0:5c4d7b2438d3 15 */
switches 0:5c4d7b2438d3 16 #ifndef MBED_BUSINOUT_H
switches 0:5c4d7b2438d3 17 #define MBED_BUSINOUT_H
switches 0:5c4d7b2438d3 18
switches 0:5c4d7b2438d3 19 #include "drivers/DigitalInOut.h"
switches 0:5c4d7b2438d3 20 #include "platform/PlatformMutex.h"
switches 0:5c4d7b2438d3 21
switches 0:5c4d7b2438d3 22 namespace mbed {
switches 0:5c4d7b2438d3 23 /** \addtogroup drivers */
switches 0:5c4d7b2438d3 24 /** @{*/
switches 0:5c4d7b2438d3 25
switches 0:5c4d7b2438d3 26 /** A digital input output bus, used for setting the state of a collection of pins
switches 0:5c4d7b2438d3 27 *
switches 0:5c4d7b2438d3 28 * @Note Synchronization level: Thread safe
switches 0:5c4d7b2438d3 29 */
switches 0:5c4d7b2438d3 30 class BusInOut {
switches 0:5c4d7b2438d3 31
switches 0:5c4d7b2438d3 32 public:
switches 0:5c4d7b2438d3 33
switches 0:5c4d7b2438d3 34 /** Create an BusInOut, connected to the specified pins
switches 0:5c4d7b2438d3 35 *
switches 0:5c4d7b2438d3 36 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
switches 0:5c4d7b2438d3 37 *
switches 0:5c4d7b2438d3 38 * @note
switches 0:5c4d7b2438d3 39 * It is only required to specify as many pin variables as is required
switches 0:5c4d7b2438d3 40 * for the bus; the rest will default to NC (not connected)
switches 0:5c4d7b2438d3 41 */
switches 0:5c4d7b2438d3 42 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
switches 0:5c4d7b2438d3 43 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
switches 0:5c4d7b2438d3 44 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
switches 0:5c4d7b2438d3 45 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
switches 0:5c4d7b2438d3 46
switches 0:5c4d7b2438d3 47 BusInOut(PinName pins[16]);
switches 0:5c4d7b2438d3 48
switches 0:5c4d7b2438d3 49 virtual ~BusInOut();
switches 0:5c4d7b2438d3 50
switches 0:5c4d7b2438d3 51 /* Group: Access Methods */
switches 0:5c4d7b2438d3 52
switches 0:5c4d7b2438d3 53 /** Write the value to the output bus
switches 0:5c4d7b2438d3 54 *
switches 0:5c4d7b2438d3 55 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
switches 0:5c4d7b2438d3 56 */
switches 0:5c4d7b2438d3 57 void write(int value);
switches 0:5c4d7b2438d3 58
switches 0:5c4d7b2438d3 59 /** Read the value currently output on the bus
switches 0:5c4d7b2438d3 60 *
switches 0:5c4d7b2438d3 61 * @returns
switches 0:5c4d7b2438d3 62 * An integer with each bit corresponding to associated DigitalInOut pin setting
switches 0:5c4d7b2438d3 63 */
switches 0:5c4d7b2438d3 64 int read();
switches 0:5c4d7b2438d3 65
switches 0:5c4d7b2438d3 66 /** Set as an output
switches 0:5c4d7b2438d3 67 */
switches 0:5c4d7b2438d3 68 void output();
switches 0:5c4d7b2438d3 69
switches 0:5c4d7b2438d3 70 /** Set as an input
switches 0:5c4d7b2438d3 71 */
switches 0:5c4d7b2438d3 72 void input();
switches 0:5c4d7b2438d3 73
switches 0:5c4d7b2438d3 74 /** Set the input pin mode
switches 0:5c4d7b2438d3 75 *
switches 0:5c4d7b2438d3 76 * @param mode PullUp, PullDown, PullNone
switches 0:5c4d7b2438d3 77 */
switches 0:5c4d7b2438d3 78 void mode(PinMode pull);
switches 0:5c4d7b2438d3 79
switches 0:5c4d7b2438d3 80 /** Binary mask of bus pins connected to actual pins (not NC pins)
switches 0:5c4d7b2438d3 81 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
switches 0:5c4d7b2438d3 82 *
switches 0:5c4d7b2438d3 83 * @returns
switches 0:5c4d7b2438d3 84 * Binary mask of connected pins
switches 0:5c4d7b2438d3 85 */
switches 0:5c4d7b2438d3 86 int mask() {
switches 0:5c4d7b2438d3 87 // No lock needed since _nc_mask is not modified outside the constructor
switches 0:5c4d7b2438d3 88 return _nc_mask;
switches 0:5c4d7b2438d3 89 }
switches 0:5c4d7b2438d3 90
switches 0:5c4d7b2438d3 91 /** A shorthand for write()
switches 0:5c4d7b2438d3 92 */
switches 0:5c4d7b2438d3 93 BusInOut& operator= (int v);
switches 0:5c4d7b2438d3 94 BusInOut& operator= (BusInOut& rhs);
switches 0:5c4d7b2438d3 95
switches 0:5c4d7b2438d3 96 /** Access to particular bit in random-iterator fashion
switches 0:5c4d7b2438d3 97 */
switches 0:5c4d7b2438d3 98 DigitalInOut& operator[] (int index);
switches 0:5c4d7b2438d3 99
switches 0:5c4d7b2438d3 100 /** A shorthand for read()
switches 0:5c4d7b2438d3 101 */
switches 0:5c4d7b2438d3 102 operator int();
switches 0:5c4d7b2438d3 103
switches 0:5c4d7b2438d3 104 protected:
switches 0:5c4d7b2438d3 105 virtual void lock();
switches 0:5c4d7b2438d3 106 virtual void unlock();
switches 0:5c4d7b2438d3 107 DigitalInOut* _pin[16];
switches 0:5c4d7b2438d3 108
switches 0:5c4d7b2438d3 109 /** Mask of bus's NC pins
switches 0:5c4d7b2438d3 110 * If bit[n] is set to 1 - pin is connected
switches 0:5c4d7b2438d3 111 * if bit[n] is cleared - pin is not connected (NC)
switches 0:5c4d7b2438d3 112 */
switches 0:5c4d7b2438d3 113 int _nc_mask;
switches 0:5c4d7b2438d3 114
switches 0:5c4d7b2438d3 115 PlatformMutex _mutex;
switches 0:5c4d7b2438d3 116
switches 0:5c4d7b2438d3 117 /* disallow copy constructor and assignment operators */
switches 0:5c4d7b2438d3 118 private:
switches 0:5c4d7b2438d3 119 BusInOut(const BusInOut&);
switches 0:5c4d7b2438d3 120 BusInOut & operator = (const BusInOut&);
switches 0:5c4d7b2438d3 121 };
switches 0:5c4d7b2438d3 122
switches 0:5c4d7b2438d3 123 } // namespace mbed
switches 0:5c4d7b2438d3 124
switches 0:5c4d7b2438d3 125 #endif
switches 0:5c4d7b2438d3 126
switches 0:5c4d7b2438d3 127 /** @}*/