Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 466 – Fall 2000 - Introduction - 1 COMMANDS RESPONSES Master/Slave Software Architecture Master void master() _task_ MAST{ Button(mode); // enq(cmd)

Similar presentations


Presentation on theme: "CSE 466 – Fall 2000 - Introduction - 1 COMMANDS RESPONSES Master/Slave Software Architecture Master void master() _task_ MAST{ Button(mode); // enq(cmd)"— Presentation transcript:

1 CSE 466 – Fall 2000 - Introduction - 1 COMMANDS RESPONSES Master/Slave Software Architecture Master void master() _task_ MAST{ Button(mode); // enq(cmd) checkDB(mode); // enq(cmd) } void comTop() _task_ COM{ wait(K_TMO, 1); if (!deq(cmd)) { cmd = pollCmd(next++); slave = next; } else slave = toWho(cmd); write(slave, cmd); read(response); signal(VERIFY); } void comBot() _task_ VERIFY{ // match up resp. and commds wait(K_SIG); verify(response); updateDB(response); } Slave void mainTask() _task_ SL{ manageLoad(mode); } void comTop() _task_ TOP{ read(master,cmd); write(master,response); //prev signal(DO); }// could be ISR void comBot() _task_ DO { wait(K_SIG); response = do(cmd); // set local mode } commands and responses are packets not single bytes responses are for previous command mode is NOT a global variable

2 CSE 466 – Fall 2000 - Introduction - 2 Sockets are a logical constructs Master slave socket == 2-way fifo Socket could be implemented in shared memory, internet, or anything in between. High level architecture can be independent of implementation choices.

3 CSE 466 – Fall 2000 - Introduction - 3 Physical Network MCU1 MCU2 Device1 Device2 Bus

4 CSE 466 – Fall 2000 - Introduction - 4 ISO Network Layers – modularity/interop.  Physical Layer: What physically moves a bit/byte from one place to another (ethernet). Devices have a local physical address.  Voltage  Current  Photons  Radio  Sonar  Data Link Layer: Guarantees delivery of “frames” over the physical layer, to the physical address. Assembles/dissembles packets from/to frames.  Address (Source and Destination)  Checksum  Data  Usually a fixed size or maximum size.  Network Layer: Primarily responsible for routing of network packets  Maps packet destination address from/to local physical address  Adds network layer header to packet  Gives packets w/ header to data link layer, along with physical address.

5 CSE 466 – Fall 2000 - Introduction - 5 ISO Layers Continued  Transport Layer: responsible for end-to-end protocol of user data buffer transmissions. Source and destination addresses are private – host to host.  Maps application space channel (socket) name to network address.  makes network packets w/ transport header and communicates w/ network layer.  Each layer has a peer-to-peer and an intra-stack protocol Transport -- TCP Network -- IP Datalink -- Ether Physical -- Etherethernet fiber Datalink -- Ether Network -- IP fiber ethernet Datalink -- Ether Network -- IP Transport -- TCP Network -- IP Datalink -- Ether Physical -- Ether write(s, buf,n);read(s, buf,n ); Application

6 CSE 466 – Fall 2000 - Introduction - 6 Transport Network -- IP Transport Network -- IP Embedded Networking: Simplest Case  Simple case: socket name is the same as physical address. No mapping, we just need to break our message into frames…maybe  Physical Layer – typically low bandwidth, serial, byte oriented  Data link layer – read/write interface to the application  frames: destination address, data, checksum.  No mapping from sockets to network address  No mapping from network address to physical address (no routing) Datalink Physicalethernet fiber Datalink -- Ether fiber ethernet Datalink -- EtherDatalink Physical write(s, buf,n);read(s, buf,n ); Application

7 CSE 466 – Fall 2000 - Introduction - 7 Example of Physical Layer: SPI Bus Master Slave SCK SDO SDI SCK SDI SDO void isr() interrupt TIMER { SDR = S; while(!SPF); R = SDR; } void isr() interrupt SPF{ R = SDR; SDR = S signal(RECV); } 1 0 0 1 1 1 1 0 shift reg 0 0 0 1 1 0 0 0 shift reg

8 CSE 466 – Fall 2000 - Introduction - 8 Multiple Slave Configuration Master Slave SCK SDO SDI SCK SDI SDO Slave SCK SDI SDO

9 CSE 466 – Fall 2000 - Introduction - 9 Master Slave Data Link Protocol  As an example frame is [destination address, command, data]  An acknowledgement frame is [address, data, checksum] Master Slave SCK SDO SDI SCK SDI SDO Slave SCK SDI SDO mux dstcmddatadsttypedata addrdatasumtypedatasum mux x x x 1 1 1 2 2 2

10 CSE 466 – Fall 2000 - Introduction - 10 Data Link Layer (Master/Slave) void physical() interrupt TIMER { S = deq() setMux(S); SDR = S while (!SDF); R = SDR; signal(DLIN); } void datalink() _task_ DLIN { while(1) { wait(); frame[i++] = R; if (i == 3) { i = 0; process(frame); } void physical() interrupt SF { R = SDR; SDR = deq(); signal(DLIN); } void datalink _task_ DLIN { while (1) { wait(); frame[i++] = R; if (i == 3) { i = 0; process(frame); } longer packets = less overhead but longer latency (response time) loadtable slave110cont.slave115endslave130 o o o write(slave1, “loadtable 10 15 25 30”); //transport interface verify checksum update local DB with data in the ACK frame. Handle error. if for me, prepare ACK assemble into packets and signal app when packet complete not shown: synchronizing dealing w/ errors

11 CSE 466 – Fall 2000 - Introduction - 11 Application Interface to Data Link Layer void mast() _task_ app { … // application layer protocol defines meaning write(SLAVE1, “loadtable 10 15 20 25 30”); //blocking … } void write(int dst, char *command{ // transport interface frame_array = mkFrames(dst,command); for (each byte in frame array) enq(byte); } loadtable slave110 cont.slave115 endslave130 void slave()_task_ app( while(1) { if (!read(master, cmd)) do(cmd); other_processing() } int read() { if (test(READ)) { sprintf(cmd,”%s”,deq()) return(0); } return(-1) } void process(char *frame) { response = resp(frame); for (each byte) enq(response); if (addframe(p,frame)) { enq(p); p = new packet(); signal(READ); }

12 CSE 466 – Fall 2000 - Introduction - 12 Trade-off Between Frame Size and Overhead write(p1, “loadtable 10 15 25 30”); //transport interface loadtable p110 cont.p115 endp130 or loadtable p1 1015202530end Frame: bus is dedicated to that transmission during the entire frame similar to the OS time slice problem: efficiency v. responsiveness

13 CSE 466 – Fall 2000 - Introduction - 13 Another Physical Layer – I2C  Multi-mastered  Send and receive  Two wire (plus ground)  Packet oriented (block send)

14 CSE 466 – Fall 2000 - Introduction - 14 Major Features of I2C

15 CSE 466 – Fall 2000 - Introduction - 15 Physical Layer

16 CSE 466 – Fall 2000 - Introduction - 16 Bit Transfer Transmitter Master

17 CSE 466 – Fall 2000 - Introduction - 17 Who gets to be master The one who initiates a frame: A frame is: … OR … …

18 CSE 466 – Fall 2000 - Introduction - 18 An I2C Byte Transfer Tx Device Rx Device master slave Rx MSB First MSB……………….LSB

19 CSE 466 – Fall 2000 - Introduction - 19 “Bit Banging” v. Bus Controller Bit Banging do all signal transitions in SW very difficult IC Interface: Mem Mapped device: set your address initiate transfer service the device on interrupt byte received transmission complete

20 CSE 466 – Fall 2000 - Introduction - 20 Schematic from App Note Something is wrong with this picture…but its close

21 CSE 466 – Fall 2000 - Introduction - 21 Arbitration what’s the backoff rule?

22 CSE 466 – Fall 2000 - Introduction - 22 A Complete Frame MSB……..LSB

23 CSE 466 – Fall 2000 - Introduction - 23


Download ppt "CSE 466 – Fall 2000 - Introduction - 1 COMMANDS RESPONSES Master/Slave Software Architecture Master void master() _task_ MAST{ Button(mode); // enq(cmd)"

Similar presentations


Ads by Google