Library to use the Kaji-Lab's Electrical Simulator
Dependents: Interference_Simple
KajiLabES.cpp@2:9b21e855a577, 2018-06-01 (annotated)
- Committer:
- aktk
- Date:
- Fri Jun 01 09:36:58 2018 +0000
- Revision:
- 2:9b21e855a577
- Parent:
- 1:48d671d82b81
- Child:
- 3:9110712a0942
just changed comment. Last commit message was mistaken.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aktk | 0:06a61ec386e8 | 1 | #include "KajiLabES.h" |
aktk | 0:06a61ec386e8 | 2 | /* |
aktk | 0:06a61ec386e8 | 3 | KajiLabES::KajiLabES(): |
aktk | 0:06a61ec386e8 | 4 | _spiDAAD(SPI(p5, p6, p7)), // mosi(master output slave input, miso(not connected), clock signal |
aktk | 0:06a61ec386e8 | 5 | _DA_sync(DigitalOut(p8)), //chip select for AD5452 |
aktk | 0:06a61ec386e8 | 6 | _AD_cs(DigitalOut(p9)) |
aktk | 0:06a61ec386e8 | 7 | {} |
aktk | 0:06a61ec386e8 | 8 | */ |
aktk | 0:06a61ec386e8 | 9 | KajiLabES::KajiLabES( |
aktk | 0:06a61ec386e8 | 10 | PinName mosi, |
aktk | 0:06a61ec386e8 | 11 | PinName miso, |
aktk | 0:06a61ec386e8 | 12 | PinName clk , |
aktk | 0:06a61ec386e8 | 13 | PinName DA_sync, |
aktk | 0:06a61ec386e8 | 14 | PinName AD_cs |
aktk | 0:06a61ec386e8 | 15 | ): |
aktk | 0:06a61ec386e8 | 16 | _spiDAAD(SPI(mosi,miso,clk)),//(p5, p6, p7); // mosi(master output slave input, miso(not connected), clock signal |
aktk | 0:06a61ec386e8 | 17 | _DA_sync(DigitalOut(DA_sync)),//(p8); //chip select for AD5452 |
aktk | 0:06a61ec386e8 | 18 | _AD_cs(DigitalOut(AD_cs))//(p9); |
aktk | 0:06a61ec386e8 | 19 | {} |
aktk | 0:06a61ec386e8 | 20 | //KajiLabES::~KajiLabES(){} |
aktk | 0:06a61ec386e8 | 21 | |
aktk | 0:06a61ec386e8 | 22 | // DA&AD at the same time |
aktk | 0:06a61ec386e8 | 23 | // DA output by AD5452(SPI) |
aktk | 0:06a61ec386e8 | 24 | // AD input by AD7276(SPI) |
aktk | 0:06a61ec386e8 | 25 | short KajiLabES::DAAD(short DA) |
aktk | 0:06a61ec386e8 | 26 | { |
aktk | 0:06a61ec386e8 | 27 | short AD; |
aktk | 0:06a61ec386e8 | 28 | |
aktk | 0:06a61ec386e8 | 29 | //enable |
aktk | 0:06a61ec386e8 | 30 | _DA_sync = 0; |
aktk | 0:06a61ec386e8 | 31 | _AD_cs = 0; |
aktk | 0:06a61ec386e8 | 32 | //simultaneous DA and AD |
aktk | 0:06a61ec386e8 | 33 | AD = _spiDAAD.write(DA<<2); |
aktk | 0:06a61ec386e8 | 34 | //disable |
aktk | 0:06a61ec386e8 | 35 | _DA_sync = 1; |
aktk | 0:06a61ec386e8 | 36 | _AD_cs = 1; |
aktk | 0:06a61ec386e8 | 37 | |
aktk | 2:9b21e855a577 | 38 | //return the impedance scanned last. bottom 2bits are unnecessary |
aktk | 2:9b21e855a577 | 39 | return AD>>2; |
aktk | 0:06a61ec386e8 | 40 | } |
aktk | 0:06a61ec386e8 | 41 | void KajiLabES::DAADinit() |
aktk | 0:06a61ec386e8 | 42 | { |
aktk | 0:06a61ec386e8 | 43 | //Setup SPI, 16bit, falling edge, 48MHz clock |
aktk | 1:48d671d82b81 | 44 | _spiDAAD.format(16, 2); |
aktk | 1:48d671d82b81 | 45 | //_spiDAAD.format(16, 1); |
aktk | 0:06a61ec386e8 | 46 | _spiDAAD.frequency(48000000); |
aktk | 0:06a61ec386e8 | 47 | } |