test
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
source/drivers/MicroBitIO.cpp@1:8aa5cdb4ab67, 2016-04-07 (annotated)
- Committer:
- Jonathan Austin
- Date:
- Thu Apr 07 01:33:22 2016 +0100
- Revision:
- 1:8aa5cdb4ab67
Synchronized with git rev 55cb9199
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
1:8aa5cdb4ab67 | 1 | /* |
Jonathan Austin |
1:8aa5cdb4ab67 | 2 | The MIT License (MIT) |
Jonathan Austin |
1:8aa5cdb4ab67 | 3 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 4 | Copyright (c) 2016 British Broadcasting Corporation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 5 | This software is provided by Lancaster University by arrangement with the BBC. |
Jonathan Austin |
1:8aa5cdb4ab67 | 6 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 7 | Permission is hereby granted, free of charge, to any person obtaining a |
Jonathan Austin |
1:8aa5cdb4ab67 | 8 | copy of this software and associated documentation files (the "Software"), |
Jonathan Austin |
1:8aa5cdb4ab67 | 9 | to deal in the Software without restriction, including without limitation |
Jonathan Austin |
1:8aa5cdb4ab67 | 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Jonathan Austin |
1:8aa5cdb4ab67 | 11 | and/or sell copies of the Software, and to permit persons to whom the |
Jonathan Austin |
1:8aa5cdb4ab67 | 12 | Software is furnished to do so, subject to the following conditions: |
Jonathan Austin |
1:8aa5cdb4ab67 | 13 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 14 | The above copyright notice and this permission notice shall be included in |
Jonathan Austin |
1:8aa5cdb4ab67 | 15 | all copies or substantial portions of the Software. |
Jonathan Austin |
1:8aa5cdb4ab67 | 16 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Jonathan Austin |
1:8aa5cdb4ab67 | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Jonathan Austin |
1:8aa5cdb4ab67 | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
Jonathan Austin |
1:8aa5cdb4ab67 | 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Jonathan Austin |
1:8aa5cdb4ab67 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
Jonathan Austin |
1:8aa5cdb4ab67 | 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
Jonathan Austin |
1:8aa5cdb4ab67 | 23 | DEALINGS IN THE SOFTWARE. |
Jonathan Austin |
1:8aa5cdb4ab67 | 24 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 25 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 26 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 27 | * Class definition for MicroBit IO. |
Jonathan Austin |
1:8aa5cdb4ab67 | 28 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 29 | * Represents a collection of all I/O pins on the edge connector. |
Jonathan Austin |
1:8aa5cdb4ab67 | 30 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 31 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 32 | #include "MicroBitConfig.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 33 | #include "MicroBitIO.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 34 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 35 | /** |
Jonathan Austin |
1:8aa5cdb4ab67 | 36 | * Constructor. |
Jonathan Austin |
1:8aa5cdb4ab67 | 37 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 38 | * Create a representation of all given I/O pins on the edge connector |
Jonathan Austin |
1:8aa5cdb4ab67 | 39 | * |
Jonathan Austin |
1:8aa5cdb4ab67 | 40 | * Accepts a sequence of unique ID's used to distinguish events raised |
Jonathan Austin |
1:8aa5cdb4ab67 | 41 | * by MicroBitPin instances on the default EventModel. |
Jonathan Austin |
1:8aa5cdb4ab67 | 42 | */ |
Jonathan Austin |
1:8aa5cdb4ab67 | 43 | MicroBitIO::MicroBitIO(int ID_P0, int ID_P1, int ID_P2, |
Jonathan Austin |
1:8aa5cdb4ab67 | 44 | int ID_P3, int ID_P4, int ID_P5, |
Jonathan Austin |
1:8aa5cdb4ab67 | 45 | int ID_P6, int ID_P7, int ID_P8, |
Jonathan Austin |
1:8aa5cdb4ab67 | 46 | int ID_P9, int ID_P10,int ID_P11, |
Jonathan Austin |
1:8aa5cdb4ab67 | 47 | int ID_P12,int ID_P13,int ID_P14, |
Jonathan Austin |
1:8aa5cdb4ab67 | 48 | int ID_P15,int ID_P16,int ID_P19, |
Jonathan Austin |
1:8aa5cdb4ab67 | 49 | int ID_P20) : |
Jonathan Austin |
1:8aa5cdb4ab67 | 50 | P0 (ID_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_ALL), //P0 is the left most pad (ANALOG/DIGITAL/TOUCH) |
Jonathan Austin |
1:8aa5cdb4ab67 | 51 | P1 (ID_P1, MICROBIT_PIN_P1, PIN_CAPABILITY_ALL), //P1 is the middle pad (ANALOG/DIGITAL/TOUCH) |
Jonathan Austin |
1:8aa5cdb4ab67 | 52 | P2 (ID_P2, MICROBIT_PIN_P2, PIN_CAPABILITY_ALL), //P2 is the right most pad (ANALOG/DIGITAL/TOUCH) |
Jonathan Austin |
1:8aa5cdb4ab67 | 53 | P3 (ID_P3, MICROBIT_PIN_P3, PIN_CAPABILITY_AD), //COL1 (ANALOG/DIGITAL) |
Jonathan Austin |
1:8aa5cdb4ab67 | 54 | P4 (ID_P4, MICROBIT_PIN_P4, PIN_CAPABILITY_AD), //COL2 (ANALOG/DIGITAL) |
Jonathan Austin |
1:8aa5cdb4ab67 | 55 | P5 (ID_P5, MICROBIT_PIN_P5, PIN_CAPABILITY_DIGITAL), //BTN_A |
Jonathan Austin |
1:8aa5cdb4ab67 | 56 | P6 (ID_P6, MICROBIT_PIN_P6, PIN_CAPABILITY_DIGITAL), //ROW2 |
Jonathan Austin |
1:8aa5cdb4ab67 | 57 | P7 (ID_P7, MICROBIT_PIN_P7, PIN_CAPABILITY_DIGITAL), //ROW1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 58 | P8 (ID_P8, MICROBIT_PIN_P8, PIN_CAPABILITY_DIGITAL), //PIN 18 |
Jonathan Austin |
1:8aa5cdb4ab67 | 59 | P9 (ID_P9, MICROBIT_PIN_P9, PIN_CAPABILITY_DIGITAL), //ROW3 |
Jonathan Austin |
1:8aa5cdb4ab67 | 60 | P10(ID_P10,MICROBIT_PIN_P10,PIN_CAPABILITY_AD), //COL3 (ANALOG/DIGITAL) |
Jonathan Austin |
1:8aa5cdb4ab67 | 61 | P11(ID_P11,MICROBIT_PIN_P11,PIN_CAPABILITY_DIGITAL), //BTN_B |
Jonathan Austin |
1:8aa5cdb4ab67 | 62 | P12(ID_P12,MICROBIT_PIN_P12,PIN_CAPABILITY_DIGITAL), //PIN 20 |
Jonathan Austin |
1:8aa5cdb4ab67 | 63 | P13(ID_P13,MICROBIT_PIN_P13,PIN_CAPABILITY_DIGITAL), //SCK |
Jonathan Austin |
1:8aa5cdb4ab67 | 64 | P14(ID_P14,MICROBIT_PIN_P14,PIN_CAPABILITY_DIGITAL), //MISO |
Jonathan Austin |
1:8aa5cdb4ab67 | 65 | P15(ID_P15,MICROBIT_PIN_P15,PIN_CAPABILITY_DIGITAL), //MOSI |
Jonathan Austin |
1:8aa5cdb4ab67 | 66 | P16(ID_P16,MICROBIT_PIN_P16,PIN_CAPABILITY_DIGITAL), //PIN 16 |
Jonathan Austin |
1:8aa5cdb4ab67 | 67 | P19(ID_P19,MICROBIT_PIN_P19,PIN_CAPABILITY_DIGITAL), //SCL |
Jonathan Austin |
1:8aa5cdb4ab67 | 68 | P20(ID_P20,MICROBIT_PIN_P20,PIN_CAPABILITY_DIGITAL) //SDA |
Jonathan Austin |
1:8aa5cdb4ab67 | 69 | { |
Jonathan Austin |
1:8aa5cdb4ab67 | 70 | } |