Test program for mbed app shield pots

Dependencies:   C12832 mbed

Fork of mbed-app-shield by Chris Styles

Committer:
chris
Date:
Wed Jan 08 01:19:09 2014 +0000
Revision:
0:cca95aa94e09
Child:
1:e50da1f1f653
program to show the issue with apps shield on the u-blox board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:cca95aa94e09 1 #include "mbed.h"
chris 0:cca95aa94e09 2 #include "C12832_lcd.h"
chris 0:cca95aa94e09 3
chris 0:cca95aa94e09 4 // Map the LPC1768 pins to the arduino pin names
chris 0:cca95aa94e09 5 // These are the only things that are constant between ARCH, FRDM, u-blox etc
chris 0:cca95aa94e09 6 #define ARD_D5 P2_1
chris 0:cca95aa94e09 7 #define ARD_D7 P2_11
chris 0:cca95aa94e09 8 #define ARD_D10 P1_21
chris 0:cca95aa94e09 9 #define ARD_D11 P1_24
chris 0:cca95aa94e09 10 #define ARD_D12 P1_23
chris 0:cca95aa94e09 11 #define ARD_D13 P1_20
chris 0:cca95aa94e09 12
chris 0:cca95aa94e09 13 DigitalOut redled(ARD_D5);
chris 0:cca95aa94e09 14
chris 0:cca95aa94e09 15 // ==== Using SDK primitives ======
chris 0:cca95aa94e09 16 // Construct the required pin functions, this works!
chris 0:cca95aa94e09 17
chris 0:cca95aa94e09 18 /*
chris 0:cca95aa94e09 19 DigitalOut a_d7 (ARD_D7); // a0
chris 0:cca95aa94e09 20 DigitalOut a_d10 (ARD_D10); // nCS
chris 0:cca95aa94e09 21 DigitalOut a_d12 (ARD_D12); // reset
chris 0:cca95aa94e09 22 SPI myspi (ARD_D11,NC,ARD_D13); // MOSI
chris 0:cca95aa94e09 23 */
chris 0:cca95aa94e09 24
chris 0:cca95aa94e09 25
chris 0:cca95aa94e09 26 // ==== Using the LCD library ======
chris 0:cca95aa94e09 27
chris 0:cca95aa94e09 28 // Use my fork of the original library that allows pin names to be passed in
chris 0:cca95aa94e09 29 // This works on KL25Z and Seeedstudio Arch
chris 0:cca95aa94e09 30 // C12832_LCD(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name = "LCD");
chris 0:cca95aa94e09 31 // using this causes the program to hang
chris 0:cca95aa94e09 32 C12832_LCD lcd(ARD_D11, ARD_D13, ARD_D12, ARD_D7, ARD_D10);
chris 0:cca95aa94e09 33
chris 0:cca95aa94e09 34
chris 0:cca95aa94e09 35
chris 0:cca95aa94e09 36 int main()
chris 0:cca95aa94e09 37 {
chris 0:cca95aa94e09 38
chris 0:cca95aa94e09 39 int i=0;
chris 0:cca95aa94e09 40 while(1) {
chris 0:cca95aa94e09 41
chris 0:cca95aa94e09 42 // === USING THE LCD ====
chris 0:cca95aa94e09 43 // Note that the program will hang, even if we do not call any of the LCD functions
chris 0:cca95aa94e09 44 // Is it the cosntructor breaking things
chris 0:cca95aa94e09 45 // lcd.cls();
chris 0:cca95aa94e09 46 // lcd.locate(0,3);
chris 0:cca95aa94e09 47 // lcd.printf("Hello %d",i);
chris 0:cca95aa94e09 48
chris 0:cca95aa94e09 49
chris 0:cca95aa94e09 50 // === USING THE SDK Primitives ===
chris 0:cca95aa94e09 51 // If we just use the SPI and DigitalOut, instead we can access them happily
chris 0:cca95aa94e09 52 // and the program runs
chris 0:cca95aa94e09 53 // a_d7 = !a_d7;
chris 0:cca95aa94e09 54 // a_d10 = !a_d10;
chris 0:cca95aa94e09 55 // a_d12 = !a_d12;
chris 0:cca95aa94e09 56 // myspi.write(i);
chris 0:cca95aa94e09 57
chris 0:cca95aa94e09 58
chris 0:cca95aa94e09 59 wait(0.2);
chris 0:cca95aa94e09 60 redled = !redled; // I have an red LED on my test board.. for sanity :)
chris 0:cca95aa94e09 61 i++;
chris 0:cca95aa94e09 62 }
chris 0:cca95aa94e09 63
chris 0:cca95aa94e09 64 }