From 04bbba6c1267e4a40b9b30c182039bd8e27d2a7f Mon Sep 17 00:00:00 2001 From: Ralf Schlatterbeck Date: Fri, 22 Apr 2016 17:51:59 +0200 Subject: [PATCH] Multi-platform support, osd-merkur-{128,256} Rename guhRF platform to osd-merkur-256, previous osd-merkur platform is now osd-merkur-128. Also check that everything is consistent. Add both platforms to the regression tests. Move redundant files in platform dev directory of both platforms to cpu/avr/dev. Note that this probably needs some rework. Already discovered some inconsistency in io definitions of both devices in the avr/io.h includes. Added a workaround in the obvious cases. The platform makefiles now set correct parameters for bootloader and for reading mac-address from flash memory. Factor the flash programming into cpu/avr and platform/osd-merkur* and rework *all* osd example makefiles to use the new settings. Also update all the flash.sh and run.sh to use the new settings. The suli ledstrip modules (and osd example) have also been removed. --- .gitmodules | 3 - cpu/avr/Makefile.avr | 29 +- {platform/guhRF => cpu/avr}/dev/adc.c | 0 {platform/guhRF => cpu/avr}/dev/adc.h | 0 .../dev => cpu/avr/dev/arduino}/Arduino.h | 0 .../avr}/dev/arduino/Print.cpp | 0 .../avr}/dev/arduino/Print.h | 0 .../avr}/dev/arduino/Printable.h | 0 .../avr}/dev/arduino/Stream.cpp | 0 .../avr}/dev/arduino/Stream.h | 0 .../avr}/dev/arduino/WMath.cpp | 0 .../avr}/dev/arduino/WString.cpp | 0 .../avr}/dev/arduino/WString.h | 0 .../avr}/dev/arduino/Wire.cpp | 0 .../osd-merkur => cpu/avr}/dev/arduino/Wire.h | 0 .../dev => cpu/avr/dev/arduino}/binary.h | 0 .../dev => cpu/avr/dev/arduino}/hw-arduino.h | 0 .../avr}/dev/arduino/new.cpp | 0 .../osd-merkur => cpu/avr}/dev/arduino/new.h | 0 .../osd-merkur => cpu/avr}/dev/arduino/twi.c | 0 .../osd-merkur => cpu/avr}/dev/arduino/twi.h | 0 .../avr/dev/arduino}/wiring_digital.c | 0 .../avr}/dev/arduino/wiring_private.h | 0 {platform/guhRF => cpu/avr}/dev/batmon.c | 0 {platform/guhRF => cpu/avr}/dev/batmon.h | 0 .../guhRF => cpu/avr}/dev/battery-sensor.c | 0 .../guhRF => cpu/avr}/dev/battery-sensor.h | 0 .../avr}/dev/button-sensor.c | 0 {platform/guhRF => cpu/avr}/dev/dht11.c | 0 {platform/guhRF => cpu/avr}/dev/dht11.h | 0 {platform/guhRF => cpu/avr}/dev/ds1820.c | 0 {platform/guhRF => cpu/avr}/dev/ds1820.h | 0 {platform/guhRF => cpu/avr}/dev/i2c.c | 0 {platform/guhRF => cpu/avr}/dev/i2c.h | 0 {platform/guhRF => cpu/avr}/dev/key.c | 0 {platform/guhRF => cpu/avr}/dev/key.h | 0 {platform/osd-merkur => cpu/avr}/dev/led.c | 0 {platform/osd-merkur => cpu/avr}/dev/led.h | 13 + .../guhRF => cpu/avr}/dev/optriac-sensor.c | 0 .../guhRF => cpu/avr}/dev/optriac-sensor.h | 0 .../osd-merkur => cpu/avr}/dev/pir-sensor.c | 0 {platform/guhRF => cpu/avr}/dev/pir-sensor.h | 0 .../guhRF => cpu/avr}/dev/relay-sensor.c | 0 .../guhRF => cpu/avr}/dev/relay-sensor.h | 0 {platform/guhRF => cpu/avr}/dev/relay.c | 0 {platform/guhRF => cpu/avr}/dev/relay.h | 0 .../guhRF => cpu/avr}/dev/servo-sensor.c | 0 .../guhRF => cpu/avr}/dev/servo-sensor.h | 0 {platform/guhRF => cpu/avr}/dev/servo.c | 0 {platform/guhRF => cpu/avr}/dev/servo.h | 0 {platform/guhRF => cpu/avr}/dev/sg-ready.c | 2 +- {platform/guhRF => cpu/avr}/dev/sg-ready.h | 23 + .../guhRF => cpu/avr}/dev/t4-servo-sensor.c | 0 .../guhRF => cpu/avr}/dev/t4-servo-sensor.h | 0 {platform/guhRF => cpu/avr}/dev/t4-servo.c | 0 {platform/guhRF => cpu/avr}/dev/t4-servo.h | 0 .../avr}/dev/temperature-sensor.c | 0 .../avr}/dev/temperature-sensor.h | 0 examples/osd/.gitignore | 2 + examples/osd/arduino-climate3/Makefile | 57 +- examples/osd/arduino-climate3/flash.sh | 2 +- examples/osd/arduino-climate3/run.sh | 4 +- examples/osd/arduino-dallastemp/Makefile | 34 +- examples/osd/arduino-dallastemp/flash.sh | 2 +- examples/osd/arduino-dallastemp/run.sh | 4 +- examples/osd/arduino-distance/Makefile | 34 +- examples/osd/arduino-distance/flash.sh | 2 +- examples/osd/arduino-distance/run.sh | 4 +- examples/osd/arduino-dooralert/Makefile | 34 +- examples/osd/arduino-dooralert/flash.sh | 2 +- examples/osd/arduino-dooralert/run.sh | 4 +- examples/osd/arduino-htu21/Makefile | 34 +- examples/osd/arduino-htu21/flash.sh | 2 +- examples/osd/arduino-htu21/run.sh | 4 +- examples/osd/arduino-ledstrip/Makefile | 33 +- examples/osd/arduino-ledstrip/flash.sh | 2 +- examples/osd/arduino-ledstrip/run.sh | 4 +- examples/osd/arduino-merkurboard/Makefile | 34 +- examples/osd/arduino-merkurboard/flash.sh | 2 +- examples/osd/arduino-merkurboard/run.sh | 4 +- examples/osd/arduino-plantobserving/Makefile | 34 +- examples/osd/arduino-plantobserving/flash.sh | 2 +- examples/osd/arduino-plantobserving/run.sh | 4 +- examples/osd/arduino-roller/Makefile | 34 +- examples/osd/arduino-roller/flash.sh | 2 +- examples/osd/arduino-roller/run.sh | 4 +- examples/osd/arduino-roomalert/Makefile | 34 +- examples/osd/arduino-roomalert/flash.sh | 2 +- examples/osd/arduino-roomalert/run.sh | 4 +- examples/osd/arduino-sketch/Makefile | 34 +- examples/osd/arduino-sketch/flash.sh | 2 +- examples/osd/arduino-sketch/run.sh | 4 +- examples/osd/arduino-wateralert/Makefile | 34 +- examples/osd/arduino-wateralert/flash.sh | 2 +- examples/osd/arduino-wateralert/run.sh | 4 +- examples/osd/climate/Makefile | 27 +- examples/osd/climate/flash.sh | 2 +- examples/osd/climate/run.sh | 4 +- examples/osd/climate2/Makefile | 25 +- examples/osd/climate2/flash.sh | 2 +- examples/osd/climate2/run.sh | 4 +- examples/osd/dual-rgbw-actor/Makefile | 12 +- examples/osd/dual-rgbw-actor/flash.sh | 2 +- examples/osd/dual-rgbw-actor/run.sh | 7 +- examples/osd/embedd-vm-merkurboard/Makefile | 11 +- examples/osd/embedd-vm-merkurboard/flash.sh | 2 +- examples/osd/embedd-vm-merkurboard/run.sh | 7 +- .../osd/er-rest-example-merkurboard/Makefile | 46 +- .../osd/er-rest-example-merkurboard/flash.sh | 2 +- .../osd/er-rest-example-merkurboard/run.sh | 4 +- examples/osd/led-strip/Makefile | 94 --- examples/osd/led-strip/flash.sh | 2 - examples/osd/led-strip/led-strip.c | 160 ----- examples/osd/led-strip/project-conf.h | 102 --- examples/osd/led-strip/run.sh | 5 - examples/osd/light-actor/Makefile | 34 +- examples/osd/light-actor/flash.sh | 2 +- examples/osd/light-actor/pcintkey.c | 25 +- examples/osd/light-actor/run.sh | 7 +- examples/osd/light-shutter-control/Makefile | 11 +- examples/osd/light-shutter-control/flash.sh | 2 +- examples/osd/light-shutter-control/pcintkey.c | 25 +- examples/osd/light-shutter-control/run.sh | 7 +- examples/osd/merkurboard/Makefile | 48 +- examples/osd/merkurboard/flash.sh | 2 +- examples/osd/merkurboard/run.sh | 4 +- examples/osd/native-border-router/Makefile | 12 +- examples/osd/pingtheplug/Makefile | 34 +- examples/osd/pingtheplug/er-example-server.c | 2 +- examples/osd/pingtheplug/flash.sh | 2 +- examples/osd/pingtheplug/pcintkey.c | 25 +- examples/osd/pingtheplug/run.sh | 7 +- examples/osd/pir-sensor/Makefile | 11 +- examples/osd/pir-sensor/flash.sh | 2 +- examples/osd/pir-sensor/run.sh | 7 +- examples/osd/poti/Makefile | 26 +- examples/osd/poti/flash.sh | 2 +- examples/osd/poti/run.sh | 4 +- examples/osd/powerbox/Makefile | 13 +- examples/osd/powerbox/flash.sh | 2 +- examples/osd/powerbox/run.sh | 7 +- examples/osd/pwm-example/Makefile | 34 +- examples/osd/pwm-example/flash.sh | 2 +- examples/osd/pwm-example/run.sh | 4 +- examples/osd/rpl-border-router/Makefile | 11 +- examples/osd/rpl-border-router/flash.sh | 2 +- examples/osd/rpl-border-router/run.sh | 8 +- examples/osd/servo-sensor/Makefile | 15 +- examples/osd/servo-sensor/flash.sh | 2 +- examples/osd/servo-sensor/run.sh | 7 +- examples/osd/slip-radio/Makefile | 11 +- examples/osd/slip-radio/flash.sh | 2 +- examples/osd/slip-radio/run.sh | 7 +- examples/osd/wallclock-time/Makefile | 61 +- examples/osd/wallclock-time/flash.sh | 2 +- examples/osd/wallclock-time/run.sh | 4 +- .../{er-example-server.c => wallclock.c} | 1 + examples/osd/wirelessplug/Makefile | 22 +- examples/osd/wirelessplug/flash.sh | 2 +- examples/osd/wirelessplug/run.sh | 7 +- platform/guhRF/dev/button-sensor.c | 78 --- platform/guhRF/dev/led.c | 72 -- platform/guhRF/dev/led.h | 52 -- platform/guhRF/dev/pir-sensor.c | 85 --- platform/guhRF/dev/wiring_private.h | 69 -- .../Makefile.osd-merkur-128} | 36 +- .../contiki-conf.h | 76 +-- .../contiki-main.c | 37 +- .../dev/leds-arch.c | 22 +- .../{guhRF => osd-merkur-128}/dev/leds-arch.h | 5 +- .../dev/pins_arduino.h | 0 platform/{guhRF => osd-merkur-128}/node-id.c | 0 platform/{guhRF => osd-merkur-128}/node-id.h | 0 platform/{guhRF => osd-merkur-128}/params.c | 0 .../{osd-merkur => osd-merkur-128}/params.h | 9 +- .../{guhRF => osd-merkur-128}/slip_uart0.c | 0 .../Makefile.osd-merkur-256} | 76 +-- .../{guhRF => osd-merkur-256}/contiki-conf.h | 47 +- .../{guhRF => osd-merkur-256}/contiki-main.c | 6 +- .../{guhRF => osd-merkur-256}/dev/leds-arch.c | 0 platform/osd-merkur-256/dev/leds-arch.h | 25 + .../dev/pins_arduino.h | 0 .../{osd-merkur => osd-merkur-256}/node-id.c | 0 .../{osd-merkur => osd-merkur-256}/node-id.h | 0 .../{osd-merkur => osd-merkur-256}/params.c | 0 platform/{guhRF => osd-merkur-256}/params.h | 7 +- .../slip_uart0.c | 0 platform/osd-merkur/dev/LED_Strip_Suli | 1 - platform/osd-merkur/dev/Suli.h | 106 --- platform/osd-merkur/dev/adc.c | 84 --- platform/osd-merkur/dev/adc.h | 65 -- platform/osd-merkur/dev/arduino/Arduino.h | 172 ----- platform/osd-merkur/dev/arduino/hw-arduino.h | 83 --- .../osd-merkur/dev/arduino/wiring_digital.c | 104 --- platform/osd-merkur/dev/batmon.c | 55 -- platform/osd-merkur/dev/batmon.h | 8 - platform/osd-merkur/dev/battery-sensor.c | 90 --- platform/osd-merkur/dev/battery-sensor.h | 48 -- platform/osd-merkur/dev/binary.h | 515 -------------- platform/osd-merkur/dev/dht11.c | 125 ---- platform/osd-merkur/dev/dht11.h | 67 -- platform/osd-merkur/dev/ds1820.c | 291 -------- platform/osd-merkur/dev/ds1820.h | 45 -- platform/osd-merkur/dev/i2c.c | 391 ----------- platform/osd-merkur/dev/i2c.h | 131 ---- platform/osd-merkur/dev/key.c | 73 -- platform/osd-merkur/dev/key.h | 50 -- platform/osd-merkur/dev/leds-arch.h | 31 - platform/osd-merkur/dev/old/Printable.h | 40 -- platform/osd-merkur/dev/old/Stream.cpp | 270 -------- platform/osd-merkur/dev/old/Stream.h | 96 --- platform/osd-merkur/dev/old/WString.cpp | 645 ------------------ platform/osd-merkur/dev/old/WString.h | 205 ------ platform/osd-merkur/dev/old/Wire.cpp | 298 -------- platform/osd-merkur/dev/old/Wire.h | 79 --- platform/osd-merkur/dev/old/new.cpp | 28 - platform/osd-merkur/dev/old/new.h | 24 - platform/osd-merkur/dev/old/twi.c | 527 -------------- platform/osd-merkur/dev/old/twi.h | 53 -- platform/osd-merkur/dev/optriac-sensor.c | 102 --- platform/osd-merkur/dev/optriac-sensor.h | 54 -- platform/osd-merkur/dev/pir-sensor.h | 48 -- platform/osd-merkur/dev/relay-sensor.c | 109 --- platform/osd-merkur/dev/relay-sensor.h | 66 -- platform/osd-merkur/dev/relay.c | 76 --- platform/osd-merkur/dev/relay.h | 54 -- platform/osd-merkur/dev/servo-sensor.c | 100 --- platform/osd-merkur/dev/servo-sensor.h | 50 -- platform/osd-merkur/dev/servo.c | 152 ----- platform/osd-merkur/dev/servo.h | 44 -- platform/osd-merkur/dev/t4-servo-sensor.c | 101 --- platform/osd-merkur/dev/t4-servo-sensor.h | 52 -- platform/osd-merkur/dev/t4-servo.c | 139 ---- platform/osd-merkur/dev/t4-servo.h | 61 -- platform/osd-merkur/dev/temperature-sensor.c | 66 -- platform/osd-merkur/dev/temperature-sensor.h | 49 -- .../20-compile-osd-ports/Makefile | 68 +- 237 files changed, 679 insertions(+), 7835 deletions(-) rename {platform/guhRF => cpu/avr}/dev/adc.c (100%) rename {platform/guhRF => cpu/avr}/dev/adc.h (100%) rename {platform/guhRF/dev => cpu/avr/dev/arduino}/Arduino.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Print.cpp (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Print.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Printable.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Stream.cpp (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Stream.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/WMath.cpp (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/WString.cpp (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/WString.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Wire.cpp (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/Wire.h (100%) rename {platform/guhRF/dev => cpu/avr/dev/arduino}/binary.h (100%) rename {platform/guhRF/dev => cpu/avr/dev/arduino}/hw-arduino.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/new.cpp (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/new.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/twi.c (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/twi.h (100%) rename {platform/guhRF/dev => cpu/avr/dev/arduino}/wiring_digital.c (100%) rename {platform/osd-merkur => cpu/avr}/dev/arduino/wiring_private.h (100%) rename {platform/guhRF => cpu/avr}/dev/batmon.c (100%) rename {platform/guhRF => cpu/avr}/dev/batmon.h (100%) rename {platform/guhRF => cpu/avr}/dev/battery-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/battery-sensor.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/button-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/dht11.c (100%) rename {platform/guhRF => cpu/avr}/dev/dht11.h (100%) rename {platform/guhRF => cpu/avr}/dev/ds1820.c (100%) rename {platform/guhRF => cpu/avr}/dev/ds1820.h (100%) rename {platform/guhRF => cpu/avr}/dev/i2c.c (100%) rename {platform/guhRF => cpu/avr}/dev/i2c.h (100%) rename {platform/guhRF => cpu/avr}/dev/key.c (100%) rename {platform/guhRF => cpu/avr}/dev/key.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/led.c (100%) rename {platform/osd-merkur => cpu/avr}/dev/led.h (89%) rename {platform/guhRF => cpu/avr}/dev/optriac-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/optriac-sensor.h (100%) rename {platform/osd-merkur => cpu/avr}/dev/pir-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/pir-sensor.h (100%) rename {platform/guhRF => cpu/avr}/dev/relay-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/relay-sensor.h (100%) rename {platform/guhRF => cpu/avr}/dev/relay.c (100%) rename {platform/guhRF => cpu/avr}/dev/relay.h (100%) rename {platform/guhRF => cpu/avr}/dev/servo-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/servo-sensor.h (100%) rename {platform/guhRF => cpu/avr}/dev/servo.c (100%) rename {platform/guhRF => cpu/avr}/dev/servo.h (100%) rename {platform/guhRF => cpu/avr}/dev/sg-ready.c (100%) rename {platform/guhRF => cpu/avr}/dev/sg-ready.h (84%) rename {platform/guhRF => cpu/avr}/dev/t4-servo-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/t4-servo-sensor.h (100%) rename {platform/guhRF => cpu/avr}/dev/t4-servo.c (100%) rename {platform/guhRF => cpu/avr}/dev/t4-servo.h (100%) rename {platform/guhRF => cpu/avr}/dev/temperature-sensor.c (100%) rename {platform/guhRF => cpu/avr}/dev/temperature-sensor.h (100%) delete mode 100644 examples/osd/led-strip/Makefile delete mode 100755 examples/osd/led-strip/flash.sh delete mode 100644 examples/osd/led-strip/led-strip.c delete mode 100644 examples/osd/led-strip/project-conf.h delete mode 100755 examples/osd/led-strip/run.sh rename examples/osd/wallclock-time/{er-example-server.c => wallclock.c} (99%) delete mode 100644 platform/guhRF/dev/button-sensor.c delete mode 100644 platform/guhRF/dev/led.c delete mode 100644 platform/guhRF/dev/led.h delete mode 100644 platform/guhRF/dev/pir-sensor.c delete mode 100644 platform/guhRF/dev/wiring_private.h rename platform/{osd-merkur/Makefile.osd-merkur => osd-merkur-128/Makefile.osd-merkur-128} (70%) rename platform/{osd-merkur => osd-merkur-128}/contiki-conf.h (81%) rename platform/{osd-merkur => osd-merkur-128}/contiki-main.c (93%) rename platform/{osd-merkur => osd-merkur-128}/dev/leds-arch.c (83%) rename platform/{guhRF => osd-merkur-128}/dev/leds-arch.h (88%) rename platform/{guhRF => osd-merkur-128}/dev/pins_arduino.h (100%) rename platform/{guhRF => osd-merkur-128}/node-id.c (100%) rename platform/{guhRF => osd-merkur-128}/node-id.h (100%) rename platform/{guhRF => osd-merkur-128}/params.c (100%) rename platform/{osd-merkur => osd-merkur-128}/params.h (91%) rename platform/{guhRF => osd-merkur-128}/slip_uart0.c (100%) rename platform/{guhRF/Makefile.guhRF => osd-merkur-256/Makefile.osd-merkur-256} (50%) rename platform/{guhRF => osd-merkur-256}/contiki-conf.h (90%) rename platform/{guhRF => osd-merkur-256}/contiki-main.c (99%) rename platform/{guhRF => osd-merkur-256}/dev/leds-arch.c (100%) create mode 100644 platform/osd-merkur-256/dev/leds-arch.h rename platform/{osd-merkur => osd-merkur-256}/dev/pins_arduino.h (100%) rename platform/{osd-merkur => osd-merkur-256}/node-id.c (100%) rename platform/{osd-merkur => osd-merkur-256}/node-id.h (100%) rename platform/{osd-merkur => osd-merkur-256}/params.c (100%) rename platform/{guhRF => osd-merkur-256}/params.h (91%) rename platform/{osd-merkur => osd-merkur-256}/slip_uart0.c (100%) delete mode 160000 platform/osd-merkur/dev/LED_Strip_Suli delete mode 100644 platform/osd-merkur/dev/Suli.h delete mode 100644 platform/osd-merkur/dev/adc.c delete mode 100644 platform/osd-merkur/dev/adc.h delete mode 100644 platform/osd-merkur/dev/arduino/Arduino.h delete mode 100644 platform/osd-merkur/dev/arduino/hw-arduino.h delete mode 100644 platform/osd-merkur/dev/arduino/wiring_digital.c delete mode 100644 platform/osd-merkur/dev/batmon.c delete mode 100644 platform/osd-merkur/dev/batmon.h delete mode 100644 platform/osd-merkur/dev/battery-sensor.c delete mode 100644 platform/osd-merkur/dev/battery-sensor.h delete mode 100644 platform/osd-merkur/dev/binary.h delete mode 100644 platform/osd-merkur/dev/dht11.c delete mode 100644 platform/osd-merkur/dev/dht11.h delete mode 100644 platform/osd-merkur/dev/ds1820.c delete mode 100644 platform/osd-merkur/dev/ds1820.h delete mode 100644 platform/osd-merkur/dev/i2c.c delete mode 100644 platform/osd-merkur/dev/i2c.h delete mode 100644 platform/osd-merkur/dev/key.c delete mode 100644 platform/osd-merkur/dev/key.h delete mode 100644 platform/osd-merkur/dev/leds-arch.h delete mode 100644 platform/osd-merkur/dev/old/Printable.h delete mode 100644 platform/osd-merkur/dev/old/Stream.cpp delete mode 100644 platform/osd-merkur/dev/old/Stream.h delete mode 100644 platform/osd-merkur/dev/old/WString.cpp delete mode 100644 platform/osd-merkur/dev/old/WString.h delete mode 100644 platform/osd-merkur/dev/old/Wire.cpp delete mode 100644 platform/osd-merkur/dev/old/Wire.h delete mode 100644 platform/osd-merkur/dev/old/new.cpp delete mode 100644 platform/osd-merkur/dev/old/new.h delete mode 100644 platform/osd-merkur/dev/old/twi.c delete mode 100644 platform/osd-merkur/dev/old/twi.h delete mode 100644 platform/osd-merkur/dev/optriac-sensor.c delete mode 100644 platform/osd-merkur/dev/optriac-sensor.h delete mode 100644 platform/osd-merkur/dev/pir-sensor.h delete mode 100644 platform/osd-merkur/dev/relay-sensor.c delete mode 100644 platform/osd-merkur/dev/relay-sensor.h delete mode 100644 platform/osd-merkur/dev/relay.c delete mode 100644 platform/osd-merkur/dev/relay.h delete mode 100644 platform/osd-merkur/dev/servo-sensor.c delete mode 100644 platform/osd-merkur/dev/servo-sensor.h delete mode 100644 platform/osd-merkur/dev/servo.c delete mode 100644 platform/osd-merkur/dev/servo.h delete mode 100644 platform/osd-merkur/dev/t4-servo-sensor.c delete mode 100644 platform/osd-merkur/dev/t4-servo-sensor.h delete mode 100644 platform/osd-merkur/dev/t4-servo.c delete mode 100644 platform/osd-merkur/dev/t4-servo.h delete mode 100644 platform/osd-merkur/dev/temperature-sensor.c delete mode 100644 platform/osd-merkur/dev/temperature-sensor.h diff --git a/.gitmodules b/.gitmodules index 1fc8b720e..eecb69722 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "tools/cc2538-bsl"] path = tools/cc2538-bsl url = https://github.com/JelmerT/cc2538-bsl.git -[submodule "platform/osd-merkur/dev/LED_Strip_Suli"] - path = platform/osd-merkur/dev/LED_Strip_Suli - url = https://github.com/osdomotics/LED_Strip_Suli.git [submodule "cpu/cc26xx-cc13xx/lib/cc26xxware"] path = cpu/cc26xx-cc13xx/lib/cc26xxware url = https://github.com/g-oikonomou/cc26xxware.git diff --git a/cpu/avr/Makefile.avr b/cpu/avr/Makefile.avr index 34537caa9..bc94010a2 100644 --- a/cpu/avr/Makefile.avr +++ b/cpu/avr/Makefile.avr @@ -12,7 +12,7 @@ CONTIKI_CPU=$(CONTIKI)/cpu/avr ### These directories will be searched for the specified source files ### TARGETLIBS are platform-specific routines in the contiki library path -CONTIKI_CPU_DIRS = . dev +CONTIKI_CPU_DIRS = . dev dev/arduino AVR = clock.c mtarch.c eeprom.c flash.c rs232.c leds-arch.c \ watchdog.c rtimer-arch.c bootloader.c ELFLOADER = elfloader.c elfloader-avr.c symtab-avr.c @@ -202,23 +202,30 @@ endif ### Upload image #Let avrdude use defaults if port or programmer not defined AVRDUDE ?= avrdude -ifdef AVRDUDE_PORT - AVRDUDE_PORT:=-P $(AVRDUDE_PORT) -endif -ifdef AVRDUDE_PROGRAMMER - AVRDUDE_PROGRAMMER:=-c $(AVRDUDE_PROGRAMMER) -endif ifdef AVRDUDE_MCU - AVRDUDE_MCU:=-p $(AVRDUDE_MCU) + DUDE_MCU:=-p $(AVRDUDE_MCU) else - AVRDUDE_MCU:=-p $(MCU) + DUDE_MCU:=-p $(MCU) endif %.u: %.hex - $(AVRDUDE) $(AVRDUDE_MCU) $(AVRDUDE_OPTIONS) $(AVRDUDE_PORT) $(AVRDUDE_PROGRAMMER) -U flash:w:$< + $(AVRDUDE) $(DUDE_MCU) $(AVRDUDE_OPTIONS) -P $(AVRDUDE_PORT) \ + -c $(AVRDUDE_PROGRAMMER) -U flash:w:$<:i %.eu: %.eep - $(AVRDUDE) $(AVRDUDE_MCU) ${AVRDUDE_OPTIONS} ${AVRDUDE_PORT} ${AVRDUDE_PROGRAMMER} -U eeprom:w:$< + $(AVRDUDE) $(DUDE_MCU) ${AVRDUDE_OPTIONS} -P ${AVRDUDE_PORT} \ + -c ${AVRDUDE_PROGRAMMER} -U eeprom:w:$<:i symbols.c: cp ${CONTIKI}/tools/empty-symbols.c symbols.c cp ${CONTIKI}/tools/empty-symbols.h symbols.h + +# Generic rules for .hex, .eep and .sz (size) file: +%.$(TARGET).hex: %.$(TARGET) + $(OBJCOPY) -j .text -j .data -O ihex $< $@ + +%.$(TARGET).eep: %.$(TARGET) + $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O ihex $< $@ + +%.$(TARGET).sz: %.$(TARGET) + $(ELF_SIZE) $< diff --git a/platform/guhRF/dev/adc.c b/cpu/avr/dev/adc.c similarity index 100% rename from platform/guhRF/dev/adc.c rename to cpu/avr/dev/adc.c diff --git a/platform/guhRF/dev/adc.h b/cpu/avr/dev/adc.h similarity index 100% rename from platform/guhRF/dev/adc.h rename to cpu/avr/dev/adc.h diff --git a/platform/guhRF/dev/Arduino.h b/cpu/avr/dev/arduino/Arduino.h similarity index 100% rename from platform/guhRF/dev/Arduino.h rename to cpu/avr/dev/arduino/Arduino.h diff --git a/platform/osd-merkur/dev/arduino/Print.cpp b/cpu/avr/dev/arduino/Print.cpp similarity index 100% rename from platform/osd-merkur/dev/arduino/Print.cpp rename to cpu/avr/dev/arduino/Print.cpp diff --git a/platform/osd-merkur/dev/arduino/Print.h b/cpu/avr/dev/arduino/Print.h similarity index 100% rename from platform/osd-merkur/dev/arduino/Print.h rename to cpu/avr/dev/arduino/Print.h diff --git a/platform/osd-merkur/dev/arduino/Printable.h b/cpu/avr/dev/arduino/Printable.h similarity index 100% rename from platform/osd-merkur/dev/arduino/Printable.h rename to cpu/avr/dev/arduino/Printable.h diff --git a/platform/osd-merkur/dev/arduino/Stream.cpp b/cpu/avr/dev/arduino/Stream.cpp similarity index 100% rename from platform/osd-merkur/dev/arduino/Stream.cpp rename to cpu/avr/dev/arduino/Stream.cpp diff --git a/platform/osd-merkur/dev/arduino/Stream.h b/cpu/avr/dev/arduino/Stream.h similarity index 100% rename from platform/osd-merkur/dev/arduino/Stream.h rename to cpu/avr/dev/arduino/Stream.h diff --git a/platform/osd-merkur/dev/arduino/WMath.cpp b/cpu/avr/dev/arduino/WMath.cpp similarity index 100% rename from platform/osd-merkur/dev/arduino/WMath.cpp rename to cpu/avr/dev/arduino/WMath.cpp diff --git a/platform/osd-merkur/dev/arduino/WString.cpp b/cpu/avr/dev/arduino/WString.cpp similarity index 100% rename from platform/osd-merkur/dev/arduino/WString.cpp rename to cpu/avr/dev/arduino/WString.cpp diff --git a/platform/osd-merkur/dev/arduino/WString.h b/cpu/avr/dev/arduino/WString.h similarity index 100% rename from platform/osd-merkur/dev/arduino/WString.h rename to cpu/avr/dev/arduino/WString.h diff --git a/platform/osd-merkur/dev/arduino/Wire.cpp b/cpu/avr/dev/arduino/Wire.cpp similarity index 100% rename from platform/osd-merkur/dev/arduino/Wire.cpp rename to cpu/avr/dev/arduino/Wire.cpp diff --git a/platform/osd-merkur/dev/arduino/Wire.h b/cpu/avr/dev/arduino/Wire.h similarity index 100% rename from platform/osd-merkur/dev/arduino/Wire.h rename to cpu/avr/dev/arduino/Wire.h diff --git a/platform/guhRF/dev/binary.h b/cpu/avr/dev/arduino/binary.h similarity index 100% rename from platform/guhRF/dev/binary.h rename to cpu/avr/dev/arduino/binary.h diff --git a/platform/guhRF/dev/hw-arduino.h b/cpu/avr/dev/arduino/hw-arduino.h similarity index 100% rename from platform/guhRF/dev/hw-arduino.h rename to cpu/avr/dev/arduino/hw-arduino.h diff --git a/platform/osd-merkur/dev/arduino/new.cpp b/cpu/avr/dev/arduino/new.cpp similarity index 100% rename from platform/osd-merkur/dev/arduino/new.cpp rename to cpu/avr/dev/arduino/new.cpp diff --git a/platform/osd-merkur/dev/arduino/new.h b/cpu/avr/dev/arduino/new.h similarity index 100% rename from platform/osd-merkur/dev/arduino/new.h rename to cpu/avr/dev/arduino/new.h diff --git a/platform/osd-merkur/dev/arduino/twi.c b/cpu/avr/dev/arduino/twi.c similarity index 100% rename from platform/osd-merkur/dev/arduino/twi.c rename to cpu/avr/dev/arduino/twi.c diff --git a/platform/osd-merkur/dev/arduino/twi.h b/cpu/avr/dev/arduino/twi.h similarity index 100% rename from platform/osd-merkur/dev/arduino/twi.h rename to cpu/avr/dev/arduino/twi.h diff --git a/platform/guhRF/dev/wiring_digital.c b/cpu/avr/dev/arduino/wiring_digital.c similarity index 100% rename from platform/guhRF/dev/wiring_digital.c rename to cpu/avr/dev/arduino/wiring_digital.c diff --git a/platform/osd-merkur/dev/arduino/wiring_private.h b/cpu/avr/dev/arduino/wiring_private.h similarity index 100% rename from platform/osd-merkur/dev/arduino/wiring_private.h rename to cpu/avr/dev/arduino/wiring_private.h diff --git a/platform/guhRF/dev/batmon.c b/cpu/avr/dev/batmon.c similarity index 100% rename from platform/guhRF/dev/batmon.c rename to cpu/avr/dev/batmon.c diff --git a/platform/guhRF/dev/batmon.h b/cpu/avr/dev/batmon.h similarity index 100% rename from platform/guhRF/dev/batmon.h rename to cpu/avr/dev/batmon.h diff --git a/platform/guhRF/dev/battery-sensor.c b/cpu/avr/dev/battery-sensor.c similarity index 100% rename from platform/guhRF/dev/battery-sensor.c rename to cpu/avr/dev/battery-sensor.c diff --git a/platform/guhRF/dev/battery-sensor.h b/cpu/avr/dev/battery-sensor.h similarity index 100% rename from platform/guhRF/dev/battery-sensor.h rename to cpu/avr/dev/battery-sensor.h diff --git a/platform/osd-merkur/dev/button-sensor.c b/cpu/avr/dev/button-sensor.c similarity index 100% rename from platform/osd-merkur/dev/button-sensor.c rename to cpu/avr/dev/button-sensor.c diff --git a/platform/guhRF/dev/dht11.c b/cpu/avr/dev/dht11.c similarity index 100% rename from platform/guhRF/dev/dht11.c rename to cpu/avr/dev/dht11.c diff --git a/platform/guhRF/dev/dht11.h b/cpu/avr/dev/dht11.h similarity index 100% rename from platform/guhRF/dev/dht11.h rename to cpu/avr/dev/dht11.h diff --git a/platform/guhRF/dev/ds1820.c b/cpu/avr/dev/ds1820.c similarity index 100% rename from platform/guhRF/dev/ds1820.c rename to cpu/avr/dev/ds1820.c diff --git a/platform/guhRF/dev/ds1820.h b/cpu/avr/dev/ds1820.h similarity index 100% rename from platform/guhRF/dev/ds1820.h rename to cpu/avr/dev/ds1820.h diff --git a/platform/guhRF/dev/i2c.c b/cpu/avr/dev/i2c.c similarity index 100% rename from platform/guhRF/dev/i2c.c rename to cpu/avr/dev/i2c.c diff --git a/platform/guhRF/dev/i2c.h b/cpu/avr/dev/i2c.h similarity index 100% rename from platform/guhRF/dev/i2c.h rename to cpu/avr/dev/i2c.h diff --git a/platform/guhRF/dev/key.c b/cpu/avr/dev/key.c similarity index 100% rename from platform/guhRF/dev/key.c rename to cpu/avr/dev/key.c diff --git a/platform/guhRF/dev/key.h b/cpu/avr/dev/key.h similarity index 100% rename from platform/guhRF/dev/key.h rename to cpu/avr/dev/key.h diff --git a/platform/osd-merkur/dev/led.c b/cpu/avr/dev/led.c similarity index 100% rename from platform/osd-merkur/dev/led.c rename to cpu/avr/dev/led.c diff --git a/platform/osd-merkur/dev/led.h b/cpu/avr/dev/led.h similarity index 89% rename from platform/osd-merkur/dev/led.h rename to cpu/avr/dev/led.h index ffa753859..60ce30b01 100644 --- a/platform/osd-merkur/dev/led.h +++ b/cpu/avr/dev/led.h @@ -43,6 +43,19 @@ #include +/* Some io.h definitions of shift vary among processors */ +#ifndef DDE0 +#define DDE0 DDRE0 +#define DDE1 DDRE1 +#define DDE2 DDRE2 +#define DDE3 DDRE3 +#define DDE4 DDRE4 +#define DDE5 DDRE5 +#define DDE6 DDRE6 +#define DDE7 DDRE7 +#endif + + /** @name LED Functions */ /** @{ */ void led1_on(void); diff --git a/platform/guhRF/dev/optriac-sensor.c b/cpu/avr/dev/optriac-sensor.c similarity index 100% rename from platform/guhRF/dev/optriac-sensor.c rename to cpu/avr/dev/optriac-sensor.c diff --git a/platform/guhRF/dev/optriac-sensor.h b/cpu/avr/dev/optriac-sensor.h similarity index 100% rename from platform/guhRF/dev/optriac-sensor.h rename to cpu/avr/dev/optriac-sensor.h diff --git a/platform/osd-merkur/dev/pir-sensor.c b/cpu/avr/dev/pir-sensor.c similarity index 100% rename from platform/osd-merkur/dev/pir-sensor.c rename to cpu/avr/dev/pir-sensor.c diff --git a/platform/guhRF/dev/pir-sensor.h b/cpu/avr/dev/pir-sensor.h similarity index 100% rename from platform/guhRF/dev/pir-sensor.h rename to cpu/avr/dev/pir-sensor.h diff --git a/platform/guhRF/dev/relay-sensor.c b/cpu/avr/dev/relay-sensor.c similarity index 100% rename from platform/guhRF/dev/relay-sensor.c rename to cpu/avr/dev/relay-sensor.c diff --git a/platform/guhRF/dev/relay-sensor.h b/cpu/avr/dev/relay-sensor.h similarity index 100% rename from platform/guhRF/dev/relay-sensor.h rename to cpu/avr/dev/relay-sensor.h diff --git a/platform/guhRF/dev/relay.c b/cpu/avr/dev/relay.c similarity index 100% rename from platform/guhRF/dev/relay.c rename to cpu/avr/dev/relay.c diff --git a/platform/guhRF/dev/relay.h b/cpu/avr/dev/relay.h similarity index 100% rename from platform/guhRF/dev/relay.h rename to cpu/avr/dev/relay.h diff --git a/platform/guhRF/dev/servo-sensor.c b/cpu/avr/dev/servo-sensor.c similarity index 100% rename from platform/guhRF/dev/servo-sensor.c rename to cpu/avr/dev/servo-sensor.c diff --git a/platform/guhRF/dev/servo-sensor.h b/cpu/avr/dev/servo-sensor.h similarity index 100% rename from platform/guhRF/dev/servo-sensor.h rename to cpu/avr/dev/servo-sensor.h diff --git a/platform/guhRF/dev/servo.c b/cpu/avr/dev/servo.c similarity index 100% rename from platform/guhRF/dev/servo.c rename to cpu/avr/dev/servo.c diff --git a/platform/guhRF/dev/servo.h b/cpu/avr/dev/servo.h similarity index 100% rename from platform/guhRF/dev/servo.h rename to cpu/avr/dev/servo.h diff --git a/platform/guhRF/dev/sg-ready.c b/cpu/avr/dev/sg-ready.c similarity index 100% rename from platform/guhRF/dev/sg-ready.c rename to cpu/avr/dev/sg-ready.c index c992462f0..93c1990bc 100644 --- a/platform/guhRF/dev/sg-ready.c +++ b/cpu/avr/dev/sg-ready.c @@ -98,8 +98,8 @@ sg_set_state(uint8_t state) State 2 - Relays 0:0 State 3 - Relays 0:1 State 4 - Relays 1:1 - */ uint8_t i = 0; + */ uint8_t current_state; PRINTF("GET STATE\n"); diff --git a/platform/guhRF/dev/sg-ready.h b/cpu/avr/dev/sg-ready.h similarity index 84% rename from platform/guhRF/dev/sg-ready.h rename to cpu/avr/dev/sg-ready.h index 0e92ba557..644df6109 100644 --- a/platform/guhRF/dev/sg-ready.h +++ b/cpu/avr/dev/sg-ready.h @@ -43,6 +43,29 @@ #include +/* Some other io settings of io include define DDRxx as DDxx */ +#ifndef DDRB0 +#define DDRB0 DDB0 +#define DDRB1 DDB1 +#define DDRB2 DDB2 +#define DDRB3 DDB3 +#define DDRB4 DDB4 +#define DDRB5 DDB5 +#define DDRB6 DDB6 +#define DDRB7 DDB7 +#endif + +#ifndef DDRD0 +#define DDRD0 DDD0 +#define DDRD1 DDD1 +#define DDRD2 DDD2 +#define DDRD3 DDD3 +#define DDRD4 DDD4 +#define DDRD5 DDD5 +#define DDRD6 DDD6 +#define DDRD7 DDD7 +#endif + #define LATCH_TIME 3000 // time in micro seconds #define RELAY1_ON (1< - */ - -#include -#include -#include -#include -#include "contiki.h" -#include "contiki-net.h" -#include "rest-engine.h" -#include "generic_resource.h" - -/* - * Resources to be activated need to be imported through the extern keyword. - * The build system automatically compiles the resources in the - * corresponding sub-directory. - */ - -#if PLATFORM_HAS_BATTERY -#include "dev/battery-sensor.h" -extern resource_t res_battery; -#endif - -#if PLATFORM_HAS_RADIO -#include "dev/radio-sensor.h" -extern resource_t res_radio; -#endif - -#include "LED_Strip_Suli.h" - -uint8_t color_rgb [3] = {0, 255, 0}; - -static uint8_t name_to_offset (const char * name) -{ - uint8_t offset = 0; - if (0 == strcmp (name, "green")) { - offset = 1; - } else if (0 == strcmp (name, "blue")) { - offset = 2; - } - return offset; -} - -static size_t -color_to_string (const char *name, const char *uri, char *buf, size_t bsize) -{ - return snprintf (buf, bsize, "%d", color_rgb [name_to_offset (name)]); -} - -int color_from_string (const char *name, const char *uri, const char *s) -{ - color_rgb [name_to_offset (name)] = atoi (s); - led_strip_begin (); - led_strip_set_color (color_rgb [0], color_rgb [1], color_rgb [2]); - led_strip_end (); - printf ("Set to R:%d G:%d B:%d\n" - , color_rgb [0], color_rgb [1], color_rgb [2]) - ; - return 0; -} - -GENERIC_RESOURCE - ( red - , RED_LED - , s - , 1 - , color_from_string - , color_to_string - ); - -GENERIC_RESOURCE - ( green - , GREEN_LED - , s - , 1 - , color_from_string - , color_to_string - ); - -GENERIC_RESOURCE - ( blue - , BLUE_LED - , s - , 1 - , color_from_string - , color_to_string - ); - - -PROCESS(led_strip, "LED Strip Example"); -AUTOSTART_PROCESSES(&led_strip); - -PROCESS_THREAD(led_strip, ev, data) -{ - - PROCESS_BEGIN(); - - /* Initialize the REST engine. */ - rest_init_engine (); - printf ("Initialized\n"); - led_strip_init (3, 14); - led_strip_begin (); - led_strip_set_color (color_rgb [0], color_rgb [1], color_rgb [2]); - led_strip_end (); - printf ("Set to R:%d G:%d B:%d\n" - , color_rgb [0], color_rgb [1], color_rgb [2]) - ; - - /* Activate the application-specific resources. */ -#if PLATFORM_HAS_BATTERY - SENSORS_ACTIVATE(battery_sensor); - rest_activate_resource (&res_battery,"s/battery"); -#endif - rest_activate_resource (&res_red, "led/R"); - rest_activate_resource (&res_green, "led/G"); - rest_activate_resource (&res_blue, "led/B"); - - /* Define application-specific events here. */ - /* Don't do anything for now, everything done in resources */ - while(1) { - PROCESS_WAIT_EVENT(); - } /* while (1) */ - - PROCESS_END(); -} diff --git a/examples/osd/led-strip/project-conf.h b/examples/osd/led-strip/project-conf.h deleted file mode 100644 index e45478f02..000000000 --- a/examples/osd/led-strip/project-conf.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2013, Matthias Kovatsch - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - */ - -#ifndef PROJECT_ERBIUM_CONF_H_ -#define PROJECT_ERBIUM_CONF_H_ - -#define PLATFORM_HAS_INFO 1 -#define PLATFORM_HAS_BATTERY 1 -//#define PLATFORM_HAS_DHT11TEMP 1 -#define PLATFORM_HAS_LEDS 1 - -/* For Debug: Dont allow MCU sleeping between channel checks */ -#undef RDC_CONF_MCU_SLEEP -#define RDC_CONF_MCU_SLEEP 0 - -/* Some platforms have weird includes. */ -#undef IEEE802154_CONF_PANID - -/* Disabling RDC for demo purposes. Core updates often require more memory. */ -/* For projects, optimize memory and enable RDC again. */ -// #undef NETSTACK_CONF_RDC -//#define NETSTACK_CONF_RDC nullrdc_driver - -/* Increase rpl-border-router IP-buffer when using more than 64. */ -#undef REST_MAX_CHUNK_SIZE -#define REST_MAX_CHUNK_SIZE 64 - -/* Estimate your header size, especially when using Proxy-Uri. */ -/* -#undef COAP_MAX_HEADER_SIZE -#define COAP_MAX_HEADER_SIZE 70 -*/ - -/* The IP buffer size must fit all other hops, in particular the border router. */ - -#undef UIP_CONF_BUFFER_SIZE -#define UIP_CONF_BUFFER_SIZE 256 - - -/* Multiplies with chunk size, be aware of memory constraints. */ -#undef COAP_MAX_OPEN_TRANSACTIONS -#define COAP_MAX_OPEN_TRANSACTIONS 4 - -/* Must be <= open transaction number, default is COAP_MAX_OPEN_TRANSACTIONS-1. */ -/* -#undef COAP_MAX_OBSERVERS -#define COAP_MAX_OBSERVERS 2 -*/ - -/* Filtering .well-known/core per query can be disabled to save space. */ -/* -#undef COAP_LINK_FORMAT_FILTERING -#define COAP_LINK_FORMAT_FILTERING 0 -*/ - -/* Save some memory for the sky platform. */ -/* -#undef NBR_TABLE_CONF_MAX_NEIGHBORS -#define NBR_TABLE_CONF_MAX_NEIGHBORS 10 -#undef UIP_CONF_MAX_ROUTES -#define UIP_CONF_MAX_ROUTES 10 -*/ - -/* Reduce 802.15.4 frame queue to save RAM. */ -/* -#undef QUEUEBUF_CONF_NUM -#define QUEUEBUF_CONF_NUM 4 -*/ - -/* -#undef SICSLOWPAN_CONF_FRAG -#define SICSLOWPAN_CONF_FRAG 1 -*/ -#endif /* PROJECT_ERBIUM_CONF_H_ */ diff --git a/examples/osd/led-strip/run.sh b/examples/osd/led-strip/run.sh deleted file mode 100755 index 0fceb01ce..000000000 --- a/examples/osd/led-strip/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# For the ages-old bootloader (before 2014) you want to use -# BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur diff --git a/examples/osd/light-actor/Makefile b/examples/osd/light-actor/Makefile index 02b345590..881d7002c 100644 --- a/examples/osd/light-actor/Makefile +++ b/examples/osd/light-actor/Makefile @@ -1,10 +1,6 @@ -ifeq ($(TARGET), osd-merkur) -PLATFORM_FILES= avr-size er-example-server.osd-merkur.hex \ - er-example-server.osd-merkur.eep -endif +EXE=er-example-server -all: er-example-server $(PLATFORM_FILES) -# use this target explicitly if requried: er-plugtest-server +all: $(EXE) CONTIKI=../../.. @@ -41,25 +37,6 @@ APPS += json json-resource include $(CONTIKI)/Makefile.include -avr-size: er-example-server.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur - -er-example-server.osd-merkur.hex: er-example-server.osd-merkur - avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur \ - er-example-server.osd-merkur.hex - -er-example-server.osd-merkur.eep: er-example-server.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - er-example-server.osd-merkur er-example-server.osd-merkur.eep - -flash: er-example-server.osd-merkur.hex er-example-server.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \ - flash:w:er-example-server.osd-merkur.hex:a -U \ - eeprom:w:er-example-server.osd-merkur.eep:a - -.PHONY: flash avr-size - $(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) @@ -71,3 +48,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/light-actor/flash.sh b/examples/osd/light-actor/flash.sh index e92d472f6..e82962073 100755 --- a/examples/osd/light-actor/flash.sh +++ b/examples/osd/light-actor/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/light-actor/pcintkey.c b/examples/osd/light-actor/pcintkey.c index 5fc065e24..f9553efd4 100644 --- a/examples/osd/light-actor/pcintkey.c +++ b/examples/osd/light-actor/pcintkey.c @@ -55,9 +55,32 @@ ISR(PCINT0_vect) // } // } } + +/* Compatibility of old vs new definitions in io.h */ +#ifndef DDE0 +#define DDE0 DDRE0 +#define DDE1 DDRE1 +#define DDE2 DDRE2 +#define DDE3 DDRE3 +#define DDE4 DDRE4 +#define DDE5 DDRE5 +#define DDE6 DDRE6 +#define DDE7 DDRE7 +#endif +#ifndef DDF0 +#define DDF0 DDRF0 +#define DDF1 DDRF1 +#define DDF2 DDRF2 +#define DDF3 DDRF3 +#define DDF4 DDRF4 +#define DDF5 DDRF5 +#define DDF6 DDRF6 +#define DDF7 DDRF7 +#endif + /** * \brief This will intialize the KEY for button readings. -*/ + */ void key_init(void) { diff --git a/examples/osd/light-actor/run.sh b/examples/osd/light-actor/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/light-actor/run.sh +++ b/examples/osd/light-actor/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/light-shutter-control/Makefile b/examples/osd/light-shutter-control/Makefile index 7a3466655..340032d58 100644 --- a/examples/osd/light-shutter-control/Makefile +++ b/examples/osd/light-shutter-control/Makefile @@ -1,6 +1,6 @@ -all: er-example-server -# use this target explicitly if requried: er-plugtest-server +EXE=er-example-server +all: $(EXE) # variable for this Makefile # configure CoAP implementation (3|7|12|13) (er-coap-07 also supports CoAP draft 08) @@ -96,3 +96,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/light-shutter-control/flash.sh b/examples/osd/light-shutter-control/flash.sh index e92d472f6..e82962073 100755 --- a/examples/osd/light-shutter-control/flash.sh +++ b/examples/osd/light-shutter-control/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/light-shutter-control/pcintkey.c b/examples/osd/light-shutter-control/pcintkey.c index a6e90afa5..8bbf5fcee 100644 --- a/examples/osd/light-shutter-control/pcintkey.c +++ b/examples/osd/light-shutter-control/pcintkey.c @@ -55,9 +55,32 @@ ISR(PCINT0_vect) // } // } } + +/* Compatibility of old vs new definitions in io.h */ +#ifndef DDE0 +#define DDE0 DDRE0 +#define DDE1 DDRE1 +#define DDE2 DDRE2 +#define DDE3 DDRE3 +#define DDE4 DDRE4 +#define DDE5 DDRE5 +#define DDE6 DDRE6 +#define DDE7 DDRE7 +#endif +#ifndef DDF0 +#define DDF0 DDRF0 +#define DDF1 DDRF1 +#define DDF2 DDRF2 +#define DDF3 DDRF3 +#define DDF4 DDRF4 +#define DDF5 DDRF5 +#define DDF6 DDRF6 +#define DDF7 DDRF7 +#endif + /** * \brief This will intialize the KEY for button readings. -*/ + */ void key_init(void) { diff --git a/examples/osd/light-shutter-control/run.sh b/examples/osd/light-shutter-control/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/light-shutter-control/run.sh +++ b/examples/osd/light-shutter-control/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/merkurboard/Makefile b/examples/osd/merkurboard/Makefile index 58d6ce4ac..9cd7198da 100644 --- a/examples/osd/merkurboard/Makefile +++ b/examples/osd/merkurboard/Makefile @@ -1,13 +1,6 @@ -ifeq ($(TARGET), osd-merkur) -PLATFORM_FILES= avr-size-server er-example-server.osd-merkur.hex \ - er-example-server.osd-merkur.eep \ - avr-size-client er-example-client.osd-merkur.hex \ - er-example-client.osd-merkur.eep -endif +EXE=er-example-server er-example-client -all: er-example-server er-example-client $(PLATFORM_FILES) - -# use target "er-plugtest-server" explicitly when requried +all: $(EXE) CONTIKI=../../.. @@ -72,38 +65,15 @@ connect-router-native: $(CONTIKI)/examples/ipv6/native-border-router/border-rout connect-minimal: sudo ip address add fdfd::1/64 dev tap0 -avr-size-server: er-example-server.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur +avr-size-server: er-example-server.$(TARGET).sz -er-example-server.osd-merkur.hex: er-example-server.osd-merkur - avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur \ - er-example-server.osd-merkur.hex +avr-size-client: er-example-server.$(TARGET).sz -er-example-server.osd-merkur.eep: er-example-server.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - er-example-server.osd-merkur er-example-server.osd-merkur.eep +flash-server: er-example-server.$(TARGET).u er-example-server.$(TARGET).eu -flash-server: er-example-server.osd-merkur.hex er-example-server.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \ - flash:w:er-example-server.osd-merkur.hex:a -U \ - eeprom:w:er-example-server.osd-merkur.eep:a - -avr-size-client: er-example-client.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 er-example-client.osd-merkur - -er-example-client.osd-merkur.hex: er-example-client.osd-merkur - avr-objcopy -j .text -j .data -O ihex er-example-client.osd-merkur \ - er-example-client.osd-merkur.hex - -er-example-client.osd-merkur.eep: er-example-client.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - er-example-client.osd-merkur er-example-client.osd-merkur.eep - -flash-client: er-example-client.osd-merkur.hex er-example-client.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \ - flash:w:er-example-client.osd-merkur.hex:a -U \ - eeprom:w:er-example-client.osd-merkur.eep:a +flash-client: er-example-client.$(TARGET).u er-example-client.$(TARGET).eu .PHONY: flash-client avr-size-client flash-server avr-size-server +.PRECIOUS: er-example-server.$(TARGET).hex er-example-server.$(TARGET).eep \ + er-example-client.$(TARGET).hex er-example-client.$(TARGET).eep + diff --git a/examples/osd/merkurboard/flash.sh b/examples/osd/merkurboard/flash.sh index c75149555..824d375a0 100755 --- a/examples/osd/merkurboard/flash.sh +++ b/examples/osd/merkurboard/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo make flash-server +make TARGET=osd-merkur-128 flash-server diff --git a/examples/osd/merkurboard/run.sh b/examples/osd/merkurboard/run.sh index 0fceb01ce..5d5cbbbb4 100755 --- a/examples/osd/merkurboard/run.sh +++ b/examples/osd/merkurboard/run.sh @@ -1,5 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/native-border-router/Makefile b/examples/osd/native-border-router/Makefile index d781ed35c..442a39e78 100644 --- a/examples/osd/native-border-router/Makefile +++ b/examples/osd/native-border-router/Makefile @@ -1,5 +1,5 @@ -CONTIKI_PROJECT=border-router -all: $(CONTIKI_PROJECT) +EXE=border-router +all: $(EXE) APPS = slip-cmd CONTIKI=../../.. @@ -25,3 +25,11 @@ include $(CONTIKI)/Makefile.include connect-router: border-router.native sudo ./border-router.native aaaa::1/64 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep + diff --git a/examples/osd/pingtheplug/Makefile b/examples/osd/pingtheplug/Makefile index 02b345590..881d7002c 100644 --- a/examples/osd/pingtheplug/Makefile +++ b/examples/osd/pingtheplug/Makefile @@ -1,10 +1,6 @@ -ifeq ($(TARGET), osd-merkur) -PLATFORM_FILES= avr-size er-example-server.osd-merkur.hex \ - er-example-server.osd-merkur.eep -endif +EXE=er-example-server -all: er-example-server $(PLATFORM_FILES) -# use this target explicitly if requried: er-plugtest-server +all: $(EXE) CONTIKI=../../.. @@ -41,25 +37,6 @@ APPS += json json-resource include $(CONTIKI)/Makefile.include -avr-size: er-example-server.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur - -er-example-server.osd-merkur.hex: er-example-server.osd-merkur - avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur \ - er-example-server.osd-merkur.hex - -er-example-server.osd-merkur.eep: er-example-server.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - er-example-server.osd-merkur er-example-server.osd-merkur.eep - -flash: er-example-server.osd-merkur.hex er-example-server.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \ - flash:w:er-example-server.osd-merkur.hex:a -U \ - eeprom:w:er-example-server.osd-merkur.eep:a - -.PHONY: flash avr-size - $(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) @@ -71,3 +48,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/pingtheplug/er-example-server.c b/examples/osd/pingtheplug/er-example-server.c index ea6357e87..2b62e47ec 100644 --- a/examples/osd/pingtheplug/er-example-server.c +++ b/examples/osd/pingtheplug/er-example-server.c @@ -678,7 +678,7 @@ AUTOSTART_PROCESSES(&rest_server_example, &sensors_process); PROCESS_THREAD(rest_server_example, ev, data) { static struct etimer ds_periodic_timer; - static int ext4=0; +// static int ext4=0; static int ext5=0; static int ext6=0; // ext4 = is_button_ext4(); diff --git a/examples/osd/pingtheplug/flash.sh b/examples/osd/pingtheplug/flash.sh index e92d472f6..e82962073 100755 --- a/examples/osd/pingtheplug/flash.sh +++ b/examples/osd/pingtheplug/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/pingtheplug/pcintkey.c b/examples/osd/pingtheplug/pcintkey.c index 5fc065e24..f9553efd4 100644 --- a/examples/osd/pingtheplug/pcintkey.c +++ b/examples/osd/pingtheplug/pcintkey.c @@ -55,9 +55,32 @@ ISR(PCINT0_vect) // } // } } + +/* Compatibility of old vs new definitions in io.h */ +#ifndef DDE0 +#define DDE0 DDRE0 +#define DDE1 DDRE1 +#define DDE2 DDRE2 +#define DDE3 DDRE3 +#define DDE4 DDRE4 +#define DDE5 DDRE5 +#define DDE6 DDRE6 +#define DDE7 DDRE7 +#endif +#ifndef DDF0 +#define DDF0 DDRF0 +#define DDF1 DDRF1 +#define DDF2 DDRF2 +#define DDF3 DDRF3 +#define DDF4 DDRF4 +#define DDF5 DDRF5 +#define DDF6 DDRF6 +#define DDF7 DDRF7 +#endif + /** * \brief This will intialize the KEY for button readings. -*/ + */ void key_init(void) { diff --git a/examples/osd/pingtheplug/run.sh b/examples/osd/pingtheplug/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/pingtheplug/run.sh +++ b/examples/osd/pingtheplug/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/pir-sensor/Makefile b/examples/osd/pir-sensor/Makefile index 8a253c40d..0675e5538 100644 --- a/examples/osd/pir-sensor/Makefile +++ b/examples/osd/pir-sensor/Makefile @@ -1,6 +1,6 @@ -all: er-example-server -# use this target explicitly if requried: er-plugtest-server +EXE=er-example-server +all: $(EXE) # variable for this Makefile # configure CoAP implementation (3|7|12|13) (er-coap-07 also supports CoAP draft 08) @@ -92,3 +92,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/pir-sensor/flash.sh b/examples/osd/pir-sensor/flash.sh index e92d472f6..e82962073 100755 --- a/examples/osd/pir-sensor/flash.sh +++ b/examples/osd/pir-sensor/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/pir-sensor/run.sh b/examples/osd/pir-sensor/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/pir-sensor/run.sh +++ b/examples/osd/pir-sensor/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/poti/Makefile b/examples/osd/poti/Makefile index 536488828..8593b01cb 100644 --- a/examples/osd/poti/Makefile +++ b/examples/osd/poti/Makefile @@ -1,10 +1,6 @@ -SERIAL=/dev/ttyUSB0 -ifeq ($(TARGET), osd-merkur) -PLATFORM_FILES= avr-size poti.osd-merkur.hex \ - poti.osd-merkur.eep -endif +EXE=poti -all: poti $(PLATFORM_FILES) +all: $(EXE) CONTIKI=../../.. @@ -74,21 +70,9 @@ connect-router-native: $(CONTIKI)/examples/ipv6/native-border-router/border-rout connect-minimal: sudo ip address add fdfd::1/64 dev tap0 -avr-size: poti.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 poti.osd-merkur +avr-size: $(EXE).$(TARGET).sz -poti.osd-merkur.hex: poti.osd-merkur - avr-objcopy -j .text -j .data -O ihex poti.osd-merkur \ - poti.osd-merkur.hex - -poti.osd-merkur.eep: poti.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - poti.osd-merkur poti.osd-merkur.eep - -flash: poti.osd-merkur.hex poti.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P$(SERIAL) -b57600 -e -U \ - flash:w:poti.osd-merkur.hex:a -U \ - eeprom:w:poti.osd-merkur.eep:a +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu .PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/poti/flash.sh b/examples/osd/poti/flash.sh index 2b14c43f4..e82962073 100755 --- a/examples/osd/poti/flash.sh +++ b/examples/osd/poti/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -make flash TARGET=osd-merkur +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/poti/run.sh b/examples/osd/poti/run.sh index 0fceb01ce..5d5cbbbb4 100755 --- a/examples/osd/poti/run.sh +++ b/examples/osd/poti/run.sh @@ -1,5 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/powerbox/Makefile b/examples/osd/powerbox/Makefile index fa0c805ea..72ffc56e5 100644 --- a/examples/osd/powerbox/Makefile +++ b/examples/osd/powerbox/Makefile @@ -1,8 +1,6 @@ -all: er-example-server -# use this target explicitly if requried: er-plugtest-server +EXE=er-example-server - -# variable for this Makefile +all: $(EXE) # for some platforms UIP_CONF_IPV6=1 @@ -59,3 +57,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/powerbox/flash.sh b/examples/osd/powerbox/flash.sh index e92d472f6..e82962073 100755 --- a/examples/osd/powerbox/flash.sh +++ b/examples/osd/powerbox/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/powerbox/run.sh b/examples/osd/powerbox/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/powerbox/run.sh +++ b/examples/osd/powerbox/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/pwm-example/Makefile b/examples/osd/pwm-example/Makefile index 8aa7ec9c1..c10f7ff31 100644 --- a/examples/osd/pwm-example/Makefile +++ b/examples/osd/pwm-example/Makefile @@ -1,10 +1,6 @@ -ifeq ($(TARGET), osd-merkur) -PLATFORM_FILES= avr-size er-example-server.osd-merkur.hex \ - er-example-server.osd-merkur.eep -endif +EXE=er-example-server -all: er-example-server $(PLATFORM_FILES) -# use this target explicitly if requried: er-plugtest-server +all: $(EXE) CONTIKI=../../.. @@ -39,25 +35,6 @@ APPS += json json-resource include $(CONTIKI)/Makefile.include -avr-size: er-example-server.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur - -er-example-server.osd-merkur.hex: er-example-server.osd-merkur - avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur \ - er-example-server.osd-merkur.hex - -er-example-server.osd-merkur.eep: er-example-server.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - er-example-server.osd-merkur er-example-server.osd-merkur.eep - -flash: er-example-server.osd-merkur.hex er-example-server.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \ - flash:w:er-example-server.osd-merkur.hex:a -U \ - eeprom:w:er-example-server.osd-merkur.eep:a - -.PHONY: flash avr-size - $(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) @@ -69,3 +46,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/pwm-example/flash.sh b/examples/osd/pwm-example/flash.sh index e9cb40bfc..e82962073 100755 --- a/examples/osd/pwm-example/flash.sh +++ b/examples/osd/pwm-example/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -make TARGET=osd-merkur flash +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/pwm-example/run.sh b/examples/osd/pwm-example/run.sh index 0fceb01ce..5d5cbbbb4 100755 --- a/examples/osd/pwm-example/run.sh +++ b/examples/osd/pwm-example/run.sh @@ -1,5 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/rpl-border-router/Makefile b/examples/osd/rpl-border-router/Makefile index ce90a4eac..e57591e80 100644 --- a/examples/osd/rpl-border-router/Makefile +++ b/examples/osd/rpl-border-router/Makefile @@ -1,5 +1,5 @@ -CONTIKI_PROJECT=border-router -all: $(CONTIKI_PROJECT) +EXE=border-router +all: $(EXE) CONTIKI=../../.. @@ -47,3 +47,10 @@ connect-router: $(CONTIKI)/tools/tunslip6 connect-router-cooja: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX) + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/rpl-border-router/flash.sh b/examples/osd/rpl-border-router/flash.sh index 07cfc9a65..e82962073 100755 --- a/examples/osd/rpl-border-router/flash.sh +++ b/examples/osd/rpl-border-router/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:border-router.osd-merkur.hex:a -U eeprom:w:border-router.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/rpl-border-router/run.sh b/examples/osd/rpl-border-router/run.sh index 9833eba6b..dc2b12de9 100755 --- a/examples/osd/rpl-border-router/run.sh +++ b/examples/osd/rpl-border-router/run.sh @@ -1,8 +1,6 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 border-router.osd-merkur -avr-objcopy -j .text -j .data -O ihex border-router.osd-merkur border-router.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex border-router.osd-merkur border-router.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 avr-size diff --git a/examples/osd/servo-sensor/Makefile b/examples/osd/servo-sensor/Makefile index 0349fc11f..72ffc56e5 100644 --- a/examples/osd/servo-sensor/Makefile +++ b/examples/osd/servo-sensor/Makefile @@ -1,10 +1,6 @@ -all: er-example-server -# use this target explicitly if requried: er-plugtest-server +EXE=er-example-server - -# variable for this Makefile -# configure CoAP implementation (3|7|12|13) (er-coap-07 also supports CoAP draft 08) -WITH_COAP=13 +all: $(EXE) # for some platforms UIP_CONF_IPV6=1 @@ -61,3 +57,10 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/servo-sensor/flash.sh b/examples/osd/servo-sensor/flash.sh index b91668634..e82962073 100755 --- a/examples/osd/servo-sensor/flash.sh +++ b/examples/osd/servo-sensor/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/servo-sensor/run.sh b/examples/osd/servo-sensor/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/servo-sensor/run.sh +++ b/examples/osd/servo-sensor/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/slip-radio/Makefile b/examples/osd/slip-radio/Makefile index 9d6f8ca88..d6bb0802c 100644 --- a/examples/osd/slip-radio/Makefile +++ b/examples/osd/slip-radio/Makefile @@ -1,5 +1,5 @@ -CONTIKI_PROJECT=slip-radio -all: $(CONTIKI_PROJECT) +EXE=slip-radio +all: $(EXE) APPS = slip-cmd ifeq ($(TARGET),) @@ -26,3 +26,10 @@ endif CONTIKI_WITH_RPL = 0 CONTIKI_WITH_IPV6 = 1 include $(CONTIKI)/Makefile.include + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/slip-radio/flash.sh b/examples/osd/slip-radio/flash.sh index 633f3f434..e82962073 100755 --- a/examples/osd/slip-radio/flash.sh +++ b/examples/osd/slip-radio/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:slip-radio.osd-merkur.hex:a -U eeprom:w:slip-radio.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/slip-radio/run.sh b/examples/osd/slip-radio/run.sh index eebc9a53a..5d5cbbbb4 100755 --- a/examples/osd/slip-radio/run.sh +++ b/examples/osd/slip-radio/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size slip-radio.osd-merkur -avr-objcopy -j .text -j .data -O ihex slip-radio.osd-merkur slip-radio.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex slip-radio.osd-merkur slip-radio.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/wallclock-time/Makefile b/examples/osd/wallclock-time/Makefile index 5c0062751..46d8e4625 100644 --- a/examples/osd/wallclock-time/Makefile +++ b/examples/osd/wallclock-time/Makefile @@ -1,10 +1,6 @@ -ifeq ($(TARGET), osd-merkur) -PLATFORM_FILES= avr-size er-example-server.osd-merkur.hex \ - er-example-server.osd-merkur.eep -endif +EXE=wallclock -all: er-example-server $(PLATFORM_FILES) -# use target "er-plugtest-server" explicitly when requried +all: $(EXE) CONTIKI=../../.. @@ -28,62 +24,25 @@ APPS += er-coap APPS += rest-engine APPS += json json-resource time -# optional rules to get assembly -#CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 -#CUSTOM_RULE_S_TO_OBJECTDIR_O = 1 - CONTIKI_WITH_IPV6 = 1 include $(CONTIKI)/Makefile.include -# minimal-net target is currently broken in Contiki -ifeq ($(TARGET), minimal-net) -CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\" -${info INFO: er-example compiling with large buffers} -CFLAGS += -DUIP_CONF_BUFFER_SIZE=1300 -CFLAGS += -DREST_MAX_CHUNK_SIZE=1024 -CFLAGS += -DCOAP_MAX_HEADER_SIZE=176 -CONTIKI_WITH_RPL=0 -endif - -# optional rules to get assembly -#$(OBJECTDIR)/%.o: asmdir/%.S -# $(CC) $(CFLAGS) -MMD -c $< -o $@ -# @$(FINALIZE_DEPENDENCY) -# -#asmdir/%.S: %.c -# $(CC) $(CFLAGS) -MMD -S $< -o $@ - -# border router rules -$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c +$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c (cd $(CONTIKI)/tools && $(MAKE) tunslip6) -connect-router: $(CONTIKI)/tools/tunslip6 +connect-router: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64 -connect-router-cooja: $(CONTIKI)/tools/tunslip6 +connect-router-cooja: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 aaaa::1/64 -connect-router-native: $(CONTIKI)/examples/ipv6/native-border-router/border-router.native - sudo $(CONTIKI)/exmples/ipv6/native-border-router/border-router.native -a 127.0.0.1 -p 60001 aaaa::1/64 - connect-minimal: - sudo ip address add fdfd::1/64 dev tap0 + sudo ip address add fdfd::1/64 dev tap0 -avr-size: er-example-server.osd-merkur - avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur +avr-size: $(EXE).$(TARGET).sz -er-example-server.osd-merkur.hex: er-example-server.osd-merkur - avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur \ - er-example-server.osd-merkur.hex - -er-example-server.osd-merkur.eep: er-example-server.osd-merkur - avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O ihex \ - er-example-server.osd-merkur er-example-server.osd-merkur.eep - -flash: er-example-server.osd-merkur.hex er-example-server.osd-merkur.eep - avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \ - flash:w:er-example-server.osd-merkur.hex:a -U \ - eeprom:w:er-example-server.osd-merkur.eep:a +# At some point we may want to include the eeprom file +flash: $(EXE).$(TARGET).u # $(EXE).$(TARGET).eu .PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/wallclock-time/flash.sh b/examples/osd/wallclock-time/flash.sh index e9cb40bfc..e82962073 100755 --- a/examples/osd/wallclock-time/flash.sh +++ b/examples/osd/wallclock-time/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -make TARGET=osd-merkur flash +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/wallclock-time/run.sh b/examples/osd/wallclock-time/run.sh index 0fceb01ce..5d5cbbbb4 100755 --- a/examples/osd/wallclock-time/run.sh +++ b/examples/osd/wallclock-time/run.sh @@ -1,5 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/examples/osd/wallclock-time/er-example-server.c b/examples/osd/wallclock-time/wallclock.c similarity index 99% rename from examples/osd/wallclock-time/er-example-server.c rename to examples/osd/wallclock-time/wallclock.c index 709844d2d..9e0013b78 100644 --- a/examples/osd/wallclock-time/er-example-server.c +++ b/examples/osd/wallclock-time/wallclock.c @@ -134,6 +134,7 @@ PROCESS_THREAD(rest_server_example, ev, data) /* Initialize the OSD Hardware. */ hw_init (); + led_set (0); /* Initialize the REST engine. */ rest_init_engine (); diff --git a/examples/osd/wirelessplug/Makefile b/examples/osd/wirelessplug/Makefile index 17792e430..aeaa5e2ad 100644 --- a/examples/osd/wirelessplug/Makefile +++ b/examples/osd/wirelessplug/Makefile @@ -1,11 +1,6 @@ -all: er-example-server er-example-client -# use this target explicitly if requried: er-plugtest-server - - -# variable for this Makefile -# configure CoAP implementation (3|7|12|13) (er-coap-07 also supports CoAP draft 08) -WITH_COAP=13 +EXE=er-example-server er-example-client +all: $(EXE) # variable for Makefile.include WITH_UIP6=1 @@ -95,3 +90,16 @@ connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-minimal: sudo ip address add fdfd::1/64 dev tap0 + +avr-size-server: er-example-server.$(TARGET).sz + +avr-size-client: er-example-server.$(TARGET).sz + +flash-server: er-example-server.$(TARGET).u er-example-server.$(TARGET).eu + +flash-client: er-example-client.$(TARGET).u er-example-client.$(TARGET).eu + +.PHONY: flash-client avr-size-client flash-server avr-size-server +.PRECIOUS: er-example-server.$(TARGET).hex er-example-server.$(TARGET).eep \ + er-example-client.$(TARGET).hex er-example-client.$(TARGET).eep + diff --git a/examples/osd/wirelessplug/flash.sh b/examples/osd/wirelessplug/flash.sh index e92d472f6..e82962073 100755 --- a/examples/osd/wirelessplug/flash.sh +++ b/examples/osd/wirelessplug/flash.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U flash:w:er-example-server.osd-merkur.hex:a -U eeprom:w:er-example-server.osd-merkur.eep:a +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/wirelessplug/run.sh b/examples/osd/wirelessplug/run.sh index 4b11e9d2a..5d5cbbbb4 100755 --- a/examples/osd/wirelessplug/run.sh +++ b/examples/osd/wirelessplug/run.sh @@ -1,8 +1,5 @@ #!/bin/bash # For the ages-old bootloader (before 2014) you want to use # BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. -make clean TARGET=osd-merkur -make TARGET=osd-merkur -avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur -avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.hex -avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex er-example-server.osd-merkur er-example-server.osd-merkur.eep +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 diff --git a/platform/guhRF/dev/button-sensor.c b/platform/guhRF/dev/button-sensor.c deleted file mode 100644 index a524a99b1..000000000 --- a/platform/guhRF/dev/button-sensor.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Sensor routine */ - -#include "lib/sensors.h" -#include "dev/button-sensor.h" - -#include -#include - -const struct sensors_sensor button_sensor; - -static struct timer debouncetimer; -static int status(int type); -static int enabled = 0; -struct sensors_sensor *sensors[1]; -unsigned char sensors_flags[1]; - -#define BUTTON_BIT INTF4 -#define BUTTON_CHECK_IRQ() (EIFR & BUTTON_BIT) ? 0 : 1 - -#define PRINTF(...) printf(__VA_ARGS__) -/*---------------------------------------------------------------------------*/ -ISR(INT4_vect) -{ - if(BUTTON_CHECK_IRQ()) { - if(timer_expired(&debouncetimer)) { - timer_set(&debouncetimer, CLOCK_SECOND / 4); - sensors_changed(&button_sensor); - } - } -} -/*---------------------------------------------------------------------------*/ - -static int -value(int type) -{ - return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer); - - //return 0; -} - -static int -configure(int type, int c) -{ - switch (type) { - case SENSORS_ACTIVE: - if (c) { - if(!status(SENSORS_ACTIVE)) { - timer_set(&debouncetimer, 0); - DDRE |= (0< - -/** @name LED Functions */ -/** @{ */ -void led1_on(void); -void led1_off(void); -/** @} */ - -#endif /* __LED_H__ */ diff --git a/platform/guhRF/dev/pir-sensor.c b/platform/guhRF/dev/pir-sensor.c deleted file mode 100644 index 37a97c025..000000000 --- a/platform/guhRF/dev/pir-sensor.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Sensor routine */ -#include "contiki.h" -#include "lib/sensors.h" -#include "dev/pir-sensor.h" - -#include -#include "led.h" // debug - -const struct sensors_sensor pir_sensor; - -static struct timer debouncetimer; -static int status(int type); -static int enabled = 0; -struct sensors_sensor *sensors[1]; -unsigned char sensors_flags[1]; - -#define PIR_BIT INTF6 -#define PIR_CHECK_IRQ() (EIFR & PIR_BIT) ? 0 : 1 - -#define PRINTF(...) printf(__VA_ARGS__) -/*---------------------------------------------------------------------------*/ -ISR(INT6_vect) -{ - -// leds_toggle(LEDS_YELLOW); - - if(PIR_CHECK_IRQ()) { - if(timer_expired(&debouncetimer)) { - // led1_on(); - timer_set(&debouncetimer, CLOCK_SECOND / 4); - sensors_changed(&pir_sensor); - // led1_off(); - } - } - -} -/*---------------------------------------------------------------------------*/ - -static int -value(int type) -{ - return (PORTE & _BV(PE6) ? 0 : 1) || !timer_expired(&debouncetimer); - //return 0; -} - -static int -configure(int type, int c) -{ - switch (type) { - case SENSORS_ACTIVE: - if (c) { - if(!status(SENSORS_ACTIVE)) { - // led1_on(); - timer_set(&debouncetimer, 0); - DDRE |= (0< -#include -#include -#include - -#include "Arduino.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -#ifndef cbi -#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) -#endif -#ifndef sbi -#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) -#endif - -#define EXTERNAL_INT_0 0 -#define EXTERNAL_INT_1 1 -#define EXTERNAL_INT_2 2 -#define EXTERNAL_INT_3 3 -#define EXTERNAL_INT_4 4 -#define EXTERNAL_INT_5 5 -#define EXTERNAL_INT_6 6 -#define EXTERNAL_INT_7 7 - -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define EXTERNAL_NUM_INTERRUPTS 8 -#elif defined(__AVR_ATmega128RFA1__) || (__AVR_ATmega256RFR2__) -#define EXTERNAL_NUM_INTERRUPTS 8 -#else -#define EXTERNAL_NUM_INTERRUPTS 2 -#endif - -typedef void (*voidFuncPtr)(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/platform/osd-merkur/Makefile.osd-merkur b/platform/osd-merkur-128/Makefile.osd-merkur-128 similarity index 70% rename from platform/osd-merkur/Makefile.osd-merkur rename to platform/osd-merkur-128/Makefile.osd-merkur-128 index 1527cdc6c..8817f3855 100644 --- a/platform/osd-merkur/Makefile.osd-merkur +++ b/platform/osd-merkur-128/Makefile.osd-merkur-128 @@ -1,10 +1,11 @@ -CONTIKI_TARGET_DIRS = . dev dev/LED_Strip_Suli apps net loader dev/arduino +CONTIKI_TARGET_DIRS = . dev apps net loader dev/arduino CONTIKI_CORE=contiki-main CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o CONTIKI_TARGET_SOURCEFILES += contiki-main.c params.c node-id.c #Needed for slip -CONTIKI_TARGET_SOURCEFILES += temperature-sensor.c adc.c led.c sensors.c slip_uart0.c slip.c leds-arch.c +CONTIKI_TARGET_SOURCEFILES += led.c sensors.c slip_uart0.c slip.c leds-arch.c +CONTIKI_TARGET_SOURCEFILES += temperature-sensor.c adc.c #Needed for Button CONTIKI_TARGET_SOURCEFILES += button-sensor.c # i2c Master @@ -19,7 +20,6 @@ CONTIKI_TARGET_SOURCEFILES += battery-sensor.c batmon.c CONTIKI_TARGET_SOURCEFILES += pir-sensor.c #Needed for OPTRIAC CONTIKI_TARGET_SOURCEFILES += optriac-sensor.c -CONTIKIAVR=$(CONTIKI)/cpu/avr #Needed for SERVO CONTIKI_TARGET_SOURCEFILES += servo.c servo-sensor.c #Needed for Timer4 Servo @@ -28,11 +28,13 @@ CONTIKI_TARGET_SOURCEFILES += servo.c servo-sensor.c CONTIKI_TARGET_SOURCEFILES += relay.c relay-sensor.c # Arduino CONTIKI_TARGET_SOURCEFILES += wiring_digital.c -CONTIKI_TARGET_SOURCEFILES += LED_Strip_Suli.c CONTIKI_TARGET_SOURCEFILES += new.cpp twi.c Wire.cpp WMath.cpp CONTIKI_TARGET_SOURCEFILES += Print.cpp Stream.cpp WString.cpp +# guh Source Files +# Smart Grid Ready Interface +CONTIKI_TARGET_SOURCEFILES += sg-ready.c -SULI_DIR=$(CONTIKI)/platform/$(TARGET)/dev/LED_Strip_Suli +CONTIKIAVR=$(CONTIKI)/cpu/avr CONTIKIBOARD=. BOOTLOADER_START = 0x1F000 @@ -40,19 +42,29 @@ CONTIKI_PLAT_DEFS = -DF_CPU=16000000UL -DAUTO_CRC_PADDING=2 -DPLAT_TIMER=5 MCU=atmega128rfa1 -AVRDUDE_PROGRAMMER=jtag2 +#AVRDUDE_PROGRAMMER=jtag2 +AVRDUDE_PROGRAMMER=arduino -# For usb devices, you may either use PORT=usb, or (e.g. if you have more than one -# programmer connected) you can use the following trick to find out the serial number: +# For usb devices, you may either use PORT=usb, or (e.g. if you have +# more than one programmer connected) you can use the following trick to +# find out the serial number: # # The example is for an JTAGICE mkII used to program an ATmega128: # avrdude -v -P usb:xxxx -c jtag2 -p atmega128 -AVRDUDE_PORT=usb:00B000000D79 - +# AVRDUDE_PORT=usb:00B000000D79 +# For serial devices with bootloader we also use the AVRDUDE_PORT setting: +AVRDUDE_PORT=/dev/ttyUSB0 +# Only needed for serial devices, use empty setting for other +# programmers +AVRDUDE_BAUD_OPTION=-b 57600 # Additional avrdude options -# Verify off -AVRDUDE_OPTIONS=-V +# First some flash options: +# Verify off is -V +# Erase is -e +# No-Erase (needed by some stk500 variants) is -D +AVRDUDE_FLASH_OPTIONS=-e +AVRDUDE_OPTIONS=$(AVRDUDE_BAUD_OPTION) $(AVRDUDE_FLASH_OPTIONS) AVRDUDE_MCU=m128rfa1 #debug diff --git a/platform/osd-merkur/contiki-conf.h b/platform/osd-merkur-128/contiki-conf.h similarity index 81% rename from platform/osd-merkur/contiki-conf.h rename to platform/osd-merkur-128/contiki-conf.h index 65d1c0510..043dff995 100644 --- a/platform/osd-merkur/contiki-conf.h +++ b/platform/osd-merkur-128/contiki-conf.h @@ -66,21 +66,8 @@ typedef uint32_t clock_time_t; void clock_delay_msec(uint16_t howlong); void clock_adjust_ticks(clock_time_t howmany); -/* Michael Hartman's atmega128rfa1 board has an external 32768Hz crystal connected to TOSC1 and 2 pins similar to the Raven 1284p */ -/* and theoretically can use TIMER2 with it to keep time. Else TIMER0 is used. */ -/* The sleep timer requires the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */ -#define AVR_CONF_USE32KCRYSTAL 0 - -/* Michael Hartman's protobyte board has LED on PORTE1, used for radio on indication */ -/* However this results in disabling UART0. */ -#define RF230BB_CONF_LEDONPORTE1 0 - -/* COM port to be used for SLIP connection. This is usually UART0, but see above */ -#if RF230BB_CONF_LEDONPORTE1 -#define SLIP_PORT RS232_PORT_1 -#else +/* COM port to be used for SLIP connection. This is usually UART0. */ #define SLIP_PORT RS232_PORT_0 -#endif /* Pre-allocated memory for loadable modules heap space (in bytes)*/ /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */ @@ -124,8 +111,11 @@ typedef unsigned short uip_stats_t; #define RF230_MAX_TX_POWER 15 #define RF230_MIN_RX_POWER 30 */ - /* The rf231 and atmega128rfa1 can use an rssi threshold for triggering rx_busy that saves 0.5ma in rx mode */ -/* 1 - 15 maps into -90 to -48 dBm; the register is written with RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity */ + /* The rf231, atmega128rfa1 and atmega256rfr2 can use an rssi + * threshold for triggering rx_busy that saves 0.5ma in rx mode + * 1 - 15 maps into -90 to -48 dBm; the register is written with + * RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity + */ //#define RF230_MIN_RX_POWER 0 /* Network setup */ @@ -134,7 +124,7 @@ typedef unsigned short uip_stats_t; /* TX routine does automatic cca and optional backoffs */ #define RDC_CONF_HARDWARE_CSMA 1 /* Allow MCU sleeping between channel checks */ -#define RDC_CONF_MCU_SLEEP 1 +#define RDC_CONF_MCU_SLEEP 1 #if NETSTACK_CONF_WITH_IPV6 #define LINKADDR_CONF_SIZE 8 @@ -218,7 +208,7 @@ typedef unsigned short uip_stats_t; #define NBR_TABLE_CONF_MAX_NEIGHBORS 20 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 20 +#define UIP_CONF_MAX_ROUTES 20 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 @@ -234,9 +224,9 @@ typedef unsigned short uip_stats_t; /* So without the header this needed for RPL mesh to form */ #define CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE 43-18 //multicast RPL DIS length /* Not tested much yet */ -#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0 -#define CONTIKIMAC_CONF_COMPOWER 1 -#define RIMESTATS_CONF_ENABLED 0 +#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0 +#define CONTIKIMAC_CONF_COMPOWER 1 +#define RIMESTATS_CONF_ENABLED 0 #if NETSTACK_CONF_WITH_IPV6 #define NETSTACK_CONF_FRAMER framer_802154 @@ -266,51 +256,11 @@ typedef unsigned short uip_stats_t; #define NBR_TABLE_CONF_MAX_NEIGHBORS 20 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 4 +#define UIP_CONF_MAX_ROUTES 4 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 - -#elif 1 /* cx-mac radio cycling */ -/* RF230 does clear-channel assessment in extended mode (autoretries>0) */ -/* These values are guesses */ -#define RF230_CONF_FRAME_RETRIES 10 -#define RF230_CONF_CSMA_RETRIES 2 -#if RF230_CONF_CSMA_RETRIES -#define NETSTACK_CONF_MAC nullmac_driver -#else -#define NETSTACK_CONF_MAC csma_driver -#endif -#define NETSTACK_CONF_RDC cxmac_driver -#define NETSTACK_CONF_FRAMER framer_802154 -#define NETSTACK_CONF_RADIO rf230_driver -#define CHANNEL_802_15_4 26 -#define RF230_CONF_AUTOACK 1 -#define SICSLOWPAN_CONF_FRAG 1 -#define SICSLOWPAN_CONF_MAXAGE 3 -#define CXMAC_CONF_ANNOUNCEMENTS 0 -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 -/* 211 bytes per queue buffer. Burst mode will need 15 for a 1280 byte MTU */ -#define QUEUEBUF_CONF_NUM 15 -/* 54 bytes per queue ref buffer */ -#define QUEUEBUF_CONF_REF_NUM 2 -/* Allocate remaining RAM. Not much left due to queuebuf increase */ -#define UIP_CONF_MAX_CONNECTIONS 2 -#define UIP_CONF_MAX_LISTENPORTS 4 -#define UIP_CONF_UDP_CONNS 5 -#define NBR_TABLE_CONF_MAX_NEIGHBORS 4 -#define UIP_CONF_DS6_DEFRT_NBU 2 -#define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 4 -#define UIP_CONF_DS6_ADDR_NBU 3 -#define UIP_CONF_DS6_MADDR_NBU 0 -#define UIP_CONF_DS6_AADDR_NBU 0 -//Below gives 10% duty cycle, undef for default 5% -//#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80) -//Below gives 50% duty cycle -//#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16) - #else #error Network configuration not specified! #endif /* Network setup */ @@ -321,7 +271,7 @@ typedef unsigned short uip_stats_t; #if UIP_CONF_IPV6_RPL #define UIP_CONF_ROUTER 1 -#define UIP_CONF_ND6_SEND_RA 0 +#define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_REACHABLE_TIME 600000 #define UIP_CONF_ND6_RETRANS_TIMER 10000 diff --git a/platform/osd-merkur/contiki-main.c b/platform/osd-merkur-128/contiki-main.c similarity index 93% rename from platform/osd-merkur/contiki-main.c rename to platform/osd-merkur-128/contiki-main.c index 4be90c6e5..142d6edd7 100644 --- a/platform/osd-merkur/contiki-main.c +++ b/platform/osd-merkur-128/contiki-main.c @@ -69,10 +69,6 @@ #include "dev/serial-line.h" #include "dev/slip.h" -#ifdef RAVEN_LCD_INTERFACE -#include "raven-lcd.h" -#endif - #if AVR_WEBSERVER #include "httpd-fs.h" #include "httpd-cgi.h" @@ -186,27 +182,15 @@ void initialize(void) watchdog_init(); watchdog_start(); -/* The Raven implements a serial command and data interface via uart0 to a 3290p, - * which could be duplicated using another host computer. - */ -#if !RF230BB_CONF_LEDONPORTE1 //Conflicts with USART0 -#ifdef RAVEN_LCD_INTERFACE - rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); - rs232_set_input(0,raven_lcd_serial_input); -#else /* Generic or slip connection on uart0 */ rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); -#endif -#endif /* Second rs232 port for debugging or slip alternative */ // rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); + /* Redirect stdout */ -#if RF230BB_CONF_LEDONPORTE1 || defined(RAVEN_LCD_INTERFACE) - rs232_redirect_stdout(RS232_PORT_1); -#else rs232_redirect_stdout(RS232_PORT_0); -#endif + clock_init(); if(MCUSR & (1< - Bernhard Trinnes + * Bernhard Trinnes */ #ifndef CONTIKI_CONF_H_ #define CONTIKI_CONF_H_ /* Platform name, type, and MCU clock rate */ -#define PLATFORM_NAME "guhRF" +#define PLATFORM_NAME "RFR2" #define PLATFORM_TYPE ATMEGA256RFR2 #ifndef F_CPU #define F_CPU 16000000UL #endif - #include #define IEEE802154_CONF_PANID 0xABCD // default panid @@ -60,29 +59,15 @@ */ /* Clock ticks per second */ #define CLOCK_CONF_SECOND 128 -#if 1 -/* 16 bit counter overflows every ~10 minutes */ -typedef unsigned short clock_time_t; -#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0) -#define INFINITE_TIME 0xffff -#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */ -#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */ -#else -typedef unsigned long clock_time_t; -#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0) -#define INFINITE_TIME 0xffffffff -#endif + +typedef uint32_t clock_time_t; +#define CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0) + /* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */ void clock_delay_msec(uint16_t howlong); void clock_adjust_ticks(clock_time_t howmany); - -/* and theoretically can use TIMER2 with it to keep time. Else TIMER0 is used. */ -/* The sleep timer requires the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */ -#define AVR_CONF_USE32KCRYSTAL 0 - - -/* COM port to be used for SLIP connection. This is usually UART0, but see above */ +/* COM port to be used for SLIP connection. This is usually UART0. */ #define SLIP_PORT RS232_PORT_0 /* Pre-allocated memory for loadable modules heap space (in bytes)*/ @@ -127,8 +112,11 @@ typedef unsigned short uip_stats_t; #define RF230_MAX_TX_POWER 15 #define RF230_MIN_RX_POWER 30 */ - /* The rf231 and ATMEGA256RFR2 can use an rssi threshold for triggering rx_busy that saves 0.5ma in rx mode */ -/* 1 - 15 maps into -90 to -48 dBm; the register is written with RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity */ + /* The rf231, atmega128rfa1 and atmega256rfr2 can use an rssi + * threshold for triggering rx_busy that saves 0.5ma in rx mode + * 1 - 15 maps into -90 to -48 dBm; the register is written with + * RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity + */ //#define RF230_MIN_RX_POWER 0 /* Network setup */ @@ -137,8 +125,7 @@ typedef unsigned short uip_stats_t; /* TX routine does automatic cca and optional backoffs */ #define RDC_CONF_HARDWARE_CSMA 1 /* Allow MCU sleeping between channel checks */ -#define RDC_CONF_MCU_SLEEP 1 - +#define RDC_CONF_MCU_SLEEP 1 #if NETSTACK_CONF_WITH_IPV6 #define LINKADDR_CONF_SIZE 8 @@ -222,7 +209,7 @@ typedef unsigned short uip_stats_t; #define NBR_TABLE_CONF_MAX_NEIGHBORS 20 #define UIP_CONF_DS6_DEFRT_NBU 2 #define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 20 +#define UIP_CONF_MAX_ROUTES 20 #define UIP_CONF_DS6_ADDR_NBU 3 #define UIP_CONF_DS6_MADDR_NBU 0 #define UIP_CONF_DS6_AADDR_NBU 0 @@ -239,8 +226,8 @@ typedef unsigned short uip_stats_t; #define CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE 43-18 //multicast RPL DIS length /* Not tested much yet */ #define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0 -#define CONTIKIMAC_CONF_COMPOWER 1 -#define RIMESTATS_CONF_ENABLED 0 +#define CONTIKIMAC_CONF_COMPOWER 1 +#define RIMESTATS_CONF_ENABLED 0 #if NETSTACK_CONF_WITH_IPV6 #define NETSTACK_CONF_FRAMER framer_802154 @@ -285,7 +272,7 @@ typedef unsigned short uip_stats_t; #if UIP_CONF_IPV6_RPL #define UIP_CONF_ROUTER 1 -#define UIP_CONF_ND6_SEND_RA 0 +#define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_REACHABLE_TIME 600000 #define UIP_CONF_ND6_RETRANS_TIMER 10000 diff --git a/platform/guhRF/contiki-main.c b/platform/osd-merkur-256/contiki-main.c similarity index 99% rename from platform/guhRF/contiki-main.c rename to platform/osd-merkur-256/contiki-main.c index 1b12f3da5..420871524 100644 --- a/platform/guhRF/contiki-main.c +++ b/platform/osd-merkur-256/contiki-main.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -144,7 +143,8 @@ FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,}; #include "lib/sensors.h" #include "dev/button-sensor.h" #include "dev/battery-sensor.h" - +#include "dev/pir-sensor.h" +SENSORS(&button_sensor, &pir_sensor); uint8_t rng_get_uint8(void) { @@ -185,14 +185,12 @@ void initialize(void) /* Generic or slip connection on uart0 */ rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); - /* Second rs232 port for debugging or slip alternative */ // rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); /* Redirect stdout */ rs232_redirect_stdout(RS232_PORT_0); - clock_init(); if(MCUSR & (1< - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define suli_delay_ms(ms) clock_delay_msec(ms) -#define suli_delay_us(us) clock_delay_usec(us) - -/* These are used by Suli */ -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef int16_t int16; -typedef int32_t int32; - -typedef int IO_T; // IO type -typedef int PIN_T; // pin name -typedef int DIR_T; // pin direction - -/* From Arduino.h */ -#define HAL_PIN_INPUT INPUT -#define HAL_PIN_OUTPUT OUTPUT -#define HAL_PIN_HIGH HIGH -#define HAL_PIN_LOW LOW - -static inline void suli_pin_init (IO_T *pio, PIN_T pin) -{ - *pio = pin; -} - -static inline void suli_pin_dir (IO_T *pio, DIR_T dir) -{ - pinMode (*pio, dir); -} - -static inline void suli_pin_write (IO_T *pio, int16 state) -{ - digitalWrite (*pio, state); -} - -static inline int16 suli_pin_read (IO_T *pio) -{ - return digitalRead (*pio); -} - -#ifdef __cplusplus -} // extern "C" -#endif - -/* - * VI settings, see coding style - * ex:ts=8:et:sw=2 - */ - -/** @} */ diff --git a/platform/osd-merkur/dev/adc.c b/platform/osd-merkur/dev/adc.c deleted file mode 100644 index 7efde72e1..000000000 --- a/platform/osd-merkur/dev/adc.c +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright (c) 2012, BinaryLabs. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: adc.c,v 1.1 2010/08/25 19:34:06 nifi Exp $ -*/ - -/** -* \file -* ADC file for Atmega128rfa1. -* \author -* Paulo Louro -*/ - -#include "adc.h" - -static uint8_t analog_reference = ADC_DEFAULT; - -/* - * For arduino interface for setting external reference voltage - * Note that applying an external voltage *and* then setting the analog - * reference to something internal will short the internal and the - * external reference voltage and most likely destroy the processor. - */ -void analogReference(uint8_t mode) -{ - analog_reference = mode; -} - -int readADC(uint8_t pin) -{ - int result = 0; - - adc_setup (analog_reference, pin); - result = adc_read (); - adc_fin (); - return result; -} - -/** -* \return Internal temperature in 0.01C, e.g. 25C is 2500 -*/ -int readInternalTemp(void) -{ - int reading = 0; - - ADCSRB |= _BV(MUX5); - ADMUX = _BV(REFS1) | _BV(REFS0) | 0b1001 ; - ADCSRA = _BV(ADEN) | _BV(ADPS0) | _BV(ADPS2) ; - - ADCSRA |= 1 << ADSC; - loop_until_bit_is_clear(ADCSRA,ADSC); - reading = ADC; - - ADCSRB=0; //disable ADC, need to write B first for MUX5 bit - ADCSRA=0; //disable ADC - ADMUX=0; //turn off internal vref - - return reading * 113 - 27280; -} diff --git a/platform/osd-merkur/dev/adc.h b/platform/osd-merkur/dev/adc.h deleted file mode 100644 index e3ff516b1..000000000 --- a/platform/osd-merkur/dev/adc.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __ADC_ARCH_H__ -#define __ADC_ARCH_H__ - -#include - -/* - * Reference voltage - * The default is 1.6V reference voltage - * The selected reference voltage is the maximum voltage that can be - * measured. - * Directly provide shifted variants so we don't need to shift. - */ -#define ADC_1_5 (2<<6) -#define ADC_1_6 (3<<6) -#define ADC_1_8 (1<<6) -#define ADC_EXTERNAL (0<<6) -#define ADC_DEFAULT ADC_1_6 - -/* sometimes it's desirable to decouple setup / finish from sampling */ - -static inline void adc_setup (uint8_t ref_volt, uint8_t pin) -{ - ADMUX = ref_volt | (pin & 0x7); - ADCSRA = _BV(ADEN) | _BV(ADPS0) | _BV(ADPS2); -} - -static inline int adc_read (void) -{ - ADCSRA |= (1 << ADSC); - loop_until_bit_is_clear (ADCSRA, ADSC); - return ADC; -} - -static inline void adc_fin (void) -{ - ADCSRA = 0; - ADMUX = 0; -} - -static inline void adc_init (void) -{ - uint8_t temp; - ADCSRC = 0; - ADCSRB = 0; - adc_fin (); - /* - * Disable JTAG interface - * Hardware manual about JTD bit: - * "In order to avoid unintentional disabling or enabling of the - * JTAG interface, a timed sequence must be followed when changing - * this bit: The application software must write this bit to the - * desired value twice within four cycles to change its value." - * 15.4.1 "MCUCR - MCU Control Register", p. 219 - */ - temp = MCUCR | (1 << JTD); - MCUCR = temp; - MCUCR = temp; -} - -int readADC(uint8_t pin); -long readVcc(); -int readInternalTemp(void); -void analogReference(uint8_t mode); - -#endif /* __ADC_ARCH_H__ */ diff --git a/platform/osd-merkur/dev/arduino/Arduino.h b/platform/osd-merkur/dev/arduino/Arduino.h deleted file mode 100644 index e0ea47b10..000000000 --- a/platform/osd-merkur/dev/arduino/Arduino.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef Arduino_h -#define Arduino_h - -#include -#include -#include -#include - -#include -#include -#include - -#include "binary.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -#define HIGH 0x1 -#define LOW 0x0 - -#define INPUT 0x0 -#define OUTPUT 0x1 -#define INPUT_PULLUP 0x2 - -#define true 0x1 -#define false 0x0 - -#define PI 3.1415926535897932384626433832795 -#define HALF_PI 1.5707963267948966192313216916398 -#define TWO_PI 6.283185307179586476925286766559 -#define DEG_TO_RAD 0.017453292519943295769236907684886 -#define RAD_TO_DEG 57.295779513082320876798154814105 - -#define SERIAL 0x0 -#define DISPLAY 0x1 - -#define LSBFIRST 0 -#define MSBFIRST 1 - -#define CHANGE 1 -#define FALLING 2 -#define RISING 3 - -#define DEFAULT ADC_DEFAULT -#define EXTERNAL ADC_EXTERNAL - -// undefine stdlib's abs if encountered -#ifdef abs -#undef abs -#endif - -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#define abs(x) ((x)>0?(x):-(x)) -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) - -#define interrupts() sei() -#define noInterrupts() cli() - -#define lowByte(w) ((uint8_t) ((w) & 0xff)) -#define highByte(w) ((uint8_t) ((w) >> 8)) - -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) - - -typedef unsigned int word; - -#define bit(b) (1UL << (b)) - -typedef uint8_t boolean; -typedef uint8_t byte; - -void pinMode(uint8_t, uint8_t); -void digitalWrite(uint8_t, uint8_t); -int digitalRead(uint8_t); - -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); - -void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); -uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); - -void attachInterrupt(uint8_t, void (*)(void), int mode); -void detachInterrupt(uint8_t); - -void setup(void); -void loop(void); - -// Get the bit location within the hardware port of the given virtual pin. -// This comes from the pins_*.c file for the active board configuration. - -#define analogInPinToBit(P) (P) - -// On the ATmega1280, the addresses of some of the port registers are -// greater than 255, so we can't store them in uint8_t's. -extern const uint16_t PROGMEM port_to_mode_PGM[]; -extern const uint16_t PROGMEM port_to_input_PGM[]; -extern const uint16_t PROGMEM port_to_output_PGM[]; - -extern const uint8_t PROGMEM digital_pin_to_port_PGM[]; -// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[]; -extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[]; - -// Get the bit location within the hardware port of the given virtual pin. -// This comes from the pins_*.c file for the active board configuration. -// -// These perform slightly better as macros compared to inline functions -// -#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) -#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) -#define analogInPinToBit(P) (P) -#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) -#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) -#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) - -#define NOT_A_PIN 0 -#define NOT_A_PORT 0 - -#ifdef ARDUINO_MAIN -#define PA 1 -#define PB 2 -#define PC 3 -#define PD 4 -#define PE 5 -#define PF 6 -#define PG 7 -#define PH 8 -#define PJ 10 -#define PK 11 -#define PL 12 -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#ifdef __cplusplus -// look at this again when considering implementing serial -//#include "WCharacter.h" -//#include "WString.h" -//#include "HardwareSerial.h" - -uint16_t makeWord(uint16_t w); -uint16_t makeWord(byte h, byte l); - -#define word(...) makeWord(__VA_ARGS__) - -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); - -void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); -void noTone(uint8_t _pin); - -// WMath prototypes -long random(long); -long random(long, long); -void randomSeed(unsigned int); -long map(long, long, long, long, long); - -#endif - -#include "pins_arduino.h" - -#include "dev/arduino/arduino-compat.h" - -#endif diff --git a/platform/osd-merkur/dev/arduino/hw-arduino.h b/platform/osd-merkur/dev/arduino/hw-arduino.h deleted file mode 100644 index bcd626ec6..000000000 --- a/platform/osd-merkur/dev/arduino/hw-arduino.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2014, Ralf Schlatterbeck Open Source Consulting - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ - -/** - * \defgroup compatibility Arduino - Contiki - * - * This defines contiki-compatible hardware definitions for running - * arduino sketches (or just to call arduino-compatible function). - * For now only for osd hardware, a similar file should exist for each - * arduino-compatible hardware. - * - * @{ - */ - -/** - * \file - * Header file for arduino compatibility - * \author - * Ralf Schlatterbeck - * - */ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include "contiki.h" - -/* - * The OSD hardware only supports timer 3 for PWM, timer 2 is used by - * contiki for sleep/wakeup timing and is not usable for PWM. - */ -#define digitalPinToTimer(pin) \ - ( (pin) == 2 \ - ? TIMER3A \ - : ( (pin) == 3 \ - ? TIMER3B \ - : ((pin == 4) ? TIMER3C : NOT_ON_TIMER) \ - ) \ - ) - -/* Only init timer 3 with phase correct pwm 8-bit and prescaler 64 */ -#define arduino_pwm_timer_init() \ - (hwtimer_ini (3, HWT_WGM_PWM_PHASE_8_BIT, HWT_CLOCK_PRESCALER_64, 0)) - -/* - * VI settings, see coding style - * ex:ts=8:et:sw=2 - */ - -#ifdef __cplusplus -} // extern "C" -#endif - -/** @} */ diff --git a/platform/osd-merkur/dev/arduino/wiring_digital.c b/platform/osd-merkur/dev/arduino/wiring_digital.c deleted file mode 100644 index 75b6745d6..000000000 --- a/platform/osd-merkur/dev/arduino/wiring_digital.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - wiring_digital.c - digital input and output functions - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - Modified 28 September 2010 by Mark Sproul - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ -*/ - -#define ARDUINO_MAIN -#include "wiring_private.h" -#include "pins_arduino.h" - -void pinMode(uint8_t pin, uint8_t mode) -{ - uint8_t bit = digitalPinToBitMask(pin); - uint8_t port = digitalPinToPort(pin); - volatile uint8_t *reg, *out; - - if (port == NOT_A_PIN) return; - - // JWS: can I let the optimizer do this? - reg = portModeRegister(port); - out = portOutputRegister(port); - - if (mode == INPUT) { - uint8_t oldSREG = SREG; - cli(); - *reg &= ~bit; - *out &= ~bit; - SREG = oldSREG; - } else if (mode == INPUT_PULLUP) { - uint8_t oldSREG = SREG; - cli(); - *reg &= ~bit; - *out |= bit; - SREG = oldSREG; - } else { - uint8_t oldSREG = SREG; - cli(); - *reg |= bit; - SREG = oldSREG; - } -} - -void digitalWrite(uint8_t pin, uint8_t val) -{ - uint8_t timer = digitalPinToTimer(pin); - uint8_t bit = digitalPinToBitMask(pin); - uint8_t port = digitalPinToPort(pin); - volatile uint8_t *out; - - if (port == NOT_A_PIN) return; - - // If the pin that support PWM output, we need to turn it off - // before doing a digital write. - if (timer != NOT_ON_TIMER) turnOffPWM(timer); - - out = portOutputRegister(port); - - uint8_t oldSREG = SREG; - cli(); - - if (val == LOW) { - *out &= ~bit; - } else { - *out |= bit; - } - - SREG = oldSREG; -} - -int digitalRead(uint8_t pin) -{ - uint8_t timer = digitalPinToTimer(pin); - uint8_t bit = digitalPinToBitMask(pin); - uint8_t port = digitalPinToPort(pin); - - if (port == NOT_A_PIN) return LOW; - - // If the pin that support PWM output, we need to turn it off - // before getting a digital reading. - if (timer != NOT_ON_TIMER) turnOffPWM(timer); - - if (*portInputRegister(port) & bit) return HIGH; - return LOW; -} diff --git a/platform/osd-merkur/dev/batmon.c b/platform/osd-merkur/dev/batmon.c deleted file mode 100644 index 5c61d125f..000000000 --- a/platform/osd-merkur/dev/batmon.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "contiki.h" -#include "batmon.h" -#include - - - - -int8_t batmon_init() -{ - return 0; -} - -int8_t batmon_get_voltage(uint16_t* voltage) -{ - uint16_t volt = 0; - uint16_t resolution = 75; - uint16_t offset = 2550; - int8_t ctr = 0; - - BATMON = 0 | _BV(BATMON_HR); - _delay_us(2); - - if(BATMON & _BV(BATMON_OK)) - { - // voltage above 2.550 V - resolution = 75; - offset = 2550; - for(ctr=15; ctr>=0; ctr--) - { - BATMON = (BATMON & 0xF0) | (ctr); - _delay_us(2); - if(BATMON & _BV(BATMON_OK)) break; - } - } - else - { - // voltage below 2.550 V - resolution = 50; - offset = 1700; - - BATMON &= ~_BV(BATMON_HR); - - for(ctr=15; ctr>=0; ctr--) - { - BATMON = (BATMON & 0xF0) | (ctr); - _delay_us(2); - if(BATMON & _BV(BATMON_OK)) break; - } - } - - volt = resolution*ctr+offset; - *voltage=volt; - - return 0; -} diff --git a/platform/osd-merkur/dev/batmon.h b/platform/osd-merkur/dev/batmon.h deleted file mode 100644 index c05f48200..000000000 --- a/platform/osd-merkur/dev/batmon.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef BATMON_H_ -#define BATMON_H_ - -int8_t batmon_init(); -int8_t batmon_get_voltage(uint16_t* voltage); - - -#endif /* BATMON_H_ */ diff --git a/platform/osd-merkur/dev/battery-sensor.c b/platform/osd-merkur/dev/battery-sensor.c deleted file mode 100644 index 1eb7906b4..000000000 --- a/platform/osd-merkur/dev/battery-sensor.c +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright (c) 2012, BinaryLabs. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: battery-sensor.h,v 1.1 2012/08/25 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Battery sensor file for Atmega128rfa1. -* \author -* Paulo Louro -* Harald Pichler -*/ - -/** -*The atmel rf23x radios have a low voltage detector that can be configured in units of 75 millivolts. Here is example *code for the ATmega128rfa1, where the BATMON register is in extended io space [dak664] -*/ - -#include "dev/battery-sensor.h" -#include "dev/batmon.h" - -const struct sensors_sensor battery_sensor; -/*---------------------------------------------------------------------------*/ - -/** -* \return Voltage on battery measurement with BATMON register. -*/ -static int -value(int type) -{ - - uint16_t h; -/* - uint8_t p1; - BATMON = 16; //give BATMON time to stabilize at highest range and lowest voltage - -// Bandgap can't be measured against supply voltage in this chip. -// Use BATMON register instead - for ( p1=16; p1<31; p1++) { - BATMON = p1; - clock_delay_usec(100); // delay needed !! - if ((BATMON&(1< -*/ - -#ifndef __BATTERY_SENSOR_H__ -#define __BATTERY_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor battery_sensor; - -#define BATTERY_SENSOR "Battery" - -#endif /* __BATTERY_SENSOR_H__ */ \ No newline at end of file diff --git a/platform/osd-merkur/dev/binary.h b/platform/osd-merkur/dev/binary.h deleted file mode 100644 index af1498033..000000000 --- a/platform/osd-merkur/dev/binary.h +++ /dev/null @@ -1,515 +0,0 @@ -#ifndef Binary_h -#define Binary_h - -#define B0 0 -#define B00 0 -#define B000 0 -#define B0000 0 -#define B00000 0 -#define B000000 0 -#define B0000000 0 -#define B00000000 0 -#define B1 1 -#define B01 1 -#define B001 1 -#define B0001 1 -#define B00001 1 -#define B000001 1 -#define B0000001 1 -#define B00000001 1 -#define B10 2 -#define B010 2 -#define B0010 2 -#define B00010 2 -#define B000010 2 -#define B0000010 2 -#define B00000010 2 -#define B11 3 -#define B011 3 -#define B0011 3 -#define B00011 3 -#define B000011 3 -#define B0000011 3 -#define B00000011 3 -#define B100 4 -#define B0100 4 -#define B00100 4 -#define B000100 4 -#define B0000100 4 -#define B00000100 4 -#define B101 5 -#define B0101 5 -#define B00101 5 -#define B000101 5 -#define B0000101 5 -#define B00000101 5 -#define B110 6 -#define B0110 6 -#define B00110 6 -#define B000110 6 -#define B0000110 6 -#define B00000110 6 -#define B111 7 -#define B0111 7 -#define B00111 7 -#define B000111 7 -#define B0000111 7 -#define B00000111 7 -#define B1000 8 -#define B01000 8 -#define B001000 8 -#define B0001000 8 -#define B00001000 8 -#define B1001 9 -#define B01001 9 -#define B001001 9 -#define B0001001 9 -#define B00001001 9 -#define B1010 10 -#define B01010 10 -#define B001010 10 -#define B0001010 10 -#define B00001010 10 -#define B1011 11 -#define B01011 11 -#define B001011 11 -#define B0001011 11 -#define B00001011 11 -#define B1100 12 -#define B01100 12 -#define B001100 12 -#define B0001100 12 -#define B00001100 12 -#define B1101 13 -#define B01101 13 -#define B001101 13 -#define B0001101 13 -#define B00001101 13 -#define B1110 14 -#define B01110 14 -#define B001110 14 -#define B0001110 14 -#define B00001110 14 -#define B1111 15 -#define B01111 15 -#define B001111 15 -#define B0001111 15 -#define B00001111 15 -#define B10000 16 -#define B010000 16 -#define B0010000 16 -#define B00010000 16 -#define B10001 17 -#define B010001 17 -#define B0010001 17 -#define B00010001 17 -#define B10010 18 -#define B010010 18 -#define B0010010 18 -#define B00010010 18 -#define B10011 19 -#define B010011 19 -#define B0010011 19 -#define B00010011 19 -#define B10100 20 -#define B010100 20 -#define B0010100 20 -#define B00010100 20 -#define B10101 21 -#define B010101 21 -#define B0010101 21 -#define B00010101 21 -#define B10110 22 -#define B010110 22 -#define B0010110 22 -#define B00010110 22 -#define B10111 23 -#define B010111 23 -#define B0010111 23 -#define B00010111 23 -#define B11000 24 -#define B011000 24 -#define B0011000 24 -#define B00011000 24 -#define B11001 25 -#define B011001 25 -#define B0011001 25 -#define B00011001 25 -#define B11010 26 -#define B011010 26 -#define B0011010 26 -#define B00011010 26 -#define B11011 27 -#define B011011 27 -#define B0011011 27 -#define B00011011 27 -#define B11100 28 -#define B011100 28 -#define B0011100 28 -#define B00011100 28 -#define B11101 29 -#define B011101 29 -#define B0011101 29 -#define B00011101 29 -#define B11110 30 -#define B011110 30 -#define B0011110 30 -#define B00011110 30 -#define B11111 31 -#define B011111 31 -#define B0011111 31 -#define B00011111 31 -#define B100000 32 -#define B0100000 32 -#define B00100000 32 -#define B100001 33 -#define B0100001 33 -#define B00100001 33 -#define B100010 34 -#define B0100010 34 -#define B00100010 34 -#define B100011 35 -#define B0100011 35 -#define B00100011 35 -#define B100100 36 -#define B0100100 36 -#define B00100100 36 -#define B100101 37 -#define B0100101 37 -#define B00100101 37 -#define B100110 38 -#define B0100110 38 -#define B00100110 38 -#define B100111 39 -#define B0100111 39 -#define B00100111 39 -#define B101000 40 -#define B0101000 40 -#define B00101000 40 -#define B101001 41 -#define B0101001 41 -#define B00101001 41 -#define B101010 42 -#define B0101010 42 -#define B00101010 42 -#define B101011 43 -#define B0101011 43 -#define B00101011 43 -#define B101100 44 -#define B0101100 44 -#define B00101100 44 -#define B101101 45 -#define B0101101 45 -#define B00101101 45 -#define B101110 46 -#define B0101110 46 -#define B00101110 46 -#define B101111 47 -#define B0101111 47 -#define B00101111 47 -#define B110000 48 -#define B0110000 48 -#define B00110000 48 -#define B110001 49 -#define B0110001 49 -#define B00110001 49 -#define B110010 50 -#define B0110010 50 -#define B00110010 50 -#define B110011 51 -#define B0110011 51 -#define B00110011 51 -#define B110100 52 -#define B0110100 52 -#define B00110100 52 -#define B110101 53 -#define B0110101 53 -#define B00110101 53 -#define B110110 54 -#define B0110110 54 -#define B00110110 54 -#define B110111 55 -#define B0110111 55 -#define B00110111 55 -#define B111000 56 -#define B0111000 56 -#define B00111000 56 -#define B111001 57 -#define B0111001 57 -#define B00111001 57 -#define B111010 58 -#define B0111010 58 -#define B00111010 58 -#define B111011 59 -#define B0111011 59 -#define B00111011 59 -#define B111100 60 -#define B0111100 60 -#define B00111100 60 -#define B111101 61 -#define B0111101 61 -#define B00111101 61 -#define B111110 62 -#define B0111110 62 -#define B00111110 62 -#define B111111 63 -#define B0111111 63 -#define B00111111 63 -#define B1000000 64 -#define B01000000 64 -#define B1000001 65 -#define B01000001 65 -#define B1000010 66 -#define B01000010 66 -#define B1000011 67 -#define B01000011 67 -#define B1000100 68 -#define B01000100 68 -#define B1000101 69 -#define B01000101 69 -#define B1000110 70 -#define B01000110 70 -#define B1000111 71 -#define B01000111 71 -#define B1001000 72 -#define B01001000 72 -#define B1001001 73 -#define B01001001 73 -#define B1001010 74 -#define B01001010 74 -#define B1001011 75 -#define B01001011 75 -#define B1001100 76 -#define B01001100 76 -#define B1001101 77 -#define B01001101 77 -#define B1001110 78 -#define B01001110 78 -#define B1001111 79 -#define B01001111 79 -#define B1010000 80 -#define B01010000 80 -#define B1010001 81 -#define B01010001 81 -#define B1010010 82 -#define B01010010 82 -#define B1010011 83 -#define B01010011 83 -#define B1010100 84 -#define B01010100 84 -#define B1010101 85 -#define B01010101 85 -#define B1010110 86 -#define B01010110 86 -#define B1010111 87 -#define B01010111 87 -#define B1011000 88 -#define B01011000 88 -#define B1011001 89 -#define B01011001 89 -#define B1011010 90 -#define B01011010 90 -#define B1011011 91 -#define B01011011 91 -#define B1011100 92 -#define B01011100 92 -#define B1011101 93 -#define B01011101 93 -#define B1011110 94 -#define B01011110 94 -#define B1011111 95 -#define B01011111 95 -#define B1100000 96 -#define B01100000 96 -#define B1100001 97 -#define B01100001 97 -#define B1100010 98 -#define B01100010 98 -#define B1100011 99 -#define B01100011 99 -#define B1100100 100 -#define B01100100 100 -#define B1100101 101 -#define B01100101 101 -#define B1100110 102 -#define B01100110 102 -#define B1100111 103 -#define B01100111 103 -#define B1101000 104 -#define B01101000 104 -#define B1101001 105 -#define B01101001 105 -#define B1101010 106 -#define B01101010 106 -#define B1101011 107 -#define B01101011 107 -#define B1101100 108 -#define B01101100 108 -#define B1101101 109 -#define B01101101 109 -#define B1101110 110 -#define B01101110 110 -#define B1101111 111 -#define B01101111 111 -#define B1110000 112 -#define B01110000 112 -#define B1110001 113 -#define B01110001 113 -#define B1110010 114 -#define B01110010 114 -#define B1110011 115 -#define B01110011 115 -#define B1110100 116 -#define B01110100 116 -#define B1110101 117 -#define B01110101 117 -#define B1110110 118 -#define B01110110 118 -#define B1110111 119 -#define B01110111 119 -#define B1111000 120 -#define B01111000 120 -#define B1111001 121 -#define B01111001 121 -#define B1111010 122 -#define B01111010 122 -#define B1111011 123 -#define B01111011 123 -#define B1111100 124 -#define B01111100 124 -#define B1111101 125 -#define B01111101 125 -#define B1111110 126 -#define B01111110 126 -#define B1111111 127 -#define B01111111 127 -#define B10000000 128 -#define B10000001 129 -#define B10000010 130 -#define B10000011 131 -#define B10000100 132 -#define B10000101 133 -#define B10000110 134 -#define B10000111 135 -#define B10001000 136 -#define B10001001 137 -#define B10001010 138 -#define B10001011 139 -#define B10001100 140 -#define B10001101 141 -#define B10001110 142 -#define B10001111 143 -#define B10010000 144 -#define B10010001 145 -#define B10010010 146 -#define B10010011 147 -#define B10010100 148 -#define B10010101 149 -#define B10010110 150 -#define B10010111 151 -#define B10011000 152 -#define B10011001 153 -#define B10011010 154 -#define B10011011 155 -#define B10011100 156 -#define B10011101 157 -#define B10011110 158 -#define B10011111 159 -#define B10100000 160 -#define B10100001 161 -#define B10100010 162 -#define B10100011 163 -#define B10100100 164 -#define B10100101 165 -#define B10100110 166 -#define B10100111 167 -#define B10101000 168 -#define B10101001 169 -#define B10101010 170 -#define B10101011 171 -#define B10101100 172 -#define B10101101 173 -#define B10101110 174 -#define B10101111 175 -#define B10110000 176 -#define B10110001 177 -#define B10110010 178 -#define B10110011 179 -#define B10110100 180 -#define B10110101 181 -#define B10110110 182 -#define B10110111 183 -#define B10111000 184 -#define B10111001 185 -#define B10111010 186 -#define B10111011 187 -#define B10111100 188 -#define B10111101 189 -#define B10111110 190 -#define B10111111 191 -#define B11000000 192 -#define B11000001 193 -#define B11000010 194 -#define B11000011 195 -#define B11000100 196 -#define B11000101 197 -#define B11000110 198 -#define B11000111 199 -#define B11001000 200 -#define B11001001 201 -#define B11001010 202 -#define B11001011 203 -#define B11001100 204 -#define B11001101 205 -#define B11001110 206 -#define B11001111 207 -#define B11010000 208 -#define B11010001 209 -#define B11010010 210 -#define B11010011 211 -#define B11010100 212 -#define B11010101 213 -#define B11010110 214 -#define B11010111 215 -#define B11011000 216 -#define B11011001 217 -#define B11011010 218 -#define B11011011 219 -#define B11011100 220 -#define B11011101 221 -#define B11011110 222 -#define B11011111 223 -#define B11100000 224 -#define B11100001 225 -#define B11100010 226 -#define B11100011 227 -#define B11100100 228 -#define B11100101 229 -#define B11100110 230 -#define B11100111 231 -#define B11101000 232 -#define B11101001 233 -#define B11101010 234 -#define B11101011 235 -#define B11101100 236 -#define B11101101 237 -#define B11101110 238 -#define B11101111 239 -#define B11110000 240 -#define B11110001 241 -#define B11110010 242 -#define B11110011 243 -#define B11110100 244 -#define B11110101 245 -#define B11110110 246 -#define B11110111 247 -#define B11111000 248 -#define B11111001 249 -#define B11111010 250 -#define B11111011 251 -#define B11111100 252 -#define B11111101 253 -#define B11111110 254 -#define B11111111 255 - -#endif diff --git a/platform/osd-merkur/dev/dht11.c b/platform/osd-merkur/dev/dht11.c deleted file mode 100644 index 39e1a7701..000000000 --- a/platform/osd-merkur/dev/dht11.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - DHT-11 Library - (c) Created by Charalampos Andrianakis on 18/12/11. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -#include -#include "contiki.h" -#include "dht11.h" -#include "led.h" // debug - -#define udelay(u) clock_delay_usec(u) -#define mdelay(u) clock_delay_msec(u) - -// todo: set DHT22 or DHT11 in project file -// define for DHT11 else for DHT22, RHT03 -// #define DHT11 1 - -uint8_t DHT_Read_Data(uint16_t *temperature, uint16_t *humidity){ - - //data[5] is 8byte table where data come from DHT are stored - //laststate holds laststate value - //counter is used to count microSeconds - uint8_t data[5], laststate = 0, counter = 0, j = 0, i = 0; - - //Clear array - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - uint8_t volatile sreg; - sreg = SREG; /* Save status register before disabling interrupts. */ - cli(); /* Disable interrupts. */ - - //Set pin Output - //Pin High - DHT_DRIVE(); - mdelay(100); //Wait for 100mS - - //Send Request Signal - //Pin Low - OUTP_0(); //20ms Low - mdelay(20); - //Pin High - OUTP_1(); - udelay(40); //40us High - - //Set pin Input to read Bus - //Set pin Input - DHT_RELEASE(); - laststate=DHT_INP(); //Read Pin value - - //Repeat for each Transistions - for (i=0; i254) break; - } - - if (counter>254) break; - - //laststate==_BV(DHT_PIN) checks if laststate was High - //ignore the first 2 transitions which are the DHT Response - //if (laststate==_BV(DHT_PIN) && (i > 2)) { - if ((i&0x01) && (i > 2)) { - //Save bits in segments of bytes - //Shift data[] value 1 position left - //Example. 01010100 if we shift it left one time it will be - //10101000 - - data[j/8]<<=1; - if (counter >= 15) { //If it was high for more than 40uS - //led1_on(); - data[j/8]|=1; //it means it is bit '1' so make a logic - //led1_off(); - } //OR with the value (save it) - j++; //making an OR by 1 to this value 10101000 - } //we will have the resault 10101001 - //1 in 8-bit binary is 00000001 - //j/8 changes table record every 8 bits which means a byte has been saved - //so change to next record. 0/8=0 1/8=0 ... 7/8=0 8/8=1 ... 15/8=1 16/8=2 - laststate=DHT_INP(); //save current state - counter=0; //reset counter - - } - SREG = sreg; /* Enable interrupts. */ - //printf("HUM %d %d %d %d %d %d",data[0],data[1],data[2],data[3],data[4],(uint8_t)(data[0] + data[1] + data[2] + data[3]) ); - //Check if data received are correct by checking the CheckSum - if ((uint8_t)(data[0] + data[1] + data[2] + data[3]) == data[4]) { -#ifdef DHT11 - *humidity = data[0]*100; - *temperature = data[2]*100; -#else - *humidity = ((uint16_t)data[0]<<8 | data[1])*10; - *temperature = ((uint16_t)data[2]<<8 | data[3])*10; -#endif - return 0; - }else{ - *humidity = 2; - *temperature = 2; -// uart_puts("\r\nCheck Sum Error"); - } - - return 0xff; // Check Sum Error -} diff --git a/platform/osd-merkur/dev/dht11.h b/platform/osd-merkur/dev/dht11.h deleted file mode 100644 index 6cf757e5d..000000000 --- a/platform/osd-merkur/dev/dht11.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - DHT-11 Library - (c) Created by Charalampos Andrianakis on 18/12/11. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -#include -#include -#include - -/* DHT 1-wire is at PortE.6 */ -#define DHT_PIN_READ PINE -#define DHT_PIN_MASK _BV(PE6) -#define DHT_PxOUT PORTE -#define DHT_PxDIR DDRE - -#define SET_PIN_INPUT() (DHT_PxDIR &= ~DHT_PIN_MASK) -#define SET_PIN_OUTPUT() (DHT_PxDIR |= DHT_PIN_MASK) - -#define OUTP_0() (DHT_PxOUT &= ~DHT_PIN_MASK) -#define OUTP_1() (DHT_PxOUT |= DHT_PIN_MASK) - -#define PIN_INIT() do{ \ - SET_PIN_INPUT(); \ - OUTP_0(); \ - } while(0) - - -/* Drive the one wire interface hight */ -#define DHT_DRIVE() do { \ - SET_PIN_OUTPUT(); \ - OUTP_1(); \ - } while (0) - -/* Release the one wire by turning on the internal pull-up. */ -#define DHT_RELEASE() do { \ - SET_PIN_INPUT(); \ - OUTP_1(); \ - } while (0) - -/* Read one bit. */ -#define DHT_INP() (DHT_PIN_READ & DHT_PIN_MASK) - -//The packet size is 40bit but each bit consists of low and high state -//so 40 x 2 = 80 transitions. Also we have 2 transistions DHT response -//and 2 transitions which indicates End Of Frame. In total 84 -#define MAXTIMINGS 84 - -//This is the main function which requests and reads the packet -uint8_t DHT_Read_Data(uint16_t *temperature, uint16_t *humidity); diff --git a/platform/osd-merkur/dev/ds1820.c b/platform/osd-merkur/dev/ds1820.c deleted file mode 100644 index 9de3fc8a9..000000000 --- a/platform/osd-merkur/dev/ds1820.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$Id: ds1820.c,v 1.5 2010/08/25 18:35:52 nifi Exp $ - */ -/* - * Device driver for the Dallas Semiconductor DS1820 chip. Heavily - * based on the application note 126 "1-Wire Communications Through - * Software". - * - * http://www.maxim-ic.com/appnotes.cfm/appnote_number/126 - */ - -/* - * For now we stuff in Moteiv Corporation's unique OUI. - * From http://www.ethereal.com/distribution/manuf.txt: - * 00:12:75 Moteiv # Moteiv Corporation - * - * The EUI-64 is a concatenation of the 24-bit OUI value assigned by - * the IEEE Registration Authority and a 40-bit extension identifier - * assigned by the organization with that OUI assignment. - */ - -#include -#include -#include "contiki.h" -#include "ds1820.h" - - -unsigned char ds1820_id[8]; -unsigned char ds1820_ok[8]; - -/* 1-wire is at PortE.3 */ -#define SERIAL_ID_PIN_READ PINE -//#define SERIAL_ID_PIN_MASK _BV(PE3) -#define SERIAL_ID_PIN_MASK _BV(PE4) -#define SERIAL_ID_PxOUT PORTE -#define SERIAL_ID_PxDIR DDRE - -#define SET_PIN_INPUT() (SERIAL_ID_PxDIR &= ~SERIAL_ID_PIN_MASK) -#define SET_PIN_OUTPUT() (SERIAL_ID_PxDIR |= SERIAL_ID_PIN_MASK) - -#define OUTP_0() (SERIAL_ID_PxOUT &= ~SERIAL_ID_PIN_MASK) -#define OUTP_1() (SERIAL_ID_PxOUT |= SERIAL_ID_PIN_MASK) - -#define PIN_INIT() do{ \ - SET_PIN_INPUT(); \ - OUTP_0(); \ - } while(0) - - -/* Drive the one wire interface low */ -#define OW_DRIVE() do { \ - SET_PIN_OUTPUT(); \ - OUTP_0(); \ - } while (0) - -/* Release the one wire by turning on the internal pull-up. */ -#define OW_RELEASE() do { \ - SET_PIN_INPUT(); \ - OUTP_1(); \ - } while (0) - -/* Read one bit. */ -#define INP() (SERIAL_ID_PIN_READ & SERIAL_ID_PIN_MASK) - - -/* - * Delay times in us. - */ -#define tA 6 /* min-5, recommended-6, max-15 */ -#define tB 64 /* min-59, recommended-64, max-N/A */ -#define tC 60 /* min-60, recommended-60, max-120 */ -#define tD 10 /* min-5.3, recommended-10, max-N/A */ -#define tE 9 /* min-0.3, recommended-9, max-9.3 */ -#define tF 55 /* min-50, recommended-55, max-N/A */ -#define tG 0 /* min-0, recommended-0, max-0 */ -#define tH 480 /* min-480, recommended-480, max-640 */ -#define tI 70 /* min-60.3, recommended-70, max-75.3 */ -#define tJ 410 /* min-410, recommended-410, max-N/A */ -/*---------------------------------------------------------------------------*/ -#define udelay(u) clock_delay_usec(u) -/*---------------------------------------------------------------------------*/ - -static int -owreset(void) -{ - int result; - - OW_DRIVE(); - udelay(tH); /* 480 < tH < 640 */ - OW_RELEASE(); /* Releases the bus */ - udelay(tI); - result = INP(); - udelay(tJ); - return result; -} -/*---------------------------------------------------------------------------*/ -static void -owwriteb(unsigned byte) -{ - int i = 7; - - do { - if(byte & 0x01) { - OW_DRIVE(); - udelay(tA); - OW_RELEASE(); /* Releases the bus */ - udelay(tB); - } else { - OW_DRIVE(); - udelay(tC); - OW_RELEASE(); /* Releases the bus */ - udelay(tD); - } - if(i == 0) { - return; - } - i--; - byte >>= 1; - } while(1); -} -/*---------------------------------------------------------------------------*/ -static unsigned -owreadb(void) -{ - unsigned result = 0; - int i = 7; - - do { - OW_DRIVE(); - udelay(tA); - OW_RELEASE(); /* Releases the bus */ - udelay(tE); - if (INP()){ - result |= 0x80; /* LSbit first */ - } - udelay(tF); - if(i == 0) { - return result; - } - i--; - result >>= 1; - } while(1); -} -/*---------------------------------------------------------------------------*/ -/* Polynomial ^8 + ^5 + ^4 + 1 */ -static unsigned -crc8_add(unsigned acc, unsigned byte) -{ - int i; - acc ^= byte; - for(i = 0; i < 8; i++) { - if(acc & 1) { - acc = (acc >> 1) ^ 0x8c; - } else { - acc >>= 1; - } - } - return acc; -} -/*---------------------------------------------------------------------------*/ -int -ds1820_init() -{ - int i; - unsigned family, crc, acc; - - PIN_INIT(); - - if(owreset() == 0) { /* Something pulled down 1-wire. */ - - owwriteb(0x33); /* Read ROM command. */ - family = owreadb(); - /* We receive 6 bytes in the reverse order, LSbyte first. */ - for(i = 7; i >= 2; i--) { - ds1820_id[i] = owreadb(); - } - crc = owreadb(); - - /* Verify family DS1820 and that CRC match. */ - if(family != 0x10) { - goto fail; - } - acc = crc8_add(0x0, family); - for(i = 7; i >= 2; i--) { - acc = crc8_add(acc, ds1820_id[i]); - } - if(acc == crc) { - ds1820_id[0] = 0x00; - ds1820_id[1] = 0x00; - ds1820_id[2] = 0x00; - return 1; /* Success! */ - } - } else { - } - - - fail: - memset(ds1820_id, 0x0, sizeof(ds1820_id)); - return 0; /* Fail! */ -} -/*---------------------------------------------------------------------------*/ -int -ds1820_temp() -{ - ds1820_convert(); -// wait max 750ms pin lo - clock_wait(CLOCK_SECOND); - ds1820_read(); - return 1; -} - -int -ds1820_convert() -{ - unsigned i; - - PIN_INIT(); - for(i=0;i<3;i++){ - if(owreset() == 0) { /* Something pulled down 1-wire. */ - owwriteb(0xCC); /* Skip ROM command. */ - owwriteb(0x44); /* Convert T command. */ - OW_RELEASE(); /* Releases the bus */ - return 1; - } else { - } - } - return 0; /* Fail! */ -} -/*---------------------------------------------------------------------------*/ -int -ds1820_read() -{ - int i; - unsigned crc, acc; - - if(owreset() == 0) { /* Something pulled down 1-wire. */ - owwriteb(0xCC); /* Skip ROM command. */ - owwriteb(0xBE); /* Read Scratchpad command. */ - /* We receive 8 bytes in the reverse order, LSbyte first. */ - for(i = 0; i < 8; i++) { - ds1820_id[i] = owreadb(); - } - crc = owreadb(); - - acc=0; - for(i = 0; i < 8; i++) { - acc = crc8_add(acc, ds1820_id[i]); - } - if(acc == crc) { - // store temp - for(i = 0; i < 8; i++) { - ds1820_ok[i]=ds1820_id[i]; - } - return 1; /* Success! */ - } else { - return 0; /* Fail! */ - } - } else { - return 0; /* Fail! */ - } - return 1; /* Fail! */ -} diff --git a/platform/osd-merkur/dev/ds1820.h b/platform/osd-merkur/dev/ds1820.h deleted file mode 100644 index e4178d63e..000000000 --- a/platform/osd-merkur/dev/ds1820.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$Id: ds1820.h,v 1.1 2006/06/17 22:41:16 adamdunkels Exp $ - */ -/* -*- C -*- */ -/* @(#)$Id: ds1820.h,v 1.1 2006/06/17 22:41:16 adamdunkels Exp $ */ - -#ifndef DS1820_H -#define DS1820_H - -extern unsigned char ds1820_id[8]; -extern unsigned char ds1820_ok[8]; -extern int ds1820_init(); -extern int ds1820_convert(); -extern int ds1820_read(); -extern int ds1820_temp(); -#endif /* DS1820_H */ diff --git a/platform/osd-merkur/dev/i2c.c b/platform/osd-merkur/dev/i2c.c deleted file mode 100644 index 0fa295849..000000000 --- a/platform/osd-merkur/dev/i2c.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 2014, Ingo Gulyas Intembsys - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - - /** - * \file - * I2C driver for ATMEGA128rfa1 - * - * \author - * Ingo Gulyas Intembsys - * office@intembsys.at - * www.intembsys.at - */ - - -#include "i2c.h" -#include "contiki-conf.h" -#include -#include -#include -#include - -#if I2C_TD != 0 -#include -#include -#include "system_mgmt.h" -#define PRINTD(FORMAT,args...) {sleep_acquire_lock(); printf_P(PSTR(FORMAT),##args); sleep_release_lock();} -#else -#define PRINTD(...) -#endif - -#if WITH_RTDEBUG == 1 -#include "rtdebug.h" -#define RTDEBUG_PUSH(x) rtdebug_push(x) -#else -#warning "I2C Driver compiling without RTDEBUG!" -#define RTDEBUG_PUSH(x) -#endif - -#ifndef TIMEOUT_TIMER -#warning "I2C Driver compiling without TIMEOUT!" -#endif - - -static int8_t wait_job(); -static int8_t wait_stop(); - -static int8_t i2c_ioctl(const i2c_driver* const me, uint8_t cmd, uint8_t arg); -static int8_t i2c_read(const i2c_driver* const me, uint8_t cmd_flags, uint8_t* buffer, uint8_t len); -static int8_t i2c_write(const i2c_driver* const me, uint8_t cmd_flags, const uint8_t* data, uint8_t len); - - -// static linkage of member functions -i2c_driver i2c_drv = {i2c_ioctl, i2c_read, i2c_write}; -// lock spi if driver opened to prevent further opening access -static volatile bool i2c_lock = false; - - -/////////////////////////////////////////////////////////////// -// global functions -/////////////////////////////////////////////////////////////// - -i2c_driver* i2c_open(void) -{ - if(i2c_lock == true) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_OPEN__DEVICE_BUSY); - return NULL; - } - - i2c_lock = true; - power_twi_enable(); - I2C_INIT(); - - TWBR = I2C_FREQ_STANDARD; - TWSR &= ~((1< 0) && (buffer == NULL)) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__ERROR_NULLPOINTER); - return I2C_ERROR_DRIVER; - } - - do - { - if(cmd_flags & I2C_CMD_FLAG_START) - { - I2C_START(); - if(wait_job() != I2C_OK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__START_TIMEOUT); - status = I2C_ERROR_TIMEOUT; - break; - } - if((I2C_STATUS() != I2C_STATUS_START) && (I2C_STATUS() != I2C_STATUS_START_REP)) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__START_ERROR); - status = I2C_ERROR_START; - break; - } - PRINTD("I2C-RD-START\n"); - } - - if(len == 0) break; - - for(i=0; i<(len-1); i++) - { - I2C_READ_BYTE_ACK(); - if(wait_job() != I2C_OK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__READ_BYTE_ACK_TIMEOUT); - status = I2C_ERROR_TIMEOUT; - break; - } - if(I2C_STATUS() != I2C_STATUS_DATAR_ACK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__READ_BYTE_ACK_ERROR); - status = I2C_ERROR_READ; - break; - } - buffer[i] = I2C_RX_REG; - PRINTD("I2C-RD-RACK: 0x%02X\n", buffer[i]); - } - - I2C_READ_BYTE_NACK(); - if(wait_job() != I2C_OK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__READ_BYTE_NACK_TIMEOUT); - status = I2C_ERROR_TIMEOUT; - break; - } - if(I2C_STATUS() != I2C_STATUS_DATAR_NACK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__READ_BYTE_NACK_ERROR); - status = I2C_ERROR_READ; - break; - } - buffer[i] = I2C_RX_REG; - PRINTD("I2C-RD-RNACK: 0x%02X\n", buffer[i]); - - } while (0); - - if(cmd_flags & I2C_CMD_FLAG_STOP) - { - I2C_STOP(); - if(wait_stop() != I2C_OK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_READ__STOP_TIMEOUT); - status = I2C_ERROR_TIMEOUT; - } - PRINTD("I2C-RD_STOP\n"); - } - - return status; -} - -static int8_t i2c_write(const i2c_driver* const me, uint8_t cmd_flags, const uint8_t* data, uint8_t len) -{ - uint8_t i = 0; - int8_t status = I2C_OK; - - - if(me == NULL || i2c_lock == false) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_WRITE__DEVICE_CLOSED); - return I2C_ERROR_DRIVER; - } - - if((len > 0) && (data == NULL)) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_WRITE__ERROR_NULLPOINTER); - return I2C_ERROR_DRIVER; - } - - do - { - if(cmd_flags & I2C_CMD_FLAG_START) - { - I2C_START(); - if(wait_job() != I2C_OK) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_WRITE__START_TIMEOUT); - status = I2C_ERROR_TIMEOUT; - break; - } - if((I2C_STATUS() != I2C_STATUS_START) && (I2C_STATUS() != I2C_STATUS_START_REP)) - { - RTDEBUG_PUSH(RTDEBUG_CODE__I2C_WRITE__START_ERROR); - status = I2C_ERROR_START; - break; - } - PRINTD("I2C-WR-START\n"); - } - - - - for(i=0; i - -//////////////////////////////////////////////////////////////////////////////////////////// -// CONFIGURATION SECTION: - -#define I2C_TD 0 // compiler switch: i2c testdriver code - -#define I2C_PORT PORTD -#define I2C_DDR DDRD -#define I2C_SCL_PIN 0 -#define I2C_SDA_PIN 1 - -// END OF CONFIGURATION SECTION -//////////////////////////////////////////////////////////////////////////////////////////// - -#define I2C_INIT() ({I2C_DDR &= ~((1< CHECK F_CPU SETTINGS!" -#endif - - -#define I2C_STATUS_REG TWSR -#define I2C_TX_REG TWDR -#define I2C_RX_REG TWDR - -#define I2C_START() (TWCR = (1< -#include - -void key_init(void); -uint8_t is_button(void); - -#endif /* __KEY_H__ */ diff --git a/platform/osd-merkur/dev/leds-arch.h b/platform/osd-merkur/dev/leds-arch.h deleted file mode 100644 index b790ad5b8..000000000 --- a/platform/osd-merkur/dev/leds-arch.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __LEDS_ARCH_H__ -#define __LEDS_ARCH_H__ - -#define LED_OUT PORTE - -#define BIT_RED _BV(PE5) -#define BIT_BLUE BIT_RED -#define BIT_GREEN BIT_RED -#define BIT_YELLOW BIT_RED - -#define LED_GREEN_ON() LED_OUT &= ~BIT_GREEN -#define LED_GREEN_OFF() LED_OUT |= BIT_GREEN -#define LED_YELLOW_ON() LED_OUT &= ~BIT_YELLOW -#define LED_YELLOW_OFF() LED_OUT |= BIT_YELLOW -#define LED_RED_ON() LED_OUT &= ~BIT_RED -#define LED_RED_OFF() LED_OUT |= BIT_RED - - -#define LED_GREEN_TOGGLE() LED_OUT ^= BIT_GREEN -#define LED_YELLOW_TOGGLE() LED_OUT ^= BIT_YELLOW -#define LED_RED_TOGGLE() LED_OUT ^= BIT_RED - -#define LEDS_ON() LED_OUT &= ~(BIT_BLUE | BIT_GREEN | BIT_RED) -#define LEDS_OFF() LED_OUT |= (BIT_BLUE | BIT_GREEN | BIT_RED) - - -void leds_arch_init(void); -unsigned char leds_arch_get(void); -void leds_arch_set(unsigned char leds); - -#endif /* __LEDS_ARCH_H__ */ diff --git a/platform/osd-merkur/dev/old/Printable.h b/platform/osd-merkur/dev/old/Printable.h deleted file mode 100644 index d03c9af62..000000000 --- a/platform/osd-merkur/dev/old/Printable.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Printable.h - Interface class that allows printing of complex types - Copyright (c) 2011 Adrian McEwen. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef Printable_h -#define Printable_h - -#include - -class Print; - -/** The Printable class provides a way for new classes to allow themselves to be printed. - By deriving from Printable and implementing the printTo method, it will then be possible - for users to print out instances of this class by passing them into the usual - Print::print and Print::println methods. -*/ - -class Printable -{ - public: - virtual size_t printTo(Print& p) const = 0; -}; - -#endif - diff --git a/platform/osd-merkur/dev/old/Stream.cpp b/platform/osd-merkur/dev/old/Stream.cpp deleted file mode 100644 index aafb7fcf9..000000000 --- a/platform/osd-merkur/dev/old/Stream.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - Stream.cpp - adds parsing methods to Stream class - Copyright (c) 2008 David A. Mellis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Created July 2011 - parsing functions based on TextFinder library by Michael Margolis - */ - -#include "Arduino.h" -#include "Stream.h" - -#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait -#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field - -// private method to read stream with timeout -int Stream::timedRead() -{ - int c; - _startMillis = millis(); - do { - c = read(); - if (c >= 0) return c; - } while(millis() - _startMillis < _timeout); - return -1; // -1 indicates timeout -} - -// private method to peek stream with timeout -int Stream::timedPeek() -{ - int c; - _startMillis = millis(); - do { - c = peek(); - if (c >= 0) return c; - } while(millis() - _startMillis < _timeout); - return -1; // -1 indicates timeout -} - -// returns peek of the next digit in the stream or -1 if timeout -// discards non-numeric characters -int Stream::peekNextDigit() -{ - int c; - while (1) { - c = timedPeek(); - if (c < 0) return c; // timeout - if (c == '-') return c; - if (c >= '0' && c <= '9') return c; - read(); // discard non-numeric - } -} - -// Public Methods -////////////////////////////////////////////////////////////// - -void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait -{ - _timeout = timeout; -} - - // find returns true if the target string is found -bool Stream::find(char *target) -{ - return findUntil(target, NULL); -} - -// reads data from the stream until the target string of given length is found -// returns true if target string is found, false if timed out -bool Stream::find(char *target, size_t length) -{ - return findUntil(target, length, NULL, 0); -} - -// as find but search ends if the terminator string is found -bool Stream::findUntil(char *target, char *terminator) -{ - return findUntil(target, strlen(target), terminator, strlen(terminator)); -} - -// reads data from the stream until the target string of the given length is found -// search terminated if the terminator string is found -// returns true if target string is found, false if terminated or timed out -bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) -{ - size_t index = 0; // maximum target string length is 64k bytes! - size_t termIndex = 0; - int c; - - if( *target == 0) - return true; // return true if target is a null string - while( (c = timedRead()) > 0){ - - if(c != target[index]) - index = 0; // reset index if any char does not match - - if( c == target[index]){ - //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); - if(++index >= targetLen){ // return true if all chars in the target match - return true; - } - } - - if(termLen > 0 && c == terminator[termIndex]){ - if(++termIndex >= termLen) - return false; // return false if terminate string found before target string - } - else - termIndex = 0; - } - return false; -} - - -// returns the first valid (long) integer value from the current position. -// initial characters that are not digits (or the minus sign) are skipped -// function is terminated by the first character that is not a digit. -long Stream::parseInt() -{ - return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) -} - -// as above but a given skipChar is ignored -// this allows format characters (typically commas) in values to be ignored -long Stream::parseInt(char skipChar) -{ - boolean isNegative = false; - long value = 0; - int c; - - c = peekNextDigit(); - // ignore non numeric leading characters - if(c < 0) - return 0; // zero returned if timeout - - do{ - if(c == skipChar) - ; // ignore this charactor - else if(c == '-') - isNegative = true; - else if(c >= '0' && c <= '9') // is c a digit? - value = value * 10 + c - '0'; - read(); // consume the character we got with peek - c = timedPeek(); - } - while( (c >= '0' && c <= '9') || c == skipChar ); - - if(isNegative) - value = -value; - return value; -} - - -// as parseInt but returns a floating point value -float Stream::parseFloat() -{ - return parseFloat(NO_SKIP_CHAR); -} - -// as above but the given skipChar is ignored -// this allows format characters (typically commas) in values to be ignored -float Stream::parseFloat(char skipChar){ - boolean isNegative = false; - boolean isFraction = false; - long value = 0; - char c; - float fraction = 1.0; - - c = peekNextDigit(); - // ignore non numeric leading characters - if(c < 0) - return 0; // zero returned if timeout - - do{ - if(c == skipChar) - ; // ignore - else if(c == '-') - isNegative = true; - else if (c == '.') - isFraction = true; - else if(c >= '0' && c <= '9') { // is c a digit? - value = value * 10 + c - '0'; - if(isFraction) - fraction *= 0.1; - } - read(); // consume the character we got with peek - c = timedPeek(); - } - while( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); - - if(isNegative) - value = -value; - if(isFraction) - return value * fraction; - else - return value; -} - -// read characters from stream into buffer -// terminates if length characters have been read, or timeout (see setTimeout) -// returns the number of characters placed in the buffer -// the buffer is NOT null terminated. -// -size_t Stream::readBytes(char *buffer, size_t length) -{ - size_t count = 0; - while (count < length) { - int c = timedRead(); - if (c < 0) break; - *buffer++ = (char)c; - count++; - } - return count; -} - - -// as readBytes with terminator character -// terminates if length characters have been read, timeout, or if the terminator character detected -// returns the number of characters placed in the buffer (0 means no valid data found) - -size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) -{ - if (length < 1) return 0; - size_t index = 0; - while (index < length) { - int c = timedRead(); - if (c < 0 || c == terminator) break; - *buffer++ = (char)c; - index++; - } - return index; // return number of characters, not including null terminator -} - -String Stream::readString() -{ - String ret; - int c = timedRead(); - while (c >= 0) - { - ret += (char)c; - c = timedRead(); - } - return ret; -} - -String Stream::readStringUntil(char terminator) -{ - String ret; - int c = timedRead(); - while (c >= 0 && c != terminator) - { - ret += (char)c; - c = timedRead(); - } - return ret; -} - diff --git a/platform/osd-merkur/dev/old/Stream.h b/platform/osd-merkur/dev/old/Stream.h deleted file mode 100644 index 58bbf752f..000000000 --- a/platform/osd-merkur/dev/old/Stream.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Stream.h - base class for character-based streams. - Copyright (c) 2010 David A. Mellis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - parsing functions based on TextFinder library by Michael Margolis -*/ - -#ifndef Stream_h -#define Stream_h - -#include -#include "Print.h" - -// compatability macros for testing -/* -#define getInt() parseInt() -#define getInt(skipChar) parseInt(skipchar) -#define getFloat() parseFloat() -#define getFloat(skipChar) parseFloat(skipChar) -#define getString( pre_string, post_string, buffer, length) -readBytesBetween( pre_string, terminator, buffer, length) -*/ - -class Stream : public Print -{ - private: - unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read - unsigned long _startMillis; // used for timeout measurement - int timedRead(); // private method to read stream with timeout - int timedPeek(); // private method to peek stream with timeout - int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout - - public: - virtual int available() = 0; - virtual int read() = 0; - virtual int peek() = 0; - virtual void flush() = 0; - - Stream() {_timeout=1000;} - -// parsing methods - - void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second - - bool find(char *target); // reads data from the stream until the target string is found - // returns true if target string is found, false if timed out (see setTimeout) - - bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found - // returns true if target string is found, false if timed out - - bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found - - bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found - - - long parseInt(); // returns the first valid (long) integer value from the current position. - // initial characters that are not digits (or the minus sign) are skipped - // integer is terminated by the first character that is not a digit. - - float parseFloat(); // float version of parseInt - - size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer - // terminates if length characters have been read or timeout (see setTimeout) - // returns the number of characters placed in the buffer (0 means no valid data found) - - size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character - // terminates if length characters have been read, timeout, or if the terminator character detected - // returns the number of characters placed in the buffer (0 means no valid data found) - - // Arduino String functions to be added here - String readString(); - String readStringUntil(char terminator); - - protected: - long parseInt(char skipChar); // as above but the given skipChar is ignored - // as above but the given skipChar is ignored - // this allows format characters (typically commas) in values to be ignored - - float parseFloat(char skipChar); // as above but the given skipChar is ignored -}; - -#endif diff --git a/platform/osd-merkur/dev/old/WString.cpp b/platform/osd-merkur/dev/old/WString.cpp deleted file mode 100644 index c6839fc0d..000000000 --- a/platform/osd-merkur/dev/old/WString.cpp +++ /dev/null @@ -1,645 +0,0 @@ -/* - WString.cpp - String library for Wiring & Arduino - ...mostly rewritten by Paul Stoffregen... - Copyright (c) 2009-10 Hernando Barragan. All rights reserved. - Copyright 2011, Paul Stoffregen, paul@pjrc.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "WString.h" - - -/*********************************************/ -/* Constructors */ -/*********************************************/ - -String::String(const char *cstr) -{ - init(); - if (cstr) copy(cstr, strlen(cstr)); -} - -String::String(const String &value) -{ - init(); - *this = value; -} - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -String::String(String &&rval) -{ - init(); - move(rval); -} -String::String(StringSumHelper &&rval) -{ - init(); - move(rval); -} -#endif - -String::String(char c) -{ - init(); - char buf[2]; - buf[0] = c; - buf[1] = 0; - *this = buf; -} - -String::String(unsigned char value, unsigned char base) -{ - init(); - char buf[9]; - utoa(value, buf, base); - *this = buf; -} - -String::String(int value, unsigned char base) -{ - init(); - char buf[18]; - itoa(value, buf, base); - *this = buf; -} - -String::String(unsigned int value, unsigned char base) -{ - init(); - char buf[17]; - utoa(value, buf, base); - *this = buf; -} - -String::String(long value, unsigned char base) -{ - init(); - char buf[34]; - ltoa(value, buf, base); - *this = buf; -} - -String::String(unsigned long value, unsigned char base) -{ - init(); - char buf[33]; - ultoa(value, buf, base); - *this = buf; -} - -String::~String() -{ - free(buffer); -} - -/*********************************************/ -/* Memory Management */ -/*********************************************/ - -inline void String::init(void) -{ - buffer = NULL; - capacity = 0; - len = 0; - flags = 0; -} - -void String::invalidate(void) -{ - if (buffer) free(buffer); - buffer = NULL; - capacity = len = 0; -} - -unsigned char String::reserve(unsigned int size) -{ - if (buffer && capacity >= size) return 1; - if (changeBuffer(size)) { - if (len == 0) buffer[0] = 0; - return 1; - } - return 0; -} - -unsigned char String::changeBuffer(unsigned int maxStrLen) -{ - char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); - if (newbuffer) { - buffer = newbuffer; - capacity = maxStrLen; - return 1; - } - return 0; -} - -/*********************************************/ -/* Copy and Move */ -/*********************************************/ - -String & String::copy(const char *cstr, unsigned int length) -{ - if (!reserve(length)) { - invalidate(); - return *this; - } - len = length; - strcpy(buffer, cstr); - return *this; -} - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -void String::move(String &rhs) -{ - if (buffer) { - if (capacity >= rhs.len) { - strcpy(buffer, rhs.buffer); - len = rhs.len; - rhs.len = 0; - return; - } else { - free(buffer); - } - } - buffer = rhs.buffer; - capacity = rhs.capacity; - len = rhs.len; - rhs.buffer = NULL; - rhs.capacity = 0; - rhs.len = 0; -} -#endif - -String & String::operator = (const String &rhs) -{ - if (this == &rhs) return *this; - - if (rhs.buffer) copy(rhs.buffer, rhs.len); - else invalidate(); - - return *this; -} - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -String & String::operator = (String &&rval) -{ - if (this != &rval) move(rval); - return *this; -} - -String & String::operator = (StringSumHelper &&rval) -{ - if (this != &rval) move(rval); - return *this; -} -#endif - -String & String::operator = (const char *cstr) -{ - if (cstr) copy(cstr, strlen(cstr)); - else invalidate(); - - return *this; -} - -/*********************************************/ -/* concat */ -/*********************************************/ - -unsigned char String::concat(const String &s) -{ - return concat(s.buffer, s.len); -} - -unsigned char String::concat(const char *cstr, unsigned int length) -{ - unsigned int newlen = len + length; - if (!cstr) return 0; - if (length == 0) return 1; - if (!reserve(newlen)) return 0; - strcpy(buffer + len, cstr); - len = newlen; - return 1; -} - -unsigned char String::concat(const char *cstr) -{ - if (!cstr) return 0; - return concat(cstr, strlen(cstr)); -} - -unsigned char String::concat(char c) -{ - char buf[2]; - buf[0] = c; - buf[1] = 0; - return concat(buf, 1); -} - -unsigned char String::concat(unsigned char num) -{ - char buf[4]; - itoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(int num) -{ - char buf[7]; - itoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(unsigned int num) -{ - char buf[6]; - utoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(long num) -{ - char buf[12]; - ltoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(unsigned long num) -{ - char buf[11]; - ultoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -/*********************************************/ -/* Concatenate */ -/*********************************************/ - -StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) -{ - StringSumHelper &a = const_cast(lhs); - if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, char c) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(c)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, int num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, long num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -/*********************************************/ -/* Comparison */ -/*********************************************/ - -int String::compareTo(const String &s) const -{ - if (!buffer || !s.buffer) { - if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; - if (buffer && len > 0) return *(unsigned char *)buffer; - return 0; - } - return strcmp(buffer, s.buffer); -} - -unsigned char String::equals(const String &s2) const -{ - return (len == s2.len && compareTo(s2) == 0); -} - -unsigned char String::equals(const char *cstr) const -{ - if (len == 0) return (cstr == NULL || *cstr == 0); - if (cstr == NULL) return buffer[0] == 0; - return strcmp(buffer, cstr) == 0; -} - -unsigned char String::operator<(const String &rhs) const -{ - return compareTo(rhs) < 0; -} - -unsigned char String::operator>(const String &rhs) const -{ - return compareTo(rhs) > 0; -} - -unsigned char String::operator<=(const String &rhs) const -{ - return compareTo(rhs) <= 0; -} - -unsigned char String::operator>=(const String &rhs) const -{ - return compareTo(rhs) >= 0; -} - -unsigned char String::equalsIgnoreCase( const String &s2 ) const -{ - if (this == &s2) return 1; - if (len != s2.len) return 0; - if (len == 0) return 1; - const char *p1 = buffer; - const char *p2 = s2.buffer; - while (*p1) { - if (tolower(*p1++) != tolower(*p2++)) return 0; - } - return 1; -} - -unsigned char String::startsWith( const String &s2 ) const -{ - if (len < s2.len) return 0; - return startsWith(s2, 0); -} - -unsigned char String::startsWith( const String &s2, unsigned int offset ) const -{ - if (offset > len - s2.len || !buffer || !s2.buffer) return 0; - return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; -} - -unsigned char String::endsWith( const String &s2 ) const -{ - if ( len < s2.len || !buffer || !s2.buffer) return 0; - return strcmp(&buffer[len - s2.len], s2.buffer) == 0; -} - -/*********************************************/ -/* Character Access */ -/*********************************************/ - -char String::charAt(unsigned int loc) const -{ - return operator[](loc); -} - -void String::setCharAt(unsigned int loc, char c) -{ - if (loc < len) buffer[loc] = c; -} - -char & String::operator[](unsigned int index) -{ - static char dummy_writable_char; - if (index >= len || !buffer) { - dummy_writable_char = 0; - return dummy_writable_char; - } - return buffer[index]; -} - -char String::operator[]( unsigned int index ) const -{ - if (index >= len || !buffer) return 0; - return buffer[index]; -} - -void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const -{ - if (!bufsize || !buf) return; - if (index >= len) { - buf[0] = 0; - return; - } - unsigned int n = bufsize - 1; - if (n > len - index) n = len - index; - strncpy((char *)buf, buffer + index, n); - buf[n] = 0; -} - -/*********************************************/ -/* Search */ -/*********************************************/ - -int String::indexOf(char c) const -{ - return indexOf(c, 0); -} - -int String::indexOf( char ch, unsigned int fromIndex ) const -{ - if (fromIndex >= len) return -1; - const char* temp = strchr(buffer + fromIndex, ch); - if (temp == NULL) return -1; - return temp - buffer; -} - -int String::indexOf(const String &s2) const -{ - return indexOf(s2, 0); -} - -int String::indexOf(const String &s2, unsigned int fromIndex) const -{ - if (fromIndex >= len) return -1; - const char *found = strstr(buffer + fromIndex, s2.buffer); - if (found == NULL) return -1; - return found - buffer; -} - -int String::lastIndexOf( char theChar ) const -{ - return lastIndexOf(theChar, len - 1); -} - -int String::lastIndexOf(char ch, unsigned int fromIndex) const -{ - if (fromIndex >= len) return -1; - char tempchar = buffer[fromIndex + 1]; - buffer[fromIndex + 1] = '\0'; - char* temp = strrchr( buffer, ch ); - buffer[fromIndex + 1] = tempchar; - if (temp == NULL) return -1; - return temp - buffer; -} - -int String::lastIndexOf(const String &s2) const -{ - return lastIndexOf(s2, len - s2.len); -} - -int String::lastIndexOf(const String &s2, unsigned int fromIndex) const -{ - if (s2.len == 0 || len == 0 || s2.len > len) return -1; - if (fromIndex >= len) fromIndex = len - 1; - int found = -1; - for (char *p = buffer; p <= buffer + fromIndex; p++) { - p = strstr(p, s2.buffer); - if (!p) break; - if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer; - } - return found; -} - -String String::substring( unsigned int left ) const -{ - return substring(left, len); -} - -String String::substring(unsigned int left, unsigned int right) const -{ - if (left > right) { - unsigned int temp = right; - right = left; - left = temp; - } - String out; - if (left > len) return out; - if (right > len) right = len; - char temp = buffer[right]; // save the replaced character - buffer[right] = '\0'; - out = buffer + left; // pointer arithmetic - buffer[right] = temp; //restore character - return out; -} - -/*********************************************/ -/* Modification */ -/*********************************************/ - -void String::replace(char find, char replace) -{ - if (!buffer) return; - for (char *p = buffer; *p; p++) { - if (*p == find) *p = replace; - } -} - -void String::replace(const String& find, const String& replace) -{ - if (len == 0 || find.len == 0) return; - int diff = replace.len - find.len; - char *readFrom = buffer; - char *foundAt; - if (diff == 0) { - while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { - memcpy(foundAt, replace.buffer, replace.len); - readFrom = foundAt + replace.len; - } - } else if (diff < 0) { - char *writeTo = buffer; - while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { - unsigned int n = foundAt - readFrom; - memcpy(writeTo, readFrom, n); - writeTo += n; - memcpy(writeTo, replace.buffer, replace.len); - writeTo += replace.len; - readFrom = foundAt + find.len; - len += diff; - } - strcpy(writeTo, readFrom); - } else { - unsigned int size = len; // compute size needed for result - while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { - readFrom = foundAt + find.len; - size += diff; - } - if (size == len) return; - if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! - int index = len - 1; - while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { - readFrom = buffer + index + find.len; - memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); - len += diff; - buffer[len] = 0; - memcpy(buffer + index, replace.buffer, replace.len); - index--; - } - } -} - -void String::toLowerCase(void) -{ - if (!buffer) return; - for (char *p = buffer; *p; p++) { - *p = tolower(*p); - } -} - -void String::toUpperCase(void) -{ - if (!buffer) return; - for (char *p = buffer; *p; p++) { - *p = toupper(*p); - } -} - -void String::trim(void) -{ - if (!buffer || len == 0) return; - char *begin = buffer; - while (isspace(*begin)) begin++; - char *end = buffer + len - 1; - while (isspace(*end) && end >= begin) end--; - len = end + 1 - begin; - if (begin > buffer) memcpy(buffer, begin, len); - buffer[len] = 0; -} - -/*********************************************/ -/* Parsing / Conversion */ -/*********************************************/ - -long String::toInt(void) const -{ - if (buffer) return atol(buffer); - return 0; -} - - diff --git a/platform/osd-merkur/dev/old/WString.h b/platform/osd-merkur/dev/old/WString.h deleted file mode 100644 index 947325e5f..000000000 --- a/platform/osd-merkur/dev/old/WString.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - WString.h - String library for Wiring & Arduino - ...mostly rewritten by Paul Stoffregen... - Copyright (c) 2009-10 Hernando Barragan. All right reserved. - Copyright 2011, Paul Stoffregen, paul@pjrc.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef String_class_h -#define String_class_h -#ifdef __cplusplus - -#include -#include -#include -#include - -// When compiling programs with this class, the following gcc parameters -// dramatically increase performance and memory (RAM) efficiency, typically -// with little or no increase in code size. -// -felide-constructors -// -std=c++0x - -class __FlashStringHelper; -#define F(string_literal) (reinterpret_cast(PSTR(string_literal))) - -// An inherited class for holding the result of a concatenation. These -// result objects are assumed to be writable by subsequent concatenations. -class StringSumHelper; - -// The string class -class String -{ - // use a function pointer to allow for "if (s)" without the - // complications of an operator bool(). for more information, see: - // http://www.artima.com/cppsource/safebool.html - typedef void (String::*StringIfHelperType)() const; - void StringIfHelper() const {} - -public: - // constructors - // creates a copy of the initial value. - // if the initial value is null or invalid, or if memory allocation - // fails, the string will be marked as invalid (i.e. "if (s)" will - // be false). - String(const char *cstr = ""); - String(const String &str); - #ifdef __GXX_EXPERIMENTAL_CXX0X__ - String(String &&rval); - String(StringSumHelper &&rval); - #endif - explicit String(char c); - explicit String(unsigned char, unsigned char base=10); - explicit String(int, unsigned char base=10); - explicit String(unsigned int, unsigned char base=10); - explicit String(long, unsigned char base=10); - explicit String(unsigned long, unsigned char base=10); - ~String(void); - - // memory management - // return true on success, false on failure (in which case, the string - // is left unchanged). reserve(0), if successful, will validate an - // invalid string (i.e., "if (s)" will be true afterwards) - unsigned char reserve(unsigned int size); - inline unsigned int length(void) const {return len;} - - // creates a copy of the assigned value. if the value is null or - // invalid, or if the memory allocation fails, the string will be - // marked as invalid ("if (s)" will be false). - String & operator = (const String &rhs); - String & operator = (const char *cstr); - #ifdef __GXX_EXPERIMENTAL_CXX0X__ - String & operator = (String &&rval); - String & operator = (StringSumHelper &&rval); - #endif - - // concatenate (works w/ built-in types) - - // returns true on success, false on failure (in which case, the string - // is left unchanged). if the argument is null or invalid, the - // concatenation is considered unsucessful. - unsigned char concat(const String &str); - unsigned char concat(const char *cstr); - unsigned char concat(char c); - unsigned char concat(unsigned char c); - unsigned char concat(int num); - unsigned char concat(unsigned int num); - unsigned char concat(long num); - unsigned char concat(unsigned long num); - - // if there's not enough memory for the concatenated value, the string - // will be left unchanged (but this isn't signalled in any way) - String & operator += (const String &rhs) {concat(rhs); return (*this);} - String & operator += (const char *cstr) {concat(cstr); return (*this);} - String & operator += (char c) {concat(c); return (*this);} - String & operator += (unsigned char num) {concat(num); return (*this);} - String & operator += (int num) {concat(num); return (*this);} - String & operator += (unsigned int num) {concat(num); return (*this);} - String & operator += (long num) {concat(num); return (*this);} - String & operator += (unsigned long num) {concat(num); return (*this);} - - friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); - friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); - friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); - friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); - - // comparison (only works w/ Strings and "strings") - operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } - int compareTo(const String &s) const; - unsigned char equals(const String &s) const; - unsigned char equals(const char *cstr) const; - unsigned char operator == (const String &rhs) const {return equals(rhs);} - unsigned char operator == (const char *cstr) const {return equals(cstr);} - unsigned char operator != (const String &rhs) const {return !equals(rhs);} - unsigned char operator != (const char *cstr) const {return !equals(cstr);} - unsigned char operator < (const String &rhs) const; - unsigned char operator > (const String &rhs) const; - unsigned char operator <= (const String &rhs) const; - unsigned char operator >= (const String &rhs) const; - unsigned char equalsIgnoreCase(const String &s) const; - unsigned char startsWith( const String &prefix) const; - unsigned char startsWith(const String &prefix, unsigned int offset) const; - unsigned char endsWith(const String &suffix) const; - - // character acccess - char charAt(unsigned int index) const; - void setCharAt(unsigned int index, char c); - char operator [] (unsigned int index) const; - char& operator [] (unsigned int index); - void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; - void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const - {getBytes((unsigned char *)buf, bufsize, index);} - - // search - int indexOf( char ch ) const; - int indexOf( char ch, unsigned int fromIndex ) const; - int indexOf( const String &str ) const; - int indexOf( const String &str, unsigned int fromIndex ) const; - int lastIndexOf( char ch ) const; - int lastIndexOf( char ch, unsigned int fromIndex ) const; - int lastIndexOf( const String &str ) const; - int lastIndexOf( const String &str, unsigned int fromIndex ) const; - String substring( unsigned int beginIndex ) const; - String substring( unsigned int beginIndex, unsigned int endIndex ) const; - - // modification - void replace(char find, char replace); - void replace(const String& find, const String& replace); - void toLowerCase(void); - void toUpperCase(void); - void trim(void); - - // parsing/conversion - long toInt(void) const; - -protected: - char *buffer; // the actual char array - unsigned int capacity; // the array length minus one (for the '\0') - unsigned int len; // the String length (not counting the '\0') - unsigned char flags; // unused, for future features -protected: - void init(void); - void invalidate(void); - unsigned char changeBuffer(unsigned int maxStrLen); - unsigned char concat(const char *cstr, unsigned int length); - - // copy and move - String & copy(const char *cstr, unsigned int length); - #ifdef __GXX_EXPERIMENTAL_CXX0X__ - void move(String &rhs); - #endif -}; - -class StringSumHelper : public String -{ -public: - StringSumHelper(const String &s) : String(s) {} - StringSumHelper(const char *p) : String(p) {} - StringSumHelper(char c) : String(c) {} - StringSumHelper(unsigned char num) : String(num) {} - StringSumHelper(int num) : String(num) {} - StringSumHelper(unsigned int num) : String(num) {} - StringSumHelper(long num) : String(num) {} - StringSumHelper(unsigned long num) : String(num) {} -}; - -#endif // __cplusplus -#endif // String_class_h diff --git a/platform/osd-merkur/dev/old/Wire.cpp b/platform/osd-merkur/dev/old/Wire.cpp deleted file mode 100644 index 4e7a17c47..000000000 --- a/platform/osd-merkur/dev/old/Wire.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* - TwoWire.cpp - TWI/I2C library for Wiring & Arduino - Copyright (c) 2006 Nicholas Zambetti. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts -*/ - -extern "C" { - #include - #include - #include - #include "twi.h" -} - -#include "Wire.h" - -// Initialize Class Variables ////////////////////////////////////////////////// - -uint8_t TwoWire::rxBuffer[BUFFER_LENGTH]; -uint8_t TwoWire::rxBufferIndex = 0; -uint8_t TwoWire::rxBufferLength = 0; - -uint8_t TwoWire::txAddress = 0; -uint8_t TwoWire::txBuffer[BUFFER_LENGTH]; -uint8_t TwoWire::txBufferIndex = 0; -uint8_t TwoWire::txBufferLength = 0; - -uint8_t TwoWire::transmitting = 0; -void (*TwoWire::user_onRequest)(void); -void (*TwoWire::user_onReceive)(int); - -// Constructors //////////////////////////////////////////////////////////////// - -TwoWire::TwoWire() -{ -} - -// Public Methods ////////////////////////////////////////////////////////////// - -void TwoWire::begin(void) -{ - rxBufferIndex = 0; - rxBufferLength = 0; - - txBufferIndex = 0; - txBufferLength = 0; - - twi_init(); -} - -void TwoWire::begin(uint8_t address) -{ - twi_setAddress(address); - twi_attachSlaveTxEvent(onRequestService); - twi_attachSlaveRxEvent(onReceiveService); - begin(); -} - -void TwoWire::begin(int address) -{ - begin((uint8_t)address); -} - -uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) -{ - // clamp to buffer length - if(quantity > BUFFER_LENGTH){ - quantity = BUFFER_LENGTH; - } - // perform blocking read into buffer - uint8_t read = twi_readFrom(address, rxBuffer, quantity, sendStop); - // set rx buffer iterator vars - rxBufferIndex = 0; - rxBufferLength = read; - - return read; -} - -uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) -{ - return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true); -} - -uint8_t TwoWire::requestFrom(int address, int quantity) -{ - return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true); -} - -uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop) -{ - return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop); -} - -void TwoWire::beginTransmission(uint8_t address) -{ - // indicate that we are transmitting - transmitting = 1; - // set address of targeted slave - txAddress = address; - // reset tx buffer iterator vars - txBufferIndex = 0; - txBufferLength = 0; -} - -void TwoWire::beginTransmission(int address) -{ - beginTransmission((uint8_t)address); -} - -// -// Originally, 'endTransmission' was an f(void) function. -// It has been modified to take one parameter indicating -// whether or not a STOP should be performed on the bus. -// Calling endTransmission(false) allows a sketch to -// perform a repeated start. -// -// WARNING: Nothing in the library keeps track of whether -// the bus tenure has been properly ended with a STOP. It -// is very possible to leave the bus in a hung state if -// no call to endTransmission(true) is made. Some I2C -// devices will behave oddly if they do not see a STOP. -// -uint8_t TwoWire::endTransmission(uint8_t sendStop) -{ - // transmit buffer (blocking) - int8_t ret = twi_writeTo(txAddress, txBuffer, txBufferLength, 1, sendStop); - // reset tx buffer iterator vars - txBufferIndex = 0; - txBufferLength = 0; - // indicate that we are done transmitting - transmitting = 0; - return ret; -} - -// This provides backwards compatibility with the original -// definition, and expected behaviour, of endTransmission -// -uint8_t TwoWire::endTransmission(void) -{ - return endTransmission(true); -} - -// must be called in: -// slave tx event callback -// or after beginTransmission(address) -size_t TwoWire::write(uint8_t data) -{ - if(transmitting){ - // in master transmitter mode - // don't bother if buffer is full - if(txBufferLength >= BUFFER_LENGTH){ - setWriteError(); - return 0; - } - // put byte in tx buffer - txBuffer[txBufferIndex] = data; - ++txBufferIndex; - // update amount in buffer - txBufferLength = txBufferIndex; - }else{ - // in slave send mode - // reply to master - twi_transmit(&data, 1); - } - return 1; -} - -// must be called in: -// slave tx event callback -// or after beginTransmission(address) -size_t TwoWire::write(const uint8_t *data, size_t quantity) -{ - if(transmitting){ - // in master transmitter mode - for(size_t i = 0; i < quantity; ++i){ - write(data[i]); - } - }else{ - // in slave send mode - // reply to master - twi_transmit(data, quantity); - } - return quantity; -} - -// must be called in: -// slave rx event callback -// or after requestFrom(address, numBytes) -int TwoWire::available(void) -{ - return rxBufferLength - rxBufferIndex; -} - -// must be called in: -// slave rx event callback -// or after requestFrom(address, numBytes) -int TwoWire::read(void) -{ - int value = -1; - - // get each successive byte on each call - if(rxBufferIndex < rxBufferLength){ - value = rxBuffer[rxBufferIndex]; - ++rxBufferIndex; - } - - return value; -} - -// must be called in: -// slave rx event callback -// or after requestFrom(address, numBytes) -int TwoWire::peek(void) -{ - int value = -1; - - if(rxBufferIndex < rxBufferLength){ - value = rxBuffer[rxBufferIndex]; - } - - return value; -} - -void TwoWire::flush(void) -{ - // XXX: to be implemented. -} - -// behind the scenes function that is called when data is received -void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes) -{ - // don't bother if user hasn't registered a callback - if(!user_onReceive){ - return; - } - // don't bother if rx buffer is in use by a master requestFrom() op - // i know this drops data, but it allows for slight stupidity - // meaning, they may not have read all the master requestFrom() data yet - if(rxBufferIndex < rxBufferLength){ - return; - } - // copy twi rx buffer into local read buffer - // this enables new reads to happen in parallel - for(uint8_t i = 0; i < numBytes; ++i){ - rxBuffer[i] = inBytes[i]; - } - // set rx iterator vars - rxBufferIndex = 0; - rxBufferLength = numBytes; - // alert user program - user_onReceive(numBytes); -} - -// behind the scenes function that is called when data is requested -void TwoWire::onRequestService(void) -{ - // don't bother if user hasn't registered a callback - if(!user_onRequest){ - return; - } - // reset tx buffer iterator vars - // !!! this will kill any pending pre-master sendTo() activity - txBufferIndex = 0; - txBufferLength = 0; - // alert user program - user_onRequest(); -} - -// sets function called on slave write -void TwoWire::onReceive( void (*function)(int) ) -{ - user_onReceive = function; -} - -// sets function called on slave read -void TwoWire::onRequest( void (*function)(void) ) -{ - user_onRequest = function; -} - -// Preinstantiate Objects ////////////////////////////////////////////////////// - -TwoWire Wire = TwoWire(); - diff --git a/platform/osd-merkur/dev/old/Wire.h b/platform/osd-merkur/dev/old/Wire.h deleted file mode 100644 index a93d0f5bb..000000000 --- a/platform/osd-merkur/dev/old/Wire.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - TwoWire.h - TWI/I2C library for Arduino & Wiring - Copyright (c) 2006 Nicholas Zambetti. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts -*/ - -#ifndef TwoWire_h -#define TwoWire_h - -#include -#include "Stream.h" - -#define BUFFER_LENGTH 32 - -class TwoWire : public Stream -{ - private: - static uint8_t rxBuffer[]; - static uint8_t rxBufferIndex; - static uint8_t rxBufferLength; - - static uint8_t txAddress; - static uint8_t txBuffer[]; - static uint8_t txBufferIndex; - static uint8_t txBufferLength; - - static uint8_t transmitting; - static void (*user_onRequest)(void); - static void (*user_onReceive)(int); - static void onRequestService(void); - static void onReceiveService(uint8_t*, int); - public: - TwoWire(); - void begin(); - void begin(uint8_t); - void begin(int); - void beginTransmission(uint8_t); - void beginTransmission(int); - uint8_t endTransmission(void); - uint8_t endTransmission(uint8_t); - uint8_t requestFrom(uint8_t, uint8_t); - uint8_t requestFrom(uint8_t, uint8_t, uint8_t); - uint8_t requestFrom(int, int); - uint8_t requestFrom(int, int, int); - virtual size_t write(uint8_t); - virtual size_t write(const uint8_t *, size_t); - virtual int available(void); - virtual int read(void); - virtual int peek(void); - virtual void flush(void); - void onReceive( void (*)(int) ); - void onRequest( void (*)(void) ); - - inline size_t write(unsigned long n) { return write((uint8_t)n); } - inline size_t write(long n) { return write((uint8_t)n); } - inline size_t write(unsigned int n) { return write((uint8_t)n); } - inline size_t write(int n) { return write((uint8_t)n); } - using Print::write; -}; - -extern TwoWire Wire; - -#endif - diff --git a/platform/osd-merkur/dev/old/new.cpp b/platform/osd-merkur/dev/old/new.cpp deleted file mode 100644 index b81031e90..000000000 --- a/platform/osd-merkur/dev/old/new.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -void * operator new(size_t size) -{ - return malloc(size); -} - -void * operator new[](size_t size) -{ - return malloc(size); -} - -void operator delete(void * ptr) -{ - free(ptr); -} - -void operator delete[](void * ptr) -{ - free(ptr); -} - -int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);}; -void __cxa_guard_release (__guard *g) {*(char *)g = 1;}; -void __cxa_guard_abort (__guard *) {}; - -void __cxa_pure_virtual(void) {}; - diff --git a/platform/osd-merkur/dev/old/new.h b/platform/osd-merkur/dev/old/new.h deleted file mode 100644 index 991c86c75..000000000 --- a/platform/osd-merkur/dev/old/new.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Header to define new/delete operators as they aren't provided by avr-gcc by default - Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453 - */ - -#ifndef NEW_H -#define NEW_H - -#include - -void * operator new(size_t size); -void * operator new[](size_t size); -void operator delete(void * ptr); -void operator delete[](void * ptr); - -__extension__ typedef int __guard __attribute__((mode (__DI__))); - -extern "C" int __cxa_guard_acquire(__guard *); -extern "C" void __cxa_guard_release (__guard *); -extern "C" void __cxa_guard_abort (__guard *); - -extern "C" void __cxa_pure_virtual(void); - -#endif - diff --git a/platform/osd-merkur/dev/old/twi.c b/platform/osd-merkur/dev/old/twi.c deleted file mode 100644 index 6b2db3cdc..000000000 --- a/platform/osd-merkur/dev/old/twi.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - twi.c - TWI/I2C library for Wiring & Arduino - Copyright (c) 2006 Nicholas Zambetti. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts -*/ - -#include -#include -#include -#include -#include -#include -#include "Arduino.h" // for digitalWrite - -#ifndef cbi -#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) -#endif - -#ifndef sbi -#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) -#endif - -#include "pins_arduino.h" -#include "twi.h" - -static volatile uint8_t twi_state; -static volatile uint8_t twi_slarw; -static volatile uint8_t twi_sendStop; // should the transaction end with a stop -static volatile uint8_t twi_inRepStart; // in the middle of a repeated start - -static void (*twi_onSlaveTransmit)(void); -static void (*twi_onSlaveReceive)(uint8_t*, int); - -static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH]; -static volatile uint8_t twi_masterBufferIndex; -static volatile uint8_t twi_masterBufferLength; - -static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH]; -static volatile uint8_t twi_txBufferIndex; -static volatile uint8_t twi_txBufferLength; - -static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH]; -static volatile uint8_t twi_rxBufferIndex; - -static volatile uint8_t twi_error; - -/* - * Function twi_init - * Desc readys twi pins and sets twi bitrate - * Input none - * Output none - */ -void twi_init(void) -{ - // initialize state - twi_state = TWI_READY; - twi_sendStop = true; // default value - twi_inRepStart = false; - - // activate internal pullups for twi. - digitalWrite(SDA, 1); - digitalWrite(SCL, 1); - - // initialize twi prescaler and bit rate - cbi(TWSR, TWPS0); - cbi(TWSR, TWPS1); - TWBR = ((F_CPU / TWI_FREQ) - 16) / 2; - - /* twi bit rate formula from atmega128 manual pg 204 - SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR)) - note: TWBR should be 10 or higher for master mode - It is 72 for a 16mhz Wiring board with 100kHz TWI */ - - // enable twi module, acks, and twi interrupt - TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA); -} - -/* - * Function twi_slaveInit - * Desc sets slave address and enables interrupt - * Input none - * Output none - */ -void twi_setAddress(uint8_t address) -{ - // set twi slave address (skip over TWGCE bit) - TWAR = address << 1; -} - -/* - * Function twi_readFrom - * Desc attempts to become twi bus master and read a - * series of bytes from a device on the bus - * Input address: 7bit i2c device address - * data: pointer to byte array - * length: number of bytes to read into array - * sendStop: Boolean indicating whether to send a stop at the end - * Output number of bytes read - */ -uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop) -{ - uint8_t i; - - // ensure data will fit into buffer - if(TWI_BUFFER_LENGTH < length){ - return 0; - } - - // wait until twi is ready, become master receiver - while(TWI_READY != twi_state){ - continue; - } - twi_state = TWI_MRX; - twi_sendStop = sendStop; - // reset error state (0xFF.. no error occured) - twi_error = 0xFF; - - // initialize buffer iteration vars - twi_masterBufferIndex = 0; - twi_masterBufferLength = length-1; // This is not intuitive, read on... - // On receive, the previously configured ACK/NACK setting is transmitted in - // response to the received byte before the interrupt is signalled. - // Therefor we must actually set NACK when the _next_ to last byte is - // received, causing that NACK to be sent in response to receiving the last - // expected byte of data. - - // build sla+w, slave device address + w bit - twi_slarw = TW_READ; - twi_slarw |= address << 1; - - if (true == twi_inRepStart) { - // if we're in the repeated start state, then we've already sent the start, - // (@@@ we hope), and the TWI statemachine is just waiting for the address byte. - // We need to remove ourselves from the repeated start state before we enable interrupts, - // since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning - // up. Also, don't enable the START interrupt. There may be one pending from the - // repeated start that we sent outselves, and that would really confuse things. - twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR - TWDR = twi_slarw; - TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START - } - else - // send start condition - TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA); - - // wait for read operation to complete - while(TWI_MRX == twi_state){ - continue; - } - - if (twi_masterBufferIndex < length) - length = twi_masterBufferIndex; - - // copy twi buffer to data - for(i = 0; i < length; ++i){ - data[i] = twi_masterBuffer[i]; - } - - return length; -} - -/* - * Function twi_writeTo - * Desc attempts to become twi bus master and write a - * series of bytes to a device on the bus - * Input address: 7bit i2c device address - * data: pointer to byte array - * length: number of bytes in array - * wait: boolean indicating to wait for write or not - * sendStop: boolean indicating whether or not to send a stop at the end - * Output 0 .. success - * 1 .. length to long for buffer - * 2 .. address send, NACK received - * 3 .. data send, NACK received - * 4 .. other twi error (lost bus arbitration, bus error, ..) - */ -uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop) -{ - uint8_t i; - - // ensure data will fit into buffer - if(TWI_BUFFER_LENGTH < length){ - return 1; - } - - // wait until twi is ready, become master transmitter - while(TWI_READY != twi_state){ - continue; - } - twi_state = TWI_MTX; - twi_sendStop = sendStop; - // reset error state (0xFF.. no error occured) - twi_error = 0xFF; - - // initialize buffer iteration vars - twi_masterBufferIndex = 0; - twi_masterBufferLength = length; - - // copy data to twi buffer - for(i = 0; i < length; ++i){ - twi_masterBuffer[i] = data[i]; - } - - // build sla+w, slave device address + w bit - twi_slarw = TW_WRITE; - twi_slarw |= address << 1; - - // if we're in a repeated start, then we've already sent the START - // in the ISR. Don't do it again. - // - if (true == twi_inRepStart) { - // if we're in the repeated start state, then we've already sent the start, - // (@@@ we hope), and the TWI statemachine is just waiting for the address byte. - // We need to remove ourselves from the repeated start state before we enable interrupts, - // since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning - // up. Also, don't enable the START interrupt. There may be one pending from the - // repeated start that we sent outselves, and that would really confuse things. - twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR - TWDR = twi_slarw; - TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START - } - else - // send start condition - TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs - - // wait for write operation to complete - while(wait && (TWI_MTX == twi_state)){ - continue; - } - - if (twi_error == 0xFF) - return 0; // success - else if (twi_error == TW_MT_SLA_NACK) - return 2; // error: address send, nack received - else if (twi_error == TW_MT_DATA_NACK) - return 3; // error: data send, nack received - else - return 4; // other twi error -} - -/* - * Function twi_transmit - * Desc fills slave tx buffer with data - * must be called in slave tx event callback - * Input data: pointer to byte array - * length: number of bytes in array - * Output 1 length too long for buffer - * 2 not slave transmitter - * 0 ok - */ -uint8_t twi_transmit(const uint8_t* data, uint8_t length) -{ - uint8_t i; - - // ensure data will fit into buffer - if(TWI_BUFFER_LENGTH < length){ - return 1; - } - - // ensure we are currently a slave transmitter - if(TWI_STX != twi_state){ - return 2; - } - - // set length and copy data into tx buffer - twi_txBufferLength = length; - for(i = 0; i < length; ++i){ - twi_txBuffer[i] = data[i]; - } - - return 0; -} - -/* - * Function twi_attachSlaveRxEvent - * Desc sets function called before a slave read operation - * Input function: callback function to use - * Output none - */ -void twi_attachSlaveRxEvent( void (*function)(uint8_t*, int) ) -{ - twi_onSlaveReceive = function; -} - -/* - * Function twi_attachSlaveTxEvent - * Desc sets function called before a slave write operation - * Input function: callback function to use - * Output none - */ -void twi_attachSlaveTxEvent( void (*function)(void) ) -{ - twi_onSlaveTransmit = function; -} - -/* - * Function twi_reply - * Desc sends byte or readys receive line - * Input ack: byte indicating to ack or to nack - * Output none - */ -void twi_reply(uint8_t ack) -{ - // transmit master read ready signal, with or without ack - if(ack){ - TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA); - }else{ - TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT); - } -} - -/* - * Function twi_stop - * Desc relinquishes bus master status - * Input none - * Output none - */ -void twi_stop(void) -{ - // send stop condition - TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO); - - // wait for stop condition to be exectued on bus - // TWINT is not set after a stop condition! - while(TWCR & _BV(TWSTO)){ - continue; - } - - // update twi state - twi_state = TWI_READY; -} - -/* - * Function twi_releaseBus - * Desc releases bus control - * Input none - * Output none - */ -void twi_releaseBus(void) -{ - // release bus - TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT); - - // update twi state - twi_state = TWI_READY; -} - -SIGNAL(TWI_vect) -{ - switch(TW_STATUS){ - // All Master - case TW_START: // sent start condition - case TW_REP_START: // sent repeated start condition - // copy device address and r/w bit to output register and ack - TWDR = twi_slarw; - twi_reply(1); - break; - - // Master Transmitter - case TW_MT_SLA_ACK: // slave receiver acked address - case TW_MT_DATA_ACK: // slave receiver acked data - // if there is data to send, send it, otherwise stop - if(twi_masterBufferIndex < twi_masterBufferLength){ - // copy data to output register and ack - TWDR = twi_masterBuffer[twi_masterBufferIndex++]; - twi_reply(1); - }else{ - if (twi_sendStop) - twi_stop(); - else { - twi_inRepStart = true; // we're gonna send the START - // don't enable the interrupt. We'll generate the start, but we - // avoid handling the interrupt until we're in the next transaction, - // at the point where we would normally issue the start. - TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ; - twi_state = TWI_READY; - } - } - break; - case TW_MT_SLA_NACK: // address sent, nack received - twi_error = TW_MT_SLA_NACK; - twi_stop(); - break; - case TW_MT_DATA_NACK: // data sent, nack received - twi_error = TW_MT_DATA_NACK; - twi_stop(); - break; - case TW_MT_ARB_LOST: // lost bus arbitration - twi_error = TW_MT_ARB_LOST; - twi_releaseBus(); - break; - - // Master Receiver - case TW_MR_DATA_ACK: // data received, ack sent - // put byte into buffer - twi_masterBuffer[twi_masterBufferIndex++] = TWDR; - case TW_MR_SLA_ACK: // address sent, ack received - // ack if more bytes are expected, otherwise nack - if(twi_masterBufferIndex < twi_masterBufferLength){ - twi_reply(1); - }else{ - twi_reply(0); - } - break; - case TW_MR_DATA_NACK: // data received, nack sent - // put final byte into buffer - twi_masterBuffer[twi_masterBufferIndex++] = TWDR; - if (twi_sendStop) - twi_stop(); - else { - twi_inRepStart = true; // we're gonna send the START - // don't enable the interrupt. We'll generate the start, but we - // avoid handling the interrupt until we're in the next transaction, - // at the point where we would normally issue the start. - TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ; - twi_state = TWI_READY; - } - break; - case TW_MR_SLA_NACK: // address sent, nack received - twi_stop(); - break; - // TW_MR_ARB_LOST handled by TW_MT_ARB_LOST case - - // Slave Receiver - case TW_SR_SLA_ACK: // addressed, returned ack - case TW_SR_GCALL_ACK: // addressed generally, returned ack - case TW_SR_ARB_LOST_SLA_ACK: // lost arbitration, returned ack - case TW_SR_ARB_LOST_GCALL_ACK: // lost arbitration, returned ack - // enter slave receiver mode - twi_state = TWI_SRX; - // indicate that rx buffer can be overwritten and ack - twi_rxBufferIndex = 0; - twi_reply(1); - break; - case TW_SR_DATA_ACK: // data received, returned ack - case TW_SR_GCALL_DATA_ACK: // data received generally, returned ack - // if there is still room in the rx buffer - if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){ - // put byte in buffer and ack - twi_rxBuffer[twi_rxBufferIndex++] = TWDR; - twi_reply(1); - }else{ - // otherwise nack - twi_reply(0); - } - break; - case TW_SR_STOP: // stop or repeated start condition received - // put a null char after data if there's room - if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){ - twi_rxBuffer[twi_rxBufferIndex] = '\0'; - } - // sends ack and stops interface for clock stretching - twi_stop(); - // callback to user defined callback - twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex); - // since we submit rx buffer to "wire" library, we can reset it - twi_rxBufferIndex = 0; - // ack future responses and leave slave receiver state - twi_releaseBus(); - break; - case TW_SR_DATA_NACK: // data received, returned nack - case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack - // nack back at master - twi_reply(0); - break; - - // Slave Transmitter - case TW_ST_SLA_ACK: // addressed, returned ack - case TW_ST_ARB_LOST_SLA_ACK: // arbitration lost, returned ack - // enter slave transmitter mode - twi_state = TWI_STX; - // ready the tx buffer index for iteration - twi_txBufferIndex = 0; - // set tx buffer length to be zero, to verify if user changes it - twi_txBufferLength = 0; - // request for txBuffer to be filled and length to be set - // note: user must call twi_transmit(bytes, length) to do this - twi_onSlaveTransmit(); - // if they didn't change buffer & length, initialize it - if(0 == twi_txBufferLength){ - twi_txBufferLength = 1; - twi_txBuffer[0] = 0x00; - } - // transmit first byte from buffer, fall - case TW_ST_DATA_ACK: // byte sent, ack returned - // copy data to output register - TWDR = twi_txBuffer[twi_txBufferIndex++]; - // if there is more to send, ack, otherwise nack - if(twi_txBufferIndex < twi_txBufferLength){ - twi_reply(1); - }else{ - twi_reply(0); - } - break; - case TW_ST_DATA_NACK: // received nack, we are done - case TW_ST_LAST_DATA: // received ack, but we are done already! - // ack future responses - twi_reply(1); - // leave slave receiver state - twi_state = TWI_READY; - break; - - // All - case TW_NO_INFO: // no state information - break; - case TW_BUS_ERROR: // bus error, illegal stop/start - twi_error = TW_BUS_ERROR; - twi_stop(); - break; - } -} - diff --git a/platform/osd-merkur/dev/old/twi.h b/platform/osd-merkur/dev/old/twi.h deleted file mode 100644 index 652659339..000000000 --- a/platform/osd-merkur/dev/old/twi.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - twi.h - TWI/I2C library for Wiring & Arduino - Copyright (c) 2006 Nicholas Zambetti. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef twi_h -#define twi_h - - #include - - //#define ATMEGA8 - - #ifndef TWI_FREQ - #define TWI_FREQ 100000L - #endif - - #ifndef TWI_BUFFER_LENGTH - #define TWI_BUFFER_LENGTH 32 - #endif - - #define TWI_READY 0 - #define TWI_MRX 1 - #define TWI_MTX 2 - #define TWI_SRX 3 - #define TWI_STX 4 - - void twi_init(void); - void twi_setAddress(uint8_t); - uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t); - uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); - uint8_t twi_transmit(const uint8_t*, uint8_t); - void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) ); - void twi_attachSlaveTxEvent( void (*)(void) ); - void twi_reply(uint8_t); - void twi_stop(void); - void twi_releaseBus(void); - -#endif - diff --git a/platform/osd-merkur/dev/optriac-sensor.c b/platform/osd-merkur/dev/optriac-sensor.c deleted file mode 100644 index 2f0566bc4..000000000 --- a/platform/osd-merkur/dev/optriac-sensor.c +++ /dev/null @@ -1,102 +0,0 @@ -/* -* Copyright (c) , Harald Pichler. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: servo-sensor.c,v 1.0 2013/02/20 19:34:06 nifi Exp $ -*/ - -/** -* \file -* optriac sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#include "contiki.h" -#include "Arduino.h" -#include "dev/optriac-sensor.h" - -#define PRINTF(...) printf(__VA_ARGS__) - -const struct sensors_sensor optriac_sensor; -static int status(int type); -static int enabled = 0; -static int optriac[2]={0,0}; -static int optriacpin[8]={OPTRIAC_PIN_1,OPTRIAC_PIN_2}; - -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return optriac[type]; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - switch(type) { - case SENSORS_ACTIVE: - if(c) { - if(!status(SENSORS_ACTIVE)) { - pinMode(optriacpin[OPTRIAC_SENSOR_1], OUTPUT); - digitalWrite(optriacpin[OPTRIAC_SENSOR_1], LOW); - pinMode(optriacpin[OPTRIAC_SENSOR_2], OUTPUT); - digitalWrite(optriacpin[OPTRIAC_SENSOR_2], LOW); - - enabled = 1; - } - } else { - enabled = 1; - } - break; - case OPTRIAC_SENSOR_1: - case OPTRIAC_SENSOR_2: - - if(c==0){ - digitalWrite(optriacpin[type], LOW); - optriac[type]=0; - }else{ - digitalWrite(optriacpin[type], HIGH); - optriac[type]=1; - }; - break; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return enabled; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(optriac_sensor, OPTRIAC_SENSOR, value, configure, status); diff --git a/platform/osd-merkur/dev/optriac-sensor.h b/platform/osd-merkur/dev/optriac-sensor.h deleted file mode 100644 index 8cec46c14..000000000 --- a/platform/osd-merkur/dev/optriac-sensor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright (c), Harald Pichler. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: servo-sensor.h,v 1.0 2013/02/20 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Servo sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#ifndef __OPTRIAC_SENSOR_H__ -#define __OPTRIAC_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor optriac_sensor; - -#define OPTRIAC_SENSOR "TRIAC" -#define OPTRIAC_SENSOR_1 0 -#define OPTRIAC_SENSOR_2 1 - -/* default pins Arduino-Merkurboard */ -#define OPTRIAC_PIN_1 2 -#define OPTRIAC_PIN_2 3 - -#endif /* __OPTRIAC_SENSOR_H__ */ diff --git a/platform/osd-merkur/dev/pir-sensor.h b/platform/osd-merkur/dev/pir-sensor.h deleted file mode 100644 index ac59e0f9f..000000000 --- a/platform/osd-merkur/dev/pir-sensor.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright (c) 2012, BinaryLabs. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: battery-sensor.h,v 1.1 2012/08/25 19:34:06 nifi Exp $ -*/ - -/** -* \file -* PIR sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#ifndef __PIR_SENSOR_H__ -#define __PIR_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor pir_sensor; - -#define PIR_SENSOR "PIR" - -#endif /* __PIR_SENSOR_H__ */ \ No newline at end of file diff --git a/platform/osd-merkur/dev/relay-sensor.c b/platform/osd-merkur/dev/relay-sensor.c deleted file mode 100644 index 6415926c9..000000000 --- a/platform/osd-merkur/dev/relay-sensor.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -* Copyright (c) , Harald Pichler. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: relay-sensor.c,v 1.0 2013/11/22 19:34:06 nifi Exp $ -*/ - -/** -* \file -* relay sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#include "contiki.h" -#include "dev/relay.h" -#include "dev/relay-sensor.h" - -#define PRINTF(...) printf(__VA_ARGS__) - -const struct sensors_sensor relay_sensor; -static int status(int type); -static int enabled = 0; -static int relay[8]={0,0,0,0,0,0,0,0}; -static int relaypin[8]={RELAY_PIN_1,RELAY_PIN_2,RELAY_PIN_3,RELAY_PIN_4,RELAY_PIN_5,RELAY_PIN_6,RELAY_PIN_7,RELAY_PIN_8}; -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return relay[type]; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - switch(type) { - case SENSORS_ACTIVE: - if(c) { - if(!status(SENSORS_ACTIVE)) { - relay_init(relaypin[RELAY_SENSOR_1]); - relay_init(relaypin[RELAY_SENSOR_2]); - relay_init(relaypin[RELAY_SENSOR_3]); - relay_init(relaypin[RELAY_SENSOR_4]); - relay_init(relaypin[RELAY_SENSOR_5]); - relay_init(relaypin[RELAY_SENSOR_6]); - relay_init(relaypin[RELAY_SENSOR_7]); - relay_init(relaypin[RELAY_SENSOR_8]); - enabled = 1; - } - } else { - enabled = 1; - } - break; - case RELAY_SENSOR_1: - case RELAY_SENSOR_2: - case RELAY_SENSOR_3: - case RELAY_SENSOR_4: - case RELAY_SENSOR_5: - case RELAY_SENSOR_6: - case RELAY_SENSOR_7: - case RELAY_SENSOR_8: - if(c==0){ - relay_off(relaypin[type]); - relay[type]=0; - }else{ - relay_on(relaypin[type]); - relay[type]=1; - }; - break; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return enabled; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(relay_sensor, RELAY_SENSOR, value, configure, status); diff --git a/platform/osd-merkur/dev/relay-sensor.h b/platform/osd-merkur/dev/relay-sensor.h deleted file mode 100644 index 88b9dd0f5..000000000 --- a/platform/osd-merkur/dev/relay-sensor.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright (c), Harald Pichler. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: relay-sensor.h,v 1.0 2013/11/22 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Relay sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#ifndef __RELAY_SENSOR_H__ -#define __RELAY_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor relay_sensor; - -#define RELAY_SENSOR "RELAY" -#define RELAY_SENSOR_1 0 -#define RELAY_SENSOR_2 1 -#define RELAY_SENSOR_3 2 -#define RELAY_SENSOR_4 3 -#define RELAY_SENSOR_5 4 -#define RELAY_SENSOR_6 5 -#define RELAY_SENSOR_7 6 -#define RELAY_SENSOR_8 7 - -/* default pins Arduino-Merkurboard */ -#define RELAY_PIN_1 10 -#define RELAY_PIN_2 11 -#define RELAY_PIN_3 12 -#define RELAY_PIN_4 13 -#define RELAY_PIN_5 15 -#define RELAY_PIN_6 16 -#define RELAY_PIN_7 17 -#define RELAY_PIN_8 18 - -#endif /* __RELAY_SENSOR_H__ */ diff --git a/platform/osd-merkur/dev/relay.c b/platform/osd-merkur/dev/relay.c deleted file mode 100644 index 67d9c7f5b..000000000 --- a/platform/osd-merkur/dev/relay.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2012 harald pichler - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of the copyright holders nor the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** - * \file - * - * \brief - * This file provides Raven LED support. - * - * \author - * Harald Pichler harald@the-develop.net - * - */ -#include "Arduino.h" -#include "relay.h" - -/** - * \addtogroup relay - * \{ -*/ -/*---------------------------------------------------------------------------*/ -/** - * \brief init RELAY PINS. -*/ -void -relay_init(uint8_t pin) -{ - pinMode(pin, OUTPUT); - digitalWrite(pin, LOW); -} -/** - * \brief Turns the RELAY on. -*/ - -void -relay_on(uint8_t pin) -{ - digitalWrite(pin, HIGH); -} - -/*---------------------------------------------------------------------------*/ - -/** - * \brief Turns the RELAY off -*/ -void -relay_off(uint8_t pin) -{ - digitalWrite(pin, LOW); -} diff --git a/platform/osd-merkur/dev/relay.h b/platform/osd-merkur/dev/relay.h deleted file mode 100644 index 3b9b48759..000000000 --- a/platform/osd-merkur/dev/relay.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2012 Harald Pichler - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of the copyright holders nor the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** - * \file - * - * \brief - * This file provides Raven LED support. - * - * \author - * Harald Pichler harald@the-develop.net - * - */ - -#ifndef __RELAY_H__ -#define __RELAY_H__ - -#include - -/** @name RELAY Functions */ -/** @{ */ -void relay_init(uint8_t pin); -void relay_on(uint8_t pin); -void relay_off(uint8_t pin); - -/** @} */ - -#endif /* __RELAY_H__ */ diff --git a/platform/osd-merkur/dev/servo-sensor.c b/platform/osd-merkur/dev/servo-sensor.c deleted file mode 100644 index 9da3caf80..000000000 --- a/platform/osd-merkur/dev/servo-sensor.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -* Copyright (c) , Harald Pichler. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: servo-sensor.c,v 1.0 2013/02/20 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Servo sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#include "contiki.h" -#include "dev/servo.h" -#include "dev/servo-sensor.h" - -#define PRINTF(...) printf(__VA_ARGS__) - -const struct sensors_sensor servo_sensor; -static int status(int type); -static int enabled = 0; - -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - switch(type) { - case SERVO_SENSOR_A: - return servo_get(0);; - - /* Total Solar Radiation. */ - case SERVO_SENSOR_B: - return servo_get(1); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - switch(type) { - case SENSORS_ACTIVE: - if(c) { - if(!status(SENSORS_ACTIVE)) { - servo_init(); - enabled = 1; - } - } else { - servo_off(); - enabled = 1; - } - break; - case SERVO_SENSOR_A: - servo_set(0,c); - break; - case SERVO_SENSOR_B: - servo_set(1,c); - break; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return enabled; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(servo_sensor, SERVO_SENSOR, value, configure, status); diff --git a/platform/osd-merkur/dev/servo-sensor.h b/platform/osd-merkur/dev/servo-sensor.h deleted file mode 100644 index 44e50c0f8..000000000 --- a/platform/osd-merkur/dev/servo-sensor.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright (c), Harald Pichler. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: servo-sensor.h,v 1.0 2013/02/20 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Servo sensor header file for Atmega128rfa1. -* \author -* Harald Pichler -*/ - -#ifndef __SERVO_SENSOR_H__ -#define __SERVO_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor servo_sensor; - -#define SERVO_SENSOR "Servo" -#define SERVO_SENSOR_A 0 -#define SERVO_SENSOR_B 1 - -#endif /* __SERVO_SENSOR_H__ */ diff --git a/platform/osd-merkur/dev/servo.c b/platform/osd-merkur/dev/servo.c deleted file mode 100644 index 874e98b89..000000000 --- a/platform/osd-merkur/dev/servo.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - * Device driver for the Sensirion SHT1x/SHT7x family of humidity and - * temperature sensors. - */ - -#include "contiki.h" -#include -#include - -#define DEBUG 0 - -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif - -/*---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------*/ -/* - * servo device - */ - -unsigned int servoa=SERVO_INIT; -unsigned int servob=SERVO_INIT; - -void -servo_init(void) -{ - // Port E initialization - // Set Pin 3 and 4 to output mode for OCR1A and OCR2A - DDRE |= 1<<3 | 1<<4; - - // Timer/Counter 3 initialization - // Clock source: System Clock - // Clock value: 2000.000 kHz - // Mode: Ph. & fr. cor. PWM top=ICR1 - // OC3A output: Connected - // OC3B output: Connected - // OC3C output: Connected - // Noise Canceler: Off - // Input Capture on Falling Edge - // Timer3 Overflow Interrupt: Off - // Input Capture Interrupt: Off - // Compare A Match Interrupt: Off - // Compare B Match Interrupt: Off - // Compare C Match Interrupt: Off - - /* TCCR3A = [COM3A1|COM3A0|COM3B1|COM3B0||FOC3A|FOC3B|WGM31|WGM30] */ - /* 1 0 1 0 1 0 0 0 */ - TCCR3A=0xA8; - /* TCCR3B = [ ICNC3| ICES3| -| WGM33||WGM32| CS32| CS31| CS30] */ - /* 0 0 0 1 0 0 1 0 */ - TCCR3B=0x12; - TCNT3H=0x00; - TCNT3L=0x00; - // ICR3 has a computed value of 20,000 - see the chip manual for how this - // value was derived. - // 20000 == 0x4e20 so that's what goes into the high and low byte of the ICR3 register - // alternatively, Codevision would let you just do ICR3 = 20000; - ICR3H=0x4E; - ICR3L=0x20; - - // OCR3A will govern the steering servo, OCR3B will govern throttle - OCR3A = servoa; // set it to an initial position somewhere in the middle of the 1 to 2ms range - - // OCR3A will govern the steering servo, OCR3B will govern throttle - OCR3B = servob; // set it to an initial position somewhere in the middle of the 1 to 2ms range - // start with motor off - no duty cycle at all - OCR3CH=0x00; - OCR3CL=0x00; -} -/*---------------------------------------------------------------------------*/ -/* - * Power of device. - */ -void -servo_off(void) -{ - -} -/*---------------------------------------------------------------------------*/ -/* - * get servo position - */ -unsigned int -servo_get(unsigned int i) -{ - if(i==0) - return servoa; - if(i==1) - return servob; - return 0; -} -/*---------------------------------------------------------------------------*/ -/* - * Set servo position - */ -unsigned int -servo_set(unsigned i,unsigned int j) -{ - if(j > SERVO_MAX) - j=SERVO_MAX; - if(j < SERVO_MIN) - j=SERVO_MIN; - - if(i==0) - { - servoa=j; - OCR3A = servoa; - return 1; - } - if(i==1) - { - servob=j; - OCR3B = servob; - return 1; - } - - return 0; -} diff --git a/platform/osd-merkur/dev/servo.h b/platform/osd-merkur/dev/servo.h deleted file mode 100644 index c6ae4ab57..000000000 --- a/platform/osd-merkur/dev/servo.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef SERVO_H -#define SERVO_H - -#define SERVO_MIN 575 -#define SERVO_MAX 2425 -#define SERVO_INIT 1500 - -void servo_init(void); -void servo_off(void); - -unsigned int servo_get(unsigned int i); -unsigned int servo_set(unsigned i,unsigned int j); - -#endif /* SHT11_H */ diff --git a/platform/osd-merkur/dev/t4-servo-sensor.c b/platform/osd-merkur/dev/t4-servo-sensor.c deleted file mode 100644 index a35b2de02..000000000 --- a/platform/osd-merkur/dev/t4-servo-sensor.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -** Copyright (C) 2013-2014 Marcus Priesch, All rights reserved -** In Prandnern 31, A--2122 Riedenthal, Austria. office@priesch.co.at -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. Neither the name of the Institute nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -** SUCH DAMAGE. -** -**++ -** Name -** t4-servo-sensor -** -** Purpose -** Implements a sensor around t4servo.c -** -** -** Revision Dates -** 31-Mar-2013 (MPR) Creation -** 12-Mar-2014 (MPR) Factored to support configurable amount of pwm's -** ««revision-date»»··· -**-- -*/ - -#include "contiki.h" -#include "dev/t4-servo.h" -#include "dev/t4-servo-sensor.h" - -const struct sensors_sensor t4_servo_sensor; - -static int status(int type); -static int enabled = 0; - -static int value (int channel) - { - if (channel >= SERVO_COUNT) - return -1; - else if (channel < 0) - return -2; - else - return t4_servo_get (channel); - } - -static int configure (int type, int c) // type, c: SENSORS_ACTIVE, 1 -> act. - // type, c: SENSORS_ACTIVE, 0 -> deact. - { - switch (type) - { - case SENSORS_ACTIVE : - if (c == 0) - { - t4_servo_off (); - } - else if (c == 1) - { - t4_servo_init (); - } - break; - - default : - if (type >= SERVO_COUNT) - return -1; - else - t4_servo_set (type, c); - break; - - } - return 0; - } - -static int status(int type) - { - switch (type) - { - case SENSORS_ACTIVE: - case SENSORS_READY: - return enabled; - } - return 0; - } - -SENSORS_SENSOR(t4_servo_sensor, T4_SENSOR_NAME, value, configure, status); diff --git a/platform/osd-merkur/dev/t4-servo-sensor.h b/platform/osd-merkur/dev/t4-servo-sensor.h deleted file mode 100644 index 099bb4c66..000000000 --- a/platform/osd-merkur/dev/t4-servo-sensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Copyright (C) 2013-2014 Marcus Priesch, All rights reserved -** In Prandnern 31, A--2122 Riedenthal, Austria. office@priesch.co.at -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. Neither the name of the Institute nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -** SUCH DAMAGE. -** -**++ -** Name -** t4-servo-sensor -** -** Purpose -** Implements a sensor around t4servo.c -** -** -** Revision Dates -** 31-Mar-2013 (MPR) Creation -** 12-Mar-2014 (MPR) Factored to support configurable amount of pwm's - ««revision-date»»··· -**-- -*/ - -#ifndef __T4_SERVO_SENSOR_H__ -#define __T4_SERVO_SENSOR_H__ - -#include "lib/sensors.h" -#include "t4-servo-config.h" - -extern const struct sensors_sensor t4_servo_sensor; - -#endif /* __T4_SERVO_SENSOR_H__ */ diff --git a/platform/osd-merkur/dev/t4-servo.c b/platform/osd-merkur/dev/t4-servo.c deleted file mode 100644 index 45f74ad9b..000000000 --- a/platform/osd-merkur/dev/t4-servo.c +++ /dev/null @@ -1,139 +0,0 @@ -/* -** Copyright (C) 2013-2014 Marcus Priesch, All rights reserved -** In Prandnern 31, A--2122 Riedenthal, Austria. office@priesch.co.at -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. Neither the name of the Institute nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -** SUCH DAMAGE. -** -**++ -** Name -** t4-servo -** -** Purpose -** Implements software pwm on any portpins via timer 4 -** -** -** Revision Dates -** 31-Mar-2013 (MPR) Creation -** 12-Mar-2014 (MPR) Factored to support configurable amount of pwm's -** ««revision-date»»··· -**-- -*/ - -#include "t4-servo.h" -#include "t4-servo-config.h" -#include "t4-servo-hardware.h" -#include -#include - -// static servo_channel_type servo_channels [SERVO_COUNT]; - -// timer 4: CTC OCR4A -#define WGM4 0x4 - -void t4_servo_init (void) -{ - unsigned char channel; - - for (channel = 0; channel < SERVO_COUNT; channel ++) - { - _SFR_IO8 (servo_channels [channel].ddr ) |= servo_channels [channel].pin; - _SFR_IO8 (servo_channels [channel].port) &= ~(servo_channels [channel].pin); - } - - cli (); - TCCR4A = 0x00; - TCCR4A_struct.wgm4 = WGM4 & 0x3; - TCCR4B_struct.wgm4 = (WGM4 & 0xc) >> 2; - TCCR4B_struct.cs4 = 0x1; // No prescaler - TCCR4C = 0x00; - OCR4A = (T4_VALUE); - TIMSK4_struct.ocie4a = 1; - TIMSK4_struct.toie4 = 1; - sei(); -} - -void t4_servo_off (void) - { - TIMSK4_struct.toie4 = 0; - TIMSK4_struct.ocie4a = 0; - } - -int t4_servo_get (unsigned int channel) - { - if (channel >= SERVO_COUNT) - return -1; - //printf ("t4_servo_get: %d, %d\n", channel, servo_channels [channel].duty); - return servo_channels [channel].duty; - } - -int t4_servo_set (unsigned int channel, unsigned char duty) - { - //printf ("t4_servo_set: %d, %d\n", channel, duty); - - if (channel >= SERVO_COUNT) - return -1; - - if (duty > SERVO_MAX) - return -2; - - if (duty < SERVO_MIN) - return -3; - - servo_channels [channel].duty = duty; - return 0; - } - -ISR (TIMER4_COMPA_vect, ISR_NOBLOCK) - { - unsigned char channel; - static unsigned int tick_count = 0; - - cli (); - for (channel = 0; channel < SERVO_COUNT; channel ++) - { - if (tick_count < servo_channels [channel].duty) - { - // turn on -// _SFR_IO8 (servo_channels [channel].ddr ) |= servo_channels [channel].pin; - _SFR_IO8 (servo_channels [channel].port) |= servo_channels [channel].pin; - } - else - { - // turn off - _SFR_IO8 (servo_channels [channel].port) &= ~(servo_channels [channel].pin); -// _SFR_IO8 (servo_channels [channel].ddr ) |= servo_channels [channel].pin; - } - } - - tick_count ++; - - if (tick_count >= (SERVO_MAX + SERVO_OFFSET)) - { - tick_count = 0; - } - sei(); - - } - diff --git a/platform/osd-merkur/dev/t4-servo.h b/platform/osd-merkur/dev/t4-servo.h deleted file mode 100644 index 5acdc4013..000000000 --- a/platform/osd-merkur/dev/t4-servo.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Copyright (C) 2013-2014 Marcus Priesch, All rights reserved -** In Prandnern 31, A--2122 Riedenthal, Austria. office@priesch.co.at -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. Neither the name of the Institute nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -** SUCH DAMAGE. -** -**++ -** Name -** t4-servo -** -** Purpose -** Implements software pwm on any portpins via timer 4 -** -** -** Revision Dates -** 31-Mar-2013 (MPR) Creation -** 12-Mar-2014 (MPR) Factored to support configurable amount of pwm's - ««revision-date»»··· -**-- -*/ - -#ifndef __T4_SERVO_H__ -#define __T4_SERVO_H__ - -typedef struct struct_servo_channel -{ - unsigned char port; - unsigned char ddr; - unsigned char pin; - unsigned char duty; -} servo_channel_type; - -void t4_servo_init(void); -void t4_servo_off(void); - -int t4_servo_get(unsigned int channel); -int t4_servo_set(unsigned int channel, unsigned char duty); - -#endif /* __T4_SERVO_H__ */ diff --git a/platform/osd-merkur/dev/temperature-sensor.c b/platform/osd-merkur/dev/temperature-sensor.c deleted file mode 100644 index c85896178..000000000 --- a/platform/osd-merkur/dev/temperature-sensor.c +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright (c) 2012, BinaryLabs. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: temperature-sensor.c,v 1.1 2010/08/25 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Temperature sensor header file for Atmega128rfa1. -* \author -* Paulo Louro -*/ - -#include "contiki.h" -#include "dev/temperature-sensor.h" - -#define PRINTF(...) printf(__VA_ARGS__) - - -const struct sensors_sensor temperature_sensor; - -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return readInternalTemp(); -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - return 1; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - return 1; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR, value, configure, status); \ No newline at end of file diff --git a/platform/osd-merkur/dev/temperature-sensor.h b/platform/osd-merkur/dev/temperature-sensor.h deleted file mode 100644 index 6cf5dbf26..000000000 --- a/platform/osd-merkur/dev/temperature-sensor.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2012, BinaryLabs. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* @(#)$Id: temperature-sensor.h,v 1.1 2012/08/25 19:34:06 nifi Exp $ -*/ - -/** -* \file -* Temperature sensor header file for Atmega128rfa1. -* \author -* Paulo Louro -*/ - -#ifndef __TEMPERATURE_SENSOR_H__ -#define __TEMPERATURE_SENSOR_H__ - -#include "lib/sensors.h" -#include "dev/adc.h" - -extern const struct sensors_sensor temperature_sensor; - -#define TEMPERATURE_SENSOR "Temperature" - -#endif /* __TEMPERATURE_SENSOR_H__ */ \ No newline at end of file diff --git a/regression-tests/20-compile-osd-ports/Makefile b/regression-tests/20-compile-osd-ports/Makefile index f4f21e8ff..26224a1b5 100644 --- a/regression-tests/20-compile-osd-ports/Makefile +++ b/regression-tests/20-compile-osd-ports/Makefile @@ -3,28 +3,52 @@ EXAMPLESDIR=../../examples TOOLSDIR=../../tools EXAMPLES = \ -hello-world/osd-merkur \ -osd/er-rest-example-merkurboard/osd-merkur \ -osd/rpl-border-router/osd-merkur \ -osd/slip-radio/osd-merkur \ -osd/arduino-dooralert/osd-merkur \ -osd/arduino-merkurboard/osd-merkur \ -osd/arduino-plantobserving/osd-merkur \ -osd/arduino-roomalert/osd-merkur \ -osd/arduino-sketch/osd-merkur \ -osd/arduino-wateralert/osd-merkur \ -osd/climate/osd-merkur \ -osd/climate2/osd-merkur \ -osd/servo-sensor/osd-merkur \ -osd/pingtheplug/osd-merkur \ -osd/powerbox/osd-merkur \ -osd/embedd-vm-merkurboard/osd-merkur \ -osd/light-actor/osd-merkur \ -#osd/dual-rgbw-actor/osd-merkur \ -#osd/light-shutter-control/osd-merkur \ -#osd/pir-sensor/osd-merkur \ -#osd/pwm-example/osd-merkur \ -#osd/wallclock-timer/osd-merkur +hello-world/osd-merkur-128 \ +osd/er-rest-example-merkurboard/osd-merkur-128 \ +osd/rpl-border-router/osd-merkur-128 \ +osd/slip-radio/osd-merkur-128 \ +osd/arduino-dooralert/osd-merkur-128 \ +osd/arduino-merkurboard/osd-merkur-128 \ +osd/arduino-plantobserving/osd-merkur-128 \ +osd/arduino-roomalert/osd-merkur-128 \ +osd/arduino-sketch/osd-merkur-128 \ +osd/arduino-wateralert/osd-merkur-128 \ +osd/climate/osd-merkur-128 \ +osd/climate2/osd-merkur-128 \ +osd/servo-sensor/osd-merkur-128 \ +osd/pingtheplug/osd-merkur-128 \ +osd/powerbox/osd-merkur-128 \ +osd/embedd-vm-merkurboard/osd-merkur-128 \ +osd/light-actor/osd-merkur-128 \ +hello-world/osd-merkur-256 \ +osd/er-rest-example-merkurboard/osd-merkur-256 \ +osd/rpl-border-router/osd-merkur-256 \ +osd/slip-radio/osd-merkur-256 \ +osd/arduino-dooralert/osd-merkur-256 \ +osd/arduino-merkurboard/osd-merkur-256 \ +osd/arduino-plantobserving/osd-merkur-256 \ +osd/arduino-roomalert/osd-merkur-256 \ +osd/arduino-sketch/osd-merkur-256 \ +osd/arduino-wateralert/osd-merkur-256 \ +osd/climate/osd-merkur-256 \ +osd/climate2/osd-merkur-256 \ +osd/servo-sensor/osd-merkur-256 \ +osd/pingtheplug/osd-merkur-256 \ +osd/powerbox/osd-merkur-256 \ +osd/embedd-vm-merkurboard/osd-merkur-256 \ +osd/light-actor/osd-merkur-256 \ + +#osd/dual-rgbw-actor/osd-merkur-128 \ +#osd/light-shutter-control/osd-merkur-128 \ +#osd/pir-sensor/osd-merkur-128 \ +#osd/pwm-example/osd-merkur-128 \ +#osd/wallclock-timer/osd-merkur-128 \ + +#osd/dual-rgbw-actor/osd-merkur-256 \ +#osd/light-shutter-control/osd-merkur-256 \ +#osd/pir-sensor/osd-merkur-256 \ +#osd/pwm-example/osd-merkur-256 \ +#osd/wallclock-timer/osd-merkur-256 \ TOOLS=