PV198 – One-chip Controllers, Ethernet / Dávid Danaj 1 PV198 – One-chip Controllers Ethernet PV198 – One-chip Controllers, Ethernet / Dávid Danaj 2 Content 1.What is Ethernet used for 2.Overview 1.ISO/OSI Model 2.Headers 3.FRDM-K66F Ethernet 4.lwIP 5.Application PV198 – One-chip Controllers, Ethernet / Dávid Danaj 3 What is Ethernet used for §Connecting embedded devices to a network § § § § Overview – ISO/OSI Model PV198 – One-chip Controllers, Ethernet / Dávid Danaj 4 § § § PV198 – One-chip Controllers, Ethernet / Dávid Danaj 5 Overview By David Mudrák (mudrdmz) - Vlastní produkt, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=5181616 PV198 – One-chip Controllers, Ethernet / Dávid Danaj 6 Overview – IPv4 header K66 Sub-Family Reference Manual, Figure 50-6. PV198 – One-chip Controllers, Ethernet / Dávid Danaj 7 Overview – UDP header K66 Sub-Family Reference Manual, Figure 50-11. 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 §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 §Works as 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 § §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.0.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, …) § § § PV198 – One-chip Controllers, Ethernet / Dávid Danaj 15