Library to use the Kaji-Lab's Electrical Simulator

Dependents:   Interference_Simple

Revision:
0:06a61ec386e8
Child:
1:48d671d82b81
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KajiLabES.cpp	Wed Feb 17 08:14:03 2016 +0000
@@ -0,0 +1,46 @@
+#include "KajiLabES.h"
+/*
+KajiLabES::KajiLabES():
+    _spiDAAD(SPI(p5, p6, p7)),   // mosi(master output slave input, miso(not connected), clock signal
+    _DA_sync(DigitalOut(p8)),           //chip select for AD5452
+    _AD_cs(DigitalOut(p9))
+{}
+*/
+KajiLabES::KajiLabES(
+    PinName mosi,
+    PinName miso,
+    PinName clk ,
+    PinName DA_sync,
+    PinName AD_cs
+):
+    _spiDAAD(SPI(mosi,miso,clk)),//(p5, p6, p7);   // mosi(master output slave input, miso(not connected), clock signal
+    _DA_sync(DigitalOut(DA_sync)),//(p8);           //chip select for AD5452
+    _AD_cs(DigitalOut(AD_cs))//(p9);
+{}
+//KajiLabES::~KajiLabES(){}
+
+//  DA&AD at the same time
+//  DA output by AD5452(SPI)
+//  AD input by AD7276(SPI)
+short KajiLabES::DAAD(short DA)
+{
+    short AD;
+
+    //enable
+    _DA_sync = 0;
+    _AD_cs = 0;
+    //simultaneous DA and AD
+    AD = _spiDAAD.write(DA<<2);
+    //disable
+    _DA_sync = 1;
+    _AD_cs = 1;
+
+    return AD>>2;//bottom 2bits are unnecessary
+}
+void KajiLabES::DAADinit()
+{
+    //Setup SPI, 16bit, falling edge, 48MHz clock
+//    spiDAAD.format(16, 2);
+    _spiDAAD.format(16, 1);
+    _spiDAAD.frequency(48000000);
+}
\ No newline at end of file