e-paper whereabouts board program

Dependencies:   SDFileSystem mbed

Committer:
kohacraft
Date:
Sun May 01 03:12:28 2016 +0000
Revision:
0:e4c67c26ba3f
Child:
1:cb28911c7ba5
ver1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 0:e4c67c26ba3f 1 #include "mbed.h"
kohacraft 0:e4c67c26ba3f 2 #include "extdio.h"
kohacraft 0:e4c67c26ba3f 3
kohacraft 0:e4c67c26ba3f 4
kohacraft 0:e4c67c26ba3f 5 DigitalOut CL(dp9);
kohacraft 0:e4c67c26ba3f 6 DigitalOut sdata(dp10);
kohacraft 0:e4c67c26ba3f 7 DigitalOut sclock(dp11);
kohacraft 0:e4c67c26ba3f 8 DigitalOut sdlatch(dp14);
kohacraft 0:e4c67c26ba3f 9 DigitalOut sclatch(dp13);
kohacraft 0:e4c67c26ba3f 10
kohacraft 0:e4c67c26ba3f 11 char contBasState = 0;
kohacraft 0:e4c67c26ba3f 12 bool olddata[8] = { 0,0,0,0,0,0,0,0 };
kohacraft 0:e4c67c26ba3f 13
kohacraft 0:e4c67c26ba3f 14 //set CL pin
kohacraft 0:e4c67c26ba3f 15 void setCL( bool state )
kohacraft 0:e4c67c26ba3f 16 {
kohacraft 0:e4c67c26ba3f 17 CL = state;
kohacraft 0:e4c67c26ba3f 18 }
kohacraft 0:e4c67c26ba3f 19
kohacraft 0:e4c67c26ba3f 20 //chane the contral port
kohacraft 0:e4c67c26ba3f 21 void setContBas( char mask , bool state )
kohacraft 0:e4c67c26ba3f 22 {
kohacraft 0:e4c67c26ba3f 23 sclock = 0;
kohacraft 0:e4c67c26ba3f 24 sclatch = 0;
kohacraft 0:e4c67c26ba3f 25 if( state == true)
kohacraft 0:e4c67c26ba3f 26 {
kohacraft 0:e4c67c26ba3f 27 contBasState = contBasState | mask;
kohacraft 0:e4c67c26ba3f 28 }
kohacraft 0:e4c67c26ba3f 29 else
kohacraft 0:e4c67c26ba3f 30 {
kohacraft 0:e4c67c26ba3f 31 contBasState = contBasState & (~mask);
kohacraft 0:e4c67c26ba3f 32 }
kohacraft 0:e4c67c26ba3f 33 char sendData;
kohacraft 0:e4c67c26ba3f 34 sendData = contBasState;
kohacraft 0:e4c67c26ba3f 35 char bitMask = 0x80;
kohacraft 0:e4c67c26ba3f 36
kohacraft 0:e4c67c26ba3f 37 //transfer to shift registor bit by bit from MSB
kohacraft 0:e4c67c26ba3f 38 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 39 sclock = 1;
kohacraft 0:e4c67c26ba3f 40 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 41 sclock = 0;
kohacraft 0:e4c67c26ba3f 42
kohacraft 0:e4c67c26ba3f 43 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 44 sclock = 1;
kohacraft 0:e4c67c26ba3f 45 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 46 sclock = 0;
kohacraft 0:e4c67c26ba3f 47
kohacraft 0:e4c67c26ba3f 48 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 49 sclock = 1;
kohacraft 0:e4c67c26ba3f 50 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 51 sclock = 0;
kohacraft 0:e4c67c26ba3f 52
kohacraft 0:e4c67c26ba3f 53 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 54 sclock = 1;
kohacraft 0:e4c67c26ba3f 55 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 56 sclock = 0;
kohacraft 0:e4c67c26ba3f 57
kohacraft 0:e4c67c26ba3f 58 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 59 sclock = 1;
kohacraft 0:e4c67c26ba3f 60 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 61 sclock = 0;
kohacraft 0:e4c67c26ba3f 62
kohacraft 0:e4c67c26ba3f 63 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 64 sclock = 1;
kohacraft 0:e4c67c26ba3f 65 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 66 sclock = 0;
kohacraft 0:e4c67c26ba3f 67
kohacraft 0:e4c67c26ba3f 68 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 69 sclock = 1;
kohacraft 0:e4c67c26ba3f 70 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 71 sclock = 0;
kohacraft 0:e4c67c26ba3f 72
kohacraft 0:e4c67c26ba3f 73 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 74 sclock = 1;
kohacraft 0:e4c67c26ba3f 75 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 76 sclock = 0;
kohacraft 0:e4c67c26ba3f 77
kohacraft 0:e4c67c26ba3f 78 //latch the data
kohacraft 0:e4c67c26ba3f 79 sclatch = 1;
kohacraft 0:e4c67c26ba3f 80 sclatch = 0;
kohacraft 0:e4c67c26ba3f 81 }
kohacraft 0:e4c67c26ba3f 82
kohacraft 0:e4c67c26ba3f 83 //change the data port
kohacraft 0:e4c67c26ba3f 84 void setDataBas( bool d7 , bool d6 , bool d5 , bool d4 , bool d3 , bool d2 , bool d1 , bool d0 )
kohacraft 0:e4c67c26ba3f 85 {
kohacraft 0:e4c67c26ba3f 86 sclock = 0;
kohacraft 0:e4c67c26ba3f 87 sdlatch = 0;
kohacraft 0:e4c67c26ba3f 88
kohacraft 0:e4c67c26ba3f 89 //if same data value , not chage data port ( for increace in speed processing )
kohacraft 0:e4c67c26ba3f 90 if( olddata[0] == d0 && olddata[1] == d1 && olddata[2] == d2 && olddata[3] == d3 && olddata[4] == d4 && olddata[5] == d5 && olddata[6] == d6 && olddata[7] == d7 )
kohacraft 0:e4c67c26ba3f 91 {
kohacraft 0:e4c67c26ba3f 92 return;
kohacraft 0:e4c67c26ba3f 93 }
kohacraft 0:e4c67c26ba3f 94
kohacraft 0:e4c67c26ba3f 95 olddata[0] = d0; olddata[1] = d1; olddata[2] = d2; olddata[3] = d3; olddata[4] = d4; olddata[5] = d5; olddata[6] = d6; olddata[7] = d7;
kohacraft 0:e4c67c26ba3f 96
kohacraft 0:e4c67c26ba3f 97 sdata = d0;
kohacraft 0:e4c67c26ba3f 98 sclock = 1;
kohacraft 0:e4c67c26ba3f 99 sclock = 0;
kohacraft 0:e4c67c26ba3f 100
kohacraft 0:e4c67c26ba3f 101 sdata = d1;
kohacraft 0:e4c67c26ba3f 102 sclock = 1;
kohacraft 0:e4c67c26ba3f 103 sclock = 0;
kohacraft 0:e4c67c26ba3f 104
kohacraft 0:e4c67c26ba3f 105 sdata = d2;
kohacraft 0:e4c67c26ba3f 106 sclock = 1;
kohacraft 0:e4c67c26ba3f 107 sclock = 0;
kohacraft 0:e4c67c26ba3f 108
kohacraft 0:e4c67c26ba3f 109 sdata = d3;
kohacraft 0:e4c67c26ba3f 110 sclock = 1;
kohacraft 0:e4c67c26ba3f 111 sclock = 0;
kohacraft 0:e4c67c26ba3f 112
kohacraft 0:e4c67c26ba3f 113 sdata = d4;
kohacraft 0:e4c67c26ba3f 114 sclock = 1;
kohacraft 0:e4c67c26ba3f 115 sclock = 0;
kohacraft 0:e4c67c26ba3f 116
kohacraft 0:e4c67c26ba3f 117 sdata = d5;
kohacraft 0:e4c67c26ba3f 118 sclock = 1;
kohacraft 0:e4c67c26ba3f 119 sclock = 0;
kohacraft 0:e4c67c26ba3f 120
kohacraft 0:e4c67c26ba3f 121 sdata = d6;
kohacraft 0:e4c67c26ba3f 122 sclock = 1;
kohacraft 0:e4c67c26ba3f 123 sclock = 0;
kohacraft 0:e4c67c26ba3f 124
kohacraft 0:e4c67c26ba3f 125 sdata = d7;
kohacraft 0:e4c67c26ba3f 126 sclock = 1;
kohacraft 0:e4c67c26ba3f 127 sclock = 0;
kohacraft 0:e4c67c26ba3f 128
kohacraft 0:e4c67c26ba3f 129 //latch the data
kohacraft 0:e4c67c26ba3f 130 sdlatch = 1;
kohacraft 0:e4c67c26ba3f 131 sdlatch = 0;
kohacraft 0:e4c67c26ba3f 132 }
kohacraft 0:e4c67c26ba3f 133