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.h
- Revision:
- 0:d42cfc64e43e
- Child:
- 2:722a0e1df9a9
diff -r 000000000000 -r d42cfc64e43e ARD2PMD.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ARD2PMD.h Mon Feb 10 03:10:39 2014 +0000 @@ -0,0 +1,97 @@ +/* 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. + */ + +#ifndef ARD2PMD_H +#define ARD2PMD_H + +#include "mbed.h" +#include "MAX14661.h" + + +/** ARD2PMD Library, Provides utilities for configuring the Maxim ARD2PMD Board + * + * Example: + * @code + * // Configure board to pass UART signals to peripheral connector. + * + * #include "ARD2PMD.h" + * + * ARD2PMD a2p(p28, p27); + * + * int main() { + * a2p.setMux((ARD2PMD::RX | ARD2PMD::PA3), (ARD2PMD::TX | ARD2PMD::PA2)); + * } + * @endcode + */ +class ARD2PMD +{ +public: + + /** Create a ARD2PMD interface + * + * @param sda I2C data line pin + * @param scl I2C clock line pin + * @param addr MAX14661 I2C address + */ + ARD2PMD(PinName sda, PinName scl, int addr = 0x98); + + ~ARD2PMD(); + + /** Name the register addresses + */ + enum MUXsignals { + RX = MAX14661::SW01, + TX = MAX14661::SW02, + D2 = MAX14661::SW03, + D3 = MAX14661::SW04, + PB1 = MAX14661::SW05, + PB2 = MAX14661::SW06, + PB3 = MAX14661::SW07, + PB4 = MAX14661::SW08, + D8 = MAX14661::SW09, + D9 = MAX14661::SW10, + PA1 = MAX14661::SW11, + PA2 = MAX14661::SW12, + PA3 = MAX14661::SW13, + PA4 = MAX14661::SW14, + SDA = MAX14661::SW15, + SCL = MAX14661::SW16 + }; + + /** Opens all mux switches + */ + void clearMux(); + + /** Simultaneously sets both mux channels + * + * @param chA the signals to route through channel A + * @param chB the signals to route through channel B + */ + void setMux(int chA, int chB); + + /** Convert peripheral pin index to mux bit + * + * @param index the index [7-0] of desired pin on the peripheral connector + */ + int iToMux(int index); + +private: + MAX14661 _mux; +}; + +#endif \ No newline at end of file