Arduino to Peripheral Module adapter library
This library assigns the proper pins for an Arduino compatible board with the ard2pmd adapter board.
- mux I2C pins
mux(D14, D15)
Digital I/O
pmd[8]
is an array of pointers to the DigitalInOut objects
Index | Name | Pmod |
---|---|---|
0 | pa1 | 1 |
1 | pa2 | 2 |
2 | pa3 | 3 |
3 | pa4 | 4 |
4 | pb1 | 7 |
5 | pb2 | 8 |
6 | pb3 | 9 |
7 | pb4 | 10 |
MAX14661 Multiplexer Abstraction
mux_a[17]
is an array of integers representing the bit mask of a multiplexer switch arranged in Arduino order
Index | Pin | Name |
---|---|---|
0 | D0 | RX |
1 | D1 | TX |
2 | D2 | D3 |
3 | D3 | D4 |
4 | D4 | PB1 |
5 | D5 | PB2 |
6 | D6 | PB3 |
7 | D7 | PB4 |
8 | D8 | D8 |
9 | D9 | D9 |
10 | D10 | PA1 |
11 | D11 | PA2 |
12 | D12 | PA3 |
13 | D13 | PA4 |
14 | D14 | SDA |
15 | D15 | SCL |
16 | na | 0 |
mux_p[9]
is an array of integers representing the bit mask of a multiplexer switch arranged in Pmod order
Index | Pin | Name |
---|---|---|
0 | D10 | PA1 |
1 | D11 | PA2 |
2 | D12 | PA3 |
3 | D13 | PA4 |
4 | D4 | PB1 |
5 | D5 | PB2 |
6 | D6 | PB3 |
7 | D7 | PB4 |
8 | na | 0 |
Diff: ARD2PMD.cpp
- Revision:
- 3:18ae8990f74b
- Parent:
- 1:0368c98bf4ee
--- a/ARD2PMD.cpp Sat Feb 15 22:08:18 2014 +0000 +++ b/ARD2PMD.cpp Sat May 10 02:05:38 2014 +0000 @@ -1,25 +1,14 @@ /* ARD2PMD Board Driver Library * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "ARD2PMD.h" #include "mbed.h" -ARD2PMD::ARD2PMD(PinName sda, PinName scl, int addr) : _mux(sda, scl, addr) +ARD2PMD::ARD2PMD() : + pa1(D10), pa2(D11), pa3(D12), pa4(D13), + pb1(D4), pb2(D5), pb3(D6), pb4(D7), + mux(D14, D15) { } @@ -27,36 +16,22 @@ { } -void ARD2PMD::clearMux() -{ - _mux.clearAll(); -} +const int ARD2PMD::mux_a[17] = {RX, TX, D2, D3, PB1, PB2, PB3, PB4, D8, D9, PA1, PA2, PA3, PA4, SDA, SCL, 0}; +const int ARD2PMD::mux_p[9] = {PA1, PA2, PA3, PA4, PB1, PB2, PB3, PB4, 0}; -void ARD2PMD::setMux(int chA, int chB) -{ - _mux.setAB(chA, chB); -} - -int ARD2PMD::iToMux(int index) +// Initialize Digital IO to inputs with no pullups +void ARD2PMD::init() { - switch (index) { - case 0: - return PA1; - case 1: - return PA2; - case 2: - return PA3; - case 3: - return PA4; - case 4: - return PB1; - case 5: - return PB2; - case 6: - return PB3; - case 7: - return PB4; - default: - return 0; + pmd[0] = &pa1; + pmd[1] = &pa2; + pmd[2] = &pa3; + pmd[3] = &pa4; + pmd[4] = &pb1; + pmd[5] = &pb2; + pmd[6] = &pb3; + pmd[7] = &pb4; + for (int i=0; i < 8; i++) { + (*pmd[i]).mode(PullNone); + (*pmd[i]).input(); } -} \ No newline at end of file +}