├── README ├── plc-hw ├── Makefile ├── bom.mouser.xls ├── gafrc ├── gerbers │ ├── openplc.cnc │ ├── openplc.gbl │ ├── openplc.gbs │ ├── openplc.gtl │ ├── openplc.gto │ ├── openplc.gts │ ├── openplc.tar.gz │ └── openplc.zip ├── packages │ ├── RJ45.fp │ ├── SOT223.fp │ ├── SSOP14.fp │ ├── SSOP28.fp │ ├── TERMBLK_5MM_2C.fp │ ├── TERMBLK_5MM_8C.fp │ ├── TQFP44_10.fp │ ├── pulse-J00-00XX.fp │ └── usbminib_hirose_th.fp ├── project ├── sim_board.cmd ├── sim_board.net ├── sim_board.pcb ├── sim_ether.sch ├── sim_phys_in.sch ├── sim_phys_out.sch ├── sim_pwr.sch ├── sim_uc.sch └── symbols │ ├── cap0603.sym │ ├── connector_usb.sym │ ├── diodeSOD123.sym │ ├── enc28j60.src │ ├── enc28j60.sym │ ├── inductor1008.sym │ ├── lm2902.sym │ ├── pic18f4455.src │ ├── pic18f4455.sym │ ├── pulse-J00-00XX.sym │ ├── res0603.sym │ ├── res4SipIso.src │ ├── res4SipIso.sym │ ├── resSip12kCommon.sym │ ├── ua78m33cdcyr.src │ └── ua78m33cdcyr.sym ├── plc-sw ├── MakeConf.include ├── Makefile.include ├── README ├── apps │ ├── README │ ├── dhcpc │ │ ├── Makefile.dhcpc │ │ ├── dhcpc.c │ │ └── dhcpc.h │ ├── hello-world │ │ ├── Makefile.hello-world │ │ ├── hello-world.c │ │ └── hello-world.h │ ├── jsoncmd │ │ ├── Makefile.jsoncmd │ │ ├── jsoncmd.c │ │ ├── jsoncmd.h │ │ ├── shell.c │ │ └── shell.h │ ├── port_app_mapper │ │ ├── Makefile.port_app_mapper │ │ ├── README │ │ ├── port_app_mapper.c │ │ └── port_app_mapper.h │ ├── simple-httpd │ │ ├── Makefile.simple-httpd │ │ ├── simple-httpd.c │ │ └── simple-httpd.h │ └── telnetd │ │ ├── Makefile.telnetd │ │ ├── shell.c │ │ ├── shell.h │ │ ├── telnetd.c │ │ └── telnetd.h ├── changelog.txt ├── doc │ ├── Atmega1284p.pdf │ ├── Doxyfile │ ├── ENC28J60.pdf │ ├── Makefile │ ├── README │ ├── doxygen.sty │ ├── example-mainloop-with-arp.c │ ├── example-mainloop-without-arp.c │ ├── examples.txt │ ├── header.tex │ ├── html │ │ ├── a00036.html │ │ ├── a00037.html │ │ ├── a00038.html │ │ ├── a00039.html │ │ ├── a00040.html │ │ ├── a00041.html │ │ ├── a00042.html │ │ ├── a00043.html │ │ ├── a00044.html │ │ ├── a00045.html │ │ ├── a00046.html │ │ ├── a00047.html │ │ ├── a00048.html │ │ ├── a00049.html │ │ ├── a00050.html │ │ ├── a00051.html │ │ ├── a00077.html │ │ ├── a00078.html │ │ ├── a00079.html │ │ ├── a00080.html │ │ ├── a00081.html │ │ ├── a00082.html │ │ ├── a00083.html │ │ ├── a00084.html │ │ ├── a00085.html │ │ ├── a00086.html │ │ ├── a00087.html │ │ ├── a00088.html │ │ ├── a00089.html │ │ ├── a00090.html │ │ ├── a00091.html │ │ ├── a00092.html │ │ ├── a00093.html │ │ ├── a00094.html │ │ ├── a00095.html │ │ ├── a00096.html │ │ ├── a00097.html │ │ ├── a00100.html │ │ ├── a00101.html │ │ ├── a00102.html │ │ ├── a00103.html │ │ ├── a00104.html │ │ ├── a00105.html │ │ ├── a00107.html │ │ ├── a00110.html │ │ ├── a00111.html │ │ ├── a00112.html │ │ ├── a00113.html │ │ ├── a00114.html │ │ ├── a00120.html │ │ ├── a00121.html │ │ ├── a00123.html │ │ ├── a00124.html │ │ ├── a00125.html │ │ ├── a00127.html │ │ ├── a00128.html │ │ ├── a00129.html │ │ ├── a00130.html │ │ ├── a00131.html │ │ ├── a00132.html │ │ ├── a00134.html │ │ ├── a00135.html │ │ ├── a00136.html │ │ ├── a00137.html │ │ ├── a00138.html │ │ ├── a00139.html │ │ ├── a00140.html │ │ ├── a00141.html │ │ ├── a00142.html │ │ ├── a00143.html │ │ ├── a00144.html │ │ ├── a00145.html │ │ ├── a00146.html │ │ ├── a00147.html │ │ ├── a00148.html │ │ ├── a00149.html │ │ ├── a00150.html │ │ ├── a00151.html │ │ ├── a00152.html │ │ ├── a00153.html │ │ ├── a00154.html │ │ ├── a00155.html │ │ ├── a00156.html │ │ ├── a00157.html │ │ ├── a00158.html │ │ ├── a00159.html │ │ ├── a00160.html │ │ ├── a00161.html │ │ ├── a00162.html │ │ ├── a00163.html │ │ ├── a00164.html │ │ ├── a00168.html │ │ ├── a00169.html │ │ ├── a00170.html │ │ ├── a00171.html │ │ ├── a00172.html │ │ ├── a00173.html │ │ ├── a00174.html │ │ ├── a00175.html │ │ ├── a00176.html │ │ ├── a00177.html │ │ ├── a00178.html │ │ ├── a00179.html │ │ ├── a00180.html │ │ ├── a00181.html │ │ ├── a00182.html │ │ ├── a00183.html │ │ ├── a00184.html │ │ ├── a00185.html │ │ ├── a00186.html │ │ ├── a00187.html │ │ ├── a00188.html │ │ ├── a00189.html │ │ ├── a00190.html │ │ ├── a00191.html │ │ ├── a00192.html │ │ ├── a00193.html │ │ ├── a00194.html │ │ ├── a00195.html │ │ ├── a00196.html │ │ ├── a00197.html │ │ ├── a00198.html │ │ ├── a00199.html │ │ ├── a00200.html │ │ ├── a00201.html │ │ ├── a00202.html │ │ ├── a00203.html │ │ ├── a00204.html │ │ ├── a00205.html │ │ ├── a00206.html │ │ ├── a00207.html │ │ ├── annotated.html │ │ ├── classes.html │ │ ├── doxygen.css │ │ ├── doxygen.png │ │ ├── examples.html │ │ ├── files.html │ │ ├── ftv2blank.png │ │ ├── ftv2doc.png │ │ ├── ftv2folderclosed.png │ │ ├── ftv2folderopen.png │ │ ├── ftv2lastnode.png │ │ ├── ftv2link.png │ │ ├── ftv2mlastnode.png │ │ ├── ftv2mnode.png │ │ ├── ftv2node.png │ │ ├── ftv2plastnode.png │ │ ├── ftv2pnode.png │ │ ├── ftv2vertline.png │ │ ├── functions.html │ │ ├── functions_vars.html │ │ ├── globals.html │ │ ├── globals_0x61.html │ │ ├── globals_0x62.html │ │ ├── globals_0x64.html │ │ ├── globals_0x65.html │ │ ├── globals_0x66.html │ │ ├── globals_0x68.html │ │ ├── globals_0x69.html │ │ ├── globals_0x6c.html │ │ ├── globals_0x6d.html │ │ ├── globals_0x6e.html │ │ ├── globals_0x70.html │ │ ├── globals_0x72.html │ │ ├── globals_0x73.html │ │ ├── globals_0x74.html │ │ ├── globals_0x75.html │ │ ├── globals_0x77.html │ │ ├── globals_defs.html │ │ ├── globals_defs_0x61.html │ │ ├── globals_defs_0x62.html │ │ ├── globals_defs_0x64.html │ │ ├── globals_defs_0x65.html │ │ ├── globals_defs_0x66.html │ │ ├── globals_defs_0x68.html │ │ ├── globals_defs_0x69.html │ │ ├── globals_defs_0x6c.html │ │ ├── globals_defs_0x6d.html │ │ ├── globals_defs_0x6e.html │ │ ├── globals_defs_0x70.html │ │ ├── globals_defs_0x72.html │ │ ├── globals_defs_0x73.html │ │ ├── globals_defs_0x74.html │ │ ├── globals_defs_0x75.html │ │ ├── globals_defs_0x77.html │ │ ├── globals_func.html │ │ ├── globals_type.html │ │ ├── globals_vars.html │ │ ├── hierarchy.html │ │ ├── index.hhc │ │ ├── index.hhk │ │ ├── index.hhp │ │ ├── index.html │ │ ├── main.html │ │ ├── modules.html │ │ ├── tab_b.gif │ │ ├── tab_l.gif │ │ ├── tab_r.gif │ │ ├── tabs.css │ │ └── tree.html │ ├── mobisys2003.pdf │ ├── pt-doc.txt │ ├── sicslogo.pdf │ ├── uip-code-style.c │ ├── uip-code-style.txt │ ├── uip-doc.txt │ └── uip-refman.pdf ├── drivers │ ├── enc28j60 │ │ ├── Makefile.enc28j60 │ │ ├── avrlibdefs.h │ │ ├── avrlibtypes.h │ │ ├── enc28j60.c │ │ ├── enc28j60.h │ │ ├── enc28j60conf.h │ │ ├── global.h │ │ └── network.c │ └── interfaces │ │ ├── README │ │ └── network.h ├── libs │ ├── 1wire │ │ ├── Makefile.1wire │ │ ├── crc8.c │ │ ├── crc8.h │ │ ├── ds18x20.c │ │ ├── ds18x20.h │ │ ├── onewire.c │ │ └── onewire.h │ ├── analog │ │ ├── Makefile.analog │ │ ├── analog.c │ │ └── analog.h │ ├── avrlib-avrlib-conf │ │ ├── avrlibdefs.h │ │ ├── avrlibtypes.h │ │ └── global.h │ ├── ds1302 │ │ ├── Makefile.ds1302 │ │ ├── ds1302.c │ │ └── ds1302.h │ ├── eeprom │ │ ├── Makefile.eeprom │ │ ├── eeprom.c │ │ └── eeprom.h │ ├── lcd │ │ ├── .dep │ │ │ └── 2wLCD.o.d │ │ ├── Makefile.lcd │ │ ├── SPILCD.c │ │ └── SPILCD.h │ ├── memb │ │ ├── Makefile.memb │ │ ├── memb.c │ │ └── memb.h │ ├── misc │ │ └── AVR035.h │ ├── uart │ │ ├── Makefile.uart │ │ ├── uart.c │ │ └── uart.h │ ├── usart │ │ ├── ATxmega_Baud_Rate_Calculator_v1.0.xls.zip │ │ ├── Makefile.usart │ │ ├── README │ │ ├── one_usart.c │ │ ├── one_usart.h │ │ ├── usart.c │ │ ├── usart.h │ │ ├── usart1.c │ │ ├── usart1.h │ │ ├── usart2.c │ │ └── usart2.h │ └── websrv_helper_functions │ │ ├── websrv_helper_functions.c │ │ └── websrv_helper_functions.h ├── projects │ ├── HILSim │ │ ├── Makefile │ │ ├── apps-conf.h │ │ ├── clock-arch.c │ │ ├── clock-arch.h │ │ ├── global-conf.h │ │ ├── main.c │ │ ├── phys.c │ │ ├── phys.h │ │ └── uip-conf.h │ ├── OpenPLC │ │ ├── Makefile │ │ ├── apps-conf.h │ │ ├── clock-arch.c │ │ ├── clock-arch.h │ │ ├── global-conf.h │ │ ├── main.c │ │ └── uip-conf.h │ └── Tests │ │ ├── Makefile │ │ ├── qtest.elf │ │ ├── qtest.hex │ │ └── quicktest.c ├── structure.txt ├── tools │ └── module_memory_usage └── uip │ ├── Makefile.uip │ ├── clock.h │ ├── lc-addrlabels.h │ ├── lc-switch.h │ ├── lc.h │ ├── psock.c │ ├── psock.h │ ├── pt.h │ ├── timer.c │ ├── timer.h │ ├── uip-fw.c │ ├── uip-fw.h │ ├── uip-neighbor.c │ ├── uip-neighbor.h │ ├── uip-split.c │ ├── uip-split.h │ ├── uip.c │ ├── uip.h │ ├── uip_arch.h │ ├── uip_arp.c │ ├── uip_arp.h │ ├── uiplib.c │ ├── uiplib.h │ └── uipopt.h └── setup-deb.sh /plc-hw/Makefile: -------------------------------------------------------------------------------- 1 | sim_board: sim_uc.sch sim_phys_out.sch sim_ether.sch sim_pwr.sch \ 2 | sim_phys_in.sch packages/* symbols/* 3 | refdes_renum $^ 4 | gsch2pcb -v -v $^ -o $@ 5 | 6 | clean: 7 | rm -f *~ *- *.backup *.new.pcb *.png *.bak *.gbr *.cnc 8 | 9 | destroy_pcb: clean 10 | @bash -c 'echo "Are you sure? cuz this is gonna blow up all your pcb \ 11 | shit."; read answer; if [[ "$$answer" == *yes* ]]; then rm -v -f *.cmd \ 12 | *.pcb *.net; fi' 13 | -------------------------------------------------------------------------------- /plc-hw/bom.mouser.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-hw/bom.mouser.xls -------------------------------------------------------------------------------- /plc-hw/gafrc: -------------------------------------------------------------------------------- 1 | ;; Add libraries 2 | (component-library "./symbols") 3 | -------------------------------------------------------------------------------- /plc-hw/gerbers/openplc.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-hw/gerbers/openplc.tar.gz -------------------------------------------------------------------------------- /plc-hw/gerbers/openplc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-hw/gerbers/openplc.zip -------------------------------------------------------------------------------- /plc-hw/packages/RJ45.fp: -------------------------------------------------------------------------------- 1 | # author: Levente Kovacs 2 | # author: Cory Cross made drill size 35mils instead 3 | # email: lekovacs@interware.hu 4 | # dist-license: GPL 2 5 | # use-license: unlimited 6 | 7 | Element["" "RJ-45 Jack, no shielding" "CONN" "" 200000 142500 -5000 0 0 100 ""] 8 | ( 9 | Pin[10000 35000 6000 2000 6000 3500 "" "8" "edge2"] 10 | Pin[0 30000 6000 2000 6000 3500 "" "7" "edge2"] 11 | Pin[10000 15000 6000 2000 6000 3500 "" "4" "edge2"] 12 | Pin[0 10000 6000 2000 6000 3500 "" "3" "edge2"] 13 | Pin[0 20000 6000 2000 6000 3500 "" "5" "edge2"] 14 | Pin[0 0 6000 2000 6000 3500 "" "1" "square,edge2"] 15 | Pin[10000 5000 6000 2000 6000 3500 "" "2" "edge2"] 16 | Pin[10000 25000 6000 2000 6000 3500 "" "6" "edge2"] 17 | Pin[-25000 -5000 12800 2000 12800 12800 "" "" "hole,edge2"] 18 | Pin[-25000 40000 12800 2000 12800 12800 "" "" "hole,edge2"] 19 | ElementLine [-47000 -14500 -47000 49300 1000] 20 | ElementLine [-56000 49500 15000 49500 1000] 21 | ElementLine [15000 49500 15000 -14500 1000] 22 | ElementLine [-56000 -14500 15000 -14500 1000] 23 | ElementLine [-56000 -14500 -56000 49500 1000] 24 | 25 | ) 26 | -------------------------------------------------------------------------------- /plc-hw/packages/SOT223.fp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Element(0x00 "SMT transistor, 4 pins" "" "SOT223" 305 0 3 100 0x00) 17 | ( 18 | ElementLine(0 0 0 414 10) 19 | ElementLine(0 414 285 414 10) 20 | ElementLine(285 414 285 0 10) 21 | ElementLine(285 0 0 0 10) 22 | 23 | # 1st pin on pin side 24 | Pad(52 296 25 | 52 362 26 | 56 27 | "1" "1" 0x100) 28 | 29 | 30 | Pad(142 296 31 | 142 362 32 | 56 33 | "2" "2" 0x100) 34 | 35 | 36 | 37 | 38 | # last pin on pin side 39 | Pad(233 296 40 | 233 362 41 | 56 42 | "3" "3" 0x100) 43 | 44 | 45 | # extra wide pin on opposite side 46 | Pad(187 85 47 | 97 85 48 | 122 "4" "4" 0x100) 49 | 50 | Mark(52 329) 51 | ) 52 | 53 | -------------------------------------------------------------------------------- /plc-hw/packages/SSOP14.fp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Element(0x00 "Shrink small outline package, .65mm, narrow" "" "SSOP14" 184 50 3 100 0x00) 15 | ( 16 | Pad(8 12 30 12 16 "1" 0x00) 17 | Pad(8 38 30 38 16 "2" 0x100) 18 | Pad(8 63 30 63 16 "3" 0x100) 19 | Pad(8 89 30 89 16 "4" 0x100) 20 | Pad(8 115 30 115 16 "5" 0x100) 21 | Pad(8 140 30 140 16 "6" 0x100) 22 | Pad(8 166 30 166 16 "7" 0x100) 23 | 24 | Pad(299 167 321 167 16 "8" 0x100) 25 | Pad(299 141 321 141 16 "9" 0x100) 26 | Pad(299 116 321 116 16 "10" 0x100) 27 | Pad(299 90 321 90 16 "11" 0x100) 28 | Pad(299 64 321 64 16 "12" 0x100) 29 | Pad(299 39 321 39 16 "13" 0x100) 30 | Pad(299 13 321 13 16 "14" 0x100) 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | ElementLine(-10 -10 139 -10 10) 39 | ElementArc(164 -10 25 25 0 180 10) 40 | ElementLine(189 -10 339 -10 10) 41 | ElementLine(339 -10 339 189 10) 42 | ElementLine(339 189 -10 189 10) 43 | ElementLine(-10 189 -10 -10 10) 44 | Mark(23 12) 45 | ) 46 | 47 | -------------------------------------------------------------------------------- /plc-hw/packages/SSOP28.fp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Element(0x00 "Shrink small outline package, .65mm, narrow" "" "SSOP28" 184 50 3 100 0x00) 15 | ( 16 | Pad(8 12 30 12 16 "1" 0x00) 17 | Pad(8 38 30 38 16 "2" 0x100) 18 | Pad(8 63 30 63 16 "3" 0x100) 19 | Pad(8 89 30 89 16 "4" 0x100) 20 | Pad(8 115 30 115 16 "5" 0x100) 21 | Pad(8 140 30 140 16 "6" 0x100) 22 | Pad(8 166 30 166 16 "7" 0x100) 23 | Pad(8 191 30 191 16 "8" 0x100) 24 | Pad(8 217 30 217 16 "9" 0x100) 25 | Pad(8 243 30 243 16 "10" 0x100) 26 | Pad(8 268 30 268 16 "11" 0x100) 27 | Pad(8 294 30 294 16 "12" 0x100) 28 | Pad(8 319 30 319 16 "13" 0x100) 29 | Pad(8 345 30 345 16 "14" 0x100) 30 | 31 | Pad(299 346 321 346 16 "15" 0x100) 32 | Pad(299 320 321 320 16 "16" 0x100) 33 | Pad(299 295 321 295 16 "17" 0x100) 34 | Pad(299 269 321 269 16 "18" 0x100) 35 | Pad(299 243 321 243 16 "19" 0x100) 36 | Pad(299 218 321 218 16 "20" 0x100) 37 | Pad(299 192 321 192 16 "21" 0x100) 38 | Pad(299 167 321 167 16 "22" 0x100) 39 | Pad(299 141 321 141 16 "23" 0x100) 40 | Pad(299 115 321 115 16 "24" 0x100) 41 | Pad(299 90 321 90 16 "25" 0x100) 42 | Pad(299 64 321 64 16 "26" 0x100) 43 | Pad(299 39 321 39 16 "27" 0x100) 44 | Pad(299 13 321 13 16 "28" 0x100) 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ElementLine(-10 -10 139 -10 10) 53 | ElementArc(164 -10 25 25 0 180 10) 54 | ElementLine(189 -10 339 -10 10) 55 | ElementLine(339 -10 339 368 10) 56 | ElementLine(339 368 -10 368 10) 57 | ElementLine(-10 368 -10 -10 10) 58 | Mark(23 12) 59 | ) 60 | 61 | -------------------------------------------------------------------------------- /plc-hw/packages/TERMBLK_5MM_2C.fp: -------------------------------------------------------------------------------- 1 | Element(0x00 "5MM Terminal Block, Through Hole" "" "TRMBLK_5MM_2C" 160 10 3 100 0x00) 2 | ( 3 | Pin(187 100 100 66 "1" 0x101) 4 | Pin(187 297 100 66 "2" 0x01) 5 | ElementLine(0 0 0 397 20) 6 | ElementLine(374 0 374 397 20) 7 | ElementLine(0 0 374 0 20) 8 | ElementLine(0 397 374 397 20) 9 | Mark(187 100) 10 | ) 11 | -------------------------------------------------------------------------------- /plc-hw/packages/TERMBLK_5MM_8C.fp: -------------------------------------------------------------------------------- 1 | Element(0x00 "5MM Terminal Block, Through Hole" "" "TRMBLK_5MM_8C" 160 10 3 100 0x00) 2 | ( 3 | Pin(187 100 100 66 "1" 0x101) 4 | Pin(187 297 100 66 "2" 0x01) 5 | Pin(187 494 100 66 "3" 0x01) 6 | Pin(187 691 100 66 "4" 0x01) 7 | Pin(187 888 100 66 "5" 0x01) 8 | Pin(187 1085 100 66 "6" 0x01) 9 | Pin(187 1282 100 66 "7" 0x01) 10 | Pin(187 1479 100 66 "8" 0x01) 11 | ElementLine(0 0 0 1579 20) 12 | ElementLine(374 0 374 1579 20) 13 | ElementLine(0 0 374 0 20) 14 | ElementLine(0 1579 374 1579 20) 15 | ElementLine(0 187 374 187 10) 16 | Mark(187 100) 17 | ) 18 | -------------------------------------------------------------------------------- /plc-hw/packages/pulse-J00-00XX.fp: -------------------------------------------------------------------------------- 1 | 2 | Element["" "" "J0" "" 50000 50000 -5000 -5000 0 166 ""] 3 | ( 4 | Pin[17500 25000 6500 2000 7100 3500 "" "1" ""] 5 | Pin[12500 35000 6500 2000 7100 3500 "" "2" ""] 6 | Pin[7500 25000 6500 2000 7100 3500 "" "3" ""] 7 | Pin[2500 35000 6500 2000 7100 3500 "" "4" ""] 8 | Pin[-2500 25000 6500 2000 7100 3500 "" "5" ""] 9 | Pin[-7500 35000 6500 2000 7100 3500 "" "6" ""] 10 | Pin[-12500 25000 6500 2000 7100 3500 "" "7" ""] 11 | Pin[-17500 35000 6500 2000 7100 3500 "" "8" ""] 12 | 13 | Pin[24900 -19400 6500 2000 7100 4000 "" "9" ""] 14 | Pin[14800 -13400 6500 2000 7100 4000 "" "10" ""] 15 | Pin[-15000 -19400 6500 2000 7100 4000 "" "11" ""] 16 | Pin[-25100 -13400 6500 2000 7100 4000 "" "12" ""] 17 | 18 | Pin[22500 0 14800 2000 15400 12800 "" "13" ""] 19 | Pin[-22500 0 14800 2000 15400 12800 "" "14" ""] 20 | Pin[-31000 12000 8400 2000 9000 6400 "" "15" ""] 21 | Pin[31000 12000 8400 2000 9000 6400 "" "16" ""] 22 | 23 | ElementLine [31500 42500 -32000 42500 1000] 24 | ElementLine [31500 -42500 -32000 -42500 1000] 25 | ElementLine [-32000 -42500 -32000 6000 1000] 26 | ElementLine [31500 -42500 31500 6000 1000] 27 | ElementLine [31500 42500 31500 18000 1000] 28 | ElementLine [-32000 42500 -32000 18000 1000] 29 | ElementLine [-25000 -42500 -25000 -37500 1000] 30 | ElementLine [-25000 -37500 25000 -37500 1000] 31 | ElementLine [25000 -37500 25000 -42500 1000] 32 | ElementLine [-5000 -37500 -5000 -35000 1000] 33 | ElementLine [-5000 -35000 5000 -35000 1000] 34 | ElementLine [5000 -35000 5000 -37500 1000] 35 | 36 | Attribute("author" "DJ Delorie") 37 | Attribute("copyright" "2006 DJ Delorie") 38 | Attribute("use-license" "Unlimited") 39 | Attribute("dist-license" "GPL") 40 | Attribute("description" "PulseJACK (ethernet with magnetics)") 41 | ) 42 | -------------------------------------------------------------------------------- /plc-hw/packages/usbminib_hirose_th.fp: -------------------------------------------------------------------------------- 1 | # author: Darrell Harmon 2 | # email: website@dlharmon.com 3 | # dist-license: GPL 2 4 | # use-license: unlimited 5 | # tested: yes 6 | 7 | Element[0x00 "USB mini-b connector" "" "usbminib_hirose_th" 125197 130709 0 0 0 100 0x00000000] 8 | ( 9 | Pin[-14173 12992 9000 2000 9600 6800 "" "G" 0x00004101] 10 | Pin[14173 12992 9000 2000 9600 6800 "" "G" 0x00004101] 11 | Pin[14173 -7874 9000 2000 9600 6800 "" "G" 0x00004101] 12 | Pin[-14173 -7874 9000 2000 9600 6800 "" "G" 0x00004101] 13 | Pin[6693 5118 5700 2000 6300 3600 "" "G" 0x00004001] 14 | Pin[-6693 5118 5700 2000 6300 3600 "" "G" 0x00004001] 15 | Pad[-6300 10827 -6300 16731 1969 1200 3169 "" "5" 0x00004100] 16 | Pad[6300 10827 6300 16731 1969 1200 3169 "" "1" 0x00004100] 17 | Pad[3150 10827 3150 16731 1969 1200 3169 "" "2" 0x00004100] 18 | Pad[0 10827 0 16731 1969 1200 3169 "" "3" 0x00004100] 19 | Pad[-3150 10827 -3150 16731 1969 1200 3169 "" "4" 0x00004100] 20 | ElementLine [-14173 -18111 14173 -18111 1000] 21 | ElementLine [14173 -2756 14173 7874 1000] 22 | ElementLine [-14173 7874 -14173 -2756 1000] 23 | ElementLine [14173 19291 14173 18110 1000] 24 | ElementLine [-14173 18110 -14173 19291 1000] 25 | ElementLine [-14173 19291 14173 19291 1000] 26 | ElementLine [14173 -18111 14173 -12992 1000] 27 | ElementLine [-14173 -18111 -14173 -12992 1000] 28 | 29 | ) 30 | -------------------------------------------------------------------------------- /plc-hw/project: -------------------------------------------------------------------------------- 1 | schematics sim_uc.sch sim_phys_out.sch sim_ether.sch sim_pwr.sch sim_phys_in.sch 2 | output-name sim_board 3 | -------------------------------------------------------------------------------- /plc-hw/symbols/cap0603.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | P 0 200 200 200 1 0 0 3 | { 4 | T 150 250 5 8 0 1 0 6 1 5 | pinnumber=1 6 | T 150 150 5 8 0 1 0 8 1 7 | pinseq=1 8 | T 200 200 9 8 0 1 0 0 1 9 | pinlabel=1 10 | T 200 200 5 8 0 1 0 2 1 11 | footprint=603 12 | } 13 | P 900 200 700 200 1 0 0 14 | { 15 | T 750 250 5 8 0 1 0 0 1 16 | pinnumber=2 17 | T 750 150 5 8 0 1 0 2 1 18 | pinseq=2 19 | T 700 200 9 8 0 1 0 6 1 20 | pinlabel=2 21 | T 700 200 5 8 0 1 0 8 1 22 | pintype=pas 23 | } 24 | L 400 400 400 0 3 0 0 0 -1 -1 25 | L 500 400 500 0 3 0 0 0 -1 -1 26 | L 700 200 500 200 3 0 0 0 -1 -1 27 | L 400 200 200 200 3 0 0 0 -1 -1 28 | T 200 700 5 10 0 0 0 0 1 29 | device=CAPACITOR 30 | T 200 500 8 10 1 1 0 0 1 31 | refdes=C17 32 | T 200 1300 5 10 0 0 0 0 1 33 | description=capacitor 34 | T 200 1100 5 10 0 0 0 0 1 35 | numslots=0 36 | T 200 900 5 10 0 0 0 0 1 37 | symversion=0.1 38 | T -5 0 8 10 0 1 0 0 1 39 | footprint=603 40 | -------------------------------------------------------------------------------- /plc-hw/symbols/connector_usb.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | P 1900 1400 2200 1400 1 0 1 3 | { 4 | T 1550 1350 5 8 1 1 0 0 1 5 | pinnumber=2 6 | T 750 1350 5 8 0 0 0 0 1 7 | pinseq=2 8 | T 750 1350 5 8 0 1 0 0 1 9 | pinlabel=2 10 | T 750 1350 5 8 0 1 0 0 1 11 | pintype=pas 12 | } 13 | P 1900 800 2200 800 1 0 1 14 | { 15 | T 1550 750 5 8 1 1 0 0 1 16 | pinnumber=4 17 | T 750 750 5 8 0 0 0 0 1 18 | pinseq=4 19 | T 750 750 5 8 0 1 0 0 1 20 | pinlabel=4 21 | T 750 750 5 8 0 1 0 0 1 22 | pintype=pas 23 | } 24 | P 1900 1700 2200 1700 1 0 1 25 | { 26 | T 1550 1650 5 8 1 1 0 0 1 27 | pinnumber=1 28 | T 750 1650 5 8 0 0 0 0 1 29 | pinseq=1 30 | T 750 1650 5 8 0 1 0 0 1 31 | pinlabel=1 32 | T 750 1650 5 8 0 1 0 0 1 33 | pintype=pas 34 | } 35 | P 1900 1100 2200 1100 1 0 1 36 | { 37 | T 1550 1050 5 8 1 1 0 0 1 38 | pinnumber=3 39 | T 750 1050 5 8 0 0 0 0 1 40 | pinseq=3 41 | T 750 1050 5 8 0 1 0 0 1 42 | pinlabel=3 43 | T 750 1050 5 8 0 1 0 0 1 44 | pintype=pas 45 | } 46 | P 900 300 900 0 1 0 1 47 | { 48 | T 900 850 5 8 1 1 180 6 1 49 | pinnumber=5 50 | T 850 1450 5 8 0 0 270 0 1 51 | pinseq=5 52 | T 900 350 5 8 0 1 90 0 1 53 | pinlabel=5 54 | T 850 1450 5 8 0 1 270 0 1 55 | pintype=pas 56 | } 57 | L 1900 1700 1700 1700 3 0 0 0 -1 -1 58 | L 1900 1400 1700 1400 3 0 0 0 -1 -1 59 | L 1900 1100 1700 1100 3 0 0 0 -1 -1 60 | L 1900 800 1700 800 3 0 0 0 -1 -1 61 | L 900 500 900 300 3 0 0 0 -1 -1 62 | T 100 2200 5 10 0 0 0 0 1 63 | author=andrewmATthehacktoryDOTcom 64 | T 100 2000 8 10 1 1 0 0 1 65 | refdes=CONN5 66 | V 900 600 100 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 67 | L 1000 600 1700 600 3 0 0 0 -1 -1 68 | L 1700 1900 0 1900 3 0 0 0 -1 -1 69 | L 1700 1900 1700 600 3 0 0 0 -1 -1 70 | L 800 600 0 600 3 0 0 0 -1 -1 71 | L 0 1900 0 600 3 0 0 0 -1 -1 72 | L 100 1900 100 600 3 0 0 0 -1 -1 73 | L 1000 1600 1000 1300 3 0 0 0 -1 -1 74 | L 1000 1300 200 1400 3 0 0 0 -1 -1 75 | L 200 1400 200 1500 3 0 0 0 -1 -1 76 | L 200 1500 1000 1600 3 0 0 0 -1 -1 77 | L 1000 1200 1000 900 3 0 0 0 -1 -1 78 | L 1000 900 200 1000 3 0 0 0 -1 -1 79 | L 200 1000 200 1100 3 0 0 0 -1 -1 80 | L 200 1100 1000 1200 3 0 0 0 -1 -1 81 | L 360 1520 360 1380 3 0 0 0 -1 -1 82 | L 360 1120 360 980 3 0 0 0 -1 -1 83 | T 100 2400 5 10 0 0 0 0 1 84 | dist-license=GPL 85 | T 100 2600 5 10 0 0 0 0 1 86 | use-license=unlimited 87 | T 1250 1650 9 10 1 0 0 0 1 88 | 5V 89 | T 1250 1350 9 10 1 0 0 0 1 90 | D- 91 | T 1250 1050 9 10 1 0 0 0 1 92 | D+ 93 | T 1100 750 9 10 1 0 0 0 1 94 | GND 95 | T 700 1800 8 10 0 1 0 0 1 96 | footprint=usbminib_hirose_th 97 | -------------------------------------------------------------------------------- /plc-hw/symbols/diodeSOD123.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | L 300 500 300 100 3 0 0 0 -1 -1 3 | L 300 500 600 300 3 0 0 0 -1 -1 4 | T 400 600 5 10 0 0 0 0 1 5 | device=DIODE 6 | L 600 300 300 100 3 0 0 0 -1 -1 7 | L 600 500 600 100 3 0 0 0 -1 -1 8 | P 0 300 200 300 1 0 0 9 | { 10 | T 100 350 5 8 0 1 0 0 1 11 | pinnumber=1 12 | T 100 350 5 8 0 0 0 0 1 13 | pinseq=1 14 | T 100 350 5 8 0 1 0 0 1 15 | pinlabel=1 16 | T 100 350 5 8 0 1 0 0 1 17 | pintype=pas 18 | } 19 | P 900 300 700 300 1 0 0 20 | { 21 | T 700 350 5 8 0 1 0 0 1 22 | pinnumber=2 23 | T 700 350 5 8 0 0 0 0 1 24 | pinseq=2 25 | T 700 350 5 8 0 1 0 0 1 26 | pinlabel=2 27 | T 700 350 5 8 0 1 0 0 1 28 | pintype=pas 29 | } 30 | L 700 300 600 300 3 0 0 0 -1 -1 31 | L 300 300 200 300 3 0 0 0 -1 -1 32 | A 650 500 50 0 180 3 0 0 0 -1 -1 33 | A 550 100 50 180 180 3 0 0 0 -1 -1 34 | T 300 600 8 10 1 1 0 0 1 35 | refdes=D21 36 | T -5 50 8 10 0 1 0 0 1 37 | footprint=SOD123 38 | -------------------------------------------------------------------------------- /plc-hw/symbols/enc28j60.src: -------------------------------------------------------------------------------- 1 | # This is the template file for creating symbols with tragesym 2 | # every line starting with '#' is a comment line. 3 | 4 | [options] 5 | # wordswap swaps labels if the pin is on the right side an looks like this: 6 | # "PB1 (CLK)". That's useful for micro controller port labels 7 | # rotate_labels rotates the pintext of top and bottom pins 8 | # this is useful for large symbols like FPGAs with more than 100 pins 9 | # sort_labels will sort the pins by it's labels 10 | # useful for address ports, busses, ... 11 | wordswap=yes 12 | rotate_labels=yes 13 | sort_labels=yes 14 | generate_pinseq=yes 15 | sym_width=4000 16 | pinwidthvertical=200 17 | pinwidthhorizontal=200 18 | 19 | [geda_attr] 20 | # name will be printed in the top of the symbol 21 | # name is only some graphical text, not an attribute 22 | # version specifies a gschem version. 23 | # if you have a device with slots, you'll have to use slot= and slotdef= 24 | # use comment= if there are special information you want to add 25 | version=20060113 1 26 | name=ENC28J60 27 | device=ENC28J60 28 | refdes=U17 29 | footprint=SSOP28 30 | description= Microchip MAC/PHY 31 | documentation= http://ww1.microchip.com/downloads/en/DeviceDoc/39662c.pdf 32 | author= Nicholas Wertzberger 33 | dist-license=Free 34 | use-license=Free 35 | numslots=0 36 | #slot=1 37 | #slotdef=1: 38 | #slotdef=2: 39 | #slotdef=3: 40 | #slotdef=4: 41 | #comment= 42 | #comment= 43 | #comment= 44 | 45 | [pins] 46 | # tabseparated list of pin descriptions 47 | # ---------------------------------------- 48 | # pinnr is the physical number of the pin 49 | # seq is the pinseq= attribute, leave it blank if it doesn't matter 50 | # type can be (in, out, io, oc, oe, pas, tp, tri, clk, pwr) 51 | # style can be (line,dot,clk,dotclk,spacer,none). none if only want to add a net 52 | # posit. can be (l,r,t,b) or empty for nets. 53 | # net specifies the name of the net. Vcc or GND for example. 54 | # label represents the pinlabel. 55 | # negation lines can be added with "\_" example: \_enable\_ 56 | # if you want to write a "\" use "\\" as escape sequence 57 | #----------------------------------------------------- 58 | #pinnr seq type style posit. net label 59 | #----------------------------------------------------- 60 | 1 pwr line t VCAP 61 | 2 pwr line b VSS 62 | 3 io line l CLKOUT 63 | 4 io dot l _INT 64 | 5 io line t NC* 65 | 6 io line l SO 66 | 7 io line l SI 67 | 8 io line l SCK 68 | 9 io dot l _CS 69 | 10 io dot r _RESET 70 | 11 pwr line b VSSRX 71 | 12 io line r TPIN- 72 | 13 io line r TPIN+ 73 | 14 io line r RBIAS 74 | 15 pwr line t VDDTX 75 | 16 io line r TPOUT- 76 | 17 io line r TPOUT+ 77 | 18 pwr line b VSSTX 78 | 19 pwr line t VDDRX 79 | 20 pwr line t VDDPLL 80 | 21 pwr line b VSSPLL 81 | 22 pwr line b VSSOSC 82 | 23 io line r OSC1 83 | 24 io line r OSC2 84 | 25 pwr line t VDDOSC 85 | 26 io line r LEDB 86 | 27 io line r LEDA 87 | 28 pwr line t VDD 88 | 89 | -------------------------------------------------------------------------------- /plc-hw/symbols/inductor1008.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | P 900 100 750 100 1 0 0 3 | { 4 | T 800 150 5 8 0 1 0 0 1 5 | pinnumber=2 6 | T 800 50 5 8 0 1 0 2 1 7 | pinseq=2 8 | T 700 100 9 8 0 1 0 6 1 9 | pinlabel=2 10 | T 700 100 5 8 0 1 0 8 1 11 | pintype=pas 12 | } 13 | P 0 100 150 100 1 0 0 14 | { 15 | T 100 150 5 8 0 1 0 6 1 16 | pinnumber=1 17 | T 100 50 5 8 0 1 0 8 1 18 | pinseq=1 19 | T 200 100 9 8 0 1 0 0 1 20 | pinlabel=1 21 | T 200 100 5 8 0 1 0 2 1 22 | pintype=pas 23 | } 24 | A 237 100 75 0 180 3 0 0 0 -1 -1 25 | A 379 100 75 0 180 3 0 0 0 -1 -1 26 | A 521 100 75 0 180 3 0 0 0 -1 -1 27 | A 663 100 75 0 180 3 0 0 0 -1 -1 28 | T 200 500 5 10 0 0 0 0 1 29 | device=INDUCTOR 30 | L 738 100 750 100 3 0 0 0 -1 -1 31 | L 150 100 162 100 3 0 0 0 -1 -1 32 | A 308 100 4 180 180 3 0 0 0 -1 -1 33 | A 450 100 4 180 180 3 0 0 0 -1 -1 34 | A 592 100 4 180 180 3 0 0 0 -1 -1 35 | T 200 300 8 10 1 1 0 0 1 36 | refdes=L4 37 | T 200 1100 5 10 0 0 0 0 1 38 | description=inductor 39 | T 200 900 5 10 0 0 0 0 1 40 | numslots=0 41 | T 200 700 5 10 0 0 0 0 1 42 | symversion=0.1 43 | T 1395 248 8 10 0 1 0 0 1 44 | footprint=1008 45 | -------------------------------------------------------------------------------- /plc-hw/symbols/lm2902.sym: -------------------------------------------------------------------------------- 1 | v 20031231 1 2 | L 200 0 200 800 3 0 0 0 -1 -1 3 | L 200 800 800 400 3 0 0 0 -1 -1 4 | L 800 400 200 0 3 0 0 0 -1 -1 5 | T 825 150 5 8 0 0 0 0 1 6 | device=LM2902 7 | T 700 1200 5 10 0 0 0 0 1 8 | numslots=4 9 | T 675 1050 5 10 0 0 0 0 1 10 | slotdef=1:1,2,3 11 | T 675 900 5 10 0 0 0 0 1 12 | slotdef=2:7,6,5 13 | T 675 750 5 10 0 0 0 0 1 14 | slotdef=3:8,9,10 15 | T 675 600 5 10 0 0 0 0 1 16 | slotdef=4:14,13,12 17 | T 1225 450 5 10 0 0 0 0 1 18 | slot=1 19 | P 200 600 0 600 1 0 1 20 | { 21 | T 50 625 5 8 1 1 0 0 1 22 | pinnumber=3 23 | T 50 625 5 8 0 0 0 0 1 24 | pinseq=3 25 | } 26 | P 200 200 0 200 1 0 1 27 | { 28 | T 50 225 5 8 1 1 0 0 1 29 | pinnumber=2 30 | T 50 225 5 8 0 0 0 0 1 31 | pinseq=2 32 | } 33 | P 800 400 1000 400 1 0 1 34 | { 35 | T 875 425 5 8 1 1 0 0 1 36 | pinnumber=1 37 | T 875 425 5 8 0 0 0 0 1 38 | pinseq=1 39 | } 40 | P 500 200 500 0 1 0 1 41 | { 42 | T 525 50 5 8 1 1 0 0 1 43 | pinnumber=11 44 | T 525 50 5 8 0 0 0 0 1 45 | pinseq=11 46 | } 47 | P 500 600 500 800 1 0 1 48 | { 49 | T 525 650 5 8 1 1 0 0 1 50 | pinnumber=4 51 | T 525 650 5 8 0 0 0 0 1 52 | pinseq=4 53 | } 54 | L 250 600 350 600 3 0 0 0 -1 -1 55 | L 300 650 300 550 3 0 0 0 -1 -1 56 | L 250 200 350 200 3 0 0 0 -1 -1 57 | T 225 350 9 7 1 0 0 0 1 58 | LM2902 59 | T 2200 1900 5 10 0 0 0 0 1 60 | footprint=SSOP14 61 | T 200 900 8 10 1 1 0 0 1 62 | refdes=U19 63 | -------------------------------------------------------------------------------- /plc-hw/symbols/res0603.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | L 600 200 500 0 3 0 0 0 -1 -1 3 | L 500 0 400 200 3 0 0 0 -1 -1 4 | L 400 200 300 0 3 0 0 0 -1 -1 5 | L 300 0 200 200 3 0 0 0 -1 -1 6 | T 300 400 5 10 0 0 0 0 1 7 | device=RESISTOR 8 | L 600 200 700 0 3 0 0 0 -1 -1 9 | L 700 0 750 100 3 0 0 0 -1 -1 10 | P 900 100 750 100 1 0 0 11 | { 12 | T 800 150 5 8 0 1 0 0 1 13 | pinnumber=2 14 | T 800 150 5 8 0 0 0 0 1 15 | pinseq=2 16 | T 800 150 5 8 0 1 0 0 1 17 | pinlabel=2 18 | T 800 150 5 8 0 1 0 0 1 19 | pintype=pas 20 | } 21 | P 0 100 152 100 1 0 0 22 | { 23 | T 100 150 5 8 0 1 0 0 1 24 | pinnumber=1 25 | T 100 150 5 8 0 0 0 0 1 26 | pinseq=1 27 | T 100 150 5 8 0 1 0 0 1 28 | pinlabel=1 29 | T 100 150 5 8 0 1 0 0 1 30 | pintype=pas 31 | } 32 | L 201 200 150 100 3 0 0 0 -1 -1 33 | T 200 300 8 10 1 1 0 0 1 34 | refdes=R18 35 | T 0 0 8 10 0 1 0 0 1 36 | pins=2 37 | T 0 0 8 10 0 1 0 0 1 38 | class=DISCRETE 39 | T -5 0 8 10 0 1 0 0 1 40 | footprint=603 41 | -------------------------------------------------------------------------------- /plc-hw/symbols/res4SipIso.src: -------------------------------------------------------------------------------- 1 | # This is the template file for creating symbols with tragesym 2 | # every line starting with '#' is a comment line. 3 | 4 | [options] 5 | # wordswap swaps labels if the pin is on the right side an looks like this: 6 | # "PB1 (CLK)". That's useful for micro controller port labels 7 | # rotate_labels rotates the pintext of top and bottom pins 8 | # this is useful for large symbols like FPGAs with more than 100 pins 9 | # sort_labels will sort the pins by it's labels 10 | # useful for address ports, busses, ... 11 | wordswap=yes 12 | rotate_labels=yes 13 | sort_labels=yes 14 | generate_pinseq=yes 15 | sym_width=400 16 | pinwidthvertical=200 17 | pinwidthhorizontal=200 18 | 19 | [geda_attr] 20 | # name will be printed in the top of the symbol 21 | # name is only some graphical text, not an attribute 22 | # version specifies a gschem version. 23 | # if you have a device with slots, you'll have to use slot= and slotdef= 24 | # use comment= if there are special information you want to add 25 | version=20060113 1 26 | name=SIP-RC 27 | device=SIP-RC 28 | refdes=U22 29 | footprint=SIP8 30 | description= Isolated Sip Resistor Pack 31 | documentation= http://www.mouser.com/catalog/specsheets/XC-600048.pdf 32 | author= Nicholas Wertzberger 33 | dist-license=Free 34 | use-license=Free 35 | numslots=0 36 | slot=1 37 | slotdef=1:1,2 38 | slotdef=2:3,4 39 | slotdef=3:5,6 40 | slotdef=4:7,8 41 | #comment= 42 | #comment= 43 | #comment= 44 | 45 | [pins] 46 | # tabseparated list of pin descriptions 47 | # ---------------------------------------- 48 | # pinnr is the physical number of the pin 49 | # seq is the pinseq= attribute, leave it blank if it doesn't matter 50 | # type can be (in, out, io, oc, oe, pas, tp, tri, clk, pwr) 51 | # style can be (line,dot,clk,dotclk,spacer,none). none if only want to add a net 52 | # posit. can be (l,r,t,b) or empty for nets. 53 | # net specifies the name of the net. Vcc or GND for example. 54 | # label represents the pinlabel. 55 | # negation lines can be added with "\_" example: \_enable\_ 56 | # if you want to write a "\" use "\\" as escape sequence 57 | #----------------------------------------------------- 58 | #pinnr seq type style posit. net label 59 | #----------------------------------------------------- 60 | 1 pas line l 61 | 2 pas line r 62 | 3 pas line l 63 | 4 pas line r 64 | 5 pas line l 65 | 6 pas line r 66 | 7 pas line l 67 | 8 pas line r 68 | 69 | -------------------------------------------------------------------------------- /plc-hw/symbols/res4SipIso.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | P 1100 900 800 900 1 0 0 3 | { 4 | T 900 950 5 8 1 1 0 0 1 5 | pinnumber=2 6 | T 900 850 5 8 0 1 0 2 1 7 | pinseq=2 8 | T 750 900 5 8 0 1 0 8 1 9 | pintype=pas 10 | } 11 | P 1100 700 800 700 1 0 0 12 | { 13 | T 900 750 5 8 1 1 0 0 1 14 | pinnumber=4 15 | T 900 650 5 8 0 1 0 2 1 16 | pinseq=4 17 | T 750 700 5 8 0 1 0 8 1 18 | pintype=pas 19 | } 20 | P 1100 500 800 500 1 0 0 21 | { 22 | T 900 550 5 8 1 1 0 0 1 23 | pinnumber=6 24 | T 900 450 5 8 0 1 0 2 1 25 | pinseq=6 26 | T 750 500 5 8 0 1 0 8 1 27 | pintype=pas 28 | } 29 | P 1100 300 800 300 1 0 0 30 | { 31 | T 900 350 5 8 1 1 0 0 1 32 | pinnumber=8 33 | T 900 250 5 8 0 1 0 2 1 34 | pinseq=8 35 | T 750 300 5 8 0 1 0 8 1 36 | pintype=pas 37 | } 38 | P 100 900 400 900 1 0 0 39 | { 40 | T 300 950 5 8 1 1 0 6 1 41 | pinnumber=1 42 | T 300 850 5 8 0 1 0 8 1 43 | pinseq=1 44 | T 450 900 5 8 0 1 0 2 1 45 | pintype=pas 46 | } 47 | P 100 700 400 700 1 0 0 48 | { 49 | T 300 750 5 8 1 1 0 6 1 50 | pinnumber=3 51 | T 300 650 5 8 0 1 0 8 1 52 | pinseq=3 53 | T 450 700 5 8 0 1 0 2 1 54 | pintype=pas 55 | } 56 | P 100 500 400 500 1 0 0 57 | { 58 | T 300 550 5 8 1 1 0 6 1 59 | pinnumber=5 60 | T 300 450 5 8 0 1 0 8 1 61 | pinseq=5 62 | T 450 500 5 8 0 1 0 2 1 63 | pintype=pas 64 | } 65 | P 100 300 400 300 1 0 0 66 | { 67 | T 300 350 5 8 1 1 0 6 1 68 | pinnumber=7 69 | T 300 250 5 8 0 1 0 8 1 70 | pinseq=7 71 | T 450 300 5 8 0 1 0 2 1 72 | pintype=pas 73 | } 74 | B 400 100 400 1000 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 75 | T 800 1200 8 10 1 1 0 6 1 76 | refdes=U23 77 | T 700 300 9 10 1 0 90 0 1 78 | SIP-RC 79 | T 400 1400 5 10 0 0 0 0 1 80 | device=SIP-RC 81 | T 400 1600 5 10 0 0 0 0 1 82 | footprint=SIP8 83 | T 400 1800 5 10 0 0 0 0 1 84 | author=Nicholas Wertzberger 85 | T 400 2000 5 10 0 0 0 0 1 86 | documentation=http://www.mouser.com/catalog/specsheets/XC-600048.pdf 87 | T 400 2200 5 10 0 0 0 0 1 88 | description=Isolated Sip Resistor Pack 89 | T 400 2400 5 10 0 0 0 0 1 90 | numslots=0 91 | T 400 2600 5 10 0 0 0 0 1 92 | dist-license=Free 93 | T 400 2800 5 10 0 0 0 0 1 94 | use-license=Free 95 | T 400 3000 5 10 0 0 0 0 1 96 | slot=1 97 | T 400 3200 5 10 0 0 0 0 1 98 | slotdef=1:1,2 99 | T 400 3400 5 10 0 0 0 0 1 100 | slotdef=2:3,4 101 | T 400 3600 5 10 0 0 0 0 1 102 | slotdef=3:5,6 103 | T 400 3800 5 10 0 0 0 0 1 104 | slotdef=4:7,8 105 | -------------------------------------------------------------------------------- /plc-hw/symbols/resSip12kCommon.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | P 0 200 200 200 1 0 0 3 | { 4 | T 150 250 5 8 0 1 0 6 1 5 | pinnumber=1 6 | T 150 150 5 8 0 1 0 8 1 7 | pinseq=1 8 | T 200 200 9 8 0 1 0 0 1 9 | pinlabel=1 10 | T 200 200 5 8 0 1 0 2 1 11 | footprint=603 12 | } 13 | P 900 200 700 200 1 0 0 14 | { 15 | T 750 250 5 8 0 1 0 0 1 16 | pinnumber=2 17 | T 750 150 5 8 0 1 0 2 1 18 | pinseq=2 19 | T 700 200 9 8 0 1 0 6 1 20 | pinlabel=2 21 | T 700 200 5 8 0 1 0 8 1 22 | pintype=pas 23 | } 24 | L 400 400 400 0 3 0 0 0 -1 -1 25 | L 500 400 500 0 3 0 0 0 -1 -1 26 | L 700 200 500 200 3 0 0 0 -1 -1 27 | L 400 200 200 200 3 0 0 0 -1 -1 28 | T 200 700 5 10 0 0 0 0 1 29 | device=CAPACITOR 30 | T 200 500 8 10 1 1 0 0 1 31 | refdes=C18 32 | T 200 1300 5 10 0 0 0 0 1 33 | description=capacitor 34 | T 200 1100 5 10 0 0 0 0 1 35 | numslots=0 36 | T 200 900 5 10 0 0 0 0 1 37 | symversion=0.1 38 | T -5 0 8 10 0 1 0 0 1 39 | footprint=603 40 | -------------------------------------------------------------------------------- /plc-hw/symbols/ua78m33cdcyr.src: -------------------------------------------------------------------------------- 1 | # This is the template file for creating symbols with tragesym 2 | # every line starting with '#' is a comment line. 3 | 4 | [options] 5 | # wordswap swaps labels if the pin is on the right side an looks like this: 6 | # "PB1 (CLK)". That's useful for micro controller port labels 7 | # rotate_labels rotates the pintext of top and bottom pins 8 | # this is useful for large symbols like FPGAs with more than 100 pins 9 | # sort_labels will sort the pins by it's labels 10 | # useful for address ports, busses, ... 11 | wordswap=yes 12 | rotate_labels=yes 13 | sort_labels=yes 14 | generate_pinseq=yes 15 | sym_width=1000 16 | pinwidthvertical=200 17 | pinwidthhorizontal=200 18 | 19 | [geda_attr] 20 | # name will be printed in the top of the symbol 21 | # name is only some graphical text, not an attribute 22 | # version specifies a gschem version. 23 | # if you have a device with slots, you'll have to use slot= and slotdef= 24 | # use comment= if there are special information you want to add 25 | version=20060113 1 26 | name=UA78M33CDCYR 27 | device=UA78M33CDCYR 28 | refdes=U24 29 | footprint=SOT223 30 | description= TI 3.3V Linear Regulator 31 | documentation= http://www.ti.com/lit/gpn/UA78M33 32 | author= Nicholas Wertzberger 33 | dist-license=Free 34 | use-license=Free 35 | numslots=0 36 | #slot=1 37 | #slotdef=1: 38 | #slotdef=2: 39 | #slotdef=3: 40 | #slotdef=4: 41 | #comment= 42 | #comment= 43 | #comment= 44 | 45 | [pins] 46 | # tabseparated list of pin descriptions 47 | # ---------------------------------------- 48 | # pinnr is the physical number of the pin 49 | # seq is the pinseq= attribute, leave it blank if it doesn't matter 50 | # type can be (in, out, io, oc, oe, pas, tp, tri, clk, pwr) 51 | # style can be (line,dot,clk,dotclk,spacer,none). none if only want to add a net 52 | # posit. can be (l,r,t,b) or empty for nets. 53 | # net specifies the name of the net. Vcc or GND for example. 54 | # label represents the pinlabel. 55 | # negation lines can be added with "\_" example: \_enable\_ 56 | # if you want to write a "\" use "\\" as escape sequence 57 | #----------------------------------------------------- 58 | #pinnr seq type style posit. net label 59 | #----------------------------------------------------- 60 | 1 pwr line l IN 61 | 2 pwr line b COM 62 | 3 pwr line r OUT 63 | 4 pwr line b COM 64 | 65 | -------------------------------------------------------------------------------- /plc-hw/symbols/ua78m33cdcyr.sym: -------------------------------------------------------------------------------- 1 | v 20100214 2 2 | P 1700 600 1400 600 1 0 0 3 | { 4 | T 1500 650 5 8 1 1 0 0 1 5 | pinnumber=3 6 | T 1500 550 5 8 0 1 0 2 1 7 | pinseq=3 8 | T 1350 600 9 8 1 1 0 6 1 9 | pinlabel=OUT 10 | T 1350 600 5 8 0 1 0 8 1 11 | pintype=pwr 12 | } 13 | P 100 600 400 600 1 0 0 14 | { 15 | T 300 650 5 8 1 1 0 6 1 16 | pinnumber=1 17 | T 300 550 5 8 0 1 0 8 1 18 | pinseq=1 19 | T 450 600 9 8 1 1 0 0 1 20 | pinlabel=IN 21 | T 450 600 5 8 0 1 0 2 1 22 | pintype=pwr 23 | } 24 | P 800 -100 800 200 1 0 0 25 | { 26 | T 750 100 5 8 1 1 90 6 1 27 | pinnumber=2 28 | T 850 100 5 8 0 1 90 8 1 29 | pinseq=2 30 | T 800 250 9 8 1 1 90 0 1 31 | pinlabel=COM 32 | T 800 250 5 8 0 1 90 2 1 33 | pintype=pwr 34 | } 35 | P 1000 -100 1000 200 1 0 0 36 | { 37 | T 950 100 5 8 1 1 90 6 1 38 | pinnumber=4 39 | T 1050 100 5 8 0 1 90 8 1 40 | pinseq=4 41 | T 1000 250 9 8 1 1 90 0 1 42 | pinlabel=COM 43 | T 1000 250 5 8 0 1 90 2 1 44 | pintype=pwr 45 | } 46 | B 400 200 1000 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 47 | T 1400 900 8 10 1 1 0 6 1 48 | refdes=U25 49 | T 300 900 9 10 1 0 0 0 1 50 | UA78M33 51 | T 400 1100 5 10 0 0 0 0 1 52 | device=UA78M33CDCYR 53 | T 400 1300 5 10 0 0 0 0 1 54 | footprint=SOT223 55 | T 400 1500 5 10 0 0 0 0 1 56 | author=Nicholas Wertzberger 57 | T 400 1700 5 10 0 0 0 0 1 58 | documentation=http://www.ti.com/lit/gpn/UA78M33 59 | T 400 1900 5 10 0 0 0 0 1 60 | description=TI 3.3V Linear Regulator 61 | T 400 2100 5 10 0 0 0 0 1 62 | numslots=0 63 | T 400 2300 5 10 0 0 0 0 1 64 | dist-license=Free 65 | T 400 2500 5 10 0 0 0 0 1 66 | use-license=Free 67 | -------------------------------------------------------------------------------- /plc-sw/MakeConf.include: -------------------------------------------------------------------------------- 1 | ########################## Project specific configuration ######################### 2 | #Options in this section should be copied to your project specific directory 3 | # 4 | #Microprossor choice, for avr-gcc 5 | #MCU = atmega644 6 | # 7 | #Microprossor choice, for avrdude 8 | #CHIP = m644 #See 'man avrdude', devices are listed under the Options section 9 | # 10 | #Project name 11 | #NAME = 12 | # 13 | #Included applications 14 | #APPS = 15 | # 16 | #Included libraries 17 | #LIBS = 18 | # 19 | #Included drivers 20 | #DEVS = 21 | # 22 | #Low fuse 23 | #LFUSE = 0x62 24 | # 25 | #High fuse 26 | #HFUSE = 0xDF 27 | 28 | ############################ Programmer configuration ############################# 29 | #Most of these options should probably be stored in a user specific makefile 30 | 31 | #TODO: Programmer configuration for avrdude 32 | 33 | #Define programmer used 34 | ifndef $(PROGRAMMER) 35 | PROGRAMMER = avrusb500 36 | endif 37 | 38 | ############################# Compiler configuration ############################## 39 | 40 | #Compiler selection 41 | CC = avr-gcc 42 | 43 | #check if we have a C lint tool 44 | LINT= 45 | 46 | FINDLINT:=$(shell which lint) 47 | 48 | ifeq ($(FINDLINT),) 49 | FINDLINT:=$(shell which splint) 50 | endif 51 | 52 | ifneq ($(FINDLINT),) 53 | LINT = $(FINDLINT) 54 | endif 55 | 56 | #Compiler flags 57 | ifndef CFLAGS 58 | CFLAGS = -Wall -mmcu=$(MCU) -g -fpack-struct -Os -funsigned-char -funsigned-bitfields -mcall-prologues -Wstrict-prototypes -std=gnu99 59 | endif 60 | 61 | #Object translator 62 | OBJCOPY = avr-objcopy 63 | 64 | ############################# Directory configuration ############################# 65 | 66 | ifndef TOPLEVEL 67 | TOPLEVEL = ../../ 68 | endif 69 | 70 | #directory for object files 71 | OBJECTDIR = ./obj 72 | 73 | #directory for libraries 74 | LIBSDIR = $(TOPLEVEL)/libs 75 | 76 | #directory for device drivers 77 | DEVSDIR = $(TOPLEVEL)/drivers 78 | 79 | #directory for applications 80 | APPSDIR = $(TOPLEVEL)/apps 81 | 82 | #directory of uip 83 | UIPDIR = $(TOPLEVEL)/uip 84 | 85 | #interfaces directory for drivers 86 | IDEVDIR = $(TOPLEVEL)/drivers/interfaces 87 | 88 | #interfaces directory for libraries 89 | ILIBDIR = $(TOPLEVEL)/libs/interfaces 90 | -------------------------------------------------------------------------------- /plc-sw/README: -------------------------------------------------------------------------------- 1 | OpenPLC is based on the AVR-uIP port done at http://code.google.com/p/avr-uip/. 2 | 3 | OpenPLC is broken up into two separate projects: 4 | 5 | HILSim - a hardware-in-the-loop simulator 6 | OpenPLC - a PLC that is based completely on open-source software. 7 | 8 | It is recommended that you read the README in the doc section. This area is 9 | a hodgepodge of original documentation and updated docs based on what OpenPLC does 10 | differently. 11 | 12 | The directory structure look as follows: 13 | 14 | apps/ - Example applications 15 | doc/ - Documentation 16 | libs/ - Library code used by some applications and dirvers 17 | uip/ - uIP TCP/IP stack code 18 | drivers/ - Drivers for various hardware 19 | projects/ - different projects that take advantage of the rest of the code. 20 | -------------------------------------------------------------------------------- /plc-sw/apps/README: -------------------------------------------------------------------------------- 1 | This directory contains a few example applications. They are not all 2 | heavily tested, however. 3 | -------------------------------------------------------------------------------- /plc-sw/apps/dhcpc/Makefile.dhcpc: -------------------------------------------------------------------------------- 1 | APP_SOURCES += dhcpc.c timer.c 2 | -------------------------------------------------------------------------------- /plc-sw/apps/dhcpc/dhcpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * @(#)$Id: dhcpc.h,v 1.3 2006/06/11 21:46:37 adam Exp $ 32 | */ 33 | #ifndef __DHCPC_H__ 34 | #define __DHCPC_H__ 35 | 36 | #include "timer.h" 37 | #include "pt.h" 38 | 39 | struct dhcpc_state { 40 | struct pt pt; 41 | u8_t state; 42 | struct uip_udp_conn *conn; 43 | struct timer timer; 44 | u16_t ticks; 45 | const void *mac_addr; 46 | u8_t mac_len; 47 | 48 | u8_t serverid[4]; 49 | 50 | u16_t lease_time[2]; 51 | u16_t ipaddr[2]; 52 | u16_t netmask[2]; 53 | u16_t dnsaddr[2]; 54 | u16_t default_router[2]; 55 | }; 56 | 57 | void dhcpc_init(const void *mac_addr, uint8_t mac_len); 58 | void dhcpc_request(void); 59 | void dhcpc_renew(void); 60 | 61 | void dhcpc_appcall(void); 62 | 63 | void dhcpc_configured(const struct dhcpc_state *s); 64 | 65 | 66 | #if defined PORT_APP_MAPPER 67 | #define DHCPC_APP_CALL_MAP {dhcpc_appcall, 0, 67}, 68 | #else 69 | #define DHCPC_APP_CALL_MAP 70 | #define UIP_UDP_APPCALL dhcpc_appcall 71 | typedef struct dhcpc_state uip_udp_appstate_t; 72 | #endif 73 | 74 | 75 | #endif /* __DHCPC_H__ */ 76 | -------------------------------------------------------------------------------- /plc-sw/apps/hello-world/Makefile.hello-world: -------------------------------------------------------------------------------- 1 | APP_SOURCES += hello-world.c 2 | -------------------------------------------------------------------------------- /plc-sw/apps/hello-world/hello-world.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup apps 3 | * @{ 4 | */ 5 | 6 | /** 7 | * \defgroup helloworld Hello, world 8 | * @{ 9 | * 10 | * A small example showing how to write applications with 11 | * \ref psock "protosockets". 12 | */ 13 | 14 | /** 15 | * \file 16 | * Header file for an example of how to write uIP applications 17 | * with protosockets. 18 | * \author 19 | * Adam Dunkels 20 | */ 21 | 22 | #ifndef __HELLO_WORLD_H__ 23 | #define __HELLO_WORLD_H__ 24 | 25 | /* Since this file will be included by uip.h, we cannot include uip.h 26 | here. But we might need to include uipopt.h if we need the u8_t and 27 | u16_t datatypes. */ 28 | #include "uipopt.h" 29 | 30 | #include "psock.h" 31 | 32 | /* Next, we define the uip_tcp_appstate_t datatype. This is the state 33 | of our application, and the memory required for this state is 34 | allocated together with each TCP connection. One application state 35 | for each TCP connection. */ 36 | typedef struct hello_world_state { 37 | struct psock p; 38 | char inputbuffer[10]; 39 | char name[40]; 40 | } uip_tcp_appstate_t; 41 | 42 | /* Finally we define the application function to be called by uIP. */ 43 | void hello_world_appcall(void); 44 | #ifndef UIP_APPCALL 45 | #define UIP_APPCALL hello_world_appcall 46 | #endif /* UIP_APPCALL */ 47 | 48 | void hello_world_init(void); 49 | 50 | #endif /* __HELLO_WORLD_H__ */ 51 | /** @} */ 52 | /** @} */ 53 | -------------------------------------------------------------------------------- /plc-sw/apps/jsoncmd/Makefile.jsoncmd: -------------------------------------------------------------------------------- 1 | APP_SOURCES += jsoncmd.c shell.c memb.c 2 | 3 | LIBS+= memb 4 | -------------------------------------------------------------------------------- /plc-sw/apps/jsoncmd/jsoncmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: jsoncmd.h,v 1.2 2006/06/07 09:43:54 adam Exp $ 33 | * 34 | */ 35 | #ifndef __JSONCMD_H__ 36 | #define __JSONCMD_H__ 37 | 38 | #include "uipopt.h" 39 | 40 | void jsoncmd_appcall(void); 41 | 42 | #ifndef JSONCMD_CONF_GETCALLBACK 43 | #define JSONCMD_CONF_GETCALLBACK default_callback 44 | #endif 45 | 46 | #ifndef JSONCMD_CONF_SETCALLBACK 47 | #define JSONCMD_CONF_SETCALLBACK default_callback 48 | #endif 49 | 50 | #ifndef JSONCMD_CONF_LINELEN 51 | #define JSONCMD_CONF_LINELEN 80 52 | #endif 53 | #ifndef JSONCMD_CONF_NUMLINES 54 | #define JSONCMD_CONF_NUMLINES 20 55 | #endif 56 | 57 | struct jsoncmd_state { 58 | char *lines[JSONCMD_CONF_NUMLINES]; 59 | char buf[JSONCMD_CONF_LINELEN]; 60 | char bufptr; 61 | u8_t numsent; 62 | u8_t state; 63 | }; 64 | 65 | 66 | #if defined PORT_APP_MAPPER 67 | #define JSONCMD_APP_CALL_MAP {jsoncmd_appcall, 23, 0}, 68 | struct jsoncmd_state jsoncmd_state_list[UIP_CONF_MAX_CONNECTIONS]; 69 | #else 70 | #define JSONCMD_APP_CALL_MAP 71 | #define UIP_APPCALL jsoncmd_appcall 72 | typedef struct jsoncmd_state uip_tcp_appstate_t; 73 | #endif 74 | 75 | #endif /* __JSONCMD_H__ */ 76 | -------------------------------------------------------------------------------- /plc-sw/apps/jsoncmd/shell.c: -------------------------------------------------------------------------------- 1 | #include "apps-conf.h" 2 | #include "jsoncmd.h" 3 | #include "shell.h" 4 | 5 | #include 6 | 7 | // Constants 8 | #define NUM_TOKENS 20 9 | 10 | // function prototypes 11 | static void inttostr(register char *str, unsigned int i); 12 | static void default_callback(int * vals); 13 | 14 | static int values[8]; 15 | 16 | void shell_init(void) 17 | { 18 | } 19 | 20 | void shell_start(void) 21 | { 22 | } 23 | 24 | // I need this to work yesterday... I'm sorry! 25 | void shell_input(char * js) 26 | { 27 | char * cmd = strchr(js, '"') + 1; 28 | if (strncmp(cmd,"getvalues", 4) == 0) { 29 | JSONCMD_CONF_GETCALLBACK(values); 30 | shell_prompt("{\"response\":\"OK\",\"values\":["); 31 | for (int i=0; i < 8; i++) { 32 | char buf[10]; 33 | inttostr(buf, values[i]); 34 | shell_prompt(buf); 35 | if ( i < 7 ) { 36 | shell_prompt(","); 37 | } 38 | } 39 | shell_output("]}", ""); 40 | } 41 | else if (strncmp(cmd, "setvalues", 4) == 0) { 42 | cmd = strchr(cmd, '[')+1; 43 | for( int i=0; i < 8; i++) { 44 | sscanf(cmd, "%d", &values[i]); 45 | cmd = strchr(cmd, ',') + 1; 46 | } 47 | JSONCMD_CONF_SETCALLBACK(values); 48 | shell_output("{\"response\":\"OK\"}",""); 49 | 50 | } 51 | else { 52 | shell_output("{\"response\":\"error\"}",""); 53 | } 54 | } 55 | 56 | /** 57 | * Does nothing, but saves the build if the user hasn't defined this yet... 58 | */ 59 | static void default_callback(int * vals) 60 | { 61 | } 62 | 63 | // used to convert integers into strings... Like printf! 64 | static void inttostr(register char *str, unsigned int i) 65 | { 66 | str[0] = '0' + i / 100; 67 | if(str[0] == '0') { 68 | str[0] = ' '; 69 | } 70 | str[1] = '0' + (i / 10) % 10; 71 | if(str[0] == ' ' && str[1] == '0') { 72 | str[1] = ' '; 73 | } 74 | str[2] = '0' + i % 10; 75 | str[3] = 0; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /plc-sw/apps/port_app_mapper/Makefile.port_app_mapper: -------------------------------------------------------------------------------- 1 | APP_SOURCES += port_app_mapper.c 2 | -------------------------------------------------------------------------------- /plc-sw/apps/port_app_mapper/README: -------------------------------------------------------------------------------- 1 | 2 | What is this? 3 | ------------- 4 | It's an app that will map the incomming network port and protocol to the proper app. 5 | Sort of like inetd on unix. 6 | Each app manages it's own state information and the app state data in the network connection is replaced with an uint8_t which notes which state structure for the given app is in use. 7 | This app, the mapper then is the only network app which the uip stack calls. 8 | This app when called, maps the packet the real app via the source or destination port numbers. 9 | 10 | webservers == dest port 80 11 | webclients == source port 80 12 | etc 13 | 14 | Where did this idea come from? 15 | ------------------------------ 16 | The basic idea for writing this version came from looking at code Jan Kleis Nielsen wrote to solve this issue 17 | 18 | Why did you write this? 19 | ----------------------- 20 | 21 | Fun, and I thought I might need this type of thing one day and the uip stack has this little design issue where it expects you to have only one network app for UDP and one for TCP. I like a uniform system which works for everyone... for the most part. :-) That's one of the ways things scale. 22 | 23 | -------------------------------------------------------------------------------- /plc-sw/apps/port_app_mapper/port_app_mapper.h: -------------------------------------------------------------------------------- 1 | #ifndef __PORT_APP_MAPPER_H__ 2 | #define __PORT_APP_MAPPER_H__ 3 | 4 | #include "apps-conf.h" 5 | 6 | void uip_appcall_port_app_mapper(void); 7 | void uip_udp_appcall_port_app_mapper(void); 8 | 9 | #if defined UIP_APPCALL || defined UIP_UDP_APPCALL 10 | //#warn "*** PORT APP MAPPER WILL REDEFINE APPCALL ****" 11 | #undef UIP_APPCALL 12 | // #undef UIP_UDP_APPCALL 13 | #endif 14 | 15 | // now re-define the app call 16 | #define UIP_APPCALL uip_appcall_port_app_mapper 17 | #define UIP_UDP_APPCALL uip_udp_appcall_port_app_mapper 18 | 19 | #if defined PORT_APP_MAPPER 20 | typedef int8_t uip_tcp_appstate_t; 21 | typedef int8_t uip_udp_appstate_t; 22 | #else 23 | #error "port_app_mapper compiled but, PORT_APP_MAPPER not defined in apps-conf.h" 24 | #endif 25 | 26 | struct port_appcall_map 27 | { 28 | void (*an_appcall)(void); 29 | uint16_t lport; 30 | uint16_t rport; 31 | }; 32 | 33 | // Add the following to the top of your project app-conf.h file then include this header at the end of the file 34 | // #define PORT_APP_MAPPER 1 35 | 36 | #endif // __PORT_APP_MAPPER_H__ 37 | -------------------------------------------------------------------------------- /plc-sw/apps/simple-httpd/Makefile.simple-httpd: -------------------------------------------------------------------------------- 1 | APP_SOURCES += simple-httpd.c 2 | -------------------------------------------------------------------------------- /plc-sw/apps/simple-httpd/simple-httpd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "simple-httpd.h" 5 | #include "uip.h" 6 | 7 | static int handle_connection(struct simple_httpd_state *s); 8 | 9 | void simple_httpd_init(void) 10 | { 11 | PORTD |= 1 << 2; 12 | uip_listen(HTONS(80)); 13 | } 14 | 15 | #if defined PORT_APP_MAPPER 16 | void simple_httpd_appcall(void) 17 | { 18 | PORTD |= 1 << 3; 19 | struct simple_httpd_state *s = &(httpd_state_list[0]); 20 | #else 21 | void simple_httpd_appcall(void) 22 | { 23 | struct simple_httpd_state *s = &(uip_conn->appstate); 24 | #endif 25 | if(uip_connected()) { 26 | PSOCK_INIT(&s->p, NULL, 0); 27 | } 28 | 29 | handle_connection(s); 30 | } 31 | 32 | static int handle_connection(struct simple_httpd_state *s) 33 | { 34 | PORTD |= 1 << 4; 35 | PSOCK_BEGIN(&s->p); 36 | PSOCK_SEND_STR(&s->p, "HTTP/1.0 200 OK\r\n"); 37 | PSOCK_SEND_STR(&s->p, "Content-Type: text/plain\r\n"); 38 | PSOCK_SEND_STR(&s->p, "\r\n"); 39 | PSOCK_SEND_STR(&s->p, "Hello World, From a simple httpd."); 40 | PSOCK_CLOSE(&s->p); 41 | PSOCK_END(&s->p); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /plc-sw/apps/simple-httpd/simple-httpd.h: -------------------------------------------------------------------------------- 1 | #ifndef __SIMPLE_HTTPD_H__ 2 | #define __SIMPLE_HTTPD_H__ 3 | #include "psock.h" 4 | 5 | struct simple_httpd_state { 6 | struct psock p; 7 | }; 8 | 9 | 10 | void simple_httpd_appcall(void); 11 | void simple_httpd_init(void); 12 | 13 | #if defined PORT_APP_MAPPER 14 | #define SIMPLE_HTTPD_APP_CALL_MAP {simple_httpd_appcall, 80, 0}, 15 | struct simple_httpd_state httpd_state_list[UIP_CONF_MAX_CONNECTIONS]; 16 | #else 17 | #define SIMPLE_HTTPD_APP_CALL_MAP 18 | #define UIP_APPCALL simple_httpd_appcall 19 | typedef struct simple_httpd_state uip_tcp_appstate_t; 20 | #endif 21 | 22 | #endif /* __SIMPLE_HTTPD_H__ */ 23 | -------------------------------------------------------------------------------- /plc-sw/apps/telnetd/Makefile.telnetd: -------------------------------------------------------------------------------- 1 | APP_SOURCES += telnetd.c shell.c memb.c 2 | 3 | LIBS+= memb 4 | -------------------------------------------------------------------------------- /plc-sw/apps/telnetd/telnetd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $ 33 | * 34 | */ 35 | #ifndef __TELNETD_H__ 36 | #define __TELNETD_H__ 37 | 38 | #include "uipopt.h" 39 | 40 | void telnetd_appcall(void); 41 | 42 | #ifndef TELNETD_CONF_LINELEN 43 | #define TELNETD_CONF_LINELEN 40 44 | #endif 45 | #ifndef TELNETD_CONF_NUMLINES 46 | #define TELNETD_CONF_NUMLINES 16 47 | #endif 48 | 49 | struct telnetd_state { 50 | char *lines[TELNETD_CONF_NUMLINES]; 51 | char buf[TELNETD_CONF_LINELEN]; 52 | char bufptr; 53 | u8_t numsent; 54 | u8_t state; 55 | }; 56 | 57 | 58 | #if defined PORT_APP_MAPPER 59 | #define TELNET_APP_CALL_MAP {telnetd_appcall, 23, 0}, 60 | struct telnetd_state telnetd_state_list[UIP_CONF_MAX_CONNECTIONS]; 61 | #else 62 | #define TELNET_APP_CALL_MAP 63 | #define UIP_APPCALL telnetd_appcall 64 | typedef struct telnetd_state uip_tcp_appstate_t; 65 | #endif 66 | 67 | #endif /* __TELNETD_H__ */ 68 | -------------------------------------------------------------------------------- /plc-sw/changelog.txt: -------------------------------------------------------------------------------- 1 | * Starting with project stolen from the uIP-AVR port 2 | 3 | It didn't make much sense to do it any other way. There is a defined 4 | format used by this project, and I like it. 5 | -------------------------------------------------------------------------------- /plc-sw/doc/Atmega1284p.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/Atmega1284p.pdf -------------------------------------------------------------------------------- /plc-sw/doc/ENC28J60.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/ENC28J60.pdf -------------------------------------------------------------------------------- /plc-sw/doc/Makefile: -------------------------------------------------------------------------------- 1 | all: htmldoc pdfdoc 2 | 3 | htmldoc: 4 | doxygen Doxyfile 5 | 6 | pdfdoc: htmldoc 7 | cd latex; make refman.pdf && mv refman.pdf ../uip-refman.pdf 8 | -------------------------------------------------------------------------------- /plc-sw/doc/README: -------------------------------------------------------------------------------- 1 | The files in this directory comprise the uIP documentation. The files 2 | are: 3 | 4 | html/ The uIP reference manual in HTML format. 5 | 6 | uip-refman.pdf The uIP reference manual in a printable PDF version. 7 | 8 | mobisys2003.pdf Conference paper about uIP from the First 9 | International Conference on Mobile Systems, 10 | Applications and Services (MobiSys), San 11 | Francisco, May 2003. 12 | 13 | -------------------------------------------------------------------------------- /plc-sw/doc/doxygen.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{doxygen} 3 | \RequirePackage{calc} 4 | \RequirePackage{array} 5 | \pagestyle{fancyplain} 6 | \newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}} 7 | \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} 8 | \lhead[\fancyplain{}{\bfseries\thepage}] 9 | {\fancyplain{}{\bfseries\rightmark}} 10 | \rhead[\fancyplain{}{\bfseries\leftmark}] 11 | {\fancyplain{}{\bfseries\thepage}} 12 | \rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen\lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen}} 13 | \cfoot{} 14 | \newenvironment{CompactList} 15 | {\begin{list}{}{ 16 | \setlength{\leftmargin}{0.5cm} 17 | \setlength{\itemsep}{0pt} 18 | \setlength{\parsep}{0pt} 19 | \setlength{\topsep}{0pt} 20 | \renewcommand{\makelabel}{}}} 21 | {\end{list}} 22 | \newenvironment{CompactItemize} 23 | { 24 | \begin{itemize} 25 | \setlength{\itemsep}{-3pt} 26 | \setlength{\parsep}{0pt} 27 | \setlength{\topsep}{0pt} 28 | \setlength{\partopsep}{0pt} 29 | } 30 | {\end{itemize}} 31 | \newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp} 32 | \newlength{\tmplength} 33 | \newenvironment{TabularC}[1] 34 | { 35 | \setlength{\tmplength} 36 | {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)} 37 | \par\begin{tabular*}{\linewidth} 38 | {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|} 39 | } 40 | {\end{tabular*}\par} 41 | \newcommand{\entrylabel}[1]{ 42 | {\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\\}}} 43 | \newenvironment{Desc} 44 | {\begin{list}{} 45 | { 46 | \settowidth{\labelwidth}{40pt} 47 | \setlength{\leftmargin}{\labelwidth} 48 | \setlength{\parsep}{0pt} 49 | \setlength{\itemsep}{-4pt} 50 | \renewcommand{\makelabel}{\entrylabel} 51 | } 52 | } 53 | {\end{list}} 54 | \newenvironment{Indent} 55 | {\begin{list}{}{\setlength{\leftmargin}{0.5cm}} 56 | \item[]\ignorespaces} 57 | {\unskip\end{list}} 58 | \setlength{\parindent}{0cm} 59 | \setlength{\parskip}{0.2cm} 60 | \addtocounter{secnumdepth}{1} 61 | \sloppy 62 | \usepackage[T1]{fontenc} 63 | -------------------------------------------------------------------------------- /plc-sw/doc/example-mainloop-with-arp.c: -------------------------------------------------------------------------------- 1 | #include "uip.h" 2 | #include "uip_arp.h" 3 | #include "network-device.h" 4 | #include "httpd.h" 5 | #include "timer.h" 6 | 7 | #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) 8 | 9 | /*---------------------------------------------------------------------------*/ 10 | int 11 | main(void) 12 | { 13 | int i; 14 | uip_ipaddr_t ipaddr; 15 | struct timer periodic_timer, arp_timer; 16 | 17 | timer_set(&periodic_timer, CLOCK_SECOND / 2); 18 | timer_set(&arp_timer, CLOCK_SECOND * 10); 19 | 20 | network_device_init(); 21 | uip_init(); 22 | 23 | uip_ipaddr(ipaddr, 192,168,0,2); 24 | uip_sethostaddr(ipaddr); 25 | 26 | httpd_init(); 27 | 28 | while(1) { 29 | uip_len = network_device_read(); 30 | if(uip_len > 0) { 31 | if(BUF->type == htons(UIP_ETHTYPE_IP)) { 32 | uip_arp_ipin(); 33 | uip_input(); 34 | /* If the above function invocation resulted in data that 35 | should be sent out on the network, the global variable 36 | uip_len is set to a value > 0. */ 37 | if(uip_len > 0) { 38 | uip_arp_out(); 39 | network_device_send(); 40 | } 41 | } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { 42 | uip_arp_arpin(); 43 | /* If the above function invocation resulted in data that 44 | should be sent out on the network, the global variable 45 | uip_len is set to a value > 0. */ 46 | if(uip_len > 0) { 47 | network_device_send(); 48 | } 49 | } 50 | 51 | } else if(timer_expired(&periodic_timer)) { 52 | timer_reset(&periodic_timer); 53 | for(i = 0; i < UIP_CONNS; i++) { 54 | uip_periodic(i); 55 | /* If the above function invocation resulted in data that 56 | should be sent out on the network, the global variable 57 | uip_len is set to a value > 0. */ 58 | if(uip_len > 0) { 59 | uip_arp_out(); 60 | network_device_send(); 61 | } 62 | } 63 | 64 | #if UIP_UDP 65 | for(i = 0; i < UIP_UDP_CONNS; i++) { 66 | uip_udp_periodic(i); 67 | /* If the above function invocation resulted in data that 68 | should be sent out on the network, the global variable 69 | uip_len is set to a value > 0. */ 70 | if(uip_len > 0) { 71 | uip_arp_out(); 72 | network_device_send(); 73 | } 74 | } 75 | #endif /* UIP_UDP */ 76 | 77 | /* Call the ARP timer function every 10 seconds. */ 78 | if(timer_expired(&arp_timer)) { 79 | timer_reset(&arp_timer); 80 | uip_arp_timer(); 81 | } 82 | } 83 | } 84 | return 0; 85 | } 86 | /*---------------------------------------------------------------------------*/ 87 | -------------------------------------------------------------------------------- /plc-sw/doc/example-mainloop-without-arp.c: -------------------------------------------------------------------------------- 1 | #include "uip.h" 2 | #include "uip_arp.h" 3 | #include "network-device.h" 4 | #include "httpd.h" 5 | #include "timer.h" 6 | 7 | /*---------------------------------------------------------------------------*/ 8 | int 9 | main(void) 10 | { 11 | int i; 12 | uip_ipaddr_t ipaddr; 13 | struct timer periodic_timer; 14 | 15 | timer_set(&periodic_timer, CLOCK_SECOND / 2); 16 | 17 | network_device_init(); 18 | uip_init(); 19 | 20 | uip_ipaddr(ipaddr, 192,168,0,2); 21 | uip_sethostaddr(ipaddr); 22 | 23 | httpd_init(); 24 | 25 | while(1) { 26 | uip_len = network_device_read(); 27 | if(uip_len > 0) { 28 | uip_input(); 29 | /* If the above function invocation resulted in data that 30 | should be sent out on the network, the global variable 31 | uip_len is set to a value > 0. */ 32 | if(uip_len > 0) { 33 | network_device_send(); 34 | } 35 | } else if(timer_expired(&periodic_timer)) { 36 | timer_reset(&periodic_timer); 37 | for(i = 0; i < UIP_CONNS; i++) { 38 | uip_periodic(i); 39 | /* If the above function invocation resulted in data that 40 | should be sent out on the network, the global variable 41 | uip_len is set to a value > 0. */ 42 | if(uip_len > 0) { 43 | network_device_send(); 44 | } 45 | } 46 | 47 | #if UIP_UDP 48 | for(i = 0; i < UIP_UDP_CONNS; i++) { 49 | uip_udp_periodic(i); 50 | /* If the above function invocation resulted in data that 51 | should be sent out on the network, the global variable 52 | uip_len is set to a value > 0. */ 53 | if(uip_len > 0) { 54 | network_device_send(); 55 | } 56 | } 57 | #endif /* UIP_UDP */ 58 | } 59 | } 60 | return 0; 61 | } 62 | /*---------------------------------------------------------------------------*/ 63 | -------------------------------------------------------------------------------- /plc-sw/doc/examples.txt: -------------------------------------------------------------------------------- 1 | /** 2 | \defgroup apps Applications 3 | @{ 4 | 5 | The uIP distribution contains a number of example applications that 6 | can be either used directory or studied when learning to develop 7 | applications for uIP. 8 | 9 | */ 10 | 11 | /** \example hello-world.c */ 12 | /** \example hello-world.h */ 13 | 14 | /** \example smtp.c */ 15 | /** \example smtp.h */ 16 | 17 | /** \example webclient.c */ 18 | /** \example webclient.h */ 19 | 20 | /** \example example-mainloop-with-arp.c */ 21 | /** \example example-mainloop-without-arp.c */ 22 | 23 | /** \example telnetd.c */ 24 | /** \example telnetd.h */ 25 | 26 | /** \example resolv.c */ 27 | /** \example resolv.h */ 28 | 29 | /** \example dhcpc.c */ 30 | /** \example dhcpc.h */ 31 | 32 | /** \example uip-conf.h */ 33 | 34 | /** @} */ 35 | -------------------------------------------------------------------------------- /plc-sw/doc/header.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{book} 2 | \usepackage{a4wide} 3 | \usepackage{makeidx} 4 | \usepackage{fancyhdr} 5 | \usepackage{graphicx} 6 | \usepackage{multicol} 7 | \usepackage{float} 8 | \usepackage{textcomp} 9 | \usepackage{alltt} 10 | \usepackage{times} 11 | \ifx\pdfoutput\undefined 12 | \usepackage[ps2pdf, 13 | pagebackref=true, 14 | colorlinks=true, 15 | linkcolor=blue 16 | ]{hyperref} 17 | \usepackage{pspicture} 18 | \else 19 | \usepackage[pdftex, 20 | pagebackref=true, 21 | colorlinks=true, 22 | linkcolor=blue 23 | ]{hyperref} 24 | \fi 25 | \usepackage{doxygen} 26 | \makeindex 27 | \setcounter{tocdepth}{1} 28 | \renewcommand{\footrulewidth}{0.4pt} 29 | \begin{document} 30 | \begin{titlepage} 31 | \vspace*{5cm} 32 | \begin{center} 33 | {\Huge The uIP Embedded TCP/IP Stack}\\ 34 | \vspace*{1cm} 35 | {\LARGE The uIP 1.0 Reference Manual}\\ 36 | \vspace*{3cm} 37 | {\Large June 2006}\\ 38 | \vspace*{2cm} 39 | \includegraphics[width=6cm]{../sicslogo.pdf}\\ 40 | \vspace*{1cm} 41 | {\Large Adam Dunkels}\\ 42 | {\Large \texttt{adam@sics.se}}\\ 43 | \vspace*{1cm} 44 | {\LARGE Swedish Institute of Computer Science}\\ 45 | \vspace*{0.5cm} 46 | 47 | \end{center} 48 | \end{titlepage} 49 | \clearemptydoublepage 50 | \pagenumbering{roman} 51 | \tableofcontents 52 | \clearemptydoublepage 53 | \pagenumbering{arabic} 54 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00079.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: httpd_cgi_call Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

httpd_cgi_call Struct Reference
24 | 25 | [Web server] 26 |


Detailed Description

27 | 28 |

29 | 30 |

31 | Definition at line 60 of file httpd-cgi.h. 32 | 33 | 34 | 36 | 37 | 39 | 40 |

Data Fields

35 | const char * name
38 | const httpd_cgifunction function
41 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00083.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: psock_buf Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

psock_buf Struct Reference
24 | 25 | [Protosockets library] 26 |


Detailed Description

27 | 28 |

29 | 30 |

31 | Definition at line 95 of file psock.h. 32 | 33 | 34 | 36 | 37 | 39 | 40 |

Data Fields

35 | u8_tptr
38 | unsigned short left
41 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00084.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: pt Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

pt Struct Reference
24 | 25 | [Protothreads] 26 |


Detailed Description

27 |
Examples:
28 | 29 |

30 | dhcpc.h.

31 |

32 | 33 |

34 | Definition at line 54 of file pt.h. 35 | 36 | 37 | 39 | 40 |

Data Fields

38 | lc_t lc
41 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00087.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: timer Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

timer Struct Reference
24 | 25 | [Timer library] 26 |

#include <timer.h> 27 |

28 |


Detailed Description

29 | A timer. 30 |

31 | This structure is used for declaring a timer. The timer must be set with timer_set() before it can be used.

Examples:
32 | 33 |

34 | dhcpc.h, example-mainloop-with-arp.c, example-mainloop-without-arp.c, and webclient.h.

35 |

36 | 37 |

38 | Definition at line 74 of file timer.h. 39 | 40 | 41 | 43 | 44 | 46 | 47 |

Data Fields

42 | clock_time_t start
45 | clock_time_t interval
48 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  49 | 50 | doxygen 1.4.6
51 | 52 | 53 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00089.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip_eth_addr Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uip_eth_addr Struct Reference
24 | 25 | [The uIP TCP/IP stack] 26 |

#include <uip.h> 27 |

28 |


Detailed Description

29 | Representation of a 48-bit Ethernet address. 30 |

31 | 32 |

33 | Definition at line 1542 of file uip.h. 34 | 35 | 36 | 38 | 39 |

Data Fields

37 | u8_t addr [6]
40 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  41 | 42 | doxygen 1.4.6
43 | 44 | 45 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00092.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip_neighbor_addr Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uip_neighbor_addr Struct Reference


Detailed Description

24 | 25 |

26 | 27 |

28 | Definition at line 47 of file uip-neighbor.h. 29 | 30 | 31 | 33 | 34 |

Data Fields

32 | uip_eth_addr addr
35 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  36 | 37 | doxygen 1.4.6
38 | 39 | 40 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00100.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/hello-world/hello-world.c File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/hello-world/hello-world.c File Reference


Detailed Description

22 | An example of how to write uIP applications with protosockets. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file hello-world.c. 28 |

29 | #include "hello-world.h"
30 | #include "uip.h"
31 | #include <string.h>
32 | 33 |

34 | Go to the source code of this file. 35 | 36 | 37 | 39 | 40 | 42 | 43 |

Functions

38 | void hello_world_init (void)
41 | void hello_world_appcall (void)
44 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  45 | 46 | doxygen 1.4.6
47 | 48 | 49 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00112.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/webserver/httpd-cgi.c File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/webserver/httpd-cgi.c File Reference


Detailed Description

22 | Web server script interface. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file httpd-cgi.c. 28 |

29 | #include "uip.h"
30 | #include "psock.h"
31 | #include "httpd.h"
32 | #include "httpd-cgi.h"
33 | #include "httpd-fs.h"
34 | #include <stdio.h>
35 | #include <string.h>
36 | 37 |

38 | Go to the source code of this file. 39 | 40 | 41 | 43 | 44 |

Functions

42 | httpd_cgifunction httpd_cgi (char *name)
45 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  46 | 47 | doxygen 1.4.6
48 | 49 | 50 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00113.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/webserver/httpd-cgi.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/webserver/httpd-cgi.h File Reference


Detailed Description

22 | Web server script interface header file. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file httpd-cgi.h. 28 |

29 | #include "psock.h"
30 | #include "httpd.h"
31 | 32 |

33 | Go to the source code of this file. 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 46 |

Data Structures

struct  httpd_cgi_call

Defines

#define HTTPD_CGI_CALL(name, str, function)
 HTTPD CGI function declaration.

Functions

44 | httpd_cgifunction httpd_cgi (char *name)
47 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  48 | 49 | doxygen 1.4.6
50 | 51 | 52 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00125.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip/lc.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

uip/lc.h File Reference


Detailed Description

22 | Local continuations. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file lc.h. 28 |

29 | #include "lc-switch.h"
30 | 31 |

32 | Go to the source code of this file. 33 | 34 |
35 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  36 | 37 | doxygen 1.4.6
38 | 39 | 40 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00134.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip/uip-split.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

uip/uip-split.h File Reference


Detailed Description

22 | Module for splitting outbound TCP segments in two to avoid the delayed ACK throughput degradation. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file uip-split.h. 28 |

29 | 30 |

31 | Go to the source code of this file. 32 | 33 | 34 | 35 | 36 | 37 |

Functions

void uip_split_output (void)
 Handle outgoing packets.
38 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  39 | 40 | doxygen 1.4.6
41 | 42 | 43 | -------------------------------------------------------------------------------- /plc-sw/doc/html/a00143.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Applications 4 | 5 | 6 | 7 | 8 |
9 |
16 |

Applications


Detailed Description

17 | The uIP distribution contains a number of example applications that can be either used directory or studied when learning to develop applications for uIP. 18 |

19 | 20 |

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

29 |

30 | 31 | 32 | 33 |

34 |

35 | 36 | 37 | 38 |

39 |

40 | 41 | 42 | 43 |

44 |

45 | 46 | 47 | 48 |

49 |


Modules

 DNS resolver
 The uIP DNS resolver functions are used to lookup a hostname and map it to a numerical IP address.
 SMTP E-mail sender
 The Simple Mail Transfer Protocol (SMTP) as defined by RFC821 is the standard way of sending and transfering e-mail on the Internet.
 Hello, world
 A small example showing how to write applications with protosockets.
 Web client
 This example shows a HTTP client that is able to download web pages and files from web servers.
 Web server
 The uIP web server is a very simplistic implementation of an HTTP server.
50 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  51 | 52 | doxygen 1.4.6
53 | 54 | 55 | -------------------------------------------------------------------------------- /plc-sw/doc/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/doxygen.png -------------------------------------------------------------------------------- /plc-sw/doc/html/examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Examples 4 | 5 | 6 | 7 | 8 |
9 |
16 |

uIP 1.0 Examples

Here is a list of all examples: 34 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  35 | 36 | doxygen 1.4.6
37 | 38 | 39 | -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2blank.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2doc.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2folderclosed.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2folderopen.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2lastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2lastnode.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2link.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2mlastnode.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2mnode.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2node.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2plastnode.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2pnode.png -------------------------------------------------------------------------------- /plc-sw/doc/html/ftv2vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/ftv2vertline.png -------------------------------------------------------------------------------- /plc-sw/doc/html/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- _ -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_0x65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- e -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- f -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_defs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- _ -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_defs_0x62.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- b -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_defs_0x65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- e -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_defs_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- f -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_defs_0x72.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- r -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /plc-sw/doc/html/globals_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |   31 |

32 |

43 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  44 | 45 | doxygen 1.4.6
46 | 47 | 48 | -------------------------------------------------------------------------------- /plc-sw/doc/html/hierarchy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Hierarchical Index 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uIP 1.0 Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically: 46 |
Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  47 | 48 | doxygen 1.4.6
49 | 50 | 51 | -------------------------------------------------------------------------------- /plc-sw/doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /plc-sw/doc/html/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Module Index 4 | 5 | 6 | 7 | 8 |
9 |
16 |

uIP 1.0 Modules

Here is a list of all modules: 47 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  48 | 49 | doxygen 1.4.6
50 | 51 | 52 | -------------------------------------------------------------------------------- /plc-sw/doc/html/tab_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/tab_b.gif -------------------------------------------------------------------------------- /plc-sw/doc/html/tab_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/tab_l.gif -------------------------------------------------------------------------------- /plc-sw/doc/html/tab_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/html/tab_r.gif -------------------------------------------------------------------------------- /plc-sw/doc/html/tabs.css: -------------------------------------------------------------------------------- 1 | /* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ 2 | 3 | DIV.tabs 4 | { 5 | float : left; 6 | width : 100%; 7 | background : url("tab_b.gif") repeat-x bottom; 8 | margin-bottom : 4px; 9 | } 10 | 11 | DIV.tabs UL 12 | { 13 | margin : 0px; 14 | padding-left : 10px; 15 | list-style : none; 16 | } 17 | 18 | DIV.tabs LI, DIV.tabs FORM 19 | { 20 | display : inline; 21 | margin : 0px; 22 | padding : 0px; 23 | } 24 | 25 | DIV.tabs FORM 26 | { 27 | float : right; 28 | } 29 | 30 | DIV.tabs A 31 | { 32 | float : left; 33 | background : url("tab_r.gif") no-repeat right top; 34 | border-bottom : 1px solid #84B0C7; 35 | font-size : x-small; 36 | font-weight : bold; 37 | text-decoration : none; 38 | } 39 | 40 | DIV.tabs A:hover 41 | { 42 | background-position: 100% -150px; 43 | } 44 | 45 | DIV.tabs A:link, DIV.tabs A:visited, 46 | DIV.tabs A:active, DIV.tabs A:hover 47 | { 48 | color: #1A419D; 49 | } 50 | 51 | DIV.tabs SPAN 52 | { 53 | float : left; 54 | display : block; 55 | background : url("tab_l.gif") no-repeat left top; 56 | padding : 5px 9px; 57 | white-space : nowrap; 58 | } 59 | 60 | DIV.tabs INPUT 61 | { 62 | float : right; 63 | display : inline; 64 | font-size : 1em; 65 | } 66 | 67 | DIV.tabs TD 68 | { 69 | font-size : x-small; 70 | font-weight : bold; 71 | text-decoration : none; 72 | } 73 | 74 | 75 | 76 | /* Commented Backslash Hack hides rule from IE5-Mac \*/ 77 | DIV.tabs SPAN {float : none;} 78 | /* End IE5-Mac hack */ 79 | 80 | DIV.tabs A:hover SPAN 81 | { 82 | background-position: 0% -150px; 83 | } 84 | 85 | DIV.tabs LI#current A 86 | { 87 | background-position: 100% -150px; 88 | border-width : 0px; 89 | } 90 | 91 | DIV.tabs LI#current SPAN 92 | { 93 | background-position: 0% -150px; 94 | padding-bottom : 6px; 95 | } 96 | 97 | DIV.nav 98 | { 99 | background : none; 100 | border : none; 101 | border-bottom : 1px solid #84B0C7; 102 | } 103 | -------------------------------------------------------------------------------- /plc-sw/doc/mobisys2003.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/mobisys2003.pdf -------------------------------------------------------------------------------- /plc-sw/doc/sicslogo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/sicslogo.pdf -------------------------------------------------------------------------------- /plc-sw/doc/uip-code-style.txt: -------------------------------------------------------------------------------- 1 | /** 2 | \example uip-code-style.c 3 | */ 4 | -------------------------------------------------------------------------------- /plc-sw/doc/uip-refman.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/doc/uip-refman.pdf -------------------------------------------------------------------------------- /plc-sw/drivers/enc28j60/Makefile.enc28j60: -------------------------------------------------------------------------------- 1 | DEV_SOURCES += enc28j60.c network.c 2 | LIBS += avrlib-avrlib-conf 3 | -------------------------------------------------------------------------------- /plc-sw/drivers/enc28j60/avrlibdefs.h: -------------------------------------------------------------------------------- 1 | /*! \file avrlibdefs.h \brief AVRlib global defines and macros. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'avrlibdefs.h' 5 | // Title : AVRlib global defines and macros include file 6 | // Author : Pascal Stang 7 | // Created : 7/12/2001 8 | // Revised : 9/30/2002 9 | // Version : 1.1 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : This include file is designed to contain items useful to all 14 | // code files and projects, regardless of specific implementation. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | 22 | #ifndef AVRLIBDEFS_H 23 | #define AVRLIBDEFS_H 24 | 25 | // Code compatibility to new AVR-libc 26 | // outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli() 27 | #ifndef outb 28 | #define outb(addr, data) addr = (data) 29 | #endif 30 | #ifndef inb 31 | #define inb(addr) (addr) 32 | #endif 33 | #ifndef outw 34 | #define outw(addr, data) addr = (data) 35 | #endif 36 | #ifndef inw 37 | #define inw(addr) (addr) 38 | #endif 39 | #ifndef BV 40 | #define BV(bit) (1<<(bit)) 41 | #endif 42 | #ifndef cbi 43 | #define cbi(reg,bit) reg &= ~(BV(bit)) 44 | #endif 45 | #ifndef sbi 46 | #define sbi(reg,bit) reg |= (BV(bit)) 47 | #endif 48 | #ifndef cli 49 | #define cli() __asm__ __volatile__ ("cli" ::) 50 | #endif 51 | #ifndef sei 52 | #define sei() __asm__ __volatile__ ("sei" ::) 53 | #endif 54 | 55 | // support for individual port pin naming in the mega128 56 | // see port128.h for details 57 | #ifdef __AVR_ATmega128__ 58 | // not currently necessary due to inclusion 59 | // of these defines in newest AVR-GCC 60 | // do a quick test to see if include is needed 61 | #ifndef PD0 62 | #include "port128.h" 63 | #endif 64 | #endif 65 | 66 | // use this for packed structures 67 | // (this is seldom necessary on an 8-bit architecture like AVR, 68 | // but can assist in code portability to AVR) 69 | #define GNUC_PACKED __attribute__((packed)) 70 | 71 | // port address helpers 72 | #define DDR(x) ((x)-1) // address of data direction register of port x 73 | #define PIN(x) ((x)-2) // address of input register of port x 74 | 75 | // MIN/MAX/ABS macros 76 | #define MIN(a,b) ((ab)?(a):(b)) 78 | #define ABS(x) ((x>0)?(x):(-x)) 79 | 80 | // constants 81 | #define PI 3.14159265359 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /plc-sw/drivers/enc28j60/avrlibtypes.h: -------------------------------------------------------------------------------- 1 | /*! \file avrlibtypes.h \brief AVRlib global types and typedefines. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'avrlibtypes.h' 5 | // Title : AVRlib global types and typedefines include file 6 | // Author : Pascal Stang 7 | // Created : 7/12/2001 8 | // Revised : 9/30/2002 9 | // Version : 1.0 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : Type-defines required and used by AVRlib. Most types are also 14 | // generally useful. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | 22 | #ifndef AVRLIBTYPES_H 23 | #define AVRLIBTYPES_H 24 | 25 | #ifndef WIN32 26 | // true/false defines 27 | #define FALSE 0 28 | #define TRUE -1 29 | #endif 30 | 31 | // datatype definitions macros 32 | typedef unsigned char u08; 33 | typedef signed char s08; 34 | typedef unsigned short u16; 35 | typedef signed short s16; 36 | typedef unsigned long u32; 37 | typedef signed long s32; 38 | typedef unsigned long long u64; 39 | typedef signed long long s64; 40 | 41 | /* use inttypes.h instead 42 | // C99 standard integer type definitions 43 | typedef unsigned char uint8_t; 44 | typedef signed char int8_t; 45 | typedef unsigned short uint16_t; 46 | typedef signed short int16_t; 47 | typedef unsigned long uint32_t; 48 | typedef signed long int32_t; 49 | typedef unsigned long uint64_t; 50 | typedef signed long int64_t; 51 | */ 52 | // maximum value that can be held 53 | // by unsigned data types (8,16,32bits) 54 | #define MAX_U08 255 55 | #define MAX_U16 65535 56 | #define MAX_U32 4294967295 57 | 58 | // maximum values that can be held 59 | // by signed data types (8,16,32bits) 60 | #define MIN_S08 -128 61 | #define MAX_S08 127 62 | #define MIN_S16 -32768 63 | #define MAX_S16 32767 64 | #define MIN_S32 -2147483648 65 | #define MAX_S32 2147483647 66 | 67 | #ifndef WIN32 68 | // more type redefinitions 69 | typedef unsigned char BOOL; 70 | typedef unsigned char BYTE; 71 | typedef unsigned int WORD; 72 | typedef unsigned long DWORD; 73 | 74 | typedef unsigned char UCHAR; 75 | typedef unsigned int UINT; 76 | typedef unsigned short USHORT; 77 | typedef unsigned long ULONG; 78 | 79 | typedef char CHAR; 80 | typedef int INT; 81 | typedef long LONG; 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /plc-sw/drivers/enc28j60/enc28j60conf.h: -------------------------------------------------------------------------------- 1 | /*! \file enc28j60conf.h \brief Microchip ENC28J60 Ethernet Interface Driver Configuration. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'enc28j60conf.h' 5 | // Title : Microchip ENC28J60 Ethernet Interface Driver Configuration 6 | // Author : Pascal Stang 7 | // Created : 10/5/2004 8 | // Revised : 8/22/2005 9 | // Version : 0.1 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : This driver provides initialization and transmit/receive 14 | // functions for the ENC28J60 10Mb Ethernet Controller and PHY. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | 22 | /* USERS NOTE: 23 | * Do not enter your hardware specific configurations here. Copy the settings 24 | * below and define them in your baord specific directory. Remember to also 25 | * define ENC28J60CONF_H so that these settings will not overwrite yours. 26 | * By modifying this in your board specific directory, you should be able to 27 | * update/upgrade your avr-uip distribution without having to modify updated 28 | * files. 29 | * 30 | * 31 | * DEVELOPERS NOTE: 32 | * Settings entered should be something rather common, and not update too often. 33 | */ 34 | 35 | 36 | #ifndef ENC28J60CONF_H 37 | #define ENC28J60CONF_H 38 | 39 | 40 | /* 41 | ////#ifdef PORTB1 42 | // ENC28J60 SPI port 43 | #define ENC28J60_SPI_PORT PORTB 44 | #define ENC28J60_SPI_DDR DDRB 45 | #define ENC28J60_SPI_SCK PORTB5 46 | #define ENC28J60_SPI_MOSI PORTB3 47 | #define ENC28J60_SPI_MISO PORTB4 48 | #define ENC28J60_SPI_SS PORTB2 49 | // ENC28J60 control port 50 | #define ENC28J60_CONTROL_PORT PORTB 51 | #define ENC28J60_CONTROL_DDR DDRB 52 | #define ENC28J60_CONTROL_CS PORTB2 53 | ////#else 54 | */ 55 | /* 56 | // ENC28J60 SPI port 57 | #define ENC28J60_SPI_PORT PORTB 58 | #define ENC28J60_SPI_DDR DDRB 59 | #define ENC28J60_SPI_SCK PB5 60 | #define ENC28J60_SPI_MOSI PB3 61 | #define ENC28J60_SPI_MISO PB4 62 | #define ENC28J60_SPI_SS PB2 63 | // ENC28J60 control port 64 | #define ENC28J60_CONTROL_PORT PORTB 65 | #define ENC28J60_CONTROL_DDR DDRB 66 | #define ENC28J60_CONTROL_CS PB2 67 | #endif 68 | */ 69 | 70 | // MAC address for this interface 71 | #ifdef ETHADDR0 72 | #define ENC28J60_MAC0 ETHADDR0 73 | #define ENC28J60_MAC1 ETHADDR1 74 | #define ENC28J60_MAC2 ETHADDR2 75 | #define ENC28J60_MAC3 ETHADDR3 76 | #define ENC28J60_MAC4 ETHADDR4 77 | #define ENC28J60_MAC5 ETHADDR5 78 | #else 79 | #define ENC28J60_MAC0 '0' 80 | #define ENC28J60_MAC1 'F' 81 | #define ENC28J60_MAC2 'F' 82 | #define ENC28J60_MAC3 'I' 83 | #define ENC28J60_MAC4 'C' 84 | #define ENC28J60_MAC5 'E' 85 | #endif 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /plc-sw/drivers/enc28j60/global.h: -------------------------------------------------------------------------------- 1 | /*! \file global.h \brief AVRlib project global include. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'global.h' 5 | // Title : AVRlib project global include 6 | // Author : Pascal Stang - Copyright (C) 2001-2002 7 | // Created : 7/12/2001 8 | // Revised : 9/30/2002 9 | // Version : 1.1 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : This include file is designed to contain items useful to all 14 | // code files and projects. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | #ifndef GLOBAL_H 22 | #define GLOBAL_H 23 | 24 | #include "uip.h" 25 | 26 | // global AVRLIB defines 27 | #include "avrlibdefs.h" 28 | // global AVRLIB types definitions 29 | #include "avrlibtypes.h" 30 | 31 | // project/system dependent defines 32 | #define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /plc-sw/drivers/enc28j60/network.c: -------------------------------------------------------------------------------- 1 | #include "global-conf.h" 2 | #include "enc28j60.h" 3 | #include 4 | #include 5 | 6 | unsigned int network_read(void){ 7 | return ((uint16_t) enc28j60PacketReceive(UIP_BUFSIZE, (uint8_t *)uip_buf)); 8 | } 9 | 10 | void network_send(void){ 11 | if(uip_len <= UIP_LLH_LEN + 40){ 12 | enc28j60PacketSend(uip_len, (uint8_t *)uip_buf, 0, 0); 13 | }else{ 14 | enc28j60PacketSend(54, (uint8_t *)uip_buf , uip_len - UIP_LLH_LEN - 40, (uint8_t*)uip_appdata); 15 | } 16 | } 17 | 18 | void network_init(void) 19 | { 20 | //Initialise the device 21 | enc28j60Init(); 22 | 23 | //Configure leds 24 | enc28j60PhyWrite(PHLCON,0x476); 25 | } 26 | 27 | void network_get_MAC(u08* macaddr) 28 | { 29 | // read MAC address registers 30 | // NOTE: MAC address in ENC28J60 is byte-backward 31 | *macaddr++ = enc28j60Read(MAADR5); 32 | *macaddr++ = enc28j60Read(MAADR4); 33 | *macaddr++ = enc28j60Read(MAADR3); 34 | *macaddr++ = enc28j60Read(MAADR2); 35 | *macaddr++ = enc28j60Read(MAADR1); 36 | *macaddr++ = enc28j60Read(MAADR0); 37 | } 38 | 39 | void network_set_MAC(u08* macaddr) 40 | { 41 | // write MAC address 42 | // NOTE: MAC address in ENC28J60 is byte-backward 43 | enc28j60Write(MAADR5, *macaddr++); 44 | enc28j60Write(MAADR4, *macaddr++); 45 | enc28j60Write(MAADR3, *macaddr++); 46 | enc28j60Write(MAADR2, *macaddr++); 47 | enc28j60Write(MAADR1, *macaddr++); 48 | enc28j60Write(MAADR0, *macaddr++); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /plc-sw/drivers/interfaces/README: -------------------------------------------------------------------------------- 1 | Should contain headerfiles that define interfaces to for instance a network controller. 2 | -------------------------------------------------------------------------------- /plc-sw/drivers/interfaces/network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple common network interface that all network drivers should implement. 3 | */ 4 | 5 | #ifndef __NETWORK_H__ 6 | #define __NETWORK_H__ 7 | 8 | /*Initialize the network*/ 9 | void network_init(void); 10 | 11 | /*Read from the network, returns number of read bytes*/ 12 | unsigned int network_read(void); 13 | 14 | /*Send using the network*/ 15 | void network_send(void); 16 | 17 | /*Sets the MAC address of the device*/ 18 | void network_set_MAC(uint8_t* mac); 19 | 20 | /*Gets the MAC address of the device*/ 21 | void network_get_MAC(uint8_t* mac); 22 | 23 | #endif /* __NETWORK_H__ */ 24 | -------------------------------------------------------------------------------- /plc-sw/libs/1wire/Makefile.1wire: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += crc8.c ds18x20.c onewire.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/1wire/crc8.c: -------------------------------------------------------------------------------- 1 | /* 2 | This code is from Colin O'Flynn - Copyright (c) 2002 3 | only minor changes by M.Thomas 9/2004 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | 24 | #include 25 | 26 | #define CRC8INIT 0x00 27 | #define CRC8POLY 0x18 //0X18 = X^8+X^5+X^4+X^0 28 | 29 | uint8_t crc8 ( uint8_t *data_in, uint16_t number_of_bytes_to_read ) 30 | { 31 | uint8_t crc; 32 | uint16_t loop_count; 33 | uint8_t bit_counter; 34 | uint8_t data; 35 | uint8_t feedback_bit; 36 | 37 | crc = CRC8INIT; 38 | 39 | for (loop_count = 0; loop_count != number_of_bytes_to_read; loop_count++) 40 | { 41 | data = data_in[loop_count]; 42 | 43 | bit_counter = 8; 44 | do { 45 | feedback_bit = (crc ^ data) & 0x01; 46 | 47 | if ( feedback_bit == 0x01 ) { 48 | crc = crc ^ CRC8POLY; 49 | } 50 | crc = (crc >> 1) & 0x7F; 51 | if ( feedback_bit == 0x01 ) { 52 | crc = crc | 0x80; 53 | } 54 | 55 | data = data >> 1; 56 | bit_counter--; 57 | 58 | } while (bit_counter > 0); 59 | } 60 | 61 | return crc; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /plc-sw/libs/1wire/crc8.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC8_H_ 2 | #define CRC8_H_ 3 | 4 | #include 5 | 6 | uint8_t crc8 (uint8_t* data_in, uint16_t number_of_bytes_to_read); 7 | 8 | #endif 9 | 10 | /* 11 | This is based on code from : 12 | 13 | Copyright (c) 2002 Colin O'Flynn 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 19 | the Software, and to permit persons to whom the Software is furnished to do so, 20 | subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 27 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 28 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 29 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | -------------------------------------------------------------------------------- /plc-sw/libs/1wire/onewire.h: -------------------------------------------------------------------------------- 1 | #ifndef _1wire_h_ 2 | #define _1wire_h_ 3 | 4 | #include 5 | 6 | /*******************************************/ 7 | /* Hardware connection */ 8 | /*******************************************/ 9 | 10 | /* Define OW_ONE_BUS if only one 1-Wire-Bus is used 11 | in the application -> shorter code. 12 | If not defined make sure to call ow_set_bus() before using 13 | a bus. Runtime bus-select increases code size by around 300 14 | bytes so use OW_ONE_BUS if possible */ 15 | //#define OW_ONE_BUS 16 | 17 | #ifdef OW_ONE_BUS 18 | 19 | #define OW_PIN PB0 20 | #define OW_IN PINB 21 | #define OW_OUT PORTB 22 | #define OW_DDR DDRB 23 | #define OW_CONF_DELAYOFFSET 0 24 | 25 | #else 26 | #if F_CPU<1843200 27 | #warning | experimental multi-bus-mode is not tested for 28 | #warning | frequencies below 1,84MHz - use OW_ONE_WIRE or 29 | #warning | faster clock-source (i.e. internal 2MHz R/C-Osc.) 30 | #endif 31 | #define OW_CONF_CYCLESPERACCESS 13 32 | #define OW_CONF_DELAYOFFSET ( (uint16_t)( ((OW_CONF_CYCLESPERACCESS)*1000000L) / F_CPU ) ) 33 | #endif 34 | 35 | /*******************************************/ 36 | 37 | // #define OW_SHORT_CIRCUIT 0x01 38 | 39 | #define OW_MATCH_ROM 0x55 40 | #define OW_SKIP_ROM 0xCC 41 | #define OW_SEARCH_ROM 0xF0 42 | 43 | #define OW_SEARCH_FIRST 0xFF // start new search 44 | #define OW_PRESENCE_ERR 0xFF 45 | #define OW_DATA_ERR 0xFE 46 | #define OW_LAST_DEVICE 0x00 // last device found 47 | // 0x01 ... 0x40: continue searching 48 | 49 | // rom-code size including CRC 50 | #define OW_ROMCODE_SIZE 8 51 | 52 | void OW_selectPort(unsigned char port) ; 53 | void find_sensor(uint8_t *diff, uint8_t id[]); 54 | 55 | 56 | extern uint8_t search_sensors(int maxSensors); 57 | 58 | extern uint8_t ow_reset(void); 59 | 60 | extern uint8_t ow_bit_io( uint8_t b ); 61 | extern uint8_t ow_byte_wr( uint8_t b ); 62 | extern uint8_t ow_byte_rd( void ); 63 | 64 | extern uint8_t ow_rom_search( uint8_t diff, uint8_t *id ); 65 | 66 | extern void ow_command( uint8_t command, uint8_t *id ); 67 | 68 | extern void ow_parasite_enable(void); 69 | extern void ow_parasite_disable(void); 70 | extern uint8_t ow_input_pin_state(void); 71 | 72 | #ifndef OW_ONE_BUS 73 | extern void ow_set_bus(volatile uint8_t* in, 74 | volatile uint8_t* out, 75 | volatile uint8_t* ddr, 76 | uint8_t pin); 77 | #endif 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /plc-sw/libs/analog/Makefile.analog: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += analog.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/analog/analog.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/libs/analog/analog.c -------------------------------------------------------------------------------- /plc-sw/libs/analog/analog.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/libs/analog/analog.h -------------------------------------------------------------------------------- /plc-sw/libs/avrlib-avrlib-conf/avrlibdefs.h: -------------------------------------------------------------------------------- 1 | /*! \file avrlibdefs.h \brief AVRlib global defines and macros. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'avrlibdefs.h' 5 | // Title : AVRlib global defines and macros include file 6 | // Author : Pascal Stang 7 | // Created : 7/12/2001 8 | // Revised : 9/30/2002 9 | // Version : 1.1 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : This include file is designed to contain items useful to all 14 | // code files and projects, regardless of specific implementation. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | 22 | #ifndef AVRLIBDEFS_H 23 | #define AVRLIBDEFS_H 24 | 25 | // Code compatibility to new AVR-libc 26 | // outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli() 27 | #ifndef outb 28 | #define outb(addr, data) addr = (data) 29 | #endif 30 | #ifndef inb 31 | #define inb(addr) (addr) 32 | #endif 33 | #ifndef outw 34 | #define outw(addr, data) addr = (data) 35 | #endif 36 | #ifndef inw 37 | #define inw(addr) (addr) 38 | #endif 39 | #ifndef BV 40 | #define BV(bit) (1<<(bit)) 41 | #endif 42 | #ifndef cbi 43 | #define cbi(reg,bit) reg &= ~(BV(bit)) 44 | #endif 45 | #ifndef sbi 46 | #define sbi(reg,bit) reg |= (BV(bit)) 47 | #endif 48 | #ifndef cli 49 | #define cli() __asm__ __volatile__ ("cli" ::) 50 | #endif 51 | #ifndef sei 52 | #define sei() __asm__ __volatile__ ("sei" ::) 53 | #endif 54 | 55 | // support for individual port pin naming in the mega128 56 | // see port128.h for details 57 | #ifdef __AVR_ATmega128__ 58 | // not currently necessary due to inclusion 59 | // of these defines in newest AVR-GCC 60 | // do a quick test to see if include is needed 61 | #ifndef PD0 62 | #include "port128.h" 63 | #endif 64 | #endif 65 | 66 | // use this for packed structures 67 | // (this is seldom necessary on an 8-bit architecture like AVR, 68 | // but can assist in code portability to AVR) 69 | #define GNUC_PACKED __attribute__((packed)) 70 | 71 | // port address helpers 72 | #define DDR(x) ((x)-1) // address of data direction register of port x 73 | #define PIN(x) ((x)-2) // address of input register of port x 74 | 75 | // MIN/MAX/ABS macros 76 | #define MIN(a,b) ((ab)?(a):(b)) 78 | #define ABS(x) ((x>0)?(x):(-x)) 79 | 80 | // constants 81 | #define PI 3.14159265359 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /plc-sw/libs/avrlib-avrlib-conf/avrlibtypes.h: -------------------------------------------------------------------------------- 1 | /*! \file avrlibtypes.h \brief AVRlib global types and typedefines. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'avrlibtypes.h' 5 | // Title : AVRlib global types and typedefines include file 6 | // Author : Pascal Stang 7 | // Created : 7/12/2001 8 | // Revised : 9/30/2002 9 | // Version : 1.0 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : Type-defines required and used by AVRlib. Most types are also 14 | // generally useful. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | 22 | #ifndef AVRLIBTYPES_H 23 | #define AVRLIBTYPES_H 24 | 25 | #ifndef WIN32 26 | // true/false defines 27 | #define FALSE 0 28 | #define TRUE -1 29 | #endif 30 | 31 | // datatype definitions macros 32 | typedef unsigned char u08; 33 | typedef signed char s08; 34 | typedef unsigned short u16; 35 | typedef signed short s16; 36 | typedef unsigned long u32; 37 | typedef signed long s32; 38 | typedef unsigned long long u64; 39 | typedef signed long long s64; 40 | 41 | /* use inttypes.h instead 42 | // C99 standard integer type definitions 43 | typedef unsigned char uint8_t; 44 | typedef signed char int8_t; 45 | typedef unsigned short uint16_t; 46 | typedef signed short int16_t; 47 | typedef unsigned long uint32_t; 48 | typedef signed long int32_t; 49 | typedef unsigned long uint64_t; 50 | typedef signed long int64_t; 51 | */ 52 | // maximum value that can be held 53 | // by unsigned data types (8,16,32bits) 54 | #define MAX_U08 255 55 | #define MAX_U16 65535 56 | #define MAX_U32 4294967295 57 | 58 | // maximum values that can be held 59 | // by signed data types (8,16,32bits) 60 | #define MIN_S08 -128 61 | #define MAX_S08 127 62 | #define MIN_S16 -32768 63 | #define MAX_S16 32767 64 | #define MIN_S32 -2147483648 65 | #define MAX_S32 2147483647 66 | 67 | #ifndef WIN32 68 | // more type redefinitions 69 | typedef unsigned char BOOL; 70 | typedef unsigned char BYTE; 71 | typedef unsigned int WORD; 72 | typedef unsigned long DWORD; 73 | 74 | typedef unsigned char UCHAR; 75 | typedef unsigned int UINT; 76 | typedef unsigned short USHORT; 77 | typedef unsigned long ULONG; 78 | 79 | typedef char CHAR; 80 | typedef int INT; 81 | typedef long LONG; 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /plc-sw/libs/avrlib-avrlib-conf/global.h: -------------------------------------------------------------------------------- 1 | /*! \file global.h \brief AVRlib project global include. */ 2 | //***************************************************************************** 3 | // 4 | // File Name : 'global.h' 5 | // Title : AVRlib project global include 6 | // Author : Pascal Stang - Copyright (C) 2001-2002 7 | // Created : 7/12/2001 8 | // Revised : 9/30/2002 9 | // Version : 1.1 10 | // Target MCU : Atmel AVR series 11 | // Editor Tabs : 4 12 | // 13 | // Description : This include file is designed to contain items useful to all 14 | // code files and projects. 15 | // 16 | // This code is distributed under the GNU Public License 17 | // which can be found at http://www.gnu.org/licenses/gpl.txt 18 | // 19 | //***************************************************************************** 20 | 21 | #ifndef GLOBAL_H 22 | #define GLOBAL_H 23 | 24 | #include "uip.h" 25 | 26 | // global AVRLIB defines 27 | #include "avrlibdefs.h" 28 | // global AVRLIB types definitions 29 | #include "avrlibtypes.h" 30 | 31 | 32 | #ifndef F_CPU 33 | #error "F_CPU MUST BE DEFINED" 34 | #endif 35 | 36 | // project/system dependent defines 37 | #define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /plc-sw/libs/ds1302/Makefile.ds1302: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += ds1302.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/eeprom/Makefile.eeprom: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += eeprom.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/eeprom/eeprom.c: -------------------------------------------------------------------------------- 1 | #include "eeprom.h" 2 | #include 3 | 4 | // eepromSaveByte(10, 127); 5 | // uint8_t res = eepromReadByte(10); 6 | // Se eeprom.h for hvilke pos der er til hvad 7 | 8 | void eepromSaveByte(uint16_t pos, uint8_t value) 9 | { 10 | if (eepromReadByte(pos) != value) 11 | { 12 | eeprom_write_byte((uint8_t*)pos, value); 13 | } 14 | } 15 | 16 | void eepromSaveWord(uint16_t pos, uint16_t value) 17 | { 18 | if (eepromReadWord(pos) != value) 19 | { 20 | eeprom_write_word((uint16_t*)pos, value); 21 | } 22 | } 23 | 24 | int8_t eepromReadByteSigned(uint16_t pos) 25 | { 26 | return eeprom_read_byte((uint8_t*)pos); 27 | } 28 | 29 | uint8_t eepromReadByte(uint16_t pos) 30 | { 31 | return eeprom_read_byte((uint8_t*)pos); 32 | } 33 | 34 | uint16_t eepromReadWord(uint16_t pos) 35 | { 36 | return eeprom_read_word((uint16_t*)pos); 37 | } 38 | 39 | void eepromSaveStr(uint16_t pos, char* target, uint8_t limit) 40 | { 41 | for (uint8_t i=0; i 2 | #include 3 | 4 | /* 5 | ATMEGA32 has 1024bytes om eeprom. 6 | 7 | 0-100 Reserved for system use 8 | 1 55 if eeprom contains settings, FF if new eeprom, anything else if foeing/corrupted eeprom 9 | 10 | see settings.htm for usage 11 | */ 12 | #ifndef sbeeprom 13 | #define sbeeprom 14 | 15 | extern void eepromSaveByte(uint16_t pos, uint8_t value); 16 | extern void eepromSaveWord(uint16_t pos, uint16_t value); 17 | extern uint8_t eepromReadByte(uint16_t pos); 18 | extern int8_t eepromReadByteSigned(uint16_t pos); 19 | extern uint16_t eepromReadWord(uint16_t pos); 20 | extern void eepromSaveStr(uint16_t pos, char* target, uint8_t limit); 21 | extern void eepromReadStr(uint16_t pos, char* target, uint8_t limit); 22 | 23 | #define eepromWriteByte eepromSaveByte 24 | #define eepromWriteWord eepromSaveWord 25 | #define eepromWriteStr eepromSaveStr 26 | #endif 27 | -------------------------------------------------------------------------------- /plc-sw/libs/lcd/.dep/2wLCD.o.d: -------------------------------------------------------------------------------- 1 | 2wLCD.o: 2wLCD.c \ 2 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/inttypes.h \ 3 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/stdint.h \ 4 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/io.h \ 5 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/sfr_defs.h \ 6 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/iom8.h \ 7 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/portpins.h \ 8 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/interrupt.h \ 9 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/signal.h \ 10 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/delay.h 11 | 12 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/inttypes.h: 13 | 14 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/stdint.h: 15 | 16 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/io.h: 17 | 18 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/sfr_defs.h: 19 | 20 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/iom8.h: 21 | 22 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/portpins.h: 23 | 24 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/interrupt.h: 25 | 26 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/signal.h: 27 | 28 | C:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/delay.h: 29 | -------------------------------------------------------------------------------- /plc-sw/libs/lcd/Makefile.lcd: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += SPILCD.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/lcd/SPILCD.h: -------------------------------------------------------------------------------- 1 | #ifndef __spilcd_H 2 | #define __spilcd_H 3 | void LCD_pulse_enable(void); 4 | void SPILCD_init(void); 5 | void LCD_sendData(uint8_t byte); 6 | void LCD_sendCommand(uint8_t command); 7 | void LCD_shiftout(uint8_t data); 8 | #endif -------------------------------------------------------------------------------- /plc-sw/libs/memb/Makefile.memb: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += memb.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/misc/AVR035.h: -------------------------------------------------------------------------------- 1 | #define SETBIT(ADDRESS,BIT) (ADDRESS |= (1< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | volatile unsigned int buffercounter = 0; 13 | 14 | char usart_rx_buffer[50]; 15 | char *rx_buffer_pointer_in = &usart_rx_buffer[0]; 16 | char *rx_buffer_pointer_out = &usart_rx_buffer[0]; 17 | 18 | //http://www.nongnu.org/avr-libc/user-manual/group__util__setbaud.html 19 | //Maybe use setbaud instead 20 | 21 | void usart_init(unsigned long baudrate0, unsigned long baudrate1) 22 | { 23 | UCSR0B =(1 << TXEN0 | 1 << RXEN0 | 1<< RXCIE0); 24 | UBRR0=(F_CPU / (baudrate0 * 16L) - 1); 25 | 26 | UCSR1B =(1 << TXEN0 | 1 << RXEN0 | 1<< RXCIE0); 27 | UBRR1=(F_CPU / (baudrate1 * 16L) - 1); 28 | } 29 | 30 | int uart_putchar0(char c, FILE *stream) 31 | { 32 | while(!(UCSR0A & (1< 26 | #define _UART_H 27 | 28 | #define USART_ECHO 1 29 | #ifndef SYSCLK 30 | #define SYSCLK F_CPU 31 | #endif //SYSCLK 32 | 33 | int uart_putchar0(char c, FILE *stream); 34 | int uart_putchar1(char c, FILE *stream); 35 | void usart_init(unsigned long baudrate0, unsigned long baudrate1); 36 | #endif //_UART_H 37 | -------------------------------------------------------------------------------- /plc-sw/libs/usart/ATxmega_Baud_Rate_Calculator_v1.0.xls.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/libs/usart/ATxmega_Baud_Rate_Calculator_v1.0.xls.zip -------------------------------------------------------------------------------- /plc-sw/libs/usart/Makefile.usart: -------------------------------------------------------------------------------- 1 | LIB_SOURCES += usart.c 2 | -------------------------------------------------------------------------------- /plc-sw/libs/usart/README: -------------------------------------------------------------------------------- 1 | 2 | THANK YOU!!! 3 | 4 | Okay so this code was downloaded from: 5 | http://www.cl.cam.ac.uk/teaching/1011/P31/lib/ 6 | On April 16, 2011 7 | 8 | I also found almost the same code on avrfreaks, http://tom-itx.dyndns.org:81/~webpage/how_to/atmega168/mega168_rs232_index.php, and a few other pages. 9 | 10 | So, who was / is the author... ? Don't know, it's example code published all over the net. 11 | 12 | To use this you need to init the console speed. 13 | 14 | Have a look here for how to do this: 15 | http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=70673 16 | Note this: 17 | http://www.chip45.com/download/ATxmega_Baud_Rate_Calculator_v1.0.xls.zip 18 | 19 | This xls is included here 20 | 21 | 22 | Oh, use software flow control 23 | -------------------------------------------------------------------------------- /plc-sw/libs/usart/usart.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "usart.h" 4 | 5 | #ifdef UBRR0 6 | #if defined(UBRR1) && defined(ENABLE_UBRR1) 7 | #include "usart2.c" 8 | #else 9 | #if defined(UBRR1) 10 | #warning "Chip has two USART interfaces. Only one enabled" 11 | #endif 12 | // we have two but, only use the first one 13 | #include "usart1.c" 14 | #endif 15 | #else // only the single uart 16 | #include "one_usart.c" 17 | #endif 18 | -------------------------------------------------------------------------------- /plc-sw/libs/usart/usart.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __USART_H__ 4 | #define __USART_H__ 5 | 6 | #include 7 | 8 | #include "global-conf.h" 9 | 10 | #ifdef UBRR0 11 | #if defined(UBRR1) && defined(ENABLE_UBRR1) 12 | #include "usart2.h" 13 | #else 14 | #if defined(UBRR1) 15 | #warning "Chip has two USART interfaces. Only one enabled" 16 | #endif 17 | // we have two but, only use the first one 18 | #include "usart1.h" 19 | #endif 20 | #else // only the single uart 21 | #include "one_usart.h" 22 | #endif 23 | 24 | #ifdef USART_EXTRA_SEND_FORMATS 25 | #warning "Turning on will cost you an extra 1150 bytes!!!" 26 | #warning " If you use the basic functions it's only about 90 bytes!!!" 27 | #endif 28 | 29 | #endif // end - #ifndef __USART_H__ 30 | -------------------------------------------------------------------------------- /plc-sw/libs/websrv_helper_functions/websrv_helper_functions.c: -------------------------------------------------------------------------------- 1 | /********************************************* 2 | * vim:sw=8:ts=8:si:et 3 | * To use the above modeline in vim you must have "set modeline" in your .vimrc 4 | * Author: Guido Socher 5 | * Copyright: GPL V2 6 | * 7 | * Some common utilities needed for IP and web applications 8 | *********************************************/ 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | // search for a string of the form key=value in 16 | // a string that looks like q?xyz=abc&uvw=defgh HTTP/1.1\r\n 17 | // 18 | // The returned value is stored in strbuf. You must allocate 19 | // enough storage for strbuf, maxlen is the size of strbuf. 20 | // I.e the value it is declated with: strbuf[5]-> maxlen=5 21 | uint8_t find_key_val(char *str,char *strbuf, uint8_t maxlen,char *key) 22 | { 23 | uint8_t found=0; 24 | uint8_t i=0; 25 | char *kp; 26 | kp=key; 27 | while(*str && *str!=' ' && *str!='\n' && found==0){ 28 | if (*str == *kp){ 29 | kp++; 30 | if (*kp == '\0'){ 31 | str++; 32 | kp=key; 33 | if (*str == '='){ 34 | found=1; 35 | } 36 | } 37 | }else{ 38 | kp=key; 39 | } 40 | str++; 41 | } 42 | if (found==1){ 43 | // copy the value to a buffer and terminate it with '\0' 44 | while(*str && *str!=' ' && *str!='\n' && *str!='&' && i 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "clock-arch.h" 10 | 11 | //Counted time 12 | clock_time_t clock_datetime = 0; 13 | 14 | //Overflow interrupt 15 | ISR(TIMER1_OVF_vect) 16 | { 17 | clock_datetime += 1; 18 | } 19 | 20 | //Initialise the clock 21 | void clock_init() 22 | { 23 | cli(); 24 | 25 | TCCR1B = 0; // disable ticking 26 | TCNT1H = 0; // reset counter 27 | TCNT1L = 0; 28 | ICR1H = 40000U >> 8; // set overflow value 29 | ICR1L = 40000U & 0xff; 30 | TCCR1A = 0x02; // 11 11 00 10, set channel config 31 | 32 | //Activate overflow interrupt for timer1 33 | TIMSK1 = (1< 5 | 6 | typedef uint16_t clock_time_t; 7 | #define CLOCK_CONF_SECOND (clock_time_t)76 8 | //(F_CPU / (1024*255)), this cannot be used as it gives overflows 9 | //Freqency divided prescaler and counter register size 10 | 11 | #include "clock.h" 12 | 13 | #endif /* __CLOCK_ARCH_H__ */ 14 | -------------------------------------------------------------------------------- /plc-sw/projects/HILSim/global-conf.h: -------------------------------------------------------------------------------- 1 | //Project specific configurations 2 | #ifndef __GLOBAL_CONF_H__ 3 | #define __GLOBAL_CONF_H__ 4 | 5 | #define led_conf() DDRD |= 0xfc 6 | #define led_on(X) PORTD |= 1 << (X + 2) 7 | #define led_off(X) PORTD &= ~(1 << (X + 2)) 8 | 9 | //Define frequency 10 | #define F_CPU 20000000UL 11 | 12 | //Mac adress definition for enc28j60 13 | #define ETHADDR0 0x00 14 | #define ETHADDR1 0xbd 15 | #define ETHADDR2 0x3b 16 | #define ETHADDR3 0x33 17 | #define ETHADDR4 0x05 18 | #define ETHADDR5 0x71 19 | 20 | //Mac adress definition for uip 21 | #define UIP_ETHADDR0 ETHADDR0 22 | #define UIP_ETHADDR1 ETHADDR1 23 | #define UIP_ETHADDR2 ETHADDR2 24 | #define UIP_ETHADDR3 ETHADDR3 25 | #define UIP_ETHADDR4 ETHADDR4 26 | #define UIP_ETHADDR5 ETHADDR5 27 | 28 | #define USE_DHCP 1 29 | 30 | #define UIP_IPADDR0 192 31 | #define UIP_IPADDR1 168 32 | #define UIP_IPADDR2 1 33 | #define UIP_IPADDR3 77 34 | 35 | #define UIP_NETMASK0 255 36 | #define UIP_NETMASK1 255 37 | #define UIP_NETMASK2 255 38 | #define UIP_NETMASK3 0 39 | 40 | #define UIP_DRIPADDR0 192 41 | #define UIP_DRIPADDR1 168 42 | #define UIP_DRIPADDR2 1 43 | #define UIP_DRIPADDR3 1 44 | 45 | // ENC28J60 SPI port 46 | #define ENC28J60_SPI_PORT PORTB 47 | #define ENC28J60_SPI_DDR DDRB 48 | #define ENC28J60_SPI_SCK PORTB7 49 | #define ENC28J60_SPI_MISO PORTB6 50 | #define ENC28J60_SPI_MOSI PORTB5 51 | #define ENC28J60_SPI_SS PORTB4 52 | 53 | // ENC28J60 control port 54 | #define ENC28J60_CONTROL_CS PORTB4 55 | #define ENC28J60_CONTROL_PORT PORTB 56 | #define ENC28J60_CONTROL_DDR DDRB 57 | 58 | //Include uip.h gives all the uip configurations in uip-conf.h 59 | #include "uip.h" 60 | 61 | #endif /*__GLOBAL_CONF_H__*/ 62 | -------------------------------------------------------------------------------- /plc-sw/projects/HILSim/phys.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Programmer: Nicholas Wertzberger 3 | * Email: wertnick@gmail.com 4 | * 5 | * This class is responsible for setting and getting values for the physical IO. 6 | * 7 | * 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "phys.h" 15 | 16 | void phys_init() 17 | { 18 | DDRA = 0x00; 19 | DDRC = 0xff; 20 | } 21 | 22 | void phys_in(int * data) 23 | { 24 | for (uint8_t i = 0; i < 8; i++) 25 | { 26 | data[i] = (PINA & (1 << i) ? 1 : 0); 27 | } 28 | } 29 | 30 | void phys_out(int * data) 31 | { 32 | PORTC = 0; 33 | for (uint8_t i = 0; i < 8; i++) 34 | { 35 | PORTC |= (data[i] ? 1 : 0) << i; 36 | } 37 | PORTD = PORTC; 38 | } 39 | -------------------------------------------------------------------------------- /plc-sw/projects/HILSim/phys.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Programmer: Nicholas Wertzberger 3 | * Email: wertnick@gmail.com 4 | * 5 | * This class is responsible for setting and getting values for the physical IO. 6 | * 7 | * 8 | * 9 | */ 10 | #ifndef PHYS_H 11 | #define PHYS_H 12 | 13 | #define JSONCMD_CONF_GETCALLBACK phys_in 14 | #define JSONCMD_CONF_SETCALLBACK phys_out 15 | 16 | void phys_init(void); 17 | void phys_in(int * data); 18 | void phys_out(int * data); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /plc-sw/projects/HILSim/uip-conf.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIP_CONF_H__ 2 | #define __UIP_CONF_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /** 10 | * 8 bit datatype 11 | * 12 | * This typedef defines the 8-bit type used throughout uIP. 13 | * 14 | * \hideinitializer 15 | */ 16 | typedef uint8_t u8_t; 17 | 18 | /** 19 | * 16 bit datatype 20 | * 21 | * This typedef defines the 16-bit type used throughout uIP. 22 | * 23 | * \hideinitializer 24 | */ 25 | typedef uint16_t u16_t; 26 | 27 | /** 28 | * Statistics datatype 29 | * 30 | * This typedef defines the dataype used for keeping statistics in 31 | * uIP. 32 | * 33 | * \hideinitializer 34 | */ 35 | typedef unsigned short uip_stats_t; 36 | 37 | #define UIP_REASSEMBLY 1 38 | 39 | /** 40 | * Maximum number of TCP connections. 41 | * 42 | * \hideinitializer 43 | */ 44 | #define UIP_CONF_MAX_CONNECTIONS 10 45 | 46 | /** 47 | * Maximum number of listening TCP ports. 48 | * 49 | * \hideinitializer 50 | */ 51 | #define UIP_CONF_MAX_LISTENPORTS 10 52 | 53 | /** 54 | * uIP buffer size. 55 | * 56 | * \hideinitializer 57 | */ 58 | #define UIP_CONF_BUFFER_SIZE 1024 59 | /** 60 | * CPU byte order. 61 | * 62 | * \hideinitializer 63 | */ 64 | #define UIP_CONF_BYTE_ORDER BIG_ENDIAN 65 | 66 | /** 67 | * Logging on or off 68 | * 69 | * \hideinitializer 70 | */ 71 | #define UIP_CONF_LOGGING 0 72 | 73 | /** 74 | * UDP support on or off requires DHCP if ON 75 | * 76 | * \hideinitializer 77 | */ 78 | #define UIP_CONF_UDP 1 79 | 80 | /** 81 | * UDP checksums on or off 82 | * 83 | * \hideinitializer 84 | */ 85 | #define UIP_CONF_UDP_CHECKSUMS 0 86 | 87 | /** 88 | * uIP statistics on or off 89 | * 90 | * \hideinitializer 91 | */ 92 | #define UIP_CONF_STATISTICS 0 93 | 94 | /** 95 | * Broadcast support. Needed for dhcp 96 | * 97 | * \hideinitializer 98 | */ 99 | #define UIP_CONF_BROADCAST 1 100 | 101 | /** 102 | * The maximum amount of concurrent UDP connections. 103 | * 104 | * \hideinitializer 105 | */ 106 | #define UIP_CONF_UDP_CONNS 10 107 | 108 | //Include app configuration 109 | #include "apps-conf.h" 110 | 111 | #endif /* __UIP_CONF_H__ */ 112 | 113 | /** @} */ 114 | /** @} */ 115 | -------------------------------------------------------------------------------- /plc-sw/projects/OpenPLC/Makefile: -------------------------------------------------------------------------------- 1 | #### larger chip needed for webserver.PROGMEM 2 | MCU = atmega1284p 3 | CHIP = m1284p 4 | 5 | #Project name 6 | NAME = openplc 7 | 8 | #Compiled apps 9 | APPS = telnetd dhcpc 10 | 11 | #Compiled drivers 12 | DEVS = enc28j60 #The rest are determined by makefiles for apps 13 | 14 | #Compiled libs 15 | #LIBS = #Determined by makefiles for apps or drivers 16 | 17 | #Project specific files 18 | $(NAME)_SOURCES = main.c clock-arch.c 19 | 20 | #Low fuse 21 | LFUSE = 0x60 22 | 23 | #High fuse 24 | HFUSE = 0xDF 25 | 26 | #Include global configurations 27 | -include ../../MakeConf.include 28 | 29 | #Include the genetic makefile 30 | -include ../../Makefile.include 31 | -------------------------------------------------------------------------------- /plc-sw/projects/OpenPLC/apps-conf.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPS_CONF_H__ 2 | #define __APPS_CONF_H__ 3 | 4 | 5 | //#define PORT_APP_MAPPER 1 6 | 7 | //Here we include the header file for the application(s) we use in our project. 8 | 9 | //#include "smtp.h" 10 | //#include "hello-world.h" 11 | //#include "simple-httpd.h" 12 | #include "telnetd.h" 13 | 14 | ///////////////////////// 15 | // webserver options 16 | // - uncomment to turn on POST support in the web server 17 | //#define HTTP_POST_SUPPORT 18 | // - uncomment to turn on param support for http GET requests in the web server 19 | #define HTTP_GET_PARAM_SUPPORT 20 | // - the max amount of data which may be posted or param in get (bytes) 21 | #define MAX_PARAM_DATA 100 22 | //#define HTTPD_MAX_CONNECTIONS 3 23 | //#include "webserver.h" 24 | ///////////////////////// 25 | 26 | //#define DHCP_DEBUG 1 27 | #include "dhcpc.h" 28 | 29 | //#include "resolv.h" 30 | //#include "webclient.h" 31 | 32 | #if defined PORT_APP_MAPPER 33 | #include "port_app_mapper.h" 34 | #endif 35 | #endif /*__APPS_CONF_H__*/ 36 | -------------------------------------------------------------------------------- /plc-sw/projects/OpenPLC/clock-arch.c: -------------------------------------------------------------------------------- 1 | #include "global-conf.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "clock-arch.h" 10 | 11 | //Counted time 12 | clock_time_t clock_datetime = 0; 13 | 14 | //Overflow interrupt 15 | ISR(TIMER1_OVF_vect) 16 | { 17 | clock_datetime += 1; 18 | } 19 | 20 | //Initialise the clock 21 | void clock_init() 22 | { 23 | cli(); 24 | 25 | TCCR1B = 0; // disable ticking 26 | TCNT1H = 0; // reset counter 27 | TCNT1L = 0; 28 | ICR1H = 40000U >> 8; // set overflow value 29 | ICR1L = 40000U & 0xff; 30 | TCCR1A = 0x02; // 11 11 00 10, set channel config 31 | 32 | //Activate overflow interrupt for timer1 33 | TIMSK1 = (1< 5 | 6 | typedef uint16_t clock_time_t; 7 | #define CLOCK_CONF_SECOND (clock_time_t)76 8 | //(F_CPU / (1024*255)), this cannot be used as it gives overflows 9 | //Freqency divided prescaler and counter register size 10 | 11 | #include "clock.h" 12 | 13 | #endif /* __CLOCK_ARCH_H__ */ 14 | -------------------------------------------------------------------------------- /plc-sw/projects/OpenPLC/global-conf.h: -------------------------------------------------------------------------------- 1 | //Project specific configurations 2 | #ifndef __GLOBAL_CONF_H__ 3 | #define __GLOBAL_CONF_H__ 4 | 5 | #define led_conf() DDRD |= 0xfc 6 | #define led_on(X) PORTD |= 1 << (X + 2) 7 | #define led_off(X) PORTD &= ~(1 << (X + 2)) 8 | 9 | //Define frequency 10 | #define F_CPU 20000000UL 11 | 12 | //Mac adress definition for enc28j60 13 | #define ETHADDR0 0x00 14 | #define ETHADDR1 0xbd 15 | #define ETHADDR2 0x3b 16 | #define ETHADDR3 0x33 17 | #define ETHADDR4 0x05 18 | #define ETHADDR5 0x71 19 | 20 | //Mac adress definition for uip 21 | #define UIP_ETHADDR0 ETHADDR0 22 | #define UIP_ETHADDR1 ETHADDR1 23 | #define UIP_ETHADDR2 ETHADDR2 24 | #define UIP_ETHADDR3 ETHADDR3 25 | #define UIP_ETHADDR4 ETHADDR4 26 | #define UIP_ETHADDR5 ETHADDR5 27 | 28 | #define USE_DHCP 1 29 | 30 | #define UIP_IPADDR0 192 31 | #define UIP_IPADDR1 168 32 | #define UIP_IPADDR2 1 33 | #define UIP_IPADDR3 77 34 | 35 | #define UIP_NETMASK0 255 36 | #define UIP_NETMASK1 255 37 | #define UIP_NETMASK2 255 38 | #define UIP_NETMASK3 0 39 | 40 | #define UIP_DRIPADDR0 192 41 | #define UIP_DRIPADDR1 168 42 | #define UIP_DRIPADDR2 1 43 | #define UIP_DRIPADDR3 1 44 | 45 | // ENC28J60 SPI port 46 | #define ENC28J60_SPI_PORT PORTB 47 | #define ENC28J60_SPI_DDR DDRB 48 | #define ENC28J60_SPI_SCK PORTB7 49 | #define ENC28J60_SPI_MISO PORTB6 50 | #define ENC28J60_SPI_MOSI PORTB5 51 | #define ENC28J60_SPI_SS PORTB4 52 | 53 | // ENC28J60 control port 54 | #define ENC28J60_CONTROL_CS PORTB4 55 | #define ENC28J60_CONTROL_PORT PORTB 56 | #define ENC28J60_CONTROL_DDR DDRB 57 | 58 | //Include uip.h gives all the uip configurations in uip-conf.h 59 | #include "uip.h" 60 | 61 | #endif /*__GLOBAL_CONF_H__*/ 62 | -------------------------------------------------------------------------------- /plc-sw/projects/OpenPLC/uip-conf.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIP_CONF_H__ 2 | #define __UIP_CONF_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /** 10 | * 8 bit datatype 11 | * 12 | * This typedef defines the 8-bit type used throughout uIP. 13 | * 14 | * \hideinitializer 15 | */ 16 | typedef uint8_t u8_t; 17 | 18 | /** 19 | * 16 bit datatype 20 | * 21 | * This typedef defines the 16-bit type used throughout uIP. 22 | * 23 | * \hideinitializer 24 | */ 25 | typedef uint16_t u16_t; 26 | 27 | /** 28 | * Statistics datatype 29 | * 30 | * This typedef defines the dataype used for keeping statistics in 31 | * uIP. 32 | * 33 | * \hideinitializer 34 | */ 35 | typedef unsigned short uip_stats_t; 36 | 37 | #define UIP_REASSEMBLY 1 38 | 39 | /** 40 | * Maximum number of TCP connections. 41 | * 42 | * \hideinitializer 43 | */ 44 | #define UIP_CONF_MAX_CONNECTIONS 10 45 | 46 | /** 47 | * Maximum number of listening TCP ports. 48 | * 49 | * \hideinitializer 50 | */ 51 | #define UIP_CONF_MAX_LISTENPORTS 10 52 | 53 | /** 54 | * uIP buffer size. 55 | * 56 | * \hideinitializer 57 | */ 58 | #define UIP_CONF_BUFFER_SIZE 1024 59 | /** 60 | * CPU byte order. 61 | * 62 | * \hideinitializer 63 | */ 64 | #define UIP_CONF_BYTE_ORDER BIG_ENDIAN 65 | 66 | /** 67 | * Logging on or off 68 | * 69 | * \hideinitializer 70 | */ 71 | #define UIP_CONF_LOGGING 0 72 | 73 | /** 74 | * UDP support on or off requires DHCP if ON 75 | * 76 | * \hideinitializer 77 | */ 78 | #define UIP_CONF_UDP 1 79 | 80 | /** 81 | * UDP checksums on or off 82 | * 83 | * \hideinitializer 84 | */ 85 | #define UIP_CONF_UDP_CHECKSUMS 0 86 | 87 | /** 88 | * uIP statistics on or off 89 | * 90 | * \hideinitializer 91 | */ 92 | #define UIP_CONF_STATISTICS 0 93 | 94 | /** 95 | * Broadcast support. Needed for dhcp 96 | * 97 | * \hideinitializer 98 | */ 99 | #define UIP_CONF_BROADCAST 1 100 | 101 | /** 102 | * The maximum amount of concurrent UDP connections. 103 | * 104 | * \hideinitializer 105 | */ 106 | #define UIP_CONF_UDP_CONNS 10 107 | 108 | //Include app configuration 109 | #include "apps-conf.h" 110 | 111 | #endif /* __UIP_CONF_H__ */ 112 | 113 | /** @} */ 114 | /** @} */ 115 | -------------------------------------------------------------------------------- /plc-sw/projects/Tests/Makefile: -------------------------------------------------------------------------------- 1 | # Programmer: Nicholas Wertzberger 2 | # Email: wertnick@gmail.com 3 | 4 | CC=avr-gcc 5 | AR=avr-ar 6 | PLATFORM=atmega1284p 7 | TARGET=qtest 8 | 9 | CFLAGS= -Wall -mmcu=$(PLATFORM) $(FFLAGS) 10 | LFLAGS= -Wall -mmcu=$(PLATFORM) $(FFLAGS) 11 | FFLAGS= -O0 12 | 13 | $(TARGET).hex: $(TARGET).elf 14 | avr-objcopy -O ihex $< $@ 15 | $(TARGET).elf: quicktest.c 16 | $(CC) $(CFLAGS) -o $@ $^ 17 | 18 | deploy: $(TARGET).hex 19 | sudo avrdude -c avrisp2 -p m1284p -P usb -b19200 -B 2 -U flash:w:$< -F 20 | 21 | shell: 22 | sudo avrdude -c avrisp2 -p m1284p -P usb -t 23 | -------------------------------------------------------------------------------- /plc-sw/projects/Tests/qtest.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nwertzberger/OpenPLC/5b50a9c40bc223778d7125f4f493f1cca250e88a/plc-sw/projects/Tests/qtest.elf -------------------------------------------------------------------------------- /plc-sw/projects/Tests/qtest.hex: -------------------------------------------------------------------------------- 1 | :100000000C9446000C945D000C945D000C945D0013 2 | :100010000C945D000C945D000C945D000C945D00EC 3 | :100020000C945D000C945D000C945D000C945D00DC 4 | :100030000C945D000C945D000C945D000C945D00CC 5 | :100040000C945D000C945D000C945D000C945D00BC 6 | :100050000C945D000C945D000C945D000C945D00AC 7 | :100060000C945D000C945D000C945D000C945D009C 8 | :100070000C945D000C945D000C945D000C945D008C 9 | :100080000C945D000C945D000C945D0011241FBE67 10 | :10009000CFEFD0E4DEBFCDBF11E0A0E0B1E0EEE2F3 11 | :1000A000F2E000E00BBF02C007900D92A030B10754 12 | :1000B000D9F70E94B8000C9415010C940000DF934E 13 | :1000C000CF9300D0CDB7DEB789836A83A5E2B0E0D5 14 | :1000D000E5E2F0E080818F7E8C93EEE4F0E08981B0 15 | :1000E00080648083EDE4F0E080818823DCF7EEE437 16 | :1000F000F0E08A818083EDE4F0E080818823DCF702 17 | :10010000A5E2B0E0E5E2F0E0808180618C930F90A1 18 | :100110000F90CF91DF910895DF93CF930F92CDB7DA 19 | :10012000DEB78983A5E2B0E0E5E2F0E080818F7E72 20 | :100130008C93EEE4F0E089818083EDE4F0E080814F 21 | :100140008823DCF7EEE4F0E01082EDE4F0E080815B 22 | :100150008823DCF7A5E2B0E0E5E2F0E08081806191 23 | :100160008C93EEE4F0E080810F90CF91DF910895C1 24 | :10017000DF93CF9300D000D0CDB7DEB79A838983C9 25 | :100180007C836B83EAE2F0E08CEF8083ABE2B0E04B 26 | :10019000EBE2F0E0808184608C93E4E2F0E080EBBD 27 | :1001A0008083A5E2B0E0E5E2F0E0808180618C939D 28 | :1001B000ECE4F0E080E580838DE10E948C00882FE4 29 | :1001C00090E0817090700097B9F3ABE2B0E0EBE2A1 30 | :1001D000F0E0808188608C9380E00E948C008A3FF0 31 | :1001E00041F4ABE2B0E0EBE2F0E0808180618C931F 32 | :1001F00007C0ABE2B0E0EBE2F0E080818F7E8C9351 33 | :1002000080E00E948C008A3F41F4ABE2B0E0EBE278 34 | :10021000F0E0808180628C93F3CFABE2B0E0EBE260 35 | :0E022000F0E080818F7D8C93EBCFF894FFCFC0 36 | :00000001FF 37 | -------------------------------------------------------------------------------- /plc-sw/projects/Tests/quicktest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define led_on(X) PORTD |= 1 << (X + 2) 4 | #define led_off(X) PORTD &= ~(1 << (X + 2)) 5 | 6 | #define WCR 0x40 7 | #define RCR 0x00 8 | 9 | typedef enum { 10 | ERDPTL = 0x00, 11 | ERDPTH, 12 | EWRPTL, 13 | EWRPTH, 14 | ETXSTL, 15 | ETXSTH, 16 | ETXNDL, 17 | ETXNDH, 18 | ERXSTL, 19 | ERXSTH, 20 | ERXNDL, 21 | ERXNDH, 22 | ERXRDPTL, 23 | ERXRDPTH, 24 | ERXWRPTL, 25 | ERXWRPTH, 26 | EDMASTL, 27 | EDMASTH, 28 | EDMANDL, 29 | EDMANDH, 30 | EDMADSTL, 31 | EDMADSTH, 32 | EDMACSL, 33 | EDMACSH, 34 | EIE = 0x1b, 35 | EIR, 36 | ESTAT, 37 | ECON2, 38 | ECON1 39 | } Bank1Regs; 40 | 41 | inline void eth_write(uint8_t addr, uint8_t d) 42 | { 43 | PORTB &= ~0x10; 44 | SPDR = WCR | addr; 45 | while(!(SPSR & (1< 49 | * 50 | * $Id: clock.h,v 1.3 2006/06/11 21:46:39 adam Exp $ 51 | */ 52 | #ifndef __CLOCK_H__ 53 | #define __CLOCK_H__ 54 | 55 | #include "clock-arch.h" 56 | 57 | /** 58 | * Initialize the clock library. 59 | * 60 | * This function initializes the clock library and should be called 61 | * from the main() function of the system. 62 | * 63 | */ 64 | void clock_init(void); 65 | 66 | /** 67 | * Get the current clock time. 68 | * 69 | * This function returns the current system clock time. 70 | * 71 | * \return The current clock time, measured in system ticks. 72 | */ 73 | clock_time_t clock_time(void); 74 | 75 | 76 | void clock_set_time(clock_time_t totime); 77 | 78 | /** 79 | * A second, measured in system clock time. 80 | * 81 | * \hideinitializer 82 | */ 83 | #ifdef CLOCK_CONF_SECOND 84 | #define CLOCK_SECOND CLOCK_CONF_SECOND 85 | #else 86 | #define CLOCK_SECOND (clock_time_t)32 87 | #endif 88 | 89 | #endif /* __CLOCK_H__ */ 90 | 91 | /** @} */ 92 | -------------------------------------------------------------------------------- /plc-sw/uip/lc-addrlabels.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: lc-addrlabels.h,v 1.3 2006/06/12 08:00:30 adam Exp $ 34 | */ 35 | 36 | /** 37 | * \addtogroup lc 38 | * @{ 39 | */ 40 | 41 | /** 42 | * \file 43 | * Implementation of local continuations based on the "Labels as 44 | * values" feature of gcc 45 | * \author 46 | * Adam Dunkels 47 | * 48 | * This implementation of local continuations is based on a special 49 | * feature of the GCC C compiler called "labels as values". This 50 | * feature allows assigning pointers with the address of the code 51 | * corresponding to a particular C label. 52 | * 53 | * For more information, see the GCC documentation: 54 | * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 55 | * 56 | * Thanks to dividuum for finding the nice local scope label 57 | * implementation. 58 | */ 59 | 60 | #ifndef __LC_ADDRLABELS_H__ 61 | #define __LC_ADDRLABELS_H__ 62 | 63 | /** \hideinitializer */ 64 | typedef void * lc_t; 65 | 66 | #define LC_INIT(s) s = NULL 67 | 68 | 69 | #define LC_RESUME(s) \ 70 | do { \ 71 | if(s != NULL) { \ 72 | goto *s; \ 73 | } \ 74 | } while(0) 75 | 76 | #define LC_SET(s) \ 77 | do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0) 78 | 79 | #define LC_END(s) 80 | 81 | #endif /* __LC_ADDRLABELS_H__ */ 82 | 83 | /** @} */ 84 | -------------------------------------------------------------------------------- /plc-sw/uip/lc-switch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: lc-switch.h,v 1.2 2006/06/12 08:00:30 adam Exp $ 34 | */ 35 | 36 | /** 37 | * \addtogroup lc 38 | * @{ 39 | */ 40 | 41 | /** 42 | * \file 43 | * Implementation of local continuations based on switch() statment 44 | * \author Adam Dunkels 45 | * 46 | * This implementation of local continuations uses the C switch() 47 | * statement to resume execution of a function somewhere inside the 48 | * function's body. The implementation is based on the fact that 49 | * switch() statements are able to jump directly into the bodies of 50 | * control structures such as if() or while() statmenets. 51 | * 52 | * This implementation borrows heavily from Simon Tatham's coroutines 53 | * implementation in C: 54 | * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html 55 | */ 56 | 57 | #ifndef __LC_SWITCH_H__ 58 | #define __LC_SWTICH_H__ 59 | 60 | /* WARNING! lc implementation using switch() does not work if an 61 | LC_SET() is done within another switch() statement! */ 62 | 63 | /** \hideinitializer */ 64 | typedef unsigned short lc_t; 65 | 66 | #define LC_INIT(s) s = 0; 67 | 68 | #define LC_RESUME(s) switch(s) { case 0: 69 | 70 | #define LC_SET(s) s = __LINE__; case __LINE__: 71 | 72 | #define LC_END(s) } 73 | 74 | #endif /* __LC_SWITCH_H__ */ 75 | 76 | /** @} */ 77 | -------------------------------------------------------------------------------- /plc-sw/uip/timer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup timer Timer library 3 | * 4 | * The timer library provides functions for setting, resetting and 5 | * restarting timers, and for checking if a timer has expired. An 6 | * application must "manually" check if its timers have expired; this 7 | * is not done automatically. 8 | * 9 | * A timer is declared as a \c struct \c timer and all access to the 10 | * timer is made by a pointer to the declared timer. 11 | * 12 | * \note The timer library uses the \ref clock "Clock library" to 13 | * measure time. Intervals should be specified in the format used by 14 | * the clock library. 15 | * 16 | * @{ 17 | */ 18 | 19 | 20 | /** 21 | * \file 22 | * Timer library header file. 23 | * \author 24 | * Adam Dunkels 25 | */ 26 | 27 | /* 28 | * Copyright (c) 2004, Swedish Institute of Computer Science. 29 | * All rights reserved. 30 | * 31 | * Redistribution and use in source and binary forms, with or without 32 | * modification, are permitted provided that the following conditions 33 | * are met: 34 | * 1. Redistributions of source code must retain the above copyright 35 | * notice, this list of conditions and the following disclaimer. 36 | * 2. Redistributions in binary form must reproduce the above copyright 37 | * notice, this list of conditions and the following disclaimer in the 38 | * documentation and/or other materials provided with the distribution. 39 | * 3. Neither the name of the Institute nor the names of its contributors 40 | * may be used to endorse or promote products derived from this software 41 | * without specific prior written permission. 42 | * 43 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 44 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 | * SUCH DAMAGE. 54 | * 55 | * This file is part of the uIP TCP/IP stack 56 | * 57 | * Author: Adam Dunkels 58 | * 59 | * $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $ 60 | */ 61 | #ifndef __TIMER_H__ 62 | #define __TIMER_H__ 63 | 64 | #include "clock.h" 65 | 66 | /** 67 | * A timer. 68 | * 69 | * This structure is used for declaring a timer. The timer must be set 70 | * with timer_set() before it can be used. 71 | * 72 | * \hideinitializer 73 | */ 74 | struct timer { 75 | clock_time_t start; 76 | clock_time_t interval; 77 | }; 78 | 79 | void timer_set(struct timer *t, clock_time_t interval); 80 | void timer_reset(struct timer *t); 81 | void timer_restart(struct timer *t); 82 | int timer_expired(struct timer *t); 83 | 84 | #endif /* __TIMER_H__ */ 85 | 86 | /** @} */ 87 | -------------------------------------------------------------------------------- /plc-sw/uip/uip-neighbor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: uip-neighbor.h,v 1.2 2006/06/12 08:00:30 adam Exp $ 32 | */ 33 | 34 | /** 35 | * \file 36 | * Header file for database of link-local neighbors, used by 37 | * IPv6 code and to be used by future ARP code. 38 | * \author 39 | * Adam Dunkels 40 | */ 41 | 42 | #ifndef __UIP_NEIGHBOR_H__ 43 | #define __UIP_NEIGHBOR_H__ 44 | 45 | #include "uip.h" 46 | 47 | struct uip_neighbor_addr { 48 | #if UIP_NEIGHBOR_CONF_ADDRTYPE 49 | UIP_NEIGHBOR_CONF_ADDRTYPE addr; 50 | #else 51 | struct uip_eth_addr addr; 52 | #endif 53 | }; 54 | 55 | void uip_neighbor_init(void); 56 | void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr); 57 | void uip_neighbor_update(uip_ipaddr_t ipaddr); 58 | struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr); 59 | void uip_neighbor_periodic(void); 60 | 61 | #endif /* __UIP-NEIGHBOR_H__ */ 62 | -------------------------------------------------------------------------------- /plc-sw/uip/uiplib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of 3 | * Computer Science. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: uiplib.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 33 | * 34 | */ 35 | 36 | 37 | #include "uip.h" 38 | #include "uiplib.h" 39 | 40 | 41 | /*-----------------------------------------------------------------------------------*/ 42 | unsigned char 43 | uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr) 44 | { 45 | unsigned char tmp; 46 | char c; 47 | unsigned char i, j; 48 | 49 | tmp = 0; 50 | 51 | for(i = 0; i < 4; ++i) { 52 | j = 0; 53 | do { 54 | c = *addrstr; 55 | ++j; 56 | if(j > 4) { 57 | return 0; 58 | } 59 | if(c == '.' || c == 0) { 60 | *ipaddr = tmp; 61 | ++ipaddr; 62 | tmp = 0; 63 | } else if(c >= '0' && c <= '9') { 64 | tmp = (tmp * 10) + (c - '0'); 65 | } else { 66 | return 0; 67 | } 68 | ++addrstr; 69 | } while(c != '.' && c != 0); 70 | } 71 | return 1; 72 | } 73 | 74 | /*-----------------------------------------------------------------------------------*/ 75 | -------------------------------------------------------------------------------- /plc-sw/uip/uiplib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * Various uIP library functions. 4 | * \author 5 | * Adam Dunkels 6 | * 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2002, Adam Dunkels. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above 19 | * copyright notice, this list of conditions and the following 20 | * disclaimer in the documentation and/or other materials provided 21 | * with the distribution. 22 | * 3. The name of the author may not be used to endorse or promote 23 | * products derived from this software without specific prior 24 | * written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 27 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 30 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * This file is part of the uIP TCP/IP stack 39 | * 40 | * $Id: uiplib.h,v 1.1 2006/06/07 09:15:19 adam Exp $ 41 | * 42 | */ 43 | #ifndef __UIPLIB_H__ 44 | #define __UIPLIB_H__ 45 | 46 | /** 47 | * \addtogroup uipconvfunc 48 | * @{ 49 | */ 50 | 51 | /** 52 | * Convert a textual representation of an IP address to a numerical representation. 53 | * 54 | * This function takes a textual representation of an IP address in 55 | * the form a.b.c.d and converts it into a 4-byte array that can be 56 | * used by other uIP functions. 57 | * 58 | * \param addrstr A pointer to a string containing the IP address in 59 | * textual form. 60 | * 61 | * \param addr A pointer to a 4-byte array that will be filled in with 62 | * the numerical representation of the address. 63 | * 64 | * \retval 0 If the IP address could not be parsed. 65 | * \retval Non-zero If the IP address was parsed. 66 | */ 67 | unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr); 68 | 69 | /** @} */ 70 | 71 | #endif /* __UIPLIB_H__ */ 72 | -------------------------------------------------------------------------------- /setup-deb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Developed by Nicholas Wertzberger 3 | # Copyright 2011 University of Nebraska, Omaha 4 | # This is released under the CC-AT-SA-3.0 license. Read about it here: 5 | # http://creativecommons.org/licenses/by-sa/3.0/ 6 | # This script does everything you need to set up OpenPLC for a debian-based 7 | # platform. 8 | 9 | echo I\'m going to jsut do my thing... You should have looked me over before 10 | echo you ran me... 11 | 12 | # Pre-req's 13 | apt-get install gputils 14 | apt-get install libusb-dev 15 | 16 | # PIC programmer 17 | wget http://ww1.microchip.com/downloads/en/DeviceDoc/pk2cmdv1.20LinuxMacSource.tar.gz 18 | tar -xzf pk2cmdv1.20LinuxMacSource.tar.gz 19 | cd pk2cmdv1.20LinuxMacSource/ 20 | make linux 21 | make install 22 | cd .. 23 | rm -r pk2cmdv1.20LinuxMacSource/ 24 | rm pk2cmdv1.20LinuxMacSource.tar.gz 25 | 26 | # SDCC 27 | # I use the latest source in the event that there is a compiler issue, but 28 | # this should be sufficient (i think). 29 | apt-get install sdcc 30 | 31 | 32 | --------------------------------------------------------------------------------