a
Dependencies: mbed
main.cpp@0:19dc847021dd, 2015-12-05 (annotated)
- Committer:
- lolopo008
- Date:
- Sat Dec 05 06:36:57 2015 +0000
- Revision:
- 0:19dc847021dd
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lolopo008 | 0:19dc847021dd | 1 | #include "mbed.h" |
lolopo008 | 0:19dc847021dd | 2 | |
lolopo008 | 0:19dc847021dd | 3 | SPI DataPack(SPI_MOSI, SPI_MISO, SPI_SCK); |
lolopo008 | 0:19dc847021dd | 4 | DigitalOut Latch(D10); |
lolopo008 | 0:19dc847021dd | 5 | AnalogIn VR0(A0); |
lolopo008 | 0:19dc847021dd | 6 | AnalogIn VR1(A1); |
lolopo008 | 0:19dc847021dd | 7 | Serial pc(USBTX, USBRX); |
lolopo008 | 0:19dc847021dd | 8 | |
lolopo008 | 0:19dc847021dd | 9 | int main() |
lolopo008 | 0:19dc847021dd | 10 | { |
lolopo008 | 0:19dc847021dd | 11 | DataPack.frequency(100000); |
lolopo008 | 0:19dc847021dd | 12 | DataPack.format(8,0); |
lolopo008 | 0:19dc847021dd | 13 | |
lolopo008 | 0:19dc847021dd | 14 | float VR_value0,VR_value1; |
lolopo008 | 0:19dc847021dd | 15 | int Row[8]= {1,2,4,8,16,32,64,128}; |
lolopo008 | 0:19dc847021dd | 16 | int Col[8]= {254,253,251,247,239,223,191,127}; |
lolopo008 | 0:19dc847021dd | 17 | int x; |
lolopo008 | 0:19dc847021dd | 18 | |
lolopo008 | 0:19dc847021dd | 19 | while(1) { |
lolopo008 | 0:19dc847021dd | 20 | VR_value0 = VR0.read(); |
lolopo008 | 0:19dc847021dd | 21 | VR_value1 = VR1.read(); |
lolopo008 | 0:19dc847021dd | 22 | VR_value0 = VR_value0*6; |
lolopo008 | 0:19dc847021dd | 23 | VR_value1 = VR_value1*6; |
lolopo008 | 0:19dc847021dd | 24 | |
lolopo008 | 0:19dc847021dd | 25 | for(x=1; x<7; x++) { |
lolopo008 | 0:19dc847021dd | 26 | Latch=0; |
lolopo008 | 0:19dc847021dd | 27 | DataPack.write(Col[4]); |
lolopo008 | 0:19dc847021dd | 28 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 29 | DataPack.write(0xFF); |
lolopo008 | 0:19dc847021dd | 30 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 31 | DataPack.write(0xFF); |
lolopo008 | 0:19dc847021dd | 32 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 33 | DataPack.write(Row[x]); |
lolopo008 | 0:19dc847021dd | 34 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 35 | Latch=1; |
lolopo008 | 0:19dc847021dd | 36 | wait_ms(150); |
lolopo008 | 0:19dc847021dd | 37 | } |
lolopo008 | 0:19dc847021dd | 38 | |
lolopo008 | 0:19dc847021dd | 39 | for(x=5; x>1; x--) { |
lolopo008 | 0:19dc847021dd | 40 | Latch=0; |
lolopo008 | 0:19dc847021dd | 41 | DataPack.write(Col[4]); |
lolopo008 | 0:19dc847021dd | 42 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 43 | DataPack.write(0xFF); |
lolopo008 | 0:19dc847021dd | 44 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 45 | DataPack.write(0xFF); |
lolopo008 | 0:19dc847021dd | 46 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 47 | DataPack.write(Row[x]); |
lolopo008 | 0:19dc847021dd | 48 | wait_us(1); |
lolopo008 | 0:19dc847021dd | 49 | Latch=1; |
lolopo008 | 0:19dc847021dd | 50 | wait_ms(150); |
lolopo008 | 0:19dc847021dd | 51 | } |
lolopo008 | 0:19dc847021dd | 52 | } |
lolopo008 | 0:19dc847021dd | 53 | } |