This is a data logger program to be implemented with an instrument amplifier.

Dependencies:   mbed

Committer:
KISScientific
Date:
Tue Apr 04 18:01:11 2017 +0000
Revision:
0:d75ca4e39672
This is a data logger program.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KISScientific 0:d75ca4e39672 1 /* mbed Microcontroller Library - PortInOut
KISScientific 0:d75ca4e39672 2 * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
KISScientific 0:d75ca4e39672 3 */
KISScientific 0:d75ca4e39672 4
KISScientific 0:d75ca4e39672 5 #ifndef MBED_PORTIN_H
KISScientific 0:d75ca4e39672 6 #define MBED_PORTIN_H
KISScientific 0:d75ca4e39672 7
KISScientific 0:d75ca4e39672 8 #include "PortNames.h"
KISScientific 0:d75ca4e39672 9 #include "PinNames.h"
KISScientific 0:d75ca4e39672 10
KISScientific 0:d75ca4e39672 11 namespace mbed {
KISScientific 0:d75ca4e39672 12
KISScientific 0:d75ca4e39672 13 /* Class: PortIn
KISScientific 0:d75ca4e39672 14 * A multiple pin digital input
KISScientific 0:d75ca4e39672 15 *
KISScientific 0:d75ca4e39672 16 * Example:
KISScientific 0:d75ca4e39672 17 * > // Switch on an LED if any of mbed pins 21-26 is high
KISScientific 0:d75ca4e39672 18 * >
KISScientific 0:d75ca4e39672 19 * > #include "mbed.h"
KISScientific 0:d75ca4e39672 20 * >
KISScientific 0:d75ca4e39672 21 * > PortIn p(Port2, 0x0000003F); // p21-p26
KISScientific 0:d75ca4e39672 22 * > DigitalOut ind(LED4);
KISScientific 0:d75ca4e39672 23 * >
KISScientific 0:d75ca4e39672 24 * > int main() {
KISScientific 0:d75ca4e39672 25 * > while(1) {
KISScientific 0:d75ca4e39672 26 * > int pins = p.read();
KISScientific 0:d75ca4e39672 27 * > if(pins) {
KISScientific 0:d75ca4e39672 28 * > ind = 1;
KISScientific 0:d75ca4e39672 29 * > } else {
KISScientific 0:d75ca4e39672 30 * > ind = 0;
KISScientific 0:d75ca4e39672 31 * > }
KISScientific 0:d75ca4e39672 32 * > }
KISScientific 0:d75ca4e39672 33 * > }
KISScientific 0:d75ca4e39672 34 */
KISScientific 0:d75ca4e39672 35 class PortIn {
KISScientific 0:d75ca4e39672 36 public:
KISScientific 0:d75ca4e39672 37
KISScientific 0:d75ca4e39672 38 /* Constructor: PortIn
KISScientific 0:d75ca4e39672 39 * Create an PortIn, connected to the specified port
KISScientific 0:d75ca4e39672 40 *
KISScientific 0:d75ca4e39672 41 * Variables:
KISScientific 0:d75ca4e39672 42 * port - Port to connect to (Port0-Port5)
KISScientific 0:d75ca4e39672 43 * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
KISScientific 0:d75ca4e39672 44 */
KISScientific 0:d75ca4e39672 45 PortIn(PortName port, int mask = 0xFFFFFFFF);
KISScientific 0:d75ca4e39672 46
KISScientific 0:d75ca4e39672 47 /* Function: read
KISScientific 0:d75ca4e39672 48 * Read the value currently output on the port
KISScientific 0:d75ca4e39672 49 *
KISScientific 0:d75ca4e39672 50 * Variables:
KISScientific 0:d75ca4e39672 51 * returns - An integer with each bit corresponding to associated port pin setting
KISScientific 0:d75ca4e39672 52 */
KISScientific 0:d75ca4e39672 53 int read() {
KISScientific 0:d75ca4e39672 54 return _gpio->FIOPIN & _mask;
KISScientific 0:d75ca4e39672 55 }
KISScientific 0:d75ca4e39672 56
KISScientific 0:d75ca4e39672 57 /* Function: mode
KISScientific 0:d75ca4e39672 58 * Set the input pin mode
KISScientific 0:d75ca4e39672 59 *
KISScientific 0:d75ca4e39672 60 * Variables:
KISScientific 0:d75ca4e39672 61 * mode - PullUp, PullDown, PullNone, OpenDrain
KISScientific 0:d75ca4e39672 62 */
KISScientific 0:d75ca4e39672 63 void mode(PinMode mode);
KISScientific 0:d75ca4e39672 64
KISScientific 0:d75ca4e39672 65 /* Function: operator int()
KISScientific 0:d75ca4e39672 66 * A shorthand for <read>
KISScientific 0:d75ca4e39672 67 */
KISScientific 0:d75ca4e39672 68 operator int() {
KISScientific 0:d75ca4e39672 69 return read();
KISScientific 0:d75ca4e39672 70 }
KISScientific 0:d75ca4e39672 71
KISScientific 0:d75ca4e39672 72 private:
KISScientific 0:d75ca4e39672 73 LPC_GPIO_TypeDef *_gpio;
KISScientific 0:d75ca4e39672 74 PortName _port;
KISScientific 0:d75ca4e39672 75 uint32_t _mask;
KISScientific 0:d75ca4e39672 76 };
KISScientific 0:d75ca4e39672 77
KISScientific 0:d75ca4e39672 78 } // namespace mbed
KISScientific 0:d75ca4e39672 79
KISScientific 0:d75ca4e39672 80 #endif