e-paper whereabouts board program

Dependencies:   SDFileSystem mbed

Committer:
kohacraft
Date:
Tue May 23 05:06:14 2017 +0000
Revision:
1:cb28911c7ba5
Parent:
0:e4c67c26ba3f
change mbed official newest SDFilesystem.; you can select display mode for your EDP.; modify to simply code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 1:cb28911c7ba5 1 /* EDP interface board control progtam */
kohacraft 1:cb28911c7ba5 2
kohacraft 0:e4c67c26ba3f 3 #include "mbed.h"
kohacraft 0:e4c67c26ba3f 4 #include "extdio.h"
kohacraft 0:e4c67c26ba3f 5
kohacraft 0:e4c67c26ba3f 6
kohacraft 0:e4c67c26ba3f 7 DigitalOut CL(dp9);
kohacraft 0:e4c67c26ba3f 8 DigitalOut sdata(dp10);
kohacraft 0:e4c67c26ba3f 9 DigitalOut sclock(dp11);
kohacraft 0:e4c67c26ba3f 10 DigitalOut sdlatch(dp14);
kohacraft 0:e4c67c26ba3f 11 DigitalOut sclatch(dp13);
kohacraft 0:e4c67c26ba3f 12
kohacraft 1:cb28911c7ba5 13 char _contBusState = 0; //control bus states keep
kohacraft 1:cb28911c7ba5 14 char _olddata; //data bus state keep
kohacraft 0:e4c67c26ba3f 15
kohacraft 0:e4c67c26ba3f 16 void setCL( bool state )
kohacraft 0:e4c67c26ba3f 17 {
kohacraft 0:e4c67c26ba3f 18 CL = state;
kohacraft 1:cb28911c7ba5 19 return;
kohacraft 0:e4c67c26ba3f 20 }
kohacraft 0:e4c67c26ba3f 21
kohacraft 1:cb28911c7ba5 22 //chenge control bus
kohacraft 1:cb28911c7ba5 23 void setContBus( char mask , bool state )
kohacraft 0:e4c67c26ba3f 24 {
kohacraft 0:e4c67c26ba3f 25 sclock = 0;
kohacraft 0:e4c67c26ba3f 26 sclatch = 0;
kohacraft 0:e4c67c26ba3f 27 if( state == true)
kohacraft 0:e4c67c26ba3f 28 {
kohacraft 1:cb28911c7ba5 29 _contBusState = _contBusState | mask;
kohacraft 0:e4c67c26ba3f 30 }
kohacraft 0:e4c67c26ba3f 31 else
kohacraft 0:e4c67c26ba3f 32 {
kohacraft 1:cb28911c7ba5 33 _contBusState = _contBusState & (~mask);
kohacraft 0:e4c67c26ba3f 34 }
kohacraft 0:e4c67c26ba3f 35 char sendData;
kohacraft 1:cb28911c7ba5 36 sendData = _contBusState;
kohacraft 0:e4c67c26ba3f 37 char bitMask = 0x80;
kohacraft 0:e4c67c26ba3f 38
kohacraft 1:cb28911c7ba5 39 //transfur from MSB
kohacraft 0:e4c67c26ba3f 40 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 41 sclock = 1;
kohacraft 0:e4c67c26ba3f 42 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 43 sclock = 0;
kohacraft 0:e4c67c26ba3f 44
kohacraft 0:e4c67c26ba3f 45 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 46 sclock = 1;
kohacraft 0:e4c67c26ba3f 47 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 48 sclock = 0;
kohacraft 0:e4c67c26ba3f 49
kohacraft 0:e4c67c26ba3f 50 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 51 sclock = 1;
kohacraft 0:e4c67c26ba3f 52 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 53 sclock = 0;
kohacraft 0:e4c67c26ba3f 54
kohacraft 0:e4c67c26ba3f 55 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 56 sclock = 1;
kohacraft 0:e4c67c26ba3f 57 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 58 sclock = 0;
kohacraft 0:e4c67c26ba3f 59
kohacraft 0:e4c67c26ba3f 60 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 61 sclock = 1;
kohacraft 0:e4c67c26ba3f 62 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 63 sclock = 0;
kohacraft 0:e4c67c26ba3f 64
kohacraft 0:e4c67c26ba3f 65 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 66 sclock = 1;
kohacraft 0:e4c67c26ba3f 67 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 68 sclock = 0;
kohacraft 0:e4c67c26ba3f 69
kohacraft 0:e4c67c26ba3f 70 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 71 sclock = 1;
kohacraft 0:e4c67c26ba3f 72 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 73 sclock = 0;
kohacraft 0:e4c67c26ba3f 74
kohacraft 0:e4c67c26ba3f 75 sdata = sendData & bitMask;
kohacraft 0:e4c67c26ba3f 76 sclock = 1;
kohacraft 0:e4c67c26ba3f 77 bitMask = bitMask >> 1;
kohacraft 0:e4c67c26ba3f 78 sclock = 0;
kohacraft 0:e4c67c26ba3f 79
kohacraft 1:cb28911c7ba5 80 //set data
kohacraft 0:e4c67c26ba3f 81 sclatch = 1;
kohacraft 0:e4c67c26ba3f 82 sclatch = 0;
kohacraft 1:cb28911c7ba5 83
kohacraft 1:cb28911c7ba5 84 return;
kohacraft 0:e4c67c26ba3f 85 }
kohacraft 0:e4c67c26ba3f 86
kohacraft 1:cb28911c7ba5 87 //set data bus
kohacraft 1:cb28911c7ba5 88 void setDataBus( char data )
kohacraft 0:e4c67c26ba3f 89 {
kohacraft 0:e4c67c26ba3f 90 sclock = 0;
kohacraft 0:e4c67c26ba3f 91 sdlatch = 0;
kohacraft 0:e4c67c26ba3f 92
kohacraft 1:cb28911c7ba5 93 //skip process when data is same with old data
kohacraft 1:cb28911c7ba5 94 if( _olddata == data )
kohacraft 0:e4c67c26ba3f 95 {
kohacraft 0:e4c67c26ba3f 96 return;
kohacraft 0:e4c67c26ba3f 97 }
kohacraft 1:cb28911c7ba5 98 _olddata = data;
kohacraft 0:e4c67c26ba3f 99
kohacraft 1:cb28911c7ba5 100 sdata = data&0x01;
kohacraft 0:e4c67c26ba3f 101 sclock = 1;
kohacraft 0:e4c67c26ba3f 102 sclock = 0;
kohacraft 0:e4c67c26ba3f 103
kohacraft 1:cb28911c7ba5 104 sdata = data&0x02;
kohacraft 0:e4c67c26ba3f 105 sclock = 1;
kohacraft 0:e4c67c26ba3f 106 sclock = 0;
kohacraft 0:e4c67c26ba3f 107
kohacraft 1:cb28911c7ba5 108 sdata = data&0x04;
kohacraft 1:cb28911c7ba5 109 sclock = 1;
kohacraft 1:cb28911c7ba5 110 sclock = 0;
kohacraft 1:cb28911c7ba5 111
kohacraft 1:cb28911c7ba5 112 sdata = data&0x08;
kohacraft 0:e4c67c26ba3f 113 sclock = 1;
kohacraft 0:e4c67c26ba3f 114 sclock = 0;
kohacraft 0:e4c67c26ba3f 115
kohacraft 1:cb28911c7ba5 116 sdata = data&0x10;
kohacraft 0:e4c67c26ba3f 117 sclock = 1;
kohacraft 0:e4c67c26ba3f 118 sclock = 0;
kohacraft 0:e4c67c26ba3f 119
kohacraft 1:cb28911c7ba5 120 sdata = data&0x20;
kohacraft 0:e4c67c26ba3f 121 sclock = 1;
kohacraft 0:e4c67c26ba3f 122 sclock = 0;
kohacraft 0:e4c67c26ba3f 123
kohacraft 1:cb28911c7ba5 124 sdata = data&0x40;
kohacraft 0:e4c67c26ba3f 125 sclock = 1;
kohacraft 0:e4c67c26ba3f 126 sclock = 0;
kohacraft 0:e4c67c26ba3f 127
kohacraft 1:cb28911c7ba5 128 sdata = data&0x80;
kohacraft 0:e4c67c26ba3f 129 sclock = 1;
kohacraft 0:e4c67c26ba3f 130 sclock = 0;
kohacraft 0:e4c67c26ba3f 131
kohacraft 1:cb28911c7ba5 132 //set data
kohacraft 0:e4c67c26ba3f 133 sdlatch = 1;
kohacraft 0:e4c67c26ba3f 134 sdlatch = 0;
kohacraft 1:cb28911c7ba5 135
kohacraft 1:cb28911c7ba5 136 return;
kohacraft 0:e4c67c26ba3f 137 }