PV198 – One-chip Controllers, Ethernet / Dávid Danaj 1 PV198 – One-chip Controllers Ethernet PV198 – One-chip Controllers, Ethernet / Dávid Danaj Content 1.What is Ethernet used for 2.Overview 1.ISO/OSI Model 2.Headers 3.FRDM-K66F Ethernet 4.lwIP 5.Application 2 PV198 – One-chip Controllers, Ethernet / Dávid Danaj What is Ethernet used for §Connecting embedded devices to a network • • • • 3 Overview – ISO/OSI Model PV198 – One-chip Controllers, Ethernet / Dávid Danaj 4 • • • PV198 – One-chip Controllers, Ethernet / Dávid Danaj Overview By David Mudrák (mudrdmz) - Vlastní produkt, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=5181616 5 PV198 – One-chip Controllers, Ethernet / Dávid Danaj Overview – IPv4 header K66 Sub-Family Reference Manual, Figure 50-6. 6 PV198 – One-chip Controllers, Ethernet / Dávid Danaj Overview – UDP header K66 Sub-Family Reference Manual, Figure 50-11. 7 FRDM-K66F Ethernet §10/100-Mbps Ethernet MAC (ENET) §Compliant with the IEEE802.3-2002 standard §Hardware acceleration block to optimize the performance of network controllers providing TCP/IP, UDP, and ICMP protocol services §CRC-32 checking / CRC-32 generation §Programmable MAC address PV198 – One-chip Controllers, Ethernet / Dávid Danaj 8 FRDM-K66F Ethernet PV198 – One-chip Controllers, Ethernet / Dávid Danaj 9 • • • Lightweight IP stack lwIP §Lightweight IP stack – link §Small independent implementation of the TCP/IP protocol suite – used in embedded §Features: IP, ICMP, UDP, TCP, DNS, DHCP, and more • PV198 – One-chip Controllers, Ethernet / Dávid Danaj 10 Application – Overview PV198 – One-chip Controllers, Ethernet / Dávid Danaj 11 §The application sends a message to a Database §Uses UDP packets, InfluxDB and data are shown with Grafana lGrafana: http://lavinia.fi.muni.cz:3000/ lCredentials: onechip::onechip lGoto: Student Dashboard lInfluxDB: udp://lavinia.fi.muni.cz:8089/ §When you successfully send a message, it will be visible on a dashboard Application – Template PV198 – One-chip Controllers, Ethernet / Dávid Danaj 12 §Contains initialization of pins, clocks, peripherals and lwIP §Based on UDP echo – when the board receives an UDP packet, it sends the packet back to the sender §Uses predefined static IP address Application – Source Code PV198 – One-chip Controllers, Ethernet / Dávid Danaj 13 §Main: §Configure (pins, clocks, peripherals, lwIP) §Send udp packet – your task to implement §Loop: * Receive packets §Extra: UDP Callback: §handle received packet – send the packet back to the sender Application – Task PV198 – One-chip Controllers, Ethernet / Dávid Danaj 14 §Define your unique IP address (192.168.50.x) §Implement method in udpecho_raw.c: void udp_send_data(const ip4_addr_t dst_addr, uint16_t dst_port, char *msg); Homework •Send meaningful data to the database. •E.g.: §Data from sensor (temperature, pressure, accelerometer, … ) §Logging information (button pressed, …) §You have to use address.h • • PV198 – One-chip Controllers, Ethernet / Dávid Danaj 15