Arduino to Peripheral Module adapter library

Dependents:   ARD2PMD_WebServer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ARD2PMD.h Source File

ARD2PMD.h

00001 /* ARD2PMD Board Driver Library
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  */
00018 
00019 #ifndef ARD2PMD_H
00020 #define ARD2PMD_H
00021 
00022 #include "mbed.h"
00023 #include "MAX14661.h"
00024 
00025 
00026 /** ARD2PMD Library, Provides utilities for configuring the Maxim ARD2PMD Board
00027  *
00028  * Example:
00029  * @code
00030  * // Configure board to pass UART signals to peripheral connector.
00031  *
00032  * #include "ARD2PMD.h"
00033  *
00034  * ARD2PMD a2p();
00035  *
00036  * int main() {
00037  *     a2p.mux.setAB((ARD2PMD::RX | ARD2PMD::PA3), (ARD2PMD::TX | ARD2PMD::PA2));
00038  * }
00039  * @endcode
00040  */
00041 class ARD2PMD
00042 {
00043 public:
00044 
00045     /** Create a ARD2PMD interface
00046      *
00047      * @param sda I2C data line pin
00048      * @param scl I2C clock line pin
00049      * @param addr MAX14661 I2C address
00050      */
00051     ARD2PMD();
00052 
00053     ~ARD2PMD();
00054 
00055     /** Initialize the digital pins and PWM
00056      *
00057      */
00058     void init();
00059 
00060     /** ard2pmd resources mux, digital IO
00061     */
00062     MAX14661 mux;
00063     DigitalInOut pa1;
00064     DigitalInOut pa2;
00065     DigitalInOut pa3;
00066     DigitalInOut pa4;
00067     DigitalInOut pb1;
00068     DigitalInOut pb2;
00069     DigitalInOut pb3;
00070     DigitalInOut pb4;
00071 
00072     /** Array of pointers to the DIO pins
00073     */
00074     DigitalInOut *pmd[8];
00075 
00076     /** LUT for multiplexer micro connections
00077     */
00078     static const int mux_a[17];
00079 
00080     /** LUT for multiplexer PMOD connections
00081     */
00082     static const int mux_p[9];
00083 
00084     /** Name the register addresses
00085     */
00086     enum MUXsignals {
00087         RX = MAX14661::SW01,  /**< UART Receive */
00088         TX = MAX14661::SW02,  /**< UART Transmit */
00089         D2 = MAX14661::SW03,  /**< Digital 2 */
00090         D3 = MAX14661::SW04,  /**< Digital 3 */
00091         PB1 = MAX14661::SW05, /**< Pmd row B pin 1 */
00092         PB2 = MAX14661::SW06, /**< Pmd row B pin 2 */
00093         PB3 = MAX14661::SW07, /**< Pmd row B pin 3 */
00094         PB4 = MAX14661::SW08, /**< Pmd row B pin 4 */
00095         D8 = MAX14661::SW16,  /**< Digital 8 */
00096         D9 = MAX14661::SW15,  /**< Digital 9 */
00097         PA1 = MAX14661::SW14, /**< Pmd row A pin 1 */
00098         PA2 = MAX14661::SW13, /**< Pmd row A pin 1 */
00099         PA3 = MAX14661::SW12, /**< Pmd row A pin 1 */
00100         PA4 = MAX14661::SW11, /**< Pmd row A pin 1 */
00101         SDA = MAX14661::SW10, /**< I2C Data */
00102         SCL = MAX14661::SW09  /**< I2C Clock */
00103     };
00104 
00105 };
00106 
00107 #endif