removed mbed

Committer:
wbeaumont
Date:
Mon Jun 24 15:51:37 2019 +0000
Revision:
1:2aadc0008662
Parent:
0:fdabc5739b6c
upgrade to mbed-os not succesful;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wbeaumont 0:fdabc5739b6c 1 #include "mbed.h"
wbeaumont 0:fdabc5739b6c 2
wbeaumont 0:fdabc5739b6c 3 DigitalIn spiin(p5);
wbeaumont 0:fdabc5739b6c 4 //SPISlave slave(PTA7,PTA6,PTB0,PTA5);
wbeaumont 0:fdabc5739b6c 5 SPISlave slave(p5,p6,p7,p8);
wbeaumont 0:fdabc5739b6c 6 AnalogIn ain1(p20);
wbeaumont 0:fdabc5739b6c 7 //SPISlave slave(p11,p12,p13,p14);
wbeaumont 0:fdabc5739b6c 8
wbeaumont 0:fdabc5739b6c 9 Serial pc(USBTX, USBRX);
wbeaumont 1:2aadc0008662 10 #define VER "1.35"
wbeaumont 0:fdabc5739b6c 11
wbeaumont 0:fdabc5739b6c 12 int main() {
wbeaumont 0:fdabc5739b6c 13 spiin.mode(PullUp);
wbeaumont 0:fdabc5739b6c 14 slave.format(8,0);
wbeaumont 0:fdabc5739b6c 15 slave.frequency(1000000);
wbeaumont 0:fdabc5739b6c 16 int v, res,res2;
wbeaumont 0:fdabc5739b6c 17 int cnt=0;
wbeaumont 0:fdabc5739b6c 18 int slvrecnt=0;
wbeaumont 0:fdabc5739b6c 19
wbeaumont 0:fdabc5739b6c 20 pc.printf(" start spi slave test %s \n\r",VER );
wbeaumont 0:fdabc5739b6c 21 slave.reply(0); // is in the example ?
wbeaumont 0:fdabc5739b6c 22 float sample=0;
wbeaumont 0:fdabc5739b6c 23 int slavereply;
wbeaumont 0:fdabc5739b6c 24 while(1) {
wbeaumont 0:fdabc5739b6c 25 cnt++;
wbeaumont 0:fdabc5739b6c 26 //if( (cnt % 10000000) ==0) pc.printf("%s loop : cnt %d , slvrsv cnt %d\n\r",VER,cnt, slvrecnt);
wbeaumont 0:fdabc5739b6c 27 sample=200*ain1.read();
wbeaumont 0:fdabc5739b6c 28 if(slave.receive()) {
wbeaumont 0:fdabc5739b6c 29 v = slave.read(); // Read byte from master
wbeaumont 0:fdabc5739b6c 30 if(v!=0){// discard the dummy buffer write
wbeaumont 0:fdabc5739b6c 31 //res=(v+5); // Add 5 to it
wbeaumont 0:fdabc5739b6c 32 res=slvrecnt%256;
wbeaumont 0:fdabc5739b6c 33 // res=0x13;
wbeaumont 0:fdabc5739b6c 34 slavereply=(int)sample;
wbeaumont 0:fdabc5739b6c 35 slave.reply(slavereply);// Make this the next reply
wbeaumont 0:fdabc5739b6c 36
wbeaumont 0:fdabc5739b6c 37 //pc.printf("v=%x res= %x\n\r", v,slavereply);
wbeaumont 0:fdabc5739b6c 38 slvrecnt++;
wbeaumont 0:fdabc5739b6c 39 }
wbeaumont 0:fdabc5739b6c 40 else {
wbeaumont 0:fdabc5739b6c 41 res2=cnt%256;
wbeaumont 0:fdabc5739b6c 42 slave.reply(res2); // Make this the next reply
wbeaumont 0:fdabc5739b6c 43 slvrecnt=0;
wbeaumont 0:fdabc5739b6c 44 //pc.printf("v=%d res2 = %x\n\r", v , res2);
wbeaumont 0:fdabc5739b6c 45 }
wbeaumont 0:fdabc5739b6c 46 //pc.printf( "slave receive done \n\r");
wbeaumont 0:fdabc5739b6c 47 //}
wbeaumont 0:fdabc5739b6c 48 }
wbeaumont 0:fdabc5739b6c 49 }
wbeaumont 0:fdabc5739b6c 50
wbeaumont 0:fdabc5739b6c 51
wbeaumont 0:fdabc5739b6c 52 }