For LPC1114FN28

Dependencies:   MCUGearALPC1114 TextLCD mbed

Committer:
Info
Date:
Sat May 03 17:09:44 2014 +0000
Revision:
1:fbea002af117
Parent:
0:b107e3217731
changed file name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Info 0:b107e3217731 1
Info 0:b107e3217731 2 #include "mbed.h"
Info 0:b107e3217731 3 #include "TextLCD.h"
Info 0:b107e3217731 4
Info 1:fbea002af117 5 #include "MCUGearBaseALPC1114.h"
Info 1:fbea002af117 6 #include "MCUGearALPC1114.h"
Info 1:fbea002af117 7 #include "commonALPC1114.h"
Info 0:b107e3217731 8
Info 0:b107e3217731 9 Serial pc(dp16, dp15); // tx, rx Set BaudRate = 115200 in main()
Info 0:b107e3217731 10
Info 0:b107e3217731 11 void setIOUni(MCUGear *mcugear);
Info 0:b107e3217731 12 void setIOLCD(MCUGear *mcugear);
Info 0:b107e3217731 13
Info 0:b107e3217731 14 MCUGear UniM(dp5, dp27, N_VDD_VDD_VDD); //2 Connector Universal Module
Info 0:b107e3217731 15 MCUGear LCDM(dp5, dp27, N_VDD_VSS_VSS); //LCD Module
Info 0:b107e3217731 16
Info 0:b107e3217731 17 //output pins = P0_3, P0_7, P0_11, P1_0, P1_1, P1_2, P1_4, P1_5
Info 0:b107e3217731 18 DigitalOut Dout1(dp26);
Info 0:b107e3217731 19 DigitalOut Dout2(dp28);
Info 0:b107e3217731 20 DigitalOut Dout3(dp4);
Info 0:b107e3217731 21 DigitalOut Dout4(dp9);
Info 0:b107e3217731 22 DigitalOut Dout5(dp10);
Info 0:b107e3217731 23 DigitalOut Dout6(dp11);
Info 0:b107e3217731 24 DigitalOut Dout7(dp14);
Info 0:b107e3217731 25 DigitalOut Dout8(dp15);
Info 0:b107e3217731 26
Info 0:b107e3217731 27 //inputpins = P1_8, P1_9
Info 0:b107e3217731 28 DigitalIn Din1(dp17);
Info 0:b107e3217731 29 DigitalIn Din2(dp18);
Info 0:b107e3217731 30
Info 0:b107e3217731 31 int main() {
Info 0:b107e3217731 32
Info 0:b107e3217731 33 int sw1 = 0;
Info 0:b107e3217731 34 int sw2 = 0;
Info 0:b107e3217731 35 pc.printf("Hello World!\r\n");
Info 0:b107e3217731 36
Info 0:b107e3217731 37 wait(1);
Info 0:b107e3217731 38
Info 0:b107e3217731 39 initBase(); //initialize Baseboard
Info 0:b107e3217731 40
Info 0:b107e3217731 41 //set schematic select 0-7
Info 0:b107e3217731 42 UniM.detectModule(); //save location data in MCUGear class.
Info 0:b107e3217731 43 LCDM.detectModule(); //save location data in MCUGear class.
Info 0:b107e3217731 44
Info 0:b107e3217731 45 //startReg(0); //AutoMode can not use Bank
Info 0:b107e3217731 46 setIOUni(&UniM);//make schematic Bank0
Info 0:b107e3217731 47 setIOLCD(&LCDM);//make schematic Bank0
Info 0:b107e3217731 48 //endReg(0); //AutoMode can not use Bank
Info 0:b107e3217731 49
Info 0:b107e3217731 50 //changeBank(0);//select Bank
Info 0:b107e3217731 51
Info 0:b107e3217731 52
Info 0:b107e3217731 53 LCDM.connectModuleA();
Info 0:b107e3217731 54 TextLCD lcd(dp26, dp28, dp4, dp9, dp10, dp11, TextLCD::LCD16x2); // rs, e, d4-d7//set output pins from Dout1 to Dout6.
Info 0:b107e3217731 55 lcd.cls();
Info 0:b107e3217731 56 lcd.printf("Hello World!\n");
Info 0:b107e3217731 57 wait(1);
Info 0:b107e3217731 58 LCDM.disconnectModule();
Info 0:b107e3217731 59
Info 0:b107e3217731 60 while(1) {
Info 0:b107e3217731 61
Info 0:b107e3217731 62 UniM.connectModuleA();
Info 0:b107e3217731 63 sw1 = Din1.read();
Info 0:b107e3217731 64 sw2 = Din2.read();
Info 0:b107e3217731 65 printf("sw1 = %d sw2 = %d\r\n",sw1,sw2);
Info 0:b107e3217731 66 UniM.disconnectModule();
Info 0:b107e3217731 67
Info 0:b107e3217731 68 LCDM.connectModuleA();
Info 0:b107e3217731 69 lcd.printf(" "); //set IO as a neutral position
Info 0:b107e3217731 70 lcd.cls(); //clear LCD
Info 0:b107e3217731 71 lcd.printf("sw1 = %d\nsw2 = %d",sw1,sw2); //write LCD data
Info 0:b107e3217731 72 wait_ms(10); //delay for view the LCD
Info 0:b107e3217731 73 LCDM.disconnectModule();
Info 0:b107e3217731 74
Info 0:b107e3217731 75 UniM.connectModuleA();
Info 0:b107e3217731 76 Dout1 = 0;
Info 0:b107e3217731 77 Dout2 = 1;
Info 0:b107e3217731 78 Dout3 = 1;
Info 0:b107e3217731 79 wait(0.3);
Info 0:b107e3217731 80
Info 0:b107e3217731 81 Dout1 = 1;
Info 0:b107e3217731 82 Dout2 = 0;
Info 0:b107e3217731 83 Dout3 = 1;
Info 0:b107e3217731 84 wait(0.3);
Info 0:b107e3217731 85
Info 0:b107e3217731 86 Dout1 = 1;
Info 0:b107e3217731 87 Dout2 = 1;
Info 0:b107e3217731 88 Dout3 = 0;
Info 0:b107e3217731 89 wait(0.3);
Info 0:b107e3217731 90 UniM.disconnectModule();
Info 0:b107e3217731 91
Info 0:b107e3217731 92 }
Info 0:b107e3217731 93 }
Info 0:b107e3217731 94
Info 0:b107e3217731 95
Info 0:b107e3217731 96 void setIOUni(MCUGear *mcugear){
Info 0:b107e3217731 97 mcugear->setWireA(IOin1, IO_REG_IN_DIR, 0);
Info 0:b107e3217731 98 mcugear->setWireA(IOin2, IO_REG_IN_DIR, 1);
Info 0:b107e3217731 99 mcugear->setWireA(IOout1, IO_REG_OUT_DIR,2);
Info 0:b107e3217731 100 mcugear->setWireA(IOout2, IO_REG_OUT_DIR,3);
Info 0:b107e3217731 101 mcugear->setWireA(IOout3, IO_REG_OUT_DIR,4);
Info 0:b107e3217731 102 }
Info 0:b107e3217731 103
Info 0:b107e3217731 104 void setIOLCD(MCUGear *mcugear){
Info 0:b107e3217731 105 mcugear->setWireA(IOout1, IO_REG_OUT_DIR,0);
Info 0:b107e3217731 106 mcugear->setWireA(IOout2, IO_REG_OUT_DIR,1);
Info 0:b107e3217731 107 mcugear->setWireA(IOout3, IO_REG_OUT_DIR,2);
Info 0:b107e3217731 108 mcugear->setWireA(IOout4, IO_REG_OUT_DIR,3);
Info 0:b107e3217731 109 mcugear->setWireA(IOout5, IO_REG_OUT_DIR,4);
Info 0:b107e3217731 110 mcugear->setWireA(IOout6, IO_REG_OUT_DIR,5);
Info 0:b107e3217731 111 }
Info 0:b107e3217731 112