Share an input pin to many pins.

MCU Gear can change mbed's pin assign very quick.

So, we made "input pin changer". It only use 1 input pin!

http://www.mcugear.com/en/

MCU Gearはピンアサインを素早く変更できます。そこで、1つの入力端子を複数の端子に切り替える。1入力端子チェンジャーを作りました。

http://www.mcugear.com/

This is sample code. (I used MCU Gear and LPC1114FN28)

Input changer

#include "mbed.h"

#include "MCUGearBaseALPC1114.h"
#include "MCUGearALPC1114.h"
#include "commonALPC1114.h"

Serial pc(dp16, dp15);

void setIOUni(MCUGear *mcugear);

MCUGear UniM(dp5, dp27, N_VDD_VDD_VDD);

//inputpins = P1_8
DigitalIn Din1(dp17);

void setIOUni(MCUGear *mcugear, int pin);

int main() {
    
    int sw;
    pc.printf("Hello World!\r\n");
        
    wait(1);
    
    initBase(); //initialize Baseboard
    
    UniM.detectModule();    //save location data in MCUGear class.
    
    int i;
    
    while(1) {
        UniM.connectModuleA();

        for(i=0; i<8; ++i){
            setIOUni(&UniM, i);
            sw = Din1.read();
            printf("sw%d = %d ",i,sw);
        }
        printf("\r\n");
        UniM.disconnectModule();
    }
}


void setIOUni(MCUGear *mcugear, int pin){ //changing pin assign.
    mcugear->clear();   //must be clear saved IO
    mcugear->setWireA(IOin1, IO_REG_IN_DIR, pin); //din1
}


Please log in to post comments.