mbd2pmd Adapter Board Library

Dependents:   MBD2PMD_WebServer

This library assigns the proper pins for the mbed LPC1768 with the mbd2pmd adapter board.

  • microSD pins sd(p5, p6, p7, p8 "sd")
  • mux I2C pins mux(p28, p27)

Digital I/O

pmd[8] is an array of pointers to the DigitalInOut objects

IndexNamePmod
0pa11
1pa22
2pa33
3pa44
4pb17
5pb28
6pb39
7pb410

MAX14661 Multiplexer Abstraction

mux_a[17] is an array of integers representing the bit mask of a multiplexer switch arranged in Arduino order

IndexPinName
0p10RX
1p9TX
2p30RD
3p25PWM1
4p24PB1
5p23PB2
6p22PB3
7p21PB4
8p29TD
9p26PWM2
10p14PA1
11p11PA2
12p12PA3
13p13PA4
14p28SDA
15p27SCL
16na0

mux_p[9] is an array of integers representing the bit mask of a multiplexer switch arranged in Pmod order

IndexPinName
0p14PA1
1p11PA2
2p12PA3
3p13PA4
4p24PB1
5p23PB2
6p22PB3
7p21PB4
8na0

Files at this revision

API Documentation at this revision

Comitter:
gsteiert
Date:
Sat May 10 00:35:23 2014 +0000
Commit message:
mbd2pmd Adapter Board Library initial publication

Changed in this revision

mbd2pmd.cpp Show annotated file Show diff for this revision Revisions of this file
mbd2pmd.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbd2pmd.cpp	Sat May 10 00:35:23 2014 +0000
@@ -0,0 +1,37 @@
+/* mbd2pmd Board Driver Library
+ *
+ */
+
+#include "mbed.h"
+#include "mbd2pmd.h"
+
+mbd2pmd::mbd2pmd() :
+    mux(p28, p27), sd(p5, p6, p7, p8, "sd"),
+    pa1(p14), pa2(p11), pa3(p12), pa4(p13),
+    pb1(p24), pb2(p23), pb3(p22), pb4(p21)
+{
+}
+
+mbd2pmd::~mbd2pmd()
+{
+}
+
+const int mbd2pmd::mux_a[17] = {RX, TX, RD, PWM1, PB1, PB2, PB3, PB4, TD, PWM2, PA1, PA2, PA3, PA4, SDA, SCL, 0};
+const int mbd2pmd::mux_p[9] = {PA1, PA2, PA3, PA4, PB1, PB2, PB3, PB4, 0};
+
+// Initialize Digital IO to inputs with no pullups
+void mbd2pmd::init()
+{
+    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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbd2pmd.h	Sat May 10 00:35:23 2014 +0000
@@ -0,0 +1,91 @@
+/* mbd2pmd Board Driver Library
+ *
+ */
+
+#ifndef MBD2PMD_H
+#define MBD2PMD_H
+
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "MAX14661.h"
+
+/** mbd2pmd Library, Provides utilities for configuring the mbd2pmd Board
+ *
+ * Example:
+ * @code
+ * // Configure board to pass UART signals to peripheral connector.
+ *
+ * #include "mbd2pmd.h"
+ *
+ * mbd2pmd m2p;
+ *
+ * int main() {
+ *     m2p.mux.setAB((mbd2pmd::RX | mbd2pmd::PA3), (mbd2pmd::TX | mbd2pmd::PA2));
+ * }
+ * @endcode
+ */
+class mbd2pmd
+{
+public:
+
+    /** Create a mbd2pmd interface
+     *
+     */
+    mbd2pmd();
+
+    ~mbd2pmd();
+
+    /** Initialize the digital pins and PWM
+     *
+     */
+    void init();
+
+    /** mbd2pmd resources SD card, mux, digital IO
+    */
+    SDFileSystem sd;
+    MAX14661 mux;
+    DigitalInOut pa1;
+    DigitalInOut pa2;
+    DigitalInOut pa3;
+    DigitalInOut pa4;
+    DigitalInOut pb1;
+    DigitalInOut pb2;
+    DigitalInOut pb3;
+    DigitalInOut pb4;
+
+    /** Array of pointers to the DIO pins
+    */
+    DigitalInOut *pmd[8];
+
+    /** LUT for multiplexer micro connections
+    */
+    static const int mux_a[17];
+
+    /** LUT for multiplexer PMOD connections
+    */
+    static const int mux_p[9];
+
+    /** Name the multiplexer connections
+    */
+    enum MUXsignals {
+        PWM1 = MAX14661::SW01,  /**< (1<<0) PWM */
+        PWM2 = MAX14661::SW02,  /**< (1<<1) PWM */
+        SCL = MAX14661::SW03,  /**< (1<<2) I2C Clock */
+        SDA = MAX14661::SW04,  /**< (1<<3) I2C Data */
+        TD = MAX14661::SW05,  /**< (1<<4) CAN Transmit */
+        RD = MAX14661::SW06,  /**< (1<<5) CAN Receive */
+        TX = MAX14661::SW07,  /**< (1<<6) UART Transmit */
+        RX = MAX14661::SW08,  /**< (1<<7) UART Receive */
+        PA1 = MAX14661::SW09,  /**< (1<<8) Pmd row A pin 1 */
+        PB1 = MAX14661::SW10,  /**< (1<<9) Pmd row B pin 1 */
+        PA2 = MAX14661::SW11,  /**< (1<<10) Pmd row A pin 2 */
+        PB2 = MAX14661::SW12,  /**< (1<<11) Pmd row B pin 2 */
+        PA3 = MAX14661::SW13,  /**< (1<<12) Pmd row A pin 3 */
+        PB3 = MAX14661::SW14,  /**< (1<<13) Pmd row B pin 3 */
+        PA4 = MAX14661::SW15,  /**< (1<<14) Pmd row A pin 4 */
+        PB4 = MAX14661::SW16   /**< (1<<15) Pmd row B pin 4 */
+    };
+
+};
+
+#endif
\ No newline at end of file