Browse Source

Created new file structure

Janco Kock 10 năm trước cách đây
mục cha
commit
b12fac4b8e
100 tập tin đã thay đổi với 7753 bổ sung12632 xóa
  1. 6 0
      .gitignore.bak
  2. 3 16
      .idea/InternetRadio.iml
  3. 5 0
      .idea/misc.xml
  4. 690 28
      .idea/workspace.xml
  5. 0 7
      CMakeLists.txt
  6. 20 81
      Makefile
  7. 0 191
      include/arch/arm.h
  8. 0 96
      include/arch/arm/atom.h
  9. 0 124
      include/arch/m68k/irqreg.h
  10. 0 109
      include/cfg/arch.h
  11. 0 16
      include/cpu_load.h
  12. 0 156
      include/dev/board.h
  13. 0 91
      include/dev/irqreg_avr.h
  14. 0 131
      include/dev/irqreg_h8.h
  15. 0 121
      include/dev/irqreg_m68k.h
  16. 0 1023
      include/dev/sbbif0.h
  17. 0 829
      include/dev/sbbif1.h
  18. 0 829
      include/dev/sbbif2.h
  19. 0 829
      include/dev/sbbif3.h
  20. 0 164
      include/dev/tlc16c550.h
  21. 0 90
      include/dev/twif.h
  22. 0 604
      include/dev/uart.h
  23. 0 136
      include/errno.h
  24. 0 137
      include/fs/dospart.h
  25. 0 258
      include/fs/phatvol.h
  26. 0 78
      include/fs_org/fat.h
  27. 0 35
      include/fs_org/fatfs.h
  28. 0 163
      include/fs_org/fs.h
  29. 0 186
      include/fs_org/phatdir.h
  30. 0 161
      include/fs_org/phatfs.h
  31. 0 120
      include/fs_org/uromfs.h
  32. 0 141
      include/sys/heap.h
  33. 0 221
      include/sys/thread.h
  34. 0 115
      include/watchdog.h
  35. 223 223
      lib/display.c
  36. 63 63
      lib/display.h
  37. 119 119
      lib/fat.h
  38. 153 153
      lib/fatdrv.h
  39. 399 399
      lib/flash.c
  40. 68 68
      lib/flash.h
  41. 326 326
      lib/keyboard.c
  42. 112 113
      lib/keyboard.h
  43. 111 111
      lib/led.c
  44. 48 49
      lib/led.h
  45. 371 371
      lib/log.c
  46. 131 131
      lib/log.h
  47. 347 347
      lib/mmc.c
  48. 0 3
      lib/mmc.h
  49. 758 758
      lib/mmcdrv.c
  50. 100 100
      lib/mmcdrv.h
  51. 51 51
      lib/platform.h
  52. 142 142
      lib/portio.h
  53. 151 151
      lib/remcon.c
  54. 52 52
      lib/remcon.h
  55. 471 471
      lib/rtc.c
  56. 158 158
      lib/rtc.h
  57. 228 228
      lib/spidrv.c
  58. 53 53
      lib/spidrv.h
  59. 144 144
      lib/system.h
  60. 183 183
      lib/typedefs.h
  61. 151 151
      lib/uart0driver.c
  62. 60 60
      lib/uart0driver.h
  63. 164 164
      lib/vs10xx.h
  64. 46 4
      main.c
  65. 38 0
      nutos/nut/Makedefs.arm-ecross-gcc
  66. 46 0
      nutos/nut/Makedefs.arm-ecross-gccdbg
  67. 39 0
      nutos/nut/Makedefs.arm-gcc
  68. 47 0
      nutos/nut/Makedefs.arm-gccdbg
  69. 45 0
      nutos/nut/Makedefs.arm-thumb-gcc
  70. 39 0
      nutos/nut/Makedefs.avr-gcc
  71. 46 0
      nutos/nut/Makedefs.avr-gccdbg
  72. 51 0
      nutos/nut/Makedefs.avr-icc7
  73. 40 0
      nutos/nut/Makedefs.avr32-gcc
  74. 46 0
      nutos/nut/Makedefs.avr32-gccdbg
  75. 52 0
      nutos/nut/Makedefs.avrext-icc7
  76. 38 0
      nutos/nut/Makedefs.cm3-ecross-gcc
  77. 52 0
      nutos/nut/Makedefs.cm3-ecross-gccdbg
  78. 39 0
      nutos/nut/Makedefs.cm3-gcc
  79. 54 0
      nutos/nut/Makedefs.cm3-gccdbg
  80. 65 0
      nutos/nut/Makedefs.h8-gcc
  81. 42 0
      nutos/nut/Makedefs.m68k-gcc
  82. 48 0
      nutos/nut/Makedefs.m68k-gccdbg
  83. 63 0
      nutos/nut/Makedefs.unix-gcc
  84. 57 0
      nutos/nut/Makerules.all
  85. 37 0
      nutos/nut/Makerules.arm-ecross-gcc
  86. 37 0
      nutos/nut/Makerules.arm-ecross-gccdbg
  87. 38 0
      nutos/nut/Makerules.arm-gcc
  88. 38 0
      nutos/nut/Makerules.arm-gccdbg
  89. 38 0
      nutos/nut/Makerules.arm-thumb-gcc
  90. 38 0
      nutos/nut/Makerules.avr-gcc
  91. 38 0
      nutos/nut/Makerules.avr-gccdbg
  92. 72 0
      nutos/nut/Makerules.avr-icc7
  93. 38 0
      nutos/nut/Makerules.avr32-gcc
  94. 38 0
      nutos/nut/Makerules.avr32-gccdbg
  95. 72 0
      nutos/nut/Makerules.avrext-icc7
  96. 37 0
      nutos/nut/Makerules.cm3-ecross-gcc
  97. 37 0
      nutos/nut/Makerules.cm3-ecross-gccdbg
  98. 38 0
      nutos/nut/Makerules.cm3-gcc
  99. 38 0
      nutos/nut/Makerules.cm3-gccdbg
  100. 65 0
      nutos/nut/Makerules.gcc

+ 6 - 0
.gitignore → .gitignore.bak

@@ -3,6 +3,8 @@
 *.ko
 *.obj
 *.elf
+*.d
+*.lst
 
 # Precompiled Headers
 *.gch
@@ -19,6 +21,8 @@
 *.so
 *.so.*
 *.dylib
+*.bin
+*.map
 
 # Executables
 *.exe
@@ -30,3 +34,5 @@
 
 # Debug files
 *.dSYM/
+*.sh
+.idea/

+ 3 - 16
.idea/InternetRadio.iml

@@ -1,25 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="CPP_MODULE" version="4">
   <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/main.cpp" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/CMakeLists.txt" isTestSource="false" />
-    </content>
+    <content url="file://$MODULE_DIR$" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module-library">
       <library name="Header Search Paths">
-        <CLASSES>
-          <root url="file:///usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed" />
-          <root url="file:///usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include" />
-          <root url="file:///usr/include" />
-          <root url="file:///usr/local/include" />
-        </CLASSES>
-        <SOURCES>
-          <root url="file:///usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed" />
-          <root url="file:///usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include" />
-          <root url="file:///usr/include" />
-          <root url="file:///usr/local/include" />
-        </SOURCES>
+        <CLASSES />
+        <SOURCES />
       </library>
     </orderEntry>
   </component>

+ 5 - 0
.idea/misc.xml

@@ -1,6 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
+  <component name="CidrRootsConfiguration">
+    <sourceRoots />
+    <libraryRoots />
+    <excludeRoots />
+  </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="false">
     <OptionsSetting value="true" id="Add" />
     <OptionsSetting value="true" id="Remove" />

+ 690 - 28
.idea/workspace.xml

@@ -11,7 +11,339 @@
     </ADDITIONAL_GENERATION_ENVIRONMENT>
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="8005cdec-074e-478f-b095-591cd1517046" name="Default" comment="" />
+    <list default="true" id="8005cdec-074e-478f-b095-591cd1517046" name="Default" comment="">
+      <change type="DELETED" beforePath="$PROJECT_DIR$/CMakeLists.txt" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_aic.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_ccfg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_dbgu.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_ebi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_efc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_emac.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_matrix.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_mc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_mci.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_pio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_pit.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_pmc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_ps.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_rstc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_sdramc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_sf.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_smc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_spi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_ssc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_tc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_twi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_us.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_wd.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91_wdt.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91eb40a.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91sam7x.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91sam9260.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/at91x40.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/atom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/gba.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/irqreg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/lpc2xxx.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/arm/timer.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/avr.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/avr/atom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/avr/gcc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/avr/icc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/avr/irqreg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/avr/timer.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/h8.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/h8300h/atom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/h8300h/h83068f.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/h8300h/irqreg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/m68k.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/m68k/atom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/m68k/irqreg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/timer.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/unix.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/unix/atom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/unix/irqreg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arch/unix/timer.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/arpa/inet.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/ahdlc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/arch.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/arch/armpio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/arch/avr.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/arch/avrpio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/arch/gpio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/arp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/audio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/bankmem.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/chat.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/clock.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/coconut.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/crt.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/dev.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/dhcp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/eeprom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/ethernut.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/fs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/ip.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/lcd.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/m-can.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/medianut.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/memory.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/modem.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/os.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/ppp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/progif.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/rport.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/sntp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/syslog.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/tcp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/twi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cfg/xnut.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/compiler.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cpp/nutcpp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/cpu_load.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ace.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/adc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ahdlc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ahdlcavr.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at45db.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at49bv.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at91_efc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at91_emac.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at91_mci.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at91_spi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at91sam7x_emac.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/at91sam7x_mac.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/atcan.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/avrtarget.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ax88796.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/blockdev.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/board.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/can_dev.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/chat.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/cs8900a.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/cy2239x.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/debug.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/dm9000e.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ds1307rtc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/genchar.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/hd44780.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/hd44780_bus.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ide.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/idep.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ir.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqreg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqreg_arm.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqreg_avr.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqreg_h8.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqreg_m68k.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqreg_unix.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irqstack.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/irsony.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/lanc111.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/mmcard.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/mweeprom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/netbuf.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/nicrtl.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/npl.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/nplmmc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/npluled.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/null.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/nvmem.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/pcf8563.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/pcmcia.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/pnut.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/ppp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/rtc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sbbif0.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sbbif1.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sbbif2.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sbbif3.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sbimmc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/scih8.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sja1000.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/spidigio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/spiflash.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/spimmc_at91.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/sppif0.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/st7036.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/term.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/tlc16c550.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/twif.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/uart.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/uartavr.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/uartgba.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/uartspi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/unix_devs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/urom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/usart.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/usartat91.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/usartavr.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/vs1001k.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/vs10xx.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/watchdog.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/wlan.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/wlancfg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/wlandef.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/wlandrv.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/wlantypes.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dev/x12rtc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/dirent.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/display.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/errno.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fat.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fatdrv.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fcntl.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/flash.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/dospart.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/fat.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/fatfs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/fs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phat12.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phat16.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phat32.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phatdbg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phatdir.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phatfs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phatio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phatutil.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/phatvol.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/typedefs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs/uromfs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/dospart.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/fat.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/fatfs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/fs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phat12.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phat16.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phat32.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phatdbg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phatdir.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phatfs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phatio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phatutil.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/phatvol.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/typedefs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/fs_org/uromfs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/io.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/keyboard.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/led.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/libgen.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/log.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/mmc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/mmcdrv.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/errno.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/ether.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/if.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/if_arp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/if_types.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/if_var.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/netdebug.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/ppp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/net/route.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netdb.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/icmp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/if_ether.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/if_ppp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/igmp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/in.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/ip.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/ip_icmp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/ipcsum.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/ppp_fsm.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/tcp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/tcp_fsm.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/tcputil.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/netinet/udp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/platform.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/portio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/asp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/dhcp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/discover.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/ftpd.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/httpd.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/sntp.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/ssi.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/pro/wins.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/remcon.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/rtc.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/spidrv.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/stdio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/stdio_nut_wrapper.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/strtok_r.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/atom.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/bankmem.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/confnet.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/confos.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/device.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/event.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/file.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/heap.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/msg.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/mutex.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/nut_types.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/nutconfig.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/osdebug.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/semaphore.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/sock_var.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/socket.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/sockio.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/stat.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/syslog.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/thread.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/timer.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/tracer.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/types.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/sys/version.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/system.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/time.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/typedefs.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/uart0driver.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/unistd.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/vs10xx.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/include/watchdog.h" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/display.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/display.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/fat.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/fat.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/flash.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/flash.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/http.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/inet.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/keyboard.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/keyboard.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/led.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/led.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/log.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/log.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/main.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/main.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/mmc.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/mmc.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/mmcdrv.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/mmcdrv.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/remcon.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/remcon.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/rtc.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/rtc.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/session.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/spidrv.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/spidrv.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/uart0driver.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/uart0driver.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/util.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/vs10xx.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/vs10xx.lst" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/watchdog.c" afterPath="" />
+      <change type="DELETED" beforePath="$PROJECT_DIR$/source/watchdog.lst" afterPath="" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.gitignore" afterPath="$PROJECT_DIR$/.gitignore" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/InternetRadio.iml" afterPath="$PROJECT_DIR$/.idea/InternetRadio.iml" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Makefile" afterPath="$PROJECT_DIR$/Makefile" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/main.c" afterPath="$PROJECT_DIR$/main.c" />
+    </list>
     <ignored path="InternetRadio.iws" />
     <ignored path=".idea/workspace.xml" />
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -30,22 +362,45 @@
     <favorites_list name="InternetRadio" />
   </component>
   <component name="FileEditorManager">
-    <leaf>
-      <file leaf-file-name="CMakeLists.txt" pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/CMakeLists.txt">
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
+      <file leaf-file-name="Makefile" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/Makefile">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="468">
+              <caret line="26" column="22" selection-start-line="26" selection-start-column="22" selection-end-line="26" selection-end-column="22" />
+              <folding />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file leaf-file-name=".gitignore" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/.gitignore">
           <provider selected="true" editor-type-id="text-editor">
-            <state vertical-scroll-proportion="0.0">
-              <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+            <state relative-caret-position="432">
+              <caret line="37" column="6" selection-start-line="37" selection-start-column="6" selection-end-line="37" selection-end-column="6" />
               <folding />
             </state>
           </provider>
         </entry>
       </file>
-      <file leaf-file-name="main.cpp" pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/main.cpp">
+      <file leaf-file-name="main.c" pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/main.c">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="522">
+              <caret line="44" column="18" selection-start-line="44" selection-start-column="18" selection-end-line="44" selection-end-column="18" />
+              <folding>
+                <element signature="e#666#686#0" expanded="true" />
+                <element signature="e#909#931#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file leaf-file-name="led.h" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/lib/led.h">
           <provider selected="true" editor-type-id="text-editor">
-            <state vertical-scroll-proportion="0.0">
-              <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+            <state relative-caret-position="198">
+              <caret line="29" column="77" selection-start-line="29" selection-start-column="77" selection-end-line="29" selection-end-column="77" />
               <folding />
             </state>
           </provider>
@@ -56,6 +411,16 @@
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
+  <component name="IdeDocumentHistory">
+    <option name="CHANGED_PATHS">
+      <list>
+        <option value="$PROJECT_DIR$/lib/led.h" />
+        <option value="$PROJECT_DIR$/Makefile" />
+        <option value="$PROJECT_DIR$/.gitignore" />
+        <option value="$PROJECT_DIR$/main.c" />
+      </list>
+    </option>
+  </component>
   <component name="JsBuildToolGruntFileManager" detection-done="true" />
   <component name="JsBuildToolPackageJson" detection-done="true" />
   <component name="JsGulpfileManager">
@@ -63,8 +428,8 @@
   </component>
   <component name="ProjectFrameBounds">
     <option name="y" value="27" />
-    <option name="width" value="1440" />
-    <option name="height" value="873" />
+    <option name="width" value="1920" />
+    <option name="height" value="1053" />
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="false">
     <OptionsSetting value="true" id="Add" />
@@ -113,11 +478,171 @@
       </pane>
     </panes>
   </component>
+  <component name="PropertiesComponent">
+    <property name="WebServerToolWindowFactoryState" value="false" />
+    <property name="js-jscs-nodeInterpreter" value="/usr/bin/node" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
+  </component>
   <component name="RunManager" selected="Application.Build All">
+    <configuration default="true" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="InternetRadio" TARGET_NAME="InternetRadio" CONFIG_NAME="Debug" TEST_MODE="SUITE_TEST">
+      <envs />
+      <method />
+    </configuration>
     <configuration default="true" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="InternetRadio" TARGET_NAME="InternetRadio" CONFIG_NAME="Debug">
       <envs />
       <method />
     </configuration>
+    <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
+      <method />
+    </configuration>
+    <configuration default="true" type="PythonConfigurationType" factoryName="Python">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+      </envs>
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <method />
+    </configuration>
+    <configuration default="true" type="Tox" factoryName="Tox">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs />
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <method />
+    </configuration>
+    <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
+      <node-options />
+      <gulpfile />
+      <tasks />
+      <arguments />
+      <envs />
+      <method />
+    </configuration>
+    <configuration default="true" type="js.build_tools.npm" factoryName="npm">
+      <command value="run-script" />
+      <scripts />
+      <envs />
+      <method />
+    </configuration>
+    <configuration default="true" type="tests" factoryName="Attests">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs />
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="CLASS_NAME" value="" />
+      <option name="METHOD_NAME" value="" />
+      <option name="FOLDER_NAME" value="" />
+      <option name="TEST_TYPE" value="TEST_SCRIPT" />
+      <option name="PATTERN" value="" />
+      <option name="USE_PATTERN" value="false" />
+      <method />
+    </configuration>
+    <configuration default="true" type="tests" factoryName="Doctests">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs />
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="CLASS_NAME" value="" />
+      <option name="METHOD_NAME" value="" />
+      <option name="FOLDER_NAME" value="" />
+      <option name="TEST_TYPE" value="TEST_SCRIPT" />
+      <option name="PATTERN" value="" />
+      <option name="USE_PATTERN" value="false" />
+      <method />
+    </configuration>
+    <configuration default="true" type="tests" factoryName="Nosetests">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs />
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="CLASS_NAME" value="" />
+      <option name="METHOD_NAME" value="" />
+      <option name="FOLDER_NAME" value="" />
+      <option name="TEST_TYPE" value="TEST_SCRIPT" />
+      <option name="PATTERN" value="" />
+      <option name="USE_PATTERN" value="false" />
+      <option name="PARAMS" value="" />
+      <option name="USE_PARAM" value="false" />
+      <method />
+    </configuration>
+    <configuration default="true" type="tests" factoryName="Unittests">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs />
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="CLASS_NAME" value="" />
+      <option name="METHOD_NAME" value="" />
+      <option name="FOLDER_NAME" value="" />
+      <option name="TEST_TYPE" value="TEST_SCRIPT" />
+      <option name="PATTERN" value="" />
+      <option name="USE_PATTERN" value="false" />
+      <option name="PUREUNITTEST" value="true" />
+      <option name="PARAMS" value="" />
+      <option name="USE_PARAM" value="false" />
+      <method />
+    </configuration>
+    <configuration default="true" type="tests" factoryName="py.test">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs />
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="IS_MODULE_SDK" value="false" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <module name="InternetRadio" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="CLASS_NAME" value="" />
+      <option name="METHOD_NAME" value="" />
+      <option name="FOLDER_NAME" value="" />
+      <option name="TEST_TYPE" value="TEST_SCRIPT" />
+      <option name="PATTERN" value="" />
+      <option name="USE_PATTERN" value="false" />
+      <option name="testToRun" value="" />
+      <option name="keywords" value="" />
+      <option name="params" value="" />
+      <option name="USE_PARAM" value="false" />
+      <option name="USE_KEYWORD" value="false" />
+      <method />
+    </configuration>
     <configuration default="false" name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS="FALSE" CONFIG_NAME="Debug" EXPLICIT_BUILD_TARGET_NAME="all">
       <envs />
       <method />
@@ -131,7 +656,9 @@
       <item index="1" class="java.lang.String" itemvalue="Application.InternetRadio" />
     </list>
   </component>
-  <component name="ShelveChangesManager" show_recycled="false" />
+  <component name="ShelveChangesManager" show_recycled="false">
+    <option name="remove_strategy" value="false" />
+  </component>
   <component name="TaskManager">
     <task active="true" id="Default" summary="Default task">
       <changelist id="8005cdec-074e-478f-b095-591cd1517046" name="Default" comment="" />
@@ -141,25 +668,34 @@
     </task>
     <servers />
   </component>
+  <component name="TodoView">
+    <todo-panel id="selected-file">
+      <is-autoscroll-to-source value="true" />
+    </todo-panel>
+    <todo-panel id="all">
+      <are-packages-shown value="true" />
+      <is-autoscroll-to-source value="true" />
+    </todo-panel>
+  </component>
   <component name="ToolWindowManager">
-    <frame x="0" y="27" width="1440" height="873" extended-state="0" />
-    <editor active="true" />
+    <frame x="0" y="27" width="1920" height="1053" extended-state="7" />
+    <editor active="false" />
     <layout>
-      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2496474" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
-      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
-      <window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
-      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
-      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20991561" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
+      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32972974" sideWeight="0.4978903" order="6" side_tool="false" content_ui="tabs" />
+      <window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2745946" sideWeight="0.49156117" order="7" side_tool="false" content_ui="tabs" />
+      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32864866" sideWeight="0.5221519" order="10" side_tool="true" content_ui="tabs" />
+      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32972974" sideWeight="0.4978903" order="8" side_tool="false" content_ui="tabs" />
       <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
-      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
-      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
+      <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32864866" sideWeight="0.4778481" order="9" side_tool="false" content_ui="tabs" />
+      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
       <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
-      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
       <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
       <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
-      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
       <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
       <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
+      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
       <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
       <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
     </layout>
@@ -172,21 +708,147 @@
     <watches-manager />
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/main.cpp">
+    <entry file="file://$PROJECT_DIR$/Makefile">
       <provider selected="true" editor-type-id="text-editor">
-        <state vertical-scroll-proportion="0.0">
+        <state relative-caret-position="0">
           <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/CMakeLists.txt">
+    <entry file="file://$PROJECT_DIR$/main.c">
       <provider selected="true" editor-type-id="text-editor">
-        <state vertical-scroll-proportion="0.0">
+        <state relative-caret-position="756">
+          <caret line="42" column="23" selection-start-line="42" selection-start-column="23" selection-end-line="42" selection-end-column="23" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/lib/led.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="414">
+          <caret line="23" column="77" selection-start-line="23" selection-start-column="77" selection-end-line="23" selection-end-column="77" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/lib/led.h">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="540">
+          <caret line="30" column="66" selection-start-line="30" selection-start-column="66" selection-end-line="30" selection-end-column="66" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/Makefile">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="504">
+          <caret line="28" column="26" selection-start-line="28" selection-start-column="26" selection-end-line="28" selection-end-column="26" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/main.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="558">
+          <caret line="31" column="10" selection-start-line="31" selection-start-column="10" selection-end-line="31" selection-end-column="10" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/CMakeLists.txt" />
+    <entry file="file://$PROJECT_DIR$/Makefile">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="0">
           <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
           <folding />
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/source/main.c" />
+    <entry file="file://$PROJECT_DIR$/source/http.c" />
+    <entry file="file://$PROJECT_DIR$/main.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="0">
+          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/CMakeLists.txt" />
+    <entry file="file://$PROJECT_DIR$/Makefile">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="0">
+          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/source/main.c" />
+    <entry file="file://$PROJECT_DIR$/source/http.c" />
+    <entry file="file://$PROJECT_DIR$/main.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="0">
+          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/CMakeLists.txt" />
+    <entry file="file://$PROJECT_DIR$/main.cpp" />
+    <entry file="file://$PROJECT_DIR$/CMakeLists.txt" />
+    <entry file="file://$PROJECT_DIR$/source/http.c" />
+    <entry file="file://$PROJECT_DIR$/source/main.c" />
+    <entry file="file://$PROJECT_DIR$/lib/led.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="288">
+          <caret line="102" column="3" selection-start-line="102" selection-start-column="3" selection-end-line="102" selection-end-column="3" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/main.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="288">
+          <caret line="31" column="14" selection-start-line="31" selection-start-column="14" selection-end-line="31" selection-end-column="14" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/lib/led.h">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="198">
+          <caret line="29" column="77" selection-start-line="29" selection-start-column="77" selection-end-line="29" selection-end-column="77" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/Makefile">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="468">
+          <caret line="26" column="22" selection-start-line="26" selection-start-column="22" selection-end-line="26" selection-end-column="22" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/.gitignore">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="432">
+          <caret line="37" column="6" selection-start-line="37" selection-start-column="6" selection-end-line="37" selection-end-column="6" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/main.c">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="522">
+          <caret line="44" column="18" selection-start-line="44" selection-start-column="18" selection-end-line="44" selection-end-column="18" />
+          <folding>
+            <element signature="e#666#686#0" expanded="true" />
+            <element signature="e#909#931#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
   </component>
 </project>

+ 0 - 7
CMakeLists.txt

@@ -1,7 +0,0 @@
-cmake_minimum_required(VERSION 3.3)
-project(InternetRadio)
-
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-
-set(SOURCE_FILES main.c)
-add_executable(InternetRadio ${SOURCE_FILES})

+ 20 - 81
Makefile

@@ -1,93 +1,32 @@
-TARGET	= ipac
+PROJ = bin/internetradioA6
 
-# Application source en include includes
-SRC_DIR	= ./source
-INC_DIR = ./include
 
-# NutOS location (includes and libs)
-NUT_INC = c:/ethernut-4.3.3/nut/include
-NUT_BUILD_INC = c:/ethernut-4.3.3/build/gcc/atmega2561/lib/include
-NUT_LIB_DIR = c:/ethernut-4.3.3/build/gcc/atmega2561/lib
+LIBDIR = nutos/nutbld/lib
+top_srcdir = nutos/nut
+top_blddir = nutos/nutbld
+top_appdir = nutos/nutapp
 
-# WinAvr includes
-AVR_INC = c:/winavr/avr/include
+INCFIRST=$(INCPRE)$(top_blddir)/include
+include $(top_appdir)/NutConf.mk
+include $(top_srcdir)/app/Makedefs.avr-gcc
 
 
-# Compiler, assembler & linker (flags)
-CC		= 	avr-gcc
-CFLAGS	= 	-mmcu=atmega2561 -Os -Wall -Wstrict-prototypes -DNUT_CPU_FREQ=14745600 \
-			-D__HARVARD_ARCH__ -DNUTOS_VERSION=433 \
-			-Wa,-ahlms=$(SRC_DIR)/$*lst
-ASFLAGS = 	-mmcu=atmega2561 -I. -x assembler-with-cpp -Wa,-ahlms=$(SRC_DIR)/$*lst,-gstabs 
-LDFLAGS	=	-mmcu=atmega2561 -Wl,--defsym=main=0,-Map=TIStreamer.map,--cref
+SRCS =  $(wildcard lib/*.c *.c)
+OBJS =  $(SRCS:%.c=%.o)
+LIBS =  $(LIBDIR)/nutinit.o -lnutpro -lnutnet -lnutos -lnutfs -lnutgorp -lnutarch -lnutdev -lnutarch -lnutcrt $(ADDLIBS)
 
 
-# =================================================================================
-# Source files
-CFILES =        main.c			\
-				uart0driver.c	\
-				log.c			\
-                led.c			\
-				keyboard.c		\
-				display.c		\
-                vs10xx.c		\
-                remcon.c		\
-                watchdog.c		\
-				mmc.c			\
-				spidrv.c        \
-                mmcdrv.c        \
-                fat.c			\
-				flash.c			\
-				rtc.c
-			
-				
-# Header files.
-HFILES =        display.h        keyboard.h              \
-                led.h                            \
-                portio.h         remcon.h         log.h          \
-                system.h                 settings.h     \
-                                  inet.h         \
-                platform.h       version.h        update.h       \
-                           uart0driver.h    typedefs.h     \
-                       vs10xx.h         audio.h        \
-                watchdog.h       mmc.h             \
-                flash.h          spidrv.h         command.h      \
-                parse.h          mmcdrv.h         fat.h          \
-                fatdrv.h         flash.h	  	rtc.h
+all: $(OBJS) $(TARG) $(ITARG) $(DTARG)
 
+include nutos/nutapp/Makerules
 
-# Alle source files in de ./source dir
-SRCS =	$(addprefix $(SRC_DIR)/,$(CFILES))
-OBJS = 	$(SRCS:.c=.o)
-
-NUT_LIBS = $(NUT_LIB_DIR)/nutinit.o -lnutpro -lnutnet -lnutpro -lnutfs -lnutos -lnutdev -lnutarch -lnutnet -lnutcrt -lnutdev
-
-
-# Alle includes (header files) in de ./header dir
-INCS =	$(addprefix $(INC_DIR)/,$(HFILES))
-
-# Linking rule. All *.o to elf file. Then convert to *.hex
-$(TARGET):	$(OBJS)
-	$(CC) $(OBJS) $(LDFLAGS) -L$(NUT_LIB_DIR) $(NUT_LIBS) -o $@.elf
-	avr-objcopy -O ihex $@.elf $@.hex
-#	hex2bin -ebin $@.hex
-
-# Compiling the objs's. avr-gcc autocalls assembler	
-$(SRC_DIR)/%o:	$(SRC_DIR)/%c 
-	$(CC) -c $< $(CFLAGS) -I$(INC_DIR) -I$(NUT_INC) -I$(AVR_INC) -o $@
-
-	
-all: $(TARGET)
-
-debug:
-	
-	@echo $(OBJS)
-
-
-.PHONY: clean
 clean:
 	-rm -f $(OBJS)
+	-rm -f $(TARG) $(ITARG) $(DTARG)
+	-rm -f $(PROJ).eep
+	-rm -f $(PROJ).obj
+	-rm -f $(PROJ).map
 	-rm -f $(SRCS:.c=.lst)
-	-rm -f *.hex *.elf *.map *.bin
-
-
+	-rm -f $(SRCS:.c=.bak)
+	-rm -f $(SRCS:.c=.i)
+	-rm -f $(SRCS:.c=.d)

+ 0 - 191
include/arch/arm.h

@@ -1,191 +0,0 @@
-#ifndef _ARCH_ARM_H_
-#define _ARCH_ARM_H_
-
-/*
- * Copyright (C) 2001-2006 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*
- * $Log: arm.h,v $
- * Revision 1.17  2007/05/02 11:32:07  haraldkipp
- * Mapping of Harvard specific stdio functions moved to stdio.h and io.h.
- *
- * Revision 1.16  2006/08/31 19:04:08  haraldkipp
- * Added support for the AT91SAM9260 and Atmel's AT91SAM9260 Evaluation Kit.
- *
- * Revision 1.15  2006/08/05 11:58:22  haraldkipp
- * Missing brackets may result in unexpected expansion of the _BV() macro.
- *
- * Revision 1.14  2006/08/01 07:35:59  haraldkipp
- * Exclude function prototypes when included by assembler.
- *
- * Revision 1.13  2006/07/21 09:08:58  haraldkipp
- * Map puts_P to puts and _write_P to _write for non-Harvard architectures.
- *
- * Revision 1.12  2006/07/10 14:27:03  haraldkipp
- * C++ will use main instead of NutAppMain. Contributed by Matthias Wilde.
- *
- * Revision 1.11  2006/07/05 07:45:25  haraldkipp
- * Split on-chip interface definitions.
- *
- * Revision 1.10  2006/06/28 17:22:34  haraldkipp
- * Make it compile for AT91SAM7X256.
- *
- * Revision 1.9  2006/05/25 09:35:27  haraldkipp
- * Dummy macros added to support the avr-libc special function register
- * definitions.
- *
- * Revision 1.8  2006/03/16 15:25:26  haraldkipp
- * Changed human readable strings from u_char to char to stop GCC 4 from
- * nagging about signedness.
- *
- * Revision 1.7  2006/03/02 20:02:05  haraldkipp
- * Added a few macros to allow compilation with ICCARM.
- *
- * Revision 1.6  2006/02/23 15:34:00  haraldkipp
- * Support for Philips LPC2xxx Family and LPC-E2294 Board from Olimex added.
- * Many thanks to Michael Fischer for this port.
- *
- * Revision 1.5  2005/11/20 14:45:15  haraldkipp
- * Define printf_P for non Harvard architectures.
- *
- * Revision 1.4  2005/10/24 18:03:02  haraldkipp
- * GameBoy header file added.
- *
- * Revision 1.3  2005/10/24 10:35:05  haraldkipp
- * Port I/O macros added.
- *
- * Revision 1.2  2004/09/08 10:24:26  haraldkipp
- * RAMSTART is too platform dependant
- *
- * Revision 1.1  2004/03/16 16:48:28  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- * Revision 1.1  2004/02/01 18:49:47  haraldkipp
- * Added CPU family support
- *
- */
-
-#include <cfg/arch.h>
-#if defined (MCU_AT91R40008) || defined (MCU_AT91SAM7X256) || defined (MCU_AT91SAM9260)
-#include <arch/arm/at91.h>
-#elif defined (MCU_GBA)
-#include <arch/arm/gba.h>
-#elif defined (MCU_LPC2XXX)
-#include <arch/arm/lpc2xxx.h>
-#endif
-
-#ifndef __ASSEMBLER__
-#include <dev/mweeprom.h>
-#endif
-
-#define ARM_MODE_USER       0x10
-#define ARM_MODE_FIQ        0x11
-#define ARM_MODE_IRQ        0x12
-#define ARM_MODE_SVC        0x13
-#define ARM_MODE_ABORT      0x17
-#define ARM_MODE_UNDEF      0x1B
-#define ARM_MODE_SYS        0x1F
-#define ARM_MODE_MASK       0x1F
-
-#define I_BIT               0x80
-#define F_BIT               0x40
-#define T_BIT               0x20
-
-#ifdef __GNUC__
-#define CONST      const
-#define INLINE     inline
-#else
-#ifndef CONST
-#define CONST      const
-#endif
-#ifndef INLINE
-#define INLINE
-#endif
-#endif
-
-#define PSTR(p)    (p)
-#define PRG_RDB(p) (*((const char *)(p)))
-
-#define prog_char  const char
-#define PGM_P      prog_char *
-
-#define SIGNAL(x)  __attribute__((interrupt_handler)) void x(void)
-#define RAMFUNC __attribute__ ((long_call, section (".ramfunc")))
-
-#if !defined(__arm__) && !defined(__cplusplus)
-#define main       NutAppMain
-#endif
-
-#define strlen_P(x)             strlen((char *)(x))
-#define strcpy_P(x,y)           strcpy(x,(char *)(y))
-
-#define strcmp_P(x, y)          strcmp((char *)(x), (char *)(y))
-#define memcpy_P(x, y, z)       memcpy(x, y, z)
-
-#ifndef __ASSEMBLER__
-/*!
- * \brief End of uninitialised data segment. Defined in the linker script.
- */
-extern void *__bss_end;
-
-/*!
- * \brief Begin of the stack segment. Defined in the linker script.
- */
-extern void *__stack;
-#endif
-
-#ifndef _NOP
-#ifdef __GNUC__
-#define _NOP() __asm__ __volatile__ ("mov r0, r0")
-#else
-#define _NOP() asm("mov r0, r0")
-#endif
-#endif
-
-#define outb(_reg, _val)  (*((volatile unsigned char *)(_reg)) = (_val))
-#define outw(_reg, _val)  (*((volatile unsigned short *)(_reg)) = (_val))
-#define outr(_reg, _val)  (*((volatile unsigned int *)(_reg)) = (_val))
-
-#define inb(_reg)   (*((volatile unsigned char *)(_reg)))
-#define inw(_reg)   (*((volatile unsigned short *)(_reg)))
-#define inr(_reg)   (*((volatile unsigned int *)(_reg)))
-
-#define _BV(bit)    (1 << (bit))
-
-#ifdef __IMAGECRAFT__
-#define __attribute__(x)
-#endif
-
-#define _SFR_MEM8(addr)     (addr)
-#define _SFR_MEM16(addr)    (addr)
-
-#endif

+ 0 - 96
include/arch/arm/atom.h

@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2001-2005 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
-
-/*
- * $Log: atom.h,v $
- * Revision 1.3  2006/03/02 20:03:39  haraldkipp
- * Added ICCARM inline assembly for NutEnter/ExitCritical(). Also fixed
- * SF 1440949 (FIQ never enabled).
- *
- * Revision 1.2  2005/07/26 15:47:06  haraldkipp
- * AtomicInc() and AtomicDec() are no longer required by Nut/Net.
- * Removed to simplify the porting job. Broken applications should
- * implement their own version.
- *
- * Revision 1.1  2005/06/06 10:49:35  haraldkipp
- * Building outside the source tree failed. All header files moved from
- * arch/cpu/include to include/arch/cpu.
- *
- * Revision 1.1  2005/05/27 17:41:52  drsung
- * Moved the file.
- *
- * Revision 1.1  2005/05/26 10:08:42  drsung
- * Moved the platform dependend code from include/sys/atom.h to this file.
- *
- *
- */
-
-#ifndef _SYS_ATOM_H_
-#error "Do not include this file directly. Use sys/atom.h instead!"
-#endif
-
-#ifdef __GNUC__
-
-#define NutEnterCritical() \
-        asm volatile (             \
-                "@ NutEnterCritical"      "\n\t"      \
-                "mrs r0, cpsr"      "\n\t"      \
-                "orr r0, r0, #0xC0" "\n\t"  \
-                "msr cpsr, r0"      "\n\t"  \
-                ::: "r0" )
-
-#define NutExitCritical() \
-        asm volatile (             \
-                "@ NutExitCritical"      "\n\t"      \
-                "mrs r0, cpsr"      "\n\t"      \
-                "bic r0, r0, #0xC0" "\n\t"  \
-                "msr cpsr, r0"      "\n\t"  \
-                ::: "r0" )
-
-#define NutJumpOutCritical()    NutExitCritical()
-
-#else /* __IMAGECRAFT__ */
-
-#define NutEnterCritical() \
-        asm("; NutEnterCritical\n" \
-            "mrs r12, cpsr\n" \
-            "orr r12, r12, #0xC0\n" \
-            "msr cpsr_c, r12")
-
-#define NutExitCritical() \
-        asm("; NutExitCritical\n" \
-            "mrs r12, cpsr\n" \
-            "bic r12, r12, #0xC0\n" \
-            "msr cpsr_c, r12")
-
-#endif

+ 0 - 124
include/arch/m68k/irqreg.h

@@ -1,124 +0,0 @@
-#ifndef _DEV_IRQREG_M68K_H_
-#define _DEV_IRQREG_M68K_H_
-
-/*
- * Copyright (C) 2001-2004 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*
- * $Log: irqreg.h,v $
- * Revision 1.1  2005/07/26 18:35:09  haraldkipp
- * First check in
- *
- * Revision 1.1  2004/03/16 16:48:28  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- *
- */
-
-enum {
-    IRQ_INT0,
-    IRQ_INT1,
-    IRQ_INT2,
-    IRQ_INT3,
-    IRQ_INT4,
-    IRQ_INT5,
-    IRQ_INT6,
-    IRQ_INT7,
-    IRQ_TIMER2_COMP,
-    IRQ_TIMER2_OVF,
-    IRQ_TIMER1_CAPT,
-    IRQ_TIMER1_COMPA,
-    IRQ_TIMER1_COMPB,
-    IRQ_TIMER1_OVF,
-    IRQ_TIMER0_COMP,
-    IRQ_TIMER0_OVF,
-    IRQ_SPI_STC,
-    IRQ_UART_RX,
-    IRQ_UART_UDRE,
-    IRQ_UART_TX,
-    IRQ_ADC,
-    IRQ_EE_RDY,
-    IRQ_ANA_COMP,
-#ifdef __AVR_ATmega128__
-    IRQ_TIMER1_COMPC,
-    IRQ_TIMER3_CAP,
-    IRQ_TIMER3_COMPA,
-    IRQ_TIMER3_COMPB,
-    IRQ_TIMER3_COMPC,
-    IRQ_TIMER3_OVF,
-    IRQ_UART1_RX,
-    IRQ_UART1_UDRE,
-    IRQ_UART1_TX,
-    IRQ_I2C,
-    IRQ_SPM_RDY,
-#endif
-    IRQ_MAX
-};
-
-extern IRQ_HANDLER sig_INTERRUPT0;
-extern IRQ_HANDLER sig_INTERRUPT1;
-extern IRQ_HANDLER sig_INTERRUPT2;
-extern IRQ_HANDLER sig_INTERRUPT3;
-extern IRQ_HANDLER sig_INTERRUPT4;
-extern IRQ_HANDLER sig_INTERRUPT5;
-extern IRQ_HANDLER sig_INTERRUPT6;
-extern IRQ_HANDLER sig_INTERRUPT7;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE2;
-extern IRQ_HANDLER sig_OVERFLOW2;
-extern IRQ_HANDLER sig_INPUT_CAPTURE1;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1A;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1B;
-extern IRQ_HANDLER sig_OVERFLOW1;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE0;
-extern IRQ_HANDLER sig_OVERFLOW0;
-extern IRQ_HANDLER sig_SPI;
-extern IRQ_HANDLER sig_UART0_TRANS;
-extern IRQ_HANDLER sig_UART0_DATA;
-extern IRQ_HANDLER sig_UART0_RECV;
-extern IRQ_HANDLER sig_ADC;
-extern IRQ_HANDLER sig_EEPROM_READY;
-extern IRQ_HANDLER sig_COMPARATOR;
-#ifdef __AVR_ATmega128__
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1C;
-extern IRQ_HANDLER sig_INPUT_CAPTURE3;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3A;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3B;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3C;
-extern IRQ_HANDLER sig_OVERFLOW3;
-extern IRQ_HANDLER sig_UART1_RECV;
-extern IRQ_HANDLER sig_UART1_DATA;
-extern IRQ_HANDLER sig_UART1_TRANS;
-extern IRQ_HANDLER sig_2WIRE_SERIAL;
-extern IRQ_HANDLER sig_SPM_READY;
-#endif
-
-#endif

+ 0 - 109
include/cfg/arch.h

@@ -1,109 +0,0 @@
-#ifndef _CFG_ARCH_H_
-#define _CFG_ARCH_H_
-
-/*
- * Copyright (C) 2004-2006 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
-
-/*!
- * $Log: arch.h,v $
- * Revision 1.3  2007/04/12 09:21:10  haraldkipp
- * Added ATmega2561 definitions for Ethernut 1 and 2.
- *
- * Revision 1.2  2006/05/25 09:22:47  haraldkipp
- * The PLATFORM definition broke source tree building.
- * Fixed for Ethernut Boards.
- *
- * Revision 1.1  2004/09/19 12:31:52  haraldkipp
- * Configuration placeholders added
- *
- */
-
-/*
- * This file is reserved to specify architecture dependant
- * configuration and is currently used as a placeholder 
- * when not using the Configurator.
- */
-
-#if defined(ETHERNUT1)
-
-#ifndef PLATFORM
-#define PLATFORM ETHERNUT1
-#endif
-
-#ifndef AVR_GCC
-#define AVR_GCC
-#endif
-
-#if !defined(MCU_ATMEGA128) && !defined(MCU_ATMEGA2561)
-#if defined(__AVR_ATmega2561__) || defined(ATMega2561)
-#define MCU_ATMEGA2561
-#else
-#define MCU_ATMEGA128
-#endif
-#endif
-
-#elif defined(ETHERNUT2)
-
-#ifndef PLATFORM
-#define PLATFORM ETHERNUT2
-#endif
-
-#ifndef AVR_GCC
-#define AVR_GCC
-#endif
-
-#if !defined(MCU_ATMEGA128) && !defined(MCU_ATMEGA2561)
-#if defined(__AVR_ATmega2561__) || defined(ATMega2561)
-#define MCU_ATMEGA2561
-#else
-#define MCU_ATMEGA128
-#endif
-#endif
-
-#elif defined(ETHERNUT3)
-
-#ifndef PLATFORM
-#define PLATFORM ETHERNUT3
-#endif
-
-#ifndef ARM_GCC
-#define ARM_GCC
-#endif
-
-#ifndef MCU_AT91R40008
-#define MCU_AT91R40008
-#endif
-
-#endif /* ETHERNUT3 */
-
-#endif

+ 0 - 16
include/cpu_load.h

@@ -1,16 +0,0 @@
-/*
- * <MFS> Modified for Streamit
- * File added for CPU-load measurements
- *
- * Copyright (C) 2007 by Streamit BV. All rights reserved.
- */
-
-#ifndef _CPU_LOAD_H_
-#define _CPU_LOAD_H_
-
-//#define CPU_LOAD_MEASURE
-#define CPU_LOAD_PORT PORTE
-#define CPU_LOAD_BIT 3
-#define CPU_LOAD_DDR DDRE
-
-#endif

+ 0 - 156
include/dev/board.h

@@ -1,156 +0,0 @@
-#ifndef _DEV_BOARD_H_
-#define _DEV_BOARD_H_
-
-/*
- * Copyright (C) 2001-2005 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*
- * $Log: board.h,v $
- * Revision 1.7  2006/10/05 17:18:49  haraldkipp
- * Hardware independant RTC layer added.
- *
- * Revision 1.6  2006/08/31 19:01:08  haraldkipp
- * Using devDebug2 for the DBGU output was a bad idea. Some AT91 chips
- * provide more than two UARTs. We now use devDebug to specify the DBGU
- * device. Baudrate calculations failed on CPUs running on a processor
- * clock, which differs from a futher divided main clock. This had been
- * fixed.
- *
- * Revision 1.5  2006/07/05 07:45:29  haraldkipp
- * Split on-chip interface definitions.
- *
- * Revision 1.4  2006/06/28 17:17:50  haraldkipp
- * Added initial support for Atmel's AT91SAM7X-EK.
- *
- * Revision 1.3  2006/02/23 15:34:00  haraldkipp
- * Support for Philips LPC2xxx Family and LPC-E2294 Board from Olimex added.
- * Many thanks to Michael Fischer for this port.
- *
- * Revision 1.2  2005/11/22 09:19:03  haraldkipp
- * Include condition corrected.
- *
- * Revision 1.1  2005/11/20 14:43:38  haraldkipp
- * First check-in
- *
- */
-
-/*
- * Debug device.
- */
-#include <dev/debug.h>
-
-#if defined(GBA)
-#define DEV_DEBUG_NAME  "con"
-#endif
-
-#if defined(OLIMEX_LPCE2294)
-#define DEV_DEBUG       devDebug1
-#define DEV_DEBUG_NAME  "uart1"
-#endif
-
-#if defined(DBGU_BASE)
-#define DEV_DEBUG       devDebug
-#define DEV_DEBUG_NAME  "dbgu"
-#endif
-
-#ifndef DEV_DEBUG
-#define DEV_DEBUG       devDebug0
-#endif
-#ifndef DEV_DEBUG_NAME
-#define DEV_DEBUG_NAME  "uart0"
-#endif
-
-/*
- * UART device.
- */
-#if defined(__AVR__) || defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__)
-
-#include <dev/usartavr.h>
-#define DEV_UART0       devUsartAvr0
-#define DEV_UART1       devUsartAvr1
-#define DEV_UART1_NAME  "uart1"
-
-#elif defined(ETHERNUT3) || defined(WOLF) || defined(AT91SAM7X_EK) || defined(AT91SAM9260_EK)
-
-#include <dev/usartat91.h>
-#define DEV_UART0       devUsartAt910
-#define DEV_UART1       devUsartAt911
-#define DEV_UART1_NAME  "uart1"
-
-#endif
-
-#ifndef DEV_UART0
-#define DEV_UART0       devUart0
-#endif
-#ifndef DEV_UART0_NAME
-#define DEV_UART0_NAME  "uart0"
-#endif
-
-#ifndef DEV_UART
-#define DEV_UART        DEV_UART0
-#endif
-#ifndef DEV_UART_NAME
-#define DEV_UART_NAME   DEV_UART0_NAME
-#endif
-
-/*
- * Ethernet device.
- */
-#if defined(ETHERNUT1) || defined(CHARON2) || defined(XNUT_100) || defined(XNUT_105)
-#include <dev/nicrtl.h>
-#elif defined(ETHERNUT2)
-#include <dev/lanc111.h>
-#elif defined(ETHERNUT3)
-#include <dev/dm9000e.h>
-#elif defined(WOLF)
-#include <dev/ax88796.h>
-#elif defined(OLIMEX_LPCE2294)
-#include <dev/cs8900a.h>
-#elif defined(AT91SAM7X_EK) || defined(AT91SAM9260_EK)
-#include <dev/at91sam7x_emac.h>
-#endif
-
-#ifndef DEV_ETHER
-#define DEV_ETHER       devEth0
-#endif
-#ifndef DEV_ETHER_NAME
-#define DEV_ETHER_NAME  "eth0"
-#endif
-
-/*
- * RTC chip.
- */
-#define RTC_CHIP rtcX12x6
-#include <dev/x12rtc.h>
-
-#endif
-

+ 0 - 91
include/dev/irqreg_avr.h

@@ -1,91 +0,0 @@
-#ifndef _DEV_IRQREG_AVR_H_
-#define _DEV_IRQREG_AVR_H_
-
-/*
- * Copyright (C) 2001-2004 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*
- * $Log: irqreg_avr.h,v $
- * Revision 1.3  2005/10/07 21:52:31  hwmaier
- * Removed test for __ATmega64__
- *
- * Revision 1.2  2005/02/10 07:06:51  hwmaier
- * Changes to incorporate support for AT90CAN128 CPU
- *
- * Revision 1.1  2004/03/16 16:48:28  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- *
- */
-
-extern IRQ_HANDLER sig_INTERRUPT0;
-extern IRQ_HANDLER sig_INTERRUPT1;
-extern IRQ_HANDLER sig_INTERRUPT2;
-extern IRQ_HANDLER sig_INTERRUPT3;
-extern IRQ_HANDLER sig_INTERRUPT4;
-extern IRQ_HANDLER sig_INTERRUPT5;
-extern IRQ_HANDLER sig_INTERRUPT6;
-extern IRQ_HANDLER sig_INTERRUPT7;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE2;
-extern IRQ_HANDLER sig_OVERFLOW2;
-extern IRQ_HANDLER sig_INPUT_CAPTURE1;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1A;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1B;
-extern IRQ_HANDLER sig_OVERFLOW1;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE0;
-extern IRQ_HANDLER sig_OVERFLOW0;
-extern IRQ_HANDLER sig_SPI;
-extern IRQ_HANDLER sig_UART0_TRANS;
-extern IRQ_HANDLER sig_UART0_DATA;
-extern IRQ_HANDLER sig_UART0_RECV;
-extern IRQ_HANDLER sig_ADC;
-extern IRQ_HANDLER sig_EEPROM_READY;
-extern IRQ_HANDLER sig_COMPARATOR;
-#if defined(__AVR_AT90CAN128__) || defined(__AVR_ATmega128__)
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1C;
-extern IRQ_HANDLER sig_INPUT_CAPTURE3;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3A;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3B;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3C;
-extern IRQ_HANDLER sig_OVERFLOW3;
-extern IRQ_HANDLER sig_UART1_RECV;
-extern IRQ_HANDLER sig_UART1_DATA;
-extern IRQ_HANDLER sig_UART1_TRANS;
-extern IRQ_HANDLER sig_2WIRE_SERIAL;
-extern IRQ_HANDLER sig_SPM_READY;
-#endif
-#if defined(__AVR_AT90CAN128__)
-extern IRQ_HANDLER sig_CAN_COMPLETE;
-extern IRQ_HANDLER sig_CAN_OVERRUN;
-#endif
-
-#endif

+ 0 - 131
include/dev/irqreg_h8.h

@@ -1,131 +0,0 @@
-#ifndef _DEV_IRQREG_H8_H_
-#define _DEV_IRQREG_H8_H_
-
-/*
- * Copyright (C) 2004 by Jan Dubiec. 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 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 JAN DUBIEC 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 JAN DUBIEC
- * 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.
- */
-
-/*
- * $Log: irqreg_h8.h,v $
- * Revision 1.1  2004/03/16 16:48:28  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- */
-
-enum {
-    IRQ_NMI,
-    IRQ_INT0,
-    IRQ_INT1,
-    IRQ_INT2,
-    IRQ_INT3,
-    IRQ_INT4,
-    IRQ_INT5,
-    IRQ_WOVI,
-    IRQ_CMI,
-    IRQ_ADI,
-    IRQ_IMIA0,
-    IRQ_IMIB0,
-    IRQ_OVI0,
-    IRQ_IMIA1,
-    IRQ_IMIB1,
-    IRQ_OVI1,
-    IRQ_IMIA2,
-    IRQ_IMIB2,
-    IRQ_OVI2,
-    IRQ_CMIA0,
-    IRQ_CMIB0,
-    IRQ_CMIA0_B1,
-    IRQ_TOVI0_1,
-    IRQ_CMIA2,
-    IRQ_CMIB2,
-    IRQ_CMIA2_B3,
-    IRQ_TOVI2_3,
-    IRQ_DEND0A,
-    IRQ_DEND0B,
-    IRQ_DEND1A,
-    IRQ_DEND1B,
-    IRQ_ERI0,
-    IRQ_RXI0,
-    IRQ_TXI0,
-    IRQ_TEI0,
-    IRQ_ERI1,
-    IRQ_RXI1,
-    IRQ_TXI1,
-    IRQ_TEI1,
-    IRQ_ERI2,
-    IRQ_RXI2,
-    IRQ_TXI2,
-    IRQ_TEI2,
-    IRQ_MAX
-};
-
-extern IRQ_HANDLER sig_NMI;
-extern IRQ_HANDLER sig_INT0;
-extern IRQ_HANDLER sig_INT1;
-extern IRQ_HANDLER sig_INT2;
-extern IRQ_HANDLER sig_INT3;
-extern IRQ_HANDLER sig_INT4;
-extern IRQ_HANDLER sig_INT5;
-extern IRQ_HANDLER sig_WOVI;
-extern IRQ_HANDLER sig_CMI;
-extern IRQ_HANDLER sig_ADI;
-extern IRQ_HANDLER sig_IMIA0;
-extern IRQ_HANDLER sig_IMIB0;
-extern IRQ_HANDLER sig_OVI0;
-extern IRQ_HANDLER sig_IMIA1;
-extern IRQ_HANDLER sig_IMIB1;
-extern IRQ_HANDLER sig_OVI1;
-extern IRQ_HANDLER sig_IMIA2;
-extern IRQ_HANDLER sig_IMIB2;
-extern IRQ_HANDLER sig_OVI2;
-extern IRQ_HANDLER sig_CMIA0;
-extern IRQ_HANDLER sig_IMIB0;
-extern IRQ_HANDLER sig_CMIA0_B1;
-extern IRQ_HANDLER sig_TOVI0_1;
-extern IRQ_HANDLER sig_CMIA2;
-extern IRQ_HANDLER sig_IMIB2;
-extern IRQ_HANDLER sig_CMIA2_B3;
-extern IRQ_HANDLER sig_TOVI2_3;
-extern IRQ_HANDLER sig_DEND0A;
-extern IRQ_HANDLER sig_DEND0B;
-extern IRQ_HANDLER sig_DEND1A;
-extern IRQ_HANDLER sig_DEND1B;
-extern IRQ_HANDLER sig_ERI0;
-extern IRQ_HANDLER sig_RXI0;
-extern IRQ_HANDLER sig_TXI0;
-extern IRQ_HANDLER sig_TEI0;
-extern IRQ_HANDLER sig_ERI1;
-extern IRQ_HANDLER sig_RXI1;
-extern IRQ_HANDLER sig_TXI1;
-extern IRQ_HANDLER sig_TEI1;
-extern IRQ_HANDLER sig_ERI2;
-extern IRQ_HANDLER sig_RXI2;
-extern IRQ_HANDLER sig_TXI2;
-extern IRQ_HANDLER sig_TEI2;
-
-#endif

+ 0 - 121
include/dev/irqreg_m68k.h

@@ -1,121 +0,0 @@
-#ifndef _DEV_IRQREG_M68K_H_
-#define _DEV_IRQREG_M68K_H_
-
-/*
- * Copyright (C) 2001-2004 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*
- * $Log: irqreg_m68k.h,v $
- * Revision 1.1  2004/03/16 16:48:28  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- *
- */
-
-enum {
-    IRQ_INT0,
-    IRQ_INT1,
-    IRQ_INT2,
-    IRQ_INT3,
-    IRQ_INT4,
-    IRQ_INT5,
-    IRQ_INT6,
-    IRQ_INT7,
-    IRQ_TIMER2_COMP,
-    IRQ_TIMER2_OVF,
-    IRQ_TIMER1_CAPT,
-    IRQ_TIMER1_COMPA,
-    IRQ_TIMER1_COMPB,
-    IRQ_TIMER1_OVF,
-    IRQ_TIMER0_COMP,
-    IRQ_TIMER0_OVF,
-    IRQ_SPI_STC,
-    IRQ_UART_RX,
-    IRQ_UART_UDRE,
-    IRQ_UART_TX,
-    IRQ_ADC,
-    IRQ_EE_RDY,
-    IRQ_ANA_COMP,
-#ifdef __AVR_ATmega128__
-    IRQ_TIMER1_COMPC,
-    IRQ_TIMER3_CAP,
-    IRQ_TIMER3_COMPA,
-    IRQ_TIMER3_COMPB,
-    IRQ_TIMER3_COMPC,
-    IRQ_TIMER3_OVF,
-    IRQ_UART1_RX,
-    IRQ_UART1_UDRE,
-    IRQ_UART1_TX,
-    IRQ_I2C,
-    IRQ_SPM_RDY,
-#endif
-    IRQ_MAX
-};
-
-extern IRQ_HANDLER sig_INTERRUPT0;
-extern IRQ_HANDLER sig_INTERRUPT1;
-extern IRQ_HANDLER sig_INTERRUPT2;
-extern IRQ_HANDLER sig_INTERRUPT3;
-extern IRQ_HANDLER sig_INTERRUPT4;
-extern IRQ_HANDLER sig_INTERRUPT5;
-extern IRQ_HANDLER sig_INTERRUPT6;
-extern IRQ_HANDLER sig_INTERRUPT7;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE2;
-extern IRQ_HANDLER sig_OVERFLOW2;
-extern IRQ_HANDLER sig_INPUT_CAPTURE1;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1A;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1B;
-extern IRQ_HANDLER sig_OVERFLOW1;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE0;
-extern IRQ_HANDLER sig_OVERFLOW0;
-extern IRQ_HANDLER sig_SPI;
-extern IRQ_HANDLER sig_UART0_TRANS;
-extern IRQ_HANDLER sig_UART0_DATA;
-extern IRQ_HANDLER sig_UART0_RECV;
-extern IRQ_HANDLER sig_ADC;
-extern IRQ_HANDLER sig_EEPROM_READY;
-extern IRQ_HANDLER sig_COMPARATOR;
-#ifdef __AVR_ATmega128__
-extern IRQ_HANDLER sig_OUTPUT_COMPARE1C;
-extern IRQ_HANDLER sig_INPUT_CAPTURE3;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3A;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3B;
-extern IRQ_HANDLER sig_OUTPUT_COMPARE3C;
-extern IRQ_HANDLER sig_OVERFLOW3;
-extern IRQ_HANDLER sig_UART1_RECV;
-extern IRQ_HANDLER sig_UART1_DATA;
-extern IRQ_HANDLER sig_UART1_TRANS;
-extern IRQ_HANDLER sig_2WIRE_SERIAL;
-extern IRQ_HANDLER sig_SPM_READY;
-#endif
-
-#endif

+ 0 - 1023
include/dev/sbbif0.h

@@ -1,1023 +0,0 @@
-#ifndef _DEV_SBBIF0_H_
-#define _DEV_SBBIF0_H_
-/*
- * Copyright (C) 2007 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file dev/sbbif0.h
- * \brief Serial bit banged interface 0.
- *
- * \verbatim
- *
- * $Log: sbbif0.h,v $
- * Revision 1.1  2007/04/12 09:07:54  haraldkipp
- * Configurable SPI added.
- *
- *
- * \endverbatim
- */
-
-#include <cfg/arch/gpio.h>
-
-/*!
- * \brief Maximum number of devices (chip selects).
- */
-#ifndef SBBI0_MAX_DEVICES
-#define SBBI0_MAX_DEVICES   4
-#endif
-
-#if defined(__AVR__)            /* MCU */
-/*
- * AVR implementation.
- * ======================================
- */
-
-#ifdef SBBI0_CS0_BIT
-
-#if (SBBI0_CS0_AVRPORT == AVRPORTB)
-#define SBBI0_CS0_SOD_REG PORTB
-#define SBBI0_CS0_OE_REG  DDRB
-#elif (SBBI0_CS0_AVRPORT == AVRPORTD)
-#define SBBI0_CS0_SOD_REG PORTD
-#define SBBI0_CS0_OE_REG  DDRD
-#elif (SBBI0_CS0_AVRPORT == AVRPORTE)
-#define SBBI0_CS0_SOD_REG PORTE
-#define SBBI0_CS0_OE_REG  DDRE
-#elif (SBBI0_CS0_AVRPORT == AVRPORTF)
-#define SBBI0_CS0_SOD_REG PORTF
-#define SBBI0_CS0_OE_REG  DDRF
-#elif (SBBI0_CS0_AVRPORT == AVRPORTG)
-#define SBBI0_CS0_SOD_REG PORTG
-#define SBBI0_CS0_OE_REG  DDRG
-#elif (SBBI0_CS0_AVRPORT == AVRPORTH)
-#define SBBI0_CS0_SOD_REG PORTH
-#define SBBI0_CS0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 chip select 0 output. */
-#define SBBI0_CS0_ENA()      sbi(SBBI0_CS0_OE_REG, SBBI0_CS0_BIT)
-/*! \brief Set SBBI0 chip select 0 output low. */
-#define SBBI0_CS0_CLR()      cbi(SBBI0_CS0_SOD_REG, SBBI0_CS0_BIT)
-/*! \brief Set SBBI0 chip select 0 output high. */
-#define SBBI0_CS0_SET()      sbi(SBBI0_CS0_SOD_REG, SBBI0_CS0_BIT)
-
-#else /* SBBI0_CS0_BIT */
-
-#define SBBI0_CS0_ENA()
-#define SBBI0_CS0_CLR()
-#define SBBI0_CS0_SET()
-
-#endif /* SBBI0_CS0_BIT */
-
-#ifdef SBBI0_CS1_BIT
-
-#if (SBBI0_CS1_AVRPORT == AVRPORTB)
-#define SBBI0_CS1_SOD_REG PORTB
-#define SBBI0_CS1_OE_REG  DDRB
-#elif (SBBI0_CS1_AVRPORT == AVRPORTD)
-#define SBBI0_CS1_SOD_REG PORTD
-#define SBBI0_CS1_OE_REG  DDRD
-#elif (SBBI0_CS1_AVRPORT == AVRPORTE)
-#define SBBI0_CS1_SOD_REG PORTE
-#define SBBI0_CS1_OE_REG  DDRE
-#elif (SBBI0_CS1_AVRPORT == AVRPORTF)
-#define SBBI0_CS1_SOD_REG PORTF
-#define SBBI0_CS1_OE_REG  DDRF
-#elif (SBBI0_CS1_AVRPORT == AVRPORTG)
-#define SBBI0_CS1_SOD_REG PORTG
-#define SBBI0_CS1_OE_REG  DDRG
-#elif (SBBI0_CS1_AVRPORT == AVRPORTH)
-#define SBBI0_CS1_SOD_REG PORTH
-#define SBBI0_CS1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 chip select 1 output. */
-#define SBBI0_CS1_ENA()      sbi(SBBI0_CS1_OE_REG, SBBI0_CS1_BIT)
-/*! \brief Set SBBI0 chip select 1 output low. */
-#define SBBI0_CS1_CLR()      cbi(SBBI0_CS1_SOD_REG, SBBI0_CS1_BIT)
-/*! \brief Set SBBI0 chip select 1 output high. */
-#define SBBI0_CS1_SET()      sbi(SBBI0_CS1_SOD_REG, SBBI0_CS1_BIT)
-
-#else /* SBBI0_CS1_BIT */
-
-#define SBBI0_CS1_ENA()
-#define SBBI0_CS1_CLR()
-#define SBBI0_CS1_SET()
-
-#endif /* SBBI0_CS1_BIT */
-
-#ifdef SBBI0_CS2_BIT
-
-#if (SBBI0_CS2_AVRPORT == AVRPORTB)
-#define SBBI0_CS2_SOD_REG PORTB
-#define SBBI0_CS2_OE_REG  DDRB
-#elif (SBBI0_CS2_AVRPORT == AVRPORTD)
-#define SBBI0_CS2_SOD_REG PORTD
-#define SBBI0_CS2_OE_REG  DDRD
-#elif (SBBI0_CS2_AVRPORT == AVRPORTE)
-#define SBBI0_CS2_SOD_REG PORTE
-#define SBBI0_CS2_OE_REG  DDRE
-#elif (SBBI0_CS2_AVRPORT == AVRPORTF)
-#define SBBI0_CS2_SOD_REG PORTF
-#define SBBI0_CS2_OE_REG  DDRF
-#elif (SBBI0_CS2_AVRPORT == AVRPORTG)
-#define SBBI0_CS2_SOD_REG PORTG
-#define SBBI0_CS2_OE_REG  DDRG
-#elif (SBBI0_CS2_AVRPORT == AVRPORTH)
-#define SBBI0_CS2_SOD_REG PORTH
-#define SBBI0_CS2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 chip select 2 output. */
-#define SBBI0_CS2_ENA()      sbi(SBBI0_CS2_OE_REG, SBBI0_CS2_BIT)
-/*! \brief Set SBBI0 chip select 2 output low. */
-#define SBBI0_CS2_CLR()      cbi(SBBI0_CS2_SOD_REG, SBBI0_CS2_BIT)
-/*! \brief Set SBBI0 chip select 2 output high. */
-#define SBBI0_CS2_SET()      sbi(SBBI0_CS2_SOD_REG, SBBI0_CS2_BIT)
-
-#else /* SBBI0_CS2_BIT */
-
-#define SBBI0_CS2_ENA()
-#define SBBI0_CS2_CLR()
-#define SBBI0_CS2_SET()
-
-#endif /* SBBI0_CS2_BIT */
-
-#ifdef SBBI0_CS3_BIT
-
-#if (SBBI0_CS3_AVRPORT == AVRPORTB)
-#define SBBI0_CS3_SOD_REG PORTB
-#define SBBI0_CS3_OE_REG  DDRB
-#elif (SBBI0_CS3_AVRPORT == AVRPORTD)
-#define SBBI0_CS3_SOD_REG PORTD
-#define SBBI0_CS3_OE_REG  DDRD
-#elif (SBBI0_CS3_AVRPORT == AVRPORTE)
-#define SBBI0_CS3_SOD_REG PORTE
-#define SBBI0_CS3_OE_REG  DDRE
-#elif (SBBI0_CS3_AVRPORT == AVRPORTF)
-#define SBBI0_CS3_SOD_REG PORTF
-#define SBBI0_CS3_OE_REG  DDRF
-#elif (SBBI0_CS3_AVRPORT == AVRPORTG)
-#define SBBI0_CS3_SOD_REG PORTG
-#define SBBI0_CS3_OE_REG  DDRG
-#elif (SBBI0_CS3_AVRPORT == AVRPORTH)
-#define SBBI0_CS3_SOD_REG PORTH
-#define SBBI0_CS3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 chip select 3 output. */
-#define SBBI0_CS3_ENA()      sbi(SBBI0_CS3_OE_REG, SBBI0_CS3_BIT)
-/*! \brief Set SBBI0 chip select 3 output low. */
-#define SBBI0_CS3_CLR()      cbi(SBBI0_CS3_SOD_REG, SBBI0_CS3_BIT)
-/*! \brief Set SBBI0 chip select 3 output high. */
-#define SBBI0_CS3_SET()      sbi(SBBI0_CS3_SOD_REG, SBBI0_CS3_BIT)
-
-#else /* SBBI0_CS3_BIT */
-
-#define SBBI0_CS3_ENA()
-#define SBBI0_CS3_CLR()
-#define SBBI0_CS3_SET()
-
-#endif /* SBBI0_CS3_BIT */
-
-#ifdef SBBI0_RST0_BIT
-
-#if (SBBI0_RST0_AVRPORT == AVRPORTB)
-#define SBBI0_RST0_SOD_REG PORTB
-#define SBBI0_RST0_OE_REG  DDRB
-#elif (SBBI0_RST0_AVRPORT == AVRPORTD)
-#define SBBI0_RST0_SOD_REG PORTD
-#define SBBI0_RST0_OE_REG  DDRD
-#elif (SBBI0_RST0_AVRPORT == AVRPORTE)
-#define SBBI0_RST0_SOD_REG PORTE
-#define SBBI0_RST0_OE_REG  DDRE
-#elif (SBBI0_RST0_AVRPORT == AVRPORTF)
-#define SBBI0_RST0_SOD_REG PORTF
-#define SBBI0_RST0_OE_REG  DDRF
-#elif (SBBI0_RST0_AVRPORT == AVRPORTG)
-#define SBBI0_RST0_SOD_REG PORTG
-#define SBBI0_RST0_OE_REG  DDRG
-#elif (SBBI0_RST0_AVRPORT == AVRPORTH)
-#define SBBI0_RST0_SOD_REG PORTH
-#define SBBI0_RST0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 reset 0 output. */
-#define SBBI0_RST0_ENA()      sbi(SBBI0_RST0_OE_REG, SBBI0_RST0_BIT)
-/*! \brief Set SBBI0 reset 0 output low. */
-#define SBBI0_RST0_CLR()      cbi(SBBI0_RST0_SOD_REG, SBBI0_RST0_BIT)
-/*! \brief Set SBBI0 reset 0 output high. */
-#define SBBI0_RST0_SET()      sbi(SBBI0_RST0_SOD_REG, SBBI0_RST0_BIT)
-
-#else /* SBBI0_RST0_BIT */
-
-#define SBBI0_RST0_ENA()
-#define SBBI0_RST0_CLR()
-#define SBBI0_RST0_SET()
-
-#endif /* SBBI0_RST0_BIT */
-
-#ifdef SBBI0_RST1_BIT
-
-#if (SBBI0_RST1_AVRPORT == AVRPORTB)
-#define SBBI0_RST1_SOD_REG PORTB
-#define SBBI0_RST1_OE_REG  DDRB
-#elif (SBBI0_RST1_AVRPORT == AVRPORTD)
-#define SBBI0_RST1_SOD_REG PORTD
-#define SBBI0_RST1_OE_REG  DDRD
-#elif (SBBI0_RST1_AVRPORT == AVRPORTE)
-#define SBBI0_RST1_SOD_REG PORTE
-#define SBBI0_RST1_OE_REG  DDRE
-#elif (SBBI0_RST1_AVRPORT == AVRPORTF)
-#define SBBI0_RST1_SOD_REG PORTF
-#define SBBI0_RST1_OE_REG  DDRF
-#elif (SBBI0_RST1_AVRPORT == AVRPORTG)
-#define SBBI0_RST1_SOD_REG PORTG
-#define SBBI0_RST1_OE_REG  DDRG
-#elif (SBBI0_RST1_AVRPORT == AVRPORTH)
-#define SBBI0_RST1_SOD_REG PORTH
-#define SBBI0_RST1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 reset 1 output. */
-#define SBBI0_RST1_ENA()      sbi(SBBI0_RST1_OE_REG, SBBI0_RST1_BIT)
-/*! \brief Set SBBI0 reset 1 output low. */
-#define SBBI0_RST1_CLR()      cbi(SBBI0_RST1_SOD_REG, SBBI0_RST1_BIT)
-/*! \brief Set SBBI0 reset 1 output high. */
-#define SBBI0_RST1_SET()      sbi(SBBI0_RST1_SOD_REG, SBBI0_RST1_BIT)
-
-#else /* SBBI0_RST1_BIT */
-
-#define SBBI0_RST1_ENA()
-#define SBBI0_RST1_CLR()
-#define SBBI0_RST1_SET()
-
-#endif /* SBBI0_RST1_BIT */
-
-#ifdef SBBI0_RST2_BIT
-
-#if (SBBI0_RST2_AVRPORT == AVRPORTB)
-#define SBBI0_RST2_SOD_REG PORTB
-#define SBBI0_RST2_OE_REG  DDRB
-#elif (SBBI0_RST2_AVRPORT == AVRPORTD)
-#define SBBI0_RST2_SOD_REG PORTD
-#define SBBI0_RST2_OE_REG  DDRD
-#elif (SBBI0_RST2_AVRPORT == AVRPORTE)
-#define SBBI0_RST2_SOD_REG PORTE
-#define SBBI0_RST2_OE_REG  DDRE
-#elif (SBBI0_RST2_AVRPORT == AVRPORTF)
-#define SBBI0_RST2_SOD_REG PORTF
-#define SBBI0_RST2_OE_REG  DDRF
-#elif (SBBI0_RST2_AVRPORT == AVRPORTG)
-#define SBBI0_RST2_SOD_REG PORTG
-#define SBBI0_RST2_OE_REG  DDRG
-#elif (SBBI0_RST2_AVRPORT == AVRPORTH)
-#define SBBI0_RST2_SOD_REG PORTH
-#define SBBI0_RST2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 reset 2 output. */
-#define SBBI0_RST2_ENA()      sbi(SBBI0_RST2_OE_REG, SBBI0_RST2_BIT)
-/*! \brief Set SBBI0 chip reset 2 output low. */
-#define SBBI0_RST2_CLR()      cbi(SBBI0_RST2_SOD_REG, SBBI0_RST2_BIT)
-/*! \brief Set SBBI0 chip reset 2 output high. */
-#define SBBI0_RST2_SET()      sbi(SBBI0_RST2_SOD_REG, SBBI0_RST2_BIT)
-
-#else /* SBBI0_RST2_BIT */
-
-#define SBBI0_RST2_ENA()
-#define SBBI0_RST2_CLR()
-#define SBBI0_RST2_SET()
-
-#endif /* SBBI0_RST2_BIT */
-
-#ifdef SBBI0_RST3_BIT
-
-#if (SBBI0_RST3_AVRPORT == AVRPORTB)
-#define SBBI0_RST3_SOD_REG PORTB
-#define SBBI0_RST3_OE_REG  DDRB
-#elif (SBBI0_RST3_AVRPORT == AVRPORTD)
-#define SBBI0_RST3_SOD_REG PORTD
-#define SBBI0_RST3_OE_REG  DDRD
-#elif (SBBI0_RST3_AVRPORT == AVRPORTE)
-#define SBBI0_RST3_SOD_REG PORTE
-#define SBBI0_RST3_OE_REG  DDRE
-#elif (SBBI0_RST3_AVRPORT == AVRPORTF)
-#define SBBI0_RST3_SOD_REG PORTF
-#define SBBI0_RST3_OE_REG  DDRF
-#elif (SBBI0_RST3_AVRPORT == AVRPORTG)
-#define SBBI0_RST3_SOD_REG PORTG
-#define SBBI0_RST3_OE_REG  DDRG
-#elif (SBBI0_RST3_AVRPORT == AVRPORTH)
-#define SBBI0_RST3_SOD_REG PORTH
-#define SBBI0_RST3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 reset 3 output. */
-#define SBBI0_RST3_ENA()      sbi(SBBI0_RST3_OE_REG, SBBI0_RST3_BIT)
-/*! \brief Set SBBI0 reset 3 output low. */
-#define SBBI0_RST3_CLR()      cbi(SBBI0_RST3_SOD_REG, SBBI0_RST3_BIT)
-/*! \brief Set SBBI0 reset 3 output high. */
-#define SBBI0_RST3_SET()      sbi(SBBI0_RST3_SOD_REG, SBBI0_RST3_BIT)
-
-#else /* SBBI0_RST3_BIT */
-
-#define SBBI0_RST3_ENA()
-#define SBBI0_RST3_CLR()
-#define SBBI0_RST3_SET()
-
-#endif /* SBBI0_RST3_BIT */
-
-#ifdef SBBI0_SCK_BIT
-
-#if (SBBI0_SCK_AVRPORT == AVRPORTB)
-#define SBBI0_SCK_SOD_REG PORTB
-#define SBBI0_SCK_OE_REG  DDRB
-#elif (SBBI0_SCK_AVRPORT == AVRPORTD)
-#define SBBI0_SCK_SOD_REG PORTD
-#define SBBI0_SCK_OE_REG  DDRD
-#elif (SBBI0_SCK_AVRPORT == AVRPORTE)
-#define SBBI0_SCK_SOD_REG PORTE
-#define SBBI0_SCK_OE_REG  DDRE
-#elif (SBBI0_SCK_AVRPORT == AVRPORTF)
-#define SBBI0_SCK_SOD_REG PORTF
-#define SBBI0_SCK_OE_REG  DDRF
-#elif (SBBI0_SCK_AVRPORT == AVRPORTG)
-#define SBBI0_SCK_SOD_REG PORTG
-#define SBBI0_SCK_OE_REG  DDRG
-#elif (SBBI0_SCK_AVRPORT == AVRPORTH)
-#define SBBI0_SCK_SOD_REG PORTH
-#define SBBI0_SCK_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 clock output. */
-#define SBBI0_SCK_ENA()      sbi(SBBI0_SCK_OE_REG, SBBI0_SCK_BIT)
-/*! \brief Set SBBI0 clock output low. */
-#define SBBI0_SCK_CLR()      cbi(SBBI0_SCK_SOD_REG, SBBI0_SCK_BIT)
-/*! \brief Set SBBI0 clock output high. */
-#define SBBI0_SCK_SET()      sbi(SBBI0_SCK_SOD_REG, SBBI0_SCK_BIT)
-
-#if defined(SBBI0_MOSI_BIT)
-
-#if (SBBI0_MOSI_AVRPORT == AVRPORTB)
-#define SBBI0_MOSI_SOD_REG PORTB
-#define SBBI0_MOSI_OE_REG  DDRB
-#elif (SBBI0_MOSI_AVRPORT == AVRPORTD)
-#define SBBI0_MOSI_SOD_REG PORTD
-#define SBBI0_MOSI_OE_REG  DDRD
-#elif (SBBI0_MOSI_AVRPORT == AVRPORTE)
-#define SBBI0_MOSI_SOD_REG PORTE
-#define SBBI0_MOSI_OE_REG  DDRE
-#elif (SBBI0_MOSI_AVRPORT == AVRPORTF)
-#define SBBI0_MOSI_SOD_REG PORTF
-#define SBBI0_MOSI_OE_REG  DDRF
-#elif (SBBI0_MOSI_AVRPORT == AVRPORTG)
-#define SBBI0_MOSI_SOD_REG PORTG
-#define SBBI0_MOSI_OE_REG  DDRG
-#elif (SBBI0_MOSI_AVRPORT == AVRPORTH)
-#define SBBI0_MOSI_SOD_REG PORTH
-#define SBBI0_MOSI_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 data output. */
-#define SBBI0_MOSI_ENA()      sbi(SBBI0_MOSI_OE_REG, SBBI0_MOSI_BIT)
-/*! \brief Set SBBI0 data output low. */
-#define SBBI0_MOSI_CLR()      cbi(SBBI0_MOSI_SOD_REG, SBBI0_MOSI_BIT)
-/*! \brief Set SBBI0 data output high. */
-#define SBBI0_MOSI_SET()      sbi(SBBI0_MOSI_SOD_REG, SBBI0_MOSI_BIT)
-
-#else                           /* SBBI0_MOSI_BIT */
-
-#define SBBI0_MOSI_ENA()
-#define SBBI0_MOSI_CLR()
-#define SBBI0_MOSI_SET()
-
-#endif                          /* SBBI0_MOSI_BIT */
-
-#if defined(SBBI0_MISO_BIT)
-
-#if (SBBI0_MISO_AVRPORT == AVRPORTB)
-#define SBBI0_MISO_PDS_REG PINB
-#define SBBI0_MISO_PUE_REG PORTB
-#define SBBI0_MISO_OE_REG  DDRB
-#elif (SBBI0_MISO_AVRPORT == AVRPORTD)
-#define SBBI0_MISO_PDS_REG PIND
-#define SBBI0_MISO_PUE_REG PORTD
-#define SBBI0_MISO_OE_REG  DDRD
-#elif (SBBI0_MISO_AVRPORT == AVRPORTE)
-#define SBBI0_MISO_PDS_REG PINE
-#define SBBI0_MISO_PUE_REG PORTE
-#define SBBI0_MISO_OE_REG  DDRE
-#elif (SBBI0_MISO_AVRPORT == AVRPORTF)
-#define SBBI0_MISO_PDS_REG PINF
-#define SBBI0_MISO_PUE_REG PORTF
-#define SBBI0_MISO_OE_REG  DDRF
-#elif (SBBI0_MISO_AVRPORT == AVRPORTG)
-#define SBBI0_MISO_PDS_REG PING
-#define SBBI0_MISO_PUE_REG PORTG
-#define SBBI0_MISO_OE_REG  DDRG
-#elif (SBBI0_MISO_AVRPORT == AVRPORTH)
-#define SBBI0_MISO_PDS_REG PINH
-#define SBBI0_MISO_PUE_REG PORTH
-#define SBBI0_MISO_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI0 data input. */
-#define SBBI0_MISO_ENA() \
-    cbi(SBBI0_MISO_OE_REG, SBBI0_MISO_BIT); \
-    sbi(SBBI0_MISO_PUE_REG, SBBI0_MISO_BIT)
-/*! \brief Query SBBI0 data input. */
-#define SBBI0_MISO_TST()    ((inb(SBBI0_MISO_PDS_REG) & _BV(SBBI0_MISO_BIT)) == _BV(SBBI0_MISO_BIT))
-
-#else                           /* SBBI0_MISO_BIT */
-
-#define SBBI0_MISO_ENA()
-#define SBBI0_MISO_TST()   0
-
-#endif                          /* SBBI0_MISO_BIT */
-
-#else                           /* SBBI0_SCK_BIT */
-
-#define SBBI0_SCK_ENA()
-#define SBBI0_SCK_CLR()
-#define SBBI0_SCK_SET()
-
-#define SBBI0_MOSI_ENA()
-#define SBBI0_MOSI_CLR()
-#define SBBI0_MOSI_SET()
-
-#define SBBI0_MISO_ENA()
-#define SBBI0_MISO_TST()   0
-
-#endif                          /* SBBI0_SCK_BIT */
-
-#else                           /* MCU */
-/*
- * AT91 implementation.
- * ======================================
- */
-
-#ifdef SBBI0_CS0_BIT
-
-#if !defined(SBBI0_CS0_PIO_ID)
-#define SBBI0_CS0_PE_REG        PIO_PER
-#define SBBI0_CS0_OE_REG        PIO_OER
-#define SBBI0_CS0_COD_REG       PIO_CODR
-#define SBBI0_CS0_SOD_REG       PIO_SODR
-#elif SBBI0_CS0_PIO_ID == PIO_ID
-#define SBBI0_CS0_PE_REG        PIO_PER
-#define SBBI0_CS0_OE_REG        PIO_OER
-#define SBBI0_CS0_COD_REG       PIO_CODR
-#define SBBI0_CS0_SOD_REG       PIO_SODR
-#elif SBBI0_CS0_PIO_ID == PIOA_ID
-#define SBBI0_CS0_PE_REG        PIOA_PER
-#define SBBI0_CS0_OE_REG        PIOA_OER
-#define SBBI0_CS0_COD_REG       PIOA_CODR
-#define SBBI0_CS0_SOD_REG       PIOA_SODR
-#elif SBBI0_CS0_PIO_ID == PIOB_ID
-#define SBBI0_CS0_PE_REG        PIOB_PER
-#define SBBI0_CS0_OE_REG        PIOB_OER
-#define SBBI0_CS0_COD_REG       PIOB_CODR
-#define SBBI0_CS0_SOD_REG       PIOB_SODR
-#elif SBBI0_CS0_PIO_ID == PIOC_ID
-#define SBBI0_CS0_PE_REG        PIOC_PER
-#define SBBI0_CS0_OE_REG        PIOC_OER
-#define SBBI0_CS0_COD_REG       PIOC_CODR
-#define SBBI0_CS0_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 chip select 0 output. */
-#define SBBI0_CS0_ENA() \
-    outr(SBBI0_CS0_PE_REG, _BV(SBBI0_CS0_BIT)); \
-    outr(SBBI0_CS0_OE_REG, _BV(SBBI0_CS0_BIT))
-/*! \brief Set SBBI0 chip select 0 output low. */
-#define SBBI0_CS0_CLR()   outr(SBBI0_CS0_COD_REG, _BV(SBBI0_CS0_BIT))
-/*! \brief Set SBBI0 chip select 0 output high. */
-#define SBBI0_CS0_SET()   outr(SBBI0_CS0_SOD_REG, _BV(SBBI0_CS0_BIT))
-
-#else /* SBBI0_CS0_BIT */
-
-#define SBBI0_CS0_ENA()
-#define SBBI0_CS0_CLR()
-#define SBBI0_CS0_SET()
-
-#endif /* SBBI0_CS0_BIT */
-
-#ifdef SBBI0_CS1_BIT
-
-#if !defined(SBBI0_CS1_PIO_ID)
-#define SBBI0_CS1_PE_REG        PIO_PER
-#define SBBI0_CS1_OE_REG        PIO_OER
-#define SBBI0_CS1_COD_REG       PIO_CODR
-#define SBBI0_CS1_SOD_REG       PIO_SODR
-#elif SBBI0_CS1_PIO_ID == PIO_ID
-#define SBBI0_CS1_PE_REG        PIO_PER
-#define SBBI0_CS1_OE_REG        PIO_OER
-#define SBBI0_CS1_COD_REG       PIO_CODR
-#define SBBI0_CS1_SOD_REG       PIO_SODR
-#elif SBBI0_CS1_PIO_ID == PIOA_ID
-#define SBBI0_CS1_PE_REG        PIOA_PER
-#define SBBI0_CS1_OE_REG        PIOA_OER
-#define SBBI0_CS1_COD_REG       PIOA_CODR
-#define SBBI0_CS1_SOD_REG       PIOA_SODR
-#elif SBBI0_CS1_PIO_ID == PIOB_ID
-#define SBBI0_CS1_PE_REG        PIOB_PER
-#define SBBI0_CS1_OE_REG        PIOB_OER
-#define SBBI0_CS1_COD_REG       PIOB_CODR
-#define SBBI0_CS1_SOD_REG       PIOB_SODR
-#elif SBBI0_CS1_PIO_ID == PIOC_ID
-#define SBBI0_CS1_PE_REG        PIOC_PER
-#define SBBI0_CS1_OE_REG        PIOC_OER
-#define SBBI0_CS1_COD_REG       PIOC_CODR
-#define SBBI0_CS1_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 chip select output. */
-#define SBBI0_CS1_ENA() \
-    outr(SBBI0_CS1_PE_REG, _BV(SBBI0_CS1_BIT)); \
-    outr(SBBI0_CS1_OE_REG, _BV(SBBI0_CS1_BIT))
-/*! \brief Set SBBI0 chip select output low. */
-#define SBBI0_CS1_CLR()   outr(SBBI0_CS1_COD_REG, _BV(SBBI0_CS1_BIT))
-/*! \brief Set SBBI0 chip select output high. */
-#define SBBI0_CS1_SET()   outr(SBBI0_CS1_SOD_REG, _BV(SBBI0_CS1_BIT))
-
-#else /* SBBI0_CS1_BIT */
-
-#define SBBI0_CS1_ENA()
-#define SBBI0_CS1_CLR()
-#define SBBI0_CS1_SET()
-
-#endif /* SBBI0_CS1_BIT */
-
-#ifdef SBBI0_CS2_BIT
-
-#if !defined(SBBI0_CS2_PIO_ID)
-#define SBBI0_CS2_PE_REG        PIO_PER
-#define SBBI0_CS2_OE_REG        PIO_OER
-#define SBBI0_CS2_COD_REG       PIO_CODR
-#define SBBI0_CS2_SOD_REG       PIO_SODR
-#elif SBBI0_CS2_PIO_ID == PIO_ID
-#define SBBI0_CS2_PE_REG        PIO_PER
-#define SBBI0_CS2_OE_REG        PIO_OER
-#define SBBI0_CS2_COD_REG       PIO_CODR
-#define SBBI0_CS2_SOD_REG       PIO_SODR
-#elif SBBI0_CS2_PIO_ID == PIOA_ID
-#define SBBI0_CS2_PE_REG        PIOA_PER
-#define SBBI0_CS2_OE_REG        PIOA_OER
-#define SBBI0_CS2_COD_REG       PIOA_CODR
-#define SBBI0_CS2_SOD_REG       PIOA_SODR
-#elif SBBI0_CS2_PIO_ID == PIOB_ID
-#define SBBI0_CS2_PE_REG        PIOB_PER
-#define SBBI0_CS2_OE_REG        PIOB_OER
-#define SBBI0_CS2_COD_REG       PIOB_CODR
-#define SBBI0_CS2_SOD_REG       PIOB_SODR
-#elif SBBI0_CS2_PIO_ID == PIOC_ID
-#define SBBI0_CS2_PE_REG        PIOC_PER
-#define SBBI0_CS2_OE_REG        PIOC_OER
-#define SBBI0_CS2_COD_REG       PIOC_CODR
-#define SBBI0_CS2_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 chip select output. */
-#define SBBI0_CS2_ENA() \
-    outr(SBBI0_CS2_PE_REG, _BV(SBBI0_CS2_BIT)); \
-    outr(SBBI0_CS2_OE_REG, _BV(SBBI0_CS2_BIT))
-/*! \brief Set SBBI0 chip select output low. */
-#define SBBI0_CS2_CLR()   outr(SBBI0_CS2_COD_REG, _BV(SBBI0_CS2_BIT))
-/*! \brief Set SBBI0 chip select output high. */
-#define SBBI0_CS2_SET()   outr(SBBI0_CS2_SOD_REG, _BV(SBBI0_CS2_BIT))
-
-#else /* SBBI0_CS2_BIT */
-
-#define SBBI0_CS2_ENA()
-#define SBBI0_CS2_CLR()
-#define SBBI0_CS2_SET()
-
-#endif /* SBBI0_CS2_BIT */
-
-#ifdef SBBI0_CS3_BIT
-
-#if !defined(SBBI0_CS3_PIO_ID)
-#define SBBI0_CS3_PE_REG        PIO_PER
-#define SBBI0_CS3_OE_REG        PIO_OER
-#define SBBI0_CS3_COD_REG       PIO_CODR
-#define SBBI0_CS3_SOD_REG       PIO_SODR
-#elif SBBI0_CS3_PIO_ID == PIO_ID
-#define SBBI0_CS3_PE_REG        PIO_PER
-#define SBBI0_CS3_OE_REG        PIO_OER
-#define SBBI0_CS3_COD_REG       PIO_CODR
-#define SBBI0_CS3_SOD_REG       PIO_SODR
-#elif SBBI0_CS3_PIO_ID == PIOA_ID
-#define SBBI0_CS3_PE_REG        PIOA_PER
-#define SBBI0_CS3_OE_REG        PIOA_OER
-#define SBBI0_CS3_COD_REG       PIOA_CODR
-#define SBBI0_CS3_SOD_REG       PIOA_SODR
-#elif SBBI0_CS3_PIO_ID == PIOB_ID
-#define SBBI0_CS3_PE_REG        PIOB_PER
-#define SBBI0_CS3_OE_REG        PIOB_OER
-#define SBBI0_CS3_COD_REG       PIOB_CODR
-#define SBBI0_CS3_SOD_REG       PIOB_SODR
-#elif SBBI0_CS3_PIO_ID == PIOC_ID
-#define SBBI0_CS3_PE_REG        PIOC_PER
-#define SBBI0_CS3_OE_REG        PIOC_OER
-#define SBBI0_CS3_COD_REG       PIOC_CODR
-#define SBBI0_CS3_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 chip select output. */
-#define SBBI0_CS3_ENA() \
-    outr(SBBI0_CS3_PE_REG, _BV(SBBI0_CS3_BIT)); \
-    outr(SBBI0_CS3_OE_REG, _BV(SBBI0_CS3_BIT))
-/*! \brief Set SBBI0 chip select output low. */
-#define SBBI0_CS3_CLR()   outr(SBBI0_CS3_COD_REG, _BV(SBBI0_CS3_BIT))
-/*! \brief Set SBBI0 chip select output high. */
-#define SBBI0_CS3_SET()   outr(SBBI0_CS3_SOD_REG, _BV(SBBI0_CS3_BIT))
-
-#else /* SBBI0_CS3_BIT */
-
-#define SBBI0_CS3_ENA()
-#define SBBI0_CS3_CLR()
-#define SBBI0_CS3_SET()
-
-#endif /* SBBI0_CS3_BIT */
-
-#ifdef SBBI0_RST0_BIT
-
-#if !defined(SBBI0_RST0_PIO_ID)
-#define SBBI0_RST0_PE_REG      PIO_PER
-#define SBBI0_RST0_OE_REG      PIO_OER
-#define SBBI0_RST0_COD_REG     PIO_CODR
-#define SBBI0_RST0_SOD_REG     PIO_SODR
-#elif SBBI0_RST0_PIO_ID == PIO_ID
-#define SBBI0_RST0_PE_REG      PIO_PER
-#define SBBI0_RST0_OE_REG      PIO_OER
-#define SBBI0_RST0_COD_REG     PIO_CODR
-#define SBBI0_RST0_SOD_REG     PIO_SODR
-#elif SBBI0_RST0_PIO_ID == PIOA_ID
-#define SBBI0_RST0_PE_REG      PIOA_PER
-#define SBBI0_RST0_OE_REG      PIOA_OER
-#define SBBI0_RST0_COD_REG     PIOA_CODR
-#define SBBI0_RST0_SOD_REG     PIOA_SODR
-#elif SBBI0_RST0_PIO_ID == PIOB_ID
-#define SBBI0_RST0_PE_REG      PIOB_PER
-#define SBBI0_RST0_OE_REG      PIOB_OER
-#define SBBI0_RST0_COD_REG     PIOB_CODR
-#define SBBI0_RST0_SOD_REG     PIOB_SODR
-#elif SBBI0_RST0_PIO_ID == PIOC_ID
-#define SBBI0_RST0_PE_REG      PIOC_PER
-#define SBBI0_RST0_OE_REG      PIOC_OER
-#define SBBI0_RST0_COD_REG     PIOC_CODR
-#define SBBI0_RST0_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 reset output. */
-#define SBBI0_RST0_ENA() \
-    outr(SBBI0_RST0_PE_REG, _BV(SBBI0_RST0_BIT)); \
-    outr(SBBI0_RST0_OE_REG, _BV(SBBI0_RST0_BIT))
-/*! \brief Set SBBI0 reset output low. */
-#define SBBI0_RST0_CLR()   outr(SBBI0_RST0_COD_REG, _BV(SBBI0_RST0_BIT))
-/*! \brief Set SBBI0 reset output high. */
-#define SBBI0_RST0_SET()   outr(SBBI0_RST0_SOD_REG, _BV(SBBI0_RST0_BIT))
-
-#else /* SBBI0_RST0_BIT */
-
-#define SBBI0_RST0_ENA()
-#define SBBI0_RST0_CLR()
-#define SBBI0_RST0_SET()
-
-#endif /* SBBI0_RST0_BIT */
-
-#ifdef SBBI0_RST1_BIT
-
-#if !defined(SBBI0_RST1_PIO_ID)
-#define SBBI0_RST1_PE_REG      PIO_PER
-#define SBBI0_RST1_OE_REG      PIO_OER
-#define SBBI0_RST1_COD_REG     PIO_CODR
-#define SBBI0_RST1_SOD_REG     PIO_SODR
-#elif SBBI0_RST1_PIO_ID == PIO_ID
-#define SBBI0_RST1_PE_REG      PIO_PER
-#define SBBI0_RST1_OE_REG      PIO_OER
-#define SBBI0_RST1_COD_REG     PIO_CODR
-#define SBBI0_RST1_SOD_REG     PIO_SODR
-#elif SBBI0_RST1_PIO_ID == PIOA_ID
-#define SBBI0_RST1_PE_REG      PIOA_PER
-#define SBBI0_RST1_OE_REG      PIOA_OER
-#define SBBI0_RST1_COD_REG     PIOA_CODR
-#define SBBI0_RST1_SOD_REG     PIOA_SODR
-#elif SBBI0_RST1_PIO_ID == PIOB_ID
-#define SBBI0_RST1_PE_REG      PIOB_PER
-#define SBBI0_RST1_OE_REG      PIOB_OER
-#define SBBI0_RST1_COD_REG     PIOB_CODR
-#define SBBI0_RST1_SOD_REG     PIOB_SODR
-#elif SBBI0_RST1_PIO_ID == PIOC_ID
-#define SBBI0_RST1_PE_REG      PIOC_PER
-#define SBBI0_RST1_OE_REG      PIOC_OER
-#define SBBI0_RST1_COD_REG     PIOC_CODR
-#define SBBI0_RST1_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 reset output. */
-#define SBBI0_RST1_ENA() \
-    outr(SBBI0_RST1_PE_REG, _BV(SBBI0_RST1_BIT)); \
-    outr(SBBI0_RST1_OE_REG, _BV(SBBI0_RST1_BIT))
-/*! \brief Set SBBI0 reset output low. */
-#define SBBI0_RST1_CLR()   outr(SBBI0_RST1_COD_REG, _BV(SBBI0_RST1_BIT))
-/*! \brief Set SBBI0 reset output high. */
-#define SBBI0_RST1_SET()   outr(SBBI0_RST1_SOD_REG, _BV(SBBI0_RST1_BIT))
-
-#else /* SBBI0_RST1_BIT */
-
-#define SBBI0_RST1_ENA()
-#define SBBI0_RST1_CLR()
-#define SBBI0_RST1_SET()
-
-#endif /* SBBI0_RST1_BIT */
-
-#ifdef SBBI0_RST2_BIT
-
-#if !defined(SBBI0_RST2_PIO_ID)
-#define SBBI0_RST2_PE_REG      PIO_PER
-#define SBBI0_RST2_OE_REG      PIO_OER
-#define SBBI0_RST2_COD_REG     PIO_CODR
-#define SBBI0_RST2_SOD_REG     PIO_SODR
-#elif SBBI0_RST2_PIO_ID == PIO_ID
-#define SBBI0_RST2_PE_REG      PIO_PER
-#define SBBI0_RST2_OE_REG      PIO_OER
-#define SBBI0_RST2_COD_REG     PIO_CODR
-#define SBBI0_RST2_SOD_REG     PIO_SODR
-#elif SBBI0_RST2_PIO_ID == PIOA_ID
-#define SBBI0_RST2_PE_REG      PIOA_PER
-#define SBBI0_RST2_OE_REG      PIOA_OER
-#define SBBI0_RST2_COD_REG     PIOA_CODR
-#define SBBI0_RST2_SOD_REG     PIOA_SODR
-#elif SBBI0_RST2_PIO_ID == PIOB_ID
-#define SBBI0_RST2_PE_REG      PIOB_PER
-#define SBBI0_RST2_OE_REG      PIOB_OER
-#define SBBI0_RST2_COD_REG     PIOB_CODR
-#define SBBI0_RST2_SOD_REG     PIOB_SODR
-#elif SBBI0_RST2_PIO_ID == PIOC_ID
-#define SBBI0_RST2_PE_REG      PIOC_PER
-#define SBBI0_RST2_OE_REG      PIOC_OER
-#define SBBI0_RST2_COD_REG     PIOC_CODR
-#define SBBI0_RST2_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 reset output. */
-#define SBBI0_RST2_ENA() \
-    outr(SBBI0_RST2_PE_REG, _BV(SBBI0_RST2_BIT)); \
-    outr(SBBI0_RST2_OE_REG, _BV(SBBI0_RST2_BIT))
-/*! \brief Set SBBI0 reset output low. */
-#define SBBI0_RST2_CLR()   outr(SBBI0_RST2_COD_REG, _BV(SBBI0_RST2_BIT))
-/*! \brief Set SBBI0 reset output high. */
-#define SBBI0_RST2_SET()   outr(SBBI0_RST2_SOD_REG, _BV(SBBI0_RST2_BIT))
-
-#else /* SBBI0_RST2_BIT */
-
-#define SBBI0_RST2_ENA()
-#define SBBI0_RST2_CLR()
-#define SBBI0_RST2_SET()
-
-#endif /* SBBI0_RST2_BIT */
-
-#ifdef SBBI0_RST3_BIT
-
-#if !defined(SBBI0_RST3_PIO_ID)
-#define SBBI0_RST3_PE_REG      PIO_PER
-#define SBBI0_RST3_OE_REG      PIO_OER
-#define SBBI0_RST3_COD_REG     PIO_CODR
-#define SBBI0_RST3_SOD_REG     PIO_SODR
-#elif SBBI0_RST3_PIO_ID == PIO_ID
-#define SBBI0_RST3_PE_REG      PIO_PER
-#define SBBI0_RST3_OE_REG      PIO_OER
-#define SBBI0_RST3_COD_REG     PIO_CODR
-#define SBBI0_RST3_SOD_REG     PIO_SODR
-#elif SBBI0_RST3_PIO_ID == PIOA_ID
-#define SBBI0_RST3_PE_REG      PIOA_PER
-#define SBBI0_RST3_OE_REG      PIOA_OER
-#define SBBI0_RST3_COD_REG     PIOA_CODR
-#define SBBI0_RST3_SOD_REG     PIOA_SODR
-#elif SBBI0_RST3_PIO_ID == PIOB_ID
-#define SBBI0_RST3_PE_REG      PIOB_PER
-#define SBBI0_RST3_OE_REG      PIOB_OER
-#define SBBI0_RST3_COD_REG     PIOB_CODR
-#define SBBI0_RST3_SOD_REG     PIOB_SODR
-#elif SBBI0_RST3_PIO_ID == PIOC_ID
-#define SBBI0_RST3_PE_REG      PIOC_PER
-#define SBBI0_RST3_OE_REG      PIOC_OER
-#define SBBI0_RST3_COD_REG     PIOC_CODR
-#define SBBI0_RST3_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 reset output. */
-#define SBBI0_RST3_ENA() \
-    outr(SBBI0_RST3_PE_REG, _BV(SBBI0_RST3_BIT)); \
-    outr(SBBI0_RST3_OE_REG, _BV(SBBI0_RST3_BIT))
-/*! \brief Set SBBI0 reset output low. */
-#define SBBI0_RST3_CLR()   outr(SBBI0_RST3_COD_REG, _BV(SBBI0_RST3_BIT))
-/*! \brief Set SBBI0 reset output high. */
-#define SBBI0_RST3_SET()   outr(SBBI0_RST3_SOD_REG, _BV(SBBI0_RST3_BIT))
-
-#else /* SBBI0_RST3_BIT */
-
-#define SBBI0_RST3_ENA()
-#define SBBI0_RST3_CLR()
-#define SBBI0_RST3_SET()
-
-#endif /* SBBI0_RST3_BIT */
-
-#ifdef SBBI0_SCK_BIT
-
-#if !defined(SBBI0_SCK_PIO_ID)
-#define SBBI0_SCK_PE_REG        PIO_PER
-#define SBBI0_SCK_OE_REG        PIO_OER
-#define SBBI0_SCK_COD_REG       PIO_CODR
-#define SBBI0_SCK_SOD_REG       PIO_SODR
-#elif SBBI0_SCK_PIO_ID == PIO_ID
-#define SBBI0_SCK_PE_REG        PIO_PER
-#define SBBI0_SCK_OE_REG        PIO_OER
-#define SBBI0_SCK_COD_REG       PIO_CODR
-#define SBBI0_SCK_SOD_REG       PIO_SODR
-#elif SBBI0_SCK_PIO_ID == PIOA_ID
-#define SBBI0_SCK_PE_REG        PIOA_PER
-#define SBBI0_SCK_OE_REG        PIOA_OER
-#define SBBI0_SCK_COD_REG       PIOA_CODR
-#define SBBI0_SCK_SOD_REG       PIOA_SODR
-#elif SBBI0_SCK_PIO_ID == PIOB_ID
-#define SBBI0_SCK_PE_REG        PIOB_PER
-#define SBBI0_SCK_OE_REG        PIOB_OER
-#define SBBI0_SCK_COD_REG       PIOB_CODR
-#define SBBI0_SCK_SOD_REG       PIOB_SODR
-#elif SBBI0_SCK_PIO_ID == PIOC_ID
-#define SBBI0_SCK_PE_REG        PIOC_PER
-#define SBBI0_SCK_OE_REG        PIOC_OER
-#define SBBI0_SCK_COD_REG       PIOC_CODR
-#define SBBI0_SCK_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 clock output. */
-#define SBBI0_SCK_ENA() \
-    outr(SBBI0_SCK_PE_REG, _BV(SBBI0_SCK_BIT)); \
-    outr(SBBI0_SCK_OE_REG, _BV(SBBI0_SCK_BIT))
-/*! \brief Set SBBI0 clock output low. */
-#define SBBI0_SCK_CLR()     outr(SBBI0_SCK_COD_REG, _BV(SBBI0_SCK_BIT))
-/*! \brief Set SBBI0 clock output high. */
-#define SBBI0_SCK_SET()     outr(SBBI0_SCK_SOD_REG, _BV(SBBI0_SCK_BIT))
-
-#ifdef SBBI0_MOSI_BIT
-
-#if !defined(SBBI0_MOSI_PIO_ID)
-#define SBBI0_MOSI_PE_REG       PIO_PER
-#define SBBI0_MOSI_OE_REG       PIO_OER
-#define SBBI0_MOSI_COD_REG      PIO_CODR
-#define SBBI0_MOSI_SOD_REG      PIO_SODR
-#elif SBBI0_MOSI_PIO_ID == PIO_ID
-#define SBBI0_MOSI_PE_REG       PIO_PER
-#define SBBI0_MOSI_OE_REG       PIO_OER
-#define SBBI0_MOSI_COD_REG      PIO_CODR
-#define SBBI0_MOSI_SOD_REG      PIO_SODR
-#elif SBBI0_MOSI_PIO_ID == PIOA_ID
-#define SBBI0_MOSI_PE_REG       PIOA_PER
-#define SBBI0_MOSI_OE_REG       PIOA_OER
-#define SBBI0_MOSI_COD_REG      PIOA_CODR
-#define SBBI0_MOSI_SOD_REG      PIOA_SODR
-#elif SBBI0_MOSI_PIO_ID == PIOB_ID
-#define SBBI0_MOSI_PE_REG       PIOB_PER
-#define SBBI0_MOSI_OE_REG       PIOB_OER
-#define SBBI0_MOSI_COD_REG      PIOB_CODR
-#define SBBI0_MOSI_SOD_REG      PIOB_SODR
-#elif SBBI0_MOSI_PIO_ID == PIOC_ID
-#define SBBI0_MOSI_PE_REG       PIOC_PER
-#define SBBI0_MOSI_OE_REG       PIOC_OER
-#define SBBI0_MOSI_COD_REG      PIOC_CODR
-#define SBBI0_MOSI_SOD_REG      PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI0 data output. */
-#define SBBI0_MOSI_ENA() \
-    outr(SBBI0_MOSI_PE_REG, _BV(SBBI0_MOSI_BIT)); \
-    outr(SBBI0_MOSI_OE_REG, _BV(SBBI0_MOSI_BIT))
-/*! \brief Set SBBI0 data output low. */
-#define SBBI0_MOSI_CLR()    outr(SBBI0_MOSI_COD_REG, _BV(SBBI0_MOSI_BIT))
-/*! \brief Set SBBI0 data output high. */
-#define SBBI0_MOSI_SET()    outr(SBBI0_MOSI_SOD_REG, _BV(SBBI0_MOSI_BIT))
-
-#else                           /* SBBI0_MOSI_BIT */
-
-#define SBBI0_MOSI_ENA()
-#define SBBI0_MOSI_CLR()
-#define SBBI0_MOSI_SET()
-
-#endif                          /* SBBI0_MOSI_BIT */
-
-#ifdef SBBI0_MISO_BIT
-
-#if !defined(SBBI0_MISO_PIO_ID)
-#define SBBI0_MISO_PE_REG       PIO_PER
-#define SBBI0_MISO_OD_REG       PIO_ODR
-#define SBBI0_MISO_PDS_REG      PIO_PDSR
-#elif SBBI0_MISO_PIO_ID == PIO_ID
-#define SBBI0_MISO_PE_REG       PIO_PER
-#define SBBI0_MISO_OD_REG       PIO_ODR
-#define SBBI0_MISO_PDS_REG      PIO_PDSR
-#elif SBBI0_MISO_PIO_ID == PIOA_ID
-#define SBBI0_MISO_PE_REG       PIOA_PER
-#define SBBI0_MISO_OD_REG       PIOA_ODR
-#define SBBI0_MISO_PDS_REG      PIOA_PDSR
-#elif SBBI0_MISO_PIO_ID == PIOB_ID
-#define SBBI0_MISO_PE_REG       PIOB_PER
-#define SBBI0_MISO_OD_REG       PIOB_ODR
-#define SBBI0_MISO_PDS_REG      PIOB_PDSR
-#elif SBBI0_MISO_PIO_ID == PIOC_ID
-#define SBBI0_MISO_PE_REG       PIOC_PER
-#define SBBI0_MISO_OD_REG       PIOC_ODR
-#define SBBI0_MISO_PDS_REG      PIOC_PDSR
-#endif
-
-/*! \brief Enable SBBI0 data input. */
-#define SBBI0_MISO_ENA() \
-    outr(SBBI0_MISO_PE_REG, _BV(SBBI0_MISO_BIT)); \
-    outr(SBBI0_MISO_OD_REG, _BV(SBBI0_MISO_BIT))
-/*! \brief Query SBBI0 data input. */
-#define SBBI0_MISO_TST()    ((inr(SBBI0_MISO_PDS_REG) & _BV(SBBI0_MISO_BIT)) == _BV(SBBI0_MISO_BIT))
-
-#else                           /* SBBI0_MISO_BIT */
-
-#define SBBI0_MISO_ENA()
-#define SBBI0_MISO_TST()   0
-
-#endif                          /* SBBI0_MISO_BIT */
-
-#else                           /* SBBI0_SCK_BIT */
-
-#define SBBI0_SCK_ENA()
-#define SBBI0_SCK_CLR()
-#define SBBI0_SCK_SET()
-
-#define SBBI0_MOSI_ENA()
-#define SBBI0_MOSI_CLR()
-#define SBBI0_MOSI_SET()
-
-#define SBBI0_MISO_ENA()
-#define SBBI0_MISO_TST()   0
-
-#endif                          /* SBBI0_SCK_BIT */
-
-#endif                          /* MCU */
-
-#define SBBI0_INIT() \
-{ \
-    SBBI0_SCK_CLR(); \
-    SBBI0_SCK_ENA(); \
-    SBBI0_MOSI_CLR(); \
-    SBBI0_MOSI_ENA(); \
-    SBBI0_MISO_ENA(); \
-}
-
-__BEGIN_DECLS
-/* Function prototypes */
-
-extern int Sbbi0SetMode(ureg_t ix, ureg_t mode);
-extern void Sbbi0SetSpeed(ureg_t ix, u_long rate);
-extern void Sbbi0Enable(ureg_t ix);
-extern void Sbbi0ChipReset(ureg_t ix, ureg_t hi);
-extern void Sbbi0ChipSelect(ureg_t ix, ureg_t hi);
-extern void Sbbi0SelectDevice(ureg_t ix);
-extern void Sbbi0DeselectDevice(ureg_t ix);
-extern void Sbbi0NegSelectDevice(ureg_t ix);
-extern void Sbbi0NegDeselectDevice(ureg_t ix);
-extern u_char Sbbi0Byte(u_char data);
-extern void Sbbi0Transact(CONST void *wdata, void *rdata, size_t len);
-
-__END_DECLS
-/* End of prototypes */
-
-#endif

+ 0 - 829
include/dev/sbbif1.h

@@ -1,829 +0,0 @@
-#ifndef _DEV_SBBIF1_H_
-#define _DEV_SBBIF1_H_
-/*
- * Copyright (C) 2007 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file dev/sbbif1.h
- * \brief Serial bit banged interface 1.
- *
- * \verbatim
- *
- * $Log: sbbif1.h,v $
- * Revision 1.1  2007/04/12 09:07:54  haraldkipp
- * Configurable SPI added.
- *
- *
- * \endverbatim
- */
-
-#include <cfg/arch/gpio.h>
-
-/*!
- * \brief Maximum number of devices (chip selects).
- */
-#ifndef SBBI1_MAX_DEVICES
-#define SBBI1_MAX_DEVICES   4
-#endif
-
-#if defined(__AVR__)            /* MCU */
-/*
- * AVR implementation.
- * ======================================
- */
-
-#ifdef SBBI1_CS0_BIT
-
-#if (SBBI1_CS0_AVRPORT == AVRPORTB)
-#define SBBI1_CS0_SOD_REG PORTB
-#define SBBI1_CS0_OE_REG  DDRB
-#elif (SBBI1_CS0_AVRPORT == AVRPORTD)
-#define SBBI1_CS0_SOD_REG PORTD
-#define SBBI1_CS0_OE_REG  DDRD
-#elif (SBBI1_CS0_AVRPORT == AVRPORTE)
-#define SBBI1_CS0_SOD_REG PORTE
-#define SBBI1_CS0_OE_REG  DDRE
-#elif (SBBI1_CS0_AVRPORT == AVRPORTF)
-#define SBBI1_CS0_SOD_REG PORTF
-#define SBBI1_CS0_OE_REG  DDRF
-#elif (SBBI1_CS0_AVRPORT == AVRPORTG)
-#define SBBI1_CS0_SOD_REG PORTG
-#define SBBI1_CS0_OE_REG  DDRG
-#elif (SBBI1_CS0_AVRPORT == AVRPORTH)
-#define SBBI1_CS0_SOD_REG PORTH
-#define SBBI1_CS0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 chip select 0 output. */
-#define SBBI1_CS0_ENA()      sbi(SBBI1_CS0_OE_REG, SBBI1_CS0_BIT)
-/*! \brief Set SBBI1 chip select 0 output low. */
-#define SBBI1_CS0_CLR()      cbi(SBBI1_CS0_SOD_REG, SBBI1_CS0_BIT)
-/*! \brief Set SBBI1 chip select 0 output high. */
-#define SBBI1_CS0_SET()      sbi(SBBI1_CS0_SOD_REG, SBBI1_CS0_BIT)
-
-#endif                          /* SBBI1_CS0_BIT */
-
-#ifdef SBBI1_CS1_BIT
-
-#if (SBBI1_CS1_AVRPORT == AVRPORTB)
-#define SBBI1_CS1_SOD_REG PORTB
-#define SBBI1_CS1_OE_REG  DDRB
-#elif (SBBI1_CS1_AVRPORT == AVRPORTD)
-#define SBBI1_CS1_SOD_REG PORTD
-#define SBBI1_CS1_OE_REG  DDRD
-#elif (SBBI1_CS1_AVRPORT == AVRPORTE)
-#define SBBI1_CS1_SOD_REG PORTE
-#define SBBI1_CS1_OE_REG  DDRE
-#elif (SBBI1_CS1_AVRPORT == AVRPORTF)
-#define SBBI1_CS1_SOD_REG PORTF
-#define SBBI1_CS1_OE_REG  DDRF
-#elif (SBBI1_CS1_AVRPORT == AVRPORTG)
-#define SBBI1_CS1_SOD_REG PORTG
-#define SBBI1_CS1_OE_REG  DDRG
-#elif (SBBI1_CS1_AVRPORT == AVRPORTH)
-#define SBBI1_CS1_SOD_REG PORTH
-#define SBBI1_CS1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 chip select 1 output. */
-#define SBBI1_CS1_ENA()      sbi(SBBI1_CS1_OE_REG, SBBI1_CS1_BIT)
-/*! \brief Set SBBI1 chip select 1 output low. */
-#define SBBI1_CS1_CLR()      cbi(SBBI1_CS1_SOD_REG, SBBI1_CS1_BIT)
-/*! \brief Set SBBI1 chip select 1 output high. */
-#define SBBI1_CS1_SET()      sbi(SBBI1_CS1_SOD_REG, SBBI1_CS1_BIT)
-
-#endif                          /* SBBI1_CS1_BIT */
-
-#ifdef SBBI1_CS2_BIT
-
-#if (SBBI1_CS2_AVRPORT == AVRPORTB)
-#define SBBI1_CS2_SOD_REG PORTB
-#define SBBI1_CS2_OE_REG  DDRB
-#elif (SBBI1_CS2_AVRPORT == AVRPORTD)
-#define SBBI1_CS2_SOD_REG PORTD
-#define SBBI1_CS2_OE_REG  DDRD
-#elif (SBBI1_CS2_AVRPORT == AVRPORTE)
-#define SBBI1_CS2_SOD_REG PORTE
-#define SBBI1_CS2_OE_REG  DDRE
-#elif (SBBI1_CS2_AVRPORT == AVRPORTF)
-#define SBBI1_CS2_SOD_REG PORTF
-#define SBBI1_CS2_OE_REG  DDRF
-#elif (SBBI1_CS2_AVRPORT == AVRPORTG)
-#define SBBI1_CS2_SOD_REG PORTG
-#define SBBI1_CS2_OE_REG  DDRG
-#elif (SBBI1_CS2_AVRPORT == AVRPORTH)
-#define SBBI1_CS2_SOD_REG PORTH
-#define SBBI1_CS2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 chip select 2 output. */
-#define SBBI1_CS2_ENA()      sbi(SBBI1_CS2_OE_REG, SBBI1_CS2_BIT)
-/*! \brief Set SBBI1 chip select 2 output low. */
-#define SBBI1_CS2_CLR()      cbi(SBBI1_CS2_SOD_REG, SBBI1_CS2_BIT)
-/*! \brief Set SBBI1 chip select 2 output high. */
-#define SBBI1_CS2_SET()      sbi(SBBI1_CS2_SOD_REG, SBBI1_CS2_BIT)
-
-#endif                          /* SBBI1_CS2_BIT */
-
-#ifdef SBBI1_CS3_BIT
-
-#if (SBBI1_CS3_AVRPORT == AVRPORTB)
-#define SBBI1_CS3_SOD_REG PORTB
-#define SBBI1_CS3_OE_REG  DDRB
-#elif (SBBI1_CS3_AVRPORT == AVRPORTD)
-#define SBBI1_CS3_SOD_REG PORTD
-#define SBBI1_CS3_OE_REG  DDRD
-#elif (SBBI1_CS3_AVRPORT == AVRPORTE)
-#define SBBI1_CS3_SOD_REG PORTE
-#define SBBI1_CS3_OE_REG  DDRE
-#elif (SBBI1_CS3_AVRPORT == AVRPORTF)
-#define SBBI1_CS3_SOD_REG PORTF
-#define SBBI1_CS3_OE_REG  DDRF
-#elif (SBBI1_CS3_AVRPORT == AVRPORTG)
-#define SBBI1_CS3_SOD_REG PORTG
-#define SBBI1_CS3_OE_REG  DDRG
-#elif (SBBI1_CS3_AVRPORT == AVRPORTH)
-#define SBBI1_CS3_SOD_REG PORTH
-#define SBBI1_CS3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 chip select 3 output. */
-#define SBBI1_CS3_ENA()      sbi(SBBI1_CS3_OE_REG, SBBI1_CS3_BIT)
-/*! \brief Set SBBI1 chip select 3 output low. */
-#define SBBI1_CS3_CLR()      cbi(SBBI1_CS3_SOD_REG, SBBI1_CS3_BIT)
-/*! \brief Set SBBI1 chip select 3 output high. */
-#define SBBI1_CS3_SET()      sbi(SBBI1_CS3_SOD_REG, SBBI1_CS3_BIT)
-
-#endif                          /* SBBI1_CS3_BIT */
-
-#ifdef SBBI1_RST0_BIT
-
-#if (SBBI1_RST0_AVRPORT == AVRPORTB)
-#define SBBI1_RST0_SOD_REG PORTB
-#define SBBI1_RST0_OE_REG  DDRB
-#elif (SBBI1_RST0_AVRPORT == AVRPORTD)
-#define SBBI1_RST0_SOD_REG PORTD
-#define SBBI1_RST0_OE_REG  DDRD
-#elif (SBBI1_RST0_AVRPORT == AVRPORTE)
-#define SBBI1_RST0_SOD_REG PORTE
-#define SBBI1_RST0_OE_REG  DDRE
-#elif (SBBI1_RST0_AVRPORT == AVRPORTF)
-#define SBBI1_RST0_SOD_REG PORTF
-#define SBBI1_RST0_OE_REG  DDRF
-#elif (SBBI1_RST0_AVRPORT == AVRPORTG)
-#define SBBI1_RST0_SOD_REG PORTG
-#define SBBI1_RST0_OE_REG  DDRG
-#elif (SBBI1_RST0_AVRPORT == AVRPORTH)
-#define SBBI1_RST0_SOD_REG PORTH
-#define SBBI1_RST0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 reset 0 output. */
-#define SBBI1_RST0_ENA()      sbi(SBBI1_RST0_OE_REG, SBBI1_RST0_BIT)
-/*! \brief Set SBBI1 reset 0 output low. */
-#define SBBI1_RST0_CLR()      cbi(SBBI1_RST0_SOD_REG, SBBI1_RST0_BIT)
-/*! \brief Set SBBI1 reset 0 output high. */
-#define SBBI1_RST0_SET()      sbi(SBBI1_RST0_SOD_REG, SBBI1_RST0_BIT)
-
-#endif                          /* SBBI1_RST0_BIT */
-
-#ifdef SBBI1_RST1_BIT
-
-#if (SBBI1_RST1_AVRPORT == AVRPORTB)
-#define SBBI1_RST1_SOD_REG PORTB
-#define SBBI1_RST1_OE_REG  DDRB
-#elif (SBBI1_RST1_AVRPORT == AVRPORTD)
-#define SBBI1_RST1_SOD_REG PORTD
-#define SBBI1_RST1_OE_REG  DDRD
-#elif (SBBI1_RST1_AVRPORT == AVRPORTE)
-#define SBBI1_RST1_SOD_REG PORTE
-#define SBBI1_RST1_OE_REG  DDRE
-#elif (SBBI1_RST1_AVRPORT == AVRPORTF)
-#define SBBI1_RST1_SOD_REG PORTF
-#define SBBI1_RST1_OE_REG  DDRF
-#elif (SBBI1_RST1_AVRPORT == AVRPORTG)
-#define SBBI1_RST1_SOD_REG PORTG
-#define SBBI1_RST1_OE_REG  DDRG
-#elif (SBBI1_RST1_AVRPORT == AVRPORTH)
-#define SBBI1_RST1_SOD_REG PORTH
-#define SBBI1_RST1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 reset 1 output. */
-#define SBBI1_RST1_ENA()      sbi(SBBI1_RST1_OE_REG, SBBI1_RST1_BIT)
-/*! \brief Set SBBI1 reset 1 output low. */
-#define SBBI1_RST1_CLR()      cbi(SBBI1_RST1_SOD_REG, SBBI1_RST1_BIT)
-/*! \brief Set SBBI1 reset 1 output high. */
-#define SBBI1_RST1_SET()      sbi(SBBI1_RST1_SOD_REG, SBBI1_RST1_BIT)
-
-#endif                          /* SBBI1_RST1_BIT */
-
-#ifdef SBBI1_RST2_BIT
-
-#if (SBBI1_RST2_AVRPORT == AVRPORTB)
-#define SBBI1_RST2_SOD_REG PORTB
-#define SBBI1_RST2_OE_REG  DDRB
-#elif (SBBI1_RST2_AVRPORT == AVRPORTD)
-#define SBBI1_RST2_SOD_REG PORTD
-#define SBBI1_RST2_OE_REG  DDRD
-#elif (SBBI1_RST2_AVRPORT == AVRPORTE)
-#define SBBI1_RST2_SOD_REG PORTE
-#define SBBI1_RST2_OE_REG  DDRE
-#elif (SBBI1_RST2_AVRPORT == AVRPORTF)
-#define SBBI1_RST2_SOD_REG PORTF
-#define SBBI1_RST2_OE_REG  DDRF
-#elif (SBBI1_RST2_AVRPORT == AVRPORTG)
-#define SBBI1_RST2_SOD_REG PORTG
-#define SBBI1_RST2_OE_REG  DDRG
-#elif (SBBI1_RST2_AVRPORT == AVRPORTH)
-#define SBBI1_RST2_SOD_REG PORTH
-#define SBBI1_RST2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 reset 2 output. */
-#define SBBI1_RST2_ENA()      sbi(SBBI1_RST2_OE_REG, SBBI1_RST2_BIT)
-/*! \brief Set SBBI1 chip reset 2 output low. */
-#define SBBI1_RST2_CLR()      cbi(SBBI1_RST2_SOD_REG, SBBI1_RST2_BIT)
-/*! \brief Set SBBI1 chip reset 2 output high. */
-#define SBBI1_RST2_SET()      sbi(SBBI1_RST2_SOD_REG, SBBI1_RST2_BIT)
-
-#endif                          /* SBBI1_RST2_BIT */
-
-#ifdef SBBI1_RST3_BIT
-
-#if (SBBI1_RST3_AVRPORT == AVRPORTB)
-#define SBBI1_RST3_SOD_REG PORTB
-#define SBBI1_RST3_OE_REG  DDRB
-#elif (SBBI1_RST3_AVRPORT == AVRPORTD)
-#define SBBI1_RST3_SOD_REG PORTD
-#define SBBI1_RST3_OE_REG  DDRD
-#elif (SBBI1_RST3_AVRPORT == AVRPORTE)
-#define SBBI1_RST3_SOD_REG PORTE
-#define SBBI1_RST3_OE_REG  DDRE
-#elif (SBBI1_RST3_AVRPORT == AVRPORTF)
-#define SBBI1_RST3_SOD_REG PORTF
-#define SBBI1_RST3_OE_REG  DDRF
-#elif (SBBI1_RST3_AVRPORT == AVRPORTG)
-#define SBBI1_RST3_SOD_REG PORTG
-#define SBBI1_RST3_OE_REG  DDRG
-#elif (SBBI1_RST3_AVRPORT == AVRPORTH)
-#define SBBI1_RST3_SOD_REG PORTH
-#define SBBI1_RST3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 reset 3 output. */
-#define SBBI1_RST3_ENA()      sbi(SBBI1_RST3_OE_REG, SBBI1_RST3_BIT)
-/*! \brief Set SBBI1 reset 3 output low. */
-#define SBBI1_RST3_CLR()      cbi(SBBI1_RST3_SOD_REG, SBBI1_RST3_BIT)
-/*! \brief Set SBBI1 reset 3 output high. */
-#define SBBI1_RST3_SET()      sbi(SBBI1_RST3_SOD_REG, SBBI1_RST3_BIT)
-
-#endif                          /* SBBI1_RST3_BIT */
-
-#ifdef SBBI1_SCK_BIT
-
-#if (SBBI1_SCK_AVRPORT == AVRPORTB)
-#define SBBI1_SCK_SOD_REG PORTB
-#define SBBI1_SCK_OE_REG  DDRB
-#elif (SBBI1_SCK_AVRPORT == AVRPORTD)
-#define SBBI1_SCK_SOD_REG PORTD
-#define SBBI1_SCK_OE_REG  DDRD
-#elif (SBBI1_SCK_AVRPORT == AVRPORTE)
-#define SBBI1_SCK_SOD_REG PORTE
-#define SBBI1_SCK_OE_REG  DDRE
-#elif (SBBI1_SCK_AVRPORT == AVRPORTF)
-#define SBBI1_SCK_SOD_REG PORTF
-#define SBBI1_SCK_OE_REG  DDRF
-#elif (SBBI1_SCK_AVRPORT == AVRPORTG)
-#define SBBI1_SCK_SOD_REG PORTG
-#define SBBI1_SCK_OE_REG  DDRG
-#elif (SBBI1_SCK_AVRPORT == AVRPORTH)
-#define SBBI1_SCK_SOD_REG PORTH
-#define SBBI1_SCK_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 clock output. */
-#define SBBI1_SCK_ENA()      sbi(SBBI1_SCK_OE_REG, SBBI1_SCK_BIT)
-/*! \brief Set SBBI1 clock output low. */
-#define SBBI1_SCK_CLR()      cbi(SBBI1_SCK_SOD_REG, SBBI1_SCK_BIT)
-/*! \brief Set SBBI1 clock output high. */
-#define SBBI1_SCK_SET()      sbi(SBBI1_SCK_SOD_REG, SBBI1_SCK_BIT)
-
-#if defined(SBBI1_MOSI_BIT)
-
-#if (SBBI1_MOSI_AVRPORT == AVRPORTB)
-#define SBBI1_MOSI_SOD_REG PORTB
-#define SBBI1_MOSI_OE_REG  DDRB
-#elif (SBBI1_MOSI_AVRPORT == AVRPORTD)
-#define SBBI1_MOSI_SOD_REG PORTD
-#define SBBI1_MOSI_OE_REG  DDRD
-#elif (SBBI1_MOSI_AVRPORT == AVRPORTE)
-#define SBBI1_MOSI_SOD_REG PORTE
-#define SBBI1_MOSI_OE_REG  DDRE
-#elif (SBBI1_MOSI_AVRPORT == AVRPORTF)
-#define SBBI1_MOSI_SOD_REG PORTF
-#define SBBI1_MOSI_OE_REG  DDRF
-#elif (SBBI1_MOSI_AVRPORT == AVRPORTG)
-#define SBBI1_MOSI_SOD_REG PORTG
-#define SBBI1_MOSI_OE_REG  DDRG
-#elif (SBBI1_MOSI_AVRPORT == AVRPORTH)
-#define SBBI1_MOSI_SOD_REG PORTH
-#define SBBI1_MOSI_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 data output. */
-#define SBBI1_MOSI_ENA()      sbi(SBBI1_MOSI_OE_REG, SBBI1_MOSI_BIT)
-/*! \brief Set SBBI1 data output low. */
-#define SBBI1_MOSI_CLR()      cbi(SBBI1_MOSI_SOD_REG, SBBI1_MOSI_BIT)
-/*! \brief Set SBBI1 data output high. */
-#define SBBI1_MOSI_SET()      sbi(SBBI1_MOSI_SOD_REG, SBBI1_MOSI_BIT)
-
-#else                           /* SBBI1_MOSI_BIT */
-
-#define SBBI1_MOSI_ENA()
-#define SBBI1_MOSI_CLR()
-#define SBBI1_MOSI_SET()
-
-#endif                          /* SBBI1_MOSI_BIT */
-
-#if defined(SBBI1_MISO_BIT)
-
-#if (SBBI1_MISO_AVRPORT == AVRPORTB)
-#define SBBI1_MISO_PDS_REG PINB
-#define SBBI1_MISO_PUE_REG PORTB
-#define SBBI1_MISO_OE_REG  DDRB
-#elif (SBBI1_MISO_AVRPORT == AVRPORTD)
-#define SBBI1_MISO_PDS_REG PIND
-#define SBBI1_MISO_PUE_REG PORTD
-#define SBBI1_MISO_OE_REG  DDRD
-#elif (SBBI1_MISO_AVRPORT == AVRPORTE)
-#define SBBI1_MISO_PDS_REG PINE
-#define SBBI1_MISO_PUE_REG PORTE
-#define SBBI1_MISO_OE_REG  DDRE
-#elif (SBBI1_MISO_AVRPORT == AVRPORTF)
-#define SBBI1_MISO_PDS_REG PINF
-#define SBBI1_MISO_PUE_REG PORTF
-#define SBBI1_MISO_OE_REG  DDRF
-#elif (SBBI1_MISO_AVRPORT == AVRPORTG)
-#define SBBI1_MISO_PDS_REG PING
-#define SBBI1_MISO_PUE_REG PORTG
-#define SBBI1_MISO_OE_REG  DDRG
-#elif (SBBI1_MISO_AVRPORT == AVRPORTH)
-#define SBBI1_MISO_PDS_REG PINH
-#define SBBI1_MISO_PUE_REG PORTH
-#define SBBI1_MISO_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI1 data input. */
-#define SBBI1_MISO_ENA() \
-    cbi(SBBI1_MISO_OE_REG, SBBI1_MISO_BIT); \
-    sbi(SBBI1_MISO_PUE_REG, SBBI1_MISO_BIT)
-/*! \brief Query SBBI1 data input. */
-#define SBBI1_MISO_TST()    ((inb(SBBI1_MISO_PDS_REG) & _BV(SBBI1_MISO_BIT)) == _BV(SBBI1_MISO_BIT))
-
-#else                           /* SBBI1_MISO_BIT */
-
-#define SBBI1_MISO_ENA()
-#define SBBI1_MISO_TST()   0
-
-#endif                          /* SBBI1_MISO_BIT */
-
-#endif                          /* SBBI1_SCK_BIT */
-
-#else                           /* MCU */
-/*
- * AT91 implementation.
- * ======================================
- */
-
-#ifdef SBBI1_CS0_BIT
-
-#if !defined(SBBI1_CS0_PIO_ID)
-#define SBBI1_CS0_PE_REG        PIO_PER
-#define SBBI1_CS0_OE_REG        PIO_OER
-#define SBBI1_CS0_COD_REG       PIO_CODR
-#define SBBI1_CS0_SOD_REG       PIO_SODR
-#elif SBBI1_CS0_PIO_ID == PIOA_ID
-#define SBBI1_CS0_PE_REG        PIOA_PER
-#define SBBI1_CS0_OE_REG        PIOA_OER
-#define SBBI1_CS0_COD_REG       PIOA_CODR
-#define SBBI1_CS0_SOD_REG       PIOA_SODR
-#elif SBBI1_CS0_PIO_ID == PIOB_ID
-#define SBBI1_CS0_PE_REG        PIOB_PER
-#define SBBI1_CS0_OE_REG        PIOB_OER
-#define SBBI1_CS0_COD_REG       PIOB_CODR
-#define SBBI1_CS0_SOD_REG       PIOB_SODR
-#elif SBBI1_CS0_PIO_ID == PIOC_ID
-#define SBBI1_CS0_PE_REG        PIOC_PER
-#define SBBI1_CS0_OE_REG        PIOC_OER
-#define SBBI1_CS0_COD_REG       PIOC_CODR
-#define SBBI1_CS0_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 chip select 0 output. */
-#define SBBI1_CS0_ENA() \
-    outr(SBBI1_CS0_PE_REG, _BV(SBBI1_CS0_BIT)); \
-    outr(SBBI1_CS0_OE_REG, _BV(SBBI1_CS0_BIT))
-/*! \brief Set SBBI1 chip select 0 output low. */
-#define SBBI1_CS0_CLR()   outr(SBBI1_CS0_COD_REG, _BV(SBBI1_CS0_BIT))
-/*! \brief Set SBBI1 chip select 0 output high. */
-#define SBBI1_CS0_SET()   outr(SBBI1_CS0_SOD_REG, _BV(SBBI1_CS0_BIT))
-
-#endif                          /* SBBI1_CS0_BIT */
-
-#ifdef SBBI1_CS1_BIT
-
-#if !defined(SBBI1_CS1_PIO_ID)
-#define SBBI1_CS1_PE_REG        PIO_PER
-#define SBBI1_CS1_OE_REG        PIO_OER
-#define SBBI1_CS1_COD_REG       PIO_CODR
-#define SBBI1_CS1_SOD_REG       PIO_SODR
-#elif SBBI1_CS1_PIO_ID == PIOA_ID
-#define SBBI1_CS1_PE_REG        PIOA_PER
-#define SBBI1_CS1_OE_REG        PIOA_OER
-#define SBBI1_CS1_COD_REG       PIOA_CODR
-#define SBBI1_CS1_SOD_REG       PIOA_SODR
-#elif SBBI1_CS1_PIO_ID == PIOB_ID
-#define SBBI1_CS1_PE_REG        PIOB_PER
-#define SBBI1_CS1_OE_REG        PIOB_OER
-#define SBBI1_CS1_COD_REG       PIOB_CODR
-#define SBBI1_CS1_SOD_REG       PIOB_SODR
-#elif SBBI1_CS1_PIO_ID == PIOC_ID
-#define SBBI1_CS1_PE_REG        PIOC_PER
-#define SBBI1_CS1_OE_REG        PIOC_OER
-#define SBBI1_CS1_COD_REG       PIOC_CODR
-#define SBBI1_CS1_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 chip select output. */
-#define SBBI1_CS1_ENA() \
-    outr(SBBI1_CS1_PE_REG, _BV(SBBI1_CS1_BIT)); \
-    outr(SBBI1_CS1_OE_REG, _BV(SBBI1_CS1_BIT))
-/*! \brief Set SBBI1 chip select output low. */
-#define SBBI1_CS1_CLR()   outr(SBBI1_CS1_COD_REG, _BV(SBBI1_CS1_BIT))
-/*! \brief Set SBBI1 chip select output high. */
-#define SBBI1_CS1_SET()   outr(SBBI1_CS1_SOD_REG, _BV(SBBI1_CS1_BIT))
-
-#endif                          /* SBBI1_CS1_BIT */
-
-#ifdef SBBI1_CS2_BIT
-
-#if !defined(SBBI1_CS2_PIO_ID)
-#define SBBI1_CS2_PE_REG        PIO_PER
-#define SBBI1_CS2_OE_REG        PIO_OER
-#define SBBI1_CS2_COD_REG       PIO_CODR
-#define SBBI1_CS2_SOD_REG       PIO_SODR
-#elif SBBI1_CS2_PIO_ID == PIOA_ID
-#define SBBI1_CS2_PE_REG        PIOA_PER
-#define SBBI1_CS2_OE_REG        PIOA_OER
-#define SBBI1_CS2_COD_REG       PIOA_CODR
-#define SBBI1_CS2_SOD_REG       PIOA_SODR
-#elif SBBI1_CS2_PIO_ID == PIOB_ID
-#define SBBI1_CS2_PE_REG        PIOB_PER
-#define SBBI1_CS2_OE_REG        PIOB_OER
-#define SBBI1_CS2_COD_REG       PIOB_CODR
-#define SBBI1_CS2_SOD_REG       PIOB_SODR
-#elif SBBI1_CS2_PIO_ID == PIOC_ID
-#define SBBI1_CS2_PE_REG        PIOC_PER
-#define SBBI1_CS2_OE_REG        PIOC_OER
-#define SBBI1_CS2_COD_REG       PIOC_CODR
-#define SBBI1_CS2_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 chip select output. */
-#define SBBI1_CS2_ENA() \
-    outr(SBBI1_CS2_PE_REG, _BV(SBBI1_CS2_BIT)); \
-    outr(SBBI1_CS2_OE_REG, _BV(SBBI1_CS2_BIT))
-/*! \brief Set SBBI1 chip select output low. */
-#define SBBI1_CS2_CLR()   outr(SBBI1_CS2_COD_REG, _BV(SBBI1_CS2_BIT))
-/*! \brief Set SBBI1 chip select output high. */
-#define SBBI1_CS2_SET()   outr(SBBI1_CS2_SOD_REG, _BV(SBBI1_CS2_BIT))
-
-#endif                          /* SBBI1_CS2_BIT */
-
-#ifdef SBBI1_CS3_BIT
-
-#if !defined(SBBI1_CS3_PIO_ID)
-#define SBBI1_CS3_PE_REG        PIO_PER
-#define SBBI1_CS3_OE_REG        PIO_OER
-#define SBBI1_CS3_COD_REG       PIO_CODR
-#define SBBI1_CS3_SOD_REG       PIO_SODR
-#elif SBBI1_CS3_PIO_ID == PIOA_ID
-#define SBBI1_CS3_PE_REG        PIOA_PER
-#define SBBI1_CS3_OE_REG        PIOA_OER
-#define SBBI1_CS3_COD_REG       PIOA_CODR
-#define SBBI1_CS3_SOD_REG       PIOA_SODR
-#elif SBBI1_CS3_PIO_ID == PIOB_ID
-#define SBBI1_CS3_PE_REG        PIOB_PER
-#define SBBI1_CS3_OE_REG        PIOB_OER
-#define SBBI1_CS3_COD_REG       PIOB_CODR
-#define SBBI1_CS3_SOD_REG       PIOB_SODR
-#elif SBBI1_CS3_PIO_ID == PIOC_ID
-#define SBBI1_CS3_PE_REG        PIOC_PER
-#define SBBI1_CS3_OE_REG        PIOC_OER
-#define SBBI1_CS3_COD_REG       PIOC_CODR
-#define SBBI1_CS3_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 chip select output. */
-#define SBBI1_CS3_ENA() \
-    outr(SBBI1_CS3_PE_REG, _BV(SBBI1_CS3_BIT)); \
-    outr(SBBI1_CS3_OE_REG, _BV(SBBI1_CS3_BIT))
-/*! \brief Set SBBI1 chip select output low. */
-#define SBBI1_CS3_CLR()   outr(SBBI1_CS3_COD_REG, _BV(SBBI1_CS3_BIT))
-/*! \brief Set SBBI1 chip select output high. */
-#define SBBI1_CS3_SET()   outr(SBBI1_CS3_SOD_REG, _BV(SBBI1_CS3_BIT))
-
-#endif                          /* SBBI1_CS3_BIT */
-
-#ifdef SBBI1_RST0_BIT
-
-#if !defined(SBBI1_RST0_PIO_ID)
-#define SBBI1_RST0_PE_REG      PIO_PER
-#define SBBI1_RST0_OE_REG      PIO_OER
-#define SBBI1_RST0_COD_REG     PIO_CODR
-#define SBBI1_RST0_SOD_REG     PIO_SODR
-#elif SBBI1_RST0_PIO_ID == PIOA_ID
-#define SBBI1_RST0_PE_REG      PIOA_PER
-#define SBBI1_RST0_OE_REG      PIOA_OER
-#define SBBI1_RST0_COD_REG     PIOA_CODR
-#define SBBI1_RST0_SOD_REG     PIOA_SODR
-#elif SBBI1_RST0_PIO_ID == PIOB_ID
-#define SBBI1_RST0_PE_REG      PIOB_PER
-#define SBBI1_RST0_OE_REG      PIOB_OER
-#define SBBI1_RST0_COD_REG     PIOB_CODR
-#define SBBI1_RST0_SOD_REG     PIOB_SODR
-#elif SBBI1_RST0_PIO_ID == PIOC_ID
-#define SBBI1_RST0_PE_REG      PIOC_PER
-#define SBBI1_RST0_OE_REG      PIOC_OER
-#define SBBI1_RST0_COD_REG     PIOC_CODR
-#define SBBI1_RST0_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 reset output. */
-#define SBBI1_RST0_ENA() \
-    outr(SBBI1_RST0_PE_REG, _BV(SBBI1_RST0_BIT)); \
-    outr(SBBI1_RST0_OE_REG, _BV(SBBI1_RST0_BIT))
-/*! \brief Set SBBI1 reset output low. */
-#define SBBI1_RST0_CLR()   outr(SBBI1_RST0_COD_REG, _BV(SBBI1_RST0_BIT))
-/*! \brief Set SBBI1 reset output high. */
-#define SBBI1_RST0_SET()   outr(SBBI1_RST0_SOD_REG, _BV(SBBI1_RST0_BIT))
-
-#endif                          /* SBBI1_RST0_BIT */
-
-#ifdef SBBI1_RST1_BIT
-
-#if !defined(SBBI1_RST1_PIO_ID)
-#define SBBI1_RST1_PE_REG      PIO_PER
-#define SBBI1_RST1_OE_REG      PIO_OER
-#define SBBI1_RST1_COD_REG     PIO_CODR
-#define SBBI1_RST1_SOD_REG     PIO_SODR
-#elif SBBI1_RST1_PIO_ID == PIOA_ID
-#define SBBI1_RST1_PE_REG      PIOA_PER
-#define SBBI1_RST1_OE_REG      PIOA_OER
-#define SBBI1_RST1_COD_REG     PIOA_CODR
-#define SBBI1_RST1_SOD_REG     PIOA_SODR
-#elif SBBI1_RST1_PIO_ID == PIOB_ID
-#define SBBI1_RST1_PE_REG      PIOB_PER
-#define SBBI1_RST1_OE_REG      PIOB_OER
-#define SBBI1_RST1_COD_REG     PIOB_CODR
-#define SBBI1_RST1_SOD_REG     PIOB_SODR
-#elif SBBI1_RST1_PIO_ID == PIOC_ID
-#define SBBI1_RST1_PE_REG      PIOC_PER
-#define SBBI1_RST1_OE_REG      PIOC_OER
-#define SBBI1_RST1_COD_REG     PIOC_CODR
-#define SBBI1_RST1_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 reset output. */
-#define SBBI1_RST1_ENA() \
-    outr(SBBI1_RST1_PE_REG, _BV(SBBI1_RST1_BIT)); \
-    outr(SBBI1_RST1_OE_REG, _BV(SBBI1_RST1_BIT))
-/*! \brief Set SBBI1 reset output low. */
-#define SBBI1_RST1_CLR()   outr(SBBI1_RST1_COD_REG, _BV(SBBI1_RST1_BIT))
-/*! \brief Set SBBI1 reset output high. */
-#define SBBI1_RST1_SET()   outr(SBBI1_RST1_SOD_REG, _BV(SBBI1_RST1_BIT))
-
-#endif                          /* SBBI1_RST1_BIT */
-
-#ifdef SBBI1_RST2_BIT
-
-#if !defined(SBBI1_RST2_PIO_ID)
-#define SBBI1_RST2_PE_REG      PIO_PER
-#define SBBI1_RST2_OE_REG      PIO_OER
-#define SBBI1_RST2_COD_REG     PIO_CODR
-#define SBBI1_RST2_SOD_REG     PIO_SODR
-#elif SBBI1_RST2_PIO_ID == PIOA_ID
-#define SBBI1_RST2_PE_REG      PIOA_PER
-#define SBBI1_RST2_OE_REG      PIOA_OER
-#define SBBI1_RST2_COD_REG     PIOA_CODR
-#define SBBI1_RST2_SOD_REG     PIOA_SODR
-#elif SBBI1_RST2_PIO_ID == PIOB_ID
-#define SBBI1_RST2_PE_REG      PIOB_PER
-#define SBBI1_RST2_OE_REG      PIOB_OER
-#define SBBI1_RST2_COD_REG     PIOB_CODR
-#define SBBI1_RST2_SOD_REG     PIOB_SODR
-#elif SBBI1_RST2_PIO_ID == PIOC_ID
-#define SBBI1_RST2_PE_REG      PIOC_PER
-#define SBBI1_RST2_OE_REG      PIOC_OER
-#define SBBI1_RST2_COD_REG     PIOC_CODR
-#define SBBI1_RST2_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 reset output. */
-#define SBBI1_RST2_ENA() \
-    outr(SBBI1_RST2_PE_REG, _BV(SBBI1_RST2_BIT)); \
-    outr(SBBI1_RST2_OE_REG, _BV(SBBI1_RST2_BIT))
-/*! \brief Set SBBI1 reset output low. */
-#define SBBI1_RST2_CLR()   outr(SBBI1_RST2_COD_REG, _BV(SBBI1_RST2_BIT))
-/*! \brief Set SBBI1 reset output high. */
-#define SBBI1_RST2_SET()   outr(SBBI1_RST2_SOD_REG, _BV(SBBI1_RST2_BIT))
-
-#endif                          /* SBBI1_RST2_BIT */
-
-#ifdef SBBI1_RST3_BIT
-
-#if !defined(SBBI1_RST3_PIO_ID)
-#define SBBI1_RST3_PE_REG      PIO_PER
-#define SBBI1_RST3_OE_REG      PIO_OER
-#define SBBI1_RST3_COD_REG     PIO_CODR
-#define SBBI1_RST3_SOD_REG     PIO_SODR
-#elif SBBI1_RST3_PIO_ID == PIOA_ID
-#define SBBI1_RST3_PE_REG      PIOA_PER
-#define SBBI1_RST3_OE_REG      PIOA_OER
-#define SBBI1_RST3_COD_REG     PIOA_CODR
-#define SBBI1_RST3_SOD_REG     PIOA_SODR
-#elif SBBI1_RST3_PIO_ID == PIOB_ID
-#define SBBI1_RST3_PE_REG      PIOB_PER
-#define SBBI1_RST3_OE_REG      PIOB_OER
-#define SBBI1_RST3_COD_REG     PIOB_CODR
-#define SBBI1_RST3_SOD_REG     PIOB_SODR
-#elif SBBI1_RST3_PIO_ID == PIOC_ID
-#define SBBI1_RST3_PE_REG      PIOC_PER
-#define SBBI1_RST3_OE_REG      PIOC_OER
-#define SBBI1_RST3_COD_REG     PIOC_CODR
-#define SBBI1_RST3_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 reset output. */
-#define SBBI1_RST3_ENA() \
-    outr(SBBI1_RST3_PE_REG, _BV(SBBI1_RST3_BIT)); \
-    outr(SBBI1_RST3_OE_REG, _BV(SBBI1_RST3_BIT))
-/*! \brief Set SBBI1 reset output low. */
-#define SBBI1_RST3_CLR()   outr(SBBI1_RST3_COD_REG, _BV(SBBI1_RST3_BIT))
-/*! \brief Set SBBI1 reset output high. */
-#define SBBI1_RST3_SET()   outr(SBBI1_RST3_SOD_REG, _BV(SBBI1_RST3_BIT))
-
-#endif                          /* SBBI1_RST3_BIT */
-
-#ifdef SBBI1_SCK_BIT
-
-#if !defined(SBBI1_SCK_PIO_ID)
-#define SBBI1_SCK_PE_REG        PIO_PER
-#define SBBI1_SCK_OE_REG        PIO_OER
-#define SBBI1_SCK_COD_REG       PIO_CODR
-#define SBBI1_SCK_SOD_REG       PIO_SODR
-#elif SBBI1_SCK_PIO_ID == PIOA_ID
-#define SBBI1_SCK_PE_REG        PIOA_PER
-#define SBBI1_SCK_OE_REG        PIOA_OER
-#define SBBI1_SCK_COD_REG       PIOA_CODR
-#define SBBI1_SCK_SOD_REG       PIOA_SODR
-#elif SBBI1_SCK_PIO_ID == PIOB_ID
-#define SBBI1_SCK_PE_REG        PIOB_PER
-#define SBBI1_SCK_OE_REG        PIOB_OER
-#define SBBI1_SCK_COD_REG       PIOB_CODR
-#define SBBI1_SCK_SOD_REG       PIOB_SODR
-#elif SBBI1_SCK_PIO_ID == PIOC_ID
-#define SBBI1_SCK_PE_REG        PIOC_PER
-#define SBBI1_SCK_OE_REG        PIOC_OER
-#define SBBI1_SCK_COD_REG       PIOC_CODR
-#define SBBI1_SCK_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 clock output. */
-#define SBBI1_SCK_ENA() \
-    outr(SBBI1_SCK_PE_REG, _BV(SBBI1_SCK_BIT)); \
-    outr(SBBI1_SCK_OE_REG, _BV(SBBI1_SCK_BIT))
-/*! \brief Set SBBI1 clock output low. */
-#define SBBI1_SCK_CLR()     outr(SBBI1_SCK_COD_REG, _BV(SBBI1_SCK_BIT))
-/*! \brief Set SBBI1 clock output high. */
-#define SBBI1_SCK_SET()     outr(SBBI1_SCK_SOD_REG, _BV(SBBI1_SCK_BIT))
-
-#ifdef SBBI1_MOSI_BIT
-
-#if !defined(SBBI1_MOSI_PIO_ID)
-#define SBBI1_MOSI_PE_REG       PIO_PER
-#define SBBI1_MOSI_OE_REG       PIO_OER
-#define SBBI1_MOSI_COD_REG      PIO_CODR
-#define SBBI1_MOSI_SOD_REG      PIO_SODR
-#elif SBBI1_MOSI_PIO_ID == PIOA_ID
-#define SBBI1_MOSI_PE_REG       PIOA_PER
-#define SBBI1_MOSI_OE_REG       PIOA_OER
-#define SBBI1_MOSI_COD_REG      PIOA_CODR
-#define SBBI1_MOSI_SOD_REG      PIOA_SODR
-#elif SBBI1_MOSI_PIO_ID == PIOB_ID
-#define SBBI1_MOSI_PE_REG       PIOB_PER
-#define SBBI1_MOSI_OE_REG       PIOB_OER
-#define SBBI1_MOSI_COD_REG      PIOB_CODR
-#define SBBI1_MOSI_SOD_REG      PIOB_SODR
-#elif SBBI1_MOSI_PIO_ID == PIOC_ID
-#define SBBI1_MOSI_PE_REG       PIOC_PER
-#define SBBI1_MOSI_OE_REG       PIOC_OER
-#define SBBI1_MOSI_COD_REG      PIOC_CODR
-#define SBBI1_MOSI_SOD_REG      PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI1 data output. */
-#define SBBI1_MOSI_ENA() \
-    outr(SBBI1_MOSI_PE_REG, _BV(SBBI1_MOSI_BIT)); \
-    outr(SBBI1_MOSI_OE_REG, _BV(SBBI1_MOSI_BIT))
-/*! \brief Set SBBI1 data output low. */
-#define SBBI1_MOSI_CLR()    outr(SBBI1_MOSI_COD_REG, _BV(SBBI1_MOSI_BIT))
-/*! \brief Set SBBI1 data output high. */
-#define SBBI1_MOSI_SET()    outr(SBBI1_MOSI_SOD_REG, _BV(SBBI1_MOSI_BIT))
-
-#else                           /* SBBI1_MOSI_BIT */
-
-#define SBBI1_MOSI_ENA()
-#define SBBI1_MOSI_CLR()
-#define SBBI1_MOSI_SET()
-
-#endif                          /* SBBI1_MOSI_BIT */
-
-#ifdef SBBI1_MISO_BIT
-
-#if !defined(SBBI1_MISO_PIO_ID)
-#define SBBI1_MISO_PE_REG       PIO_PER
-#define SBBI1_MISO_OD_REG       PIO_ODR
-#define SBBI1_MISO_PDS_REG      PIO_PDSR
-#elif SBBI1_MISO_PIO_ID == PIOA_ID
-#define SBBI1_MISO_PE_REG       PIOA_PER
-#define SBBI1_MISO_OD_REG       PIOA_ODR
-#define SBBI1_MISO_PDS_REG      PIOA_PDSR
-#elif SBBI1_MISO_PIO_ID == PIOB_ID
-#define SBBI1_MISO_PE_REG       PIOB_PER
-#define SBBI1_MISO_OD_REG       PIOB_ODR
-#define SBBI1_MISO_PDS_REG      PIOB_PDSR
-#elif SBBI1_MISO_PIO_ID == PIOC_ID
-#define SBBI1_MISO_PE_REG       PIOC_PER
-#define SBBI1_MISO_OD_REG       PIOC_ODR
-#define SBBI1_MISO_PDS_REG      PIOC_PDSR
-#endif
-
-/*! \brief Enable SBBI1 data input. */
-#define SBBI1_MISO_ENA() \
-    outr(SBBI1_MISO_PE_REG, _BV(SBBI1_MISO_BIT)); \
-    outr(SBBI1_MISO_OD_REG, _BV(SBBI1_MISO_BIT))
-/*! \brief Query SBBI1 data input. */
-#define SBBI1_MISO_TST()    ((inr(SBBI1_MISO_PDS_REG) & _BV(SBBI1_MISO_BIT)) == _BV(SBBI1_MISO_BIT))
-
-#else                           /* SBBI1_MISO_BIT */
-
-#define SBBI1_MISO_ENA()
-#define SBBI1_MISO_TST()   0
-
-#endif                          /* SBBI1_MISO_BIT */
-
-#endif                          /* SBBI1_SCK_BIT */
-
-#endif                          /* MCU */
-
-#define SBBI1_INIT() \
-{ \
-    SBBI1_SCK_CLR(); \
-    SBBI1_SCK_ENA(); \
-    SBBI1_MOSI_CLR(); \
-    SBBI1_MOSI_ENA(); \
-    SBBI1_MISO_ENA(); \
-}
-
-#endif

+ 0 - 829
include/dev/sbbif2.h

@@ -1,829 +0,0 @@
-#ifndef _DEV_SBBI2F_H_
-#define _DEV_SBBI2F_H_
-/*
- * Copyright (C) 2007 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file dev/sbbif2.h
- * \brief Serial bit banged interface 2.
- *
- * \verbatim
- *
- * $Log: sbbif2.h,v $
- * Revision 1.1  2007/04/12 09:07:54  haraldkipp
- * Configurable SPI added.
- *
- *
- * \endverbatim
- */
-
-#include <cfg/arch/gpio.h>
-
-/*!
- * \brief Maximum number of devices (chip selects).
- */
-#ifndef SBBI2_MAX_DEVICES
-#define SBBI2_MAX_DEVICES   4
-#endif
-
-#if defined(__AVR__)            /* MCU */
-/*
- * AVR implementation.
- * ======================================
- */
-
-#ifdef SBBI2_CS0_BIT
-
-#if (SBBI2_CS0_AVRPORT == AVRPORTB)
-#define SBBI2_CS0_SOD_REG PORTB
-#define SBBI2_CS0_OE_REG  DDRB
-#elif (SBBI2_CS0_AVRPORT == AVRPORTD)
-#define SBBI2_CS0_SOD_REG PORTD
-#define SBBI2_CS0_OE_REG  DDRD
-#elif (SBBI2_CS0_AVRPORT == AVRPORTE)
-#define SBBI2_CS0_SOD_REG PORTE
-#define SBBI2_CS0_OE_REG  DDRE
-#elif (SBBI2_CS0_AVRPORT == AVRPORTF)
-#define SBBI2_CS0_SOD_REG PORTF
-#define SBBI2_CS0_OE_REG  DDRF
-#elif (SBBI2_CS0_AVRPORT == AVRPORTG)
-#define SBBI2_CS0_SOD_REG PORTG
-#define SBBI2_CS0_OE_REG  DDRG
-#elif (SBBI2_CS0_AVRPORT == AVRPORTH)
-#define SBBI2_CS0_SOD_REG PORTH
-#define SBBI2_CS0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 chip select 0 output. */
-#define SBBI2_CS0_ENA()      sbi(SBBI2_CS0_OE_REG, SBBI2_CS0_BIT)
-/*! \brief Set SBBI2 chip select 0 output low. */
-#define SBBI2_CS0_CLR()      cbi(SBBI2_CS0_SOD_REG, SBBI2_CS0_BIT)
-/*! \brief Set SBBI2 chip select 0 output high. */
-#define SBBI2_CS0_SET()      sbi(SBBI2_CS0_SOD_REG, SBBI2_CS0_BIT)
-
-#endif                          /* SBBI2_CS0_BIT */
-
-#ifdef SBBI2_CS1_BIT
-
-#if (SBBI2_CS1_AVRPORT == AVRPORTB)
-#define SBBI2_CS1_SOD_REG PORTB
-#define SBBI2_CS1_OE_REG  DDRB
-#elif (SBBI2_CS1_AVRPORT == AVRPORTD)
-#define SBBI2_CS1_SOD_REG PORTD
-#define SBBI2_CS1_OE_REG  DDRD
-#elif (SBBI2_CS1_AVRPORT == AVRPORTE)
-#define SBBI2_CS1_SOD_REG PORTE
-#define SBBI2_CS1_OE_REG  DDRE
-#elif (SBBI2_CS1_AVRPORT == AVRPORTF)
-#define SBBI2_CS1_SOD_REG PORTF
-#define SBBI2_CS1_OE_REG  DDRF
-#elif (SBBI2_CS1_AVRPORT == AVRPORTG)
-#define SBBI2_CS1_SOD_REG PORTG
-#define SBBI2_CS1_OE_REG  DDRG
-#elif (SBBI2_CS1_AVRPORT == AVRPORTH)
-#define SBBI2_CS1_SOD_REG PORTH
-#define SBBI2_CS1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 chip select 1 output. */
-#define SBBI2_CS1_ENA()      sbi(SBBI2_CS1_OE_REG, SBBI2_CS1_BIT)
-/*! \brief Set SBBI2 chip select 1 output low. */
-#define SBBI2_CS1_CLR()      cbi(SBBI2_CS1_SOD_REG, SBBI2_CS1_BIT)
-/*! \brief Set SBBI2 chip select 1 output high. */
-#define SBBI2_CS1_SET()      sbi(SBBI2_CS1_SOD_REG, SBBI2_CS1_BIT)
-
-#endif                          /* SBBI2_CS1_BIT */
-
-#ifdef SBBI2_CS2_BIT
-
-#if (SBBI2_CS2_AVRPORT == AVRPORTB)
-#define SBBI2_CS2_SOD_REG PORTB
-#define SBBI2_CS2_OE_REG  DDRB
-#elif (SBBI2_CS2_AVRPORT == AVRPORTD)
-#define SBBI2_CS2_SOD_REG PORTD
-#define SBBI2_CS2_OE_REG  DDRD
-#elif (SBBI2_CS2_AVRPORT == AVRPORTE)
-#define SBBI2_CS2_SOD_REG PORTE
-#define SBBI2_CS2_OE_REG  DDRE
-#elif (SBBI2_CS2_AVRPORT == AVRPORTF)
-#define SBBI2_CS2_SOD_REG PORTF
-#define SBBI2_CS2_OE_REG  DDRF
-#elif (SBBI2_CS2_AVRPORT == AVRPORTG)
-#define SBBI2_CS2_SOD_REG PORTG
-#define SBBI2_CS2_OE_REG  DDRG
-#elif (SBBI2_CS2_AVRPORT == AVRPORTH)
-#define SBBI2_CS2_SOD_REG PORTH
-#define SBBI2_CS2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 chip select 2 output. */
-#define SBBI2_CS2_ENA()      sbi(SBBI2_CS2_OE_REG, SBBI2_CS2_BIT)
-/*! \brief Set SBBI2 chip select 2 output low. */
-#define SBBI2_CS2_CLR()      cbi(SBBI2_CS2_SOD_REG, SBBI2_CS2_BIT)
-/*! \brief Set SBBI2 chip select 2 output high. */
-#define SBBI2_CS2_SET()      sbi(SBBI2_CS2_SOD_REG, SBBI2_CS2_BIT)
-
-#endif                          /* SBBI2_CS2_BIT */
-
-#ifdef SBBI2_CS3_BIT
-
-#if (SBBI2_CS3_AVRPORT == AVRPORTB)
-#define SBBI2_CS3_SOD_REG PORTB
-#define SBBI2_CS3_OE_REG  DDRB
-#elif (SBBI2_CS3_AVRPORT == AVRPORTD)
-#define SBBI2_CS3_SOD_REG PORTD
-#define SBBI2_CS3_OE_REG  DDRD
-#elif (SBBI2_CS3_AVRPORT == AVRPORTE)
-#define SBBI2_CS3_SOD_REG PORTE
-#define SBBI2_CS3_OE_REG  DDRE
-#elif (SBBI2_CS3_AVRPORT == AVRPORTF)
-#define SBBI2_CS3_SOD_REG PORTF
-#define SBBI2_CS3_OE_REG  DDRF
-#elif (SBBI2_CS3_AVRPORT == AVRPORTG)
-#define SBBI2_CS3_SOD_REG PORTG
-#define SBBI2_CS3_OE_REG  DDRG
-#elif (SBBI2_CS3_AVRPORT == AVRPORTH)
-#define SBBI2_CS3_SOD_REG PORTH
-#define SBBI2_CS3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 chip select 3 output. */
-#define SBBI2_CS3_ENA()      sbi(SBBI2_CS3_OE_REG, SBBI2_CS3_BIT)
-/*! \brief Set SBBI2 chip select 3 output low. */
-#define SBBI2_CS3_CLR()      cbi(SBBI2_CS3_SOD_REG, SBBI2_CS3_BIT)
-/*! \brief Set SBBI2 chip select 3 output high. */
-#define SBBI2_CS3_SET()      sbi(SBBI2_CS3_SOD_REG, SBBI2_CS3_BIT)
-
-#endif                          /* SBBI2_CS3_BIT */
-
-#ifdef SBBI2_RST0_BIT
-
-#if (SBBI2_RST0_AVRPORT == AVRPORTB)
-#define SBBI2_RST0_SOD_REG PORTB
-#define SBBI2_RST0_OE_REG  DDRB
-#elif (SBBI2_RST0_AVRPORT == AVRPORTD)
-#define SBBI2_RST0_SOD_REG PORTD
-#define SBBI2_RST0_OE_REG  DDRD
-#elif (SBBI2_RST0_AVRPORT == AVRPORTE)
-#define SBBI2_RST0_SOD_REG PORTE
-#define SBBI2_RST0_OE_REG  DDRE
-#elif (SBBI2_RST0_AVRPORT == AVRPORTF)
-#define SBBI2_RST0_SOD_REG PORTF
-#define SBBI2_RST0_OE_REG  DDRF
-#elif (SBBI2_RST0_AVRPORT == AVRPORTG)
-#define SBBI2_RST0_SOD_REG PORTG
-#define SBBI2_RST0_OE_REG  DDRG
-#elif (SBBI2_RST0_AVRPORT == AVRPORTH)
-#define SBBI2_RST0_SOD_REG PORTH
-#define SBBI2_RST0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 reset 0 output. */
-#define SBBI2_RST0_ENA()      sbi(SBBI2_RST0_OE_REG, SBBI2_RST0_BIT)
-/*! \brief Set SBBI2 reset 0 output low. */
-#define SBBI2_RST0_CLR()      cbi(SBBI2_RST0_SOD_REG, SBBI2_RST0_BIT)
-/*! \brief Set SBBI2 reset 0 output high. */
-#define SBBI2_RST0_SET()      sbi(SBBI2_RST0_SOD_REG, SBBI2_RST0_BIT)
-
-#endif                          /* SBBI2_RST0_BIT */
-
-#ifdef SBBI2_RST1_BIT
-
-#if (SBBI2_RST1_AVRPORT == AVRPORTB)
-#define SBBI2_RST1_SOD_REG PORTB
-#define SBBI2_RST1_OE_REG  DDRB
-#elif (SBBI2_RST1_AVRPORT == AVRPORTD)
-#define SBBI2_RST1_SOD_REG PORTD
-#define SBBI2_RST1_OE_REG  DDRD
-#elif (SBBI2_RST1_AVRPORT == AVRPORTE)
-#define SBBI2_RST1_SOD_REG PORTE
-#define SBBI2_RST1_OE_REG  DDRE
-#elif (SBBI2_RST1_AVRPORT == AVRPORTF)
-#define SBBI2_RST1_SOD_REG PORTF
-#define SBBI2_RST1_OE_REG  DDRF
-#elif (SBBI2_RST1_AVRPORT == AVRPORTG)
-#define SBBI2_RST1_SOD_REG PORTG
-#define SBBI2_RST1_OE_REG  DDRG
-#elif (SBBI2_RST1_AVRPORT == AVRPORTH)
-#define SBBI2_RST1_SOD_REG PORTH
-#define SBBI2_RST1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 reset 1 output. */
-#define SBBI2_RST1_ENA()      sbi(SBBI2_RST1_OE_REG, SBBI2_RST1_BIT)
-/*! \brief Set SBBI2 reset 1 output low. */
-#define SBBI2_RST1_CLR()      cbi(SBBI2_RST1_SOD_REG, SBBI2_RST1_BIT)
-/*! \brief Set SBBI2 reset 1 output high. */
-#define SBBI2_RST1_SET()      sbi(SBBI2_RST1_SOD_REG, SBBI2_RST1_BIT)
-
-#endif                          /* SBBI2_RST1_BIT */
-
-#ifdef SBBI2_RST2_BIT
-
-#if (SBBI2_RST2_AVRPORT == AVRPORTB)
-#define SBBI2_RST2_SOD_REG PORTB
-#define SBBI2_RST2_OE_REG  DDRB
-#elif (SBBI2_RST2_AVRPORT == AVRPORTD)
-#define SBBI2_RST2_SOD_REG PORTD
-#define SBBI2_RST2_OE_REG  DDRD
-#elif (SBBI2_RST2_AVRPORT == AVRPORTE)
-#define SBBI2_RST2_SOD_REG PORTE
-#define SBBI2_RST2_OE_REG  DDRE
-#elif (SBBI2_RST2_AVRPORT == AVRPORTF)
-#define SBBI2_RST2_SOD_REG PORTF
-#define SBBI2_RST2_OE_REG  DDRF
-#elif (SBBI2_RST2_AVRPORT == AVRPORTG)
-#define SBBI2_RST2_SOD_REG PORTG
-#define SBBI2_RST2_OE_REG  DDRG
-#elif (SBBI2_RST2_AVRPORT == AVRPORTH)
-#define SBBI2_RST2_SOD_REG PORTH
-#define SBBI2_RST2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 reset 2 output. */
-#define SBBI2_RST2_ENA()      sbi(SBBI2_RST2_OE_REG, SBBI2_RST2_BIT)
-/*! \brief Set SBBI2 chip reset 2 output low. */
-#define SBBI2_RST2_CLR()      cbi(SBBI2_RST2_SOD_REG, SBBI2_RST2_BIT)
-/*! \brief Set SBBI2 chip reset 2 output high. */
-#define SBBI2_RST2_SET()      sbi(SBBI2_RST2_SOD_REG, SBBI2_RST2_BIT)
-
-#endif                          /* SBBI2_RST2_BIT */
-
-#ifdef SBBI2_RST3_BIT
-
-#if (SBBI2_RST3_AVRPORT == AVRPORTB)
-#define SBBI2_RST3_SOD_REG PORTB
-#define SBBI2_RST3_OE_REG  DDRB
-#elif (SBBI2_RST3_AVRPORT == AVRPORTD)
-#define SBBI2_RST3_SOD_REG PORTD
-#define SBBI2_RST3_OE_REG  DDRD
-#elif (SBBI2_RST3_AVRPORT == AVRPORTE)
-#define SBBI2_RST3_SOD_REG PORTE
-#define SBBI2_RST3_OE_REG  DDRE
-#elif (SBBI2_RST3_AVRPORT == AVRPORTF)
-#define SBBI2_RST3_SOD_REG PORTF
-#define SBBI2_RST3_OE_REG  DDRF
-#elif (SBBI2_RST3_AVRPORT == AVRPORTG)
-#define SBBI2_RST3_SOD_REG PORTG
-#define SBBI2_RST3_OE_REG  DDRG
-#elif (SBBI2_RST3_AVRPORT == AVRPORTH)
-#define SBBI2_RST3_SOD_REG PORTH
-#define SBBI2_RST3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 reset 3 output. */
-#define SBBI2_RST3_ENA()      sbi(SBBI2_RST3_OE_REG, SBBI2_RST3_BIT)
-/*! \brief Set SBBI2 reset 3 output low. */
-#define SBBI2_RST3_CLR()      cbi(SBBI2_RST3_SOD_REG, SBBI2_RST3_BIT)
-/*! \brief Set SBBI2 reset 3 output high. */
-#define SBBI2_RST3_SET()      sbi(SBBI2_RST3_SOD_REG, SBBI2_RST3_BIT)
-
-#endif                          /* SBBI2_RST3_BIT */
-
-#ifdef SBBI2_SCK_BIT
-
-#if (SBBI2_SCK_AVRPORT == AVRPORTB)
-#define SBBI2_SCK_SOD_REG PORTB
-#define SBBI2_SCK_OE_REG  DDRB
-#elif (SBBI2_SCK_AVRPORT == AVRPORTD)
-#define SBBI2_SCK_SOD_REG PORTD
-#define SBBI2_SCK_OE_REG  DDRD
-#elif (SBBI2_SCK_AVRPORT == AVRPORTE)
-#define SBBI2_SCK_SOD_REG PORTE
-#define SBBI2_SCK_OE_REG  DDRE
-#elif (SBBI2_SCK_AVRPORT == AVRPORTF)
-#define SBBI2_SCK_SOD_REG PORTF
-#define SBBI2_SCK_OE_REG  DDRF
-#elif (SBBI2_SCK_AVRPORT == AVRPORTG)
-#define SBBI2_SCK_SOD_REG PORTG
-#define SBBI2_SCK_OE_REG  DDRG
-#elif (SBBI2_SCK_AVRPORT == AVRPORTH)
-#define SBBI2_SCK_SOD_REG PORTH
-#define SBBI2_SCK_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 clock output. */
-#define SBBI2_SCK_ENA()      sbi(SBBI2_SCK_OE_REG, SBBI2_SCK_BIT)
-/*! \brief Set SBBI2 clock output low. */
-#define SBBI2_SCK_CLR()      cbi(SBBI2_SCK_SOD_REG, SBBI2_SCK_BIT)
-/*! \brief Set SBBI2 clock output high. */
-#define SBBI2_SCK_SET()      sbi(SBBI2_SCK_SOD_REG, SBBI2_SCK_BIT)
-
-#if defined(SBBI2_MOSI_BIT)
-
-#if (SBBI2_MOSI_AVRPORT == AVRPORTB)
-#define SBBI2_MOSI_SOD_REG PORTB
-#define SBBI2_MOSI_OE_REG  DDRB
-#elif (SBBI2_MOSI_AVRPORT == AVRPORTD)
-#define SBBI2_MOSI_SOD_REG PORTD
-#define SBBI2_MOSI_OE_REG  DDRD
-#elif (SBBI2_MOSI_AVRPORT == AVRPORTE)
-#define SBBI2_MOSI_SOD_REG PORTE
-#define SBBI2_MOSI_OE_REG  DDRE
-#elif (SBBI2_MOSI_AVRPORT == AVRPORTF)
-#define SBBI2_MOSI_SOD_REG PORTF
-#define SBBI2_MOSI_OE_REG  DDRF
-#elif (SBBI2_MOSI_AVRPORT == AVRPORTG)
-#define SBBI2_MOSI_SOD_REG PORTG
-#define SBBI2_MOSI_OE_REG  DDRG
-#elif (SBBI2_MOSI_AVRPORT == AVRPORTH)
-#define SBBI2_MOSI_SOD_REG PORTH
-#define SBBI2_MOSI_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 data output. */
-#define SBBI2_MOSI_ENA()      sbi(SBBI2_MOSI_OE_REG, SBBI2_MOSI_BIT)
-/*! \brief Set SBBI2 data output low. */
-#define SBBI2_MOSI_CLR()      cbi(SBBI2_MOSI_SOD_REG, SBBI2_MOSI_BIT)
-/*! \brief Set SBBI2 data output high. */
-#define SBBI2_MOSI_SET()      sbi(SBBI2_MOSI_SOD_REG, SBBI2_MOSI_BIT)
-
-#else                           /* SBBI2_MOSI_BIT */
-
-#define SBBI2_MOSI_ENA()
-#define SBBI2_MOSI_CLR()
-#define SBBI2_MOSI_SET()
-
-#endif                          /* SBBI2_MOSI_BIT */
-
-#if defined(SBBI2_MISO_BIT)
-
-#if (SBBI2_MISO_AVRPORT == AVRPORTB)
-#define SBBI2_MISO_PDS_REG PINB
-#define SBBI2_MISO_PUE_REG PORTB
-#define SBBI2_MISO_OE_REG  DDRB
-#elif (SBBI2_MISO_AVRPORT == AVRPORTD)
-#define SBBI2_MISO_PDS_REG PIND
-#define SBBI2_MISO_PUE_REG PORTD
-#define SBBI2_MISO_OE_REG  DDRD
-#elif (SBBI2_MISO_AVRPORT == AVRPORTE)
-#define SBBI2_MISO_PDS_REG PINE
-#define SBBI2_MISO_PUE_REG PORTE
-#define SBBI2_MISO_OE_REG  DDRE
-#elif (SBBI2_MISO_AVRPORT == AVRPORTF)
-#define SBBI2_MISO_PDS_REG PINF
-#define SBBI2_MISO_PUE_REG PORTF
-#define SBBI2_MISO_OE_REG  DDRF
-#elif (SBBI2_MISO_AVRPORT == AVRPORTG)
-#define SBBI2_MISO_PDS_REG PING
-#define SBBI2_MISO_PUE_REG PORTG
-#define SBBI2_MISO_OE_REG  DDRG
-#elif (SBBI2_MISO_AVRPORT == AVRPORTH)
-#define SBBI2_MISO_PDS_REG PINH
-#define SBBI2_MISO_PUE_REG PORTH
-#define SBBI2_MISO_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI2 data input. */
-#define SBBI2_MISO_ENA() \
-    cbi(SBBI2_MISO_OE_REG, SBBI2_MISO_BIT); \
-    sbi(SBBI2_MISO_PUE_REG, SBBI2_MISO_BIT)
-/*! \brief Query SBBI2 data input. */
-#define SBBI2_MISO_TST()    ((inb(SBBI2_MISO_PDS_REG) & _BV(SBBI2_MISO_BIT)) == _BV(SBBI2_MISO_BIT))
-
-#else                           /* SBBI2_MISO_BIT */
-
-#define SBBI2_MISO_ENA()
-#define SBBI2_MISO_TST()   0
-
-#endif                          /* SBBI2_MISO_BIT */
-
-#endif                          /* SBBI2_SCK_BIT */
-
-#else                           /* MCU */
-/*
- * AT91 implementation.
- * ======================================
- */
-
-#ifdef SBBI2_CS0_BIT
-
-#if !defined(SBBI2_CS0_PIO_ID)
-#define SBBI2_CS0_PE_REG        PIO_PER
-#define SBBI2_CS0_OE_REG        PIO_OER
-#define SBBI2_CS0_COD_REG       PIO_CODR
-#define SBBI2_CS0_SOD_REG       PIO_SODR
-#elif SBBI2_CS0_PIO_ID == PIOA_ID
-#define SBBI2_CS0_PE_REG        PIOA_PER
-#define SBBI2_CS0_OE_REG        PIOA_OER
-#define SBBI2_CS0_COD_REG       PIOA_CODR
-#define SBBI2_CS0_SOD_REG       PIOA_SODR
-#elif SBBI2_CS0_PIO_ID == PIOB_ID
-#define SBBI2_CS0_PE_REG        PIOB_PER
-#define SBBI2_CS0_OE_REG        PIOB_OER
-#define SBBI2_CS0_COD_REG       PIOB_CODR
-#define SBBI2_CS0_SOD_REG       PIOB_SODR
-#elif SBBI2_CS0_PIO_ID == PIOC_ID
-#define SBBI2_CS0_PE_REG        PIOC_PER
-#define SBBI2_CS0_OE_REG        PIOC_OER
-#define SBBI2_CS0_COD_REG       PIOC_CODR
-#define SBBI2_CS0_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 chip select 0 output. */
-#define SBBI2_CS0_ENA() \
-    outr(SBBI2_CS0_PE_REG, _BV(SBBI2_CS0_BIT)); \
-    outr(SBBI2_CS0_OE_REG, _BV(SBBI2_CS0_BIT))
-/*! \brief Set SBBI2 chip select 0 output low. */
-#define SBBI2_CS0_CLR()   outr(SBBI2_CS0_COD_REG, _BV(SBBI2_CS0_BIT))
-/*! \brief Set SBBI2 chip select 0 output high. */
-#define SBBI2_CS0_SET()   outr(SBBI2_CS0_SOD_REG, _BV(SBBI2_CS0_BIT))
-
-#endif                          /* SBBI2_CS0_BIT */
-
-#ifdef SBBI2_CS1_BIT
-
-#if !defined(SBBI2_CS1_PIO_ID)
-#define SBBI2_CS1_PE_REG        PIO_PER
-#define SBBI2_CS1_OE_REG        PIO_OER
-#define SBBI2_CS1_COD_REG       PIO_CODR
-#define SBBI2_CS1_SOD_REG       PIO_SODR
-#elif SBBI2_CS1_PIO_ID == PIOA_ID
-#define SBBI2_CS1_PE_REG        PIOA_PER
-#define SBBI2_CS1_OE_REG        PIOA_OER
-#define SBBI2_CS1_COD_REG       PIOA_CODR
-#define SBBI2_CS1_SOD_REG       PIOA_SODR
-#elif SBBI2_CS1_PIO_ID == PIOB_ID
-#define SBBI2_CS1_PE_REG        PIOB_PER
-#define SBBI2_CS1_OE_REG        PIOB_OER
-#define SBBI2_CS1_COD_REG       PIOB_CODR
-#define SBBI2_CS1_SOD_REG       PIOB_SODR
-#elif SBBI2_CS1_PIO_ID == PIOC_ID
-#define SBBI2_CS1_PE_REG        PIOC_PER
-#define SBBI2_CS1_OE_REG        PIOC_OER
-#define SBBI2_CS1_COD_REG       PIOC_CODR
-#define SBBI2_CS1_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 chip select output. */
-#define SBBI2_CS1_ENA() \
-    outr(SBBI2_CS1_PE_REG, _BV(SBBI2_CS1_BIT)); \
-    outr(SBBI2_CS1_OE_REG, _BV(SBBI2_CS1_BIT))
-/*! \brief Set SBBI2 chip select output low. */
-#define SBBI2_CS1_CLR()   outr(SBBI2_CS1_COD_REG, _BV(SBBI2_CS1_BIT))
-/*! \brief Set SBBI2 chip select output high. */
-#define SBBI2_CS1_SET()   outr(SBBI2_CS1_SOD_REG, _BV(SBBI2_CS1_BIT))
-
-#endif                          /* SBBI2_CS1_BIT */
-
-#ifdef SBBI2_CS2_BIT
-
-#if !defined(SBBI2_CS2_PIO_ID)
-#define SBBI2_CS2_PE_REG        PIO_PER
-#define SBBI2_CS2_OE_REG        PIO_OER
-#define SBBI2_CS2_COD_REG       PIO_CODR
-#define SBBI2_CS2_SOD_REG       PIO_SODR
-#elif SBBI2_CS2_PIO_ID == PIOA_ID
-#define SBBI2_CS2_PE_REG        PIOA_PER
-#define SBBI2_CS2_OE_REG        PIOA_OER
-#define SBBI2_CS2_COD_REG       PIOA_CODR
-#define SBBI2_CS2_SOD_REG       PIOA_SODR
-#elif SBBI2_CS2_PIO_ID == PIOB_ID
-#define SBBI2_CS2_PE_REG        PIOB_PER
-#define SBBI2_CS2_OE_REG        PIOB_OER
-#define SBBI2_CS2_COD_REG       PIOB_CODR
-#define SBBI2_CS2_SOD_REG       PIOB_SODR
-#elif SBBI2_CS2_PIO_ID == PIOC_ID
-#define SBBI2_CS2_PE_REG        PIOC_PER
-#define SBBI2_CS2_OE_REG        PIOC_OER
-#define SBBI2_CS2_COD_REG       PIOC_CODR
-#define SBBI2_CS2_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 chip select output. */
-#define SBBI2_CS2_ENA() \
-    outr(SBBI2_CS2_PE_REG, _BV(SBBI2_CS2_BIT)); \
-    outr(SBBI2_CS2_OE_REG, _BV(SBBI2_CS2_BIT))
-/*! \brief Set SBBI2 chip select output low. */
-#define SBBI2_CS2_CLR()   outr(SBBI2_CS2_COD_REG, _BV(SBBI2_CS2_BIT))
-/*! \brief Set SBBI2 chip select output high. */
-#define SBBI2_CS2_SET()   outr(SBBI2_CS2_SOD_REG, _BV(SBBI2_CS2_BIT))
-
-#endif                          /* SBBI2_CS2_BIT */
-
-#ifdef SBBI2_CS3_BIT
-
-#if !defined(SBBI2_CS3_PIO_ID)
-#define SBBI2_CS3_PE_REG        PIO_PER
-#define SBBI2_CS3_OE_REG        PIO_OER
-#define SBBI2_CS3_COD_REG       PIO_CODR
-#define SBBI2_CS3_SOD_REG       PIO_SODR
-#elif SBBI2_CS3_PIO_ID == PIOA_ID
-#define SBBI2_CS3_PE_REG        PIOA_PER
-#define SBBI2_CS3_OE_REG        PIOA_OER
-#define SBBI2_CS3_COD_REG       PIOA_CODR
-#define SBBI2_CS3_SOD_REG       PIOA_SODR
-#elif SBBI2_CS3_PIO_ID == PIOB_ID
-#define SBBI2_CS3_PE_REG        PIOB_PER
-#define SBBI2_CS3_OE_REG        PIOB_OER
-#define SBBI2_CS3_COD_REG       PIOB_CODR
-#define SBBI2_CS3_SOD_REG       PIOB_SODR
-#elif SBBI2_CS3_PIO_ID == PIOC_ID
-#define SBBI2_CS3_PE_REG        PIOC_PER
-#define SBBI2_CS3_OE_REG        PIOC_OER
-#define SBBI2_CS3_COD_REG       PIOC_CODR
-#define SBBI2_CS3_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 chip select output. */
-#define SBBI2_CS3_ENA() \
-    outr(SBBI2_CS3_PE_REG, _BV(SBBI2_CS3_BIT)); \
-    outr(SBBI2_CS3_OE_REG, _BV(SBBI2_CS3_BIT))
-/*! \brief Set SBBI2 chip select output low. */
-#define SBBI2_CS3_CLR()   outr(SBBI2_CS3_COD_REG, _BV(SBBI2_CS3_BIT))
-/*! \brief Set SBBI2 chip select output high. */
-#define SBBI2_CS3_SET()   outr(SBBI2_CS3_SOD_REG, _BV(SBBI2_CS3_BIT))
-
-#endif                          /* SBBI2_CS3_BIT */
-
-#ifdef SBBI2_RST0_BIT
-
-#if !defined(SBBI2_RST0_PIO_ID)
-#define SBBI2_RST0_PE_REG      PIO_PER
-#define SBBI2_RST0_OE_REG      PIO_OER
-#define SBBI2_RST0_COD_REG     PIO_CODR
-#define SBBI2_RST0_SOD_REG     PIO_SODR
-#elif SBBI2_RST0_PIO_ID == PIOA_ID
-#define SBBI2_RST0_PE_REG      PIOA_PER
-#define SBBI2_RST0_OE_REG      PIOA_OER
-#define SBBI2_RST0_COD_REG     PIOA_CODR
-#define SBBI2_RST0_SOD_REG     PIOA_SODR
-#elif SBBI2_RST0_PIO_ID == PIOB_ID
-#define SBBI2_RST0_PE_REG      PIOB_PER
-#define SBBI2_RST0_OE_REG      PIOB_OER
-#define SBBI2_RST0_COD_REG     PIOB_CODR
-#define SBBI2_RST0_SOD_REG     PIOB_SODR
-#elif SBBI2_RST0_PIO_ID == PIOC_ID
-#define SBBI2_RST0_PE_REG      PIOC_PER
-#define SBBI2_RST0_OE_REG      PIOC_OER
-#define SBBI2_RST0_COD_REG     PIOC_CODR
-#define SBBI2_RST0_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 reset output. */
-#define SBBI2_RST0_ENA() \
-    outr(SBBI2_RST0_PE_REG, _BV(SBBI2_RST0_BIT)); \
-    outr(SBBI2_RST0_OE_REG, _BV(SBBI2_RST0_BIT))
-/*! \brief Set SBBI2 reset output low. */
-#define SBBI2_RST0_CLR()   outr(SBBI2_RST0_COD_REG, _BV(SBBI2_RST0_BIT))
-/*! \brief Set SBBI2 reset output high. */
-#define SBBI2_RST0_SET()   outr(SBBI2_RST0_SOD_REG, _BV(SBBI2_RST0_BIT))
-
-#endif                          /* SBBI2_RST0_BIT */
-
-#ifdef SBBI2_RST1_BIT
-
-#if !defined(SBBI2_RST1_PIO_ID)
-#define SBBI2_RST1_PE_REG      PIO_PER
-#define SBBI2_RST1_OE_REG      PIO_OER
-#define SBBI2_RST1_COD_REG     PIO_CODR
-#define SBBI2_RST1_SOD_REG     PIO_SODR
-#elif SBBI2_RST1_PIO_ID == PIOA_ID
-#define SBBI2_RST1_PE_REG      PIOA_PER
-#define SBBI2_RST1_OE_REG      PIOA_OER
-#define SBBI2_RST1_COD_REG     PIOA_CODR
-#define SBBI2_RST1_SOD_REG     PIOA_SODR
-#elif SBBI2_RST1_PIO_ID == PIOB_ID
-#define SBBI2_RST1_PE_REG      PIOB_PER
-#define SBBI2_RST1_OE_REG      PIOB_OER
-#define SBBI2_RST1_COD_REG     PIOB_CODR
-#define SBBI2_RST1_SOD_REG     PIOB_SODR
-#elif SBBI2_RST1_PIO_ID == PIOC_ID
-#define SBBI2_RST1_PE_REG      PIOC_PER
-#define SBBI2_RST1_OE_REG      PIOC_OER
-#define SBBI2_RST1_COD_REG     PIOC_CODR
-#define SBBI2_RST1_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 reset output. */
-#define SBBI2_RST1_ENA() \
-    outr(SBBI2_RST1_PE_REG, _BV(SBBI2_RST1_BIT)); \
-    outr(SBBI2_RST1_OE_REG, _BV(SBBI2_RST1_BIT))
-/*! \brief Set SBBI2 reset output low. */
-#define SBBI2_RST1_CLR()   outr(SBBI2_RST1_COD_REG, _BV(SBBI2_RST1_BIT))
-/*! \brief Set SBBI2 reset output high. */
-#define SBBI2_RST1_SET()   outr(SBBI2_RST1_SOD_REG, _BV(SBBI2_RST1_BIT))
-
-#endif                          /* SBBI2_RST1_BIT */
-
-#ifdef SBBI2_RST2_BIT
-
-#if !defined(SBBI2_RST2_PIO_ID)
-#define SBBI2_RST2_PE_REG      PIO_PER
-#define SBBI2_RST2_OE_REG      PIO_OER
-#define SBBI2_RST2_COD_REG     PIO_CODR
-#define SBBI2_RST2_SOD_REG     PIO_SODR
-#elif SBBI2_RST2_PIO_ID == PIOA_ID
-#define SBBI2_RST2_PE_REG      PIOA_PER
-#define SBBI2_RST2_OE_REG      PIOA_OER
-#define SBBI2_RST2_COD_REG     PIOA_CODR
-#define SBBI2_RST2_SOD_REG     PIOA_SODR
-#elif SBBI2_RST2_PIO_ID == PIOB_ID
-#define SBBI2_RST2_PE_REG      PIOB_PER
-#define SBBI2_RST2_OE_REG      PIOB_OER
-#define SBBI2_RST2_COD_REG     PIOB_CODR
-#define SBBI2_RST2_SOD_REG     PIOB_SODR
-#elif SBBI2_RST2_PIO_ID == PIOC_ID
-#define SBBI2_RST2_PE_REG      PIOC_PER
-#define SBBI2_RST2_OE_REG      PIOC_OER
-#define SBBI2_RST2_COD_REG     PIOC_CODR
-#define SBBI2_RST2_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 reset output. */
-#define SBBI2_RST2_ENA() \
-    outr(SBBI2_RST2_PE_REG, _BV(SBBI2_RST2_BIT)); \
-    outr(SBBI2_RST2_OE_REG, _BV(SBBI2_RST2_BIT))
-/*! \brief Set SBBI2 reset output low. */
-#define SBBI2_RST2_CLR()   outr(SBBI2_RST2_COD_REG, _BV(SBBI2_RST2_BIT))
-/*! \brief Set SBBI2 reset output high. */
-#define SBBI2_RST2_SET()   outr(SBBI2_RST2_SOD_REG, _BV(SBBI2_RST2_BIT))
-
-#endif                          /* SBBI2_RST2_BIT */
-
-#ifdef SBBI2_RST3_BIT
-
-#if !defined(SBBI2_RST3_PIO_ID)
-#define SBBI2_RST3_PE_REG      PIO_PER
-#define SBBI2_RST3_OE_REG      PIO_OER
-#define SBBI2_RST3_COD_REG     PIO_CODR
-#define SBBI2_RST3_SOD_REG     PIO_SODR
-#elif SBBI2_RST3_PIO_ID == PIOA_ID
-#define SBBI2_RST3_PE_REG      PIOA_PER
-#define SBBI2_RST3_OE_REG      PIOA_OER
-#define SBBI2_RST3_COD_REG     PIOA_CODR
-#define SBBI2_RST3_SOD_REG     PIOA_SODR
-#elif SBBI2_RST3_PIO_ID == PIOB_ID
-#define SBBI2_RST3_PE_REG      PIOB_PER
-#define SBBI2_RST3_OE_REG      PIOB_OER
-#define SBBI2_RST3_COD_REG     PIOB_CODR
-#define SBBI2_RST3_SOD_REG     PIOB_SODR
-#elif SBBI2_RST3_PIO_ID == PIOC_ID
-#define SBBI2_RST3_PE_REG      PIOC_PER
-#define SBBI2_RST3_OE_REG      PIOC_OER
-#define SBBI2_RST3_COD_REG     PIOC_CODR
-#define SBBI2_RST3_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 reset output. */
-#define SBBI2_RST3_ENA() \
-    outr(SBBI2_RST3_PE_REG, _BV(SBBI2_RST3_BIT)); \
-    outr(SBBI2_RST3_OE_REG, _BV(SBBI2_RST3_BIT))
-/*! \brief Set SBBI2 reset output low. */
-#define SBBI2_RST3_CLR()   outr(SBBI2_RST3_COD_REG, _BV(SBBI2_RST3_BIT))
-/*! \brief Set SBBI2 reset output high. */
-#define SBBI2_RST3_SET()   outr(SBBI2_RST3_SOD_REG, _BV(SBBI2_RST3_BIT))
-
-#endif                          /* SBBI2_RST3_BIT */
-
-#ifdef SBBI2_SCK_BIT
-
-#if !defined(SBBI2_SCK_PIO_ID)
-#define SBBI2_SCK_PE_REG        PIO_PER
-#define SBBI2_SCK_OE_REG        PIO_OER
-#define SBBI2_SCK_COD_REG       PIO_CODR
-#define SBBI2_SCK_SOD_REG       PIO_SODR
-#elif SBBI2_SCK_PIO_ID == PIOA_ID
-#define SBBI2_SCK_PE_REG        PIOA_PER
-#define SBBI2_SCK_OE_REG        PIOA_OER
-#define SBBI2_SCK_COD_REG       PIOA_CODR
-#define SBBI2_SCK_SOD_REG       PIOA_SODR
-#elif SBBI2_SCK_PIO_ID == PIOB_ID
-#define SBBI2_SCK_PE_REG        PIOB_PER
-#define SBBI2_SCK_OE_REG        PIOB_OER
-#define SBBI2_SCK_COD_REG       PIOB_CODR
-#define SBBI2_SCK_SOD_REG       PIOB_SODR
-#elif SBBI2_SCK_PIO_ID == PIOC_ID
-#define SBBI2_SCK_PE_REG        PIOC_PER
-#define SBBI2_SCK_OE_REG        PIOC_OER
-#define SBBI2_SCK_COD_REG       PIOC_CODR
-#define SBBI2_SCK_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 clock output. */
-#define SBBI2_SCK_ENA() \
-    outr(SBBI2_SCK_PE_REG, _BV(SBBI2_SCK_BIT)); \
-    outr(SBBI2_SCK_OE_REG, _BV(SBBI2_SCK_BIT))
-/*! \brief Set SBBI2 clock output low. */
-#define SBBI2_SCK_CLR()     outr(SBBI2_SCK_COD_REG, _BV(SBBI2_SCK_BIT))
-/*! \brief Set SBBI2 clock output high. */
-#define SBBI2_SCK_SET()     outr(SBBI2_SCK_SOD_REG, _BV(SBBI2_SCK_BIT))
-
-#ifdef SBBI2_MOSI_BIT
-
-#if !defined(SBBI2_MOSI_PIO_ID)
-#define SBBI2_MOSI_PE_REG       PIO_PER
-#define SBBI2_MOSI_OE_REG       PIO_OER
-#define SBBI2_MOSI_COD_REG      PIO_CODR
-#define SBBI2_MOSI_SOD_REG      PIO_SODR
-#elif SBBI2_MOSI_PIO_ID == PIOA_ID
-#define SBBI2_MOSI_PE_REG       PIOA_PER
-#define SBBI2_MOSI_OE_REG       PIOA_OER
-#define SBBI2_MOSI_COD_REG      PIOA_CODR
-#define SBBI2_MOSI_SOD_REG      PIOA_SODR
-#elif SBBI2_MOSI_PIO_ID == PIOB_ID
-#define SBBI2_MOSI_PE_REG       PIOB_PER
-#define SBBI2_MOSI_OE_REG       PIOB_OER
-#define SBBI2_MOSI_COD_REG      PIOB_CODR
-#define SBBI2_MOSI_SOD_REG      PIOB_SODR
-#elif SBBI2_MOSI_PIO_ID == PIOC_ID
-#define SBBI2_MOSI_PE_REG       PIOC_PER
-#define SBBI2_MOSI_OE_REG       PIOC_OER
-#define SBBI2_MOSI_COD_REG      PIOC_CODR
-#define SBBI2_MOSI_SOD_REG      PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI2 data output. */
-#define SBBI2_MOSI_ENA() \
-    outr(SBBI2_MOSI_PE_REG, _BV(SBBI2_MOSI_BIT)); \
-    outr(SBBI2_MOSI_OE_REG, _BV(SBBI2_MOSI_BIT))
-/*! \brief Set SBBI2 data output low. */
-#define SBBI2_MOSI_CLR()    outr(SBBI2_MOSI_COD_REG, _BV(SBBI2_MOSI_BIT))
-/*! \brief Set SBBI2 data output high. */
-#define SBBI2_MOSI_SET()    outr(SBBI2_MOSI_SOD_REG, _BV(SBBI2_MOSI_BIT))
-
-#else                           /* SBBI2_MOSI_BIT */
-
-#define SBBI2_MOSI_ENA()
-#define SBBI2_MOSI_CLR()
-#define SBBI2_MOSI_SET()
-
-#endif                          /* SBBI2_MOSI_BIT */
-
-#ifdef SBBI2_MISO_BIT
-
-#if !defined(SBBI2_MISO_PIO_ID)
-#define SBBI2_MISO_PE_REG       PIO_PER
-#define SBBI2_MISO_OD_REG       PIO_ODR
-#define SBBI2_MISO_PDS_REG      PIO_PDSR
-#elif SBBI2_MISO_PIO_ID == PIOA_ID
-#define SBBI2_MISO_PE_REG       PIOA_PER
-#define SBBI2_MISO_OD_REG       PIOA_ODR
-#define SBBI2_MISO_PDS_REG      PIOA_PDSR
-#elif SBBI2_MISO_PIO_ID == PIOB_ID
-#define SBBI2_MISO_PE_REG       PIOB_PER
-#define SBBI2_MISO_OD_REG       PIOB_ODR
-#define SBBI2_MISO_PDS_REG      PIOB_PDSR
-#elif SBBI2_MISO_PIO_ID == PIOC_ID
-#define SBBI2_MISO_PE_REG       PIOC_PER
-#define SBBI2_MISO_OD_REG       PIOC_ODR
-#define SBBI2_MISO_PDS_REG      PIOC_PDSR
-#endif
-
-/*! \brief Enable SBBI2 data input. */
-#define SBBI2_MISO_ENA() \
-    outr(SBBI2_MISO_PE_REG, _BV(SBBI2_MISO_BIT)); \
-    outr(SBBI2_MISO_OD_REG, _BV(SBBI2_MISO_BIT))
-/*! \brief Query SBBI2 data input. */
-#define SBBI2_MISO_TST()    ((inr(SBBI2_MISO_PDS_REG) & _BV(SBBI2_MISO_BIT)) == _BV(SBBI2_MISO_BIT))
-
-#else                           /* SBBI2_MISO_BIT */
-
-#define SBBI2_MISO_ENA()
-#define SBBI2_MISO_TST()   0
-
-#endif                          /* SBBI2_MISO_BIT */
-
-#endif                          /* SBBI2_SCK_BIT */
-
-#endif                          /* MCU */
-
-#define SBBI2_INIT() \
-{ \
-    SBBI2_SCK_CLR(); \
-    SBBI2_SCK_ENA(); \
-    SBBI2_MOSI_CLR(); \
-    SBBI2_MOSI_ENA(); \
-    SBBI2_MISO_ENA(); \
-}
-
-#endif

+ 0 - 829
include/dev/sbbif3.h

@@ -1,829 +0,0 @@
-#ifndef _DEV_SBBIF3_H_
-#define _DEV_SBBIF3_H_
-/*
- * Copyright (C) 2007 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file dev/sbbi3.h
- * \brief Serial bit banged interface 3.
- *
- * \verbatim
- *
- * $Log: sbbif3.h,v $
- * Revision 1.1  2007/04/12 09:07:54  haraldkipp
- * Configurable SPI added.
- *
- *
- * \endverbatim
- */
-
-#include <cfg/arch/gpio.h>
-
-/*!
- * \brief Maximum number of devices (chip selects).
- */
-#ifndef SBBI3_MAX_DEVICES
-#define SBBI3_MAX_DEVICES   4
-#endif
-
-#if defined(__AVR__)            /* MCU */
-/*
- * AVR implementation.
- * ======================================
- */
-
-#ifdef SBBI3_CS0_BIT
-
-#if (SBBI3_CS0_AVRPORT == AVRPORTB)
-#define SBBI3_CS0_SOD_REG PORTB
-#define SBBI3_CS0_OE_REG  DDRB
-#elif (SBBI3_CS0_AVRPORT == AVRPORTD)
-#define SBBI3_CS0_SOD_REG PORTD
-#define SBBI3_CS0_OE_REG  DDRD
-#elif (SBBI3_CS0_AVRPORT == AVRPORTE)
-#define SBBI3_CS0_SOD_REG PORTE
-#define SBBI3_CS0_OE_REG  DDRE
-#elif (SBBI3_CS0_AVRPORT == AVRPORTF)
-#define SBBI3_CS0_SOD_REG PORTF
-#define SBBI3_CS0_OE_REG  DDRF
-#elif (SBBI3_CS0_AVRPORT == AVRPORTG)
-#define SBBI3_CS0_SOD_REG PORTG
-#define SBBI3_CS0_OE_REG  DDRG
-#elif (SBBI3_CS0_AVRPORT == AVRPORTH)
-#define SBBI3_CS0_SOD_REG PORTH
-#define SBBI3_CS0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 chip select 0 output. */
-#define SBBI3_CS0_ENA()      sbi(SBBI3_CS0_OE_REG, SBBI3_CS0_BIT)
-/*! \brief Set SBBI3 chip select 0 output low. */
-#define SBBI3_CS0_CLR()      cbi(SBBI3_CS0_SOD_REG, SBBI3_CS0_BIT)
-/*! \brief Set SBBI3 chip select 0 output high. */
-#define SBBI3_CS0_SET()      sbi(SBBI3_CS0_SOD_REG, SBBI3_CS0_BIT)
-
-#endif                          /* SBBI3_CS0_BIT */
-
-#ifdef SBBI3_CS1_BIT
-
-#if (SBBI3_CS1_AVRPORT == AVRPORTB)
-#define SBBI3_CS1_SOD_REG PORTB
-#define SBBI3_CS1_OE_REG  DDRB
-#elif (SBBI3_CS1_AVRPORT == AVRPORTD)
-#define SBBI3_CS1_SOD_REG PORTD
-#define SBBI3_CS1_OE_REG  DDRD
-#elif (SBBI3_CS1_AVRPORT == AVRPORTE)
-#define SBBI3_CS1_SOD_REG PORTE
-#define SBBI3_CS1_OE_REG  DDRE
-#elif (SBBI3_CS1_AVRPORT == AVRPORTF)
-#define SBBI3_CS1_SOD_REG PORTF
-#define SBBI3_CS1_OE_REG  DDRF
-#elif (SBBI3_CS1_AVRPORT == AVRPORTG)
-#define SBBI3_CS1_SOD_REG PORTG
-#define SBBI3_CS1_OE_REG  DDRG
-#elif (SBBI3_CS1_AVRPORT == AVRPORTH)
-#define SBBI3_CS1_SOD_REG PORTH
-#define SBBI3_CS1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 chip select 1 output. */
-#define SBBI3_CS1_ENA()      sbi(SBBI3_CS1_OE_REG, SBBI3_CS1_BIT)
-/*! \brief Set SBBI3 chip select 1 output low. */
-#define SBBI3_CS1_CLR()      cbi(SBBI3_CS1_SOD_REG, SBBI3_CS1_BIT)
-/*! \brief Set SBBI3 chip select 1 output high. */
-#define SBBI3_CS1_SET()      sbi(SBBI3_CS1_SOD_REG, SBBI3_CS1_BIT)
-
-#endif                          /* SBBI3_CS1_BIT */
-
-#ifdef SBBI3_CS2_BIT
-
-#if (SBBI3_CS2_AVRPORT == AVRPORTB)
-#define SBBI3_CS2_SOD_REG PORTB
-#define SBBI3_CS2_OE_REG  DDRB
-#elif (SBBI3_CS2_AVRPORT == AVRPORTD)
-#define SBBI3_CS2_SOD_REG PORTD
-#define SBBI3_CS2_OE_REG  DDRD
-#elif (SBBI3_CS2_AVRPORT == AVRPORTE)
-#define SBBI3_CS2_SOD_REG PORTE
-#define SBBI3_CS2_OE_REG  DDRE
-#elif (SBBI3_CS2_AVRPORT == AVRPORTF)
-#define SBBI3_CS2_SOD_REG PORTF
-#define SBBI3_CS2_OE_REG  DDRF
-#elif (SBBI3_CS2_AVRPORT == AVRPORTG)
-#define SBBI3_CS2_SOD_REG PORTG
-#define SBBI3_CS2_OE_REG  DDRG
-#elif (SBBI3_CS2_AVRPORT == AVRPORTH)
-#define SBBI3_CS2_SOD_REG PORTH
-#define SBBI3_CS2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 chip select 2 output. */
-#define SBBI3_CS2_ENA()      sbi(SBBI3_CS2_OE_REG, SBBI3_CS2_BIT)
-/*! \brief Set SBBI3 chip select 2 output low. */
-#define SBBI3_CS2_CLR()      cbi(SBBI3_CS2_SOD_REG, SBBI3_CS2_BIT)
-/*! \brief Set SBBI3 chip select 2 output high. */
-#define SBBI3_CS2_SET()      sbi(SBBI3_CS2_SOD_REG, SBBI3_CS2_BIT)
-
-#endif                          /* SBBI3_CS2_BIT */
-
-#ifdef SBBI3_CS3_BIT
-
-#if (SBBI3_CS3_AVRPORT == AVRPORTB)
-#define SBBI3_CS3_SOD_REG PORTB
-#define SBBI3_CS3_OE_REG  DDRB
-#elif (SBBI3_CS3_AVRPORT == AVRPORTD)
-#define SBBI3_CS3_SOD_REG PORTD
-#define SBBI3_CS3_OE_REG  DDRD
-#elif (SBBI3_CS3_AVRPORT == AVRPORTE)
-#define SBBI3_CS3_SOD_REG PORTE
-#define SBBI3_CS3_OE_REG  DDRE
-#elif (SBBI3_CS3_AVRPORT == AVRPORTF)
-#define SBBI3_CS3_SOD_REG PORTF
-#define SBBI3_CS3_OE_REG  DDRF
-#elif (SBBI3_CS3_AVRPORT == AVRPORTG)
-#define SBBI3_CS3_SOD_REG PORTG
-#define SBBI3_CS3_OE_REG  DDRG
-#elif (SBBI3_CS3_AVRPORT == AVRPORTH)
-#define SBBI3_CS3_SOD_REG PORTH
-#define SBBI3_CS3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 chip select 3 output. */
-#define SBBI3_CS3_ENA()      sbi(SBBI3_CS3_OE_REG, SBBI3_CS3_BIT)
-/*! \brief Set SBBI3 chip select 3 output low. */
-#define SBBI3_CS3_CLR()      cbi(SBBI3_CS3_SOD_REG, SBBI3_CS3_BIT)
-/*! \brief Set SBBI3 chip select 3 output high. */
-#define SBBI3_CS3_SET()      sbi(SBBI3_CS3_SOD_REG, SBBI3_CS3_BIT)
-
-#endif                          /* SBBI3_CS3_BIT */
-
-#ifdef SBBI3_RST0_BIT
-
-#if (SBBI3_RST0_AVRPORT == AVRPORTB)
-#define SBBI3_RST0_SOD_REG PORTB
-#define SBBI3_RST0_OE_REG  DDRB
-#elif (SBBI3_RST0_AVRPORT == AVRPORTD)
-#define SBBI3_RST0_SOD_REG PORTD
-#define SBBI3_RST0_OE_REG  DDRD
-#elif (SBBI3_RST0_AVRPORT == AVRPORTE)
-#define SBBI3_RST0_SOD_REG PORTE
-#define SBBI3_RST0_OE_REG  DDRE
-#elif (SBBI3_RST0_AVRPORT == AVRPORTF)
-#define SBBI3_RST0_SOD_REG PORTF
-#define SBBI3_RST0_OE_REG  DDRF
-#elif (SBBI3_RST0_AVRPORT == AVRPORTG)
-#define SBBI3_RST0_SOD_REG PORTG
-#define SBBI3_RST0_OE_REG  DDRG
-#elif (SBBI3_RST0_AVRPORT == AVRPORTH)
-#define SBBI3_RST0_SOD_REG PORTH
-#define SBBI3_RST0_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 reset 0 output. */
-#define SBBI3_RST0_ENA()      sbi(SBBI3_RST0_OE_REG, SBBI3_RST0_BIT)
-/*! \brief Set SBBI3 reset 0 output low. */
-#define SBBI3_RST0_CLR()      cbi(SBBI3_RST0_SOD_REG, SBBI3_RST0_BIT)
-/*! \brief Set SBBI3 reset 0 output high. */
-#define SBBI3_RST0_SET()      sbi(SBBI3_RST0_SOD_REG, SBBI3_RST0_BIT)
-
-#endif                          /* SBBI3_RST0_BIT */
-
-#ifdef SBBI3_RST1_BIT
-
-#if (SBBI3_RST1_AVRPORT == AVRPORTB)
-#define SBBI3_RST1_SOD_REG PORTB
-#define SBBI3_RST1_OE_REG  DDRB
-#elif (SBBI3_RST1_AVRPORT == AVRPORTD)
-#define SBBI3_RST1_SOD_REG PORTD
-#define SBBI3_RST1_OE_REG  DDRD
-#elif (SBBI3_RST1_AVRPORT == AVRPORTE)
-#define SBBI3_RST1_SOD_REG PORTE
-#define SBBI3_RST1_OE_REG  DDRE
-#elif (SBBI3_RST1_AVRPORT == AVRPORTF)
-#define SBBI3_RST1_SOD_REG PORTF
-#define SBBI3_RST1_OE_REG  DDRF
-#elif (SBBI3_RST1_AVRPORT == AVRPORTG)
-#define SBBI3_RST1_SOD_REG PORTG
-#define SBBI3_RST1_OE_REG  DDRG
-#elif (SBBI3_RST1_AVRPORT == AVRPORTH)
-#define SBBI3_RST1_SOD_REG PORTH
-#define SBBI3_RST1_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 reset 1 output. */
-#define SBBI3_RST1_ENA()      sbi(SBBI3_RST1_OE_REG, SBBI3_RST1_BIT)
-/*! \brief Set SBBI3 reset 1 output low. */
-#define SBBI3_RST1_CLR()      cbi(SBBI3_RST1_SOD_REG, SBBI3_RST1_BIT)
-/*! \brief Set SBBI3 reset 1 output high. */
-#define SBBI3_RST1_SET()      sbi(SBBI3_RST1_SOD_REG, SBBI3_RST1_BIT)
-
-#endif                          /* SBBI3_RST1_BIT */
-
-#ifdef SBBI3_RST2_BIT
-
-#if (SBBI3_RST2_AVRPORT == AVRPORTB)
-#define SBBI3_RST2_SOD_REG PORTB
-#define SBBI3_RST2_OE_REG  DDRB
-#elif (SBBI3_RST2_AVRPORT == AVRPORTD)
-#define SBBI3_RST2_SOD_REG PORTD
-#define SBBI3_RST2_OE_REG  DDRD
-#elif (SBBI3_RST2_AVRPORT == AVRPORTE)
-#define SBBI3_RST2_SOD_REG PORTE
-#define SBBI3_RST2_OE_REG  DDRE
-#elif (SBBI3_RST2_AVRPORT == AVRPORTF)
-#define SBBI3_RST2_SOD_REG PORTF
-#define SBBI3_RST2_OE_REG  DDRF
-#elif (SBBI3_RST2_AVRPORT == AVRPORTG)
-#define SBBI3_RST2_SOD_REG PORTG
-#define SBBI3_RST2_OE_REG  DDRG
-#elif (SBBI3_RST2_AVRPORT == AVRPORTH)
-#define SBBI3_RST2_SOD_REG PORTH
-#define SBBI3_RST2_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 reset 2 output. */
-#define SBBI3_RST2_ENA()      sbi(SBBI3_RST2_OE_REG, SBBI3_RST2_BIT)
-/*! \brief Set SBBI3 chip reset 2 output low. */
-#define SBBI3_RST2_CLR()      cbi(SBBI3_RST2_SOD_REG, SBBI3_RST2_BIT)
-/*! \brief Set SBBI3 chip reset 2 output high. */
-#define SBBI3_RST2_SET()      sbi(SBBI3_RST2_SOD_REG, SBBI3_RST2_BIT)
-
-#endif                          /* SBBI3_RST2_BIT */
-
-#ifdef SBBI3_RST3_BIT
-
-#if (SBBI3_RST3_AVRPORT == AVRPORTB)
-#define SBBI3_RST3_SOD_REG PORTB
-#define SBBI3_RST3_OE_REG  DDRB
-#elif (SBBI3_RST3_AVRPORT == AVRPORTD)
-#define SBBI3_RST3_SOD_REG PORTD
-#define SBBI3_RST3_OE_REG  DDRD
-#elif (SBBI3_RST3_AVRPORT == AVRPORTE)
-#define SBBI3_RST3_SOD_REG PORTE
-#define SBBI3_RST3_OE_REG  DDRE
-#elif (SBBI3_RST3_AVRPORT == AVRPORTF)
-#define SBBI3_RST3_SOD_REG PORTF
-#define SBBI3_RST3_OE_REG  DDRF
-#elif (SBBI3_RST3_AVRPORT == AVRPORTG)
-#define SBBI3_RST3_SOD_REG PORTG
-#define SBBI3_RST3_OE_REG  DDRG
-#elif (SBBI3_RST3_AVRPORT == AVRPORTH)
-#define SBBI3_RST3_SOD_REG PORTH
-#define SBBI3_RST3_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 reset 3 output. */
-#define SBBI3_RST3_ENA()      sbi(SBBI3_RST3_OE_REG, SBBI3_RST3_BIT)
-/*! \brief Set SBBI3 reset 3 output low. */
-#define SBBI3_RST3_CLR()      cbi(SBBI3_RST3_SOD_REG, SBBI3_RST3_BIT)
-/*! \brief Set SBBI3 reset 3 output high. */
-#define SBBI3_RST3_SET()      sbi(SBBI3_RST3_SOD_REG, SBBI3_RST3_BIT)
-
-#endif                          /* SBBI3_RST3_BIT */
-
-#ifdef SBBI3_SCK_BIT
-
-#if (SBBI3_SCK_AVRPORT == AVRPORTB)
-#define SBBI3_SCK_SOD_REG PORTB
-#define SBBI3_SCK_OE_REG  DDRB
-#elif (SBBI3_SCK_AVRPORT == AVRPORTD)
-#define SBBI3_SCK_SOD_REG PORTD
-#define SBBI3_SCK_OE_REG  DDRD
-#elif (SBBI3_SCK_AVRPORT == AVRPORTE)
-#define SBBI3_SCK_SOD_REG PORTE
-#define SBBI3_SCK_OE_REG  DDRE
-#elif (SBBI3_SCK_AVRPORT == AVRPORTF)
-#define SBBI3_SCK_SOD_REG PORTF
-#define SBBI3_SCK_OE_REG  DDRF
-#elif (SBBI3_SCK_AVRPORT == AVRPORTG)
-#define SBBI3_SCK_SOD_REG PORTG
-#define SBBI3_SCK_OE_REG  DDRG
-#elif (SBBI3_SCK_AVRPORT == AVRPORTH)
-#define SBBI3_SCK_SOD_REG PORTH
-#define SBBI3_SCK_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 clock output. */
-#define SBBI3_SCK_ENA()      sbi(SBBI3_SCK_OE_REG, SBBI3_SCK_BIT)
-/*! \brief Set SBBI3 clock output low. */
-#define SBBI3_SCK_CLR()      cbi(SBBI3_SCK_SOD_REG, SBBI3_SCK_BIT)
-/*! \brief Set SBBI3 clock output high. */
-#define SBBI3_SCK_SET()      sbi(SBBI3_SCK_SOD_REG, SBBI3_SCK_BIT)
-
-#if defined(SBBI3_MOSI_BIT)
-
-#if (SBBI3_MOSI_AVRPORT == AVRPORTB)
-#define SBBI3_MOSI_SOD_REG PORTB
-#define SBBI3_MOSI_OE_REG  DDRB
-#elif (SBBI3_MOSI_AVRPORT == AVRPORTD)
-#define SBBI3_MOSI_SOD_REG PORTD
-#define SBBI3_MOSI_OE_REG  DDRD
-#elif (SBBI3_MOSI_AVRPORT == AVRPORTE)
-#define SBBI3_MOSI_SOD_REG PORTE
-#define SBBI3_MOSI_OE_REG  DDRE
-#elif (SBBI3_MOSI_AVRPORT == AVRPORTF)
-#define SBBI3_MOSI_SOD_REG PORTF
-#define SBBI3_MOSI_OE_REG  DDRF
-#elif (SBBI3_MOSI_AVRPORT == AVRPORTG)
-#define SBBI3_MOSI_SOD_REG PORTG
-#define SBBI3_MOSI_OE_REG  DDRG
-#elif (SBBI3_MOSI_AVRPORT == AVRPORTH)
-#define SBBI3_MOSI_SOD_REG PORTH
-#define SBBI3_MOSI_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 data output. */
-#define SBBI3_MOSI_ENA()      sbi(SBBI3_MOSI_OE_REG, SBBI3_MOSI_BIT)
-/*! \brief Set SBBI3 data output low. */
-#define SBBI3_MOSI_CLR()      cbi(SBBI3_MOSI_SOD_REG, SBBI3_MOSI_BIT)
-/*! \brief Set SBBI3 data output high. */
-#define SBBI3_MOSI_SET()      sbi(SBBI3_MOSI_SOD_REG, SBBI3_MOSI_BIT)
-
-#else                           /* SBBI3_MOSI_BIT */
-
-#define SBBI3_MOSI_ENA()
-#define SBBI3_MOSI_CLR()
-#define SBBI3_MOSI_SET()
-
-#endif                          /* SBBI3_MOSI_BIT */
-
-#if defined(SBBI3_MISO_BIT)
-
-#if (SBBI3_MISO_AVRPORT == AVRPORTB)
-#define SBBI3_MISO_PDS_REG PINB
-#define SBBI3_MISO_PUE_REG PORTB
-#define SBBI3_MISO_OE_REG  DDRB
-#elif (SBBI3_MISO_AVRPORT == AVRPORTD)
-#define SBBI3_MISO_PDS_REG PIND
-#define SBBI3_MISO_PUE_REG PORTD
-#define SBBI3_MISO_OE_REG  DDRD
-#elif (SBBI3_MISO_AVRPORT == AVRPORTE)
-#define SBBI3_MISO_PDS_REG PINE
-#define SBBI3_MISO_PUE_REG PORTE
-#define SBBI3_MISO_OE_REG  DDRE
-#elif (SBBI3_MISO_AVRPORT == AVRPORTF)
-#define SBBI3_MISO_PDS_REG PINF
-#define SBBI3_MISO_PUE_REG PORTF
-#define SBBI3_MISO_OE_REG  DDRF
-#elif (SBBI3_MISO_AVRPORT == AVRPORTG)
-#define SBBI3_MISO_PDS_REG PING
-#define SBBI3_MISO_PUE_REG PORTG
-#define SBBI3_MISO_OE_REG  DDRG
-#elif (SBBI3_MISO_AVRPORT == AVRPORTH)
-#define SBBI3_MISO_PDS_REG PINH
-#define SBBI3_MISO_PUE_REG PORTH
-#define SBBI3_MISO_OE_REG  DDRH
-#endif
-
-/*! \brief Enable SBBI3 data input. */
-#define SBBI3_MISO_ENA() \
-    cbi(SBBI3_MISO_OE_REG, SBBI3_MISO_BIT); \
-    sbi(SBBI3_MISO_PUE_REG, SBBI3_MISO_BIT)
-/*! \brief Query SBBI3 data input. */
-#define SBBI3_MISO_TST()    ((inb(SBBI3_MISO_PDS_REG) & _BV(SBBI3_MISO_BIT)) == _BV(SBBI3_MISO_BIT))
-
-#else                           /* SBBI3_MISO_BIT */
-
-#define SBBI3_MISO_ENA()
-#define SBBI3_MISO_TST()   0
-
-#endif                          /* SBBI3_MISO_BIT */
-
-#endif                          /* SBBI3_SCK_BIT */
-
-#else                           /* MCU */
-/*
- * AT91 implementation.
- * ======================================
- */
-
-#ifdef SBBI3_CS0_BIT
-
-#if !defined(SBBI3_CS0_PIO_ID)
-#define SBBI3_CS0_PE_REG        PIO_PER
-#define SBBI3_CS0_OE_REG        PIO_OER
-#define SBBI3_CS0_COD_REG       PIO_CODR
-#define SBBI3_CS0_SOD_REG       PIO_SODR
-#elif SBBI3_CS0_PIO_ID == PIOA_ID
-#define SBBI3_CS0_PE_REG        PIOA_PER
-#define SBBI3_CS0_OE_REG        PIOA_OER
-#define SBBI3_CS0_COD_REG       PIOA_CODR
-#define SBBI3_CS0_SOD_REG       PIOA_SODR
-#elif SBBI3_CS0_PIO_ID == PIOB_ID
-#define SBBI3_CS0_PE_REG        PIOB_PER
-#define SBBI3_CS0_OE_REG        PIOB_OER
-#define SBBI3_CS0_COD_REG       PIOB_CODR
-#define SBBI3_CS0_SOD_REG       PIOB_SODR
-#elif SBBI3_CS0_PIO_ID == PIOC_ID
-#define SBBI3_CS0_PE_REG        PIOC_PER
-#define SBBI3_CS0_OE_REG        PIOC_OER
-#define SBBI3_CS0_COD_REG       PIOC_CODR
-#define SBBI3_CS0_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 chip select 0 output. */
-#define SBBI3_CS0_ENA() \
-    outr(SBBI3_CS0_PE_REG, _BV(SBBI3_CS0_BIT)); \
-    outr(SBBI3_CS0_OE_REG, _BV(SBBI3_CS0_BIT))
-/*! \brief Set SBBI3 chip select 0 output low. */
-#define SBBI3_CS0_CLR()   outr(SBBI3_CS0_COD_REG, _BV(SBBI3_CS0_BIT))
-/*! \brief Set SBBI3 chip select 0 output high. */
-#define SBBI3_CS0_SET()   outr(SBBI3_CS0_SOD_REG, _BV(SBBI3_CS0_BIT))
-
-#endif                          /* SBBI3_CS0_BIT */
-
-#ifdef SBBI3_CS1_BIT
-
-#if !defined(SBBI3_CS1_PIO_ID)
-#define SBBI3_CS1_PE_REG        PIO_PER
-#define SBBI3_CS1_OE_REG        PIO_OER
-#define SBBI3_CS1_COD_REG       PIO_CODR
-#define SBBI3_CS1_SOD_REG       PIO_SODR
-#elif SBBI3_CS1_PIO_ID == PIOA_ID
-#define SBBI3_CS1_PE_REG        PIOA_PER
-#define SBBI3_CS1_OE_REG        PIOA_OER
-#define SBBI3_CS1_COD_REG       PIOA_CODR
-#define SBBI3_CS1_SOD_REG       PIOA_SODR
-#elif SBBI3_CS1_PIO_ID == PIOB_ID
-#define SBBI3_CS1_PE_REG        PIOB_PER
-#define SBBI3_CS1_OE_REG        PIOB_OER
-#define SBBI3_CS1_COD_REG       PIOB_CODR
-#define SBBI3_CS1_SOD_REG       PIOB_SODR
-#elif SBBI3_CS1_PIO_ID == PIOC_ID
-#define SBBI3_CS1_PE_REG        PIOC_PER
-#define SBBI3_CS1_OE_REG        PIOC_OER
-#define SBBI3_CS1_COD_REG       PIOC_CODR
-#define SBBI3_CS1_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 chip select output. */
-#define SBBI3_CS1_ENA() \
-    outr(SBBI3_CS1_PE_REG, _BV(SBBI3_CS1_BIT)); \
-    outr(SBBI3_CS1_OE_REG, _BV(SBBI3_CS1_BIT))
-/*! \brief Set SBBI3 chip select output low. */
-#define SBBI3_CS1_CLR()   outr(SBBI3_CS1_COD_REG, _BV(SBBI3_CS1_BIT))
-/*! \brief Set SBBI3 chip select output high. */
-#define SBBI3_CS1_SET()   outr(SBBI3_CS1_SOD_REG, _BV(SBBI3_CS1_BIT))
-
-#endif                          /* SBBI3_CS1_BIT */
-
-#ifdef SBBI3_CS2_BIT
-
-#if !defined(SBBI3_CS2_PIO_ID)
-#define SBBI3_CS2_PE_REG        PIO_PER
-#define SBBI3_CS2_OE_REG        PIO_OER
-#define SBBI3_CS2_COD_REG       PIO_CODR
-#define SBBI3_CS2_SOD_REG       PIO_SODR
-#elif SBBI3_CS2_PIO_ID == PIOA_ID
-#define SBBI3_CS2_PE_REG        PIOA_PER
-#define SBBI3_CS2_OE_REG        PIOA_OER
-#define SBBI3_CS2_COD_REG       PIOA_CODR
-#define SBBI3_CS2_SOD_REG       PIOA_SODR
-#elif SBBI3_CS2_PIO_ID == PIOB_ID
-#define SBBI3_CS2_PE_REG        PIOB_PER
-#define SBBI3_CS2_OE_REG        PIOB_OER
-#define SBBI3_CS2_COD_REG       PIOB_CODR
-#define SBBI3_CS2_SOD_REG       PIOB_SODR
-#elif SBBI3_CS2_PIO_ID == PIOC_ID
-#define SBBI3_CS2_PE_REG        PIOC_PER
-#define SBBI3_CS2_OE_REG        PIOC_OER
-#define SBBI3_CS2_COD_REG       PIOC_CODR
-#define SBBI3_CS2_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 chip select output. */
-#define SBBI3_CS2_ENA() \
-    outr(SBBI3_CS2_PE_REG, _BV(SBBI3_CS2_BIT)); \
-    outr(SBBI3_CS2_OE_REG, _BV(SBBI3_CS2_BIT))
-/*! \brief Set SBBI3 chip select output low. */
-#define SBBI3_CS2_CLR()   outr(SBBI3_CS2_COD_REG, _BV(SBBI3_CS2_BIT))
-/*! \brief Set SBBI3 chip select output high. */
-#define SBBI3_CS2_SET()   outr(SBBI3_CS2_SOD_REG, _BV(SBBI3_CS2_BIT))
-
-#endif                          /* SBBI3_CS2_BIT */
-
-#ifdef SBBI3_CS3_BIT
-
-#if !defined(SBBI3_CS3_PIO_ID)
-#define SBBI3_CS3_PE_REG        PIO_PER
-#define SBBI3_CS3_OE_REG        PIO_OER
-#define SBBI3_CS3_COD_REG       PIO_CODR
-#define SBBI3_CS3_SOD_REG       PIO_SODR
-#elif SBBI3_CS3_PIO_ID == PIOA_ID
-#define SBBI3_CS3_PE_REG        PIOA_PER
-#define SBBI3_CS3_OE_REG        PIOA_OER
-#define SBBI3_CS3_COD_REG       PIOA_CODR
-#define SBBI3_CS3_SOD_REG       PIOA_SODR
-#elif SBBI3_CS3_PIO_ID == PIOB_ID
-#define SBBI3_CS3_PE_REG        PIOB_PER
-#define SBBI3_CS3_OE_REG        PIOB_OER
-#define SBBI3_CS3_COD_REG       PIOB_CODR
-#define SBBI3_CS3_SOD_REG       PIOB_SODR
-#elif SBBI3_CS3_PIO_ID == PIOC_ID
-#define SBBI3_CS3_PE_REG        PIOC_PER
-#define SBBI3_CS3_OE_REG        PIOC_OER
-#define SBBI3_CS3_COD_REG       PIOC_CODR
-#define SBBI3_CS3_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 chip select output. */
-#define SBBI3_CS3_ENA() \
-    outr(SBBI3_CS3_PE_REG, _BV(SBBI3_CS3_BIT)); \
-    outr(SBBI3_CS3_OE_REG, _BV(SBBI3_CS3_BIT))
-/*! \brief Set SBBI3 chip select output low. */
-#define SBBI3_CS3_CLR()   outr(SBBI3_CS3_COD_REG, _BV(SBBI3_CS3_BIT))
-/*! \brief Set SBBI3 chip select output high. */
-#define SBBI3_CS3_SET()   outr(SBBI3_CS3_SOD_REG, _BV(SBBI3_CS3_BIT))
-
-#endif                          /* SBBI3_CS3_BIT */
-
-#ifdef SBBI3_RST0_BIT
-
-#if !defined(SBBI3_RST0_PIO_ID)
-#define SBBI3_RST0_PE_REG      PIO_PER
-#define SBBI3_RST0_OE_REG      PIO_OER
-#define SBBI3_RST0_COD_REG     PIO_CODR
-#define SBBI3_RST0_SOD_REG     PIO_SODR
-#elif SBBI3_RST0_PIO_ID == PIOA_ID
-#define SBBI3_RST0_PE_REG      PIOA_PER
-#define SBBI3_RST0_OE_REG      PIOA_OER
-#define SBBI3_RST0_COD_REG     PIOA_CODR
-#define SBBI3_RST0_SOD_REG     PIOA_SODR
-#elif SBBI3_RST0_PIO_ID == PIOB_ID
-#define SBBI3_RST0_PE_REG      PIOB_PER
-#define SBBI3_RST0_OE_REG      PIOB_OER
-#define SBBI3_RST0_COD_REG     PIOB_CODR
-#define SBBI3_RST0_SOD_REG     PIOB_SODR
-#elif SBBI3_RST0_PIO_ID == PIOC_ID
-#define SBBI3_RST0_PE_REG      PIOC_PER
-#define SBBI3_RST0_OE_REG      PIOC_OER
-#define SBBI3_RST0_COD_REG     PIOC_CODR
-#define SBBI3_RST0_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 reset output. */
-#define SBBI3_RST0_ENA() \
-    outr(SBBI3_RST0_PE_REG, _BV(SBBI3_RST0_BIT)); \
-    outr(SBBI3_RST0_OE_REG, _BV(SBBI3_RST0_BIT))
-/*! \brief Set SBBI3 reset output low. */
-#define SBBI3_RST0_CLR()   outr(SBBI3_RST0_COD_REG, _BV(SBBI3_RST0_BIT))
-/*! \brief Set SBBI3 reset output high. */
-#define SBBI3_RST0_SET()   outr(SBBI3_RST0_SOD_REG, _BV(SBBI3_RST0_BIT))
-
-#endif                          /* SBBI3_RST0_BIT */
-
-#ifdef SBBI3_RST1_BIT
-
-#if !defined(SBBI3_RST1_PIO_ID)
-#define SBBI3_RST1_PE_REG      PIO_PER
-#define SBBI3_RST1_OE_REG      PIO_OER
-#define SBBI3_RST1_COD_REG     PIO_CODR
-#define SBBI3_RST1_SOD_REG     PIO_SODR
-#elif SBBI3_RST1_PIO_ID == PIOA_ID
-#define SBBI3_RST1_PE_REG      PIOA_PER
-#define SBBI3_RST1_OE_REG      PIOA_OER
-#define SBBI3_RST1_COD_REG     PIOA_CODR
-#define SBBI3_RST1_SOD_REG     PIOA_SODR
-#elif SBBI3_RST1_PIO_ID == PIOB_ID
-#define SBBI3_RST1_PE_REG      PIOB_PER
-#define SBBI3_RST1_OE_REG      PIOB_OER
-#define SBBI3_RST1_COD_REG     PIOB_CODR
-#define SBBI3_RST1_SOD_REG     PIOB_SODR
-#elif SBBI3_RST1_PIO_ID == PIOC_ID
-#define SBBI3_RST1_PE_REG      PIOC_PER
-#define SBBI3_RST1_OE_REG      PIOC_OER
-#define SBBI3_RST1_COD_REG     PIOC_CODR
-#define SBBI3_RST1_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 reset output. */
-#define SBBI3_RST1_ENA() \
-    outr(SBBI3_RST1_PE_REG, _BV(SBBI3_RST1_BIT)); \
-    outr(SBBI3_RST1_OE_REG, _BV(SBBI3_RST1_BIT))
-/*! \brief Set SBBI3 reset output low. */
-#define SBBI3_RST1_CLR()   outr(SBBI3_RST1_COD_REG, _BV(SBBI3_RST1_BIT))
-/*! \brief Set SBBI3 reset output high. */
-#define SBBI3_RST1_SET()   outr(SBBI3_RST1_SOD_REG, _BV(SBBI3_RST1_BIT))
-
-#endif                          /* SBBI3_RST1_BIT */
-
-#ifdef SBBI3_RST2_BIT
-
-#if !defined(SBBI3_RST2_PIO_ID)
-#define SBBI3_RST2_PE_REG      PIO_PER
-#define SBBI3_RST2_OE_REG      PIO_OER
-#define SBBI3_RST2_COD_REG     PIO_CODR
-#define SBBI3_RST2_SOD_REG     PIO_SODR
-#elif SBBI3_RST2_PIO_ID == PIOA_ID
-#define SBBI3_RST2_PE_REG      PIOA_PER
-#define SBBI3_RST2_OE_REG      PIOA_OER
-#define SBBI3_RST2_COD_REG     PIOA_CODR
-#define SBBI3_RST2_SOD_REG     PIOA_SODR
-#elif SBBI3_RST2_PIO_ID == PIOB_ID
-#define SBBI3_RST2_PE_REG      PIOB_PER
-#define SBBI3_RST2_OE_REG      PIOB_OER
-#define SBBI3_RST2_COD_REG     PIOB_CODR
-#define SBBI3_RST2_SOD_REG     PIOB_SODR
-#elif SBBI3_RST2_PIO_ID == PIOC_ID
-#define SBBI3_RST2_PE_REG      PIOC_PER
-#define SBBI3_RST2_OE_REG      PIOC_OER
-#define SBBI3_RST2_COD_REG     PIOC_CODR
-#define SBBI3_RST2_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 reset output. */
-#define SBBI3_RST2_ENA() \
-    outr(SBBI3_RST2_PE_REG, _BV(SBBI3_RST2_BIT)); \
-    outr(SBBI3_RST2_OE_REG, _BV(SBBI3_RST2_BIT))
-/*! \brief Set SBBI3 reset output low. */
-#define SBBI3_RST2_CLR()   outr(SBBI3_RST2_COD_REG, _BV(SBBI3_RST2_BIT))
-/*! \brief Set SBBI3 reset output high. */
-#define SBBI3_RST2_SET()   outr(SBBI3_RST2_SOD_REG, _BV(SBBI3_RST2_BIT))
-
-#endif                          /* SBBI3_RST2_BIT */
-
-#ifdef SBBI3_RST3_BIT
-
-#if !defined(SBBI3_RST3_PIO_ID)
-#define SBBI3_RST3_PE_REG      PIO_PER
-#define SBBI3_RST3_OE_REG      PIO_OER
-#define SBBI3_RST3_COD_REG     PIO_CODR
-#define SBBI3_RST3_SOD_REG     PIO_SODR
-#elif SBBI3_RST3_PIO_ID == PIOA_ID
-#define SBBI3_RST3_PE_REG      PIOA_PER
-#define SBBI3_RST3_OE_REG      PIOA_OER
-#define SBBI3_RST3_COD_REG     PIOA_CODR
-#define SBBI3_RST3_SOD_REG     PIOA_SODR
-#elif SBBI3_RST3_PIO_ID == PIOB_ID
-#define SBBI3_RST3_PE_REG      PIOB_PER
-#define SBBI3_RST3_OE_REG      PIOB_OER
-#define SBBI3_RST3_COD_REG     PIOB_CODR
-#define SBBI3_RST3_SOD_REG     PIOB_SODR
-#elif SBBI3_RST3_PIO_ID == PIOC_ID
-#define SBBI3_RST3_PE_REG      PIOC_PER
-#define SBBI3_RST3_OE_REG      PIOC_OER
-#define SBBI3_RST3_COD_REG     PIOC_CODR
-#define SBBI3_RST3_SOD_REG     PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 reset output. */
-#define SBBI3_RST3_ENA() \
-    outr(SBBI3_RST3_PE_REG, _BV(SBBI3_RST3_BIT)); \
-    outr(SBBI3_RST3_OE_REG, _BV(SBBI3_RST3_BIT))
-/*! \brief Set SBBI3 reset output low. */
-#define SBBI3_RST3_CLR()   outr(SBBI3_RST3_COD_REG, _BV(SBBI3_RST3_BIT))
-/*! \brief Set SBBI3 reset output high. */
-#define SBBI3_RST3_SET()   outr(SBBI3_RST3_SOD_REG, _BV(SBBI3_RST3_BIT))
-
-#endif                          /* SBBI3_RST3_BIT */
-
-#ifdef SBBI3_SCK_BIT
-
-#if !defined(SBBI3_SCK_PIO_ID)
-#define SBBI3_SCK_PE_REG        PIO_PER
-#define SBBI3_SCK_OE_REG        PIO_OER
-#define SBBI3_SCK_COD_REG       PIO_CODR
-#define SBBI3_SCK_SOD_REG       PIO_SODR
-#elif SBBI3_SCK_PIO_ID == PIOA_ID
-#define SBBI3_SCK_PE_REG        PIOA_PER
-#define SBBI3_SCK_OE_REG        PIOA_OER
-#define SBBI3_SCK_COD_REG       PIOA_CODR
-#define SBBI3_SCK_SOD_REG       PIOA_SODR
-#elif SBBI3_SCK_PIO_ID == PIOB_ID
-#define SBBI3_SCK_PE_REG        PIOB_PER
-#define SBBI3_SCK_OE_REG        PIOB_OER
-#define SBBI3_SCK_COD_REG       PIOB_CODR
-#define SBBI3_SCK_SOD_REG       PIOB_SODR
-#elif SBBI3_SCK_PIO_ID == PIOC_ID
-#define SBBI3_SCK_PE_REG        PIOC_PER
-#define SBBI3_SCK_OE_REG        PIOC_OER
-#define SBBI3_SCK_COD_REG       PIOC_CODR
-#define SBBI3_SCK_SOD_REG       PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 clock output. */
-#define SBBI3_SCK_ENA() \
-    outr(SBBI3_SCK_PE_REG, _BV(SBBI3_SCK_BIT)); \
-    outr(SBBI3_SCK_OE_REG, _BV(SBBI3_SCK_BIT))
-/*! \brief Set SBBI3 clock output low. */
-#define SBBI3_SCK_CLR()     outr(SBBI3_SCK_COD_REG, _BV(SBBI3_SCK_BIT))
-/*! \brief Set SBBI3 clock output high. */
-#define SBBI3_SCK_SET()     outr(SBBI3_SCK_SOD_REG, _BV(SBBI3_SCK_BIT))
-
-#ifdef SBBI3_MOSI_BIT
-
-#if !defined(SBBI3_MOSI_PIO_ID)
-#define SBBI3_MOSI_PE_REG       PIO_PER
-#define SBBI3_MOSI_OE_REG       PIO_OER
-#define SBBI3_MOSI_COD_REG      PIO_CODR
-#define SBBI3_MOSI_SOD_REG      PIO_SODR
-#elif SBBI3_MOSI_PIO_ID == PIOA_ID
-#define SBBI3_MOSI_PE_REG       PIOA_PER
-#define SBBI3_MOSI_OE_REG       PIOA_OER
-#define SBBI3_MOSI_COD_REG      PIOA_CODR
-#define SBBI3_MOSI_SOD_REG      PIOA_SODR
-#elif SBBI3_MOSI_PIO_ID == PIOB_ID
-#define SBBI3_MOSI_PE_REG       PIOB_PER
-#define SBBI3_MOSI_OE_REG       PIOB_OER
-#define SBBI3_MOSI_COD_REG      PIOB_CODR
-#define SBBI3_MOSI_SOD_REG      PIOB_SODR
-#elif SBBI3_MOSI_PIO_ID == PIOC_ID
-#define SBBI3_MOSI_PE_REG       PIOC_PER
-#define SBBI3_MOSI_OE_REG       PIOC_OER
-#define SBBI3_MOSI_COD_REG      PIOC_CODR
-#define SBBI3_MOSI_SOD_REG      PIOC_SODR
-#endif
-
-/*! \brief Enable SBBI3 data output. */
-#define SBBI3_MOSI_ENA() \
-    outr(SBBI3_MOSI_PE_REG, _BV(SBBI3_MOSI_BIT)); \
-    outr(SBBI3_MOSI_OE_REG, _BV(SBBI3_MOSI_BIT))
-/*! \brief Set SBBI3 data output low. */
-#define SBBI3_MOSI_CLR()    outr(SBBI3_MOSI_COD_REG, _BV(SBBI3_MOSI_BIT))
-/*! \brief Set SBBI3 data output high. */
-#define SBBI3_MOSI_SET()    outr(SBBI3_MOSI_SOD_REG, _BV(SBBI3_MOSI_BIT))
-
-#else                           /* SBBI3_MOSI_BIT */
-
-#define SBBI3_MOSI_ENA()
-#define SBBI3_MOSI_CLR()
-#define SBBI3_MOSI_SET()
-
-#endif                          /* SBBI3_MOSI_BIT */
-
-#ifdef SBBI3_MISO_BIT
-
-#if !defined(SBBI3_MISO_PIO_ID)
-#define SBBI3_MISO_PE_REG       PIO_PER
-#define SBBI3_MISO_OD_REG       PIO_ODR
-#define SBBI3_MISO_PDS_REG      PIO_PDSR
-#elif SBBI3_MISO_PIO_ID == PIOA_ID
-#define SBBI3_MISO_PE_REG       PIOA_PER
-#define SBBI3_MISO_OD_REG       PIOA_ODR
-#define SBBI3_MISO_PDS_REG      PIOA_PDSR
-#elif SBBI3_MISO_PIO_ID == PIOB_ID
-#define SBBI3_MISO_PE_REG       PIOB_PER
-#define SBBI3_MISO_OD_REG       PIOB_ODR
-#define SBBI3_MISO_PDS_REG      PIOB_PDSR
-#elif SBBI3_MISO_PIO_ID == PIOC_ID
-#define SBBI3_MISO_PE_REG       PIOC_PER
-#define SBBI3_MISO_OD_REG       PIOC_ODR
-#define SBBI3_MISO_PDS_REG      PIOC_PDSR
-#endif
-
-/*! \brief Enable SBBI3 data input. */
-#define SBBI3_MISO_ENA() \
-    outr(SBBI3_MISO_PE_REG, _BV(SBBI3_MISO_BIT)); \
-    outr(SBBI3_MISO_OD_REG, _BV(SBBI3_MISO_BIT))
-/*! \brief Query SBBI3 data input. */
-#define SBBI3_MISO_TST()    ((inr(SBBI3_MISO_PDS_REG) & _BV(SBBI3_MISO_BIT)) == _BV(SBBI3_MISO_BIT))
-
-#else                           /* SBBI3_MISO_BIT */
-
-#define SBBI3_MISO_ENA()
-#define SBBI3_MISO_TST()   0
-
-#endif                          /* SBBI3_MISO_BIT */
-
-#endif                          /* SBBI3_SCK_BIT */
-
-#endif                          /* MCU */
-
-#define SBBI3_INIT() \
-{ \
-    SBBI3_SCK_CLR(); \
-    SBBI3_SCK_ENA(); \
-    SBBI3_MOSI_CLR(); \
-    SBBI3_MOSI_ENA(); \
-    SBBI3_MISO_ENA(); \
-}
-
-#endif

+ 0 - 164
include/dev/tlc16c550.h

@@ -1,164 +0,0 @@
-#ifndef _DEV_TLC16C550_H_
-#define _DEV_TLC16C550_H_
-
-/*
- * Copyright (C) 2001-2003 by Cyber Integration, LLC. 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 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 CYBER INTEGRATION, LLC 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 CYBER
- * INTEGRATION, LLC 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.
- *
- */
-
-/*
- * $Log: tlc16c550.h,v $
- * Revision 1.2  2006/05/25 09:09:57  haraldkipp
- * API documentation updated and corrected.
- *
- * Revision 1.1  2005/11/24 11:24:06  haraldkipp
- * Initial check-in.
- * Many thanks to William Basser for this code and also to Przemyslaw Rudy
- * for several enhancements.
- *
- */
-
-/*
-	Chip connections:
-	Ax - to avr address lines
-	CSx - to avr/PGA (chip select)
-    Dn - to avr data lines
-    INTN - to vcc (for 16c554 forces activation of interrupt lines)
-    INTx - to avr interrupt lines (can be OR-ed and share common avr interrupt line)
-	OIR - to avr /rd
-	OIW - to avr /wr
-    RESET - high is active
- */
-
-#include <sys/device.h>
-#include <dev/ace.h>
-
-/*!
- * \file dev/tlc16c550.h
- * \brief ACE ACE definitions.
- */
-
-/*!
- * \addtogroup xgAceDriver
- */
-/*@{*/
-
-#define ACE_MF_RTSSENSE		0x00000001UL    /*!< DCE input, low on port bit is +12V, which means ON. */
-#define ACE_MF_CTSCONTROL	0x00000002UL    /*!< DCE output. */
-#define ACE_MF_DTRSENSE		0x00000004UL    /*!< DCE input. */
-#define ACE_MF_DSRCONTROL	0x00000008UL    /*!< DCE output. */
-#define ACE_MF_DCDCONTROL	0x00000010UL    /*!< DCE output. */
-
-#define ACE_MF_RTSCONTROL	0x00000020UL    /*!< DTE output. */
-#define ACE_MF_CTSSENSE		0x00000040UL    /*!< DTE input. */
-#define ACE_MF_DTRCONTROL	0x00000080UL    /*!< DTE output. */
-#define ACE_MF_DSRSENSE		0x00000100UL    /*!< DTE input. */
-#define ACE_MF_DCDSENSE		0x00000200UL    /*!< DTE input. */
-
-#define ACE_MF_SENSEMASK	0x0345  /*!< Handshake sense mask. */
-#define ACE_MF_CONTROLMASK	0x00BC  /*!< Handshake control mask. */
-
-#define ACE_MF_XONXOFF		0x00000400UL    /*!< Software handshake. */
-
-#define ACE_MF_LOCALECHO	0x00010000UL    /*!< Should be used in stream, not device. */
-#define ACE_MF_COOKEDMODE	0x00020000UL    /*!< Should be used in stream, not device. */
-
-#define ACE_MF_NOBUFFER		0x00100000UL    /*!< No buffering. */
-#define ACE_MF_LINEBUFFER	0x00200000UL    /*!< Line buffered. */
-#define ACE_MF_BUFFERMASK	0x00300000UL    /*!< Masks buffering mode flags. */
-
-
-#define ACE_SF_RTSOFF		0x00000001UL    /*!< Set RTS line is off. */
-#define ACE_SF_CTSOFF	    0x00000002UL        /*!< Set CTS line is off. */
-#define ACE_SF_DTROFF	    0x00000004UL        /*!< Set DTR line is off. */
-#define ACE_SF_DSROFF	    0x00000008UL        /*!< Set DSR line is off. */
-#define ACE_SF_DCDOFF	    0x00000010UL        /*!< Set DCD line is off. */
-
-#define ACE_SF_TXDISABLED	0x00000040UL    /*!< Transmitter disabled. */
-#define ACE_SF_RXDISABLED	0x00000080UL    /*!< Receiver disabled. */
-
-#define ACE_HS_DCERTSCTS	0x00000003UL    /*!< RTS/CTS DCE handshake. */
-#define ACE_HS_DCEFULL	    0x0000001FUL        /*!< Full DCE handshake. */
-
-#define ACE_HS_DTERTSCTS	0x00000060UL    /*!< RTS/CTS DTE handshake. */
-#define ACE_HS_DTEFULL	    0x000003E0UL        /*!< Full DTE handshake. */
-
-#define ACE_HS_XONXOFF	    0x00000400UL        /*!< Software handshake. */
-
-#define ACE_CLOCK           1843200     /* in MHz - common for all devices (should be ok) */
-
-/*!
- * ACE device control block type.
- */
-typedef struct _ACEDCB ACEDCB;
-
-/*!
- * \struct _ACEDCB tlc16c550.h dev/tlc16c550.h
- * \brief ACE device control block structure.
- */
-struct _ACEDCB {
-    /*! \brief pointer to the next device, used if more devices share the same interrupt */
-    NUTDEVICE *dev_next;
-
-    /*! \brief Read timeout.
-     */
-    u_long dcb_rtimeout;
-
-    /*! \brief Write timeout.
-     */
-    u_long dcb_wtimeout;
-
-    /*! \brief Queue of threads waiting for output buffer empty.
-     *
-     * Threads are added to this queue when calling ACEAvrFlush(). 
-     */
-    HANDLE dcb_tx_rdy;
-
-    /*! \brief Queue of threads waiting for a character in the input buffer.
-     *
-     * Threads are added to this queue when calling ACEAvrInput(). 
-     */
-    HANDLE dcb_rx_rdy;
-
-    /*! \brief Mode flags.
-     */
-    u_long dcb_modeflags;
-
-    /*! \brief Level of the fifo trigger, 0 if no fifo.
-     */
-    u_char dcb_rfifo;
-
-    /*! \brief Free space in the output fifo since the last write operation.
-     */
-    u_char dcb_wfifo;
-};
-
-/*@}*/
-
-#endif

+ 0 - 90
include/dev/twif.h

@@ -1,90 +0,0 @@
-#ifndef _DEV_TWIF_H_
-#define _DEV_TWIF_H_
-
-/*
- * Copyright (C) 2001-2005 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*
- * $Log: twif.h,v $
- * Revision 1.2  2005/10/24 10:56:30  haraldkipp
- * Added const modifier to transmit data pointer in TwMasterTransact().
- *
- * Revision 1.1.1.1  2003/05/09 14:41:09  haraldkipp
- * Initial using 3.2.1
- *
- * Revision 1.2  2003/03/31 14:53:23  harald
- * Prepare release 3.1
- *
- */
-
-#include <sys/types.h>
-
-#define TWI_SETSPEED		0x0401	/*!< \brief Set transfer speed. */
-#define TWI_GETSPEED		0x0402	/*!< \brief Query transfer speed. */
-#define TWI_SETSLAVEADDRESS	0x0403	/*!< \brief Set local slave address. */
-#define TWI_GETSLAVEADDRESS	0x0404	/*!< \brief Query local slave address. */
-#define TWI_SETSTATUS		0x0409	/*!< \brief Set status. */
-#define TWI_GETSTATUS		0x040a	/*!< \brief Query status. */
-
-
-#define TWERR_OK		0	/*!< \brief No error occured. */
-#define TWERR_TIMEOUT		1	/*!< \brief Interface timeout. */
-#define TWERR_BUS		2	/*!< \brief Bus error. */
-#define TWERR_IF_LOCKED		3	/*!< \brief Interface locked. */
-#define TWERR_SLA_NACK		4	/*!< \brief No slave response. */
-#define TWERR_DATA_NACK		5	/*!< \brief Data not acknowledged. */
-
-
-#define TWSLA_MIN		17	/*!< \brief Lowest slave address.
-					 * Addresses below are reserved 
-					 * for special purposes.
-					 */
-#define TWSLA_MAX		79	/*!< \brief Lowest slave address.
-					 * Addresses above are reserved 
-					 * for special purposes.
-					 */
-#define TWSLA_BCAST		0	/*!< \brief Broadcast slave address. */
-#define TWSLA_HOST		16	/*!< \brief Host slave address. */
-#define TWSLA_DEFAULT		193	/*!< \brief Default slave address. */
-
-extern int TwInit(u_char sla);
-extern int TwIOCtl(int req, void *conf);
-
-extern int TwMasterTransact(u_char sla, CONST void *txdata, u_short txlen, void *rxdata, u_short rxsiz, u_long tmo);
-extern int TwMasterError(void);
-
-extern int TwSlaveListen(u_char *sla, void *rxdata, u_short rxsiz, u_long tmo);
-extern int TwSlaveRespond(void *txdata, u_short txlen, u_long tmo);
-extern int TwSlaveError(void);
-
-
-#endif

+ 0 - 604
include/dev/uart.h

@@ -1,604 +0,0 @@
-#ifndef _DEV_UART_H
-#define _DEV_UART_H
-
-/*
- * Copyright (C) 2001-2004 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
-
-/*
- * $Log: uart.h,v $
- * Revision 1.4  2005/06/26 12:40:59  chaac
- * Added support for raw mode to AHDLC driver.
- *
- * Revision 1.3  2004/11/12 11:14:32  freckle
- * added UART_GETBLOCKREAD & UART_SETBLOCKREAD defines
- *
- * Revision 1.2  2004/05/24 20:19:08  drsung
- * Added function UartAvrSize to return number of chars in input buffer.
- *
- * Revision 1.1  2004/03/16 16:48:28  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- * Revision 1.2  2003/12/15 19:29:18  haraldkipp
- * USART driver support added
- *
- * Revision 1.1.1.1  2003/05/09 14:41:23  haraldkipp
- * Initial using 3.2.1
- *
- * Revision 1.11  2003/05/06 17:58:28  harald
- * Handshakes added
- *
- * Revision 1.10  2003/03/31 14:53:25  harald
- * Prepare release 3.1
- *
- * Revision 1.9  2003/02/04 18:00:54  harald
- * Version 3 released
- *
- * Revision 1.8  2003/01/14 16:35:24  harald
- * Definitions moved
- *
- * Revision 1.7  2002/11/02 15:17:01  harald
- * Library dependencies moved to compiler.h
- *
- * Revision 1.6  2002/06/26 17:29:30  harald
- * First pre-release with 2.4 stack
- *
- */
-
-#include <sys/device.h>
-
-/*!
- * \file dev/uart.h
- * \brief UART I/O function prototypes.
- */
-
-/*!
- * \addtogroup xgUARTIOCTL
- *
- * \brief UART _ioctl() commands.
- *
- * These commands are used to control and retrieve hardware specific
- * configurations. The definitions are kept independent from the 
- * underlying hardware, but not all commands may be fully implemented 
- * in each UART driver.
- *
- * The _ioctl() function expects three parameters:
- * - A device descriptor.
- * - A command code, any of the UART_... commands listed below.
- * - A pointer to a configuration parameter, in most cases an unsigned long.
- */
-/*@{*/
-
-/*! \brief UART _ioctl() command code to set the line speed.
- *
- * The configuration parameter specifies the input and output bit rate 
- * per second.
- */
-#define UART_SETSPEED           0x0101
-
-/*! \brief UART _ioctl() command code to query the line speed.
- *
- * The configuration parameter is set to the input and output bit rate 
- * per second.
- */
-#define UART_GETSPEED           0x0102
-
-/*! \brief UART _ioctl() command code to set the number of data bits.
- *
- * The configuration parameter specifies the number of data bits, 5, 6, 
- * 7, 8 or 9.
- */
-#define UART_SETDATABITS        0x0103
-
-/*! \brief UART _ioctl() command code to query the number of data bits.
- *
- * The configuration parameter is set to the number of data bits, 5, 6, 
- * 7, 8 or 9.
- */
-#define UART_GETDATABITS        0x0104
-
-/*! \brief UART _ioctl() command code to set the parity mode.
- *
- * The configuration parameter specifies the type of the parity bit, 
- * 0 (none), 1 (odd) or 2 (even).
- */
-#define UART_SETPARITY          0x0105
-
-/*! \brief UART _ioctl() command code to query the parity mode.
- *
- * The configuration parameter is set to the type of the parity bit, 
- * 0 (none), 1 (odd) or 2 (even).
- */
-#define UART_GETPARITY          0x0106
-
-/*! \brief UART _ioctl() command code to set the number of stop bits.
- *
- * The configuration parameter specifies the number of stop bits, 1 or 2.
- */
-#define UART_SETSTOPBITS        0x0107
-
-/*! \brief UART _ioctl() command code to query the number of stop bits.
- *
- * The configuration parameter is set to the number of stop bits, 1 or 2.
- */
-#define UART_GETSTOPBITS        0x0108
-
-/*! \brief UART _ioctl() command code to set the status.
- *
- * The configuration parameter specifies the status to set.
- */
-#define UART_SETSTATUS          0x0109
-
-/*! \brief UART _ioctl() command code to query the status.
- *
- * The configuration parameter is set to the current status.
- */
-#define UART_GETSTATUS          0x010a
-
-/*! \brief UART _ioctl() command code to set the read timeout.
- *
- * The configuration parameter specifies the read timeout in 
- * milliseconds.
- */
-#define UART_SETREADTIMEOUT     0x010b
-
-/*! \brief UART _ioctl() command code to query the read timeout.
- *
- * The configuration parameter is set to the read timeout in 
- * milliseconds.
- */
-#define UART_GETREADTIMEOUT     0x010c
-
-/*! \brief UART _ioctl() command code to set the write timeout.
- *
- * The configuration parameter specifies the write timeout in 
- * milliseconds.
- */
-#define UART_SETWRITETIMEOUT    0x010d
-
-/*! \brief UART _ioctl() command code to query the write timeout.
- *
- * The configuration parameter is set to the write timeout in 
- * milliseconds.
- */
-#define UART_GETWRITETIMEOUT    0x010e
-
-/*! \brief UART _ioctl() command code to set the local echo mode.
- *
- * The configuration parameter specifies the local echo mode, 
- * 0 (off) or 1 (on).
- */
-#define UART_SETLOCALECHO       0x010f
-
-/*! \brief UART _ioctl() command code to query the local echo mode.
- *
- * The configuration parameter is set to the local echo mode, 
- * 0 (off) or 1 (on).
- */
-#define UART_GETLOCALECHO       0x0110
-
-/*! \brief UART _ioctl() command code to set the flow control mode.
- *
- * The configuration parameter specifies the flow control mode.
- */
-#define UART_SETFLOWCONTROL     0x0111
-
-/*! \brief UART _ioctl() command code to query the flow control mode.
- *
- * The configuration parameter is set to the flow control mode.
- */
-#define UART_GETFLOWCONTROL     0x0112
-
-/*! \brief UART _ioctl() command code to set the cooking mode.
- *
- * The configuration parameter specifies the character cooking mode, 
- * 0 (raw) or 1 (EOL translation).
- */
-#define UART_SETCOOKEDMODE      0x0113
-
-/*! \brief UART _ioctl() command code to query the cooking mode.
- *
- * The configuration parameter is set to the character cooking mode, 
- * 0 (raw) or 1 (EOL translation).
- */
-#define UART_GETCOOKEDMODE      0x0114
-
-/*! \brief UART _ioctl() command code to set the buffering mode.
- *
- * The configuration parameter specifies the buffering mode.
- */
-#define UART_SETBUFFERMODE      0x0115
-
-/*! \brief UART _ioctl() command code to query the buffering mode.
- *
- * The configuration parameter is set to the buffering mode.
- */
-#define UART_GETBUFFERMODE      0x0116
-
-/*! \brief UART _ioctl() command code to set the network interface mode.
- *
- * The configuration parameter specifies the network interface mode.
- */
-#define HDLC_SETIFNET           0x0117
-
-/*! \brief UART _ioctl() command code to query the network interface mode.
- *
- * The configuration parameter is set to the network interface mode.
- */
-#define HDLC_GETIFNET           0x0118
-
-/*! \brief UART _ioctl() command code to set the clock mode.
- *
- * The configuration parameter specifies the clock mode.
- */
-#define UART_SETCLOCKMODE       0x0119
-
-/*! \brief UART _ioctl() command code to query the clock mode.
- *
- * The configuration parameter is set to the clock mode.
- */
-#define UART_GETCLOCKMODE       0x011a
-
-/*! \brief UART _ioctl() command code to set the transmit buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_SETTXBUFSIZ        0x011b
-
-/*! \brief UART _ioctl() command code to query the transmit buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_GETTXBUFSIZ        0x011c
-
-/*! \brief UART _ioctl() command code to set the receive buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_SETRXBUFSIZ        0x011d
-
-/*! \brief UART _ioctl() command code to query the receive buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_GETRXBUFSIZ        0x011e
-
-/*! \brief UART _ioctl() command code to set the transmit buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_SETTXBUFLWMARK     0x0120
-
-/*! \brief UART _ioctl() command code to query the transmit buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_GETTXBUFLWMARK     0x0121
-
-/*! \brief UART _ioctl() command code to set the transmit buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_SETTXBUFHWMARK     0x0122
-
-/*! \brief UART _ioctl() command code to query the transmit buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_GETTXBUFHWMARK     0x0123
-
-/*! \brief UART _ioctl() command code to set the receive buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_SETRXBUFLWMARK     0x0124
-
-/*! \brief UART _ioctl() command code to query the receive buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_GETRXBUFLWMARK     0x0125
-
-/*! \brief UART _ioctl() command code to set the receive buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_SETRXBUFHWMARK     0x0126
-
-/*! \brief UART _ioctl() command code to query the receive buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
-#define UART_GETRXBUFHWMARK     0x0127
-
-/*! \brief UART _ioctl() command code to set the block read mode
-*
-* The configuration parameter specifies the block read mode.
-*/
-#define UART_SETBLOCKREAD       0x0128
-
-/*! \brief UART _ioctl() command code to query the receive buffer high watermark.
-*
-* The configuration parameter specifies the block read mode.
-*/
-#define UART_GETBLOCKREAD       0x0129
-
-/*! \brief UART _ioctl() command code to set physical device to the raw mode.
- *
- * The configuration parameter specifies the raw mode for device. In raw mode
- * data encapsulation is not allowed to be done. This allows other processing to
- * be done on physical device.
- */
-#define UART_SETRAWMODE         0x012a
-
-/*! \brief UART _ioctl() command code to query the raw mode.
- *
- * The configuration parameter specified the raw mode.
- */
-#define UART_GETRAWMODE         0x012b
-
-/*!
- * \addtogroup xgUARTStatus
- * \brief UART device status flags,
- *
- * A combination of these status flags is used by the _ioctl() commands
- * \ref UART_SETSTATUS and \ref UART_GETSTATUS. 
- */
-/*@{*/
-
-/*! \brief Framing error.
- *
- * \ref UART_SETSTATUS will clear this error.
- */
-#define UART_FRAMINGERROR   0x00000001UL
-
-/*! \brief Overrun error. 
- *
- * \ref UART_SETSTATUS will clear this error.
- */
-#define UART_OVERRUNERROR   0x00000002UL
-
-/*! \brief Parity error. 
- *
- * \ref UART_SETSTATUS will clear this error.
- */
-#define UART_PARITYERROR    0x00000004UL
-
-/*! \brief UART errors.
- *
- * \ref UART_SETSTATUS will clear all errors.
- */
-#define UART_ERRORS         (UART_FRAMINGERROR | UART_OVERRUNERROR | UART_PARITYERROR)
-
-/*! \brief Receiver buffer empty. 
- */
-#define UART_RXBUFFEREMPTY  0x00000040UL
-
-/*! \brief Transmitter buffer empty.
- *
- * \ref UART_SETSTATUS will immediately clear the buffer. It will not 
- * wait until the remaining characters have been transmitted.
- */
-#define UART_TXBUFFEREMPTY  0x00000080UL
-
-/*! \brief RTS handshake output enabled. 
- */
-#define UART_RTSENABLED     0x00000100UL
-
-/*! \brief RTS handshake output disabled. 
- */
-#define UART_RTSDISABLED    0x00000200UL
-
-/*! \brief CTS handshake input enabled. 
- */
-#define UART_CTSENABLED     0x00000400UL
-
-/*! \brief CTS handshake input disabled. 
- */
-#define UART_CTSDISABLED    0x00000800UL
-
-/*! \brief DTR handshake output enabled. 
- */
-#define UART_DTRENABLED     0x00001000UL
-
-/*! \brief DTR handshake output disabled. 
- */
-#define UART_DTRDISABLED    0x00002000UL
-
-/*! \brief Receiver enabled. 
- */
-#define UART_RXENABLED      0x00010000UL
-
-/*! \brief Receiver enabled. 
- */
-#define UART_RXDISABLED     0x00020000UL
-
-/*! \brief Transmitter enabled. 
- */
-#define UART_TXENABLED      0x00040000UL
-
-/*! \brief Transmitter enabled. 
- */
-#define UART_TXDISABLED     0x00080000UL
-
-/*! \brief Receive address frames only.
- *
- * Used in multidrop communication. May only work if 9 databits have 
- * been configured.
- */
-#define UART_RXADDRFRAME    0x00100000UL
-
-/*! \brief Receive all frames.
- *
- * Used in multidrop communication.
- */
-#define UART_RXNORMFRAME    0x00200000UL
-
-/*! \brief Transmit as address frame.
- *
- * Used in multidrop communication. May only work if 9 databits have 
- * been configured.
- */
-#define UART_TXADDRFRAME    0x00400000UL
-
-/*! \brief Transmit as normal frame.
- *
- * Used in multidrop communication.
- */
-#define UART_TXNORMFRAME    0x00800000UL
-
-
-/*@}*/
-
-/*!
- * \addtogroup xgUARTHS
- * \brief UART handshake modes.
- *
- * Any of these values may be used by the _ioctl() commands
- * \ref UART_SETFLOWCONTROL and \ref UART_GETFLOWCONTROL.
- */
-/*@{*/
-
-/*! \brief RTS / CTS hardware handshake.
- *
- * Nut/OS uses DTE definitions, where RTS is output and CTS is input.
- */
-#define UART_HS_RTSCTS      0x0003
-
-/*! \brief Full modem hardware handshake.
- *
- * Not supported yet by the standard drivers.
- */
-#define UART_HS_MODEM       0x001F
-
-/*! \brief XON / XOFF software handshake.
- *
- * It is recommended to set a proper read timeout with software handshake.
- * In this case a timeout may occur, if the communication peer lost our 
- * last XON character. The application may then use ioctl() to disable the 
- * receiver and do the read again. This will send out another XON.
- */
-#define UART_HS_SOFT        0x0020
-
-/*@}*/
-
-
-/*!
- * \addtogroup xgUARTClock
- * \brief UART device clock modes.
- *
- * Any of these values may be used by the _ioctl() commands
- * \ref UART_SETCLOCKMODE and \ref UART_GETCLOCKMODE. Most drivers
- * require to set the bit rate after modifying the clock mode. In order
- * to avoid unknown clock output frequencies in master mode, set the
- * clock mode to \ref UART_SYNCSLAVE first, than use \ref UART_SETSPEED 
- * to select the bit rate and finally switch to \ref UART_SYNCMASTER or 
- * \ref UART_NSYNCMASTER.
- */
-/*@{*/
-
-#define UART_SYNC           0x01
-#define UART_MASTER         0x02
-#define UART_NCLOCK         0x04
-#define UART_HIGHSPEED      0x20
-
-/*! \brief Normal asynchronous mode.
- */
-#define UART_ASYNC          0x00
-
-/*! \brief Synchronous slave mode.
- *
- * Transmit data changes on rising edge and receive data is sampled on 
- * the falling edge of the clock input.
- */
-#define UART_SYNCSLAVE     UART_SYNC
-
-/*! \brief Synchronous master mode.
- *
- * Transmit data changes on rising edge and receive data is sampled on 
- * the falling edge of the clock output.
- */
-#define UART_SYNCMASTER    (UART_SYNC | UART_MASTER)
-
-/*! \brief Synchronous slave mode, clock negated.
- *
- * Similar to \ref UART_SYNCSLAVE, but transmit data changes on falling 
- * edge and receive data is sampled on the rising edge of the clock input.
- */
-#define UART_NSYNCSLAVE    (UART_SYNC | UART_NCLOCK)
-
-/*! \brief Synchronous master mode, clock negated
- *
- * Similar to \ref UART_SYNCMASTER, but transmit data changes on falling 
- * edge and receive data is sampled on the rising edge of the clock output.
- */
-#define UART_NSYNCMASTER   (UART_SYNC | UART_NCLOCK | UART_MASTER)
-
-/*! \brief Asynchronous high speed mode.
- *
- * More deviation sensitive than normal mode, but supports higher speed.
- */
-#define UART_ASYNC_HS      UART_HIGHSPEED
-
-/*@}*/
-
-/*@}*/
-
-__BEGIN_DECLS
-/*
- * The following prototypes are misplaced and should be removed
- * from here.
- *
- * A note by Jan Dubiec: I suggest move them to dev/uart[01].c;
- * more, those files could be even merged.
- *
- */
-extern int UartAvrInit(NUTDEVICE * dev);
-extern int UartAvrIOCtl(NUTDEVICE * dev, int req, void *conf);
-extern int UartAvrInput(NUTDEVICE * dev);
-extern int UartAvrOutput(NUTDEVICE * dev);
-extern int UartAvrFlush(NUTDEVICE * dev);
-
-extern int UartAvrGetRaw(u_char * cp);
-extern int UartAvrPutRaw(u_char ch);
-
-extern int UartAvrRead(NUTFILE * fp, void *buffer, int size);
-extern int UartAvrWrite(NUTFILE * fp, CONST void *buffer, int len);
-#ifdef __HARVARD_ARCH__
-extern int UartAvrWrite_P(NUTFILE * fp, PGM_P buffer, int len);
-#endif
-extern NUTFILE *UartAvrOpen(NUTDEVICE * dev, CONST char *name, int mode, int acc);
-extern long UartAvrSize(NUTFILE * fp);
-extern int UartAvrClose(NUTFILE * fp);
-
-__END_DECLS
-#endif

+ 0 - 136
include/errno.h

@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 1993
- *	The Regents of the University of California.  All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 University 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 REGENTS 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 REGENTS 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.
- *
- *	@(#)errno.h	8.5 (Berkeley) 1/21/94
- */
-
-#ifndef _ERRNO_H_
-
-#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__)
-//  on an emulation platform, we need to use the native errno as it might 
-//  re-define errno (e.g. on red hat enterprise linux 3)
-#include <errno_orig.h>
-
-// define _ERRNO_H_ as the native system might use a different style
-#define _ERRNO_H_
-
-#else
-
-#define _ERRNO_H_
-
-extern int errno;			/* global error number */
-
-#define	EPERM		1		/* Operation not permitted */
-#define	ENOENT		2		/* No such file or directory */
-#define	ESRCH		3		/* No such process */
-#define	EINTR		4		/* Interrupted system call */
-#define	EIO		5		/* Input/output error */
-#define	ENXIO		6		/* Device not configured */
-#define	E2BIG		7		/* Argument list too long */
-#define	ENOEXEC		8		/* Exec format error */
-#define	EBADF		9		/* Bad file descriptor */
-#define	ECHILD		10		/* No child processes */
-#define	EDEADLK		11		/* Resource deadlock avoided */
-					/* 11 was EAGAIN */
-#define	ENOMEM		12		/* Cannot allocate memory */
-#define	EACCES		13		/* Permission denied */
-#define	EFAULT		14		/* Bad address */
-#define	ENOTBLK		15		/* Block device required */
-#define	EBUSY		16		/* Device busy */
-#define	EEXIST		17		/* File exists */
-#define	EXDEV		18		/* Cross-device link */
-#define	ENODEV		19		/* Operation not supported by device */
-#define	ENOTDIR		20		/* Not a directory */
-#define	EISDIR		21		/* Is a directory */
-#define	EINVAL		22		/* Invalid argument */
-#define	ENFILE		23		/* Too many open files in system */
-#define	EMFILE		24		/* Too many open files */
-#define	ENOTTY		25		/* Inappropriate ioctl for device */
-#define	ETXTBSY		26		/* Text file busy */
-#define	EFBIG		27		/* File too large */
-#define	ENOSPC		28		/* No space left on device */
-#define	ESPIPE		29		/* Illegal seek */
-#define	EROFS		30		/* Read-only file system */
-#define	EMLINK		31		/* Too many links */
-#define	EPIPE		32		/* Broken pipe */
-
-/* math software */
-#define	EDOM		33		/* Numerical argument out of domain */
-#define	ERANGE		34		/* Result too large */
-
-/* non-blocking and interrupt i/o */
-#define	EAGAIN		35		/* Resource temporarily unavailable */
-#define	EWOULDBLOCK	EAGAIN		/* Operation would block */
-#define	EINPROGRESS	36		/* Operation now in progress */
-#define	EALREADY	37		/* Operation already in progress */
-
-/* ipc/network software -- argument errors */
-#define	ENOTSOCK	38		/* Socket operation on non-socket */
-#define	EDESTADDRREQ	39		/* Destination address required */
-#define	EMSGSIZE	40		/* Message too long */
-#define	EPROTOTYPE	41		/* Protocol wrong type for socket */
-#define	ENOPROTOOPT	42		/* Protocol not available */
-#define	EPROTONOSUPPORT	43		/* Protocol not supported */
-#define	ESOCKTNOSUPPORT	44		/* Socket type not supported */
-#define	EOPNOTSUPP	45		/* Operation not supported */
-#define	EPFNOSUPPORT	46		/* Protocol family not supported */
-#define	EAFNOSUPPORT	47		/* Address family not supported by protocol family */
-#define	EADDRINUSE	48		/* Address already in use */
-#define	EADDRNOTAVAIL	49		/* Can't assign requested address */
-
-/* ipc/network software -- operational errors */
-#define	ENETDOWN	50		/* Network is down */
-#define	ENETUNREACH	51		/* Network is unreachable */
-#define	ENETRESET	52		/* Network dropped connection on reset */
-#define	ECONNABORTED	53		/* Software caused connection abort */
-#define	ECONNRESET	54		/* Connection reset by peer */
-#define	ENOBUFS		55		/* No buffer space available */
-#define	EISCONN		56		/* Socket is already connected */
-#define	ENOTCONN	57		/* Socket is not connected */
-#define	ESHUTDOWN	58		/* Can't send after socket shutdown */
-#define	ETOOMANYREFS	59		/* Too many references: can't splice */
-#define	ETIMEDOUT	60		/* Operation timed out */
-#define	ECONNREFUSED	61		/* Connection refused */
-
-#define	ELOOP		62		/* Too many levels of symbolic links */
-#define	ENAMETOOLONG	63		/* File name too long */
-
-/* should be rearranged */
-#define	EHOSTDOWN	64		/* Host is down */
-#define	EHOSTUNREACH	65		/* No route to host */
-#define	ENOTEMPTY	66		/* Directory not empty */
-
-#endif
-
-#endif
-

+ 0 - 137
include/fs/dospart.h

@@ -1,137 +0,0 @@
-#ifndef FS_DOSPART_H_
-#define FS_DOSPART_H_
-
-/*
- * Copyright (C) 2005 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file fs/dospart.h
- * \brief DOS partition table definitions.
- *
- * \verbatim
- *
- * $Log: dospart.h,v $
- * Revision 1.1  2006/01/05 16:32:26  haraldkipp
- * First check-in.
- *
- *
- * \endverbatim
- */
-
-#include <sys/types.h>
-
-/*!
- * \addtogroup xgPartition
- */
-/*@{*/
-
-/*!
- * \name Known partition types.
- */
-/*@{*/
-
-#define PTYPE_EMPTY         0x00
-#define PTYPE_FAT12         0x01
-#define PTYPE_FAT16         0x04
-#define PTYPE_DOS_EXT       0x05
-#define PTYPE_FAT16_BIG     0x06
-#define PTYPE_IFS           0x07
-#define PTYPE_OS2V1         0x08
-#define PTYPE_AIXDATA       0x09
-#define PTYPE_OS2BM         0x0A
-#define PTYPE_FAT32         0x0B
-#define PTYPE_FAT32_LBA     0x0C
-#define PTYPE_FAT16_LBA     0x0E
-#define PTYPE_EXT_LBA       0x0F
-#define PTYPE_OPUS          0x10
-#define PTYPE_FAT12_HIDDEN  0x11
-#define PTYPE_OEM           0x12
-#define PTYPE_FAT16_HIDDEN  0x14
-#define PTYPE_FAT16_BIGH    0x16
-#define PTYPE_IFS_HIDDEN    0x17
-#define PTYPE_AST_SLEEP     0x18
-#define PTYPE_FAT32_HIDDEN  0x1B
-#define PTYPE_FAT32_LBAH    0x1C
-#define PTYPE_FAT16_LBAH    0x1E
-#define PTYPE_DOS33_NEC     0x24
-#define PTYPE_JFS           0x35
-#define PTYPE_MINIX         0x41
-#define PTYPE_DYN           0x42
-#define PTYPE_UNIX_SYSV     0x63
-#define PTYPE_LINUX_SWAP    0x82
-#define PTYPE_LINUX         0x83
-#define PTYPE_PM_HIBERNATE  0x84
-#define PTYPE_LINUX_EXT     0x85
-#define PTYPE_FAT16_MULTI   0x86
-#define PTYPE_NTFS_MULTI    0x87
-#define PTYPE_LT_HIBERNATE  0xA0
-#define PTYPE_BSD           0xA5
-#define PTYPE_OPENBSD       0xA6
-#define PTYPE_MACOSX        0xA8
-#define PTYPE_NETBSD        0xA9
-#define PTYPE_MACOSX_BOOT   0xAB
-#define PTYPE_BSD_SWAP      0xB8
-#define PTYPE_CPM86         0xD8
-#define PTYPE_DATA          0xDA
-#define PTYPE_DRCPM         0xDB
-#define PTYPE_OEM_DELL      0xDE
-#define PTYPE_GPT           0xEE
-#define PTYPE_EFI           0xEF
-#define PTYPE_OEM_IBM       0xFE
-
-/*@}*/
-
-#define DOSPART_SECTORPOS   446
-
-/*!
- * \brief Partition table entry.
- *
- * Multibyte values are little endian.
- */
-typedef struct __attribute__ ((packed)) _DOSPART {
-    /*! \brief Boot descriptor. */
-    u_char part_state;
-    /*! \brief Partition start. */
-    u_char part_start[3];
-    /*! \brief Partition type. See PTYPE_ definitions. */
-    u_char part_type;
-    /*! \brief Partition end. */
-    u_char part_end[3];
-    /*! \brief First linear block address of this partition. */
-    u_long part_sect_offs;
-    /*! \brief Partition size in sectors. */
-    u_long part_sects;
-} DOSPART;
-
-/*@}*/
-
-#endif

+ 0 - 258
include/fs/phatvol.h

@@ -1,258 +0,0 @@
-#ifndef FS_PHATVOL_H_
-#define FS_PHATVOL_H_
-
-/*
- * <MFS> Modified for Streamit
- * added provison to avoid counting free clusters untill the first 'write' action
- *
- * 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file fs/phatvol.h
- * \brief PHAT file system.
- *
- * \verbatim
- *
- * $Log: phatvol.h,v $
- * Revision 1.4  2006/10/08 16:42:56  haraldkipp
- * Not optimal, but simple and reliable exclusive access implemented.
- * Fixes bug #1486539. Furthermore, bug #1567790, which had been rejected,
- * had been reported correctly and is now fixed.
- *
- * Revision 1.3  2006/07/11 12:20:19  haraldkipp
- * PHAT file system failed when accessed from multiple threads. A mutual
- * exclusion semaphore fixes this.
- *
- * Revision 1.2  2006/02/23 15:47:18  haraldkipp
- * PHAT file system now supports configurable number of sector buffers.
- *
- * Revision 1.1  2006/01/05 16:33:10  haraldkipp
- * First check-in.
- *
- *
- * \endverbatim
- */
-
-#include <cfg/fs.h>
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/device.h>
-
-/*!
- * \addtogroup xgPhatVol
- */
-/*@{*/
-
-/*!
- * \brief Volume boot record.
- */
-typedef struct __attribute__ ((packed)) _PHATVBR {
-    /*! \brief Jump instruction, contains E9xxxx or EBxx90. */
-    u_char boot_jump[3];
-    /*! \brief OEM name and version. */
-    u_char boot_oem[8];
-    /*! \brief Bytes per sector. 
-     *
-     * The BIOS parameter block starts here.
-     */
-    u_short bios_sectsz;
-    /*! \brief Sectors per cluster. */
-    u_char bios_clustsz;
-    /*! \brief Number of reserved sectors. 
-     *
-     * This includes the boot sector, which is typically the only
-     * reserved sector with PHAT12/16.
-     */
-    u_short bios_rsvd_sects;
-    /*! \brief Number of allocation tables. */
-    u_char bios_ntabs;
-    /*! \brief Number of root directory entries. */
-    u_short bios_rootsz;
-    /*! \brief Total number of sectors. */
-    u_short bios_volsz;
-    /*! \brief Media descriptor. */
-    u_char bios_media;
-    /*! \brief Number of sectors per allocation table.
-     *
-     * If zero, then the value is stored in bios_tabsz_big.
-     */
-    u_short bios_tabsz;
-    /*! \brief Number of sectors per track. */
-    u_short bios_sects_p_trk;
-    /*! \brief Number of heads. */
-    u_short bios_heads;
-    /*! \brief Number of hidden sectors. 
-     *
-     * With PHAT12 this field is two bytes only. We ignore it anyway.
-     */
-    u_long bios_sects_hidd;
-    /*! \brief Total number of sectors for huge drives. 
-     *
-     * Valid only if the value in bios_volsz is zero.
-     */
-    u_long bios_volsz_big;
-
-    /*! \brief Number of sectors per allocation table for huge drives.
-     *
-     * This and the following 6 fields are available with PHAT32 only.
-     */
-    u_long bios_tabsz_big;
-    /*! \brief Extended flags. 
-     *
-     * If bit 7 is set, then bits 0-3 specify the active allocation table.
-     * This feature is not yet supported. PHAT32 always updates the first
-     * two tables.
-     */
-    u_short bios_xflags;
-    /*! \brief File system version. */
-    u_short bios_fsver;
-    /*! \brief First cluster of root directory. */
-    u_long bios_root_clust;
-    /*! \brief File system info sector. */
-    u_short bios_fsinfo;
-    /*! \brief Boot backup sector. */
-    u_short bios_boot_bak;
-    /*! \brief Reserved for future expansion. 
-     *
-     * End of the BIOS parameter block.
-     */
-    u_char bios_rsvd32[12];
-
-    /*! \brief Logical drive number.
-     *
-     * With PHAT12 and PHAT16 this and the following fields
-     * are at offset 36.
-     */
-    u_char boot_drive;
-    /*! \brief Reserved field, used by Windows NT. */
-    u_char boot_rsvd_nt;
-    /*! \brief Extended signature.
-     *
-     * If 0x28 or 0x29, than the following fields are valid.
-     */
-    u_char boot_xsig;
-    /*! \brief Volume serial number. */
-    u_long boot_vol_id;
-    /*! \brief Volume label. */
-    u_char boot_vol_lbl[11];
-    /*! \brief File system. */
-    u_char boot_vol_fs[8];
-} PHATVBR;
-
-/*!
- * \brief Sector buffer structure.
- */
-typedef struct _PHATSECTBUF {
-    /*! \brief Sector data buffer. */
-    u_char *sect_data;
-    /*! \brief Sector currently stored in the buffer. */
-    u_long sect_num;
-    /*! \brief If not zero, buffer needs to be written. */
-    int sect_dirty;
-} PHATSECTBUF;
-
-/*!
- * \brief Volume info structure.
- */
-typedef struct _PHATVOL {
-    /*! \brief Type of volume.
-     *
-     * Either 12, 16 or 32.
-     */
-    int vol_type;
-    /*! \brief Number of free clusters. */
-    u_long vol_numfree;
-    /*! \brief Possibly next free cluster. */
-    u_long vol_nxtfree;
-    /*! \brief Sector buffer of this volume. */
-#if PHAT_SECTOR_BUFFERS
-    PHATSECTBUF vol_buf[PHAT_SECTOR_BUFFERS];
-    /*! \brief Next buffer to use. Simple round robin scheme. */
-    int vol_usenext;
-#else
-    PHATSECTBUF vol_buf[1];
-#endif
-    /*! \brief Mutual exclusion filesystem access semaphore. */
-    HANDLE vol_fsmutex;
-    /*! \brief Mutual exclusion I/O semaphore. */
-    HANDLE vol_iomutex;
-    /*! \brief Bytes per sector. */
-    u_int vol_sectsz;
-    /*! \brief Sectors per cluster. */
-    u_int vol_clustsz;
-
-    /*! \brief Number of sectors per allocation table. */
-    u_long vol_tabsz;
-    /*! \brief First sector of each allocation table. 
-     *
-     * We maintain upto two allocation tables.
-     */
-    u_long vol_tab_sect[2];
-
-    /*! \brief Number of sectors used by the root directory. */
-    u_int vol_rootsz;
-    /*! \brief First sector of the root directory. */
-    u_long vol_root_sect;
-    /*! \brief First cluster of the root directory. */
-    u_long vol_root_clust;
-
-    /*! \brief Last data cluster number.
-     *
-     * The first cluster number is 2, so this value is equal to the total
-     * number of data clusters plus 2.
-     */
-    u_long vol_last_clust;
-    /*! \brief First data sector. 
-     *
-     * The first sector following the root directory.
-     */
-    u_long vol_data_sect;
-    /*! \brief indicate if number of free clusters is valid
-     *
-     * Flag that indicates if the number of free clusters were counted
-     */
-    u_char vol_numfree_valid;
-
-} PHATVOL;
-
-/*@}*/
-
-__BEGIN_DECLS
-/* Prototypes */
-extern int PhatVolMount(NUTDEVICE * dev, NUTFILE * blkmnt, u_char part_type);
-extern int PhatVolUnmount(NUTDEVICE * dev);
-extern u_long PhatClusterSector(NUTFILE * nfp, u_long clust);
-extern u_long PhatCountFreeClustersFast(NUTDEVICE * dev);
-extern u_long PhatCountFreeClusters(NUTDEVICE * dev);
-
-__END_DECLS
-/* End of prototypes */
-#endif

+ 0 - 78
include/fs_org/fat.h

@@ -1,78 +0,0 @@
-/****************************************************************************
-*  This file is part of the AVRIDE device driver.
-*
-*  Copyright (c) 2002-2003 by Michael Fischer. 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 author 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 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.
-*
-****************************************************************************
-*  History:
-*
-*  14.12.02  mifi   First Version 
-*  18.01.03  mifi   Change Licence from GPL to BSD
-*  25.01.03  mifi   Change FAT32Init 
-*                   New function FAT32MountDrive and FAT32UnMountDrive
-*                   Remove FAT32_MAX_FILES, a file handle will be 
-*                   allocated by NutHeapAlloc, therefore we have no
-*                   restrictions about the count of the open file handle.
-*                   (Only by available memory)
-*  27.01.03  mifi   Rename all FAT32xxx function to FATxxx.
-*
-*  28.01.03  mifi   Start porting to Nut/OS 3.X.X
-*  29.06.03  mifi   First ATAPI-Version
-****************************************************************************/
-#ifndef __FAT_H__
-#define __FAT_H__
-
-#include <sys/device.h>
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-//
-// Device mode
-//
-#define FAT_MODE_IDE_HD         0x0001
-#define FAT_MODE_IDE_HD_7MHZ    0x0002
-#define FAT_MODE_IDE_CF         0x0003
-#define FAT_MODE_MEM_CF         0x0004
-
-/*-------------------------------------------------------------------------*/
-/* global types                                                            */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* global macros                                                           */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* Prototypes                                                              */
-/*-------------------------------------------------------------------------*/
-extern NUTDEVICE devFATC;
-
-#endif                          /* !__FAT_H__ */

+ 0 - 35
include/fs_org/fatfs.h

@@ -1,35 +0,0 @@
-/****************************************************************************
-*  This file is part of the AVRIDE device driver
-*
-*  Copyright (C) 2002  Michael Fischer <mifi42@web.de>
-*
-*  This program is free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  This program 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 General Public License for more details.
-*
-*  You should have received a copy of the GNU General Public License
-*  along with this program; if not, write to the Free Software
-*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-****************************************************************************
-*  History:
-*
-*  26.12.02  mifi   First Version 
-*                   Change FAT32FileSize return value from int to long
-****************************************************************************/
-#ifndef _FS_FATFS_H_
-#define _FS_FATFS_H_
-
-typedef void FILE;
-
-extern FILE *NutFileOpen(char *name);
-extern int   NutFileClose(FILE *romf);
-extern int   NutFileRead(FILE *romf, void *data, int size);
-extern long  NutFileSize(FILE *romf);
-
-#endif

+ 0 - 163
include/fs_org/fs.h

@@ -1,163 +0,0 @@
-#ifndef _FS_FS_H_
-#define _FS_FS_H_
-
-/*
- * Copyright (C) 2004-2005 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
-
-/*!
- * \file fs/fs.h
- * \brief File system access.
- *
- * \verbatim
- *
- * $Log: fs.h,v $
- * Revision 1.3  2006/01/05 16:45:25  haraldkipp
- * New ioctl functions.
- *
- * Revision 1.2  2005/08/05 11:28:25  olereinhardt
- * Corrected typo
- *
- * Revision 1.1  2005/02/05 20:37:18  haraldkipp
- * Peanut added
- *
- *
- * \endverbatim
- */
-
-#include <sys/file.h>
-
-/*!
- * \addtogroup xgFS
- */
-/*@{*/
-
-/*!
- * \name File System I/O Control Codes
- */
-/*@{*/
-
-/*!
- * \brief Obtain information about a specified file entry.
- */
-#define FS_STATUS       0x1101
-
-/*!
- * \brief Create a new directory entry.
- */
-#define FS_DIR_CREATE   0x1111
-
-/*!
- * \brief Remove a previously created directory entry.
- */
-#define FS_DIR_REMOVE   0x1112
-
-/*!
- * \brief Open a directory stream.
- */
-#define FS_DIR_OPEN     0x1113
-
-/*!
- * \brief Close a directory stream.
- */
-#define FS_DIR_CLOSE    0x1114
-
-/*!
- * \brief Read the next directory entry.
- */
-#define FS_DIR_READ     0x1115
-
-/*!
- * \brief Obtain information about an opened file.
- */
-#define FS_FILE_STATUS  0x1121
-
-/*!
- * \brief Remove a previously created file.
- */
-#define FS_FILE_DELETE  0x1122
-
-/*!
- * \brief Set a file pointer position.
- */
-#define FS_FILE_SEEK    0x1123
-
-/*@}*/
-
-#define FS_VOL_MOUNT         0x1130
-#define FS_VOL_UNMOUNT       0x1131
-#define FS_RENAME        0x1132
-#define NUTFS_UNLINK        0x1133
-#define NUTFS_MKDIR         0x1134
-#define NUTFS_RMDIR         0x1135
-
-/*!
- * \brief General structure for two arguments.
- *
- * Used to pass two arguments to an I/O control function.
- */
-typedef struct {
-    void *arg1;
-    void *arg2;
-} IOCTL_ARG2;
-
-/*!
- * \brief General structure for three arguments.
- *
- * Used to pass three arguments to an I/O control function.
- */
-typedef struct {
-    void *arg1;
-    void *arg2;
-    void *arg3;
-} IOCTL_ARG3;
-
-typedef struct _FSCP_VOL_MOUNT {
-    /*! \brief Block device mount. */
-    NUTFILE *fscp_bmnt;
-    /*! \brief Partition type. */
-    u_char fscp_part_type;
-} FSCP_VOL_MOUNT;
-
-typedef struct _FSCP_RENAME {
-    char *par_old;
-    char *par_new;
-} FSCP_RENAME;
-
-typedef struct _FSCP_STATUS {
-    CONST char *par_path;
-    struct stat *par_stp;
-} FSCP_STATUS;
-
-/*@}*/
-
-#endif

+ 0 - 186
include/fs_org/phatdir.h

@@ -1,186 +0,0 @@
-#ifndef FS_PHATDIR_H_
-#define FS_PHATDIR_H_
-
-/*
- * Copyright (C) 2005-2006 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file fs/phatdir.h
- * \brief PHAT file system.
- *
- * \verbatim
- *
- * $Log: phatdir.h,v $
- * Revision 1.3  2006/10/08 16:42:56  haraldkipp
- * Not optimal, but simple and reliable exclusive access implemented.
- * Fixes bug #1486539. Furthermore, bug #1567790, which had been rejected,
- * had been reported correctly and is now fixed.
- *
- * Revision 1.2  2006/06/18 16:41:55  haraldkipp
- * Support for long filenames (VFAT) added.
- * New function PhatDirReleaseChain() simplifies code.
- * Static function PhatDirOpenParentPath() replaced by global
- * PhatDirOpenParent().
- * Added const attribute to path parameter of PhatDirOpen().
- *
- * Revision 1.1  2006/01/05 16:32:52  haraldkipp
- * First check-in.
- *
- *
- * \endverbatim
- */
-
-#include <dirent.h>
-#include <sys/stat.h>
-
-/*!
- * \addtogroup xgPhatDir
- */
-/*@{*/
-
-/*!
- * \brief Maximum length of a base file name.
- */
-#ifndef PHAT_MAX_NAMELEN
-#define PHAT_MAX_NAMELEN    255
-#endif
-
-#define PHAT_REM_DIRENT  0xE5
-#define PHAT_REM_NAMENT  0x05
-
-/*!
- * \brief Structure of a directory entry.
- *
- * Once created, this structure will never change if it points
- * to another directory. Except if the entry is removed.
- */
-typedef struct __attribute__ ((packed)) _PHATDIRENT {
-    /*! \brief File name, padded with blanks. */
-    u_char dent_name[11];
-    /*! \brief File attributes. 
-     *
-     * See PHAT_FATTR_ flags. 
-     */
-    u_char dent_attr;
-    /*! \brief Reserved byte, possibly used by NT. */
-    u_char dent_rsvdnt;
-    /*! \brief Hundredth of seconds of file creation time. */
-    u_char dent_ctsecs;
-    /*! \brief File creation time. */
-    u_short dent_ctime;
-    /*! \brief File creation date. */
-    u_short dent_cdate;
-    /*! \brief Last file access date. */
-    u_short dent_adate;
-    /*! \brief High bytes of first cluster of this file.
-     *
-     * If used with the double dot entry, dent_clusthi and dent_clust
-     * must be zero if the entry points to the root directory.
-     *
-     * The same is true when pointing to a normal file with zero
-     * length.
-     */
-    u_short dent_clusthi;
-    /*! \brief Last file modification time. */
-    u_short dent_mtime;
-    /*! \brief Last file modification date. */
-    u_short dent_mdate;
-    /*! \brief First cluster used.
-     *
-     * This is zero for empty files.
-     */
-    u_short dent_clust;
-    /*! \brief Size of the file in bytes. 
-     *
-     * For directories, this is always zero.
-     */
-    u_long dent_fsize;
-} PHATDIRENT;
-
-/*!
- * \brief Structure of an extended directory entry.
- *
- * Used for long filenames.
- */
-typedef struct __attribute__ ((packed)) _PHATXDIRENT {
-    /*! \brief Sequence number. */
-    u_char xdent_seq;
-    /*! \brief Unicode characters 1-5. */
-    u_short xdent_uname_1_5[5];
-    /*! \brief Attribut. */
-    u_char xdent_attr;
-    /*! \brief Type. */
-    u_char xdent_rsvd;
-    /*! \brief Checksum. */
-    u_char xdent_cks;
-    /*! \brief Unicode characters 6-11. */
-    u_short xdent_uname_6_11[6];
-    /*! \brief Starting cluster. */
-    u_short xdent_clust;
-    /*! \brief Unicode characters 12-13. */
-    u_short xdent_uname_12_13[2];
-} PHATXDIRENT;
-
-typedef struct _PHATFIND {
-    PHATDIRENT phfind_ent;
-    u_long phfind_pos;
-    /*! Number of entries used for the long filename. */
-    int phfind_xcnt;
-    char phfind_name[PHAT_MAX_NAMELEN];
-} PHATFIND;
-
-/*@}*/
-
-__BEGIN_DECLS
-/* Prototypes */
-extern int PhatDirEntryCreate(NUTFILE * ndp, CONST char *name, int acc, PHATDIRENT * dirent);
-
-extern int PhatDirEntryUpdate(NUTFILE * ndp);
-
-extern int PhatDirReleaseChain(NUTDEVICE * dev, PHATDIRENT * dent);
-
-extern int PhatDirDelEntry(NUTDEVICE * dev, CONST char *path, u_long flags);
-extern int PhatDirRenameEntry(NUTDEVICE * dev, CONST char *old_path, CONST char *new_path);
-
-extern NUTFILE *PhatDirOpen(NUTDEVICE * dev, CONST char *dpath);
-extern NUTFILE *PhatDirOpenParent(NUTDEVICE * dev, CONST char *path, CONST char **basename);
-extern int PhatDirEntryFind(NUTFILE * nfp, CONST char *spec, u_long flags, PHATFIND * srch);
-extern int PhatDirRead(DIR * dir);
-
-extern int PhatDirCreate(NUTDEVICE * dev, char *path);
-extern int PhatDirRemove(NUTDEVICE * dev, char *path);
-
-extern int PhatDirEntryStatus(NUTDEVICE * dev, CONST char *path, struct stat *s);
-
-__END_DECLS
-/* End of prototypes */
-#endif

+ 0 - 161
include/fs_org/phatfs.h

@@ -1,161 +0,0 @@
-#ifndef FS_PHATFS_H_
-#define FS_PHATFS_H_
-
-/*
- * Copyright (C) 2005-2006 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- */
-
-/*!
- * \file fs/phatfs.h
- * \brief PHAT file system.
- *
- * \verbatim
- *
- * $Log: phatfs.h,v $
- * Revision 1.5  2006/10/08 16:42:56  haraldkipp
- * Not optimal, but simple and reliable exclusive access implemented.
- * Fixes bug #1486539. Furthermore, bug #1567790, which had been rejected,
- * had been reported correctly and is now fixed.
- *
- * Revision 1.4  2006/06/18 16:42:50  haraldkipp
- * Support for long filenames (VFAT) added.
- *
- * Revision 1.3  2006/05/15 11:48:38  haraldkipp
- * Added a second PHAT file system instance.
- *
- * Revision 1.2  2006/01/22 17:44:20  haraldkipp
- * ICCAVR failed to find local header files.
- *
- * Revision 1.1  2006/01/05 16:32:57  haraldkipp
- * First check-in.
- *
- *
- * \endverbatim
- */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/device.h>
-
-#include <fs/phatdir.h>
-
-/*!
- * \addtogroup xgPhatFs
- */
-/*@{*/
-
-/*!
- * \brief PHAT file descriptor structure.
- */
-typedef struct _PHATFILE {
-    /*! \brief Current position into the file. */
-    u_long f_pos;
-    /*! \brief Current cluster. */
-    u_long f_clust;
-    /*! \brief Sector within the current cluster. */
-    u_long f_clust_pos;
-    /*! \brief Position within the sector. */
-    u_long f_sect_pos;
-    /*! \brief Previous cluster used, */
-    u_long f_clust_prv;
-    /*! \brief File open mode flags. */
-    u_long f_mode;
-    /*! \brief Directory entry of this file. */
-    PHATDIRENT f_dirent;
-    /*! \brief Sector of the directory entry.
-     *
-     * For the root directory this value is zero, because the root
-     * doesn't have any entry in another directory.
-     */
-    u_long f_de_sect;
-    /*! \brief Offset into the sector containing the directory entry. */
-    u_long f_de_offs;
-    /*! \brief Directory entry change marker. */
-    u_int f_de_dirty;
-    /*! \brief First cluster of the parent directory, low word. 
-     *
-     * Our directory entry is located in this cluster.
-     */
-    u_short f_pde_clust;
-    /*! \brief First cluster of the parent directory, high word. */
-    u_short f_pde_clusthi;
-} PHATFILE;
-
-/*! \brief Marks end of cluster chain. */
-#define PHATEOC     0x0FFFFFF8
-
-/*!
- * \name File attributes.
- */
-/*@{*/
-
-/*! Read only file. */
-#define PHAT_FATTR_RDONLY    0x01
-/*! Hidden file. */
-#define PHAT_FATTR_HIDDEN    0x02
-/*! System file. */
-#define PHAT_FATTR_SYSTEM    0x04
-/*! No file, but a volume label. */
-#define PHAT_FATTR_VOLID     0x08
-/*! File contains a subdirectory. */
-#define PHAT_FATTR_DIR       0x10
-/*! File is not archived. This flag will be set when the file is created
- * or modified.
- */
-#define PHAT_FATTR_ARCHIV    0x20
-
-/*! Long filename entry. */
-#define PHAT_FATTR_LFN      (PHAT_FATTR_RDONLY | PHAT_FATTR_HIDDEN | PHAT_FATTR_SYSTEM | PHAT_FATTR_VOLID)
-
-/*! Only these flags are allowed for files and directories. */
-#define PHAT_FATTR_FILEMASK  0x37
-
-/*@}*/
-
-
-#include <fs/phat12.h>
-#include <fs/phat16.h>
-#include <fs/phat32.h>
-
-extern NUTDEVICE devPhat0;
-extern NUTDEVICE devPhat1;
-
-extern u_long AllocFirstCluster(NUTFILE * nfp);
-
-extern NUTFILE *PhatFileOpen(NUTDEVICE * dev, CONST char *path, int mode, int acc);
-extern int PhatFileClose(NUTFILE * nfp);
-extern int PhatFileWrite(NUTFILE * nfp, CONST void *buffer, int len);
-#ifdef __HARVARD_ARCH__
-extern int PhatFileWrite_P(NUTFILE * nfp, PGM_P buffer, int len);
-#endif
-extern int PhatFileRead(NUTFILE * nfp, void *buffer, int size);
-
-#endif

+ 0 - 120
include/fs_org/uromfs.h

@@ -1,120 +0,0 @@
-#ifndef _FS_UROMFS_H_
-#define _FS_UROMFS_H_
-
-/*
- * Copyright (C) 2001-2004 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
-
-/*
- * $Log: uromfs.h,v $
- * Revision 1.4  2006/01/05 16:45:29  haraldkipp
- * Size and pos types changed to support 32 bit targets.
- *
- * Revision 1.3  2004/03/18 11:38:09  haraldkipp
- * Deprecated functions removed
- *
- * Revision 1.2  2003/07/20 19:27:59  haraldkipp
- * Patch by Alessandro Zummo. Moves the urom filesystem filenames to
- * AVR's flash memory.
- *
- * Revision 1.1.1.1  2003/05/09 14:41:10  haraldkipp
- * Initial using 3.2.1
- *
- * Revision 1.8  2003/02/04 18:00:41  harald
- * Version 3 released
- *
- * Revision 1.7  2003/01/14 16:34:21  harald
- * *** empty log message ***
- *
- * Revision 1.6  2002/11/02 15:17:00  harald
- * Library dependencies moved to compiler.h
- *
- * Revision 1.5  2002/07/03 16:45:40  harald
- * Using GCC 3.2
- *
- * Revision 1.4  2002/06/26 17:29:17  harald
- * First pre-release with 2.4 stack
- *
- */
-#include <stddef.h>
-#include <sys/types.h>
-
-/*!
- * \file fs/uromfs.h
- * \brief Micro-ROM file system definitions.
- */
-
-/*!
- * \brief Mikro-ROM directory entry type.
- */
-typedef struct _ROMENTRY ROMENTRY;
-
-/*!
- * \struct _ROMENTRY uromfs.h fs/uromfs.h
- * \brief Mikro-ROM directory entry structure.
- */
-#ifdef __IMAGECRAFT__
-struct _ROMENTRY {
-    ROMENTRY *rome_next;    /*!< Link to next ROMENTRY structure. */
-    const u_char *rome_name;/*!< Filename. */
-    u_int rome_size;        /*!< File size. */
-    const char *rome_data;  /*!< File data. */
-};
-#else
-struct _ROMENTRY {
-    ROMENTRY *rome_next;    /*!< Link to next ROMENTRY structure. */
-    prog_char *rome_name;   /*!< Filename. */
-    u_int rome_size;        /*!< File size. */
-    prog_char *rome_data;   /* __attribute__ ((progmem));  !< File data. */
-};
-#endif
-
-/*!
- * \brief Mikro-ROM file information type.
- */
-typedef struct _ROMFILE ROMFILE;
-
-/*!
- * \struct _ROMFILE uromfs.h fs/uromfs.h
- * \brief Mikro-ROM file information structure.
- */
-struct _ROMFILE {
-    ROMENTRY *romf_entry;   /*!< Points to ROMENTRY */
-    u_int romf_pos;      /*!< Current read position. */
-};
-
-/*!
- * \brief Linked list of all microROM files.
- */
-extern ROMENTRY *romEntryList;
-
-#endif

+ 0 - 141
include/sys/heap.h

@@ -1,141 +0,0 @@
-#ifndef _SYS_HEAP_H_
-#define _SYS_HEAP_H_
-
-/*
- * Copyright (C) 2001-2003 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- * -
- * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk>
- *
- * This file 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.
- *
- * You can redistribute this file and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software Foundation;
- * either version 2 of the License, or (at your discretion) any later version.
- * See the accompanying file "copying-gpl.txt" for more details.
- *
- * As a special exception to the GPL, permission is granted for additional
- * uses of the text contained in this file.  See the accompanying file
- * "copying-liquorice.txt" for details.
- */
-
-/*
- * $Log: heap.h,v $
- * Revision 1.4  2006/10/06 23:19:08  hwmaier
- * Added include statement for cfg/memory.h so the macro NUTMEM_STACKHEAP is found when compiling for the AT90CAN128.
- *
- * Revision 1.3  2006/09/29 12:26:14  haraldkipp
- * All code should use dedicated stack allocation routines. For targets
- * allocating stack from the normal heap the API calls are remapped by
- * preprocessor macros.
- * Stack allocation code moved from thread module to heap module.
- * Adding static attribute to variable 'available' will avoid interference
- * with application code. The ugly format macros had been replaced by
- * converting all platform specific sizes to unsigned integers.
- *
- * Revision 1.2  2004/03/16 16:48:44  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- * Revision 1.1.1.1  2003/05/09 14:41:20  haraldkipp
- * Initial using 3.2.1
- *
- * Revision 1.7  2003/02/04 18:00:52  harald
- * Version 3 released
- *
- * Revision 1.6  2002/06/26 17:29:28  harald
- * First pre-release with 2.4 stack
- *
- */
-
-#include <cfg/memory.h>
-#include <sys/types.h>
-
-/*!
- * \file sys/heap.h
- * \brief Heap management definitions.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- * \struct _HEAPNODE heap.h sys/heap.h
- * \brief Heap memory node information structure.
- */
-/*!
- * \typedef HEAPNODE
- * \brief Heap memory node type.
- */
-typedef struct _HEAPNODE {
-    size_t hn_size;             /*!< \brief Size of this node. */
-    struct _HEAPNODE *hn_next;  /*!< \brief Link to next free node. */
-} HEAPNODE;
-
-extern HEAPNODE* volatile heapFreeList;
-
-
-/*!
- * \brief Allocation threshold.
- *
- * Might be increased to avoid creating
- * too many small nodes.
- */
-#define ALLOC_THRESHOLD 6
-
-extern void *NutHeapAlloc(size_t size);
-extern void *NutHeapAllocClear(size_t size);
-extern int NutHeapFree(void *block);
-extern void NutHeapAdd(void *addr, size_t size);
-extern size_t NutHeapAvailable(void);
-
-#if defined (NUTMEM_STACKHEAP)
-
-/* Dedicated stack memory. */
-extern void *NutStackAlloc(size_t size);
-extern int NutStackFree(void *block);
-extern void NutStackAdd(void *addr, size_t size);
-
-#else /* !NUTMEM_STACKHEAP */
-
-/* Thread stacks resides in normal heap. */
-#define NutStackAlloc(size)     NutHeapAlloc(size)
-#define NutStackFree(block)     NutHeapFree(block)
-
-#endif /* !NUTMEM_STACKHEAP */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 0 - 221
include/sys/thread.h

@@ -1,221 +0,0 @@
-#ifndef _SYS_THREAD_H_
-#define _SYS_THREAD_H_
-
-/*
- * Copyright (C) 2001-2006 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- * -
- * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk>
- *
- * This file 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.
- *
- * You can redistribute this file and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software Foundation;
- * either version 2 of the License, or (at your discretion) any later version.
- * See the accompanying file "copying-gpl.txt" for more details.
- *
- * As a special exception to the GPL, permission is granted for additional
- * uses of the text contained in this file.  See the accompanying file
- * "copying-liquorice.txt" for details.
- */
-
-/*!
- * \file sys/thread.h
- * \brief Thread management definitions.
- *
- * \verbatim
- *
- * $Log: thread.h,v $
- * Revision 1.15  2006/09/29 12:24:14  haraldkipp
- * Stack allocation code moved from thread module to heap module.
- * All code should use dedicated stack allocation routines. For targets
- * allocating stack from the normal heap the API calls are remapped by
- * preprocessor macros.
- *
- * Revision 1.14  2006/06/29 03:52:19  hwmaier
- * Added include statement for cfg/memory.h so the macro
- * NUTMEM_STACKHEAP is found when compiling for the
- * AT90CAN128.
- *
- * Revision 1.13  2006/06/28 14:35:31  haraldkipp
- * Event/thread/timer re-design.
- * Code indention corrected.
- * Volatile attribute removed from THREADINFO link pointer.
- *
- * Revision 1.12  2006/03/16 15:25:34  haraldkipp
- * Changed human readable strings from u_char to char to stop GCC 4 from
- * nagging about signedness.
- *
- * Revision 1.11  2005/10/07 21:48:25  hwmaier
- * Using __AVR_ENHANCED__ macro instead of __AVR_ATmega128__ to support also AT90CAN128 MCU
- *
- * Revision 1.10  2005/10/04 05:25:17  hwmaier
- * Added support for separating stack and conventional heap as required by AT09CAN128 MCUs
- *
- * Revision 1.9  2005/08/02 17:46:49  haraldkipp
- * Major API documentation update.
- *
- * Revision 1.8  2005/07/26 15:49:59  haraldkipp
- * Cygwin support added.
- *
- * Revision 1.7  2005/02/17 14:42:37  phblum
- * Removed volatile declarations of runQueue since it is not touched from interrupt context. Same for nutThreadList, runningThread and killedThreads.
- *
- * Revision 1.6  2005/02/16 19:53:15  haraldkipp
- * Ready-to-run queue handling removed from interrupt context.
- *
- * Revision 1.5  2004/07/09 19:51:34  freckle
- * Added new function NutThreadSetSleepMode to tell nut/os to set the MCU
- * into sleep mode when idle (avr-gcc && avr128 only)
- *
- * Revision 1.4  2004/04/07 12:13:57  haraldkipp
- * Matthias Ringwald's *nix emulation added
- *
- * Revision 1.3  2004/03/16 16:48:44  haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- * Revision 1.2  2003/12/15 19:28:26  haraldkipp
- * Kill function prototypes
- *
- * Revision 1.1.1.1  2003/05/09 14:41:22  haraldkipp
- * Initial using 3.2.1
- *
- * Revision 1.14  2003/02/04 18:00:54  harald
- * Version 3 released
- *
- * Revision 1.13  2002/10/29 15:40:50  harald
- * *** empty log message ***
- *
- * Revision 1.12  2002/06/26 17:29:29  harald
- * First pre-release with 2.4 stack
- *
- * \endverbatim
- */
-
-#include <sys/types.h>
-#include <cfg/memory.h>
-
-#define DEADBEEF    0xDEADBEEF
-
-
-/*!
- * \addtogroup xgThread
- */
-/*@{*/
-
-/*!
- * Thread information structure type.
- */
-typedef struct _NUTTHREADINFO NUTTHREADINFO;
-
-/*!
- * \struct _NUTTHREADINFO thread.h sys/thread.h
- * \brief Thread information structure.
- *
- * \todo Sort items while considering alignment.
- */
-
-struct _NUTTHREADINFO {
-    NUTTHREADINFO *td_next;     /*!< \brief Linked list of all threads. */
-    NUTTHREADINFO *td_qnxt;     /*!< \brief Linked list of all queued thread. */
-    volatile u_int td_qpec;     /*!< \brief Pending event counter. */
-    char td_name[9];            /*!< \brief Name of this thread. */
-    u_char td_state;            /*!< \brief Operating state. One of TDS_ */
-    uptr_t td_sp;               /*!< \brief Stack pointer. */
-    u_char td_priority;         /*!< \brief Priority level. 0 is highest priority. */
-    u_char *td_memory;          /*!< \brief Pointer to heap memory used for stack. */
-    HANDLE td_timer;            /*!< \brief Event timer. */
-    volatile HANDLE td_queue;   /*!< \brief Root entry of the waiting queue. */
-#if defined (__APPLE__) || defined(__linux__) || defined(__CYGWIN__)
-    pthread_t td_pthread;       /*!< \brief pthread for unix emulations. */
-    void (*td_fn) (void *);     /*!< \brief thread function */
-    void *td_arg;               /*!< \brief args given to NutCreateThread */
-    pthread_cond_t td_cv;       /*!< \brief conditional variable for unix emulations. */
-    u_short td_cs_level;        /*! \brief number critical sections has been entered without leaving */
-#endif
-};
-/*@}*/
-
-/*!
- * \name Thread States
- */
-/*@{*/
-#define TDS_TERM        0       /*!< Thread has exited. */
-#define TDS_RUNNING     1       /*!< Thread is running. */
-#define TDS_READY       2       /*!< Thread is ready to run. */
-#define TDS_SLEEP       3       /*!< Thread is sleeping. */
-/*@}*/
-
-#define SLEEP_MODE_NONE 0xff
-
-extern NUTTHREADINFO *runningThread;
-extern NUTTHREADINFO *nutThreadList;
-extern NUTTHREADINFO *runQueue;
-
-__BEGIN_DECLS
-/* Function prototypes. */
-#if defined (__APPLE__) || defined(__linux__) || defined(__CYGWIN__)
-extern void NutThreadInit(void);
-#endif
-
-#if defined(__GNUC__) && defined (__AVR_ENHANCED__)
-extern void NutThreadSetSleepMode(u_char mode);
-#endif
-
-extern HANDLE NutThreadCreate(char *name, void (*fn) (void *), void *arg, size_t stackSize);
-extern u_char NutThreadSetPriority(u_char level);
-
-extern void NutThreadKill(void);
-extern void NutThreadDestroy(void);
-extern void NutThreadExit(void);
-
-extern void NutThreadResume(void);
-extern void NutThreadWake(HANDLE timer, HANDLE th);
-extern void NutThreadYield(void);
-
-extern void NutThreadAddPriQueue(NUTTHREADINFO * td, NUTTHREADINFO * volatile *tqpp);
-extern void NutThreadRemoveQueue(NUTTHREADINFO * td, NUTTHREADINFO * volatile *tqpp);
-
-extern void NutThreadSwitch(void);
-extern HANDLE GetThreadByName(char *name);
-
-/*!
- * \brief Macro for thread entry definitions.
- */
-#define THREAD(threadfn, arg) \
-void threadfn(void *arg) __attribute__ ((noreturn)); \
-void threadfn(void *arg)
-
-__END_DECLS
-/* */
-#endif

+ 0 - 115
include/watchdog.h

@@ -1,115 +0,0 @@
-#ifndef _watchdog_H
-#define _watchdog_H
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : watchdog
- *  File name  $Workfile: watchdog.h  $
- *       Last Save $Date: 2007/01/16 11:13:53  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2007/01/16 11:13:53
- *
- *  Description         : Watchdog routines for the ATMega128/256
- *                        Inspired by the arch/xxx/dev/watchdog routines in
- *                        NutOS 4.2.1 and higher.
- *
- */
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*!
- * \brief Start the watch dog timer.
- *
- * This function can be used by applications to prevent hang-ups.
- * The watch dog timer will be automatically enabled on return.
- *
- * \param   ms [in] Watch dog time out in milliseconds.
- *
- * \return  -
- *
- * The following code fragment starts the watch timer with a time out
- * of 550 milliseconds and restarts it every 500 milliseconds.
- *
- * \code
- * #include <sys/timer.h>
- * #include "watchdog.h"
- *
- * WatchDogStart(550);
- * for(;;)
- * {
- *     WatchDogRestart();
- *     NutSleep(500);
- * }
- *
- * \endcode
- */
-extern void WatchDogStart(unsigned long ms);
-
-
-/*!
- * \brief Restart the watch dog timer.
- */
-extern void WatchDogRestart(void);
-
-/*!
- * \brief Disables the watch dog timer.
- *
- * Applications should call this function to temporarily disable the
- * watch dog timer. To re-enable it, call WatchDogEnable().
- *
- * \code
- * #include <dev/watchdog.h>
- *
- * WatchDogStart(100, 0);
- *
- * //Some code here.
- *
- * WatchDogRestart();
- *
- * //Some code here.
- *
- * WatchDogDisable();
- *
- * //Some lengthy code here, like writing to flash memory.
- *
- * WatchDogEnable();
- *
- * \endcode
- */
-extern void WatchDogDisable(void);
-
-/*!
- * \brief Enables the watch dog timer.
- *
- * The function can be safely used within nested subroutines.
- * The watch dog will be enabled only, if this function is called
- * the same number of times as WatchDogDisable(). If enabled,
- * the watch dog timer will also have been re-started and the
- * full time out value is available before another WatchDogRestart()
- * is required.
- *
- * If the watch has not been started by WatchDogStart(), then this
- * function does nothing.
- */
-extern void WatchDogEnable(void);
-
-#endif /* _watchdog_H */

+ 223 - 223
source/display.c → lib/display.c

@@ -1,223 +1,223 @@
-/* ========================================================================
- * [PROJECT]    SIR100
- * [MODULE]     Display
- * [TITLE]      display source file
- * [FILE]       display.c
- * [VSN]        1.0
- * [CREATED]    26092003
- * [LASTCHNGD]  06102006
- * [COPYRIGHT]  Copyright (C) STREAMIT BV
- * [PURPOSE]    contains all interface- and low-level routines to
- *              control the LCD and write characters or strings (menu-items)
- * ======================================================================== */
-
-#define LOG_MODULE  LOG_DISPLAY_MODULE
-
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/timer.h>
-#include <sys/event.h>
-#include <sys/thread.h>
-#include <sys/heap.h>
-
-#include "system.h"
-#include "portio.h"
-#include "display.h"
-#include "log.h"
-
-/*-------------------------------------------------------------------------*/
-/* local defines                                                           */
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-
-
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-static void LcdWriteByte(u_char, u_char);
-static void LcdWriteNibble(u_char, u_char);
-static void LcdWaitBusy(void);
-
-/*!
- * \addtogroup Display
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief control backlight
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-void LcdBackLight(u_char Mode)
-{
-    if (Mode==LCD_BACKLIGHT_ON)
-    {
-        sbi(LCD_BL_PORT, LCD_BL_BIT);   // Turn on backlight
-    }
-
-    if (Mode==LCD_BACKLIGHT_OFF)
-    {
-        cbi(LCD_BL_PORT, LCD_BL_BIT);   // Turn off backlight
-    }
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Write a single character on the LCD
- *
- * Writes a single character on the LCD on the current cursor position
- *
- * \param LcdChar character to write
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-void LcdChar(char MyChar)
-{
-    LcdWriteByte(WRITE_DATA, MyChar);
-}
-
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Low-level initialisation function of the LCD-controller
- *
- * Initialise the controller and send the User-Defined Characters to CG-RAM
- * settings: 4-bit interface, cursor invisible and NOT blinking
- *           1 line dislay, 10 dots high characters
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
- void LcdLowLevelInit()
-{
-    u_char i;
-
-    NutDelay(140);                               // wait for more than 140 ms after Vdd rises to 2.7 V
-
-    for (i=0; i<3; ++i)
-    {
-        LcdWriteNibble(WRITE_COMMAND, 0x33);      // function set: 8-bit mode; necessary to guarantee that
-        NutDelay(4);                              // SIR starts up always in 5x10 dot mode
-    }
-
-    LcdWriteNibble(WRITE_COMMAND, 0x22);        // function set: 4-bit mode; necessary because KS0070 doesn't
-    NutDelay(1);                                // accept combined 4-bit mode & 5x10 dot mode programming
-
-    //LcdWriteByte(WRITE_COMMAND, 0x24);        // function set: 4-bit mode, 5x10 dot mode, 1-line
-    LcdWriteByte(WRITE_COMMAND, 0x28);          // function set: 4-bit mode, 5x7 dot mode, 2-lines
-    NutDelay(5);
-
-    LcdWriteByte(WRITE_COMMAND, 0x0C);          // display ON/OFF: display ON, cursor OFF, blink OFF
-    NutDelay(5);
-
-    LcdWriteByte(WRITE_COMMAND, 0x01);          // display clear
-    NutDelay(5);
-
-    LcdWriteByte(WRITE_COMMAND, 0x06);          // entry mode set: increment mode, entire shift OFF
-
-
-    LcdWriteByte(WRITE_COMMAND, 0x80);          // DD-RAM address counter (cursor pos) to '0'
-}
-
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Low-level routine to write a byte to LCD-controller
- *
- * Writes one byte to the LCD-controller (by  calling LcdWriteNibble twice)
- * CtrlState determines if the byte is written to the instruction register
- * or to the data register.
- *
- * \param CtrlState destination: instruction or data
- * \param LcdByte byte to write
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static void LcdWriteByte(u_char CtrlState, u_char LcdByte)
-{
-    LcdWaitBusy();                      // see if the controller is ready to receive next byte
-    LcdWriteNibble(CtrlState, LcdByte & 0xF0);
-    LcdWriteNibble(CtrlState, LcdByte << 4);
-
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Low-level routine to write a nibble to LCD-controller
- *
- * Writes a nibble to the LCD-controller (interface is a 4-bit databus, so
- * only 4 databits can be send at once).
- * The nibble to write is in the upper 4 bits of LcdNibble
- *
- * \param CtrlState destination: instruction or data
- * \param LcdNibble nibble to write (upper 4 bits in this byte
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static void LcdWriteNibble(u_char CtrlState, u_char LcdNibble)
-{
-    outp((inp(LCD_DATA_DDR) & 0x0F) | 0xF0, LCD_DATA_DDR);  // set data-port to output again
-
-    outp((inp(LCD_DATA_PORT) & 0x0F) | (LcdNibble & 0xF0), LCD_DATA_PORT); // prepare databus with nibble to write
-
-    if (CtrlState == WRITE_COMMAND)
-    {
-        cbi(LCD_RS_PORT, LCD_RS);     // command: RS low
-    }
-    else
-    {
-        sbi(LCD_RS_PORT, LCD_RS);     // data: RS high
-    }
-
-    sbi(LCD_EN_PORT, LCD_EN);
-
-    asm("nop\n\tnop");                    // small delay
-
-    cbi(LCD_EN_PORT, LCD_EN);
-    cbi(LCD_RS_PORT, LCD_RS);
-    outp((inp(LCD_DATA_DDR) & 0x0F), LCD_DATA_DDR);           // set upper 4-bits of data-port to input
-    outp((inp(LCD_DATA_PORT) & 0x0F) | 0xF0, LCD_DATA_PORT);  // enable pull-ups in data-port
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Low-level routine to see if the controller is ready to receive
- *
- * This routine repeatetly reads the databus and checks if the highest bit (bit 7)
- * has become '0'. If a '0' is detected on bit 7 the function returns.
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static void LcdWaitBusy()
-{
-    u_char Busy = 1;
-	u_char LcdStatus = 0;
-
-    cbi (LCD_RS_PORT, LCD_RS);              // select instruction register
-
-    sbi (LCD_RW_PORT, LCD_RW);              // we are going to read
-
-    while (Busy)
-    {
-        sbi (LCD_EN_PORT, LCD_EN);          // set 'enable' to catch 'Ready'
-
-        asm("nop\n\tnop");                  // small delay
-        LcdStatus =  inp(LCD_IN_PORT);      // LcdStatus is used elsewhere in this module as well
-        Busy = LcdStatus & 0x80;            // break out of while-loop cause we are ready (b7='0')
-    }
-
-    cbi (LCD_EN_PORT, LCD_EN);              // all ctrlpins low
-    cbi (LCD_RS_PORT, LCD_RS);
-    cbi (LCD_RW_PORT, LCD_RW);              // we are going to write
-}
-
-/* ---------- end of module ------------------------------------------------ */
-
-/*@}*/
+/* ========================================================================
+ * [PROJECT]    SIR100
+ * [MODULE]     Display
+ * [TITLE]      display source file
+ * [FILE]       display.c
+ * [VSN]        1.0
+ * [CREATED]    26092003
+ * [LASTCHNGD]  06102006
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV
+ * [PURPOSE]    contains all interface- and low-level routines to
+ *              control the LCD and write characters or strings (menu-items)
+ * ======================================================================== */
+
+#define LOG_MODULE  LOG_DISPLAY_MODULE
+
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/timer.h>
+#include <sys/event.h>
+#include <sys/thread.h>
+#include <sys/heap.h>
+
+#include "system.h"
+#include "portio.h"
+#include "display.h"
+#include "log.h"
+
+/*-------------------------------------------------------------------------*/
+/* local defines                                                           */
+/*-------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+
+
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+static void LcdWriteByte(u_char, u_char);
+static void LcdWriteNibble(u_char, u_char);
+static void LcdWaitBusy(void);
+
+/*!
+ * \addtogroup Display
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief control backlight
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void LcdBackLight(u_char Mode)
+{
+    if (Mode==LCD_BACKLIGHT_ON)
+    {
+        sbi(LCD_BL_PORT, LCD_BL_BIT);   // Turn on backlight
+    }
+
+    if (Mode==LCD_BACKLIGHT_OFF)
+    {
+        cbi(LCD_BL_PORT, LCD_BL_BIT);   // Turn off backlight
+    }
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Write a single character on the LCD
+ *
+ * Writes a single character on the LCD on the current cursor position
+ *
+ * \param LcdChar character to write
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void LcdChar(char MyChar)
+{
+    LcdWriteByte(WRITE_DATA, MyChar);
+}
+
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Low-level initialisation function of the LCD-controller
+ *
+ * Initialise the controller and send the User-Defined Characters to CG-RAM
+ * settings: 4-bit interface, cursor invisible and NOT blinking
+ *           1 line dislay, 10 dots high characters
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+ void LcdLowLevelInit()
+{
+    u_char i;
+
+    NutDelay(140);                               // wait for more than 140 ms after Vdd rises to 2.7 V
+
+    for (i=0; i<3; ++i)
+    {
+        LcdWriteNibble(WRITE_COMMAND, 0x33);      // function set: 8-bit mode; necessary to guarantee that
+        NutDelay(4);                              // SIR starts up always in 5x10 dot mode
+    }
+
+    LcdWriteNibble(WRITE_COMMAND, 0x22);        // function set: 4-bit mode; necessary because KS0070 doesn't
+    NutDelay(1);                                // accept combined 4-bit mode & 5x10 dot mode programming
+
+    //LcdWriteByte(WRITE_COMMAND, 0x24);        // function set: 4-bit mode, 5x10 dot mode, 1-line
+    LcdWriteByte(WRITE_COMMAND, 0x28);          // function set: 4-bit mode, 5x7 dot mode, 2-lines
+    NutDelay(5);
+
+    LcdWriteByte(WRITE_COMMAND, 0x0C);          // display ON/OFF: display ON, cursor OFF, blink OFF
+    NutDelay(5);
+
+    LcdWriteByte(WRITE_COMMAND, 0x01);          // display clear
+    NutDelay(5);
+
+    LcdWriteByte(WRITE_COMMAND, 0x06);          // entry mode set: increment mode, entire shift OFF
+
+
+    LcdWriteByte(WRITE_COMMAND, 0x80);          // DD-RAM address counter (cursor pos) to '0'
+}
+
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Low-level routine to write a byte to LCD-controller
+ *
+ * Writes one byte to the LCD-controller (by  calling LcdWriteNibble twice)
+ * CtrlState determines if the byte is written to the instruction register
+ * or to the data register.
+ *
+ * \param CtrlState destination: instruction or data
+ * \param LcdByte byte to write
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static void LcdWriteByte(u_char CtrlState, u_char LcdByte)
+{
+    LcdWaitBusy();                      // see if the controller is ready to receive next byte
+    LcdWriteNibble(CtrlState, LcdByte & 0xF0);
+    LcdWriteNibble(CtrlState, LcdByte << 4);
+
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Low-level routine to write a nibble to LCD-controller
+ *
+ * Writes a nibble to the LCD-controller (interface is a 4-bit databus, so
+ * only 4 databits can be send at once).
+ * The nibble to write is in the upper 4 bits of LcdNibble
+ *
+ * \param CtrlState destination: instruction or data
+ * \param LcdNibble nibble to write (upper 4 bits in this byte
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static void LcdWriteNibble(u_char CtrlState, u_char LcdNibble)
+{
+    outp((inp(LCD_DATA_DDR) & 0x0F) | 0xF0, LCD_DATA_DDR);  // set data-port to output again
+
+    outp((inp(LCD_DATA_PORT) & 0x0F) | (LcdNibble & 0xF0), LCD_DATA_PORT); // prepare databus with nibble to write
+
+    if (CtrlState == WRITE_COMMAND)
+    {
+        cbi(LCD_RS_PORT, LCD_RS);     // command: RS low
+    }
+    else
+    {
+        sbi(LCD_RS_PORT, LCD_RS);     // data: RS high
+    }
+
+    sbi(LCD_EN_PORT, LCD_EN);
+
+    asm("nop\n\tnop");                    // small delay
+
+    cbi(LCD_EN_PORT, LCD_EN);
+    cbi(LCD_RS_PORT, LCD_RS);
+    outp((inp(LCD_DATA_DDR) & 0x0F), LCD_DATA_DDR);           // set upper 4-bits of data-port to input
+    outp((inp(LCD_DATA_PORT) & 0x0F) | 0xF0, LCD_DATA_PORT);  // enable pull-ups in data-port
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Low-level routine to see if the controller is ready to receive
+ *
+ * This routine repeatetly reads the databus and checks if the highest bit (bit 7)
+ * has become '0'. If a '0' is detected on bit 7 the function returns.
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static void LcdWaitBusy()
+{
+    u_char Busy = 1;
+	u_char LcdStatus = 0;
+
+    cbi (LCD_RS_PORT, LCD_RS);              // select instruction register
+
+    sbi (LCD_RW_PORT, LCD_RW);              // we are going to read
+
+    while (Busy)
+    {
+        sbi (LCD_EN_PORT, LCD_EN);          // set 'enable' to catch 'Ready'
+
+        asm("nop\n\tnop");                  // small delay
+        LcdStatus =  inp(LCD_IN_PORT);      // LcdStatus is used elsewhere in this module as well
+        Busy = LcdStatus & 0x80;            // break out of while-loop cause we are ready (b7='0')
+    }
+
+    cbi (LCD_EN_PORT, LCD_EN);              // all ctrlpins low
+    cbi (LCD_RS_PORT, LCD_RS);
+    cbi (LCD_RW_PORT, LCD_RW);              // we are going to write
+}
+
+/* ---------- end of module ------------------------------------------------ */
+
+/*@}*/

+ 63 - 63
include/display.h → lib/display.h

@@ -1,63 +1,63 @@
-/* ========================================================================
- * [PROJECT]    SIR100
- * [MODULE]     Display
- * [TITLE]      display header file
- * [FILE]       display.h
- * [VSN]        1.0
- * [CREATED]    030414
- * [LASTCHNGD]  030414
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    API and gobal defines for display module
- * ======================================================================== */
-
-#ifndef _Display_H
-#define _Display_H
-
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-#define DISPLAY_SIZE                16
-#define NROF_LINES                  2
-#define MAX_SCREEN_CHARS            (NROF_LINES*DISPLAY_SIZE)
-
-#define LINE_0                      0
-#define LINE_1                      1
-
-#define FIRSTPOS_LINE_0             0
-#define FIRSTPOS_LINE_1             0x40
-
-
-#define LCD_BACKLIGHT_ON            1
-#define LCD_BACKLIGHT_OFF           0
-
-#define ALL_ZERO          			0x00      // 0000 0000 B
-#define WRITE_COMMAND     			0x02      // 0000 0010 B
-#define WRITE_DATA        			0x03      // 0000 0011 B
-#define READ_COMMAND      			0x04      // 0000 0100 B
-#define READ_DATA         			0x06      // 0000 0110 B
-
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-extern void LcdChar(char);
-extern void LcdBackLight(u_char);
-extern void LcdInit(void);
-extern void LcdLowLevelInit(void);
-
-#endif /* _Display_H */
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
-
-
-
+/* ========================================================================
+ * [PROJECT]    SIR100
+ * [MODULE]     Display
+ * [TITLE]      display header file
+ * [FILE]       display.h
+ * [VSN]        1.0
+ * [CREATED]    030414
+ * [LASTCHNGD]  030414
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    API and gobal defines for display module
+ * ======================================================================== */
+
+#ifndef _Display_H
+#define _Display_H
+
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+#define DISPLAY_SIZE                16
+#define NROF_LINES                  2
+#define MAX_SCREEN_CHARS            (NROF_LINES*DISPLAY_SIZE)
+
+#define LINE_0                      0
+#define LINE_1                      1
+
+#define FIRSTPOS_LINE_0             0
+#define FIRSTPOS_LINE_1             0x40
+
+
+#define LCD_BACKLIGHT_ON            1
+#define LCD_BACKLIGHT_OFF           0
+
+#define ALL_ZERO          			0x00      // 0000 0000 B
+#define WRITE_COMMAND     			0x02      // 0000 0010 B
+#define WRITE_DATA        			0x03      // 0000 0011 B
+#define READ_COMMAND      			0x04      // 0000 0100 B
+#define READ_DATA         			0x06      // 0000 0110 B
+
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Global variables                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+extern void LcdChar(char);
+extern void LcdBackLight(u_char);
+extern void LcdInit(void);
+extern void LcdLowLevelInit(void);
+
+#endif /* _Display_H */
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+
+
+
+

+ 119 - 119
include/fat.h → lib/fat.h

@@ -1,119 +1,119 @@
-/****************************************************************************
-*  This file is part of the AVRIDE device driver.
-*
-*  Copyright (c) 2002-2004 by Michael Fischer. 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 author 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 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.
-*
-****************************************************************************
-*  History:
-*
-*  14.12.02  mifi   First Version 
-*  18.01.03  mifi   Change Licence from GPL to BSD
-*  25.01.03  mifi   Change FAT32Init 
-*                   New function FAT32MountDrive and FAT32UnMountDrive
-*                   Remove FAT32_MAX_FILES, a file handle will be 
-*                   allocated by NutHeapAlloc, therefore we have no
-*                   restrictions about the count of the open file handle.
-*                   (Only by available memory)
-*  27.01.03  mifi   Rename all FAT32xxx function to FATxxx.
-*
-*  28.01.03  mifi   Start porting to Nut/OS 3.X.X
-*  29.06.03  mifi   First ATAPI-Version
-*  24.07.04  mifi   Some changes to support more than one drive (datanut)
-*  25.07.04  mifi   Add support for the PCMCIA_11 hardware.
-*  27.07.04  mifi   Add support for IOCTL function
-****************************************************************************/
-#ifndef __FAT_H__
-#define __FAT_H__
-
-#include <sys/device.h>
-#include "fatdrv.h"
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-/*
- * Device mode
- */
-#define FAT_MODE_IDE_HD           0x0000
-#define FAT_MODE_IDE_CF           0x0001
-#define FAT_MODE_MEM_CF           0x0002
-#define FAT_MODE_DATANUT_CF       0x0003
-#define FAT_MODE_DATANUT_IDECF    0x0004
-#define FAT_MODE_DATANUT_IDEWLAN  0x0005
-#define FAT_MODE_USB              0x0006
-#define FAT_MODE_MMC              0x0007
-
-
-/*
- * If the function should be 
- * supported, set it to 1
- */
-#define FAT_SUPPORT_FORMAT        1
-
-/*
- * IOCTL-Function
- */
-#define FAT_IOCTL_QUICK_FORMAT    0x1000
-
-/*-------------------------------------------------------------------------*/
-/* global types                                                            */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* global macros                                                           */
-/*-------------------------------------------------------------------------*/
-#define FAT_IOCTL(_a,_b,_c)   ((NUTDEVICE *)_a)->dev_ioctl((_a), (_b), (_c))
-
-#define FATQuickFormat(_a)    FAT_IOCTL(_a, FAT_IOCTL_QUICK_FORMAT, NULL)
- 
-
-/*-------------------------------------------------------------------------*/
-/* Prototypes                                                              */
-/*-------------------------------------------------------------------------*/
-extern NUTDEVICE devFAT;
-
-#if (FAT_USE_IDE_INTERFACE >= 1)
-extern NUTDEVICE devFATCF;
-extern NUTDEVICE devFATIDE0;
-extern NUTDEVICE devFATIDE1;
-#endif
-
-#if (FAT_USE_USB_INTERFACE >= 1)
-extern NUTDEVICE devFATUSB0;
-#endif
-
-#if (FAT_USE_MMC_INTERFACE >= 1)
-extern NUTDEVICE devFATMMC0;
-extern void FATRelease(void);
-
-#endif
-
-
-#endif                          /* !__FAT_H__ */
+/****************************************************************************
+*  This file is part of the AVRIDE device driver.
+*
+*  Copyright (c) 2002-2004 by Michael Fischer. 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 author 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 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.
+*
+****************************************************************************
+*  History:
+*
+*  14.12.02  mifi   First Version 
+*  18.01.03  mifi   Change Licence from GPL to BSD
+*  25.01.03  mifi   Change FAT32Init 
+*                   New function FAT32MountDrive and FAT32UnMountDrive
+*                   Remove FAT32_MAX_FILES, a file handle will be 
+*                   allocated by NutHeapAlloc, therefore we have no
+*                   restrictions about the count of the open file handle.
+*                   (Only by available memory)
+*  27.01.03  mifi   Rename all FAT32xxx function to FATxxx.
+*
+*  28.01.03  mifi   Start porting to Nut/OS 3.X.X
+*  29.06.03  mifi   First ATAPI-Version
+*  24.07.04  mifi   Some changes to support more than one drive (datanut)
+*  25.07.04  mifi   Add support for the PCMCIA_11 hardware.
+*  27.07.04  mifi   Add support for IOCTL function
+****************************************************************************/
+#ifndef __FAT_H__
+#define __FAT_H__
+
+#include <sys/device.h>
+#include "fatdrv.h"
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+
+/*
+ * Device mode
+ */
+#define FAT_MODE_IDE_HD           0x0000
+#define FAT_MODE_IDE_CF           0x0001
+#define FAT_MODE_MEM_CF           0x0002
+#define FAT_MODE_DATANUT_CF       0x0003
+#define FAT_MODE_DATANUT_IDECF    0x0004
+#define FAT_MODE_DATANUT_IDEWLAN  0x0005
+#define FAT_MODE_USB              0x0006
+#define FAT_MODE_MMC              0x0007
+
+
+/*
+ * If the function should be 
+ * supported, set it to 1
+ */
+#define FAT_SUPPORT_FORMAT        1
+
+/*
+ * IOCTL-Function
+ */
+#define FAT_IOCTL_QUICK_FORMAT    0x1000
+
+/*-------------------------------------------------------------------------*/
+/* global types                                                            */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* global macros                                                           */
+/*-------------------------------------------------------------------------*/
+#define FAT_IOCTL(_a,_b,_c)   ((NUTDEVICE *)_a)->dev_ioctl((_a), (_b), (_c))
+
+#define FATQuickFormat(_a)    FAT_IOCTL(_a, FAT_IOCTL_QUICK_FORMAT, NULL)
+ 
+
+/*-------------------------------------------------------------------------*/
+/* Prototypes                                                              */
+/*-------------------------------------------------------------------------*/
+extern NUTDEVICE devFAT;
+
+#if (FAT_USE_IDE_INTERFACE >= 1)
+extern NUTDEVICE devFATCF;
+extern NUTDEVICE devFATIDE0;
+extern NUTDEVICE devFATIDE1;
+#endif
+
+#if (FAT_USE_USB_INTERFACE >= 1)
+extern NUTDEVICE devFATUSB0;
+#endif
+
+#if (FAT_USE_MMC_INTERFACE >= 1)
+extern NUTDEVICE devFATMMC0;
+extern void FATRelease(void);
+
+#endif
+
+
+#endif                          /* !__FAT_H__ */

+ 153 - 153
include/fatdrv.h → lib/fatdrv.h

@@ -1,153 +1,153 @@
-/****************************************************************************
-*  This file is part of the FAT device driver.
-*
-*  Copyright (c) 2002-2004 by Michael Fischer. 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 author 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 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.
-*
-****************************************************************************
-*  History:
-*
-*  03.08.04  mifi   First Version
-****************************************************************************/
-#ifndef __FATDRV_H__
-#define __FATDRV_H__
-
-#include "typedefs.h"
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-/*
- * Define the hardware here
- */
-#define FAT_USE_IDE_INTERFACE     0 
-#define FAT_USE_USB_INTERFACE     0
-#define FAT_USE_MMC_INTERFACE     1 
-
-
-#if (FAT_USE_IDE_INTERFACE >= 1)
-#include "ide.h"
-
-#define HW_SUPPORT_WRITE  IDE_SUPPORT_WRITE
-#define HW_SUPPORT_ATAPI  IDE_SUPPORT_ATAPI
-
-#define HW_OK             IDE_OK
-#define HW_ERROR          IDE_ERROR
-
-#define HW_DRIVE_C        IDE_DRIVE_C
-#define HW_DRIVE_D        IDE_DRIVE_D
-#define HW_DRIVE_E        IDE_DRIVE_E
-
-#define HW_SECTOR_SIZE    IDE_SECTOR_SIZE
-#endif /* (FAT_USE_IDE_INTERFACE >= 1) */ 
-
-
-#if (FAT_USE_USB_INTERFACE >= 1)
-#include "usbdrv.h"
-
-#define HW_SUPPORT_WRITE  USB_SUPPORT_WRITE
-#define HW_SUPPORT_ATAPI  USB_SUPPORT_ATAPI
-
-#define HW_OK             USB_OK
-#define HW_ERROR          USB_ERROR
-
-#define HW_DRIVE_C        USB_DRIVE_C
-#define HW_DRIVE_D        USB_DRIVE_D
-#define HW_DRIVE_E        USB_DRIVE_E
-
-#define HW_SECTOR_SIZE    USB_SECTOR_SIZE
-
-#endif /* (FAT_USE_USB_INTERFACE >= 1) */
-
-
-#if (FAT_USE_MMC_INTERFACE >= 1)
-#include "mmcdrv.h"
-
-#define HW_SUPPORT_WRITE  MMC_SUPPORT_WRITE
-#define HW_SUPPORT_ATAPI  MMC_SUPPORT_ATAPI
-
-#define HW_OK             MMC_OK
-#define HW_ERROR          MMC_ERROR
-
-#define HW_DRIVE_C        MMC_DRIVE_C
-#define HW_DRIVE_D        MMC_DRIVE_C
-#define HW_DRIVE_E        MMC_DRIVE_C
-
-#define HW_SECTOR_SIZE    MMC_SECTOR_SIZE
-
-#endif /* (FAT_USE_MMC_INTERFACE >= 1) */
-
-/*-------------------------------------------------------------------------*/
-/* global types                                                            */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* global macros                                                           */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* Prototypes                                                              */
-/*-------------------------------------------------------------------------*/
-#if (FAT_USE_IDE_INTERFACE >= 1)
-#define HWInit              IDEInit
-#define HWMountAllDevices   IDEMountAllDevices
-#define HWGetSectorSize     IDEGetSectorSize
-#define HWIsCDROMDevice     IDEIsCDROMDevice
-#define HWIsZIPDevice       IDEIsZIPDevice
-#define HWUnMountDevice     IDEUnMountDevice
-#define HWGetTotalSectors   IDEGetTotalSectors
-#define HWReadSectors       IDEReadSectors  
-#define HWWriteSectors      IDEWriteSectors
-#endif /* (FAT_USE_IDE_INTERFACE >= 1) */ 
-
-#if (FAT_USE_USB_INTERFACE >= 1)
-#define HWInit              USBInit
-#define HWMountAllDevices   USBMountAllDevices
-#define HWGetSectorSize     USBGetSectorSize
-#define HWIsCDROMDevice     USBIsCDROMDevice
-#define HWIsZIPDevice       USBIsZIPDevice
-#define HWUnMountDevice     USBUnMountDevice
-#define HWGetTotalSectors   USBGetTotalSectors
-#define HWReadSectors       USBReadSectors  
-#define HWWriteSectors      USBWriteSectors
-#endif /* (FAT_USE_USB_INTERFACE == 1) */
-
-#if (FAT_USE_MMC_INTERFACE >= 1)
-#define HWInit              MMCInit
-#define HWMountAllDevices   MMCMountAllDevices
-#define HWGetSectorSize     MMCGetSectorSize
-#define HWIsCDROMDevice     MMCIsCDROMDevice
-#define HWIsZIPDevice       MMCIsZIPDevice
-#define HWUnMountDevice     MMCUnMountDevice
-#define HWGetTotalSectors   MMCGetTotalSectors
-#define HWReadSectors       MMCReadSectors  
-#define HWWriteSectors      MMCWriteSectors
-#endif /* (FAT_USE_MMC_INTERFACE == 1) */
-
-#endif /* !__FATDRV_H__ */
+/****************************************************************************
+*  This file is part of the FAT device driver.
+*
+*  Copyright (c) 2002-2004 by Michael Fischer. 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 author 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 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.
+*
+****************************************************************************
+*  History:
+*
+*  03.08.04  mifi   First Version
+****************************************************************************/
+#ifndef __FATDRV_H__
+#define __FATDRV_H__
+
+#include "typedefs.h"
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+
+/*
+ * Define the hardware here
+ */
+#define FAT_USE_IDE_INTERFACE     0 
+#define FAT_USE_USB_INTERFACE     0
+#define FAT_USE_MMC_INTERFACE     1 
+
+
+#if (FAT_USE_IDE_INTERFACE >= 1)
+#include "ide.h"
+
+#define HW_SUPPORT_WRITE  IDE_SUPPORT_WRITE
+#define HW_SUPPORT_ATAPI  IDE_SUPPORT_ATAPI
+
+#define HW_OK             IDE_OK
+#define HW_ERROR          IDE_ERROR
+
+#define HW_DRIVE_C        IDE_DRIVE_C
+#define HW_DRIVE_D        IDE_DRIVE_D
+#define HW_DRIVE_E        IDE_DRIVE_E
+
+#define HW_SECTOR_SIZE    IDE_SECTOR_SIZE
+#endif /* (FAT_USE_IDE_INTERFACE >= 1) */ 
+
+
+#if (FAT_USE_USB_INTERFACE >= 1)
+#include "usbdrv.h"
+
+#define HW_SUPPORT_WRITE  USB_SUPPORT_WRITE
+#define HW_SUPPORT_ATAPI  USB_SUPPORT_ATAPI
+
+#define HW_OK             USB_OK
+#define HW_ERROR          USB_ERROR
+
+#define HW_DRIVE_C        USB_DRIVE_C
+#define HW_DRIVE_D        USB_DRIVE_D
+#define HW_DRIVE_E        USB_DRIVE_E
+
+#define HW_SECTOR_SIZE    USB_SECTOR_SIZE
+
+#endif /* (FAT_USE_USB_INTERFACE >= 1) */
+
+
+#if (FAT_USE_MMC_INTERFACE >= 1)
+#include "mmcdrv.h"
+
+#define HW_SUPPORT_WRITE  MMC_SUPPORT_WRITE
+#define HW_SUPPORT_ATAPI  MMC_SUPPORT_ATAPI
+
+#define HW_OK             MMC_OK
+#define HW_ERROR          MMC_ERROR
+
+#define HW_DRIVE_C        MMC_DRIVE_C
+#define HW_DRIVE_D        MMC_DRIVE_C
+#define HW_DRIVE_E        MMC_DRIVE_C
+
+#define HW_SECTOR_SIZE    MMC_SECTOR_SIZE
+
+#endif /* (FAT_USE_MMC_INTERFACE >= 1) */
+
+/*-------------------------------------------------------------------------*/
+/* global types                                                            */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* global macros                                                           */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* Prototypes                                                              */
+/*-------------------------------------------------------------------------*/
+#if (FAT_USE_IDE_INTERFACE >= 1)
+#define HWInit              IDEInit
+#define HWMountAllDevices   IDEMountAllDevices
+#define HWGetSectorSize     IDEGetSectorSize
+#define HWIsCDROMDevice     IDEIsCDROMDevice
+#define HWIsZIPDevice       IDEIsZIPDevice
+#define HWUnMountDevice     IDEUnMountDevice
+#define HWGetTotalSectors   IDEGetTotalSectors
+#define HWReadSectors       IDEReadSectors  
+#define HWWriteSectors      IDEWriteSectors
+#endif /* (FAT_USE_IDE_INTERFACE >= 1) */ 
+
+#if (FAT_USE_USB_INTERFACE >= 1)
+#define HWInit              USBInit
+#define HWMountAllDevices   USBMountAllDevices
+#define HWGetSectorSize     USBGetSectorSize
+#define HWIsCDROMDevice     USBIsCDROMDevice
+#define HWIsZIPDevice       USBIsZIPDevice
+#define HWUnMountDevice     USBUnMountDevice
+#define HWGetTotalSectors   USBGetTotalSectors
+#define HWReadSectors       USBReadSectors  
+#define HWWriteSectors      USBWriteSectors
+#endif /* (FAT_USE_USB_INTERFACE == 1) */
+
+#if (FAT_USE_MMC_INTERFACE >= 1)
+#define HWInit              MMCInit
+#define HWMountAllDevices   MMCMountAllDevices
+#define HWGetSectorSize     MMCGetSectorSize
+#define HWIsCDROMDevice     MMCIsCDROMDevice
+#define HWIsZIPDevice       MMCIsZIPDevice
+#define HWUnMountDevice     MMCUnMountDevice
+#define HWGetTotalSectors   MMCGetTotalSectors
+#define HWReadSectors       MMCReadSectors  
+#define HWWriteSectors      MMCWriteSectors
+#endif /* (FAT_USE_MMC_INTERFACE == 1) */
+
+#endif /* !__FATDRV_H__ */

+ 399 - 399
source/flash.c → lib/flash.c

@@ -1,399 +1,399 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     Flash
- * [TITLE]      Routines for Atmel AT45 serial dataflash memory chips.
- * [FILE]       flash.c
- * [VSN]        1.0
- * [CREATED]    11042007
- * [LASTCHNGD]  11042007
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    contains all interface- and low-level routines to
- *              read/write/delete blocks in the serial DataFlash (AT45DBXX)
- * ======================================================================== */
-
-#define LOG_MODULE  LOG_FLASH_MODULE
-
-//#include <stdio.h>
-#include <cfg/os.h>
-#include <cfg/memory.h>
-
-#include <sys/timer.h>
-
-#include <string.h>
-#include <stdlib.h>
-
-#include "typedefs.h"
-#include "flash.h"
-#include "portio.h"
-#include "log.h"
-#include "spidrv.h"
-
-
-/*-------------------------------------------------------------------------*/
-/* local defines                                                           */
-/*-------------------------------------------------------------------------*/
-#ifndef MAX_AT45_CMDLEN
-#define MAX_AT45_CMDLEN         8
-#endif
-
-#ifndef AT45_ERASE_WAIT
-#define AT45_ERASE_WAIT         3000
-#endif
-
-#ifndef AT45_CHIP_ERASE_WAIT
-#define AT45_CHIP_ERASE_WAIT    50000
-#endif
-
-#ifndef AT45_WRITE_POLLS
-#define AT45_WRITE_POLLS        1000
-#endif
-
-#define DFCMD_READ_PAGE         0xD2    /* Read main memory page. */
-#define DFCMD_READ_STATUS       0xD7    /* Read status register. */
-#define DFCMD_CONT_READ         0xE8    /* Continuos read. */
-#define DFCMD_PAGE_ERASE        0x81    /* Page erase. */
-#define DFCMD_BUF1_WRITE        0x84    /* Buffer 1 write. */
-#define DFCMD_BUF1_FLASH        0x83    /* Buffer 1 flash with page erase. */
-
-/*
- *  \brief last page of flash (264 bytes) can be dedicated for parameter storage
- *   Special routines are provided for that goal but can be disabled here to save
- *   codespace (about 360 bytes of code for GCC)
- */
-
-//#define USE_FLASH_PARAM_PAGE
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-/*!
- * \brief Known device type entry.
- */
-typedef struct _AT45_DEVTAB
-{
-    u_long devt_pages;
-    u_int devt_pagsiz;
-    u_int devt_offs;
-    u_char devt_srmsk;
-    u_char devt_srval;
-} AT45_DEVTAB;
-
-/*!
- * \brief Active device entry.
- */
-typedef struct _AT45DB_DCB
-{
-    AT45_DEVTAB *dcb_devt;
-    u_char dcb_cmdbuf[MAX_AT45_CMDLEN];
-} AT45DB_DCB;
-
-/*!
- * \brief Table of known Dataflash types.
- */
-AT45_DEVTAB at45_devt[] = {
-    {512,  264,  9,  0x3C, 0x0C},   // AT45DB011B - 128kB
-    {1025, 264,  9,  0x3C, 0x14},   // AT45DB021B - 256kB
-    {2048, 264,  9,  0x3C, 0x1C},   // AT45DB041B - 512kB
-    {4096, 264,  9,  0x3C, 0x24},   // AT45DB081B - 1MB
-    {4096, 528,  10, 0x3C, 0x2C},   // AT45DB0161B - 2MB
-    {8192, 528,  10, 0x3C, 0x34},   // AT45DB0321B - 4MB
-    {8192, 1056, 11, 0x38, 0x38},   // AT45DB0642 - 8MB
-    {0,    0,    0,  0,    0}       // End of table
-};
-
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-/*!
- * \brief Table of active devices.
- */
-static AT45DB_DCB dcbtab;
-
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-static int At45dbTransfer(CONST void *txbuf, void *rxbuf, int xlen, CONST void *txnbuf, void *rxnbuf, int xnlen);
-
-/*!
- * \addtogroup SerialFlash
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-/*!
- * \brief mid-level SPI-interface routine
- *
- *  This routine handles sending a command an reading back the reply in one routine
- *  It will perform 'xlen' + 'xnlen' SPI-byte cycles. During the 'xlen' cycles, data in 'txbuf'
- *  is sent using the SPI, and each resulting byte is stored in 'rxbuf'. Then it starts with
- *  the 'xnlen' cycles whereby the contents of the 'txnbuf' are sent using the SPI.
- *  Each resulting byte then is stored in 'rxnbuf'
- */
-//                                        cb,          cb,        len,             tdata,         rdata,      datalen
-static int At45dbTransfer(CONST void *txbuf, void *rxbuf, int xlen, CONST void *txnbuf, void *rxnbuf, int xnlen)
-{   int i;
-    u_char *ptTxbuf, *ptRxbuf;
-
-    SPIselect(SPI_DEV_FLASH);
-
-    ptTxbuf=(u_char*)txbuf;
-    ptRxbuf=(u_char*)rxbuf;
-    /*
-     *  send command, store the bytes that were read the same time
-     */
-    for (i=0; i<xlen; ++i)
-    {
-        *ptRxbuf++=SPItransferByte(*ptTxbuf++);
-    }
-
-    ptTxbuf=(u_char*)txnbuf;
-    ptRxbuf=(u_char*)rxnbuf;
-    /*
-     *  send dummy data, store the bytes that were read the same time
-     */
-    for (i=0; i<xnlen; ++i)
-    {
-        *ptRxbuf++=SPItransferByte(*ptTxbuf++);
-    }
-
-    SPIdeselect();
-
-    return(0);  // always...
-
-}
-
-/*!
- * \brief send a command to the AT45dbXX
- *
- */
-int At45dbSendCmd(u_char op, u_long parm, int len, CONST void *tdata, void *rdata, int datalen)
-{
-    u_char *cb = dcbtab.dcb_cmdbuf;
-
-    if (len > MAX_AT45_CMDLEN)
-    {
-        return (-1);
-    }
-    memset(cb, 0, len);
-    cb[0] = op;
-    if (parm)
-    {
-        cb[1] = (u_char) (parm >> 16);
-        cb[2] = (u_char) (parm >> 8);
-        cb[3] = (u_char) parm;
-    }
-    return (At45dbTransfer(cb, cb, len, tdata, rdata, datalen));
-}
-
-/*!
- * \brief read status
- *
- */
-u_char At45dbGetStatus()
-{
-    u_char buf[2] = { DFCMD_READ_STATUS, 0xFF};
-
-    if (At45dbTransfer(buf, buf, 2, NULL, NULL, 0))
-    {
-        return(u_char) - 1;
-    }
-    return (buf[1]);
-}
-
-/*!
- * \brief Wait until flash memory cycle finished.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int At45dbWaitReady(u_long tmo, int poll)
-{
-    u_char sr;
-
-    while (((sr = At45dbGetStatus()) & 0x80) == 0)
-    {
-        if (!poll)
-        {
-            NutSleep(1);
-        }
-        if (tmo-- == 0)
-        {
-            return (-1);
-        }
-    }
-    return (0);
-}
-
-/*!
- * \brief runtime detection of serial flash device
- */
-int At45dbInit()
-{
-    u_char sr;
-    u_char i;
-
-    At45dbGetStatus();
-    sr = At45dbGetStatus();
-
-    for (i=0; at45_devt[i].devt_pages; i++)
-    {
-        if ((sr & at45_devt[i].devt_srmsk) == at45_devt[i].devt_srval)
-        {
-            dcbtab.dcb_devt = &at45_devt[i];
-            break;
-        }
-    }
-    return (i);
-}
-
-/*!
- * \brief Erase sector at the specified offset.
- */
-int At45dbPageErase(u_int pgn)
-{
-    return (At45dbSendCmd(DFCMD_PAGE_ERASE, pgn, 4, NULL, NULL, 0));
-}
-
-/*!
- * \brief Erase entire flash memory chip.
- */
-int At45dbChipErase(void)
-{
-    return (-1);
-}
-
-/*!
- * \brief Read data from flash memory.
- *
- * \param pgn  Page number to read, starting at 0.
- * \param data Points to a buffer that receives the data.
- * \param len  Number of bytes to read.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int At45dbPageRead(u_long pgn, void *data, u_int len)
-{
-    pgn <<= dcbtab.dcb_devt->devt_offs;
-    return (At45dbSendCmd(DFCMD_CONT_READ, pgn, 8, data, data, len));
-}
-
-/*!
- * \brief Write data into flash memory.
- *
- * The related sector must have been erased before calling this function.
- *
- * \param pgn  Start location within the chip, starting at 0.
- * \param data Points to a buffer that contains the bytes to be written.
- * \param len  Number of bytes to write.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int At45dbPageWrite(u_long pgn, CONST void *data, u_int len)
-{
-    int rc = -1;
-    void *rp;
-
-    if ((rp = malloc(len)) != NULL)
-    {
-        /* Copy data to dataflash RAM buffer. */
-        if (At45dbSendCmd(DFCMD_BUF1_WRITE, 0, 4, data, rp, len) == 0)
-        {
-            /* Flash RAM buffer. */
-            pgn <<= dcbtab.dcb_devt->devt_offs;
-            if (At45dbSendCmd(DFCMD_BUF1_FLASH, pgn, 4, NULL, NULL, 0) == 0)
-            {
-                rc = At45dbWaitReady(AT45_WRITE_POLLS, 1);
-            }
-        }
-        free(rp);
-    }
-    return (rc);
-}
-
-#ifdef USE_FLASH_PARAM_PAGE
-
-u_long At45dbParamPage(void)
-{
-#ifdef AT45_CONF_PAGE
-    return (AT45_CONF_PAGE);
-#else
-    return (dcbtab.dcb_devt->devt_pages - 1);
-#endif
-}
-
-int At45dbParamSize(void)
-{
-    int rc;
-
-#ifdef AT45_CONF_SIZE
-    rc = AT45_CONF_SIZE;
-#else
-    rc = dcbtab.dcb_devt->devt_pagsiz;
-#endif
-    return (rc);
-}
-
-/*!
- * \brief Load configuration parameters from flash memory.
- *
- * \param pos  Start location within configuration sector.
- * \param data Points to a buffer that receives the contents.
- * \param len  Number of bytes to read.
- *
- * \return Always 0.
- */
-int At45dbParamRead(u_int pos, void *data, u_int len)
-{
-    int rc = -1;
-    u_char *buff;
-    int csize = At45dbParamSize();
-    u_long cpage = At45dbParamPage();
-
-    /* Load the complete configuration area. */
-    if (csize > len && (buff = malloc(csize)) != NULL)
-    {
-        rc = At45dbPageRead(cpage, buff, csize);
-        /* Copy requested contents to caller's buffer. */
-        memcpy(data, buff + pos, len);
-        free(buff);
-    }
-    return (rc);
-}
-
-/*!
- * \brief Store configuration parameters in flash memory.
- *
- * \param pos   Start location within configuration sector.
- * \param data  Points to a buffer that contains the bytes to store.
- * \param len   Number of bytes to store.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int At45dbParamWrite(u_int pos, CONST void *data, u_int len)
-{
-    int rc = -1;
-    u_char *buff;
-    int csize = At45dbParamSize();
-    u_long cpage = At45dbParamPage();
-
-    /* Load the complete configuration area. */
-    if (csize > len && (buff = malloc(csize)) != NULL)
-    {
-        rc = At45dbPageRead(cpage, buff, csize);
-        /* Compare old with new contents. */
-        if (memcmp(buff + pos, data, len))
-        {
-            /* New contents differs. Copy it into the sector buffer. */
-            memcpy(buff + pos, data, len);
-            /* Erase sector and write new data. */
-            rc = At45dbPageWrite(cpage, buff, csize);
-        }
-        free(buff);
-    }
-    return (rc);
-}
-
-#endif // USE_FLASH_PARAM_PAGE
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     Flash
+ * [TITLE]      Routines for Atmel AT45 serial dataflash memory chips.
+ * [FILE]       flash.c
+ * [VSN]        1.0
+ * [CREATED]    11042007
+ * [LASTCHNGD]  11042007
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    contains all interface- and low-level routines to
+ *              read/write/delete blocks in the serial DataFlash (AT45DBXX)
+ * ======================================================================== */
+
+#define LOG_MODULE  LOG_FLASH_MODULE
+
+//#include <stdio.h>
+#include <cfg/os.h>
+#include <cfg/memory.h>
+
+#include <sys/timer.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "typedefs.h"
+#include "flash.h"
+#include "portio.h"
+#include "log.h"
+#include "spidrv.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* local defines                                                           */
+/*-------------------------------------------------------------------------*/
+#ifndef MAX_AT45_CMDLEN
+#define MAX_AT45_CMDLEN         8
+#endif
+
+#ifndef AT45_ERASE_WAIT
+#define AT45_ERASE_WAIT         3000
+#endif
+
+#ifndef AT45_CHIP_ERASE_WAIT
+#define AT45_CHIP_ERASE_WAIT    50000
+#endif
+
+#ifndef AT45_WRITE_POLLS
+#define AT45_WRITE_POLLS        1000
+#endif
+
+#define DFCMD_READ_PAGE         0xD2    /* Read main memory page. */
+#define DFCMD_READ_STATUS       0xD7    /* Read status register. */
+#define DFCMD_CONT_READ         0xE8    /* Continuos read. */
+#define DFCMD_PAGE_ERASE        0x81    /* Page erase. */
+#define DFCMD_BUF1_WRITE        0x84    /* Buffer 1 write. */
+#define DFCMD_BUF1_FLASH        0x83    /* Buffer 1 flash with page erase. */
+
+/*
+ *  \brief last page of flash (264 bytes) can be dedicated for parameter storage
+ *   Special routines are provided for that goal but can be disabled here to save
+ *   codespace (about 360 bytes of code for GCC)
+ */
+
+//#define USE_FLASH_PARAM_PAGE
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+/*!
+ * \brief Known device type entry.
+ */
+typedef struct _AT45_DEVTAB
+{
+    u_long devt_pages;
+    u_int devt_pagsiz;
+    u_int devt_offs;
+    u_char devt_srmsk;
+    u_char devt_srval;
+} AT45_DEVTAB;
+
+/*!
+ * \brief Active device entry.
+ */
+typedef struct _AT45DB_DCB
+{
+    AT45_DEVTAB *dcb_devt;
+    u_char dcb_cmdbuf[MAX_AT45_CMDLEN];
+} AT45DB_DCB;
+
+/*!
+ * \brief Table of known Dataflash types.
+ */
+AT45_DEVTAB at45_devt[] = {
+    {512,  264,  9,  0x3C, 0x0C},   // AT45DB011B - 128kB
+    {1025, 264,  9,  0x3C, 0x14},   // AT45DB021B - 256kB
+    {2048, 264,  9,  0x3C, 0x1C},   // AT45DB041B - 512kB
+    {4096, 264,  9,  0x3C, 0x24},   // AT45DB081B - 1MB
+    {4096, 528,  10, 0x3C, 0x2C},   // AT45DB0161B - 2MB
+    {8192, 528,  10, 0x3C, 0x34},   // AT45DB0321B - 4MB
+    {8192, 1056, 11, 0x38, 0x38},   // AT45DB0642 - 8MB
+    {0,    0,    0,  0,    0}       // End of table
+};
+
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+/*!
+ * \brief Table of active devices.
+ */
+static AT45DB_DCB dcbtab;
+
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+static int At45dbTransfer(CONST void *txbuf, void *rxbuf, int xlen, CONST void *txnbuf, void *rxnbuf, int xnlen);
+
+/*!
+ * \addtogroup SerialFlash
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+
+/*!
+ * \brief mid-level SPI-interface routine
+ *
+ *  This routine handles sending a command an reading back the reply in one routine
+ *  It will perform 'xlen' + 'xnlen' SPI-byte cycles. During the 'xlen' cycles, data in 'txbuf'
+ *  is sent using the SPI, and each resulting byte is stored in 'rxbuf'. Then it starts with
+ *  the 'xnlen' cycles whereby the contents of the 'txnbuf' are sent using the SPI.
+ *  Each resulting byte then is stored in 'rxnbuf'
+ */
+//                                        cb,          cb,        len,             tdata,         rdata,      datalen
+static int At45dbTransfer(CONST void *txbuf, void *rxbuf, int xlen, CONST void *txnbuf, void *rxnbuf, int xnlen)
+{   int i;
+    u_char *ptTxbuf, *ptRxbuf;
+
+    SPIselect(SPI_DEV_FLASH);
+
+    ptTxbuf=(u_char*)txbuf;
+    ptRxbuf=(u_char*)rxbuf;
+    /*
+     *  send command, store the bytes that were read the same time
+     */
+    for (i=0; i<xlen; ++i)
+    {
+        *ptRxbuf++=SPItransferByte(*ptTxbuf++);
+    }
+
+    ptTxbuf=(u_char*)txnbuf;
+    ptRxbuf=(u_char*)rxnbuf;
+    /*
+     *  send dummy data, store the bytes that were read the same time
+     */
+    for (i=0; i<xnlen; ++i)
+    {
+        *ptRxbuf++=SPItransferByte(*ptTxbuf++);
+    }
+
+    SPIdeselect();
+
+    return(0);  // always...
+
+}
+
+/*!
+ * \brief send a command to the AT45dbXX
+ *
+ */
+int At45dbSendCmd(u_char op, u_long parm, int len, CONST void *tdata, void *rdata, int datalen)
+{
+    u_char *cb = dcbtab.dcb_cmdbuf;
+
+    if (len > MAX_AT45_CMDLEN)
+    {
+        return (-1);
+    }
+    memset(cb, 0, len);
+    cb[0] = op;
+    if (parm)
+    {
+        cb[1] = (u_char) (parm >> 16);
+        cb[2] = (u_char) (parm >> 8);
+        cb[3] = (u_char) parm;
+    }
+    return (At45dbTransfer(cb, cb, len, tdata, rdata, datalen));
+}
+
+/*!
+ * \brief read status
+ *
+ */
+u_char At45dbGetStatus()
+{
+    u_char buf[2] = { DFCMD_READ_STATUS, 0xFF};
+
+    if (At45dbTransfer(buf, buf, 2, NULL, NULL, 0))
+    {
+        return(u_char) - 1;
+    }
+    return (buf[1]);
+}
+
+/*!
+ * \brief Wait until flash memory cycle finished.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int At45dbWaitReady(u_long tmo, int poll)
+{
+    u_char sr;
+
+    while (((sr = At45dbGetStatus()) & 0x80) == 0)
+    {
+        if (!poll)
+        {
+            NutSleep(1);
+        }
+        if (tmo-- == 0)
+        {
+            return (-1);
+        }
+    }
+    return (0);
+}
+
+/*!
+ * \brief runtime detection of serial flash device
+ */
+int At45dbInit()
+{
+    u_char sr;
+    u_char i;
+
+    At45dbGetStatus();
+    sr = At45dbGetStatus();
+
+    for (i=0; at45_devt[i].devt_pages; i++)
+    {
+        if ((sr & at45_devt[i].devt_srmsk) == at45_devt[i].devt_srval)
+        {
+            dcbtab.dcb_devt = &at45_devt[i];
+            break;
+        }
+    }
+    return (i);
+}
+
+/*!
+ * \brief Erase sector at the specified offset.
+ */
+int At45dbPageErase(u_int pgn)
+{
+    return (At45dbSendCmd(DFCMD_PAGE_ERASE, pgn, 4, NULL, NULL, 0));
+}
+
+/*!
+ * \brief Erase entire flash memory chip.
+ */
+int At45dbChipErase(void)
+{
+    return (-1);
+}
+
+/*!
+ * \brief Read data from flash memory.
+ *
+ * \param pgn  Page number to read, starting at 0.
+ * \param data Points to a buffer that receives the data.
+ * \param len  Number of bytes to read.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int At45dbPageRead(u_long pgn, void *data, u_int len)
+{
+    pgn <<= dcbtab.dcb_devt->devt_offs;
+    return (At45dbSendCmd(DFCMD_CONT_READ, pgn, 8, data, data, len));
+}
+
+/*!
+ * \brief Write data into flash memory.
+ *
+ * The related sector must have been erased before calling this function.
+ *
+ * \param pgn  Start location within the chip, starting at 0.
+ * \param data Points to a buffer that contains the bytes to be written.
+ * \param len  Number of bytes to write.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int At45dbPageWrite(u_long pgn, CONST void *data, u_int len)
+{
+    int rc = -1;
+    void *rp;
+
+    if ((rp = malloc(len)) != NULL)
+    {
+        /* Copy data to dataflash RAM buffer. */
+        if (At45dbSendCmd(DFCMD_BUF1_WRITE, 0, 4, data, rp, len) == 0)
+        {
+            /* Flash RAM buffer. */
+            pgn <<= dcbtab.dcb_devt->devt_offs;
+            if (At45dbSendCmd(DFCMD_BUF1_FLASH, pgn, 4, NULL, NULL, 0) == 0)
+            {
+                rc = At45dbWaitReady(AT45_WRITE_POLLS, 1);
+            }
+        }
+        free(rp);
+    }
+    return (rc);
+}
+
+#ifdef USE_FLASH_PARAM_PAGE
+
+u_long At45dbParamPage(void)
+{
+#ifdef AT45_CONF_PAGE
+    return (AT45_CONF_PAGE);
+#else
+    return (dcbtab.dcb_devt->devt_pages - 1);
+#endif
+}
+
+int At45dbParamSize(void)
+{
+    int rc;
+
+#ifdef AT45_CONF_SIZE
+    rc = AT45_CONF_SIZE;
+#else
+    rc = dcbtab.dcb_devt->devt_pagsiz;
+#endif
+    return (rc);
+}
+
+/*!
+ * \brief Load configuration parameters from flash memory.
+ *
+ * \param pos  Start location within configuration sector.
+ * \param data Points to a buffer that receives the contents.
+ * \param len  Number of bytes to read.
+ *
+ * \return Always 0.
+ */
+int At45dbParamRead(u_int pos, void *data, u_int len)
+{
+    int rc = -1;
+    u_char *buff;
+    int csize = At45dbParamSize();
+    u_long cpage = At45dbParamPage();
+
+    /* Load the complete configuration area. */
+    if (csize > len && (buff = malloc(csize)) != NULL)
+    {
+        rc = At45dbPageRead(cpage, buff, csize);
+        /* Copy requested contents to caller's buffer. */
+        memcpy(data, buff + pos, len);
+        free(buff);
+    }
+    return (rc);
+}
+
+/*!
+ * \brief Store configuration parameters in flash memory.
+ *
+ * \param pos   Start location within configuration sector.
+ * \param data  Points to a buffer that contains the bytes to store.
+ * \param len   Number of bytes to store.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int At45dbParamWrite(u_int pos, CONST void *data, u_int len)
+{
+    int rc = -1;
+    u_char *buff;
+    int csize = At45dbParamSize();
+    u_long cpage = At45dbParamPage();
+
+    /* Load the complete configuration area. */
+    if (csize > len && (buff = malloc(csize)) != NULL)
+    {
+        rc = At45dbPageRead(cpage, buff, csize);
+        /* Compare old with new contents. */
+        if (memcmp(buff + pos, data, len))
+        {
+            /* New contents differs. Copy it into the sector buffer. */
+            memcpy(buff + pos, data, len);
+            /* Erase sector and write new data. */
+            rc = At45dbPageWrite(cpage, buff, csize);
+        }
+        free(buff);
+    }
+    return (rc);
+}
+
+#endif // USE_FLASH_PARAM_PAGE

+ 68 - 68
include/flash.h → lib/flash.h

@@ -1,68 +1,68 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     Flash
- * [TITLE]      Routines for Atmel AT45 serial dataflash memory chips.
- * [FILE]       flash.c
- * [VSN]        1.0
- * [CREATED]    11042007
- * [LASTCHNGD]  11042007
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    contains all interface- and low-level routines to
- *              read/write/delete blocks in the serial DataFlash (AT45DBXX)
- * ======================================================================== */
-#ifndef _Flash_H
-#define _Flash_H
-
-
-#include <sys/types.h>
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-/*
- *  next defines have a 1-1 relationship to the index in the 'at45_devt'
- *  array, so do not change the values
- */
-#define AT45DB011B  0
-#define AT45DB021B  1
-#define AT45DB041B  2
-#define AT45DB081B  3
-#define AT45DB0161B 4
-#define AT45DB0321B 5
-#define AT45DB0642  6
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/*  Global variables                                                       */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-
-extern int At45dbSendCmd(u_char op, u_long parm, int len, CONST void *tdata, void *rdata, int datalen);
-extern u_char At45dbGetStatus(void);
-extern int At45dbWaitReady(u_long tmo, int poll);
-extern int At45dbInit(void);
-extern int At45dbPageErase(u_int off);
-extern int At45dbChipErase(void);
-extern int At45dbPageRead(u_long pgn, void *data, u_int len);
-extern int At45dbPageWrite(u_long pgn, CONST void *data, u_int len);
-
-#ifdef USE_FLASH_PARAM_PAGE
-extern int At45dbParamRead(u_int pos, void *data, u_int len);
-extern int At45dbParamWrite(u_int pos, CONST void *data, u_int len);
-#endif // USE_FLASH_PARAM_PAGE
-
-#endif /* _Flash_H */
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
-
-
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     Flash
+ * [TITLE]      Routines for Atmel AT45 serial dataflash memory chips.
+ * [FILE]       flash.c
+ * [VSN]        1.0
+ * [CREATED]    11042007
+ * [LASTCHNGD]  11042007
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    contains all interface- and low-level routines to
+ *              read/write/delete blocks in the serial DataFlash (AT45DBXX)
+ * ======================================================================== */
+#ifndef _Flash_H
+#define _Flash_H
+
+
+#include <sys/types.h>
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+
+/*
+ *  next defines have a 1-1 relationship to the index in the 'at45_devt'
+ *  array, so do not change the values
+ */
+#define AT45DB011B  0
+#define AT45DB021B  1
+#define AT45DB041B  2
+#define AT45DB081B  3
+#define AT45DB0161B 4
+#define AT45DB0321B 5
+#define AT45DB0642  6
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/*  Global variables                                                       */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+
+extern int At45dbSendCmd(u_char op, u_long parm, int len, CONST void *tdata, void *rdata, int datalen);
+extern u_char At45dbGetStatus(void);
+extern int At45dbWaitReady(u_long tmo, int poll);
+extern int At45dbInit(void);
+extern int At45dbPageErase(u_int off);
+extern int At45dbChipErase(void);
+extern int At45dbPageRead(u_long pgn, void *data, u_int len);
+extern int At45dbPageWrite(u_long pgn, CONST void *data, u_int len);
+
+#ifdef USE_FLASH_PARAM_PAGE
+extern int At45dbParamRead(u_int pos, void *data, u_int len);
+extern int At45dbParamWrite(u_int pos, CONST void *data, u_int len);
+#endif // USE_FLASH_PARAM_PAGE
+
+#endif /* _Flash_H */
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+
+
+
+
+

+ 326 - 326
source/keyboard.c → lib/keyboard.c

@@ -1,326 +1,326 @@
-/*! \file
- * keyboard.c contains the low-level keyboard scan and the
- * interfacing with NutOS (signalling)
- *  Copyright STREAMIT, 2010.
- *  \version 1.0
- *  \date 26 september 2003
- */
-
-
-#define LOG_MODULE  LOG_KEYBOARD_MODULE
-
-#include <sys/atom.h>
-#include <sys/event.h>
-
-//#pragma text:appcode
-
-#include "log.h"
-#include "keyboard.h"
-#include "portio.h"
-#include "system.h"
-
-/*-------------------------------------------------------------------------*/
-/* local defines                                                          */
-/*-------------------------------------------------------------------------*/
-/*
- *  definition of raw keys as found in keyboardscan
- *  Note that these 16-bit values are remapped before
- *  the application uses them
- */
-#define RAW_KEY_01         0xFFFB
-#define RAW_KEY_02         0xFFFD
-#define RAW_KEY_03         0xFF7F
-#define RAW_KEY_04         0xFFF7
-#define RAW_KEY_05         0xFFFE
-#define RAW_KEY_ALT        0xFFBF
-
-#define RAW_KEY_ESC        0xFFEF
-#define RAW_KEY_UP         0xF7FF
-#define RAW_KEY_OK         0xFFDF
-#define RAW_KEY_LEFT       0xFEFF
-#define RAW_KEY_DOWN       0xFBFF
-#define RAW_KEY_RIGHT      0xFDFF
-
-#define RAW_KEY_POWER      0xEFFF
-
-#define RAW_KEY_SETUP      0xFFCF       // combine 'ESCAPE' (0xFFEF') with 'OK' (0xFFDF)
-
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-static HANDLE  hKBEvent;
-static u_short KeyFound;        // use short for 4 nibbles (4 colums)
-static u_char KeyBuffer[KB_BUFFER_SIZE];
-static u_short HoldCounter;
-static u_char KbState;
-static u_char KeyRepeatArray[KEY_NROF_KEYS];
-
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-static void KbClearEvent(HANDLE*);
-static u_char KbRemapKey(u_short LongKey);
-
-
-/*!
- * \addtogroup Keyboard
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-
-
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Clear the eventbuffer of this module
- *
- * This routine is called during module initialization.
- *
- * \param *pEvent pointer to the event queue
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static void KbClearEvent(HANDLE *pEvent)
-{
-    NutEnterCritical();
-
-    *pEvent = 0;
-
-    NutExitCritical();
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Low-level keyboard scan
- *
- * KbScan is called each 4.44 msec from MainBeat interrupt
- * Remember: pressed key gives a '0' on KB_IN_READ
- *
- * After each keyboard-scan, check for a valid MMCard
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-int KbScan()
-{
-    u_char KeyNibble0, KeyNibble1, KeyNibble2, KeyNibble3;
-
-    /*
-     *  we must scan 4 colums, 2 in PORTG and 2 in PORTD
-     */
-
-#ifndef USE_JTAG
-    // scan keys in COL 0
-    cbi (KB_OUT_WRITE_A, KB_COL_0);
-    asm("nop\n\tnop");                    // small delay
-    KeyNibble0 = inp(KB_IN_READ) & KB_ROW_MASK;
-    sbi (KB_OUT_WRITE_A, KB_COL_0);
-
-    // scan keys in COL 1
-    cbi (KB_OUT_WRITE_A, KB_COL_1);
-    asm("nop\n\tnop");                    // small delay
-    KeyNibble1 = inp(KB_IN_READ) & KB_ROW_MASK;
-    sbi (KB_OUT_WRITE_A, KB_COL_1);
-
-    // scan keys in COL 2
-    cbi (KB_OUT_WRITE_B, KB_COL_2);
-    asm("nop\n\tnop");                    // small delay
-    KeyNibble2 = inp(KB_IN_READ) & KB_ROW_MASK;
-    sbi (KB_OUT_WRITE_B, KB_COL_2);
-
-    // scan keys in COL 3
-    cbi (KB_OUT_WRITE_B, KB_COL_3);
-    asm("nop\n\tnop");                    // small delay
-    KeyNibble3 = inp(KB_IN_READ) & KB_ROW_MASK;
-    sbi (KB_OUT_WRITE_B, KB_COL_3);
-
-
-    /*
-     *  we want to detect exactly 1 key in exactly 1 colom
-     *  exception is the combination of VOLMIN & POWER (-> SETUP)
-     *  meaning: Keynibble0==[0000 1011] (KEY_VOLMIN) & KeyNibble1==[0111 0000] (KEY_POWER)
-     */
-
-    /*
-     *  put all 4 seperate nibbles in place in 'KeyFound'
-     *
-     *  KeyNibble0 on b3...b0  (col 0)
-     *  KeyNibble1 on b7...b4  (col 1)
-     *  KeyNibble2 on b11..b8  (col 2)
-     *  KeyNibble3 on b15..b12 (col 3)
-     */
-
-    KeyFound =  ((KeyNibble0>>4) & 0x000F);     // b7..b4 in 'KeyNibble0' to b3...b0  in 'KeyFound' >> shift 4 right
-    KeyFound |= (KeyNibble1 & 0x00F0);          // b7..b4 in 'KeyNibble1' to b7...b4  in 'KeyFound' -- do nothing
-    KeyFound |= ((KeyNibble2<<4) & 0x0F00);     // b7..b4 in 'KeyNibble2' to b11..b8  in 'KeyFound' << shift 4 left
-    KeyFound |= ((KeyNibble3<<8) & 0xF000);     // b7..b4 in 'KeyNibble3' to b15..b12 in 'KeyFound' << shift 8 left
-	return KeyFound;
-#endif  // USE_JTAG
-
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Remap the 16-bit value for the active key to an 8-bit value
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static u_char KbRemapKey(u_short LongKey)
-{
-    switch (LongKey)
-    {
-        case RAW_KEY_01:        return(KEY_01);
-        case RAW_KEY_02:        return(KEY_02);
-        case RAW_KEY_03:        return(KEY_03);
-        case RAW_KEY_04:        return(KEY_04);
-        case RAW_KEY_05:        return(KEY_05);
-        case RAW_KEY_ALT:       return(KEY_ALT);
-
-        case RAW_KEY_ESC:       return(KEY_ESC);
-        case RAW_KEY_UP:        return(KEY_UP);
-        case RAW_KEY_OK:        return(KEY_OK);
-        case RAW_KEY_LEFT:      return(KEY_LEFT);
-        case RAW_KEY_DOWN:      return(KEY_DOWN);
-        case RAW_KEY_RIGHT:     return(KEY_RIGHT);
-
-        case RAW_KEY_POWER:     return(KEY_POWER);
-        case RAW_KEY_SETUP:     return(KEY_SETUP);      // combined key
-
-        default:                return(KEY_UNDEFINED);
-    }
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Return the repeating property for this key
- *
- * \return 'TRUE' in case the key was repeating, 'FALSE' if not
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static u_char KbKeyIsRepeating(u_short Key)
-{
-    return(KeyRepeatArray[KbRemapKey(Key)]==KEY_REPEAT);
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief set the property of this key to repeating or not-repeating
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-void KbSetKeyRepeating(u_char Key, u_char Property)
-{
-    // check arguments
-    if (((Property==KEY_REPEAT) || (Property==KEY_NO_REPEAT)) && (Key < KEY_NROF_KEYS))
-    {
-        KeyRepeatArray[Key]=Property;
-    }
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Wait until an event was pushed on the eventqueue for this module
- *
- * This routine provides the event interface for other Luks-modules
- *
- * \param dwTimeout time in milisecs that this routine should wait before
- * it will return with KB_ERROR
- *
- * \return KB_OK in case an event was found
- * \return KB_ERROR in case no event was found (return due to timeout)
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-int KbWaitForKeyEvent(u_long dwTimeout)
-{
-
-    int nError = KB_OK;
-    int nTimeout;
-
-    nTimeout = NutEventWait(&hKBEvent, dwTimeout);
-    if (nTimeout == -1)
-    {
-        nError = KB_ERROR;
-    }
-
-    return(nError);
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Return the databyte that was receeived in the IR-stream
- *
- * In case a valid key is found in the keyboard scan, the key-code is
- * stored in the keyboardbuffer. This routine returns the first available
- * valid key in this buffer
-
- * \return the keycode that was found by the keyboard scan
- *
- * \todo implement a key-buffer for this routine
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-u_char KbGetKey()
-{
-    return(KeyBuffer[0]);
-}
-
-/*!
- * \brief inject a virtual key into the system
- *
- */
-void KbInjectKey(u_char VirtualKey)
-{
-    KeyBuffer[0]=VirtualKey;
-    NutEventPostFromIrq(&hKBEvent);   // 'valid key' detected -> generate Event
-}
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Initialise the Keyboard module
- *
- *
- * - initialise the keyboard read- and write port
- * - flush the keyboardbuffer
- * - flush the eventqueue for this module
- *
- * \note PORTF uses internal pull-ups. That's why a '1' is read
- * when no key is pressed. Use negative logic to detect keys.
- * So default state of the colums is '1'
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-void KbInit()
-{
-    u_char i;
-
-    sbi (KB_OUT_WRITE_A, KB_COL_0);
-    sbi (KB_OUT_WRITE_A, KB_COL_1);
-    sbi (KB_OUT_WRITE_B, KB_COL_2);
-    sbi (KB_OUT_WRITE_B, KB_COL_3);
-
-    KbState = KB_IDLE;
-    KeyFound = KEY_NO_KEY;
-
-    KbClearEvent(&hKBEvent);
-
-    for (i=0;i<KB_BUFFER_SIZE;++i)
-    {
-        KeyBuffer[i] = (u_char)KEY_NO_KEY;
-    }
-
-    for (i=0; i<KEY_NROF_KEYS; ++i)
-    {
-        KeyRepeatArray[i]=KEY_NO_REPEAT;
-    }
-
-    HoldCounter=0;
-
-    // arrow keys are repeating keys by default
-    KbSetKeyRepeating(KEY_UP, KEY_REPEAT);
-    KbSetKeyRepeating(KEY_DOWN, KEY_REPEAT);
-    KbSetKeyRepeating(KEY_LEFT, KEY_REPEAT);
-    KbSetKeyRepeating(KEY_RIGHT, KEY_REPEAT);
-}
-/* ---------- end of module ------------------------------------------------ */
-
-/*@}*/
+/*! \file
+ * keyboard.c contains the low-level keyboard scan and the
+ * interfacing with NutOS (signalling)
+ *  Copyright STREAMIT, 2010.
+ *  \version 1.0
+ *  \date 26 september 2003
+ */
+
+
+#define LOG_MODULE  LOG_KEYBOARD_MODULE
+
+#include <sys/atom.h>
+#include <sys/event.h>
+
+//#pragma text:appcode
+
+#include "keyboard.h"
+#include "portio.h"
+#include "system.h"
+
+/*-------------------------------------------------------------------------*/
+/* local defines                                                          */
+/*-------------------------------------------------------------------------*/
+/*
+ *  definition of raw keys as found in keyboardscan
+ *  Note that these 16-bit values are remapped before
+ *  the application uses them
+ */
+#define RAW_KEY_01         0xFFFB
+#define RAW_KEY_02         0xFFFD
+#define RAW_KEY_03         0xFF7F
+#define RAW_KEY_04         0xFFF7
+#define RAW_KEY_05         0xFFFE
+#define RAW_KEY_ALT        0xFFBF
+
+#define RAW_KEY_ESC        0xFFEF
+#define RAW_KEY_UP         0xF7FF
+#define RAW_KEY_OK         0xFFDF
+#define RAW_KEY_LEFT       0xFEFF
+#define RAW_KEY_DOWN       0xFBFF
+#define RAW_KEY_RIGHT      0xFDFF
+
+#define RAW_KEY_POWER      0xEFFF
+
+#define RAW_KEY_SETUP      0xFFCF       // combine 'ESCAPE' (0xFFEF') with 'OK' (0xFFDF)
+
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+static HANDLE  hKBEvent;
+static u_short KeyFound;        // use short for 4 nibbles (4 colums)
+static u_char KeyBuffer[KB_BUFFER_SIZE];
+static u_short HoldCounter;
+static u_char KbState;
+static u_char KeyRepeatArray[KEY_NROF_KEYS];
+
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+static void KbClearEvent(HANDLE*);
+static u_char KbRemapKey(u_short LongKey);
+
+
+/*!
+ * \addtogroup Keyboard
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+
+
+
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Clear the eventbuffer of this module
+ *
+ * This routine is called during module initialization.
+ *
+ * \param *pEvent pointer to the event queue
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static void KbClearEvent(HANDLE *pEvent)
+{
+    NutEnterCritical();
+
+    *pEvent = 0;
+
+    NutExitCritical();
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Low-level keyboard scan
+ *
+ * KbScan is called each 4.44 msec from MainBeat interrupt
+ * Remember: pressed key gives a '0' on KB_IN_READ
+ *
+ * After each keyboard-scan, check for a valid MMCard
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void KbScan()
+{
+    u_char KeyNibble0, KeyNibble1, KeyNibble2, KeyNibble3;
+
+    /*
+     *  we must scan 4 colums, 2 in PORTG and 2 in PORTD
+     */
+
+#ifndef USE_JTAG
+    // scan keys in COL 0
+    cbi (KB_OUT_WRITE_A, KB_COL_0);
+    asm("nop\n\tnop");                    // small delay
+    KeyNibble0 = inp(KB_IN_READ) & KB_ROW_MASK;
+    sbi (KB_OUT_WRITE_A, KB_COL_0);
+
+    // scan keys in COL 1
+    cbi (KB_OUT_WRITE_A, KB_COL_1);
+    asm("nop\n\tnop");                    // small delay
+    KeyNibble1 = inp(KB_IN_READ) & KB_ROW_MASK;
+    sbi (KB_OUT_WRITE_A, KB_COL_1);
+
+    // scan keys in COL 2
+    cbi (KB_OUT_WRITE_B, KB_COL_2);
+    asm("nop\n\tnop");                    // small delay
+    KeyNibble2 = inp(KB_IN_READ) & KB_ROW_MASK;
+    sbi (KB_OUT_WRITE_B, KB_COL_2);
+
+    // scan keys in COL 3
+    cbi (KB_OUT_WRITE_B, KB_COL_3);
+    asm("nop\n\tnop");                    // small delay
+    KeyNibble3 = inp(KB_IN_READ) & KB_ROW_MASK;
+    sbi (KB_OUT_WRITE_B, KB_COL_3);
+
+
+    /*
+     *  we want to detect exactly 1 key in exactly 1 colom
+     *  exception is the combination of VOLMIN & POWER (-> SETUP)
+     *  meaning: Keynibble0==[0000 1011] (KEY_VOLMIN) & KeyNibble1==[0111 0000] (KEY_POWER)
+     */
+
+    /*
+     *  put all 4 seperate nibbles in place in 'KeyFound'
+     *
+     *  KeyNibble0 on b3...b0  (col 0)
+     *  KeyNibble1 on b7...b4  (col 1)
+     *  KeyNibble2 on b11..b8  (col 2)
+     *  KeyNibble3 on b15..b12 (col 3)
+     */
+
+    KeyFound =  ((KeyNibble0>>4) & 0x000F);     // b7..b4 in 'KeyNibble0' to b3...b0  in 'KeyFound' >> shift 4 right
+    KeyFound |= (KeyNibble1 & 0x00F0);          // b7..b4 in 'KeyNibble1' to b7...b4  in 'KeyFound' -- do nothing
+    KeyFound |= ((KeyNibble2<<4) & 0x0F00);     // b7..b4 in 'KeyNibble2' to b11..b8  in 'KeyFound' << shift 4 left
+    KeyFound |= ((KeyNibble3<<8) & 0xF000);     // b7..b4 in 'KeyNibble3' to b15..b12 in 'KeyFound' << shift 8 left
+
+
+#endif  // USE_JTAG
+
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Remap the 16-bit value for the active key to an 8-bit value
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static u_char KbRemapKey(u_short LongKey)
+{
+    switch (LongKey)
+    {
+        case RAW_KEY_01:        return(KEY_01);
+        case RAW_KEY_02:        return(KEY_02);
+        case RAW_KEY_03:        return(KEY_03);
+        case RAW_KEY_04:        return(KEY_04);
+        case RAW_KEY_05:        return(KEY_05);
+        case RAW_KEY_ALT:       return(KEY_ALT);
+
+        case RAW_KEY_ESC:       return(KEY_ESC);
+        case RAW_KEY_UP:        return(KEY_UP);
+        case RAW_KEY_OK:        return(KEY_OK);
+        case RAW_KEY_LEFT:      return(KEY_LEFT);
+        case RAW_KEY_DOWN:      return(KEY_DOWN);
+        case RAW_KEY_RIGHT:     return(KEY_RIGHT);
+
+        case RAW_KEY_POWER:     return(KEY_POWER);
+        case RAW_KEY_SETUP:     return(KEY_SETUP);      // combined key
+
+        default:                return(KEY_UNDEFINED);
+    }
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Return the repeating property for this key
+ *
+ * \return 'TRUE' in case the key was repeating, 'FALSE' if not
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static u_char KbKeyIsRepeating(u_short Key)
+{
+    return(KeyRepeatArray[KbRemapKey(Key)]==KEY_REPEAT);
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief set the property of this key to repeating or not-repeating
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void KbSetKeyRepeating(u_char Key, u_char Property)
+{
+    // check arguments
+    if (((Property==KEY_REPEAT) || (Property==KEY_NO_REPEAT)) && (Key < KEY_NROF_KEYS))
+    {
+        KeyRepeatArray[Key]=Property;
+    }
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Wait until an event was pushed on the eventqueue for this module
+ *
+ * This routine provides the event interface for other Luks-modules
+ *
+ * \param dwTimeout time in milisecs that this routine should wait before
+ * it will return with KB_ERROR
+ *
+ * \return KB_OK in case an event was found
+ * \return KB_ERROR in case no event was found (return due to timeout)
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+int KbWaitForKeyEvent(u_long dwTimeout)
+{
+
+    int nError = KB_OK;
+    int nTimeout;
+
+    nTimeout = NutEventWait(&hKBEvent, dwTimeout);
+    if (nTimeout == -1)
+    {
+        nError = KB_ERROR;
+    }
+
+    return(nError);
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Return the databyte that was receeived in the IR-stream
+ *
+ * In case a valid key is found in the keyboard scan, the key-code is
+ * stored in the keyboardbuffer. This routine returns the first available
+ * valid key in this buffer
+
+ * \return the keycode that was found by the keyboard scan
+ *
+ * \todo implement a key-buffer for this routine
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+u_char KbGetKey()
+{
+    return(KeyBuffer[0]);
+}
+
+/*!
+ * \brief inject a virtual key into the system
+ *
+ */
+void KbInjectKey(u_char VirtualKey)
+{
+    KeyBuffer[0]=VirtualKey;
+    NutEventPostFromIrq(&hKBEvent);   // 'valid key' detected -> generate Event
+}
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Initialise the Keyboard module
+ *
+ *
+ * - initialise the keyboard read- and write port
+ * - flush the keyboardbuffer
+ * - flush the eventqueue for this module
+ *
+ * \note PORTF uses internal pull-ups. That's why a '1' is read
+ * when no key is pressed. Use negative logic to detect keys.
+ * So default state of the colums is '1'
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void KbInit()
+{
+    u_char i;
+
+    sbi (KB_OUT_WRITE_A, KB_COL_0);
+    sbi (KB_OUT_WRITE_A, KB_COL_1);
+    sbi (KB_OUT_WRITE_B, KB_COL_2);
+    sbi (KB_OUT_WRITE_B, KB_COL_3);
+
+    KbState = KB_IDLE;
+    KeyFound = KEY_NO_KEY;
+
+    KbClearEvent(&hKBEvent);
+
+    for (i=0;i<KB_BUFFER_SIZE;++i)
+    {
+        KeyBuffer[i] = (u_char)KEY_NO_KEY;
+    }
+
+    for (i=0; i<KEY_NROF_KEYS; ++i)
+    {
+        KeyRepeatArray[i]=KEY_NO_REPEAT;
+    }
+
+    HoldCounter=0;
+
+    // arrow keys are repeating keys by default
+    KbSetKeyRepeating(KEY_UP, KEY_REPEAT);
+    KbSetKeyRepeating(KEY_DOWN, KEY_REPEAT);
+    KbSetKeyRepeating(KEY_LEFT, KEY_REPEAT);
+    KbSetKeyRepeating(KEY_RIGHT, KEY_REPEAT);
+}
+/* ---------- end of module ------------------------------------------------ */
+
+/*@}*/

+ 112 - 113
include/keyboard.h → lib/keyboard.h

@@ -1,113 +1,112 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     Keyboard module
- * [TITLE]      keyboard module source file
- * [FILE]       keyboard.h
- * [VSN]        1.0
- * [CREATED]    28 july 2003
- * [LASTCHNGD]  18 august 2003
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    Keyboard routines
- * ======================================================================== */
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-#define KB_COL_0       3
-#define KB_COL_1       4
-#define KB_COL_2       3
-#define KB_COL_3       2
-
-#define KB_ROW_0       0
-#define KB_ROW_1       1
-#define KB_ROW_2       2
-#define KB_ROW_3       3
-
-#define KB_ROW_MASK    0xF0
-
-#define KB_OK          0x00
-#define KB_ERROR       0x01
-
-/* state machine defines -------------------------------------------------- */
-#define KB_IDLE        0x00
-#define KB_KEY         0x01
-#define KB_VALID       0x02
-#define KB_RELEASE     0x03
-
-#define KB_COUNTER_OK  0x03    // # a key must be seen before declared 'valid'
-#define KB_LONG_HOLD_TIME 500  // 500 x 4.4 msec = 2200 msec
-#define KB_BUFFER_SIZE 1
-
-
-/*
- *  below are the keys after they where remapped to 8-bit values
- *  These definitions are used by the application
- */
-
-#define KEY_SPEC       0
-#define KEY_01         1
-#define KEY_02         2
-#define KEY_03         3
-#define KEY_04         4
-#define KEY_05         5
-#define KEY_ALT        6
-
-#define KEY_ESC        7
-#define KEY_UP         8
-#define KEY_OK         9
-#define KEY_LEFT       10
-#define KEY_DOWN       11
-#define KEY_RIGHT      12
-
-#define KEY_POWER      13
-#define KEY_SETUP      14
-#define KEY_LCD        15       // virtual key, generated when '1' is pressed and hold for > 2 secs
-
-#define KEY_07         18       // only on RC and only used for selftest
-
-#define KEY_NROF_KEYS  16
-
-// next 2 'keys' are simulated when inserting or removing a MMC
-#define KEY_MMC_IN     16
-#define KEY_MMC_OUT    17
-
-
-// remove these, not available on SIR100
-#define KEY_00         0xFC
-
-#define IS_IR_KEY(key)  (((key>=KEY_01) && (key<=KEY_09)) || (key==KEY_00))
-
-/* definition of virtual special keys ------------------------------------- */
-#define KEY_UNDEFINED  0x88
-#define KEY_TIMEOUT    0xAA
-#define KEY_NO_KEY     0xFFFF   // yes, indeed no u_char....
-
-#define KEY_REPEAT_TIME     100 // 100 * 4.48 = about half a second
-#define KEY_REPEAT          1
-#define KEY_NO_REPEAT       2
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-void    KbInit(void);
-int    KbScan(void);
-int 	CheckKey();
-int     KbWaitForKeyEvent(u_long);
-u_char  KbGetKey(void);
-void    KbSetKeyRepeating(u_char, u_char);
-void    KbInjectKey(u_char VirtualKey);
-
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
-
-
-
-
-
-
-
-
-
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     Keyboard module
+ * [TITLE]      keyboard module source file
+ * [FILE]       keyboard.h
+ * [VSN]        1.0
+ * [CREATED]    28 july 2003
+ * [LASTCHNGD]  18 august 2003
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    Keyboard routines
+ * ======================================================================== */
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+#define KB_COL_0       3
+#define KB_COL_1       4
+#define KB_COL_2       3
+#define KB_COL_3       2
+
+#define KB_ROW_0       0
+#define KB_ROW_1       1
+#define KB_ROW_2       2
+#define KB_ROW_3       3
+
+#define KB_ROW_MASK    0xF0
+
+#define KB_OK          0x00
+#define KB_ERROR       0x01
+
+/* state machine defines -------------------------------------------------- */
+#define KB_IDLE        0x00
+#define KB_KEY         0x01
+#define KB_VALID       0x02
+#define KB_RELEASE     0x03
+
+#define KB_COUNTER_OK  0x03    // # a key must be seen before declared 'valid'
+#define KB_LONG_HOLD_TIME 500  // 500 x 4.4 msec = 2200 msec
+#define KB_BUFFER_SIZE 1
+
+
+/*
+ *  below are the keys after they where remapped to 8-bit values
+ *  These definitions are used by the application
+ */
+
+#define KEY_SPEC       0
+#define KEY_01         1
+#define KEY_02         2
+#define KEY_03         3
+#define KEY_04         4
+#define KEY_05         5
+#define KEY_ALT        6
+
+#define KEY_ESC        7
+#define KEY_UP         8
+#define KEY_OK         9
+#define KEY_LEFT       10
+#define KEY_DOWN       11
+#define KEY_RIGHT      12
+
+#define KEY_POWER      13
+#define KEY_SETUP      14
+#define KEY_LCD        15       // virtual key, generated when '1' is pressed and hold for > 2 secs
+
+#define KEY_07         18       // only on RC and only used for selftest
+
+#define KEY_NROF_KEYS  16
+
+// next 2 'keys' are simulated when inserting or removing a MMC
+#define KEY_MMC_IN     16
+#define KEY_MMC_OUT    17
+
+
+// remove these, not available on SIR100
+#define KEY_00         0xFC
+
+#define IS_IR_KEY(key)  (((key>=KEY_01) && (key<=KEY_09)) || (key==KEY_00))
+
+/* definition of virtual special keys ------------------------------------- */
+#define KEY_UNDEFINED  0x88
+#define KEY_TIMEOUT    0xAA
+#define KEY_NO_KEY     0xFFFF   // yes, indeed no u_char....
+
+#define KEY_REPEAT_TIME     100 // 100 * 4.48 = about half a second
+#define KEY_REPEAT          1
+#define KEY_NO_REPEAT       2
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+void    KbInit(void);
+void    KbScan(void);
+int     KbWaitForKeyEvent(u_long);
+u_char  KbGetKey(void);
+void    KbSetKeyRepeating(u_char, u_char);
+void    KbInjectKey(u_char VirtualKey);
+
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 111 - 111
source/led.c → lib/led.c

@@ -1,111 +1,111 @@
-/*! \file
- * Led.c contains all interface- and low-level routines to
- * control the LED
- *  Copyright STREAMIT BV 2010
- *  \version 1.0
- *  \date 26 september 2003
- */
-
-
-#define LOG_MODULE  LOG_LED_MODULE
-
-#include <sys/timer.h>
-#include <sys/thread.h>
-#include <sys/event.h>
-
-#include "system.h"
-#include "portio.h"
-#include "led.h"
-
-static u_char LedStatus;
-
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-
-
-/*!
- * \addtogroup Led
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Interface routine to control the SIR LED
- *
- * Using this routine, the LED can be set to 'ON', 'OFF" or it's state can
- * be toggeld
- *
- * \param LedMode can be eiter 'ON', 'OFF' or 'TOGGLE'
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/************************************************************/
-/*  Control the LED: ON, OFF or TOGGLE                      */
-/*                   in case Lucas is 'OFF' -> return       */
-/************************************************************/
-void LedControl(u_char LedMode)
-{
-   switch (LedMode)
-    {
-        case LED_OFF:
-        case LED_POWER_OFF:
-        case LED_FLASH_OFF:
-            cbi (LED_OUT_WRITE, LED_PIN);
-            LedStatus = LedMode;
-            break;
-        case LED_ON:
-        case LED_POWER_ON:
-        case LED_FLASH_ON:
-            sbi (LED_OUT_WRITE, LED_PIN);
-            LedStatus = LedMode;
-            break;
-        case LED_TOGGLE:
-            if (LedStatus == LED_ON)
-            {
-                cbi (LED_OUT_WRITE, LED_PIN);
-                LedStatus = LED_OFF;
-            }
-            else
-            {
-                sbi (LED_OUT_WRITE, LED_PIN);
-                LedStatus = LED_ON;
-            }
-            break;
-    }
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Initialise the Led module
- *
- * clear LED and update LedStatus
- *
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-void LedInit()
-{
-    cbi (LED_OUT_WRITE, LED_PIN);
-    LedStatus = LED_OFF;
-}
-
-/*!
- * \brief Get LedStatus for external use
- *
- */
-u_char LedGetStatus()
-{
-  return(LedStatus);
-}
-
-/* ---------- end of module ------------------------------------------------ */
-
-/*@}*/
+/*! \file
+ * Led.c contains all interface- and low-level routines to
+ * control the LED
+ *  Copyright STREAMIT BV 2010
+ *  \version 1.0
+ *  \date 26 september 2003
+ */
+
+
+#define LOG_MODULE  LOG_LED_MODULE
+
+#include <sys/timer.h>
+#include <sys/thread.h>
+#include <sys/event.h>
+
+#include "system.h"
+#include "portio.h"
+#include "led.h"
+
+static u_char LedStatus;
+
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+
+
+/*!
+ * \addtogroup Led
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Interface routine to control the SIR LED
+ *
+ * Using this routine, the LED can be set to 'ON', 'OFF" or it's state can
+ * be toggeld
+ *
+ * \param LedMode can be eiter 'ON', 'OFF' or 'TOGGLE'
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/************************************************************/
+/*  Control the LED: ON, OFF or TOGGLE                      */
+/*                   in case Lucas is 'OFF' -> return       */
+/************************************************************/
+void LedControl(u_char LedMode)
+{
+   switch (LedMode)
+    {
+        case LED_OFF:
+        case LED_POWER_OFF:
+        case LED_FLASH_OFF:
+            cbi (LED_OUT_WRITE, LED_PIN);
+            LedStatus = LedMode;
+            break;
+        case LED_ON:
+        case LED_POWER_ON:
+        case LED_FLASH_ON:
+            sbi (LED_OUT_WRITE, LED_PIN);
+            LedStatus = LedMode;
+            break;
+        case LED_TOGGLE:
+            if (LedStatus == LED_ON)
+            {
+                cbi (LED_OUT_WRITE, LED_PIN);
+                LedStatus = LED_OFF;
+            }
+            else
+            {
+                sbi (LED_OUT_WRITE, LED_PIN);
+                LedStatus = LED_ON;
+            }
+            break;
+    }
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Initialise the Led module
+ *
+ * clear LED and update LedStatus
+ *
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void LedInit()
+{
+    cbi (LED_OUT_WRITE, LED_PIN);
+    LedStatus = LED_OFF;
+}
+
+/*!
+ * \brief Get LedStatus for external use
+ *
+ */
+u_char LedGetStatus()
+{
+  return(LedStatus);
+}
+
+/* ---------- end of module ------------------------------------------------ */
+
+/*@}*/

+ 48 - 49
include/led.h → lib/led.h

@@ -1,49 +1,48 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     LED
- * [TITLE]      LED control header file
- * [FILE]       led.h
- * [VSN]        1.0
- * [CREATED]    1 augustus 2003
- * [LASTCHNGD]  23 augustus 2003
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    LED control routines for SIR
- * ======================================================================== */
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-#define LED_OFF         0
-#define LED_ON          1
-#define LED_POWER_ON    2
-#define LED_POWER_OFF   3
-#define LED_TOGGLE      4
-#define LED_FLASH_ON    5
-#define LED_FLASH_OFF   6
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-void LedInit(void);
-void LedControl(u_char);
-u_char LedGetStatus(void);
-
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
-
-
-
-
-
-
-
-
-
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     LED
+ * [TITLE]      LED control header file
+ * [FILE]       led.h
+ * [VSN]        1.0
+ * [CREATED]    1 augustus 2003
+ * [LASTCHNGD]  23 augustus 2003
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    LED control routines for SIR
+ * ======================================================================== */
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+
+#define LED_OFF         0
+#define LED_ON          1
+#define LED_POWER_ON    2
+#define LED_POWER_OFF   3
+#define LED_TOGGLE      4
+#define LED_FLASH_ON    5
+#define LED_FLASH_OFF   6
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+void LedInit(void);
+void LedControl(u_char);
+u_char LedGetStatus(void);
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 371 - 371
source/log.c → lib/log.c

@@ -1,371 +1,371 @@
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Log
- *  File name  $Workfile:   Log.c  $
- *       Last Save $Date:   2003/08/16 15:01:19  $
- *             $Revision:   0.1  $
- *  Creation Date       : 2003/08/16 15:01:19
- *
- *  Description         : Keeps track of log messages
- *                        As an initial implementation this module
- *                        outputs messages to the serial port and uses
- *                        no buffering. (As a result logging delays execution
- *                        as long as the serial write takes)
- *                        At a later stage this module will have a logging
- *                        queue. This will not have much impact on execution
- *                        time. It will output messages to either a serial port
- *                        or telnet client.
- *
- */
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#define LOG_MODULE  LOG_LOG_MODULE
-
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/thread.h>
-#include <sys/heap.h>
-#include <sys/device.h>
-#include <sys/osdebug.h>
-
-//#pragma text:appcode
-
-#include "uart0driver.h"
-//#include "settings.h"
-#include "log.h"
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-/*!\brief Max length of address */
-#define MAX_OFFSET_LEN  8
-
-/*!\brief Max byte values printed on a line */
-#define BYTES_PER_LINE  16
-
-/*!\brief Max number of characters hex dump takes: 2 digits plus trailing blank */
-#define HEX_DUMP_LEN    (BYTES_PER_LINE*3)
-
-/*!\brief Number of characters hex dump + ascii take: 3 chars, 2 blanks, 1 char */
-#define DATA_DUMP_LEN   (HEX_DUMP_LEN + 2 + BYTES_PER_LINE)
-
-/*!\brief Number of characters per line: address, 2 blanks, data dump */
-#define MAX_LINE_LEN    (MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN)
-
-#define LEVEL_MASK      0x07        // b0...b2
-#define NAME_MASK       0xF8        // b3..b7
-
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local variables                                                         */
-/*--------------------------------------------------------------------------*/
-/*!\brief The current log level */
-static TLogLevel    g_tLevel;
-
-/*!\brief Stream to output the log data to */
-static FILE         *g_tStream;
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Local functions                                                         */
-/*--------------------------------------------------------------------------*/
-
-/*!
- * \brief Return the prefix-level for the given log level.
- *
- * \param   tLevel [in] The log level.
- *
- * \return  Pointer to a string in program space.
- */
-static PGM_P LogPrefixLevel_P(TLogLevel tLevel)
-{
-
-    switch (tLevel)
-    {
-        case LOG_EMERG_LEV   :return(PSTR("\n#Emerg "));
-        case LOG_ALERT_LEV   :return(PSTR("\n#Alert "));
-        case LOG_CRIT_LEV    :return(PSTR("\n#Crit  "));
-        case LOG_ERR_LEV     :return(PSTR("\n#Err   "));
-        case LOG_WARNING_LEV :return(PSTR("\n#Warn  "));
-        case LOG_NOTICE_LEV  :return(PSTR("\n#Notic "));
-        case LOG_INFO_LEV    :return(PSTR("\n#Info  "));
-        case LOG_DEBUG_LEV   :return(PSTR("\n#Debug "));
-        default          :return(PSTR("\n"));
-    }
-}
-
-/*!
- * \brief Return the prefix-name for the given log module.
- *
- * \param   tLevel [in] The log module.
- *
- * \return  Pointer to a string in program space.
- */
-static PGM_P LogPrefixName_P(TLogLevel tLevel)
-{
-
-    switch (tLevel)
-    {
-        case LOG_AUDIO_MODULE        :return(PSTR("AU: "));
-        case LOG_CHANNEL_MODULE      :return(PSTR("CH: "));
-        case LOG_COMAND_MODULE       :return(PSTR("CM: "));
-        case LOG_DISPLAY_MODULE      :return(PSTR("DP: "));
-        case LOG_FAT_MODULE          :return(PSTR("FA: "));
-        case LOG_FLASH_MODULE        :return(PSTR("FL: "));
-        case LOG_HTTP_MODULE         :return(PSTR("HT: "));
-        case LOG_INET_MODULE         :return(PSTR("IN: "));
-        case LOG_KEYBOARD_MODULE     :return(PSTR("KB: "));
-        case LOG_LED_MODULE          :return(PSTR("LE: "));
-        case LOG_LOG_MODULE          :return(PSTR("LG: "));
-        case LOG_MAIN_MODULE         :return(PSTR("SY: "));
-        case LOG_MENU_MODULE         :return(PSTR("ME: "));
-        case LOG_MMC_MODULE          :return(PSTR("MM: "));
-        case LOG_MMCDRV_MODULE       :return(PSTR("MD: "));
-        case LOG_PARSE_MODULE        :return(PSTR("PA: "));
-        case LOG_PLAYER_MODULE       :return(PSTR("PL: "));
-        case LOG_REMCON_MODULE       :return(PSTR("RC: "));
-        case LOG_RTC_MODULE          :return(PSTR("RT: "));
-        case LOG_SELFTEST_MODULE     :return(PSTR("ST: "));
-        case LOG_SESSION_MODULE      :return(PSTR("SE: "));
-        case LOG_SETTINGS_MODULE     :return(PSTR("SG: "));
-        case LOG_SPIDRV_MODULE       :return(PSTR("SP: "));
-        case LOG_STREAMER_MODULE     :return(PSTR("SR: "));
-        case LOG_UART0DRIVER_MODULE  :return(PSTR("UA: "));
-        case LOG_UPDATE_MODULE       :return(PSTR("UD: "));
-        case LOG_UTIL_MODULE         :return(PSTR("UT: "));
-        case LOG_VERSION_MODULE      :return(PSTR("VE: "));
-        case LOG_VS10XX_MODULE       :return(PSTR("VS: "));
-        case LOG_WATCHDOG_MODULE     :return(PSTR("WD: "));
-        default          :return(PSTR("?? <DMK> "));
-    }
-}
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*!
- * \brief Initialises this module
- *
- * \param   -
- *
- * \return  -
- */
-void LogInit(void)
-{
-    /* Set default level */
-    g_tLevel = LOG_DEBUG_LEV;
-
-    LogOpen();
-}
-
-/*!
- * \brief Opens the module for use.
- *
- * \param   -
- *
- * \return  -
- */
-void LogOpen(void)
-{
-    /* Associate our stream with a device */
-    g_tStream = Uart0DriverGetStream();
-}
-
-/*!
- * \brief Closes the module.
- *
- * All interface functions from this module will result in void
- * operations.
- *
- * \param   -
- *
- * \return  -
- */
-void LogClose(void)
-{
-    FILE *tPrevStream = g_tStream;
-
-    /* Don't allow adding of new output. */
-    g_tStream = NULL;
-
-    /* Finish all current output. */
-    fflush(tPrevStream);
-}
-
-/*!
- * \brief Log a message to the log medium using a fixed string.
- *
- * The fixed string must reside in program space. It is parsed
- * using the rules of (s)printf.
- *
- * \param tLevel priority level of the message.
- * \param szMsg  format string of the message.
- * \param ...    arguments to the format string.
- */
-void LogMsg_P(TLogLevel tLevel, PGM_P szMsg, ...)
-{
-    va_list ap;
-
-    if (g_tStream)
-    {
-        /* Log the string if the message is more important than the current level */
-        if ((tLevel&LEVEL_MASK) <= g_tLevel)
-        {
-            fputs_P(LogPrefixLevel_P(tLevel&LEVEL_MASK), g_tStream);
-            fputs_P(LogPrefixName_P(tLevel&NAME_MASK), g_tStream);
-            va_start(ap, szMsg);
-            vfprintf_P(g_tStream, szMsg, ap);
-            va_end(ap);
-        }
-    }
-}
-
-void LogChar_P(const char bChar)
-{
-    if (g_tStream)
-    {
-        fputc(bChar, g_tStream);
-    }
-}
-
-/*!
- * \brief Set the priority level
- *
- * \param tNewLevel New priority level
- *
- * \return The previous priority level
- */
-TLogLevel LogSetLevel(TLogLevel tNewLevel)
-{
-    TLogLevel tPrevLevel = g_tLevel;
-
-    if (tNewLevel <= LOG_DEBUG_LEV)
-    {
-        g_tLevel = tNewLevel;
-    }
-    return(tPrevLevel);
-}
-
-/*!
- * \brief Print a block of memory
- *
- * Prints out 16 bytes of data per line
- * Every line starts with the address (offset),
- * the data in hex and that same data in ascii.
- *
- * \param tStream The stream to print to
- * \param cp The data
- * \param length The length of the data
- *
- * \return none
- */
-void HexDump(FILE *tStream, CONST u_char *cp, size_t length)
-{
-    register unsigned int address, i, hex_pos, ascii_pos, l;
-    unsigned int address_len;
-    unsigned char c;
-    char line[MAX_LINE_LEN + 1];
-    static CONST char binhex[16] =
-    {
-        '0', '1', '2', '3', '4', '5', '6', '7',
-        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
-    };
-
-    if (tStream != NULL)
-    {
-        /*
-         * How many digits do we need for the address?
-         * We use at least 4 digits or more as needed
-         */
-        if (((length - 1) & 0xF0000000) != 0)
-        {
-            address_len = 8;
-        }
-        else if (((length - 1) & 0x0F000000) != 0)
-        {
-            address_len = 7;
-        }
-        else if (((length - 1) & 0x00F00000) != 0)
-        {
-            address_len = 6;
-        }
-        else if (((length - 1) & 0x000F0000) != 0)
-        {
-            address_len = 5;
-        }
-        else
-        {
-            address_len = 4;
-        }
-
-        address = 0;
-        i = 0;
-        hex_pos = 0;
-        ascii_pos = 0;
-        while (i < length)
-        {
-            if ((i & 15) == 0)
-            {
-                /*
-                 * Start of a new line.
-                 */
-                memset(line, ' ', sizeof(line));
-                hex_pos = 0;
-                ascii_pos = 0;
-                l = address_len;
-                do
-                {
-                    l--;
-                    c = (address >> (l*4)) & 0xF;
-                    line[hex_pos++] = binhex[c];
-                } while (l != 0);
-
-                /* 2 spaces */
-                hex_pos += 2;
-
-                /*
-                 * Offset in line of ASCII dump.
-                 */
-                ascii_pos = hex_pos + HEX_DUMP_LEN + 2;
-            }
-            c = *cp++;
-
-            /* Dump the hex value */
-            line[hex_pos++] = binhex[c >> 4];
-            line[hex_pos++] = binhex[c & 0xF];
-            hex_pos++;
-
-            /* Print the ascii value */
-            line[ascii_pos++] = (c >= ' ' && c < 127) ? c : '.';
-
-            i++;
-            if ((i & 15) == 0 || i == length)
-            {
-                /*
-                 * We'll be starting a new line, or
-                 * we're finished printing this buffer;
-                 * dump out the line we've constructed,
-                 * and advance the offset.
-                 */
-                line[ascii_pos] = '\0';
-                fputs(line, tStream);
-                fputc('\n', tStream);
-                address += BYTES_PER_LINE;
-            }
-        }
-    }
-}
-
+/*
+ *  Copyright STREAMIT BV, 2010.
+ *
+ *  Project             : SIR
+ *  Module              : Log
+ *  File name  $Workfile:   Log.c  $
+ *       Last Save $Date:   2003/08/16 15:01:19  $
+ *             $Revision:   0.1  $
+ *  Creation Date       : 2003/08/16 15:01:19
+ *
+ *  Description         : Keeps track of log messages
+ *                        As an initial implementation this module
+ *                        outputs messages to the serial port and uses
+ *                        no buffering. (As a result logging delays execution
+ *                        as long as the serial write takes)
+ *                        At a later stage this module will have a logging
+ *                        queue. This will not have much impact on execution
+ *                        time. It will output messages to either a serial port
+ *                        or telnet client.
+ *
+ */
+
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+#define LOG_MODULE  LOG_LOG_MODULE
+
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/thread.h>
+#include <sys/heap.h>
+#include <sys/device.h>
+#include <sys/osdebug.h>
+
+//#pragma text:appcode
+
+#include "uart0driver.h"
+//#include "settings.h"
+#include "log.h"
+
+/*--------------------------------------------------------------------------*/
+/*  Constant definitions                                                    */
+/*--------------------------------------------------------------------------*/
+/*!\brief Max length of address */
+#define MAX_OFFSET_LEN  8
+
+/*!\brief Max byte values printed on a line */
+#define BYTES_PER_LINE  16
+
+/*!\brief Max number of characters hex dump takes: 2 digits plus trailing blank */
+#define HEX_DUMP_LEN    (BYTES_PER_LINE*3)
+
+/*!\brief Number of characters hex dump + ascii take: 3 chars, 2 blanks, 1 char */
+#define DATA_DUMP_LEN   (HEX_DUMP_LEN + 2 + BYTES_PER_LINE)
+
+/*!\brief Number of characters per line: address, 2 blanks, data dump */
+#define MAX_LINE_LEN    (MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN)
+
+#define LEVEL_MASK      0x07        // b0...b2
+#define NAME_MASK       0xF8        // b3..b7
+
+
+/*--------------------------------------------------------------------------*/
+/*  Type declarations                                                       */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Local variables                                                         */
+/*--------------------------------------------------------------------------*/
+/*!\brief The current log level */
+static TLogLevel    g_tLevel;
+
+/*!\brief Stream to output the log data to */
+static FILE         *g_tStream;
+
+/*--------------------------------------------------------------------------*/
+/*  Global variables                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Local functions                                                         */
+/*--------------------------------------------------------------------------*/
+
+/*!
+ * \brief Return the prefix-level for the given log level.
+ *
+ * \param   tLevel [in] The log level.
+ *
+ * \return  Pointer to a string in program space.
+ */
+static PGM_P LogPrefixLevel_P(TLogLevel tLevel)
+{
+
+    switch (tLevel)
+    {
+        case LOG_EMERG_LEV   :return(PSTR("\n#Emerg "));
+        case LOG_ALERT_LEV   :return(PSTR("\n#Alert "));
+        case LOG_CRIT_LEV    :return(PSTR("\n#Crit  "));
+        case LOG_ERR_LEV     :return(PSTR("\n#Err   "));
+        case LOG_WARNING_LEV :return(PSTR("\n#Warn  "));
+        case LOG_NOTICE_LEV  :return(PSTR("\n#Notic "));
+        case LOG_INFO_LEV    :return(PSTR("\n#Info  "));
+        case LOG_DEBUG_LEV   :return(PSTR("\n#Debug "));
+        default          :return(PSTR("\n"));
+    }
+}
+
+/*!
+ * \brief Return the prefix-name for the given log module.
+ *
+ * \param   tLevel [in] The log module.
+ *
+ * \return  Pointer to a string in program space.
+ */
+static PGM_P LogPrefixName_P(TLogLevel tLevel)
+{
+
+    switch (tLevel)
+    {
+        case LOG_AUDIO_MODULE        :return(PSTR("AU: "));
+        case LOG_CHANNEL_MODULE      :return(PSTR("CH: "));
+        case LOG_COMAND_MODULE       :return(PSTR("CM: "));
+        case LOG_DISPLAY_MODULE      :return(PSTR("DP: "));
+        case LOG_FAT_MODULE          :return(PSTR("FA: "));
+        case LOG_FLASH_MODULE        :return(PSTR("FL: "));
+        case LOG_HTTP_MODULE         :return(PSTR("HT: "));
+        case LOG_INET_MODULE         :return(PSTR("IN: "));
+        case LOG_KEYBOARD_MODULE     :return(PSTR("KB: "));
+        case LOG_LED_MODULE          :return(PSTR("LE: "));
+        case LOG_LOG_MODULE          :return(PSTR("LG: "));
+        case LOG_MAIN_MODULE         :return(PSTR("SY: "));
+        case LOG_MENU_MODULE         :return(PSTR("ME: "));
+        case LOG_MMC_MODULE          :return(PSTR("MM: "));
+        case LOG_MMCDRV_MODULE       :return(PSTR("MD: "));
+        case LOG_PARSE_MODULE        :return(PSTR("PA: "));
+        case LOG_PLAYER_MODULE       :return(PSTR("PL: "));
+        case LOG_REMCON_MODULE       :return(PSTR("RC: "));
+        case LOG_RTC_MODULE          :return(PSTR("RT: "));
+        case LOG_SELFTEST_MODULE     :return(PSTR("ST: "));
+        case LOG_SESSION_MODULE      :return(PSTR("SE: "));
+        case LOG_SETTINGS_MODULE     :return(PSTR("SG: "));
+        case LOG_SPIDRV_MODULE       :return(PSTR("SP: "));
+        case LOG_STREAMER_MODULE     :return(PSTR("SR: "));
+        case LOG_UART0DRIVER_MODULE  :return(PSTR("UA: "));
+        case LOG_UPDATE_MODULE       :return(PSTR("UD: "));
+        case LOG_UTIL_MODULE         :return(PSTR("UT: "));
+        case LOG_VERSION_MODULE      :return(PSTR("VE: "));
+        case LOG_VS10XX_MODULE       :return(PSTR("VS: "));
+        case LOG_WATCHDOG_MODULE     :return(PSTR("WD: "));
+        default          :return(PSTR("?? <DMK> "));
+    }
+}
+
+/*--------------------------------------------------------------------------*/
+/*  Global functions                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*!
+ * \brief Initialises this module
+ *
+ * \param   -
+ *
+ * \return  -
+ */
+void LogInit(void)
+{
+    /* Set default level */
+    g_tLevel = LOG_DEBUG_LEV;
+
+    LogOpen();
+}
+
+/*!
+ * \brief Opens the module for use.
+ *
+ * \param   -
+ *
+ * \return  -
+ */
+void LogOpen(void)
+{
+    /* Associate our stream with a device */
+    g_tStream = Uart0DriverGetStream();
+}
+
+/*!
+ * \brief Closes the module.
+ *
+ * All interface functions from this module will result in void
+ * operations.
+ *
+ * \param   -
+ *
+ * \return  -
+ */
+void LogClose(void)
+{
+    FILE *tPrevStream = g_tStream;
+
+    /* Don't allow adding of new output. */
+    g_tStream = NULL;
+
+    /* Finish all current output. */
+    fflush(tPrevStream);
+}
+
+/*!
+ * \brief Log a message to the log medium using a fixed string.
+ *
+ * The fixed string must reside in program space. It is parsed
+ * using the rules of (s)printf.
+ *
+ * \param tLevel priority level of the message.
+ * \param szMsg  format string of the message.
+ * \param ...    arguments to the format string.
+ */
+void LogMsg_P(TLogLevel tLevel, PGM_P szMsg, ...)
+{
+    va_list ap;
+
+    if (g_tStream)
+    {
+        /* Log the string if the message is more important than the current level */
+        if ((tLevel&LEVEL_MASK) <= g_tLevel)
+        {
+            fputs_P(LogPrefixLevel_P(tLevel&LEVEL_MASK), g_tStream);
+            fputs_P(LogPrefixName_P(tLevel&NAME_MASK), g_tStream);
+            va_start(ap, szMsg);
+            vfprintf_P(g_tStream, szMsg, ap);
+            va_end(ap);
+        }
+    }
+}
+
+void LogChar_P(const char bChar)
+{
+    if (g_tStream)
+    {
+        fputc(bChar, g_tStream);
+    }
+}
+
+/*!
+ * \brief Set the priority level
+ *
+ * \param tNewLevel New priority level
+ *
+ * \return The previous priority level
+ */
+TLogLevel LogSetLevel(TLogLevel tNewLevel)
+{
+    TLogLevel tPrevLevel = g_tLevel;
+
+    if (tNewLevel <= LOG_DEBUG_LEV)
+    {
+        g_tLevel = tNewLevel;
+    }
+    return(tPrevLevel);
+}
+
+/*!
+ * \brief Print a block of memory
+ *
+ * Prints out 16 bytes of data per line
+ * Every line starts with the address (offset),
+ * the data in hex and that same data in ascii.
+ *
+ * \param tStream The stream to print to
+ * \param cp The data
+ * \param length The length of the data
+ *
+ * \return none
+ */
+void HexDump(FILE *tStream, CONST u_char *cp, size_t length)
+{
+    register unsigned int address, i, hex_pos, ascii_pos, l;
+    unsigned int address_len;
+    unsigned char c;
+    char line[MAX_LINE_LEN + 1];
+    static CONST char binhex[16] =
+    {
+        '0', '1', '2', '3', '4', '5', '6', '7',
+        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+    };
+
+    if (tStream != NULL)
+    {
+        /*
+         * How many digits do we need for the address?
+         * We use at least 4 digits or more as needed
+         */
+        if (((length - 1) & 0xF0000000) != 0)
+        {
+            address_len = 8;
+        }
+        else if (((length - 1) & 0x0F000000) != 0)
+        {
+            address_len = 7;
+        }
+        else if (((length - 1) & 0x00F00000) != 0)
+        {
+            address_len = 6;
+        }
+        else if (((length - 1) & 0x000F0000) != 0)
+        {
+            address_len = 5;
+        }
+        else
+        {
+            address_len = 4;
+        }
+
+        address = 0;
+        i = 0;
+        hex_pos = 0;
+        ascii_pos = 0;
+        while (i < length)
+        {
+            if ((i & 15) == 0)
+            {
+                /*
+                 * Start of a new line.
+                 */
+                memset(line, ' ', sizeof(line));
+                hex_pos = 0;
+                ascii_pos = 0;
+                l = address_len;
+                do
+                {
+                    l--;
+                    c = (address >> (l*4)) & 0xF;
+                    line[hex_pos++] = binhex[c];
+                } while (l != 0);
+
+                /* 2 spaces */
+                hex_pos += 2;
+
+                /*
+                 * Offset in line of ASCII dump.
+                 */
+                ascii_pos = hex_pos + HEX_DUMP_LEN + 2;
+            }
+            c = *cp++;
+
+            /* Dump the hex value */
+            line[hex_pos++] = binhex[c >> 4];
+            line[hex_pos++] = binhex[c & 0xF];
+            hex_pos++;
+
+            /* Print the ascii value */
+            line[ascii_pos++] = (c >= ' ' && c < 127) ? c : '.';
+
+            i++;
+            if ((i & 15) == 0 || i == length)
+            {
+                /*
+                 * We'll be starting a new line, or
+                 * we're finished printing this buffer;
+                 * dump out the line we've constructed,
+                 * and advance the offset.
+                 */
+                line[ascii_pos] = '\0';
+                fputs(line, tStream);
+                fputc('\n', tStream);
+                address += BYTES_PER_LINE;
+            }
+        }
+    }
+}
+

+ 131 - 131
include/log.h → lib/log.h

@@ -1,131 +1,131 @@
-#ifndef _Log_H
-#define _Log_H
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Log
- *  File name  $Workfile: Log.h  $
- *       Last Save $Date: 2003/08/16 15:01:36  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2003/08/16 15:01:36
- *
- *  Description         :
- *
- */
-
-/*!
- *\ brief Define this to output raw unformatted output.
- *
- * Advantage of RAW is you can use fprintf(stdout, "format", ...) anywhere.
- * Disadvantage is that there is no selection on loglevel and that there
- * is no indication whether it is a warning, error, etc.
- */
-//#define LOG_RAW
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-#ifdef LOG_RAW
-#define LogMsg_P            fputc('\n', stdout);fprintf_P
-#endif
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-/*! \brief The log priority levels
- * The first entry has the highest priority
- */
-#ifdef LOG_RAW
-#define LOG_EMERG stdout
-#define LOG_ALERT stdout
-#define LOG_CRIT stdout
-#define LOG_ERR stdout
-#define LOG_WARNING stdout
-#define LOG_NOTICE stdout
-#define LOG_INFO stdout
-#define LOG_DEBUG stdout
-typedef FILE * TLogLevel;
-#else
-typedef u_char TLogLevel;
-#endif
-
-// bit 0..2 for LEVEL
-#define LOG_EMERG_LEV   0x00
-#define LOG_ALERT_LEV   0x01
-#define LOG_CRIT_LEV    0x02
-#define LOG_ERR_LEV     0x03
-#define LOG_WARNING_LEV 0x04
-#define LOG_NOTICE_LEV  0x05
-#define LOG_INFO_LEV    0x06
-#define LOG_DEBUG_LEV   0x07
-
-// bit 3..7 for MODULE
-#define LOG_AUDIO_MODULE        0x10
-#define LOG_CHANNEL_MODULE      0x20
-#define LOG_COMAND_MODULE       0x30
-#define LOG_DISPLAY_MODULE      0x40
-#define LOG_FAT_MODULE          0x50
-#define LOG_FLASH_MODULE        0x60
-#define LOG_HTTP_MODULE         0x70
-#define LOG_INET_MODULE         0x80
-#define LOG_KEYBOARD_MODULE     0x90
-#define LOG_LED_MODULE          0xA0
-#define LOG_LOG_MODULE          0xB0
-#define LOG_MAIN_MODULE         0xC0
-#define LOG_MENU_MODULE         0xD0
-#define LOG_MMC_MODULE          0xE0
-#define LOG_MMCDRV_MODULE       0xF0
-#define LOG_PARSE_MODULE        0x08
-#define LOG_PLAYER_MODULE       0x18
-#define LOG_REMCON_MODULE       0x28
-#define LOG_RTC_MODULE          0x38
-#define LOG_SELFTEST_MODULE     0x48
-#define LOG_SESSION_MODULE      0x58
-#define LOG_SETTINGS_MODULE     0x68
-#define LOG_SPIDRV_MODULE       0x78
-#define LOG_STREAMER_MODULE     0x88
-#define LOG_UART0DRIVER_MODULE  0x98
-#define LOG_UPDATE_MODULE       0xA8
-#define LOG_UTIL_MODULE         0xB8
-#define LOG_VERSION_MODULE      0xC8
-#define LOG_VS10XX_MODULE       0xD8
-#define LOG_WATCHDOG_MODULE     0xE8
-
-// note that LOG_MODULE must be defined before including this "log.h"
-#define LOG_EMERG       (TLogLevel)(LOG_EMERG_LEV   | LOG_MODULE)
-#define LOG_ALERT       (TLogLevel)(LOG_ALERT_LEV   | LOG_MODULE)
-#define LOG_CRIT        (TLogLevel)(LOG_CRIT_LEV    | LOG_MODULE)
-#define LOG_ERR         (TLogLevel)(LOG_ERR_LEV     | LOG_MODULE)
-#define LOG_WARNING     (TLogLevel)(LOG_WARNING_LEV | LOG_MODULE)
-#define LOG_NOTICE      (TLogLevel)(LOG_NOTICE_LEV  | LOG_MODULE)
-#define LOG_INFO        (TLogLevel)(LOG_INFO_LEV    | LOG_MODULE)
-#define LOG_DEBUG       (TLogLevel)(LOG_DEBUG_LEV   | LOG_MODULE)
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-extern void LogInit(void);
-
-extern void LogOpen(void);
-extern void LogClose(void);
-
-#ifndef LOG_RAW
-extern void LogMsg_P(TLogLevel tLevel, PGM_P szMsg, ...);
-extern void LogChar_P(const char bChar);
-#endif
-
-extern TLogLevel LogSetLevel(TLogLevel tLevel);
-
-extern void HexDump(FILE *stream, CONST unsigned char *cp, size_t length);
-
-#endif /* _Log_H */
+#ifndef _Log_H
+#define _Log_H
+/*
+ *  Copyright STREAMIT BV, 2010.
+ *
+ *  Project             : SIR
+ *  Module              : Log
+ *  File name  $Workfile: Log.h  $
+ *       Last Save $Date: 2003/08/16 15:01:36  $
+ *             $Revision: 0.1  $
+ *  Creation Date       : 2003/08/16 15:01:36
+ *
+ *  Description         :
+ *
+ */
+
+/*!
+ *\ brief Define this to output raw unformatted output.
+ *
+ * Advantage of RAW is you can use fprintf(stdout, "format", ...) anywhere.
+ * Disadvantage is that there is no selection on loglevel and that there
+ * is no indication whether it is a warning, error, etc.
+ */
+//#define LOG_RAW
+
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+#include <stdio.h>
+
+/*--------------------------------------------------------------------------*/
+/*  Constant definitions                                                    */
+/*--------------------------------------------------------------------------*/
+#ifdef LOG_RAW
+#define LogMsg_P            fputc('\n', stdout);fprintf_P
+#endif
+
+/*--------------------------------------------------------------------------*/
+/*  Type declarations                                                       */
+/*--------------------------------------------------------------------------*/
+/*! \brief The log priority levels
+ * The first entry has the highest priority
+ */
+#ifdef LOG_RAW
+#define LOG_EMERG stdout
+#define LOG_ALERT stdout
+#define LOG_CRIT stdout
+#define LOG_ERR stdout
+#define LOG_WARNING stdout
+#define LOG_NOTICE stdout
+#define LOG_INFO stdout
+#define LOG_DEBUG stdout
+typedef FILE * TLogLevel;
+#else
+typedef u_char TLogLevel;
+#endif
+
+// bit 0..2 for LEVEL
+#define LOG_EMERG_LEV   0x00
+#define LOG_ALERT_LEV   0x01
+#define LOG_CRIT_LEV    0x02
+#define LOG_ERR_LEV     0x03
+#define LOG_WARNING_LEV 0x04
+#define LOG_NOTICE_LEV  0x05
+#define LOG_INFO_LEV    0x06
+#define LOG_DEBUG_LEV   0x07
+
+// bit 3..7 for MODULE
+#define LOG_AUDIO_MODULE        0x10
+#define LOG_CHANNEL_MODULE      0x20
+#define LOG_COMAND_MODULE       0x30
+#define LOG_DISPLAY_MODULE      0x40
+#define LOG_FAT_MODULE          0x50
+#define LOG_FLASH_MODULE        0x60
+#define LOG_HTTP_MODULE         0x70
+#define LOG_INET_MODULE         0x80
+#define LOG_KEYBOARD_MODULE     0x90
+#define LOG_LED_MODULE          0xA0
+#define LOG_LOG_MODULE          0xB0
+#define LOG_MAIN_MODULE         0xC0
+#define LOG_MENU_MODULE         0xD0
+#define LOG_MMC_MODULE          0xE0
+#define LOG_MMCDRV_MODULE       0xF0
+#define LOG_PARSE_MODULE        0x08
+#define LOG_PLAYER_MODULE       0x18
+#define LOG_REMCON_MODULE       0x28
+#define LOG_RTC_MODULE          0x38
+#define LOG_SELFTEST_MODULE     0x48
+#define LOG_SESSION_MODULE      0x58
+#define LOG_SETTINGS_MODULE     0x68
+#define LOG_SPIDRV_MODULE       0x78
+#define LOG_STREAMER_MODULE     0x88
+#define LOG_UART0DRIVER_MODULE  0x98
+#define LOG_UPDATE_MODULE       0xA8
+#define LOG_UTIL_MODULE         0xB8
+#define LOG_VERSION_MODULE      0xC8
+#define LOG_VS10XX_MODULE       0xD8
+#define LOG_WATCHDOG_MODULE     0xE8
+
+// note that LOG_MODULE must be defined before including this "log.h"
+#define LOG_EMERG       (TLogLevel)(LOG_EMERG_LEV   | LOG_MODULE)
+#define LOG_ALERT       (TLogLevel)(LOG_ALERT_LEV   | LOG_MODULE)
+#define LOG_CRIT        (TLogLevel)(LOG_CRIT_LEV    | LOG_MODULE)
+#define LOG_ERR         (TLogLevel)(LOG_ERR_LEV     | LOG_MODULE)
+#define LOG_WARNING     (TLogLevel)(LOG_WARNING_LEV | LOG_MODULE)
+#define LOG_NOTICE      (TLogLevel)(LOG_NOTICE_LEV  | LOG_MODULE)
+#define LOG_INFO        (TLogLevel)(LOG_INFO_LEV    | LOG_MODULE)
+#define LOG_DEBUG       (TLogLevel)(LOG_DEBUG_LEV   | LOG_MODULE)
+
+/*--------------------------------------------------------------------------*/
+/*  Global variables                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Global functions                                                        */
+/*--------------------------------------------------------------------------*/
+extern void LogInit(void);
+
+extern void LogOpen(void);
+extern void LogClose(void);
+
+#ifndef LOG_RAW
+extern void LogMsg_P(TLogLevel tLevel, PGM_P szMsg, ...);
+extern void LogChar_P(const char bChar);
+#endif
+
+extern TLogLevel LogSetLevel(TLogLevel tLevel);
+
+extern void HexDump(FILE *stream, CONST unsigned char *cp, size_t length);
+
+#endif /* _Log_H */

+ 347 - 347
source/mmc.c → lib/mmc.c

@@ -1,347 +1,347 @@
-/* ========================================================================
- * [PROJECT]    SIR100
- * [MODULE]     MMC driver
- * [TITLE]      Media Card driver
- * [FILE]       mmc.c
- * [VSN]        1.0
- * [CREATED]    02 october 2006
- * [LASTCHNGD]  20 may 2007
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    routines and API to support MMC-application
- * ======================================================================== */
-
-#define LOG_MODULE  LOG_MMC_MODULE
-
-#include <string.h>
-#include <stdio.h>
-#include <io.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <ctype.h>
-
-#include <sys/event.h>
-#include <sys/thread.h>
-#include <sys/timer.h>
-#include <sys/device.h>
-#include <sys/bankmem.h>
-#include <sys/heap.h>
-
-//#pragma text:appcode
-
-#include "system.h"
-#include "mmc.h"
-#include "portio.h"
-#include "vs10xx.h"
-#include "display.h"
-#include "log.h"
-#include "fat.h"
-#include "mmcdrv.h"
-#include "led.h"
-#include "keyboard.h"
-
-#ifdef DEBUG
-//#define MMC__DEBUG
-#endif /* #ifdef DEBUG */
-/*-------------------------------------------------------------------------*/
-/* local defines                                                           */
-/*-------------------------------------------------------------------------*/
-
-#define CARD_PRESENT_COUNTER_OK         30
-#define CARD_NOT_PRESENT_COUNTER_OK     20
-
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-/*!\brief Statemachine for card-detection */
-typedef enum T_CARD_STATE
-{
-    CARD_IDLE,                      /* nothing to do */
-    CARD_PRESENT,                   /* card seen at least one time */
-    CARD_VALID,                     /* card seen at least <valid> times */
-    CARD_NOT_PRESENT                /* card not seen at least (valid> times */
-}TCardState;
-
-
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-static u_char CardPresentFlag;
-static u_char ValidateCounter;
-
-/*!\brief state-variable for Card-statemachine */
-static TCardState CardState;
-
-/*!\brief Status of this module */
-static TError g_tStatus;
-
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-
-
-
-/*!
- * \addtogroup Card
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-/*!
- * \brief check if MM-Card is inserted or removed.
- *
- * \Note: this routine is called from an ISR !
- *
- */
-u_char CardCheckCard(void)
-{
-    u_char RetValue=CARD_NO_CHANGE;
-
-    switch (CardState)
-    {
-        case CARD_IDLE:
-            {
-                if (bit_is_clear(MMC_IN_READ, MMC_CDETECT))
-                {
-                    ValidateCounter=1;
-                    CardState = CARD_PRESENT;
-                }
-            }
-            break;
-        case CARD_PRESENT:
-            {
-                if (bit_is_clear(MMC_IN_READ, MMC_CDETECT))
-                {
-                    if (++ValidateCounter==CARD_PRESENT_COUNTER_OK)
-                    {
-                        CardPresentFlag=CARD_IS_PRESENT;
-                        CardState=CARD_VALID;
-                        RetValue=CARD_IS_PRESENT;
-                    }
-                }
-                else
-                {
-                    CardState=CARD_IDLE;                  // false alarm,start over again
-                }
-            }
-            break;
-        case CARD_VALID:
-            {
-                if (bit_is_set(MMC_IN_READ, MMC_CDETECT))
-                {
-                    ValidateCounter=1;
-                    CardState=CARD_NOT_PRESENT;         // Card removed
-                }
-            }
-            break;
-        case CARD_NOT_PRESENT:
-            {
-                if (++ValidateCounter==CARD_NOT_PRESENT_COUNTER_OK)
-                {
-                    CardPresentFlag=CARD_IS_NOT_PRESENT;
-                    CardState=CARD_IDLE;
-                    RetValue=CARD_IS_NOT_PRESENT;
-                }
-            }
-            break;
-    }
-    return(RetValue);
-}
-
-/*!
- * \brief return status of "Card is Present"
- *
- */
-u_char CardCheckPresent()
-{
-    return(CardPresentFlag);
-}
-
-/*!
- * \brief initialise the card by reading card contents (.pls files)
- *
- * We initialse the card by registering the card and the filesystem
- * that is on the card.
- *
- * Then we start checking if a number of playlists are
- * present on the card. The names of these playlists are hardcoded
- * (1.pls, 2.pls, to 20.pls). We 'search' the card for these list
- * of playlists by trying to open them. If succesfull, we read the
- * number of songs present (int) in that list
- * Finally we update some administration (global) variables
- *
- */
-int CardInitCard()
-{
-    int iResult=-1;
-    int fid;        // current file descriptor
-    char szFileName[10];
-    //u_char i;
-	u_char ief;
-
-    /*
-     * Register our device for the file system (if not done already.....)
-     */
-    if (NutDeviceLookup(devFAT.dev_name) == 0)
-    {
-        ief = VsPlayerInterrupts(0);
-        if ((iResult=NutRegisterDevice(&devFAT, FAT_MODE_MMC, 0)) == 0)
-        {
-            iResult=NutRegisterDevice(&devFATMMC0, FAT_MODE_MMC, 0);
-        }
-        VsPlayerInterrupts(ief);
-    }
-    else
-    {
-        NUTDEVICE * dev;
-
-        /*
-         *  we must call 'FatInit' here to initialise and mount the filesystem (again)
-         */
-
-        FATRelease();
-        ief = VsPlayerInterrupts(0);
-        dev=&devFAT;
-        if (dev->dev_init == 0 || (*dev->dev_init)(dev) == 0)
-        {
-            dev=&devFATMMC0;
-            if (dev->dev_init == 0 || (*dev->dev_init)(dev) == 0)
-            {
-                iResult=0;
-            }
-        }
-        VsPlayerInterrupts(ief);
-    }
-
-    if (iResult==0)
-    {
-        LogMsg_P(LOG_INFO, PSTR("Card mounted"));
-        /*
-         *  try to open the playlists. If an error is returned, we assume the
-         *  playlist does not exist and we do not check any further lists
-         */
-
-		 /* Kroeske: onderstaande code ter illustratie om file op card te openen */
-		 
- //       for (i=1; i<SETTINGS_NROF_PLAYLISTST; ++i)
- //       {
-            // compose name to open
-            //sprintf_P(szFileName, PSTR("FM0:%d.pls"), i);
-            if ((fid = _open(szFileName, _O_RDONLY)) != -1)
-            {
-                _close(fid);
-            }
-            else
-            {
-
-                //g_NrofPlayLists=i-1;
-                //LogMsg_P(LOG_INFO, PSTR("Found %d Playlists on the Card"), i-1);
- //               break;
-            }
-//        }
-    }
-    else
-    {
-        LogMsg_P(LOG_ERR, PSTR("Error initialising File system and Card-driver"));
-    }
-
-    return(iResult);
-}
-
-/*!
- * \brief The CardPresent thread.
- *
- * execute code when card is inserted or redrawn
- *
- * \param   -
- *
- * \return  -
- */
-THREAD(CardPresent, pArg)
-{
-    static u_char OldCardStatus;
-
-    OldCardStatus=CardPresentFlag;
-
-    for (;;)
-    {
-        if ((CardPresentFlag==CARD_IS_PRESENT) && (OldCardStatus==CARD_IS_NOT_PRESENT))
-        {
-            LogMsg_P(LOG_INFO, PSTR("Card inserted"));
-            if (CardInitCard()==0)
-            {
-                KbInjectKey(KEY_MMC_IN);
-            }
-            OldCardStatus=CardPresentFlag;
-        }
-        else if ((CardPresentFlag==CARD_IS_NOT_PRESENT) && (OldCardStatus==CARD_IS_PRESENT))
-        {
-            LogMsg_P(LOG_INFO, PSTR("Card removed"));
-            CardClose();
-            OldCardStatus=CardPresentFlag;
-        }
-        else
-        {
-            NutSleep(500);
-        }
-    }
-}
-
-
-/*!
- * \brief return global variable that indicates the status of this module
- *
- */
-TError CardStatus(void)
-{
-    return(g_tStatus);
-}
-
-/*!
- * \brief Stop playing.
- *
- * \param   -
- *
- * \return  -
- */
-void CardClose(void)
-{
-
-}
-
-
-/*!
- * \brief initialise this module
- *
- */
-void CardInit()
-{
-    char ThreadName[10];
-
-    CardState=CARD_IDLE;
-    CardPresentFlag=CARD_IS_NOT_PRESENT;
-
-    /*
-     * Create a CardPresent thread
-     */
-    strcpy_P(ThreadName, PSTR("CardPres"));
-
-    if (GetThreadByName((char *)ThreadName) == NULL)
-    {
-        if (NutThreadCreate((char *)ThreadName, CardPresent, 0, 768) == 0)
-        {
-            LogMsg_P(LOG_EMERG, PSTR("Thread failed"));
-        }
-    }
-
-}
-
-/* ---------- end of module ------------------------------------------------ */
-
-/*@}*/
-
-
+/* ========================================================================
+ * [PROJECT]    SIR100
+ * [MODULE]     MMC driver
+ * [TITLE]      Media Card driver
+ * [FILE]       mmc.c
+ * [VSN]        1.0
+ * [CREATED]    02 october 2006
+ * [LASTCHNGD]  20 may 2007
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    routines and API to support MMC-application
+ * ======================================================================== */
+
+#define LOG_MODULE  LOG_MMC_MODULE
+
+#include <string.h>
+#include <stdio.h>
+#include <io.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+
+#include <sys/event.h>
+#include <sys/thread.h>
+#include <sys/timer.h>
+#include <sys/device.h>
+#include <sys/bankmem.h>
+#include <sys/heap.h>
+
+//#pragma text:appcode
+
+#include "system.h"
+#include "mmc.h"
+#include "portio.h"
+#include "vs10xx.h"
+#include "display.h"
+#include "log.h"
+#include "fat.h"
+#include "mmcdrv.h"
+#include "led.h"
+#include "keyboard.h"
+
+#ifdef DEBUG
+//#define MMC__DEBUG
+#endif /* #ifdef DEBUG */
+/*-------------------------------------------------------------------------*/
+/* local defines                                                           */
+/*-------------------------------------------------------------------------*/
+
+#define CARD_PRESENT_COUNTER_OK         30
+#define CARD_NOT_PRESENT_COUNTER_OK     20
+
+
+/*--------------------------------------------------------------------------*/
+/*  Type declarations                                                       */
+/*--------------------------------------------------------------------------*/
+/*!\brief Statemachine for card-detection */
+typedef enum T_CARD_STATE
+{
+    CARD_IDLE,                      /* nothing to do */
+    CARD_PRESENT,                   /* card seen at least one time */
+    CARD_VALID,                     /* card seen at least <valid> times */
+    CARD_NOT_PRESENT                /* card not seen at least (valid> times */
+}TCardState;
+
+
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+static u_char CardPresentFlag;
+static u_char ValidateCounter;
+
+/*!\brief state-variable for Card-statemachine */
+static TCardState CardState;
+
+/*!\brief Status of this module */
+static TError g_tStatus;
+
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+
+
+
+/*!
+ * \addtogroup Card
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+
+/*!
+ * \brief check if MM-Card is inserted or removed.
+ *
+ * \Note: this routine is called from an ISR !
+ *
+ */
+u_char CardCheckCard(void)
+{
+    u_char RetValue=CARD_NO_CHANGE;
+
+    switch (CardState)
+    {
+        case CARD_IDLE:
+            {
+                if (bit_is_clear(MMC_IN_READ, MMC_CDETECT))
+                {
+                    ValidateCounter=1;
+                    CardState = CARD_PRESENT;
+                }
+            }
+            break;
+        case CARD_PRESENT:
+            {
+                if (bit_is_clear(MMC_IN_READ, MMC_CDETECT))
+                {
+                    if (++ValidateCounter==CARD_PRESENT_COUNTER_OK)
+                    {
+                        CardPresentFlag=CARD_IS_PRESENT;
+                        CardState=CARD_VALID;
+                        RetValue=CARD_IS_PRESENT;
+                    }
+                }
+                else
+                {
+                    CardState=CARD_IDLE;                  // false alarm,start over again
+                }
+            }
+            break;
+        case CARD_VALID:
+            {
+                if (bit_is_set(MMC_IN_READ, MMC_CDETECT))
+                {
+                    ValidateCounter=1;
+                    CardState=CARD_NOT_PRESENT;         // Card removed
+                }
+            }
+            break;
+        case CARD_NOT_PRESENT:
+            {
+                if (++ValidateCounter==CARD_NOT_PRESENT_COUNTER_OK)
+                {
+                    CardPresentFlag=CARD_IS_NOT_PRESENT;
+                    CardState=CARD_IDLE;
+                    RetValue=CARD_IS_NOT_PRESENT;
+                }
+            }
+            break;
+    }
+    return(RetValue);
+}
+
+/*!
+ * \brief return status of "Card is Present"
+ *
+ */
+u_char CardCheckPresent()
+{
+    return(CardPresentFlag);
+}
+
+/*!
+ * \brief initialise the card by reading card contents (.pls files)
+ *
+ * We initialse the card by registering the card and the filesystem
+ * that is on the card.
+ *
+ * Then we start checking if a number of playlists are
+ * present on the card. The names of these playlists are hardcoded
+ * (1.pls, 2.pls, to 20.pls). We 'search' the card for these list
+ * of playlists by trying to open them. If succesfull, we read the
+ * number of songs present (int) in that list
+ * Finally we update some administration (global) variables
+ *
+ */
+int CardInitCard()
+{
+    int iResult=-1;
+    int fid;        // current file descriptor
+    char szFileName[10];
+    //u_char i;
+	u_char ief;
+
+    /*
+     * Register our device for the file system (if not done already.....)
+     */
+    if (NutDeviceLookup(devFAT.dev_name) == 0)
+    {
+        ief = VsPlayerInterrupts(0);
+        if ((iResult=NutRegisterDevice(&devFAT, FAT_MODE_MMC, 0)) == 0)
+        {
+            iResult=NutRegisterDevice(&devFATMMC0, FAT_MODE_MMC, 0);
+        }
+        VsPlayerInterrupts(ief);
+    }
+    else
+    {
+        NUTDEVICE * dev;
+
+        /*
+         *  we must call 'FatInit' here to initialise and mount the filesystem (again)
+         */
+
+        FATRelease();
+        ief = VsPlayerInterrupts(0);
+        dev=&devFAT;
+        if (dev->dev_init == 0 || (*dev->dev_init)(dev) == 0)
+        {
+            dev=&devFATMMC0;
+            if (dev->dev_init == 0 || (*dev->dev_init)(dev) == 0)
+            {
+                iResult=0;
+            }
+        }
+        VsPlayerInterrupts(ief);
+    }
+
+    if (iResult==0)
+    {
+        LogMsg_P(LOG_INFO, PSTR("Card mounted"));
+        /*
+         *  try to open the playlists. If an error is returned, we assume the
+         *  playlist does not exist and we do not check any further lists
+         */
+
+		 /* Kroeske: onderstaande code ter illustratie om file op card te openen */
+		 
+ //       for (i=1; i<SETTINGS_NROF_PLAYLISTST; ++i)
+ //       {
+            // compose name to open
+            //sprintf_P(szFileName, PSTR("FM0:%d.pls"), i);
+            if ((fid = _open(szFileName, _O_RDONLY)) != -1)
+            {
+                _close(fid);
+            }
+            else
+            {
+
+                //g_NrofPlayLists=i-1;
+                //LogMsg_P(LOG_INFO, PSTR("Found %d Playlists on the Card"), i-1);
+ //               break;
+            }
+//        }
+    }
+    else
+    {
+        LogMsg_P(LOG_ERR, PSTR("Error initialising File system and Card-driver"));
+    }
+
+    return(iResult);
+}
+
+/*!
+ * \brief The CardPresent thread.
+ *
+ * execute code when card is inserted or redrawn
+ *
+ * \param   -
+ *
+ * \return  -
+ */
+THREAD(CardPresent, pArg)
+{
+    static u_char OldCardStatus;
+
+    OldCardStatus=CardPresentFlag;
+
+    for (;;)
+    {
+        if ((CardPresentFlag==CARD_IS_PRESENT) && (OldCardStatus==CARD_IS_NOT_PRESENT))
+        {
+            LogMsg_P(LOG_INFO, PSTR("Card inserted"));
+            if (CardInitCard()==0)
+            {
+                KbInjectKey(KEY_MMC_IN);
+            }
+            OldCardStatus=CardPresentFlag;
+        }
+        else if ((CardPresentFlag==CARD_IS_NOT_PRESENT) && (OldCardStatus==CARD_IS_PRESENT))
+        {
+            LogMsg_P(LOG_INFO, PSTR("Card removed"));
+            CardClose();
+            OldCardStatus=CardPresentFlag;
+        }
+        else
+        {
+            NutSleep(500);
+        }
+    }
+}
+
+
+/*!
+ * \brief return global variable that indicates the status of this module
+ *
+ */
+TError CardStatus(void)
+{
+    return(g_tStatus);
+}
+
+/*!
+ * \brief Stop playing.
+ *
+ * \param   -
+ *
+ * \return  -
+ */
+void CardClose(void)
+{
+
+}
+
+
+/*!
+ * \brief initialise this module
+ *
+ */
+void CardInit()
+{
+    char ThreadName[10];
+
+    CardState=CARD_IDLE;
+    CardPresentFlag=CARD_IS_NOT_PRESENT;
+
+    /*
+     * Create a CardPresent thread
+     */
+    strcpy_P(ThreadName, PSTR("CardPres"));
+
+    if (GetThreadByName((char *)ThreadName) == NULL)
+    {
+        if (NutThreadCreate((char *)ThreadName, CardPresent, 0, 768) == 0)
+        {
+            LogMsg_P(LOG_EMERG, PSTR("Thread failed"));
+        }
+    }
+
+}
+
+/* ---------- end of module ------------------------------------------------ */
+
+/*@}*/
+
+

+ 0 - 3
include/mmc.h → lib/mmc.h

@@ -35,7 +35,4 @@ extern void CardStopMp3File(void);
 extern void CardUpdateTicks(void);
 extern u_char CardGetNumberOfPlayLists(void);
 
-       //
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
 

+ 758 - 758
source/mmcdrv.c → lib/mmcdrv.c

@@ -1,758 +1,758 @@
-/****************************************************************************
-*  This file is part of the MMC device driver.
-*
-*  Copyright (c) 2004 by Michael Fischer. All rights reserved.
-*
-*  Thanks to Sylvain Bissonnette for some of his low level functions.
-*  Take a look at www.microsyl.com (Led Sign with MMC MemoryCard)
-*
-*  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 author 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 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.
-*
-****************************************************************************
-*  History:
-*
-*  10.10.04  mifi   First Version
-****************************************************************************/
-#define __MMCDRV_C__
-
-#define LOG_MODULE  LOG_MMCDRV_MODULE
-
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/timer.h>
-#include <sys/thread.h>
-#include <sys/event.h>
-#include <sys/heap.h>
-
-#include "typedefs.h"
-#include "portio.h"
-#include "mmcdrv.h"
-#include "vs10xx.h"
-#include "led.h"
-#include "log.h"
-#include "spidrv.h"
-
-/*==========================================================*/
-/*  DEFINE: All Structures and Common Constants             */
-/*==========================================================*/
-#define MMC_MAX_SUPPORTED_DEVICE    1
-
-/*
- * Drive Flags
- */
-#define MMC_SUPPORT_LBA             0x0001
-#define MMC_SUPPORT_LBA48           0x0002
-
-#define MMC_READ_ONLY               0x4000
-#define MMC_READY                   0x8000
-
-#define Delay_1ms(_x) NutDelay(_x)
-
-#define SPIDDR        DDRB
-#define SPIPORT       PORTB
-#define SPIPIN        PINB
-
-/*
-    PragmaLab: disable PIN-defines (already defined in 'portio.h'
-#define SCLK          0x02
-#define MOSI          0x04
-#define MISO          0x08
-#define CS            0x20
-#define ENABLE        0x40
-    end PragmaLab
-*/
-
-#define MMC_RESET         0
-#define MMC_INIT          1
-#define MMC_READ_CSD    9
-#define MMC_READ_CID    10
-
-typedef struct _drive
-{
-    /*
-     * Interface values
-     */
-    WORD  wFlags;
-    BYTE  bDevice;
-
-    /*
-     * LBA value
-     */
-    DWORD dTotalSectors;
-    WORD  wSectorSize;
-} DRIVE;
-
-/*==========================================================*/
-/*  DEFINE: Definition of all local Data                    */
-/*==========================================================*/
-static HANDLE          hMMCSemaphore;
-static DRIVE           sDrive[MMC_MAX_SUPPORTED_DEVICE];
-
-static MMC_MOUNT_FUNC *pUserMountFunc;
-static MMC_MOUNT_FUNC *pUserUnMountFunc;
-
-/*==========================================================*/
-/*  DEFINE: Definition of all local Procedures              */
-/*==========================================================*/
-
-
-/************************************************************/
-/*  MMCLock                                                 */
-/************************************************************/
-static void MMCLock(void)
-{
-    NutEventWait(&hMMCSemaphore, 0);
-} /* MMCLock */
-
-/************************************************************/
-/*  MMCFree                                                 */
-/************************************************************/
-static void MMCFree(void)
-{
-    NutEventPost(&hMMCSemaphore);
-} /* MMCFree */
-
-/************************************************************/
-/*  MMCSemaInit                                             */
-/************************************************************/
-static void MMCSemaInit(void)
-{
-    NutEventPost(&hMMCSemaphore);
-} /* MMCSemaInit */
-
-
-/************************************************************
- * int MMCDataToken(void)
- *
- * - pings the card until it gets data token
- * - returns one byte of read info (data token)
- ************************************************************/
-static BYTE MMCDataToken(void)
-{
-    WORD i = 0xffff;
-    BYTE Byte = 0xff;
-
-    while ((Byte != 0xfe) && (--i))
-    {
-        Byte = SPIgetByte();
-    }
-    return(Byte);
-} /* MMCDataToken */
-
-/************************************************************
- * unsigned char MMCGet(void)
- *
- * - pings the card until it gets a non-0xff value
- * - returns one byte of read info
- ************************************************************/
-static BYTE MMCGet(void)
-{
-    WORD i = 0xffff;
-    BYTE Byte = 0xff;
-
-    while ((Byte == 0xff) && (--i))
-    {
-        Byte = SPIgetByte();
-    }
-
-    return(Byte);
-} /* MMCGet */
-
-/************************************************************
- * void MMCCommand(unsigned char command, unsigned int px, unsigned int py)
- *
- * - send one byte of 0xff, then issue command + params + (fake) crc
- * - eat up the one command of nothing after the CRC
- ************************************************************/
-static void MMCCommand(unsigned char command, unsigned int px, unsigned int py)
-{
-    SPIselect(SPI_DEV_MMC);
-
-    SPIputByte(0xff);
-    SPIputByte(command | 0x40);
-    SPIputByte((unsigned char)((px >> 8)&0x0ff)); /* high byte of param y */
-    SPIputByte((unsigned char)(px & 0x00ff));     /* low byte of param y */
-    SPIputByte((unsigned char)((py >> 8)&0x0ff)); /* high byte of param x */
-    SPIputByte((unsigned char)(py & 0x00ff));     /* low byte of param x */
-    SPIputByte(0x95);            /* correct CRC for first command in SPI          */
-                              /* after that CRC is ignored, so no problem with */
-                              /* always sending 0x95                           */
-    SPIputByte(0xff);
-} /* MMCCommand */
-
-/************************************************************/
-/* GetCSD                                                   */
-/************************************************************/
-static int GetCSD (DRIVE *pDrive)
-{
-    int   i;
-    int  nError = MMC_ERROR;
-    BYTE bData[16];
-    WORD wREAD_BL_LEN;
-    WORD wC_SIZE;
-    WORD wC_SIZE_MULT;
-    WORD wDummy;
-    DWORD dTotalSectors = 0;
-
-    MMCCommand(MMC_READ_CSD, 0, 0);
-    if (MMCDataToken() != 0xfe)
-    {
-        LogMsg_P(LOG_ERR, PSTR("error during CSD read"));
-    }
-    else
-    {
-        for (i=0; i<16; i++)
-        {
-            bData[i] = SPIgetByte();
-        }
-
-        SPIputByte(0xff);    /* checksum -> don't care about it for now */
-        SPIputByte(0xff);    /* checksum -> don't care about it for now */
-
-        SPIdeselect();
-
-        /*
-         * Get the READ_BL_LEN
-         */
-        wREAD_BL_LEN = (1 << (bData[5] & 0x0F));
-
-        /*
-         * Get the C_SIZE
-         */
-        wC_SIZE  = (bData[6] & 0x03);
-        wC_SIZE  = wC_SIZE << 10;
-
-        wDummy   = bData[7];
-        wDummy   = wDummy << 2;
-        wC_SIZE |= wDummy;
-
-        wDummy   = (bData[8] & 0xC0);
-        wDummy   = wDummy >> 6;
-        wC_SIZE |= wDummy;
-
-        /*
-         * Get the wC_SIZE_MULT
-         */
-        wC_SIZE_MULT  = (bData[9] & 0x03);
-        wC_SIZE_MULT |= wC_SIZE_MULT << 1;
-        wDummy        = (bData[10] & 0x80);
-        wDummy        = wDummy >> 7;
-        wC_SIZE_MULT |= wDummy;
-        wC_SIZE_MULT  = (1 << (wC_SIZE_MULT+2));
-
-        dTotalSectors  = wC_SIZE+1;
-        dTotalSectors *= wC_SIZE_MULT;
-
-        pDrive->dTotalSectors = dTotalSectors;
-        pDrive->wSectorSize   = wREAD_BL_LEN;
-
-        nError = MMC_OK;
-    }
-
-    return(nError);
-} /* GetCSD */
-
-#if 0
-/************************************************************/
-/* GetCID                                                   */
-/************************************************************/
-static void GetCID(void)
-{
-    int i;
-    BYTE bData[16];
-
-    MMCCommand(MMC_READ_CID, 0, 0);
-    if (MMCDataToken() != 0xfe)
-    {
-        printf("MMC: error during CID read\n");
-    }
-    else
-    {
-        printf("MMC: CID read\n");
-    }
-
-    for (i=0; i<16; i++)
-    {
-        bData[i] = SPIgetByte();
-    }
-
-    SPIputByte(0xff);    /* checksum -> don't care about it for now */
-    SPIputByte(0xff);    /* checksum -> don't care about it for now */
-
-    SPIdeselect();
-
-    printf("MMC: Product Name: %c%c%c%c%c%c\n",
-           bData[3], bData[4], bData[5],
-           bData[6], bData[7], bData[8]);
-} /* GetCID */
-#endif
-
-/************************************************************/
-/*  InitMMCCard                                             */
-/*                                                          */
-/* - flushes card receive buffer                            */
-/* - selects card                                           */
-/* - sends the reset command                                */
-/* - sends the initialization command, waits for card ready */
-/************************************************************/
-static int InitMMCCard(void)
-{
-    WORD i;
-
-    /* PragmaLab: disable initit of PINS and SPI, already done in 'SystemInitIO()'
-    SPIDDR = SCLK + MOSI + CS;
-    SPIPORT = 0x00;
-    Delay_1ms(250);
-    Delay_1ms(250);
-    SPIPORT |= CS;
-    SPCR = (1 << SPE) | (1 << MSTR);  // enable SPI as master, set clk divider
-                                      // set to max speed
-    Delay_1ms(250);
-
-
-    SPIdeselect();
-
-    // start off with 80 bits of high data with card deselected
-
-    PragmaLab: why send dummy bytes with card DEselected? This messes up the VS10XX init */
-    for (i = 0; i < 10; i++)
-    {
-        SPIputByte(0xff);
-    }
-
-    /*end PragmaLab */
-
-    /* send CMD0 - go to idle state */
-    MMCCommand(MMC_RESET, 0, 0);
-
-    if (MMCGet() != 1)
-    {
-        SPIdeselect();
-        return(MMC_ERROR);  // MMC Not detected
-    }
-
-    /* send CMD1 until we get a 0 back, indicating card is done initializing */
-    i = 0xffff;
-    while ((SPIgetByte() != 0) && (--i))
-    {
-        MMCCommand(MMC_INIT, 0, 0);
-    }
-    if (i == 0)
-    {
-        SPIdeselect();
-        return(MMC_ERROR);  // Init Fail
-    }
-
-    SPIdeselect();
-    return(MMC_OK);
-} /* InitMMCCard */
-
-/************************************************************/
-/*  ReadSectors                                             */
-/************************************************************/
-static int ReadSectors(DRIVE *pDrive, BYTE *pBuffer, DWORD dStartSector, WORD wSectorCount)
-{
-    int   nError = MMC_OK;
-    int   nSector;
-    WORD  wDataCount;
-    DWORD dReadSector;
-
-    pDrive = pDrive;
-
-    for (nSector=0; nSector<wSectorCount; nSector++)
-    {
-        dReadSector = dStartSector + nSector;
-
-        MMCCommand(17,(dReadSector>>7) & 0xffff, (dReadSector<<9) & 0xffff);
-        if (MMCDataToken() != 0xfe)
-        {
-            nError = MMC_ERROR;
-            SPIdeselect();
-            break;
-        }
-
-        for (wDataCount=0; wDataCount<512; wDataCount++)
-        { /* read the sector */
-            *pBuffer = SPIgetByte();
-            pBuffer++;
-        }
-
-        SPIputByte(0xff);    /* checksum -> don't care about it for now */
-        SPIputByte(0xff);    /* checksum -> don't care about it for now */
-        SPIdeselect();
-    }
-
-    return(nError);
-} /* ReadSectors */
-
-#if (MMC_SUPPORT_WRITE == 1)
-/************************************************************/
-/*  WriteSectors                                            */
-/************************************************************/
-static BYTE WriteSectors(DRIVE *pDrive, BYTE *pBuffer, DWORD dStartSector, WORD wSectorCount)
-{
-    int   nError = MMC_OK;
-    int   nSector;
-    WORD  wDataCount;
-    DWORD dWriteSector;
-
-    pDrive = pDrive;
-
-    for (nSector=0; nSector<wSectorCount; nSector++)
-    {
-        dWriteSector = dStartSector + nSector;
-
-        MMCCommand(24, (dWriteSector>>7)& 0xffff, (dWriteSector<<9)& 0xffff);
-        if (MMCGet() == 0xff)
-        {
-            nError = MMC_ERROR;
-            SPIdeselect();
-            break;
-        }
-
-        SPIputByte(0xfe);  // Send Start Byte
-
-        for (wDataCount=0; wDataCount<512; wDataCount++)
-        { /* read the sector */
-            SPIputByte(*pBuffer);
-            pBuffer++;
-        }
-
-        SPIputByte(0xff);  /* checksum -> don't care about it for now */
-        SPIputByte(0xff);  /* checksum -> don't care about it for now */
-        SPIputByte(0xff);  /* Read "data response byte"               */
-
-        wDataCount = 0xffff;
-        while ((SPIgetByte() == 0x00) && (--wDataCount)); /* wait for write finish */
-        if (wDataCount == 0)
-        {
-            nError = MMC_ERROR;
-            SPIdeselect();
-            break;
-        }
-
-        SPIdeselect();
-    }
-
-    return(nError);
-}
-#endif /* WriteSectors */
-
-/*==========================================================*/
-/*  DEFINE: All code exported                               */
-/*==========================================================*/
-/************************************************************/
-/*  MMCInit                                                 */
-/************************************************************/
-int MMCInit(int nMMCMode, MMC_MOUNT_FUNC *pMountFunc,
-            MMC_MOUNT_FUNC *pUnMountFunc)
-{
-    int  nError = MMC_OK;
-    BYTE bIndex;
-
-    nMMCMode         = nMMCMode;
-    pUserMountFunc   = pMountFunc;
-    pUserUnMountFunc = pUnMountFunc;
-
-    for (bIndex=0; bIndex<MMC_MAX_SUPPORTED_DEVICE; bIndex++)
-    {
-        memset((BYTE *) & sDrive[bIndex], 0x00, sizeof(DRIVE));
-
-        sDrive[bIndex].bDevice  = bIndex;
-    }
-
-    MMCSemaInit();
-
-    nError = InitMMCCard();
-    if (nError == MMC_OK)
-    {
-        sDrive[MMC_DRIVE_C].wFlags = MMC_READY;
-        //GetCID();
-    }
-
-    return(nError);
-} /* MMCInit */
-
-/************************************************************/
-/*  MMCMountAllDevices                                      */
-/************************************************************/
-int MMCMountAllDevices(int nMMCMode, BYTE *pSectorBuffer)
-{
-    int    nError = MMC_ERROR;
-    DRIVE *pDrive;
-
-    nMMCMode = nMMCMode;
-
-    pDrive = NULL;
-
-    MMCLock();
-
-    pDrive = &sDrive[MMC_DRIVE_C];
-    if (pDrive->wFlags & MMC_READY)
-    {
-        nError = GetCSD(pDrive);
-    }
-
-    MMCFree();
-
-    if (nError == MMC_OK)
-    {
-        nError = MMCReadSectors(MMC_DRIVE_C, pSectorBuffer, 0, 1);
-    }
-
-    return(nError);
-} /* MMCMountDevice */
-
-/************************************************************/
-/*  MMCGetSectorSize                                        */
-/************************************************************/
-int MMCGetSectorSize(BYTE bDevice)
-{
-    int    nSectorSize;
-    DRIVE *pDrive;
-
-    nSectorSize = 0;
-
-    MMCLock();
-
-    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
-    {
-        nSectorSize = 0;
-    }
-    else
-    {
-        pDrive = &sDrive[bDevice];
-        nSectorSize = pDrive->wSectorSize;
-    }
-
-    MMCFree();
-
-    return(nSectorSize);
-} /* MMCGetSectorSize */
-
-/************************************************************/
-/*  MMCIsCDROMDevice                                        */
-/************************************************************/
-int MMCIsCDROMDevice(BYTE bDevice)
-{
-    return(FALSE);
-} /* MMCIsCDROMDevice */
-
-/************************************************************/
-/*  MMCIsZIPDevice                                          */
-/************************************************************/
-int MMCIsZIPDevice(BYTE bDevice)
-{
-    return(FALSE);
-} /* MMCIsZIPDevice */
-
-/************************************************************/
-/*  MMCUnMountDevice                                        */
-/************************************************************/
-int MMCUnMountDevice(BYTE bDevice)
-{
-    return(MMC_OK);
-} /* MMCUnMountDevice */
-
-/************************************************************/
-/*  MMCGetTotalSectors                                      */
-/************************************************************/
-DWORD MMCGetTotalSectors(BYTE bDevice)
-{
-    DWORD  dwTotalSectors;
-    DRIVE *pDrive;
-
-    dwTotalSectors = 0;
-
-    MMCLock();
-
-    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
-    {
-        dwTotalSectors = 0;
-    }
-    else
-    {
-        pDrive = &sDrive[bDevice];
-        dwTotalSectors = pDrive->dTotalSectors;
-
-        //dwTotalSectors -= 64;
-    }
-
-    MMCFree();
-
-    return(dwTotalSectors);
-} /* MMCGetTotalSectors */
-
-/************************************************************/
-/*  MMCReadSectors                                          */
-/************************************************************/
-int MMCReadSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount)
-{
-    int    nError;
-    WORD   wReadCount;
-    DRIVE *pDrive = 0;
-    BYTE  *pByte;
-
-    nError = MMC_OK;
-
-    MMCLock();
-
-    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
-    {
-        nError = MMC_DRIVE_NOT_FOUND;
-    }
-    else
-    {
-        pDrive = &sDrive[bDevice];
-        if ((pDrive->wFlags & MMC_READY) == 0)
-        {
-            nError = MMC_DRIVE_NOT_FOUND;
-        }
-        else
-        {
-            if ((dwStartSector + wSectorCount) > pDrive->dTotalSectors)
-            {
-                nError = MMC_PARAM_ERROR;
-            }
-        }
-    }
-
-    if (nError == MMC_OK)
-    {
-        pByte = (BYTE *)pData;
-
-        if (wSectorCount != 1)
-        {
-            while (wSectorCount > 0)
-            {
-
-                if (wSectorCount < 256)
-                {
-                    wReadCount = wSectorCount;
-                }
-                else
-                {
-                    wReadCount = 256;
-                }
-
-                nError = ReadSectors(pDrive, pByte, dwStartSector, wReadCount);
-                if (nError != MMC_OK)
-                {
-                    break;
-                }
-
-                dwStartSector += wReadCount;
-                wSectorCount -= wReadCount;
-                pByte += (wReadCount * pDrive->wSectorSize);
-            }
-        }
-        else
-        {
-            nError = ReadSectors(pDrive, pByte, dwStartSector, 1);
-        }
-    }
-
-    MMCFree();
-
-    return(nError);
-} /* MMCReadSectors */
-
-#if (MMC_SUPPORT_WRITE == 1)
-/************************************************************/
-/*  MMCWriteSectors                                         */
-/************************************************************/
-int MMCWriteSectors(BYTE   bDevice,      void *pData,
-                    DWORD dwStartSector, WORD  wSectorCount)
-{
-    int    nError;
-    WORD   wWriteCount;
-    DRIVE *pDrive = 0;
-    BYTE  *pByte;
-
-    nError = MMC_OK;
-
-    MMCLock();
-
-    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
-    {
-        nError = MMC_DRIVE_NOT_FOUND;
-    }
-    else
-    {
-        pDrive = &sDrive[bDevice];
-
-        if ((dwStartSector + wSectorCount) > pDrive->dTotalSectors)
-        {
-            nError = MMC_PARAM_ERROR;
-        }
-        if ((pDrive->wFlags & MMC_READY) == 0)
-        {
-            nError = MMC_DRIVE_NOT_FOUND;
-        }
-        if (pDrive->wFlags & MMC_READ_ONLY)
-        {
-            nError = MMC_NOT_SUPPORTED;
-        }
-    }
-
-    if (nError == MMC_OK)
-    {
-        pByte = (BYTE *) pData;
-        while (wSectorCount > 0)
-        {
-
-            if (wSectorCount < 256)
-            {
-                wWriteCount = wSectorCount;
-            }
-            else
-            {
-                wWriteCount = 256;
-            }
-
-            nError = WriteSectors(pDrive, pByte, dwStartSector, wWriteCount);
-            if (nError != MMC_OK)
-            {
-                break;
-            }
-
-            dwStartSector += wWriteCount;
-            wSectorCount  -= wWriteCount;
-            pByte         += (wWriteCount * MMC_SECTOR_SIZE);
-        }
-    }
-
-    MMCFree();
-
-    return(nError);
-} /* MMCWriteSectors */
-#endif
-
-
-
-
+/****************************************************************************
+*  This file is part of the MMC device driver.
+*
+*  Copyright (c) 2004 by Michael Fischer. All rights reserved.
+*
+*  Thanks to Sylvain Bissonnette for some of his low level functions.
+*  Take a look at www.microsyl.com (Led Sign with MMC MemoryCard)
+*
+*  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 author 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 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.
+*
+****************************************************************************
+*  History:
+*
+*  10.10.04  mifi   First Version
+****************************************************************************/
+#define __MMCDRV_C__
+
+#define LOG_MODULE  LOG_MMCDRV_MODULE
+
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/timer.h>
+#include <sys/thread.h>
+#include <sys/event.h>
+#include <sys/heap.h>
+
+#include "typedefs.h"
+#include "portio.h"
+#include "mmcdrv.h"
+#include "vs10xx.h"
+#include "led.h"
+#include "log.h"
+#include "spidrv.h"
+
+/*==========================================================*/
+/*  DEFINE: All Structures and Common Constants             */
+/*==========================================================*/
+#define MMC_MAX_SUPPORTED_DEVICE    1
+
+/*
+ * Drive Flags
+ */
+#define MMC_SUPPORT_LBA             0x0001
+#define MMC_SUPPORT_LBA48           0x0002
+
+#define MMC_READ_ONLY               0x4000
+#define MMC_READY                   0x8000
+
+#define Delay_1ms(_x) NutDelay(_x)
+
+#define SPIDDR        DDRB
+#define SPIPORT       PORTB
+#define SPIPIN        PINB
+
+/*
+    PragmaLab: disable PIN-defines (already defined in 'portio.h'
+#define SCLK          0x02
+#define MOSI          0x04
+#define MISO          0x08
+#define CS            0x20
+#define ENABLE        0x40
+    end PragmaLab
+*/
+
+#define MMC_RESET         0
+#define MMC_INIT          1
+#define MMC_READ_CSD    9
+#define MMC_READ_CID    10
+
+typedef struct _drive
+{
+    /*
+     * Interface values
+     */
+    WORD  wFlags;
+    BYTE  bDevice;
+
+    /*
+     * LBA value
+     */
+    DWORD dTotalSectors;
+    WORD  wSectorSize;
+} DRIVE;
+
+/*==========================================================*/
+/*  DEFINE: Definition of all local Data                    */
+/*==========================================================*/
+static HANDLE          hMMCSemaphore;
+static DRIVE           sDrive[MMC_MAX_SUPPORTED_DEVICE];
+
+static MMC_MOUNT_FUNC *pUserMountFunc;
+static MMC_MOUNT_FUNC *pUserUnMountFunc;
+
+/*==========================================================*/
+/*  DEFINE: Definition of all local Procedures              */
+/*==========================================================*/
+
+
+/************************************************************/
+/*  MMCLock                                                 */
+/************************************************************/
+static void MMCLock(void)
+{
+    NutEventWait(&hMMCSemaphore, 0);
+} /* MMCLock */
+
+/************************************************************/
+/*  MMCFree                                                 */
+/************************************************************/
+static void MMCFree(void)
+{
+    NutEventPost(&hMMCSemaphore);
+} /* MMCFree */
+
+/************************************************************/
+/*  MMCSemaInit                                             */
+/************************************************************/
+static void MMCSemaInit(void)
+{
+    NutEventPost(&hMMCSemaphore);
+} /* MMCSemaInit */
+
+
+/************************************************************
+ * int MMCDataToken(void)
+ *
+ * - pings the card until it gets data token
+ * - returns one byte of read info (data token)
+ ************************************************************/
+static BYTE MMCDataToken(void)
+{
+    WORD i = 0xffff;
+    BYTE Byte = 0xff;
+
+    while ((Byte != 0xfe) && (--i))
+    {
+        Byte = SPIgetByte();
+    }
+    return(Byte);
+} /* MMCDataToken */
+
+/************************************************************
+ * unsigned char MMCGet(void)
+ *
+ * - pings the card until it gets a non-0xff value
+ * - returns one byte of read info
+ ************************************************************/
+static BYTE MMCGet(void)
+{
+    WORD i = 0xffff;
+    BYTE Byte = 0xff;
+
+    while ((Byte == 0xff) && (--i))
+    {
+        Byte = SPIgetByte();
+    }
+
+    return(Byte);
+} /* MMCGet */
+
+/************************************************************
+ * void MMCCommand(unsigned char command, unsigned int px, unsigned int py)
+ *
+ * - send one byte of 0xff, then issue command + params + (fake) crc
+ * - eat up the one command of nothing after the CRC
+ ************************************************************/
+static void MMCCommand(unsigned char command, unsigned int px, unsigned int py)
+{
+    SPIselect(SPI_DEV_MMC);
+
+    SPIputByte(0xff);
+    SPIputByte(command | 0x40);
+    SPIputByte((unsigned char)((px >> 8)&0x0ff)); /* high byte of param y */
+    SPIputByte((unsigned char)(px & 0x00ff));     /* low byte of param y */
+    SPIputByte((unsigned char)((py >> 8)&0x0ff)); /* high byte of param x */
+    SPIputByte((unsigned char)(py & 0x00ff));     /* low byte of param x */
+    SPIputByte(0x95);            /* correct CRC for first command in SPI          */
+                              /* after that CRC is ignored, so no problem with */
+                              /* always sending 0x95                           */
+    SPIputByte(0xff);
+} /* MMCCommand */
+
+/************************************************************/
+/* GetCSD                                                   */
+/************************************************************/
+static int GetCSD (DRIVE *pDrive)
+{
+    int   i;
+    int  nError = MMC_ERROR;
+    BYTE bData[16];
+    WORD wREAD_BL_LEN;
+    WORD wC_SIZE;
+    WORD wC_SIZE_MULT;
+    WORD wDummy;
+    DWORD dTotalSectors = 0;
+
+    MMCCommand(MMC_READ_CSD, 0, 0);
+    if (MMCDataToken() != 0xfe)
+    {
+        LogMsg_P(LOG_ERR, PSTR("error during CSD read"));
+    }
+    else
+    {
+        for (i=0; i<16; i++)
+        {
+            bData[i] = SPIgetByte();
+        }
+
+        SPIputByte(0xff);    /* checksum -> don't care about it for now */
+        SPIputByte(0xff);    /* checksum -> don't care about it for now */
+
+        SPIdeselect();
+
+        /*
+         * Get the READ_BL_LEN
+         */
+        wREAD_BL_LEN = (1 << (bData[5] & 0x0F));
+
+        /*
+         * Get the C_SIZE
+         */
+        wC_SIZE  = (bData[6] & 0x03);
+        wC_SIZE  = wC_SIZE << 10;
+
+        wDummy   = bData[7];
+        wDummy   = wDummy << 2;
+        wC_SIZE |= wDummy;
+
+        wDummy   = (bData[8] & 0xC0);
+        wDummy   = wDummy >> 6;
+        wC_SIZE |= wDummy;
+
+        /*
+         * Get the wC_SIZE_MULT
+         */
+        wC_SIZE_MULT  = (bData[9] & 0x03);
+        wC_SIZE_MULT |= wC_SIZE_MULT << 1;
+        wDummy        = (bData[10] & 0x80);
+        wDummy        = wDummy >> 7;
+        wC_SIZE_MULT |= wDummy;
+        wC_SIZE_MULT  = (1 << (wC_SIZE_MULT+2));
+
+        dTotalSectors  = wC_SIZE+1;
+        dTotalSectors *= wC_SIZE_MULT;
+
+        pDrive->dTotalSectors = dTotalSectors;
+        pDrive->wSectorSize   = wREAD_BL_LEN;
+
+        nError = MMC_OK;
+    }
+
+    return(nError);
+} /* GetCSD */
+
+#if 0
+/************************************************************/
+/* GetCID                                                   */
+/************************************************************/
+static void GetCID(void)
+{
+    int i;
+    BYTE bData[16];
+
+    MMCCommand(MMC_READ_CID, 0, 0);
+    if (MMCDataToken() != 0xfe)
+    {
+        printf("MMC: error during CID read\n");
+    }
+    else
+    {
+        printf("MMC: CID read\n");
+    }
+
+    for (i=0; i<16; i++)
+    {
+        bData[i] = SPIgetByte();
+    }
+
+    SPIputByte(0xff);    /* checksum -> don't care about it for now */
+    SPIputByte(0xff);    /* checksum -> don't care about it for now */
+
+    SPIdeselect();
+
+    printf("MMC: Product Name: %c%c%c%c%c%c\n",
+           bData[3], bData[4], bData[5],
+           bData[6], bData[7], bData[8]);
+} /* GetCID */
+#endif
+
+/************************************************************/
+/*  InitMMCCard                                             */
+/*                                                          */
+/* - flushes card receive buffer                            */
+/* - selects card                                           */
+/* - sends the reset command                                */
+/* - sends the initialization command, waits for card ready */
+/************************************************************/
+static int InitMMCCard(void)
+{
+    WORD i;
+
+    /* PragmaLab: disable initit of PINS and SPI, already done in 'SystemInitIO()'
+    SPIDDR = SCLK + MOSI + CS;
+    SPIPORT = 0x00;
+    Delay_1ms(250);
+    Delay_1ms(250);
+    SPIPORT |= CS;
+    SPCR = (1 << SPE) | (1 << MSTR);  // enable SPI as master, set clk divider
+                                      // set to max speed
+    Delay_1ms(250);
+
+
+    SPIdeselect();
+
+    // start off with 80 bits of high data with card deselected
+
+    PragmaLab: why send dummy bytes with card DEselected? This messes up the VS10XX init */
+    for (i = 0; i < 10; i++)
+    {
+        SPIputByte(0xff);
+    }
+
+    /*end PragmaLab */
+
+    /* send CMD0 - go to idle state */
+    MMCCommand(MMC_RESET, 0, 0);
+
+    if (MMCGet() != 1)
+    {
+        SPIdeselect();
+        return(MMC_ERROR);  // MMC Not detected
+    }
+
+    /* send CMD1 until we get a 0 back, indicating card is done initializing */
+    i = 0xffff;
+    while ((SPIgetByte() != 0) && (--i))
+    {
+        MMCCommand(MMC_INIT, 0, 0);
+    }
+    if (i == 0)
+    {
+        SPIdeselect();
+        return(MMC_ERROR);  // Init Fail
+    }
+
+    SPIdeselect();
+    return(MMC_OK);
+} /* InitMMCCard */
+
+/************************************************************/
+/*  ReadSectors                                             */
+/************************************************************/
+static int ReadSectors(DRIVE *pDrive, BYTE *pBuffer, DWORD dStartSector, WORD wSectorCount)
+{
+    int   nError = MMC_OK;
+    int   nSector;
+    WORD  wDataCount;
+    DWORD dReadSector;
+
+    pDrive = pDrive;
+
+    for (nSector=0; nSector<wSectorCount; nSector++)
+    {
+        dReadSector = dStartSector + nSector;
+
+        MMCCommand(17,(dReadSector>>7) & 0xffff, (dReadSector<<9) & 0xffff);
+        if (MMCDataToken() != 0xfe)
+        {
+            nError = MMC_ERROR;
+            SPIdeselect();
+            break;
+        }
+
+        for (wDataCount=0; wDataCount<512; wDataCount++)
+        { /* read the sector */
+            *pBuffer = SPIgetByte();
+            pBuffer++;
+        }
+
+        SPIputByte(0xff);    /* checksum -> don't care about it for now */
+        SPIputByte(0xff);    /* checksum -> don't care about it for now */
+        SPIdeselect();
+    }
+
+    return(nError);
+} /* ReadSectors */
+
+#if (MMC_SUPPORT_WRITE == 1)
+/************************************************************/
+/*  WriteSectors                                            */
+/************************************************************/
+static BYTE WriteSectors(DRIVE *pDrive, BYTE *pBuffer, DWORD dStartSector, WORD wSectorCount)
+{
+    int   nError = MMC_OK;
+    int   nSector;
+    WORD  wDataCount;
+    DWORD dWriteSector;
+
+    pDrive = pDrive;
+
+    for (nSector=0; nSector<wSectorCount; nSector++)
+    {
+        dWriteSector = dStartSector + nSector;
+
+        MMCCommand(24, (dWriteSector>>7)& 0xffff, (dWriteSector<<9)& 0xffff);
+        if (MMCGet() == 0xff)
+        {
+            nError = MMC_ERROR;
+            SPIdeselect();
+            break;
+        }
+
+        SPIputByte(0xfe);  // Send Start Byte
+
+        for (wDataCount=0; wDataCount<512; wDataCount++)
+        { /* read the sector */
+            SPIputByte(*pBuffer);
+            pBuffer++;
+        }
+
+        SPIputByte(0xff);  /* checksum -> don't care about it for now */
+        SPIputByte(0xff);  /* checksum -> don't care about it for now */
+        SPIputByte(0xff);  /* Read "data response byte"               */
+
+        wDataCount = 0xffff;
+        while ((SPIgetByte() == 0x00) && (--wDataCount)); /* wait for write finish */
+        if (wDataCount == 0)
+        {
+            nError = MMC_ERROR;
+            SPIdeselect();
+            break;
+        }
+
+        SPIdeselect();
+    }
+
+    return(nError);
+}
+#endif /* WriteSectors */
+
+/*==========================================================*/
+/*  DEFINE: All code exported                               */
+/*==========================================================*/
+/************************************************************/
+/*  MMCInit                                                 */
+/************************************************************/
+int MMCInit(int nMMCMode, MMC_MOUNT_FUNC *pMountFunc,
+            MMC_MOUNT_FUNC *pUnMountFunc)
+{
+    int  nError = MMC_OK;
+    BYTE bIndex;
+
+    nMMCMode         = nMMCMode;
+    pUserMountFunc   = pMountFunc;
+    pUserUnMountFunc = pUnMountFunc;
+
+    for (bIndex=0; bIndex<MMC_MAX_SUPPORTED_DEVICE; bIndex++)
+    {
+        memset((BYTE *) & sDrive[bIndex], 0x00, sizeof(DRIVE));
+
+        sDrive[bIndex].bDevice  = bIndex;
+    }
+
+    MMCSemaInit();
+
+    nError = InitMMCCard();
+    if (nError == MMC_OK)
+    {
+        sDrive[MMC_DRIVE_C].wFlags = MMC_READY;
+        //GetCID();
+    }
+
+    return(nError);
+} /* MMCInit */
+
+/************************************************************/
+/*  MMCMountAllDevices                                      */
+/************************************************************/
+int MMCMountAllDevices(int nMMCMode, BYTE *pSectorBuffer)
+{
+    int    nError = MMC_ERROR;
+    DRIVE *pDrive;
+
+    nMMCMode = nMMCMode;
+
+    pDrive = NULL;
+
+    MMCLock();
+
+    pDrive = &sDrive[MMC_DRIVE_C];
+    if (pDrive->wFlags & MMC_READY)
+    {
+        nError = GetCSD(pDrive);
+    }
+
+    MMCFree();
+
+    if (nError == MMC_OK)
+    {
+        nError = MMCReadSectors(MMC_DRIVE_C, pSectorBuffer, 0, 1);
+    }
+
+    return(nError);
+} /* MMCMountDevice */
+
+/************************************************************/
+/*  MMCGetSectorSize                                        */
+/************************************************************/
+int MMCGetSectorSize(BYTE bDevice)
+{
+    int    nSectorSize;
+    DRIVE *pDrive;
+
+    nSectorSize = 0;
+
+    MMCLock();
+
+    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
+    {
+        nSectorSize = 0;
+    }
+    else
+    {
+        pDrive = &sDrive[bDevice];
+        nSectorSize = pDrive->wSectorSize;
+    }
+
+    MMCFree();
+
+    return(nSectorSize);
+} /* MMCGetSectorSize */
+
+/************************************************************/
+/*  MMCIsCDROMDevice                                        */
+/************************************************************/
+int MMCIsCDROMDevice(BYTE bDevice)
+{
+    return(FALSE);
+} /* MMCIsCDROMDevice */
+
+/************************************************************/
+/*  MMCIsZIPDevice                                          */
+/************************************************************/
+int MMCIsZIPDevice(BYTE bDevice)
+{
+    return(FALSE);
+} /* MMCIsZIPDevice */
+
+/************************************************************/
+/*  MMCUnMountDevice                                        */
+/************************************************************/
+int MMCUnMountDevice(BYTE bDevice)
+{
+    return(MMC_OK);
+} /* MMCUnMountDevice */
+
+/************************************************************/
+/*  MMCGetTotalSectors                                      */
+/************************************************************/
+DWORD MMCGetTotalSectors(BYTE bDevice)
+{
+    DWORD  dwTotalSectors;
+    DRIVE *pDrive;
+
+    dwTotalSectors = 0;
+
+    MMCLock();
+
+    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
+    {
+        dwTotalSectors = 0;
+    }
+    else
+    {
+        pDrive = &sDrive[bDevice];
+        dwTotalSectors = pDrive->dTotalSectors;
+
+        //dwTotalSectors -= 64;
+    }
+
+    MMCFree();
+
+    return(dwTotalSectors);
+} /* MMCGetTotalSectors */
+
+/************************************************************/
+/*  MMCReadSectors                                          */
+/************************************************************/
+int MMCReadSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount)
+{
+    int    nError;
+    WORD   wReadCount;
+    DRIVE *pDrive = 0;
+    BYTE  *pByte;
+
+    nError = MMC_OK;
+
+    MMCLock();
+
+    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
+    {
+        nError = MMC_DRIVE_NOT_FOUND;
+    }
+    else
+    {
+        pDrive = &sDrive[bDevice];
+        if ((pDrive->wFlags & MMC_READY) == 0)
+        {
+            nError = MMC_DRIVE_NOT_FOUND;
+        }
+        else
+        {
+            if ((dwStartSector + wSectorCount) > pDrive->dTotalSectors)
+            {
+                nError = MMC_PARAM_ERROR;
+            }
+        }
+    }
+
+    if (nError == MMC_OK)
+    {
+        pByte = (BYTE *)pData;
+
+        if (wSectorCount != 1)
+        {
+            while (wSectorCount > 0)
+            {
+
+                if (wSectorCount < 256)
+                {
+                    wReadCount = wSectorCount;
+                }
+                else
+                {
+                    wReadCount = 256;
+                }
+
+                nError = ReadSectors(pDrive, pByte, dwStartSector, wReadCount);
+                if (nError != MMC_OK)
+                {
+                    break;
+                }
+
+                dwStartSector += wReadCount;
+                wSectorCount -= wReadCount;
+                pByte += (wReadCount * pDrive->wSectorSize);
+            }
+        }
+        else
+        {
+            nError = ReadSectors(pDrive, pByte, dwStartSector, 1);
+        }
+    }
+
+    MMCFree();
+
+    return(nError);
+} /* MMCReadSectors */
+
+#if (MMC_SUPPORT_WRITE == 1)
+/************************************************************/
+/*  MMCWriteSectors                                         */
+/************************************************************/
+int MMCWriteSectors(BYTE   bDevice,      void *pData,
+                    DWORD dwStartSector, WORD  wSectorCount)
+{
+    int    nError;
+    WORD   wWriteCount;
+    DRIVE *pDrive = 0;
+    BYTE  *pByte;
+
+    nError = MMC_OK;
+
+    MMCLock();
+
+    if (bDevice >= MMC_MAX_SUPPORTED_DEVICE)
+    {
+        nError = MMC_DRIVE_NOT_FOUND;
+    }
+    else
+    {
+        pDrive = &sDrive[bDevice];
+
+        if ((dwStartSector + wSectorCount) > pDrive->dTotalSectors)
+        {
+            nError = MMC_PARAM_ERROR;
+        }
+        if ((pDrive->wFlags & MMC_READY) == 0)
+        {
+            nError = MMC_DRIVE_NOT_FOUND;
+        }
+        if (pDrive->wFlags & MMC_READ_ONLY)
+        {
+            nError = MMC_NOT_SUPPORTED;
+        }
+    }
+
+    if (nError == MMC_OK)
+    {
+        pByte = (BYTE *) pData;
+        while (wSectorCount > 0)
+        {
+
+            if (wSectorCount < 256)
+            {
+                wWriteCount = wSectorCount;
+            }
+            else
+            {
+                wWriteCount = 256;
+            }
+
+            nError = WriteSectors(pDrive, pByte, dwStartSector, wWriteCount);
+            if (nError != MMC_OK)
+            {
+                break;
+            }
+
+            dwStartSector += wWriteCount;
+            wSectorCount  -= wWriteCount;
+            pByte         += (wWriteCount * MMC_SECTOR_SIZE);
+        }
+    }
+
+    MMCFree();
+
+    return(nError);
+} /* MMCWriteSectors */
+#endif
+
+
+
+

+ 100 - 100
include/mmcdrv.h → lib/mmcdrv.h

@@ -1,100 +1,100 @@
-/****************************************************************************
-*  This file is part of the MMC device driver.
-*
-*  Copyright (c) 2002-2004 by Michael Fischer. 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 author 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 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.
-*
-****************************************************************************
-*  History:
-*
-*  10.10.04  mifi   First Version
-****************************************************************************/
-#ifndef __MMCDRV_H__
-#define __MMCDRV_H__
-
-#include "typedefs.h"
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-//
-// Here we can switch on/off some
-// feature of the software
-//
-#define MMC_SUPPORT_WRITE               1
-
-#define MMC_OK                          0x00
-#define MMC_ERROR                       0x01
-#define MMC_DRIVE_NOT_FOUND             0x02
-#define MMC_PARAM_ERROR                 0x03
-#define MMC_BUSY                        0x04
-#define MMC_NOT_SUPPORTED               0x08
-
-#define MMC_DRIVE_C                     0
-
-//
-// Sector size
-//
-#define MMC_SECTOR_SIZE                 512
-#define MAX_SECTOR_SIZE                 MMC_SECTOR_SIZE
-
-/*-------------------------------------------------------------------------*/
-/* global types                                                            */
-/*-------------------------------------------------------------------------*/
-typedef void MMC_MOUNT_FUNC(int nDevice);
-
-/*-------------------------------------------------------------------------*/
-/* global macros                                                           */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* Prototypes                                                              */
-/*-------------------------------------------------------------------------*/
-int MMCInit(int nMMCMode, MMC_MOUNT_FUNC * pMountFunc, MMC_MOUNT_FUNC * pUnMountFunc);
-
-int MMCMountAllDevices(int nMMCMode, BYTE *pSectorBuffer);
-
-int MMCGetSectorSize(BYTE bDevice);
-
-int MMCIsCDROMDevice(BYTE bDevice);
-
-int MMCIsZIPDevice(BYTE bDevice);
-
-int MMCUnMountDevice(BYTE bDevice);
-
-DWORD MMCGetTotalSectors(BYTE bDevice);
-
-int MMCReadSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
-
-#if (MMC_SUPPORT_WRITE == 1)
-
-int MMCWriteSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
-
-#endif
-
-#endif /* !__MMCDRV_H__ */
+/****************************************************************************
+*  This file is part of the MMC device driver.
+*
+*  Copyright (c) 2002-2004 by Michael Fischer. 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 author 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 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.
+*
+****************************************************************************
+*  History:
+*
+*  10.10.04  mifi   First Version
+****************************************************************************/
+#ifndef __MMCDRV_H__
+#define __MMCDRV_H__
+
+#include "typedefs.h"
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+//
+// Here we can switch on/off some
+// feature of the software
+//
+#define MMC_SUPPORT_WRITE               1
+
+#define MMC_OK                          0x00
+#define MMC_ERROR                       0x01
+#define MMC_DRIVE_NOT_FOUND             0x02
+#define MMC_PARAM_ERROR                 0x03
+#define MMC_BUSY                        0x04
+#define MMC_NOT_SUPPORTED               0x08
+
+#define MMC_DRIVE_C                     0
+
+//
+// Sector size
+//
+#define MMC_SECTOR_SIZE                 512
+#define MAX_SECTOR_SIZE                 MMC_SECTOR_SIZE
+
+/*-------------------------------------------------------------------------*/
+/* global types                                                            */
+/*-------------------------------------------------------------------------*/
+typedef void MMC_MOUNT_FUNC(int nDevice);
+
+/*-------------------------------------------------------------------------*/
+/* global macros                                                           */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* Prototypes                                                              */
+/*-------------------------------------------------------------------------*/
+int MMCInit(int nMMCMode, MMC_MOUNT_FUNC * pMountFunc, MMC_MOUNT_FUNC * pUnMountFunc);
+
+int MMCMountAllDevices(int nMMCMode, BYTE *pSectorBuffer);
+
+int MMCGetSectorSize(BYTE bDevice);
+
+int MMCIsCDROMDevice(BYTE bDevice);
+
+int MMCIsZIPDevice(BYTE bDevice);
+
+int MMCUnMountDevice(BYTE bDevice);
+
+DWORD MMCGetTotalSectors(BYTE bDevice);
+
+int MMCReadSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
+
+#if (MMC_SUPPORT_WRITE == 1)
+
+int MMCWriteSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
+
+#endif
+
+#endif /* !__MMCDRV_H__ */

+ 51 - 51
include/platform.h → lib/platform.h

@@ -1,51 +1,51 @@
-#ifndef _Platform_H
-#define _Platform_H
-/*
- *  Copyright STREAMIT BV, 2010.
- *
- *  Project             : SIR
- *  Module              : Platform
- *  File name  $Workfile: Platform.h  $
- *       Last Save $Date: 2003/08/18 10:09:48  $
- *             $Revision: 0.1  $
- *  Creation Date       : 2003/08/18 10:09:48
- *
- *  Description         : Definitions which are dependent on the compiler and
- *                        or processor.
- */
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-#define LOBYTE(w)           ((u_char) ((w) & 0xFF))
-#define HIBYTE(w)           ((u_char) (((u_short) (w) >> 8) & 0xFF))
-#define LOWORD(l)           ((u_short) ((l) & 0xFFFF))
-#define HIWORD(l)           ((u_short) (((u_long) (l) >> 16) & 0xFFFF))
-
-#define MAKEWORD(bLow, bHigh) \
-    ((u_short) (((u_char) (bLow)) | ((u_short) ((u_char) (bHigh))) << 8))
-#define MAKEULONG(wLow, wHigh) \
-    ((u_long) (((u_short) (wLow)) | ((u_long) ((u_short) (wHigh))) << 16))
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-
-#ifndef prog_int
-#define prog_int        prog_int16_t
-#endif /* #ifndef prog_int */
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-#define PRG_RDW(addr)   pgm_read_word(addr)
-
-#endif /* _Platform_H */
+#ifndef _Platform_H
+#define _Platform_H
+/*
+ *  Copyright STREAMIT BV, 2010.
+ *
+ *  Project             : SIR
+ *  Module              : Platform
+ *  File name  $Workfile: Platform.h  $
+ *       Last Save $Date: 2003/08/18 10:09:48  $
+ *             $Revision: 0.1  $
+ *  Creation Date       : 2003/08/18 10:09:48
+ *
+ *  Description         : Definitions which are dependent on the compiler and
+ *                        or processor.
+ */
+
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Constant definitions                                                    */
+/*--------------------------------------------------------------------------*/
+#define LOBYTE(w)           ((u_char) ((w) & 0xFF))
+#define HIBYTE(w)           ((u_char) (((u_short) (w) >> 8) & 0xFF))
+#define LOWORD(l)           ((u_short) ((l) & 0xFFFF))
+#define HIWORD(l)           ((u_short) (((u_long) (l) >> 16) & 0xFFFF))
+
+#define MAKEWORD(bLow, bHigh) \
+    ((u_short) (((u_char) (bLow)) | ((u_short) ((u_char) (bHigh))) << 8))
+#define MAKEULONG(wLow, wHigh) \
+    ((u_long) (((u_short) (wLow)) | ((u_long) ((u_short) (wHigh))) << 16))
+
+/*--------------------------------------------------------------------------*/
+/*  Type declarations                                                       */
+/*--------------------------------------------------------------------------*/
+
+#ifndef prog_int
+#define prog_int        prog_int16_t
+#endif /* #ifndef prog_int */
+
+/*--------------------------------------------------------------------------*/
+/*  Global variables                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Global functions                                                        */
+/*--------------------------------------------------------------------------*/
+#define PRG_RDW(addr)   pgm_read_word(addr)
+
+#endif /* _Platform_H */

+ 142 - 142
include/portio.h → lib/portio.h

@@ -1,142 +1,142 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     PortIO
- * [TITLE]      Port IO header file
- * [FILE]       portio.h
- * [VSN]        2.0
- * [CREATED]    030414
- * [LASTCHNGD]  072405
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    support for low-level pinning
- * ======================================================================== */
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-//      ********* PORT B ************
-
-//     7   6   5   4   3   2   1   0
-//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
-//  ³RES³CEN³CSC³XCS³SO ³ SI³CLK³CWP³
-// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
-
-#define MMC_ENABLE      5           // active LOW!
-#define VS_ENABLE       6           // note that logic has changed since SIR80 V1
-
-#define MMCVS_OUT_DDR   DDRB        // data-direction of MMC/VS functions
-#define MMCVS_OUT_WRITE PORTB       // write PORTB (B as output)
-
-//      ********* PORT D ************
-
-//     7   6   5   4   3   2   1   0
-//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
-//  ³LD7³LD6³LD5³LD4³KC2³KC3³ EN³ - ³
-// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
-
-#define LCD_EN          2           // LCD chip Enable (or: chip select)
-
-#define LCD_DATA_4      4
-#define LCD_DATA_5      5
-#define LCD_DATA_6      6
-#define LCD_DATA_7      7
-
-#define LCD_DATA_DDR    DDRD        // data-direction of LCD-data port
-#define LCD_DATA_PORT   PORTD       // port to write LCD-data
-#define LCD_IN_PORT     PIND        // port to read LCD-data
-
-#define LCD_EN_DDR      DDRE        // data-direction of LCD-control port
-#define LCD_EN_PORT     PORTE       // data of LCD-control port
-
-#define KB_OUT_DDR_B    DDRD        // data-direction of KB_OUT (second part)
-#define KB_OUT_WRITE_B  PORTD       // write PORTD (D as output)
-
-//      ********* PORT E ************
-
-//     7   6   5   4   3   2   1   0
-//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
-//  ³CSF³REQ³ETH³IR ³BL ³ - ³TXD³RXD³
-// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
-
-#define FLASH_ENABLE    7       // active LOW!
-#define LCD_BL_BIT      3       // Backlight LCD
-#define IR_PIN          4       // Infrared receive PIN
-
-#define FLASH_OUT_WRITE PORTE   // write PORTE for Flash CS
-#define LCD_BL_PORT     PORTE
-
-
-
-//      ********* PORT F ************
-
-//     7   6   5   4   3   2   1   0
-//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
-//  ³KR3³KR2³KR1³KR0³LED³LRS³LRW³CRD³        // note TDI ( JTAG-pin) is shared with KR3
-// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
-
-#define MMC_CDETECT         0       // signal card inserted/removed
-#define LCD_RW              1       // R/W LCD
-#define LCD_RS              2       // Register select LCD
-#define LED_PIN             3       // LED
-
-
-#define LCD_RS_DDR          DDRF    // data-direction of LCD-control port
-#define LCD_RS_PORT         PORTF   // data of LCD-control port
-#define LCD_RW_DDR          DDRF    // data-direction of LCD-control port
-#define LCD_RW_PORT         PORTF   // data of LCD-control port
-
-#define LED_OUT_DDR         DDRF    // data-direction of LED control pin
-#define LED_OUT_WRITE       PORTF   // write PORTF
-
-#define KB_IN_DDR           DDRF    // data-direction of KB_IN
-#define KB_IN_WRITE         PORTF   // write PORTF (F as output)
-#define KB_IN_READ          PINF    // read PINF (F as input)
-
-#define MMC_IN_DDR          DDRF    // data-direction of MMC_CDETECT
-#define MMC_IN_READ         PINF    // read PINF (F as input)
-
-
-//     7   6   5   4   3   2   1   0
-//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
-//  ³ - ³ - ³ - ³KC1³KC0³ - ³ - ³ - ³
-// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
-
-#define KB_OUT_DDR_A    DDRG        // data-direction of KB_OUT (first part)
-#define KB_OUT_WRITE_A  PORTG       // write PORTG (G as output)
-
-
-#define JTAG_REG            MCUCR
-#define OVERFLOW_SIGNAL     sig_OVERFLOW0
-
-#define init_8_bit_timer()  \
-{                           \
-    TCCR0B |= (1<<CS02);    \
-    TIFR0 |= 1<<TOV0;       \
-    TIMSK0 |= 1<<TOIE0;     \
-}
-
-#define disable_8_bit_timer_ovfl_int()  \
-{                                       \
-    TIMSK0 &= ~(1<<TOIE0);              \
-}
-
-//      ********* PORT G ************
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
-
-
-
-
-
-
-
-
-
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     PortIO
+ * [TITLE]      Port IO header file
+ * [FILE]       portio.h
+ * [VSN]        2.0
+ * [CREATED]    030414
+ * [LASTCHNGD]  072405
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    support for low-level pinning
+ * ======================================================================== */
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+
+//      ********* PORT B ************
+
+//     7   6   5   4   3   2   1   0
+//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
+//  ³RES³CEN³CSC³XCS³SO ³ SI³CLK³CWP³
+// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+
+#define MMC_ENABLE      5           // active LOW!
+#define VS_ENABLE       6           // note that logic has changed since SIR80 V1
+
+#define MMCVS_OUT_DDR   DDRB        // data-direction of MMC/VS functions
+#define MMCVS_OUT_WRITE PORTB       // write PORTB (B as output)
+
+//      ********* PORT D ************
+
+//     7   6   5   4   3   2   1   0
+//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
+//  ³LD7³LD6³LD5³LD4³KC2³KC3³ EN³ - ³
+// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+
+#define LCD_EN          2           // LCD chip Enable (or: chip select)
+
+#define LCD_DATA_4      4
+#define LCD_DATA_5      5
+#define LCD_DATA_6      6
+#define LCD_DATA_7      7
+
+#define LCD_DATA_DDR    DDRD        // data-direction of LCD-data port
+#define LCD_DATA_PORT   PORTD       // port to write LCD-data
+#define LCD_IN_PORT     PIND        // port to read LCD-data
+
+#define LCD_EN_DDR      DDRE        // data-direction of LCD-control port
+#define LCD_EN_PORT     PORTE       // data of LCD-control port
+
+#define KB_OUT_DDR_B    DDRD        // data-direction of KB_OUT (second part)
+#define KB_OUT_WRITE_B  PORTD       // write PORTD (D as output)
+
+//      ********* PORT E ************
+
+//     7   6   5   4   3   2   1   0
+//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
+//  ³CSF³REQ³ETH³IR ³BL ³ - ³TXD³RXD³
+// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+
+#define FLASH_ENABLE    7       // active LOW!
+#define LCD_BL_BIT      3       // Backlight LCD
+#define IR_PIN          4       // Infrared receive PIN
+
+#define FLASH_OUT_WRITE PORTE   // write PORTE for Flash CS
+#define LCD_BL_PORT     PORTE
+
+
+
+//      ********* PORT F ************
+
+//     7   6   5   4   3   2   1   0
+//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
+//  ³KR3³KR2³KR1³KR0³LED³LRS³LRW³CRD³        // note TDI ( JTAG-pin) is shared with KR3
+// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+
+#define MMC_CDETECT         0       // signal card inserted/removed
+#define LCD_RW              1       // R/W LCD
+#define LCD_RS              2       // Register select LCD
+#define LED_PIN             3       // LED
+
+
+#define LCD_RS_DDR          DDRF    // data-direction of LCD-control port
+#define LCD_RS_PORT         PORTF   // data of LCD-control port
+#define LCD_RW_DDR          DDRF    // data-direction of LCD-control port
+#define LCD_RW_PORT         PORTF   // data of LCD-control port
+
+#define LED_OUT_DDR         DDRF    // data-direction of LED control pin
+#define LED_OUT_WRITE       PORTF   // write PORTF
+
+#define KB_IN_DDR           DDRF    // data-direction of KB_IN
+#define KB_IN_WRITE         PORTF   // write PORTF (F as output)
+#define KB_IN_READ          PINF    // read PINF (F as input)
+
+#define MMC_IN_DDR          DDRF    // data-direction of MMC_CDETECT
+#define MMC_IN_READ         PINF    // read PINF (F as input)
+
+
+//     7   6   5   4   3   2   1   0
+//   ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
+//  ³ - ³ - ³ - ³KC1³KC0³ - ³ - ³ - ³
+// ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+
+#define KB_OUT_DDR_A    DDRG        // data-direction of KB_OUT (first part)
+#define KB_OUT_WRITE_A  PORTG       // write PORTG (G as output)
+
+
+#define JTAG_REG            MCUCR
+#define OVERFLOW_SIGNAL     sig_OVERFLOW0
+
+#define init_8_bit_timer()  \
+{                           \
+    TCCR0B |= (1<<CS02);    \
+    TIFR0 |= 1<<TOV0;       \
+    TIMSK0 |= 1<<TOIE0;     \
+}
+
+#define disable_8_bit_timer_ovfl_int()  \
+{                                       \
+    TIMSK0 &= ~(1<<TOIE0);              \
+}
+
+//      ********* PORT G ************
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 151 - 151
source/remcon.c → lib/remcon.c

@@ -1,151 +1,151 @@
-/*! \file
- * remcon.c contains all interface- and low-level routines that
- * perform handling of the infrared bitstream
- * [COPYRIGHT]  Copyright (C) STREAMIT BV
- *  \version 1.0
- *  \date 26 september 2003
- */
-
-
-
-#define LOG_MODULE  LOG_REMCON_MODULE
-
-#include <stdlib.h>
-#include <fs/typedefs.h>
-#include <sys/heap.h>
-
-#include <sys/event.h>
-#include <sys/atom.h>
-#include <sys/types.h>
-#include <dev/irqreg.h>
-
-#include "system.h"
-#include "portio.h"
-#include "remcon.h"
-#include "display.h"
-#include "keyboard.h"
-#include "led.h"
-
-
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-static HANDLE  hRCEvent;
-
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-static void RcInterrupt(void*);
-static void RcClearEvent(HANDLE*);
-
-
-/*!
- * \addtogroup RemoteControl
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief ISR Remote Control Interrupt (ISR called by Nut/OS)
- *
- *  NEC-code consists of 5 parts:
- *
- *  - leader (9 msec high, 4,5 msec low)
- *  - address (8 bits)
- *  - inverted address (8 bits)
- *  - data (8 bits)
- *  - inverted data (8 bits)
- *
- *  The first sequence contains these 5 parts, next
- *  sequences only contain the leader + 1 '0' bit as long
- *  as the user holds down the button
- *  repetition time is 108 msec in that case
- *
- *  Resolution of the 16-bit timer we use here is 4,3 usec
- *
- *  13,5 msecs are 3109 ticks
- *  '0' is 1,25 msecs (260 ticks)
- *  '1' is 2,25 msecs (517 ticks)
- *
- * \param *p not used (might be used to pass parms from the ISR)
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static void RcInterrupt(void *p)
-{
-	// Hier ISR implementeren voor bijv. NEC protocol
-}
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Clear the eventbuffer of this module
- *
- * This routine is called during module initialization.
- *
- * \param *pEvent pointer to the event queue
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-static void RcClearEvent(HANDLE *pEvent)
-{
-    NutEnterCritical();
-
-    *pEvent = 0;
-
-    NutExitCritical();
-}
-
-
-
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-/*!
- * \brief Initialise the Remote Control module
- *
- * - register the ISR in NutOS
- * - initialise the HW-timer that is used for this module (Timer1)
- * - initialise the external interrupt that inputs the infrared data
- * - flush the remote control buffer
- * - flush the eventqueue for this module
- */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-void RcInit()
-{
-    int nError = 0;
-
-    EICRB &= ~RC_INT_SENS_MASK;    // clear b0, b1 of EICRB
-
-    // Install Remote Control interrupt
-    nError = NutRegisterIrqHandler(&sig_INTERRUPT4, RcInterrupt, NULL);
-    if (nError == FALSE)
-    {
-/*
- *  ToDo: control External Interrupt following NutOS calls
-#if (NUTOS_VERSION >= 421)
-        NutIrqSetMode(&sig_INTERRUPT4, NUT_IRQMODE_FALLINGEDGE);
-#else
-        EICRB |= RC_INT_FALLING_EDGE;
-#endif
-        EIMSK |= 1<<IRQ_INT4;         // enable interrupt
- */
-        EICRB |= RC_INT_FALLING_EDGE;
-        EIMSK |= 1<<IRQ_INT4;         // enable interrupt
-    }
-
-    // Initialise 16-bit Timer (Timer1)
-    TCCR1B |= (1<<CS11) | (1<<CS10); // clockdivider = 64
-    TIFR   |= 1<<ICF1;
-    //TIMSK = 1<<TICIE1;
-
-    RcClearEvent(&hRCEvent);
-
-
-}
-
-/* ---------- end of module ------------------------------------------------ */
-
-/*@}*/
+/*! \file
+ * remcon.c contains all interface- and low-level routines that
+ * perform handling of the infrared bitstream
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV
+ *  \version 1.0
+ *  \date 26 september 2003
+ */
+
+
+
+#define LOG_MODULE  LOG_REMCON_MODULE
+
+#include <stdlib.h>
+#include <fs/typedefs.h>
+#include <sys/heap.h>
+
+#include <sys/event.h>
+#include <sys/atom.h>
+#include <sys/types.h>
+#include <dev/irqreg.h>
+
+#include "system.h"
+#include "portio.h"
+#include "remcon.h"
+#include "display.h"
+#include "keyboard.h"
+#include "led.h"
+
+
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+static HANDLE  hRCEvent;
+
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+static void RcInterrupt(void*);
+static void RcClearEvent(HANDLE*);
+
+
+/*!
+ * \addtogroup RemoteControl
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+
+
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief ISR Remote Control Interrupt (ISR called by Nut/OS)
+ *
+ *  NEC-code consists of 5 parts:
+ *
+ *  - leader (9 msec high, 4,5 msec low)
+ *  - address (8 bits)
+ *  - inverted address (8 bits)
+ *  - data (8 bits)
+ *  - inverted data (8 bits)
+ *
+ *  The first sequence contains these 5 parts, next
+ *  sequences only contain the leader + 1 '0' bit as long
+ *  as the user holds down the button
+ *  repetition time is 108 msec in that case
+ *
+ *  Resolution of the 16-bit timer we use here is 4,3 usec
+ *
+ *  13,5 msecs are 3109 ticks
+ *  '0' is 1,25 msecs (260 ticks)
+ *  '1' is 2,25 msecs (517 ticks)
+ *
+ * \param *p not used (might be used to pass parms from the ISR)
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static void RcInterrupt(void *p)
+{
+	// Hier ISR implementeren voor bijv. NEC protocol
+}
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Clear the eventbuffer of this module
+ *
+ * This routine is called during module initialization.
+ *
+ * \param *pEvent pointer to the event queue
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+static void RcClearEvent(HANDLE *pEvent)
+{
+    NutEnterCritical();
+
+    *pEvent = 0;
+
+    NutExitCritical();
+}
+
+
+
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*!
+ * \brief Initialise the Remote Control module
+ *
+ * - register the ISR in NutOS
+ * - initialise the HW-timer that is used for this module (Timer1)
+ * - initialise the external interrupt that inputs the infrared data
+ * - flush the remote control buffer
+ * - flush the eventqueue for this module
+ */
+/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+void RcInit()
+{
+    int nError = 0;
+
+    EICRB &= ~RC_INT_SENS_MASK;    // clear b0, b1 of EICRB
+
+    // Install Remote Control interrupt
+    nError = NutRegisterIrqHandler(&sig_INTERRUPT4, RcInterrupt, NULL);
+    if (nError == FALSE)
+    {
+/*
+ *  ToDo: control External Interrupt following NutOS calls
+#if (NUTOS_VERSION >= 421)
+        NutIrqSetMode(&sig_INTERRUPT4, NUT_IRQMODE_FALLINGEDGE);
+#else
+        EICRB |= RC_INT_FALLING_EDGE;
+#endif
+        EIMSK |= 1<<IRQ_INT4;         // enable interrupt
+ */
+        EICRB |= RC_INT_FALLING_EDGE;
+        EIMSK |= 1<<IRQ_INT4;         // enable interrupt
+    }
+
+    // Initialise 16-bit Timer (Timer1)
+    TCCR1B |= (1<<CS11) | (1<<CS10); // clockdivider = 64
+    TIFR   |= 1<<ICF1;
+    //TIMSK = 1<<TICIE1;
+
+    RcClearEvent(&hRCEvent);
+
+
+}
+
+/* ---------- end of module ------------------------------------------------ */
+
+/*@}*/

+ 52 - 52
include/remcon.h → lib/remcon.h

@@ -1,52 +1,52 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     Remote Control
- * [TITLE]      remote control header file
- * [FILE]       remcon.h
- * [VSN]        1.0
- * [CREATED]    1 july 2003
- * [LASTCHNGD]  1 july 2003
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    remote control routines for SIR
- * ======================================================================== */
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-#define RC_OK                 0x00
-#define RC_ERROR              0x01
-#define RC_BUSY               0x04
-
-#define RCST_IDLE             0x00
-#define RCST_WAITFORLEADER    0x01
-#define RCST_SCANADDRESS      0x02
-#define RCST_SCANDATA         0x03
-
-#define RC_INT_SENS_MASK      0x03
-#define RC_INT_FALLING_EDGE   0x02
-#define RC_INT_RISING_EDGE    0x03
-
-#define IR_RECEIVE            4
-#define IR_BUFFER_SIZE        1
-
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-void    RcInit(void);
-
-
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
-
-
-
-
-
-
-
-
-
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     Remote Control
+ * [TITLE]      remote control header file
+ * [FILE]       remcon.h
+ * [VSN]        1.0
+ * [CREATED]    1 july 2003
+ * [LASTCHNGD]  1 july 2003
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    remote control routines for SIR
+ * ======================================================================== */
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+#define RC_OK                 0x00
+#define RC_ERROR              0x01
+#define RC_BUSY               0x04
+
+#define RCST_IDLE             0x00
+#define RCST_WAITFORLEADER    0x01
+#define RCST_SCANADDRESS      0x02
+#define RCST_SCANDATA         0x03
+
+#define RC_INT_SENS_MASK      0x03
+#define RC_INT_FALLING_EDGE   0x02
+#define RC_INT_RISING_EDGE    0x03
+
+#define IR_RECEIVE            4
+#define IR_BUFFER_SIZE        1
+
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+void    RcInit(void);
+
+
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 471 - 471
source/rtc.c → lib/rtc.c

@@ -1,471 +1,471 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     Real Time Clock
- * [TITLE]      High- and low level Routines for INtersil X1205 RTC chip
- * [FILE]       rtc.c
- * [VSN]        1.0
- * [CREATED]    13042007
- * [LASTCHNGD]  131042007
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    contains all interface- and low-level routines to
- *              read/write date/time/status strings from the X1205
- * ======================================================================== */
-
-#define LOG_MODULE  LOG_RTC_MODULE
-
-#include <cfg/os.h>
-#include <dev/twif.h>
-#include <sys/event.h>
-#include <sys/timer.h>
-
-#include <time.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "rtc.h"
-#include "portio.h"
-
-#define I2C_SLA_RTC         0x6F
-#define I2C_SLA_EEPROM      0x57
-#define EEPROM_PAGE_SIZE    64
-
-
-static u_long rtc_status;
-
-/*!
- * \brief Enable or disable write access.
- *
- * \param on Write access is disabled if this parameter is 0, or
- *           enabled otherwise.
- *
- * \return 0 on success or -1 in case of an error.
- */
-static int X12WriteEnable(int on)
-{
-    int rc;
-    u_char buf[3];
-
-    buf[0] = 0;
-    buf[1] = 0x3F;
-    if (on)
-    {
-        buf[2] = 0x02;
-        if ((rc = TwMasterTransact(I2C_SLA_RTC, buf, 3, 0, 0, NUT_WAIT_INFINITE)) == 0)
-        {
-            buf[2] = 0x06;
-            rc = TwMasterTransact(I2C_SLA_RTC, buf, 3, 0, 0, NUT_WAIT_INFINITE);
-        }
-    }
-    else
-    {
-        buf[2] = 0x00;
-        rc = TwMasterTransact(I2C_SLA_RTC, buf, 3, 0, 0, NUT_WAIT_INFINITE);
-    }
-    return(rc);
-}
-
-/*!
- * \brief Wait until non-volatile write cycle finished.
- *
- * \return 0 on success or -1 in case of an error.
- */
-static int X12WaitReady(void)
-{
-    u_char poll;
-    int cnt = 20;
-
-    /* Poll for write cycle finished. */
-    while (--cnt && TwMasterTransact(I2C_SLA_EEPROM, 0, 0, &poll, 1, NUT_WAIT_INFINITE) == -1)
-    {
-        NutSleep(1);
-    }
-    return(cnt ? 0 : -1);
-}
-
-/*!
- * \brief Read RTC registers.
- *
- * \param reg  The first register to read.
- * \param buff Pointer to a buffer that receives the register contents.
- * \param cnt  The number of registers to read.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12RtcReadRegs(u_char reg, u_char *buff, size_t cnt)
-{
-    int rc = -1;
-    u_char wbuf[2];
-
-    wbuf[0] = 0;
-    wbuf[1] = reg;
-    if (TwMasterTransact(I2C_SLA_RTC, wbuf, 2, buff, cnt, NUT_WAIT_INFINITE) == cnt)
-    {
-        rc = 0;
-    }
-    return(rc);
-}
-
-/*!
- * \brief Write to RTC registers.
- *
- * \param nv   Must be set to 1 when writing to non-volatile registers.
- *             In this case the routine will poll for write cycle
- *             completion before returning to the caller. Set to zero
- *             if writing to volatile registers.
- * \param buff This buffer must contain all bytes to be transfered to
- *             the RTC chip, including the register address.
- * \param cnt  Number of valid bytes in the buffer.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12RtcWrite(int nv, CONST u_char *buff, size_t cnt)
-{
-    int rc;
-
-    if ((rc = X12WriteEnable(1)) == 0)
-    {
-        rc = TwMasterTransact(I2C_SLA_RTC, buff, cnt, 0, 0, NUT_WAIT_INFINITE);
-        if (rc == 0 && nv)
-        {
-            rc = X12WaitReady();
-        }
-        X12WriteEnable(0);
-    }
-    return(rc);
-}
-
-/*!
- * \brief Get date and time from an X12xx hardware clock.
- *
- * \deprecated New applications must use NutRtcGetTime().
- *
- * \param tm Points to a structure that receives the date and time
- *           information.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12RtcGetClock(struct _tm *tm)
-{
-    int rc;
-    u_char data[8];
-
-    if ((rc = X12RtcReadRegs(X12RTC_SC, data, 8)) == 0)
-    {
-        tm->tm_sec = BCD2BIN(data[0]);
-        tm->tm_min = BCD2BIN(data[1]);
-        tm->tm_hour = BCD2BIN(data[2] & 0x3F);
-        tm->tm_mday = BCD2BIN(data[3]);
-        tm->tm_mon = BCD2BIN(data[4]) - 1;
-        tm->tm_year = BCD2BIN(data[5]) + 100;
-        if (BCD2BIN(data[7]) > 0x19)
-        {
-            tm->tm_year += 100;
-        }
-        tm->tm_wday = data[6];
-    }
-    return(rc);
-}
-
-/*!
- * \brief Set an X12xx hardware clock.
- *
- * \deprecated New applications must use NutRtcSetTime().
- *
- * New time will be taken over at the beginning of the next second.
- *
- * \param tm Points to a structure which contains the date and time
- *           information.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12RtcSetClock(CONST struct _tm *tm)
-{
-    u_char data[10];
-
-    memset(data, 0, sizeof(data));
-    if (tm)
-    {
-        data[1] = X12RTC_SC;
-        data[2] = BIN2BCD(tm->tm_sec);
-        data[3] = BIN2BCD(tm->tm_min);
-        data[4] = BIN2BCD(tm->tm_hour) | 0x80;
-        data[5] = BIN2BCD(tm->tm_mday);
-        data[6] = BIN2BCD(tm->tm_mon + 1);
-        if (tm->tm_year > 99)
-        {
-            data[7] = BIN2BCD(tm->tm_year - 100);
-            data[9] = 0x20;
-        }
-        else
-        {
-            data[7] = BIN2BCD(tm->tm_year);
-            data[9] = 0x19;
-        }
-        data[8] = tm->tm_wday;
-    }
-    return(X12RtcWrite(0, data, 10));
-}
-
-/*!
- * \brief Get alarm date and time of an X12xx hardware clock.
- *
- * \deprecated New applications must use NutRtcGetAlarm().
- *
- * \param idx   Zero based index. Two alarms are supported.
- * \param tm    Points to a structure that receives the date and time
- *              information.
- * \param aflgs Points to an unsigned long that receives the enable flags.
- *
- * \return 0 on success or -1 in case of an error.
- *
- */
-int X12RtcGetAlarm(int idx, struct _tm *tm, int *aflgs)
-{
-    int rc;
-    u_char data[8];
-
-    *aflgs = 0;
-    memset(tm, 0, sizeof(struct _tm));
-    if ((rc = X12RtcReadRegs(idx * 8, data, 8)) == 0)
-    {
-        if (data[0] & X12RTC_SCA_ESC)
-        {
-            *aflgs |= RTC_ALARM_SECOND;
-            tm->tm_sec = BCD2BIN(data[0] & 0x7F);
-        }
-        if (data[1] & X12RTC_MNA_EMN)
-        {
-            *aflgs |= RTC_ALARM_MINUTE;
-            tm->tm_min = BCD2BIN(data[1]);
-        }
-        if (data[2] & X12RTC_HRA_EHR)
-        {
-            *aflgs |= RTC_ALARM_HOUR;
-            tm->tm_hour = BCD2BIN(data[2] & ~0x80);
-        }
-        if (data[3] & X12RTC_DTA_EDT)
-        {
-            *aflgs |= RTC_ALARM_MDAY;
-            tm->tm_mday = BCD2BIN(data[3]);
-        }
-        if (data[4] & X12RTC_MOA_EMO)
-        {
-            *aflgs |= RTC_ALARM_MONTH;
-            tm->tm_mon = BCD2BIN(data[4]) - 1;
-        }
-        if (data[6] & X12RTC_DWA_EDW)
-        {
-            *aflgs |= RTC_ALARM_WDAY;
-            tm->tm_wday = BCD2BIN(data[6]);
-        }
-    }
-    return(rc);
-}
-
-/*!
- * \brief Set alarm of an X12xx hardware clock.
- *
- * \deprecated New applications must use NutRtcSetAlarm().
- *
- * \param idx   Zero based index. Two alarms are supported.
- * \param tm    Points to a structure which contains the date and time
- *              information. May be NULL to clear the alarm.
- * \param aflgs Each bit enables a specific comparision.
- *              - Bit 0: Seconds
- *              - Bit 1: Minutes
- *              - Bit 2: Hours
- *              - Bit 3: Day of month
- *              - Bit 4: Month
- *              - Bit 7: Day of week (Sunday is zero)
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12RtcSetAlarm(int idx, CONST struct _tm *tm, int aflgs)
-{
-    u_char data[10];
-
-    memset(data, 0, sizeof(data));
-    data[1] = idx * 8;
-    if (tm)
-    {
-        if (aflgs & RTC_ALARM_SECOND)
-        {
-            data[2] = BIN2BCD(tm->tm_sec) | X12RTC_SCA_ESC;
-        }
-        if (aflgs & RTC_ALARM_MINUTE)
-        {
-            data[3] = BIN2BCD(tm->tm_min) | X12RTC_MNA_EMN;
-        }
-        if (aflgs & RTC_ALARM_HOUR)
-        {
-            data[4] = BIN2BCD(tm->tm_hour) | X12RTC_HRA_EHR;
-        }
-        if (aflgs & RTC_ALARM_MDAY)
-        {
-            data[5] = BIN2BCD(tm->tm_mday) | X12RTC_DTA_EDT;
-        }
-        if (aflgs & RTC_ALARM_MONTH)
-        {
-            data[6] = BIN2BCD(tm->tm_mon + 1) | X12RTC_MOA_EMO;
-        }
-        if (aflgs & RTC_ALARM_WDAY)
-        {
-            data[8] = BIN2BCD(tm->tm_wday) | X12RTC_DWA_EDW;
-        }
-    }
-    return(X12RtcWrite(1, data, 10));
-}
-
-/*!
- * \brief Query RTC status flags.
- *
- * \deprecated New applications must use NutRtcGetStatus().
- *
- * \param sflgs Points to an unsigned long that receives the status flags.
- *              - Bit 0: Power fail.
- *              - Bit 5: Alarm 0 occured.
- *              - Bit 6: Alarm 1 occured.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12RtcGetStatus(u_long *sflgs)
-{
-    int rc;
-    u_char data;
-
-    if ((rc = X12RtcReadRegs(X12RTC_SR, &data, 1)) == 0)
-    {
-        rtc_status |= data;
-        *sflgs = rtc_status;
-    }
-    return(rtc_status);
-}
-
-/*!
- * \brief Clear RTC status flags.
- *
- * \deprecated New applications must use NutRtcClearStatus().
- *
- * \param sflgs Status flags to clear.
- *
- * \return Always 0.
- */
-int X12RtcClearStatus(u_long sflgs)
-{
-    rtc_status &= ~sflgs;
-
-    return(0);
-}
-
-/*!
- * \brief Read contents from non-volatile EEPROM.
- *
- * \param addr  Start location.
- * \param buff  Points to a buffer that receives the contents.
- * \param len   Number of bytes to read.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12EepromRead(u_int addr, void *buff, size_t len)
-{
-    int rc = -1;
-    u_char wbuf[2];
-
-    wbuf[0] = (u_char)(addr >> 8);
-    wbuf[1] = (u_char)addr;
-    if (TwMasterTransact(I2C_SLA_EEPROM, wbuf, 2, buff, len, NUT_WAIT_INFINITE) == len)
-    {
-        rc = 0;
-    }
-    return(rc);
-}
-
-/*!
- * \brief Store buffer contents in non-volatile EEPROM.
- *
- * The EEPROM of the X122x has a capacity of 512 bytes, while the X1286 is
- * able to store 32 kBytes.
- *
- * \param addr  Storage start location.
- * \param buff  Points to a buffer that contains the bytes to store.
- * \param len   Number of valid bytes in the buffer.
- *
- * \return 0 on success or -1 in case of an error.
- */
-int X12EepromWrite(u_int addr, CONST void *buff, size_t len)
-{
-    int rc = 0;
-    u_char *wbuf;
-    size_t wlen;
-    CONST u_char *wp = buff;
-
-    /*
-     * Loop for each page to be written to.
-     */
-    while (len)
-    {
-        /* Do not cross page boundaries. */
-        wlen = EEPROM_PAGE_SIZE - (addr & (EEPROM_PAGE_SIZE - 1));
-        if (wlen > len)
-        {
-            wlen = len;
-        }
-
-        /* Allocate and set a TWI write buffer. */
-        if ((wbuf = malloc(wlen + 2)) == 0)
-        {
-            rc = -1;
-            break;
-        }
-        wbuf[0] = (u_char)(addr >> 8);
-        wbuf[1] = (u_char)addr;
-        memcpy(wbuf + 2, (void *)wp, wlen);
-
-        /* Enable EEPROM write access and send the write buffer. */
-        if ((rc = X12WriteEnable(1)) == 0)
-        {
-            rc = TwMasterTransact(I2C_SLA_EEPROM, wbuf, wlen + 2, 0, 0, NUT_WAIT_INFINITE);
-        }
-
-        /* Release the buffer and check the result. */
-        free(wbuf);
-        if (rc)
-        {
-            break;
-        }
-        len -= wlen;
-        addr += wlen;
-        wp += wlen;
-
-        /* Poll for write cycle finished. */
-        if ((rc = X12WaitReady()) != 0)
-        {
-            break;
-        }
-    }
-    X12WriteEnable(0);
-
-    return(rc);
-}
-
-/*!
- * \brief Initialize the interface to an Intersil X12xx hardware clock.
- *
- * \deprecated New applications must use NutRegisterRtc().
- *
- * \return 0 on success or -1 in case of an error.
- *
- */
-int X12Init(void)
-{
-    int rc;
-    u_long tmp;
-
-    if ((rc = TwInit(0)) == 0)
-    {
-        rc = X12RtcGetStatus(&tmp);
-    }
-    return (rc);
-}
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     Real Time Clock
+ * [TITLE]      High- and low level Routines for INtersil X1205 RTC chip
+ * [FILE]       rtc.c
+ * [VSN]        1.0
+ * [CREATED]    13042007
+ * [LASTCHNGD]  131042007
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    contains all interface- and low-level routines to
+ *              read/write date/time/status strings from the X1205
+ * ======================================================================== */
+
+#define LOG_MODULE  LOG_RTC_MODULE
+
+#include <cfg/os.h>
+#include <dev/twif.h>
+#include <sys/event.h>
+#include <sys/timer.h>
+
+#include <time.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "rtc.h"
+#include "portio.h"
+
+#define I2C_SLA_RTC         0x6F
+#define I2C_SLA_EEPROM      0x57
+#define EEPROM_PAGE_SIZE    64
+
+
+static u_long rtc_status;
+
+/*!
+ * \brief Enable or disable write access.
+ *
+ * \param on Write access is disabled if this parameter is 0, or
+ *           enabled otherwise.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+static int X12WriteEnable(int on)
+{
+    int rc;
+    u_char buf[3];
+
+    buf[0] = 0;
+    buf[1] = 0x3F;
+    if (on)
+    {
+        buf[2] = 0x02;
+        if ((rc = TwMasterTransact(I2C_SLA_RTC, buf, 3, 0, 0, NUT_WAIT_INFINITE)) == 0)
+        {
+            buf[2] = 0x06;
+            rc = TwMasterTransact(I2C_SLA_RTC, buf, 3, 0, 0, NUT_WAIT_INFINITE);
+        }
+    }
+    else
+    {
+        buf[2] = 0x00;
+        rc = TwMasterTransact(I2C_SLA_RTC, buf, 3, 0, 0, NUT_WAIT_INFINITE);
+    }
+    return(rc);
+}
+
+/*!
+ * \brief Wait until non-volatile write cycle finished.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+static int X12WaitReady(void)
+{
+    u_char poll;
+    int cnt = 20;
+
+    /* Poll for write cycle finished. */
+    while (--cnt && TwMasterTransact(I2C_SLA_EEPROM, 0, 0, &poll, 1, NUT_WAIT_INFINITE) == -1)
+    {
+        NutSleep(1);
+    }
+    return(cnt ? 0 : -1);
+}
+
+/*!
+ * \brief Read RTC registers.
+ *
+ * \param reg  The first register to read.
+ * \param buff Pointer to a buffer that receives the register contents.
+ * \param cnt  The number of registers to read.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12RtcReadRegs(u_char reg, u_char *buff, size_t cnt)
+{
+    int rc = -1;
+    u_char wbuf[2];
+
+    wbuf[0] = 0;
+    wbuf[1] = reg;
+    if (TwMasterTransact(I2C_SLA_RTC, wbuf, 2, buff, cnt, NUT_WAIT_INFINITE) == cnt)
+    {
+        rc = 0;
+    }
+    return(rc);
+}
+
+/*!
+ * \brief Write to RTC registers.
+ *
+ * \param nv   Must be set to 1 when writing to non-volatile registers.
+ *             In this case the routine will poll for write cycle
+ *             completion before returning to the caller. Set to zero
+ *             if writing to volatile registers.
+ * \param buff This buffer must contain all bytes to be transfered to
+ *             the RTC chip, including the register address.
+ * \param cnt  Number of valid bytes in the buffer.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12RtcWrite(int nv, CONST u_char *buff, size_t cnt)
+{
+    int rc;
+
+    if ((rc = X12WriteEnable(1)) == 0)
+    {
+        rc = TwMasterTransact(I2C_SLA_RTC, buff, cnt, 0, 0, NUT_WAIT_INFINITE);
+        if (rc == 0 && nv)
+        {
+            rc = X12WaitReady();
+        }
+        X12WriteEnable(0);
+    }
+    return(rc);
+}
+
+/*!
+ * \brief Get date and time from an X12xx hardware clock.
+ *
+ * \deprecated New applications must use NutRtcGetTime().
+ *
+ * \param tm Points to a structure that receives the date and time
+ *           information.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12RtcGetClock(struct _tm *tm)
+{
+    int rc;
+    u_char data[8];
+
+    if ((rc = X12RtcReadRegs(X12RTC_SC, data, 8)) == 0)
+    {
+        tm->tm_sec = BCD2BIN(data[0]);
+        tm->tm_min = BCD2BIN(data[1]);
+        tm->tm_hour = BCD2BIN(data[2] & 0x3F);
+        tm->tm_mday = BCD2BIN(data[3]);
+        tm->tm_mon = BCD2BIN(data[4]) - 1;
+        tm->tm_year = BCD2BIN(data[5]) + 100;
+        if (BCD2BIN(data[7]) > 0x19)
+        {
+            tm->tm_year += 100;
+        }
+        tm->tm_wday = data[6];
+    }
+    return(rc);
+}
+
+/*!
+ * \brief Set an X12xx hardware clock.
+ *
+ * \deprecated New applications must use NutRtcSetTime().
+ *
+ * New time will be taken over at the beginning of the next second.
+ *
+ * \param tm Points to a structure which contains the date and time
+ *           information.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12RtcSetClock(CONST struct _tm *tm)
+{
+    u_char data[10];
+
+    memset(data, 0, sizeof(data));
+    if (tm)
+    {
+        data[1] = X12RTC_SC;
+        data[2] = BIN2BCD(tm->tm_sec);
+        data[3] = BIN2BCD(tm->tm_min);
+        data[4] = BIN2BCD(tm->tm_hour) | 0x80;
+        data[5] = BIN2BCD(tm->tm_mday);
+        data[6] = BIN2BCD(tm->tm_mon + 1);
+        if (tm->tm_year > 99)
+        {
+            data[7] = BIN2BCD(tm->tm_year - 100);
+            data[9] = 0x20;
+        }
+        else
+        {
+            data[7] = BIN2BCD(tm->tm_year);
+            data[9] = 0x19;
+        }
+        data[8] = tm->tm_wday;
+    }
+    return(X12RtcWrite(0, data, 10));
+}
+
+/*!
+ * \brief Get alarm date and time of an X12xx hardware clock.
+ *
+ * \deprecated New applications must use NutRtcGetAlarm().
+ *
+ * \param idx   Zero based index. Two alarms are supported.
+ * \param tm    Points to a structure that receives the date and time
+ *              information.
+ * \param aflgs Points to an unsigned long that receives the enable flags.
+ *
+ * \return 0 on success or -1 in case of an error.
+ *
+ */
+int X12RtcGetAlarm(int idx, struct _tm *tm, int *aflgs)
+{
+    int rc;
+    u_char data[8];
+
+    *aflgs = 0;
+    memset(tm, 0, sizeof(struct _tm));
+    if ((rc = X12RtcReadRegs(idx * 8, data, 8)) == 0)
+    {
+        if (data[0] & X12RTC_SCA_ESC)
+        {
+            *aflgs |= RTC_ALARM_SECOND;
+            tm->tm_sec = BCD2BIN(data[0] & 0x7F);
+        }
+        if (data[1] & X12RTC_MNA_EMN)
+        {
+            *aflgs |= RTC_ALARM_MINUTE;
+            tm->tm_min = BCD2BIN(data[1]);
+        }
+        if (data[2] & X12RTC_HRA_EHR)
+        {
+            *aflgs |= RTC_ALARM_HOUR;
+            tm->tm_hour = BCD2BIN(data[2] & ~0x80);
+        }
+        if (data[3] & X12RTC_DTA_EDT)
+        {
+            *aflgs |= RTC_ALARM_MDAY;
+            tm->tm_mday = BCD2BIN(data[3]);
+        }
+        if (data[4] & X12RTC_MOA_EMO)
+        {
+            *aflgs |= RTC_ALARM_MONTH;
+            tm->tm_mon = BCD2BIN(data[4]) - 1;
+        }
+        if (data[6] & X12RTC_DWA_EDW)
+        {
+            *aflgs |= RTC_ALARM_WDAY;
+            tm->tm_wday = BCD2BIN(data[6]);
+        }
+    }
+    return(rc);
+}
+
+/*!
+ * \brief Set alarm of an X12xx hardware clock.
+ *
+ * \deprecated New applications must use NutRtcSetAlarm().
+ *
+ * \param idx   Zero based index. Two alarms are supported.
+ * \param tm    Points to a structure which contains the date and time
+ *              information. May be NULL to clear the alarm.
+ * \param aflgs Each bit enables a specific comparision.
+ *              - Bit 0: Seconds
+ *              - Bit 1: Minutes
+ *              - Bit 2: Hours
+ *              - Bit 3: Day of month
+ *              - Bit 4: Month
+ *              - Bit 7: Day of week (Sunday is zero)
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12RtcSetAlarm(int idx, CONST struct _tm *tm, int aflgs)
+{
+    u_char data[10];
+
+    memset(data, 0, sizeof(data));
+    data[1] = idx * 8;
+    if (tm)
+    {
+        if (aflgs & RTC_ALARM_SECOND)
+        {
+            data[2] = BIN2BCD(tm->tm_sec) | X12RTC_SCA_ESC;
+        }
+        if (aflgs & RTC_ALARM_MINUTE)
+        {
+            data[3] = BIN2BCD(tm->tm_min) | X12RTC_MNA_EMN;
+        }
+        if (aflgs & RTC_ALARM_HOUR)
+        {
+            data[4] = BIN2BCD(tm->tm_hour) | X12RTC_HRA_EHR;
+        }
+        if (aflgs & RTC_ALARM_MDAY)
+        {
+            data[5] = BIN2BCD(tm->tm_mday) | X12RTC_DTA_EDT;
+        }
+        if (aflgs & RTC_ALARM_MONTH)
+        {
+            data[6] = BIN2BCD(tm->tm_mon + 1) | X12RTC_MOA_EMO;
+        }
+        if (aflgs & RTC_ALARM_WDAY)
+        {
+            data[8] = BIN2BCD(tm->tm_wday) | X12RTC_DWA_EDW;
+        }
+    }
+    return(X12RtcWrite(1, data, 10));
+}
+
+/*!
+ * \brief Query RTC status flags.
+ *
+ * \deprecated New applications must use NutRtcGetStatus().
+ *
+ * \param sflgs Points to an unsigned long that receives the status flags.
+ *              - Bit 0: Power fail.
+ *              - Bit 5: Alarm 0 occured.
+ *              - Bit 6: Alarm 1 occured.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12RtcGetStatus(u_long *sflgs)
+{
+    int rc;
+    u_char data;
+
+    if ((rc = X12RtcReadRegs(X12RTC_SR, &data, 1)) == 0)
+    {
+        rtc_status |= data;
+        *sflgs = rtc_status;
+    }
+    return(rtc_status);
+}
+
+/*!
+ * \brief Clear RTC status flags.
+ *
+ * \deprecated New applications must use NutRtcClearStatus().
+ *
+ * \param sflgs Status flags to clear.
+ *
+ * \return Always 0.
+ */
+int X12RtcClearStatus(u_long sflgs)
+{
+    rtc_status &= ~sflgs;
+
+    return(0);
+}
+
+/*!
+ * \brief Read contents from non-volatile EEPROM.
+ *
+ * \param addr  Start location.
+ * \param buff  Points to a buffer that receives the contents.
+ * \param len   Number of bytes to read.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12EepromRead(u_int addr, void *buff, size_t len)
+{
+    int rc = -1;
+    u_char wbuf[2];
+
+    wbuf[0] = (u_char)(addr >> 8);
+    wbuf[1] = (u_char)addr;
+    if (TwMasterTransact(I2C_SLA_EEPROM, wbuf, 2, buff, len, NUT_WAIT_INFINITE) == len)
+    {
+        rc = 0;
+    }
+    return(rc);
+}
+
+/*!
+ * \brief Store buffer contents in non-volatile EEPROM.
+ *
+ * The EEPROM of the X122x has a capacity of 512 bytes, while the X1286 is
+ * able to store 32 kBytes.
+ *
+ * \param addr  Storage start location.
+ * \param buff  Points to a buffer that contains the bytes to store.
+ * \param len   Number of valid bytes in the buffer.
+ *
+ * \return 0 on success or -1 in case of an error.
+ */
+int X12EepromWrite(u_int addr, CONST void *buff, size_t len)
+{
+    int rc = 0;
+    u_char *wbuf;
+    size_t wlen;
+    CONST u_char *wp = buff;
+
+    /*
+     * Loop for each page to be written to.
+     */
+    while (len)
+    {
+        /* Do not cross page boundaries. */
+        wlen = EEPROM_PAGE_SIZE - (addr & (EEPROM_PAGE_SIZE - 1));
+        if (wlen > len)
+        {
+            wlen = len;
+        }
+
+        /* Allocate and set a TWI write buffer. */
+        if ((wbuf = malloc(wlen + 2)) == 0)
+        {
+            rc = -1;
+            break;
+        }
+        wbuf[0] = (u_char)(addr >> 8);
+        wbuf[1] = (u_char)addr;
+        memcpy(wbuf + 2, (void *)wp, wlen);
+
+        /* Enable EEPROM write access and send the write buffer. */
+        if ((rc = X12WriteEnable(1)) == 0)
+        {
+            rc = TwMasterTransact(I2C_SLA_EEPROM, wbuf, wlen + 2, 0, 0, NUT_WAIT_INFINITE);
+        }
+
+        /* Release the buffer and check the result. */
+        free(wbuf);
+        if (rc)
+        {
+            break;
+        }
+        len -= wlen;
+        addr += wlen;
+        wp += wlen;
+
+        /* Poll for write cycle finished. */
+        if ((rc = X12WaitReady()) != 0)
+        {
+            break;
+        }
+    }
+    X12WriteEnable(0);
+
+    return(rc);
+}
+
+/*!
+ * \brief Initialize the interface to an Intersil X12xx hardware clock.
+ *
+ * \deprecated New applications must use NutRegisterRtc().
+ *
+ * \return 0 on success or -1 in case of an error.
+ *
+ */
+int X12Init(void)
+{
+    int rc;
+    u_long tmp;
+
+    if ((rc = TwInit(0)) == 0)
+    {
+        rc = X12RtcGetStatus(&tmp);
+    }
+    return (rc);
+}
+
+

+ 158 - 158
include/rtc.h → lib/rtc.h

@@ -1,158 +1,158 @@
-#ifndef _RTC_H_
-#define	_RTC_H_
-
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     Real Time Clock
- * [TITLE]      High- and low level Routines for INtersil X1205 RTC chip
- * [FILE]       rtc.c
- * [VSN]        1.0
- * [CREATED]    13042007
- * [LASTCHNGD]  131042007
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    contains all interface- and low-level routines to
- *              read/write date/time/status strings from the X1205
- * ======================================================================== */
-#include <time.h>           // for tm-struct
-                            //
-/*! \name Non-Volatile Alarm Registers */
-/*@{*/
-#define X12RTC_SCA0         0x00    /*!< \brief Alarm 0 second. */
-#define X12RTC_SCA1         0x08    /*!< \brief Alarm 1 second. */
-#define X12RTC_SCA_ESC      0x80    /*!< \brief Second alarm enabled. */
-
-#define X12RTC_MNA0         0x01    /*!< \brief Alarm 0 minute. */
-#define X12RTC_MNA1         0x09    /*!< \brief Alarm 1 minute. */
-#define X12RTC_MNA_EMN      0x80    /*!< \brief Minute alarm enabled. */
-
-#define X12RTC_HRA0         0x02    /*!< \brief Alarm 0 hour. */
-#define X12RTC_HRA1         0x0A    /*!< \brief Alarm 1 hour. */
-#define X12RTC_HRA_EHR      0x80    /*!< \brief Hour alarm enabled. */
-
-#define X12RTC_DTA0         0x03    /*!< \brief Alarm 0 day of month. */
-#define X12RTC_DTA1         0x0B    /*!< \brief Alarm 1 day of month. */
-#define X12RTC_DTA_EDT      0x80    /*!< \brief Day of month alarm enabled. */
-
-#define X12RTC_MOA0         0x04    /*!< \brief Alarm 0 month. */
-#define X12RTC_MOA1         0x0C    /*!< \brief Alarm 1 month. */
-#define X12RTC_MOA_EMO      0x80    /*!< \brief Month alarm enabled. */
-
-#define X12RTC_YRA0         0x05    /*!< \brief Currently unused alarm 0 register. */
-#define X12RTC_YRA1         0x0D    /*!< \brief Currently unused alarm 1 register. */
-
-#define X12RTC_DWA0         0x06    /*!< \brief Alarm 0 weekday. */
-#define X12RTC_DWA1         0x0E    /*!< \brief Alarm 1 weekday. */
-#define X12RTC_DWA_EDW      0x80    /*!< \brief Weekday alarm enabled. */
-
-#define X12RTC_Y2K0         0x07    /*!< \brief Alarm 0 . */
-#define X12RTC_Y2K1         0x0F    /*!< \brief Alarm 1 . */
-/*@}*/
-
-/*! \name Non-Volatile Control Registers */
-/*@{*/
-#define X12RTC_BL           0x10    /*!< \brief Block protection and watchdog register. */
-
-#define X12RTC_BL_WD        0x14    /*!< \brief Watchdog configuration. */
-#define X12RTC_BL_WD_1750   0x00    /*!< \brief Timeout after 1.75 seconds. */
-#define X12RTC_BL_WD_750    0x04    /*!< \brief Timeout after 750 milliseconds. */
-#define X12RTC_BL_WD_250    0x10    /*!< \brief Timeout after 250 milliseconds. */
-#define X12RTC_BL_WD_OFF    0x14    /*!< \brief Disabled. */
-
-#define X12RTC_BL_BP        0xE0    /*!< \brief Block protection. */
-#define X12RTC_BL_BP_NONE   0x00    /*!< \brief No protection. */
-#define X12RTC_BL_BP_UQUAD  0x20    /*!< \brief Upper quarter protected. */
-#define X12RTC_BL_BP_UHALF  0x40    /*!< \brief Upper half protected. */
-#define X12RTC_BL_BP_FULL   0x60    /*!< \brief Full array protected. */
-#define X12RTC_BL_BP_FIRST1 0x80    /*!< \brief First page protected. */
-#define X12RTC_BL_BP_FIRST2 0xA0    /*!< \brief First 2 pages protected. */
-#define X12RTC_BL_BP_FIRST3 0xC0    /*!< \brief First 4 pages protected. */
-#define X12RTC_BL_BP_FIRST8 0xE0    /*!< \brief First 8 pages protected. */
-
-#define X12RTC_INT          0x11    /*!< \brief Interrupt control and freq. output register. */
-
-#define X12RTC_INT_FO       0x14    /*!< \brief Programmable frequency output bits. */
-#define X12RTC_INT_FO_IRQ   0x00    /*!< \brief Alarm interrupt. */
-#define X12RTC_INT_FO_32KHZ 0x04    /*!< \brief 32.768kHz. */
-#define X12RTC_INT_FO_100HZ 0x10    /*!< \brief 100Hz. */
-#define X12RTC_INT_FO_1HZ   0x14    /*!< \brief 1Hz. */
-
-#define X12RTC_INT_AL0E     0x20    /*!< \brief Alarm 0 interrupt enable. */
-#define X12RTC_INT_AL1E     0x40    /*!< \brief Alarm 1 interrupt enable. */
-#define X12RTC_INT_IM       0x80    /*!< \brief Repetitive alarm. */
-
-#define X12RTC_ATR          0x12    /*!< \brief Analog trimming register. */
-
-#define X12RTC_DTR          0x13    /*!< \brief Digital trimming register. */
-#define X12RTC_DTR_NONE     0x00    /*!< \brief 0 PPM. */
-#define X12RTC_DTR_PLUS10   0x02    /*!< \brief +10 PPM. */
-#define X12RTC_DTR_PLUS20   0x01    /*!< \brief +20 PPM. */
-#define X12RTC_DTR_PLUS30   0x03    /*!< \brief +30 PPM. */
-#define X12RTC_DTR_MINUS10  0x06    /*!< \brief -10 PPM. */
-#define X12RTC_DTR_MINUS20  0x05    /*!< \brief -20 PPM. */
-#define X12RTC_DTR_MINUS30  0x07    /*!< \brief -30 PPM. */
-/*@}*/
-
-/*! \name Volatile Date and Time Registers */
-/*@{*/
-#define X12RTC_SC           0x30    /*!< Seconds register, 0 - 59. */
-#define X12RTC_MN           0x31    /*!< Minutes register, 0 - 59. */
-#define X12RTC_HR           0x32    /*!< Hours register, 0 - 23. */
-#define X12RTC_HR_MIL       0x80    /*!< Use 24h format. */
-#define X12RTC_DT           0x33    /*!< Day register, 1 - 31. */
-#define X12RTC_MO           0x34    /*!< Month register, 1 - 12. */
-#define X12RTC_YR           0x35    /*!< Year register, 0 - 99. */
-#define X12RTC_DW           0x36    /*!< Day of the weeks register, 0 - 6. */
-#define X128xRTC_SSEC       0x37    /*!< X1286 1/100 second register, 0 - 99 (read only). */
-#define X122xRTC_Y2K        0x37    /*!< X1226 epoch register, 19 or 20. */
-/*@}*/
-
-/*! \name Volatile Status Register */
-/*@{*/
-#define X12RTC_SR           0x3F    /*!< Status register. */
-#define X12RTC_SR_RTCF      0x01    /*!< Power failure. */
-#define X12RTC_SR_WEL       0x02    /*!< Memory write enable. */
-#define X12RTC_SR_RWEL      0x04    /*!< Register write enable. */
-#define X12RTC_SR_AL0       0x20    /*!< Alarm 0 indicator. */
-#define X12RTC_SR_AL1       0x40    /*!< Alarm 1 indicator. */
-#define X12RTC_SR_BAT       0x80    /*!< Operating from battery. */
-/*@}*/
-
-#define RTC_STATUS_PF       0x00000001
-#define RTC_STATUS_AL0      0x00000020
-#define RTC_STATUS_AL1      0x00000040
-
-#define RTC_ALARM_SECOND    0x00000001
-#define RTC_ALARM_MINUTE    0x00000002
-#define RTC_ALARM_HOUR      0x00000004
-#define RTC_ALARM_MDAY      0x00000008
-#define RTC_ALARM_MONTH     0x00000010
-#define RTC_ALARM_WDAY      0x00000080
-
-/*!
- * \brief Convert binary coded decimal to binary value.
- */
-#define BCD2BIN(x) ((((u_char)(x)) >> 4) * 10 + ((x) & 0x0F))
-
-/*!
- * \brief Convert binary to binary coded decimal value.
- */
-#define BIN2BCD(x) (((((u_char)(x)) / 10) << 4) + (x) % 10)
-
-
-/* Prototypes */
-extern int X12Init(void);
-
-extern int X12RtcGetClock(tm *tm);
-extern int X12RtcSetClock(CONST tm *tm);
-extern int X12RtcGetAlarm(int idx, tm *tm, int *aflgs);
-extern int X12RtcSetAlarm(int idx, CONST tm *tm, int aflgs);
-extern int X12RtcGetStatus(u_long *sflgs);
-extern int X12RtcClearStatus(u_long sflgs);
-extern int X12RtcReadRegs(u_char addr, u_char *buff, size_t len);
-extern int X12RtcWrite(int nv, CONST u_char *buff, size_t len);
-
-extern int X12EepromRead(u_int addr, void *buff, size_t len);
-extern int X12EepromWrite(u_int addr, CONST void *buff, size_t len);
-
-/* End of prototypes */
-#endif
+#ifndef _RTC_H_
+#define	_RTC_H_
+
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     Real Time Clock
+ * [TITLE]      High- and low level Routines for INtersil X1205 RTC chip
+ * [FILE]       rtc.c
+ * [VSN]        1.0
+ * [CREATED]    13042007
+ * [LASTCHNGD]  131042007
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    contains all interface- and low-level routines to
+ *              read/write date/time/status strings from the X1205
+ * ======================================================================== */
+#include <time.h>           // for tm-struct
+                            //
+/*! \name Non-Volatile Alarm Registers */
+/*@{*/
+#define X12RTC_SCA0         0x00    /*!< \brief Alarm 0 second. */
+#define X12RTC_SCA1         0x08    /*!< \brief Alarm 1 second. */
+#define X12RTC_SCA_ESC      0x80    /*!< \brief Second alarm enabled. */
+
+#define X12RTC_MNA0         0x01    /*!< \brief Alarm 0 minute. */
+#define X12RTC_MNA1         0x09    /*!< \brief Alarm 1 minute. */
+#define X12RTC_MNA_EMN      0x80    /*!< \brief Minute alarm enabled. */
+
+#define X12RTC_HRA0         0x02    /*!< \brief Alarm 0 hour. */
+#define X12RTC_HRA1         0x0A    /*!< \brief Alarm 1 hour. */
+#define X12RTC_HRA_EHR      0x80    /*!< \brief Hour alarm enabled. */
+
+#define X12RTC_DTA0         0x03    /*!< \brief Alarm 0 day of month. */
+#define X12RTC_DTA1         0x0B    /*!< \brief Alarm 1 day of month. */
+#define X12RTC_DTA_EDT      0x80    /*!< \brief Day of month alarm enabled. */
+
+#define X12RTC_MOA0         0x04    /*!< \brief Alarm 0 month. */
+#define X12RTC_MOA1         0x0C    /*!< \brief Alarm 1 month. */
+#define X12RTC_MOA_EMO      0x80    /*!< \brief Month alarm enabled. */
+
+#define X12RTC_YRA0         0x05    /*!< \brief Currently unused alarm 0 register. */
+#define X12RTC_YRA1         0x0D    /*!< \brief Currently unused alarm 1 register. */
+
+#define X12RTC_DWA0         0x06    /*!< \brief Alarm 0 weekday. */
+#define X12RTC_DWA1         0x0E    /*!< \brief Alarm 1 weekday. */
+#define X12RTC_DWA_EDW      0x80    /*!< \brief Weekday alarm enabled. */
+
+#define X12RTC_Y2K0         0x07    /*!< \brief Alarm 0 . */
+#define X12RTC_Y2K1         0x0F    /*!< \brief Alarm 1 . */
+/*@}*/
+
+/*! \name Non-Volatile Control Registers */
+/*@{*/
+#define X12RTC_BL           0x10    /*!< \brief Block protection and watchdog register. */
+
+#define X12RTC_BL_WD        0x14    /*!< \brief Watchdog configuration. */
+#define X12RTC_BL_WD_1750   0x00    /*!< \brief Timeout after 1.75 seconds. */
+#define X12RTC_BL_WD_750    0x04    /*!< \brief Timeout after 750 milliseconds. */
+#define X12RTC_BL_WD_250    0x10    /*!< \brief Timeout after 250 milliseconds. */
+#define X12RTC_BL_WD_OFF    0x14    /*!< \brief Disabled. */
+
+#define X12RTC_BL_BP        0xE0    /*!< \brief Block protection. */
+#define X12RTC_BL_BP_NONE   0x00    /*!< \brief No protection. */
+#define X12RTC_BL_BP_UQUAD  0x20    /*!< \brief Upper quarter protected. */
+#define X12RTC_BL_BP_UHALF  0x40    /*!< \brief Upper half protected. */
+#define X12RTC_BL_BP_FULL   0x60    /*!< \brief Full array protected. */
+#define X12RTC_BL_BP_FIRST1 0x80    /*!< \brief First page protected. */
+#define X12RTC_BL_BP_FIRST2 0xA0    /*!< \brief First 2 pages protected. */
+#define X12RTC_BL_BP_FIRST3 0xC0    /*!< \brief First 4 pages protected. */
+#define X12RTC_BL_BP_FIRST8 0xE0    /*!< \brief First 8 pages protected. */
+
+#define X12RTC_INT          0x11    /*!< \brief Interrupt control and freq. output register. */
+
+#define X12RTC_INT_FO       0x14    /*!< \brief Programmable frequency output bits. */
+#define X12RTC_INT_FO_IRQ   0x00    /*!< \brief Alarm interrupt. */
+#define X12RTC_INT_FO_32KHZ 0x04    /*!< \brief 32.768kHz. */
+#define X12RTC_INT_FO_100HZ 0x10    /*!< \brief 100Hz. */
+#define X12RTC_INT_FO_1HZ   0x14    /*!< \brief 1Hz. */
+
+#define X12RTC_INT_AL0E     0x20    /*!< \brief Alarm 0 interrupt enable. */
+#define X12RTC_INT_AL1E     0x40    /*!< \brief Alarm 1 interrupt enable. */
+#define X12RTC_INT_IM       0x80    /*!< \brief Repetitive alarm. */
+
+#define X12RTC_ATR          0x12    /*!< \brief Analog trimming register. */
+
+#define X12RTC_DTR          0x13    /*!< \brief Digital trimming register. */
+#define X12RTC_DTR_NONE     0x00    /*!< \brief 0 PPM. */
+#define X12RTC_DTR_PLUS10   0x02    /*!< \brief +10 PPM. */
+#define X12RTC_DTR_PLUS20   0x01    /*!< \brief +20 PPM. */
+#define X12RTC_DTR_PLUS30   0x03    /*!< \brief +30 PPM. */
+#define X12RTC_DTR_MINUS10  0x06    /*!< \brief -10 PPM. */
+#define X12RTC_DTR_MINUS20  0x05    /*!< \brief -20 PPM. */
+#define X12RTC_DTR_MINUS30  0x07    /*!< \brief -30 PPM. */
+/*@}*/
+
+/*! \name Volatile Date and Time Registers */
+/*@{*/
+#define X12RTC_SC           0x30    /*!< Seconds register, 0 - 59. */
+#define X12RTC_MN           0x31    /*!< Minutes register, 0 - 59. */
+#define X12RTC_HR           0x32    /*!< Hours register, 0 - 23. */
+#define X12RTC_HR_MIL       0x80    /*!< Use 24h format. */
+#define X12RTC_DT           0x33    /*!< Day register, 1 - 31. */
+#define X12RTC_MO           0x34    /*!< Month register, 1 - 12. */
+#define X12RTC_YR           0x35    /*!< Year register, 0 - 99. */
+#define X12RTC_DW           0x36    /*!< Day of the weeks register, 0 - 6. */
+#define X128xRTC_SSEC       0x37    /*!< X1286 1/100 second register, 0 - 99 (read only). */
+#define X122xRTC_Y2K        0x37    /*!< X1226 epoch register, 19 or 20. */
+/*@}*/
+
+/*! \name Volatile Status Register */
+/*@{*/
+#define X12RTC_SR           0x3F    /*!< Status register. */
+#define X12RTC_SR_RTCF      0x01    /*!< Power failure. */
+#define X12RTC_SR_WEL       0x02    /*!< Memory write enable. */
+#define X12RTC_SR_RWEL      0x04    /*!< Register write enable. */
+#define X12RTC_SR_AL0       0x20    /*!< Alarm 0 indicator. */
+#define X12RTC_SR_AL1       0x40    /*!< Alarm 1 indicator. */
+#define X12RTC_SR_BAT       0x80    /*!< Operating from battery. */
+/*@}*/
+
+#define RTC_STATUS_PF       0x00000001
+#define RTC_STATUS_AL0      0x00000020
+#define RTC_STATUS_AL1      0x00000040
+
+#define RTC_ALARM_SECOND    0x00000001
+#define RTC_ALARM_MINUTE    0x00000002
+#define RTC_ALARM_HOUR      0x00000004
+#define RTC_ALARM_MDAY      0x00000008
+#define RTC_ALARM_MONTH     0x00000010
+#define RTC_ALARM_WDAY      0x00000080
+
+/*!
+ * \brief Convert binary coded decimal to binary value.
+ */
+#define BCD2BIN(x) ((((u_char)(x)) >> 4) * 10 + ((x) & 0x0F))
+
+/*!
+ * \brief Convert binary to binary coded decimal value.
+ */
+#define BIN2BCD(x) (((((u_char)(x)) / 10) << 4) + (x) % 10)
+
+
+/* Prototypes */
+extern int X12Init(void);
+
+extern int X12RtcGetClock(tm *tm);
+extern int X12RtcSetClock(CONST tm *tm);
+extern int X12RtcGetAlarm(int idx, tm *tm, int *aflgs);
+extern int X12RtcSetAlarm(int idx, CONST tm *tm, int aflgs);
+extern int X12RtcGetStatus(u_long *sflgs);
+extern int X12RtcClearStatus(u_long sflgs);
+extern int X12RtcReadRegs(u_char addr, u_char *buff, size_t len);
+extern int X12RtcWrite(int nv, CONST u_char *buff, size_t len);
+
+extern int X12EepromRead(u_int addr, void *buff, size_t len);
+extern int X12EepromWrite(u_int addr, CONST void *buff, size_t len);
+
+/* End of prototypes */
+#endif

+ 228 - 228
source/spidrv.c → lib/spidrv.c

@@ -1,228 +1,228 @@
-/* ========================================================================
- * [PROJECT]    SIR100
- * [MODULE]     SPI
- * [TITLE]      SPI source file
- * [FILE]       spi.c
- * [VSN]        1.0
- * [CREATED]    06102006
- * [LASTCHNGD]  06102006
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    contains all interface- and low-level routines to
- *              control audiofunctions of the VS1003//AT45DBXX/MMC-SD(HC)card
- * ======================================================================== */
-
-#define LOG_MODULE  LOG_SPIDRV_MODULE
-
-/*-------------------------------------------------------------------------*/
-/* includes                                                                */
-/*-------------------------------------------------------------------------*/
-#include <stdio.h>
-
-#include "system.h"
-#include "spidrv.h"
-#include "portio.h"
-#include "log.h"
-
-#include "vs10xx.h"
-
-#include <sys/timer.h>
-
-/*-------------------------------------------------------------------------*/
-/* local defines                                                           */
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-/*-------------------------------------------------------------------------*/
-/* local variable definitions                                              */
-/*-------------------------------------------------------------------------*/
-static u_char g_Speedmode;
-
-/*-------------------------------------------------------------------------*/
-/* local routines (prototyping)                                            */
-/*-------------------------------------------------------------------------*/
-
-/*!
- * \addtogroup Drivers
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-/*!
- * \brief enable SPI-logic for given device
- *
- * SPI bits:
- * SPSR:  SPI2X         double speed as set in SPR0, SPR1
- * SPCR:  SPIE:         SPI interrupt enable
- *        SPE:          SPI enable
- *        SPR1, SPR0:   clockrate
- *        MSTR:         set to master
- *
- * SPI2X SPR1 SPR0 for a ATMEGA @  14.7456 MHz
- *
- * 1     0    0:  fosc/2  = 136 ns  -> 7.37 MHz
- * 0     0    0:  fosc/4  = 271 ns  -> 3.6864 MHz
- * 1     0    1:  fosc/8  = 542 ns  -> 1.8432 MHz
- * 0     0    1:  fosc/16 = 1085 ns -> 0.9216 MHz
- *
- */
-
-void SPIselect(TSPIDevice Device)
-{
-
-    // set SPI-speed for selected device
-    if (Device==SPI_DEV_VS10XX)
-    {
-        if (g_Speedmode==SPEED_SLOW)
-        {
-            // set speed to Fosc/8
-            outb(SPSR, BV(SPI2X));
-            outb(SPCR, BV(MSTR) | BV(SPE) | BV(SPR0));
-        }
-        else if (g_Speedmode==SPEED_FAST)
-        {
-            // set speed to Fosc/4
-            outb(SPSR, 0);
-            outb(SPCR, BV(MSTR) | BV(SPE));
-        }
-        else if (g_Speedmode==SPEED_ULTRA_FAST)
-        {
-            // set speed to Fosc/2
-            outb(SPSR, BV(SPI2X));
-            outb(SPCR, BV(MSTR) | BV(SPE));
-        }
-        else
-        {
-            LogMsg_P(LOG_ERR,PSTR("invalid Speed"));
-        }
-    }
-    else if (Device==SPI_DEV_FLASH)
-    {
-        // set speed for flash to Fosc/2
-        outb(SPSR, BV(SPI2X));
-        outb(SPCR, BV(MSTR) | BV(SPE));
-    }
-    else
-    {
-        // set speed for flash to Fosc/2
-//        outb(SPSR, BV(SPI2X));
-//        outb(SPCR, BV(MSTR) | BV(SPE));
-
-        // set speed for card to Fosc/4
-        outb(SPSR, 0);
-        outb(SPCR, BV(MSTR) | BV(SPE));
-
-        // set speed for card to Fosc/8
-//        outb(SPSR, BV(SPI2X));
-//        outb(SPCR, BV(MSTR) | BV(SPE) | BV(SPR0));
-
-        // set speed for card to Fosc/16
-//        outb(SPSR, 0);
-//        outb(SPCR, BV(MSTR) | BV(SPE) | BV(SPR0));
-    }
-
-    // enable selected device
-    switch (Device)
-    {
-        case SPI_DEV_VS10XX:
-            {
-                sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
-                sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
-                sbi(MMCVS_OUT_WRITE, VS_ENABLE);       // enable VS10XX
-                break;
-            }
-        case SPI_DEV_FLASH:
-            {
-                sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
-                cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
-                cbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // enable serial Flash
-                break;
-            }
-        case SPI_DEV_MMC:
-            {
-                sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
-                cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
-                cbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // enable MMC/SDHC
-                break;
-            }
-        default: break;
-    }
-}
-
-/*!
- * \brief disable SPI-logic for ALL devices
- *
- */
-void SPIdeselect()
-{
-    sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
-    cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
-    sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
-}
-
-/*!
- * \brief not all devices can operate always on maximum speed. This routine determines the several speed modes.
- *
- */
-void SPImode(u_char data)
-{
-    g_Speedmode = data;
-}
-
-u_char SPIgetmode(void)
-{
-    return(g_Speedmode);
-}
-/*!
- * \brief send a byte using SPI, ignore result
- *
- */
-void SPIputByte(u_char data)
-{
-    SPDR = data;
-    while (!(SPSR & (1<<SPIF)));     // wait for completion
-}
-
-/*!
- * \brief read byte using SPI, don't use any input
- *
- */
-u_char SPIgetByte()
-{
-    SPDR = 0xFF;                     // dummy
-    while (!(SPSR & (1<<SPIF)));     // wait for completion
-    return(SPDR);                    // return with byte shifted in from receiver
-}
-
-/*!
- * \brief send byte using SPI, return result
- *
- */
-u_char SPItransferByte(u_char data)
-{
-    SPDR = data;
-    while (!(SPSR & (1<<SPIF)));     // wait for completion
-    return(SPDR);                    // return with byte shifted in from receiver
-}
-
-/*!
- * \brief Initialise SPI registers (speed)
- *
- *  Note that the IO-lines (SCK, SI, SO) are already set in 'SysInitIO()'
- *  in the main-module
- *
- */
-void SPIinit()
-{
-    sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
-    cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
-    sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
-}
-
-
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
+/* ========================================================================
+ * [PROJECT]    SIR100
+ * [MODULE]     SPI
+ * [TITLE]      SPI source file
+ * [FILE]       spi.c
+ * [VSN]        1.0
+ * [CREATED]    06102006
+ * [LASTCHNGD]  06102006
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    contains all interface- and low-level routines to
+ *              control audiofunctions of the VS1003//AT45DBXX/MMC-SD(HC)card
+ * ======================================================================== */
+
+#define LOG_MODULE  LOG_SPIDRV_MODULE
+
+/*-------------------------------------------------------------------------*/
+/* includes                                                                */
+/*-------------------------------------------------------------------------*/
+#include <stdio.h>
+
+#include "system.h"
+#include "spidrv.h"
+#include "portio.h"
+#include "log.h"
+
+#include "vs10xx.h"
+
+#include <sys/timer.h>
+
+/*-------------------------------------------------------------------------*/
+/* local defines                                                           */
+/*-------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
+/* local variable definitions                                              */
+/*-------------------------------------------------------------------------*/
+static u_char g_Speedmode;
+
+/*-------------------------------------------------------------------------*/
+/* local routines (prototyping)                                            */
+/*-------------------------------------------------------------------------*/
+
+/*!
+ * \addtogroup Drivers
+ */
+
+/*@{*/
+
+/*-------------------------------------------------------------------------*/
+/*                         start of code                                   */
+/*-------------------------------------------------------------------------*/
+/*!
+ * \brief enable SPI-logic for given device
+ *
+ * SPI bits:
+ * SPSR:  SPI2X         double speed as set in SPR0, SPR1
+ * SPCR:  SPIE:         SPI interrupt enable
+ *        SPE:          SPI enable
+ *        SPR1, SPR0:   clockrate
+ *        MSTR:         set to master
+ *
+ * SPI2X SPR1 SPR0 for a ATMEGA @  14.7456 MHz
+ *
+ * 1     0    0:  fosc/2  = 136 ns  -> 7.37 MHz
+ * 0     0    0:  fosc/4  = 271 ns  -> 3.6864 MHz
+ * 1     0    1:  fosc/8  = 542 ns  -> 1.8432 MHz
+ * 0     0    1:  fosc/16 = 1085 ns -> 0.9216 MHz
+ *
+ */
+
+void SPIselect(TSPIDevice Device)
+{
+
+    // set SPI-speed for selected device
+    if (Device==SPI_DEV_VS10XX)
+    {
+        if (g_Speedmode==SPEED_SLOW)
+        {
+            // set speed to Fosc/8
+            outb(SPSR, BV(SPI2X));
+            outb(SPCR, BV(MSTR) | BV(SPE) | BV(SPR0));
+        }
+        else if (g_Speedmode==SPEED_FAST)
+        {
+            // set speed to Fosc/4
+            outb(SPSR, 0);
+            outb(SPCR, BV(MSTR) | BV(SPE));
+        }
+        else if (g_Speedmode==SPEED_ULTRA_FAST)
+        {
+            // set speed to Fosc/2
+            outb(SPSR, BV(SPI2X));
+            outb(SPCR, BV(MSTR) | BV(SPE));
+        }
+        else
+        {
+            LogMsg_P(LOG_ERR,PSTR("invalid Speed"));
+        }
+    }
+    else if (Device==SPI_DEV_FLASH)
+    {
+        // set speed for flash to Fosc/2
+        outb(SPSR, BV(SPI2X));
+        outb(SPCR, BV(MSTR) | BV(SPE));
+    }
+    else
+    {
+        // set speed for flash to Fosc/2
+//        outb(SPSR, BV(SPI2X));
+//        outb(SPCR, BV(MSTR) | BV(SPE));
+
+        // set speed for card to Fosc/4
+        outb(SPSR, 0);
+        outb(SPCR, BV(MSTR) | BV(SPE));
+
+        // set speed for card to Fosc/8
+//        outb(SPSR, BV(SPI2X));
+//        outb(SPCR, BV(MSTR) | BV(SPE) | BV(SPR0));
+
+        // set speed for card to Fosc/16
+//        outb(SPSR, 0);
+//        outb(SPCR, BV(MSTR) | BV(SPE) | BV(SPR0));
+    }
+
+    // enable selected device
+    switch (Device)
+    {
+        case SPI_DEV_VS10XX:
+            {
+                sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
+                sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
+                sbi(MMCVS_OUT_WRITE, VS_ENABLE);       // enable VS10XX
+                break;
+            }
+        case SPI_DEV_FLASH:
+            {
+                sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
+                cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
+                cbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // enable serial Flash
+                break;
+            }
+        case SPI_DEV_MMC:
+            {
+                sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
+                cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
+                cbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // enable MMC/SDHC
+                break;
+            }
+        default: break;
+    }
+}
+
+/*!
+ * \brief disable SPI-logic for ALL devices
+ *
+ */
+void SPIdeselect()
+{
+    sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
+    cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
+    sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
+}
+
+/*!
+ * \brief not all devices can operate always on maximum speed. This routine determines the several speed modes.
+ *
+ */
+void SPImode(u_char data)
+{
+    g_Speedmode = data;
+}
+
+u_char SPIgetmode(void)
+{
+    return(g_Speedmode);
+}
+/*!
+ * \brief send a byte using SPI, ignore result
+ *
+ */
+void SPIputByte(u_char data)
+{
+    SPDR = data;
+    while (!(SPSR & (1<<SPIF)));     // wait for completion
+}
+
+/*!
+ * \brief read byte using SPI, don't use any input
+ *
+ */
+u_char SPIgetByte()
+{
+    SPDR = 0xFF;                     // dummy
+    while (!(SPSR & (1<<SPIF)));     // wait for completion
+    return(SPDR);                    // return with byte shifted in from receiver
+}
+
+/*!
+ * \brief send byte using SPI, return result
+ *
+ */
+u_char SPItransferByte(u_char data)
+{
+    SPDR = data;
+    while (!(SPSR & (1<<SPIF)));     // wait for completion
+    return(SPDR);                    // return with byte shifted in from receiver
+}
+
+/*!
+ * \brief Initialise SPI registers (speed)
+ *
+ *  Note that the IO-lines (SCK, SI, SO) are already set in 'SysInitIO()'
+ *  in the main-module
+ *
+ */
+void SPIinit()
+{
+    sbi(FLASH_OUT_WRITE, FLASH_ENABLE);    // disable serial Flash
+    cbi(MMCVS_OUT_WRITE, VS_ENABLE);       // disable VS10XX
+    sbi(MMCVS_OUT_WRITE, MMC_ENABLE);      // disable MMC/SDHC
+}
+
+
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+

+ 53 - 53
include/spidrv.h → lib/spidrv.h

@@ -1,53 +1,53 @@
-/* ========================================================================
- * [PROJECT]    SIR100
- * [MODULE]     SPI
- * [TITLE]      spi header file
- * [FILE]       spi.h
- * [VSN]        1.0
- * [CREATED]    12052007
- * [LASTCHNGD]  12052007
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    API and global defines for SPI module
- * ======================================================================== */
-
-#ifndef _SPI_H
-#define _SPI_H
-
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-#define SPEED_SLOW         0
-#define SPEED_FAST         1
-#define SPEED_ULTRA_FAST   2
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-typedef enum
-{
-    SPI_DEV_VS10XX=0,
-    SPI_DEV_FLASH,
-    SPI_DEV_MMC,
-
-    SPI_NROF_DEVICES        // keep last
-}TSPIDevice;
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-extern void SPIselect(TSPIDevice Device);
-extern void SPIdeselect(void);
-extern void SPIputByte(u_char bByte);       // send byte using SPI, ignore result
-extern u_char SPIgetByte(void);             // read byte using SPI, don't use any input
-extern u_char SPItransferByte(u_char);      // send byte using SPI, return result
-extern void SPIinit(void);                  // initialise SPI-registers (speed, mode)
-extern void SPImode(u_char data);
-extern u_char SPIgetmode(void);
-
-#endif /* _SPI_H */
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
+/* ========================================================================
+ * [PROJECT]    SIR100
+ * [MODULE]     SPI
+ * [TITLE]      spi header file
+ * [FILE]       spi.h
+ * [VSN]        1.0
+ * [CREATED]    12052007
+ * [LASTCHNGD]  12052007
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    API and global defines for SPI module
+ * ======================================================================== */
+
+#ifndef _SPI_H
+#define _SPI_H
+
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+#define SPEED_SLOW         0
+#define SPEED_FAST         1
+#define SPEED_ULTRA_FAST   2
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+typedef enum
+{
+    SPI_DEV_VS10XX=0,
+    SPI_DEV_FLASH,
+    SPI_DEV_MMC,
+
+    SPI_NROF_DEVICES        // keep last
+}TSPIDevice;
+/*--------------------------------------------------------------------------*/
+/*  Global variables                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+extern void SPIselect(TSPIDevice Device);
+extern void SPIdeselect(void);
+extern void SPIputByte(u_char bByte);       // send byte using SPI, ignore result
+extern u_char SPIgetByte(void);             // read byte using SPI, don't use any input
+extern u_char SPItransferByte(u_char);      // send byte using SPI, return result
+extern void SPIinit(void);                  // initialise SPI-registers (speed, mode)
+extern void SPImode(u_char data);
+extern u_char SPIgetmode(void);
+
+#endif /* _SPI_H */
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+

+ 144 - 144
include/system.h → lib/system.h

@@ -1,144 +1,144 @@
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     global module
- * [TITLE]      system header file
- * [FILE]       system.h
- * [VSN]        1.0
- * [CREATED]    18 august 2003
- * [LASTCHNGD]  18 august 2003
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    global defines and prototypes for Lucas project
- * ======================================================================== */
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include "typedefs.h"
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-#define ON    (1)
-#define OFF   (0)
-
-#define NO_CHANNEL      200     // make sure this is > SETTINGS_NROF_CHANNELS
-#define NO_PLAYLIST     200     // make sure this is > SETTINGS_NROF_PLAYLISTS
-
-
-/*!\brief System status bit definitions */
-#define STATUS_STARTING_UP              0x01        // true during startup and Setup Wizzard
-#define STATUS_IP_MODE                  0x02        // do we use DHCP or Static IP?
-#define STATUS_POWER                    0x04        // if set, we are on
-#define STATUS_SELFTEST                 0x08        // switch to re-direct keys from Menu to Selftest module
-#define STATUS_CONFIGURED               0x10        // if set, we are configured
-#define STATUS_GPB_INVALID              0x20        // if set, we cannot rely on Productcode, Remote Updatemode, etc
-#define STATUS_FALLBACK_ACTIVE          0x40        // if set, we cannot play from the internet and if a card is present, we play from card
-
-#define STATUS_STARTING_UP_MASK         0x01
-#define STATUS_IP_MODE_MASK             0x02
-#define STATUS_POWER_MASK               0x04
-#define STATUS_SELFTEST_MASK            0x08
-#define STATUS_CONFIGURED_MASK          0x10
-#define STATUS_GPB_INVALID_MASK         0x20
-#define STATUS_FALLBACK_ACTIVE_MASK     0x40
-
-#define ONE_SECOND      225             // 225 times 4,44 msecs makes 1 second
-#define ONE_MINUTE      60
-#define ONE_HOUR        60
-
-
-/*!\brief define possible languages */
-#define LANGUAGE_NL     0
-#define LANGUAGE_EN     1
-#define LANGUAGE_DE     2
-
-/*!\brief define possible IP_Modes */
-#define IP_MODE_DHCP    0
-#define IP_MODE_STATIC  1
-
-/*!\brief define possible countrycodes (mainly used for the modem) */
-#define COUNTRY_US      0
-#define COUNTRY_UK      1
-#define COUNTRY_SA      2
-#define COUNTRY_NL_V92  3
-#define COUNTRY_NL_V34  4
-#define COUNTRY_NROF    5
-
-/*!\brief Maximum size to use for threadnames */
-#define THREADNAME_SIZE 9
-
-enum
-{
-        IRQ_INT0,
-        IRQ_INT1,
-        IRQ_INT2,
-        IRQ_INT3,
-        IRQ_INT4,
-        IRQ_INT5,
-        IRQ_INT6,
-        IRQ_INT7,
-        IRQ_TIMER2_COMP,
-        IRQ_TIMER2_OVF,
-        IRQ_TIMER1_CAPT,
-        IRQ_TIMER1_COMPA,
-        IRQ_TIMER1_COMPB,
-        IRQ_TIMER1_OVF,
-        IRQ_TIMER0_COMP,
-        IRQ_TIMER0_OVF,
-        IRQ_SPI_STC,
-        IRQ_UART_RX,
-        IRQ_UART_UDRE,
-        IRQ_UART_TX,
-        IRQ_ADC,
-        IRQ_EE_RDY,
-        IRQ_ANA_COMP,
-        IRQ_TIMER1_COMPC,
-        IRQ_TIMER3_CAP,
-        IRQ_TIMER3_COMPA,
-        IRQ_TIMER3_COMPB,
-        IRQ_TIMER3_COMPC,
-        IRQ_TIMER3_OVF,
-        IRQ_UART1_RX,
-        IRQ_UART1_UDRE,
-        IRQ_UART1_TX,
-        IRQ_I2C,
-        IRQ_SPM_RDY,
-        IRQ_MAX
-};
-
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-typedef struct
-{
-    u_char KeyLockStatus;               // overall lock, if ACTIVE, keyboard is locked
-    u_char KeyLockEditStatus;           // used when user wants to change the status of the Keylock
-    u_char KeyLockTempStatus;           // after entering a valid PIN, this goes to INACTIVE for 30 secs
-    u_short KeyLockPIN;                 // range = [0]..[5555]
-} TKeyLock;
-
-typedef u_char TIPMode;
-typedef u_char TLanguage;
-
-/*-------------------------------------------------------------------------*/
-/* export global variables                                                 */
-/*-------------------------------------------------------------------------*/
-extern u_char           SystemStatus;
-
-extern TLanguage        SystemLanguage;
-extern TIPMode          SystemIPMode;
-extern TKeyLock         SystemKeyLock;
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-extern void SysInitVars(void);
-extern void SysPowerOn(void);
-extern void SysPowerOff(void);
-extern void SysInitIO(void);
-extern void SystemShowSysInfo(void);
-
-
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-
-
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     global module
+ * [TITLE]      system header file
+ * [FILE]       system.h
+ * [VSN]        1.0
+ * [CREATED]    18 august 2003
+ * [LASTCHNGD]  18 august 2003
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    global defines and prototypes for Lucas project
+ * ======================================================================== */
+
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+#include "typedefs.h"
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+#define ON    (1)
+#define OFF   (0)
+
+#define NO_CHANNEL      200     // make sure this is > SETTINGS_NROF_CHANNELS
+#define NO_PLAYLIST     200     // make sure this is > SETTINGS_NROF_PLAYLISTS
+
+
+/*!\brief System status bit definitions */
+#define STATUS_STARTING_UP              0x01        // true during startup and Setup Wizzard
+#define STATUS_IP_MODE                  0x02        // do we use DHCP or Static IP?
+#define STATUS_POWER                    0x04        // if set, we are on
+#define STATUS_SELFTEST                 0x08        // switch to re-direct keys from Menu to Selftest module
+#define STATUS_CONFIGURED               0x10        // if set, we are configured
+#define STATUS_GPB_INVALID              0x20        // if set, we cannot rely on Productcode, Remote Updatemode, etc
+#define STATUS_FALLBACK_ACTIVE          0x40        // if set, we cannot play from the internet and if a card is present, we play from card
+
+#define STATUS_STARTING_UP_MASK         0x01
+#define STATUS_IP_MODE_MASK             0x02
+#define STATUS_POWER_MASK               0x04
+#define STATUS_SELFTEST_MASK            0x08
+#define STATUS_CONFIGURED_MASK          0x10
+#define STATUS_GPB_INVALID_MASK         0x20
+#define STATUS_FALLBACK_ACTIVE_MASK     0x40
+
+#define ONE_SECOND      225             // 225 times 4,44 msecs makes 1 second
+#define ONE_MINUTE      60
+#define ONE_HOUR        60
+
+
+/*!\brief define possible languages */
+#define LANGUAGE_NL     0
+#define LANGUAGE_EN     1
+#define LANGUAGE_DE     2
+
+/*!\brief define possible IP_Modes */
+#define IP_MODE_DHCP    0
+#define IP_MODE_STATIC  1
+
+/*!\brief define possible countrycodes (mainly used for the modem) */
+#define COUNTRY_US      0
+#define COUNTRY_UK      1
+#define COUNTRY_SA      2
+#define COUNTRY_NL_V92  3
+#define COUNTRY_NL_V34  4
+#define COUNTRY_NROF    5
+
+/*!\brief Maximum size to use for threadnames */
+#define THREADNAME_SIZE 9
+
+enum
+{
+        IRQ_INT0,
+        IRQ_INT1,
+        IRQ_INT2,
+        IRQ_INT3,
+        IRQ_INT4,
+        IRQ_INT5,
+        IRQ_INT6,
+        IRQ_INT7,
+        IRQ_TIMER2_COMP,
+        IRQ_TIMER2_OVF,
+        IRQ_TIMER1_CAPT,
+        IRQ_TIMER1_COMPA,
+        IRQ_TIMER1_COMPB,
+        IRQ_TIMER1_OVF,
+        IRQ_TIMER0_COMP,
+        IRQ_TIMER0_OVF,
+        IRQ_SPI_STC,
+        IRQ_UART_RX,
+        IRQ_UART_UDRE,
+        IRQ_UART_TX,
+        IRQ_ADC,
+        IRQ_EE_RDY,
+        IRQ_ANA_COMP,
+        IRQ_TIMER1_COMPC,
+        IRQ_TIMER3_CAP,
+        IRQ_TIMER3_COMPA,
+        IRQ_TIMER3_COMPB,
+        IRQ_TIMER3_COMPC,
+        IRQ_TIMER3_OVF,
+        IRQ_UART1_RX,
+        IRQ_UART1_UDRE,
+        IRQ_UART1_TX,
+        IRQ_I2C,
+        IRQ_SPM_RDY,
+        IRQ_MAX
+};
+
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+typedef struct
+{
+    u_char KeyLockStatus;               // overall lock, if ACTIVE, keyboard is locked
+    u_char KeyLockEditStatus;           // used when user wants to change the status of the Keylock
+    u_char KeyLockTempStatus;           // after entering a valid PIN, this goes to INACTIVE for 30 secs
+    u_short KeyLockPIN;                 // range = [0]..[5555]
+} TKeyLock;
+
+typedef u_char TIPMode;
+typedef u_char TLanguage;
+
+/*-------------------------------------------------------------------------*/
+/* export global variables                                                 */
+/*-------------------------------------------------------------------------*/
+extern u_char           SystemStatus;
+
+extern TLanguage        SystemLanguage;
+extern TIPMode          SystemIPMode;
+extern TKeyLock         SystemKeyLock;
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+extern void SysInitVars(void);
+extern void SysPowerOn(void);
+extern void SysPowerOff(void);
+extern void SysInitIO(void);
+extern void SystemShowSysInfo(void);
+
+
+/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+
+

+ 183 - 183
include/typedefs.h → lib/typedefs.h

@@ -1,183 +1,183 @@
-#ifndef _Typedefs_H
-#define _Typedefs_H
-/* ========================================================================
- * [PROJECT]    SIR
- * [MODULE]     global module
- * [TITLE]      system header file
- * [FILE]       typedefs.h
- * [VSN]        1.0
- * [CREATED]    09 november 2003
- * [LASTCHNGD]  09 november 2003
- * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
- * [PURPOSE]    global typedefs
- * ======================================================================== */
-
-
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <fs/typedefs.h>
-
-/*--------------------------------------------------------------------------*/
-/*  Constant definitions                                                    */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Type declarations                                                       */
-/*--------------------------------------------------------------------------*/
-/* RL: this 'table' has now a mirror table in 'Display.c' (LcdErrorStrings) */
-/*     Make sure that any modification made to this table are reflected by  */
-/*     the LcdErrorStirngs table! (an error is bad but showing the wrong    */
-/*     error is too much....) */
-typedef enum _TERRORCODE
-{
-    OK = 0,                             /* All ok */
-
-    /*
-     * Status messages
-     */
-    CHANNEL_CONNECTING,                 /* Channel connecting */
-    CHANNEL_RETRIEVING,                 /* Retrieving channels */
-    STREAMER_CONNECTING,                /* Connecting to stream */
-    STREAMER_BUFFERING,                 /* Buffering audio */
-    STREAMER_PLAYING,                   /* Playing audio from a stream */
-    STREAMER_FALLBACK,                  /* trying card now, inet failed*/
-    UPDATE_CONNECTING,                  /* connecting to update server */
-    CARD_BUFFERING,                     /* Buffering audio */
-    CARD_PLAYING,                       /* Playing audio from a card */
-
-    USER_ABORT,                         /* User abort */
-
-    /*
-     * Warnings. In other words, problems that are
-     * probably recoverable by a retry
-     */
-    PLAYER_WARNINGS = 200,
-    CHANNEL_HOSTNOTFOUND,               /* Could not resolve hostname */
-    CHANNEL_NEW_ISP,                    /* New ISP settings received */
-    CHANNEL_NEW_DB,                     /* New DB URL info received */
-    CHANNEL_NEW_CHANNEL,                /* New channel info received */
-    CHANNEL_NOCONNECT,                  /* Could not connect (will retry) */
-
-    CHANNEL_TOO_MANY_NOCONNECTS,        /* Could not connect */
-    CHANNEL_REDIRECT,                   /* Redirect (will retry) */
-    CHANNEL_TOO_MANY_REDIRECTS,         /* Too many redirects */
-    CHANNEL_BADRESPONSE,                /* Bad server response (will retry) */
-    CHANNEL_TOO_MANY_BADRESPONSES,      /* Bad server response */
-
-    STREAM_HOSTNOTFOUND,                /* Could not resolve hostname */
-    STREAM_NOCONNECT,                   /* Could not connect (will retry) */
-    STREAM_REDIRECT,                    /* Redirect (will retry) */
-    STREAM_BADRESPONSE,                 /* Bad server response (will retry) */
-
-    INET_HOSTNOTFOUND,                  /* Could not resolve hostname (will retry) */
-    INET_NOCONNECT,                     /* Could not connect (will retry) */
-    INET_BADRESPONSE,                   /* Bad server response (will retry) */
-    INET_REDIRECT,                      /* Redirect (will retry) */
-    INET_ACCESS_RESTRICTED,             /* Access needs login info (will retry) */
-
-    STREAM_TIMEOUT,                     /* Network timeout */
-    STREAM_BADAUDIO,                    /* Audio data seems invalid */
-    STREAM_DISCONNECTED,                /* Server closed the connection */
-    STREAM_BUFFEREMPTY,                 /* Audio buffer ran out of data */
-    STREAM_BADCHANNEL,                  /* Bad channel number */
-
-    UPDATE_NEEDED,                      /* Firmware update is needed */
-
-    PLAYER_WAITPLAY,                    /* Player has nothing to do */
-    PLAYER_STARTING,
-
-    CARD_BUFFEREMPTY,                   /* Audio buffer ran out of data */
-    CARD_BADPLAYLIST,                   /* non-existing or invalid playlist requested */
-    CARD_BADAUDIO,                      /* Audio data seems invalid */
-
-    /*
-     * Errors.
-     * User interaction (e.g. select a different channel) can solve these
-     */
-    PLAYER_ERRORS = 400,
-    BADCHANNEL,                         /* Bad channel number                   - no longer used */
-    STREAM_TOO_MANY_NOCONNECTS,         /* Too many no connects */
-    STREAM_TOO_MANY_BADRESPONSES,       /* Too many bad server responses */
-    STREAM_TOO_MANY_REDIRECTS,          /* Too many redirects */
-    UPDATE_FAILED,                      /* not specified, just failed */
-
-    CHANNEL_NODATA,                     /* Didn't receive any data */
-
-    STREAM_BAD_FILETYPE,                /* Bad type of file */
-    STREAM_BAD_NETWORK,                 /* Too many network failures            - no longer used */
-    STREAM_DISCONNECTED_UNUSED,         /* Server closed the connection         - no longer used */
-    STREAM_BUFFEREMPTY_UNUSED,          /* Audio buffer ran out of data         - no longer used */
-
-    INET_HOST_NONEXISTANT,              /* Hostname unknown */
-    INET_TOO_MANY_NOCONNECTS,           /* Too many no connects */
-    INET_TOO_MANY_REDIRECTS,            /* Too many redirects */
-    INET_TOO_MANY_BADRESPONSES,         /* Too many bad server responses */
-    INET_ACCESS_DENIED,                 /* Access to the server was denied */
-
-    CARD_NO_SONG,                       /* no (more) songs found on this card */
-    CARD_PLAYLIST_IN_USE,               /* trying to open a playlist that was open already */
-    CARD_CREATE_STREAM,                 /* Failed to create a stream */
-    CARD_NO_CARD,                       /* card not present to perfom desired action */
-    CARD_NO_HEAP,                       /* unable to allocate RAM */
-    CARD_NOT_REGISTERED,                /* card present but not know in the system */
-    CARD_WRONG_HASH,                    /* hash results in a non-valid flash-address */
-    /*
-     * System Errors.
-     * These include programming errors but also:
-     * errors that may (or may not..) be solved by a reboot (indicated by REBOOT)
-     */
-    PLAYER_SYSTEMERRORS = 500,
-    PLAYER_NOTREADY,                    /* Player was not successfully initialised */
-    SESSION_NODEVICE,                   /* Could not register devices */
-    SESSION_NODHCP_NOEEPROM,            /* No DHCP and no previous IP address. REBOOT */
-    SESSION_MDMNOINIT,                  /* Could not initialise modem. REBOOT */
-    SESSION_MDMNODISCONNECT,            /* Modem is still connected. REBOOT */
-
-    SESSION_PPPINIT,                    /* Could not initialise PPP */
-    SESSION_PPPSTART,                   /* Could not start PPP (username/password incorrect?)
-                                           Note that NutOs ALWAYS requires a REBOOT in this case! */
-    SESSION_NOROUTEADD,                 /* Could not add route to routetable */
-    CHANNEL_NOMEM,                      /* Not enough memory for channel */
-    CHANNEL_CREATE_SOCKET,              /* Failed to create a socket */
-
-    CHANNEL_SOCK_RCVTO,                 /* Could not set socket option RCVTO */
-    CHANNEL_CREATE_STREAM,              /* Failed to create a stream */
-    STREAM_NOTHREAD,                    /* Could not start streamer thread */
-    STREAM_NOMEM,                       /* Not enough memory for streamer */
-    STREAM_CREATE_SOCKET,               /* Failed to create a socket */
-
-    STREAM_CREATE_STREAM,               /* Failed to create a stream */
-    STREAM_SOCK_MSS,                    /* Could not set socket option MSS */
-    STREAM_SOCK_RCVTO,                  /* Could not set socket option RCVTO */
-    STREAM_SOCK_RXBUF,                  /* Could not set socket option RXBUF */
-
-    UPDATE_WRONG_NROF_BYTES,            /* nrof bytes not as specified in 'update.inf' */
-    UPDATE_CODESIZE_OVERFLOW,           /* codesize exceeds 126KB (note: 2KB needed for bootloader) */
-    UPDATE_CRC_ERROR,                   /* CRC of downloaded code in RAM incorrect */
-    UPDATE_NOT_ALLOWED,                 /* either ISP or bootloader prohibits Remote Update functionality */
-
-    INET_NOMEM,                         /* Not enough memory */
-    INET_CREATE_SOCKET,                 /* Failed to create a socket */
-    INET_SOCK_MSS,                      /* Could not set socket option MSS */
-    INET_SOCK_RCVTO,                    /* Could not set socket option RCVTO */
-    INET_SOCK_RXBUF,                    /* Could not set socket option RXBUF */
-    INET_CREATE_STREAM,                 /* Failed to create a stream */
-    INET_SEND_FAIL,                     /* Failed to send data */
-
-    STREAM_TOO_MANY_ERRORS,             /* Seen too many errors */
-
-    PLAYER_NO_THREAD,                   /* Could not start player thread */
-    PLAYER_NO_SOURCE,                   /* No source to play audio from */
-} TError;
-
-
-/*--------------------------------------------------------------------------*/
-/*  Global variables                                                        */
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-/*  Global functions                                                        */
-/*--------------------------------------------------------------------------*/
-
-#endif /* _Typedefs_H */
+#ifndef _Typedefs_H
+#define _Typedefs_H
+/* ========================================================================
+ * [PROJECT]    SIR
+ * [MODULE]     global module
+ * [TITLE]      system header file
+ * [FILE]       typedefs.h
+ * [VSN]        1.0
+ * [CREATED]    09 november 2003
+ * [LASTCHNGD]  09 november 2003
+ * [COPYRIGHT]  Copyright (C) STREAMIT BV 2010
+ * [PURPOSE]    global typedefs
+ * ======================================================================== */
+
+
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+#include <fs/typedefs.h>
+
+/*--------------------------------------------------------------------------*/
+/*  Constant definitions                                                    */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Type declarations                                                       */
+/*--------------------------------------------------------------------------*/
+/* RL: this 'table' has now a mirror table in 'Display.c' (LcdErrorStrings) */
+/*     Make sure that any modification made to this table are reflected by  */
+/*     the LcdErrorStirngs table! (an error is bad but showing the wrong    */
+/*     error is too much....) */
+typedef enum _TERRORCODE
+{
+    OK = 0,                             /* All ok */
+
+    /*
+     * Status messages
+     */
+    CHANNEL_CONNECTING,                 /* Channel connecting */
+    CHANNEL_RETRIEVING,                 /* Retrieving channels */
+    STREAMER_CONNECTING,                /* Connecting to stream */
+    STREAMER_BUFFERING,                 /* Buffering audio */
+    STREAMER_PLAYING,                   /* Playing audio from a stream */
+    STREAMER_FALLBACK,                  /* trying card now, inet failed*/
+    UPDATE_CONNECTING,                  /* connecting to update server */
+    CARD_BUFFERING,                     /* Buffering audio */
+    CARD_PLAYING,                       /* Playing audio from a card */
+
+    USER_ABORT,                         /* User abort */
+
+    /*
+     * Warnings. In other words, problems that are
+     * probably recoverable by a retry
+     */
+    PLAYER_WARNINGS = 200,
+    CHANNEL_HOSTNOTFOUND,               /* Could not resolve hostname */
+    CHANNEL_NEW_ISP,                    /* New ISP settings received */
+    CHANNEL_NEW_DB,                     /* New DB URL info received */
+    CHANNEL_NEW_CHANNEL,                /* New channel info received */
+    CHANNEL_NOCONNECT,                  /* Could not connect (will retry) */
+
+    CHANNEL_TOO_MANY_NOCONNECTS,        /* Could not connect */
+    CHANNEL_REDIRECT,                   /* Redirect (will retry) */
+    CHANNEL_TOO_MANY_REDIRECTS,         /* Too many redirects */
+    CHANNEL_BADRESPONSE,                /* Bad server response (will retry) */
+    CHANNEL_TOO_MANY_BADRESPONSES,      /* Bad server response */
+
+    STREAM_HOSTNOTFOUND,                /* Could not resolve hostname */
+    STREAM_NOCONNECT,                   /* Could not connect (will retry) */
+    STREAM_REDIRECT,                    /* Redirect (will retry) */
+    STREAM_BADRESPONSE,                 /* Bad server response (will retry) */
+
+    INET_HOSTNOTFOUND,                  /* Could not resolve hostname (will retry) */
+    INET_NOCONNECT,                     /* Could not connect (will retry) */
+    INET_BADRESPONSE,                   /* Bad server response (will retry) */
+    INET_REDIRECT,                      /* Redirect (will retry) */
+    INET_ACCESS_RESTRICTED,             /* Access needs login info (will retry) */
+
+    STREAM_TIMEOUT,                     /* Network timeout */
+    STREAM_BADAUDIO,                    /* Audio data seems invalid */
+    STREAM_DISCONNECTED,                /* Server closed the connection */
+    STREAM_BUFFEREMPTY,                 /* Audio buffer ran out of data */
+    STREAM_BADCHANNEL,                  /* Bad channel number */
+
+    UPDATE_NEEDED,                      /* Firmware update is needed */
+
+    PLAYER_WAITPLAY,                    /* Player has nothing to do */
+    PLAYER_STARTING,
+
+    CARD_BUFFEREMPTY,                   /* Audio buffer ran out of data */
+    CARD_BADPLAYLIST,                   /* non-existing or invalid playlist requested */
+    CARD_BADAUDIO,                      /* Audio data seems invalid */
+
+    /*
+     * Errors.
+     * User interaction (e.g. select a different channel) can solve these
+     */
+    PLAYER_ERRORS = 400,
+    BADCHANNEL,                         /* Bad channel number                   - no longer used */
+    STREAM_TOO_MANY_NOCONNECTS,         /* Too many no connects */
+    STREAM_TOO_MANY_BADRESPONSES,       /* Too many bad server responses */
+    STREAM_TOO_MANY_REDIRECTS,          /* Too many redirects */
+    UPDATE_FAILED,                      /* not specified, just failed */
+
+    CHANNEL_NODATA,                     /* Didn't receive any data */
+
+    STREAM_BAD_FILETYPE,                /* Bad type of file */
+    STREAM_BAD_NETWORK,                 /* Too many network failures            - no longer used */
+    STREAM_DISCONNECTED_UNUSED,         /* Server closed the connection         - no longer used */
+    STREAM_BUFFEREMPTY_UNUSED,          /* Audio buffer ran out of data         - no longer used */
+
+    INET_HOST_NONEXISTANT,              /* Hostname unknown */
+    INET_TOO_MANY_NOCONNECTS,           /* Too many no connects */
+    INET_TOO_MANY_REDIRECTS,            /* Too many redirects */
+    INET_TOO_MANY_BADRESPONSES,         /* Too many bad server responses */
+    INET_ACCESS_DENIED,                 /* Access to the server was denied */
+
+    CARD_NO_SONG,                       /* no (more) songs found on this card */
+    CARD_PLAYLIST_IN_USE,               /* trying to open a playlist that was open already */
+    CARD_CREATE_STREAM,                 /* Failed to create a stream */
+    CARD_NO_CARD,                       /* card not present to perfom desired action */
+    CARD_NO_HEAP,                       /* unable to allocate RAM */
+    CARD_NOT_REGISTERED,                /* card present but not know in the system */
+    CARD_WRONG_HASH,                    /* hash results in a non-valid flash-address */
+    /*
+     * System Errors.
+     * These include programming errors but also:
+     * errors that may (or may not..) be solved by a reboot (indicated by REBOOT)
+     */
+    PLAYER_SYSTEMERRORS = 500,
+    PLAYER_NOTREADY,                    /* Player was not successfully initialised */
+    SESSION_NODEVICE,                   /* Could not register devices */
+    SESSION_NODHCP_NOEEPROM,            /* No DHCP and no previous IP address. REBOOT */
+    SESSION_MDMNOINIT,                  /* Could not initialise modem. REBOOT */
+    SESSION_MDMNODISCONNECT,            /* Modem is still connected. REBOOT */
+
+    SESSION_PPPINIT,                    /* Could not initialise PPP */
+    SESSION_PPPSTART,                   /* Could not start PPP (username/password incorrect?)
+                                           Note that NutOs ALWAYS requires a REBOOT in this case! */
+    SESSION_NOROUTEADD,                 /* Could not add route to routetable */
+    CHANNEL_NOMEM,                      /* Not enough memory for channel */
+    CHANNEL_CREATE_SOCKET,              /* Failed to create a socket */
+
+    CHANNEL_SOCK_RCVTO,                 /* Could not set socket option RCVTO */
+    CHANNEL_CREATE_STREAM,              /* Failed to create a stream */
+    STREAM_NOTHREAD,                    /* Could not start streamer thread */
+    STREAM_NOMEM,                       /* Not enough memory for streamer */
+    STREAM_CREATE_SOCKET,               /* Failed to create a socket */
+
+    STREAM_CREATE_STREAM,               /* Failed to create a stream */
+    STREAM_SOCK_MSS,                    /* Could not set socket option MSS */
+    STREAM_SOCK_RCVTO,                  /* Could not set socket option RCVTO */
+    STREAM_SOCK_RXBUF,                  /* Could not set socket option RXBUF */
+
+    UPDATE_WRONG_NROF_BYTES,            /* nrof bytes not as specified in 'update.inf' */
+    UPDATE_CODESIZE_OVERFLOW,           /* codesize exceeds 126KB (note: 2KB needed for bootloader) */
+    UPDATE_CRC_ERROR,                   /* CRC of downloaded code in RAM incorrect */
+    UPDATE_NOT_ALLOWED,                 /* either ISP or bootloader prohibits Remote Update functionality */
+
+    INET_NOMEM,                         /* Not enough memory */
+    INET_CREATE_SOCKET,                 /* Failed to create a socket */
+    INET_SOCK_MSS,                      /* Could not set socket option MSS */
+    INET_SOCK_RCVTO,                    /* Could not set socket option RCVTO */
+    INET_SOCK_RXBUF,                    /* Could not set socket option RXBUF */
+    INET_CREATE_STREAM,                 /* Failed to create a stream */
+    INET_SEND_FAIL,                     /* Failed to send data */
+
+    STREAM_TOO_MANY_ERRORS,             /* Seen too many errors */
+
+    PLAYER_NO_THREAD,                   /* Could not start player thread */
+    PLAYER_NO_SOURCE,                   /* No source to play audio from */
+} TError;
+
+
+/*--------------------------------------------------------------------------*/
+/*  Global variables                                                        */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/*  Global functions                                                        */
+/*--------------------------------------------------------------------------*/
+
+#endif /* _Typedefs_H */

+ 151 - 151
source/uart0driver.c → lib/uart0driver.c

@@ -1,151 +1,151 @@
-/*!
- * Copyright (C) 2003 by Streamit 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. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgement:
- *
-  *    This product includes software developed by Streamit
- *    and its contributors.
- *
- * THIS SOFTWARE IS PROVIDED BY STREAMIT 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 CALL DIRECT
- * CELLULAR SOLUTIONS 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.
- *
- * For additional information see http://www.streamit.nl/
- */
-
-/*!
- *
- * COPYRIGHT STREAMIT BV 2010
- * Tested except for the DTR code. This will be done when the final hardware is available
- *
- *
- * [Note] this UART0 is used for serial communication with LTP (or a PC in general).
- */
-
-
-#define LOG_MODULE  LOG_UART0DRIVER_MODULE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <io.h>
-
-#include <dev/uartavr.h>
-//#include <sys/heap.h>
-#include <sys/thread.h>
-#include <sys/timer.h>
-
-//#pragma text:appcode
-
-#include "system.h"
-#include "uart0driver.h"
-
-
-//----------------------------------------------------------
-
-static FILE *stream=NULL;
-
-//----------------------------------------------------------
-
-/*!
- * \brief Handle input.
- */
-// THREAD(Uart0KeyEvents, arg)
-// {
-    // NutThreadSetPriority(254);  // low prio
-    // for (;;)
-    // {
-        // if (stream==NULL)
-        // {
-            // NutSleep(2000);           //Mhe
-            // continue;
-        // }
-
-       // CommandHandler(stream);
-    // }
-// }
-
-//----------------------------------------------------------
-
-/*!
- * \brief return stream that is connected to terminal program (serial or TCP/IP)
- */
-FILE *Uart0DriverGetStream(void)
-{
-    return(stream);
-}
-
-/*!
- * \brief Uart0 process initialisation. Uses stdout in combination with Uart0.
- */
-void Uart0DriverInit(void)
-{
-    stream = NULL;
-
-    // register Uart0
-    NutRegisterDevice(&devUart0, 0, 0);
-}
-
-/*!
- * \brief Creates a thread to handle incoming data from User.
- */
-void Uart0DriverStart(void)
-{
-    u_long baud = 115200;
-    char DeviceNameBuffer[6];
-    char FileModeBuffer[3];
-
-    strcpy_P(DeviceNameBuffer, PSTR("uart0"));
-    strcpy_P(FileModeBuffer, PSTR("w"));
-
-    /* Open the stream, connect to stdout */
-    if ((stream=freopen(DeviceNameBuffer, FileModeBuffer, stdout)) != NULL)
-    {
-        _ioctl(_fileno(stream), UART_SETSPEED, &baud);
-    }
-
-    // if (stream != NULL)
-    // {
-        // if (GetThreadByName(DeviceNameBuffer) == NULL)
-        // {
-            // NutThreadCreate(DeviceNameBuffer, Uart0KeyEvents, 0, 512);
-        // }
-    // }
-}
-
-void Uart0DriverSetCookedMode(u_long CookedMode)
-{
-    _ioctl(_fileno(stream), UART_SETCOOKEDMODE, &CookedMode);
-}
-
-/*!
- * \brief Close the stream.
- */
-void Uart0DriverStop(void)
-{
-    if (stream)
-    {
-        // needed? (void)_close(_fileno(stream));
-        (void)fclose(stream);
-        stream = NULL;
-    }
-}
+/*!
+ * Copyright (C) 2003 by Streamit 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *
+  *    This product includes software developed by Streamit
+ *    and its contributors.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STREAMIT 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 CALL DIRECT
+ * CELLULAR SOLUTIONS 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.
+ *
+ * For additional information see http://www.streamit.nl/
+ */
+
+/*!
+ *
+ * COPYRIGHT STREAMIT BV 2010
+ * Tested except for the DTR code. This will be done when the final hardware is available
+ *
+ *
+ * [Note] this UART0 is used for serial communication with LTP (or a PC in general).
+ */
+
+
+#define LOG_MODULE  LOG_UART0DRIVER_MODULE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <io.h>
+
+#include <dev/uartavr.h>
+//#include <sys/heap.h>
+#include <sys/thread.h>
+#include <sys/timer.h>
+
+//#pragma text:appcode
+
+#include "system.h"
+#include "uart0driver.h"
+
+
+//----------------------------------------------------------
+
+static FILE *stream=NULL;
+
+//----------------------------------------------------------
+
+/*!
+ * \brief Handle input.
+ */
+// THREAD(Uart0KeyEvents, arg)
+// {
+    // NutThreadSetPriority(254);  // low prio
+    // for (;;)
+    // {
+        // if (stream==NULL)
+        // {
+            // NutSleep(2000);           //Mhe
+            // continue;
+        // }
+
+       // CommandHandler(stream);
+    // }
+// }
+
+//----------------------------------------------------------
+
+/*!
+ * \brief return stream that is connected to terminal program (serial or TCP/IP)
+ */
+FILE *Uart0DriverGetStream(void)
+{
+    return(stream);
+}
+
+/*!
+ * \brief Uart0 process initialisation. Uses stdout in combination with Uart0.
+ */
+void Uart0DriverInit(void)
+{
+    stream = NULL;
+
+    // register Uart0
+    NutRegisterDevice(&devUart0, 0, 0);
+}
+
+/*!
+ * \brief Creates a thread to handle incoming data from User.
+ */
+void Uart0DriverStart(void)
+{
+    u_long baud = 115200;
+    char DeviceNameBuffer[6];
+    char FileModeBuffer[3];
+
+    strcpy_P(DeviceNameBuffer, PSTR("uart0"));
+    strcpy_P(FileModeBuffer, PSTR("w"));
+
+    /* Open the stream, connect to stdout */
+    if ((stream=freopen(DeviceNameBuffer, FileModeBuffer, stdout)) != NULL)
+    {
+        _ioctl(_fileno(stream), UART_SETSPEED, &baud);
+    }
+
+    // if (stream != NULL)
+    // {
+        // if (GetThreadByName(DeviceNameBuffer) == NULL)
+        // {
+            // NutThreadCreate(DeviceNameBuffer, Uart0KeyEvents, 0, 512);
+        // }
+    // }
+}
+
+void Uart0DriverSetCookedMode(u_long CookedMode)
+{
+    _ioctl(_fileno(stream), UART_SETCOOKEDMODE, &CookedMode);
+}
+
+/*!
+ * \brief Close the stream.
+ */
+void Uart0DriverStop(void)
+{
+    if (stream)
+    {
+        // needed? (void)_close(_fileno(stream));
+        (void)fclose(stream);
+        stream = NULL;
+    }
+}

+ 60 - 60
include/uart0driver.h → lib/uart0driver.h

@@ -1,60 +1,60 @@
-#ifndef _UART0DRIVER_H_
-#define _UART0DRIVER_H_
-/*!
- * Copyright (C) 2003 by Streamit 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. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgement:
- *
-  *    This product includes software developed by Streamit
- *    and its contributors.
- *
- * THIS SOFTWARE IS PROVIDED BY STREAMIT 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 CALL DIRECT
- * CELLULAR SOLUTIONS 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.
- *
- * For additional information see http://www.streamit.eu/
- */
-/*!
- *
- * COPYRIGHT STREAMIT BV 2010
- * Created
- *
- *
- */
-/*--------------------------------------------------------------------------*/
-/*  Include files                                                           */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
-
-#define UART_COOKEDMODE_RAW    0L
-#define UART_COOKEDMODE_EOL    1L
-
-extern void  Uart0DriverInit(void);
-extern void  Uart0DriverStart(void);
-extern void  Uart0DriverStop(void);
-extern FILE *Uart0DriverGetStream(void);
-extern int   Uart0DriverGetNumber(PGM_P prompt, int dflt);
-extern int   Uart0DriverKey(void);
-extern void  Uart0DriverSetCookedMode(u_long Mode);
-
-
-#endif
+#ifndef _UART0DRIVER_H_
+#define _UART0DRIVER_H_
+/*!
+ * Copyright (C) 2003 by Streamit 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. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *
+  *    This product includes software developed by Streamit
+ *    and its contributors.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STREAMIT 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 CALL DIRECT
+ * CELLULAR SOLUTIONS 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.
+ *
+ * For additional information see http://www.streamit.eu/
+ */
+/*!
+ *
+ * COPYRIGHT STREAMIT BV 2010
+ * Created
+ *
+ *
+ */
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+#include <stdio.h>
+
+#define UART_COOKEDMODE_RAW    0L
+#define UART_COOKEDMODE_EOL    1L
+
+extern void  Uart0DriverInit(void);
+extern void  Uart0DriverStart(void);
+extern void  Uart0DriverStop(void);
+extern FILE *Uart0DriverGetStream(void);
+extern int   Uart0DriverGetNumber(PGM_P prompt, int dflt);
+extern int   Uart0DriverKey(void);
+extern void  Uart0DriverSetCookedMode(u_long Mode);
+
+
+#endif

+ 164 - 164
include/vs10xx.h → lib/vs10xx.h

@@ -1,164 +1,164 @@
-/*
- * Copyright (C) 2001-2003 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
- * SOFTWARE GMBH 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.
- *
- * For additional information see http://www.ethernut.de/
- *
- * -
- * Portions Copyright (C) 2001 Jesper Hansen <jesperh@telia.com>.
- *
- * This file is part of the yampp system.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-/*
- *
- * Revision 2.0  2004/09/30 19:37:39  johan van der stoel
- * Fully rewritten to support VS1011 / VS1003. For VS1001: use driver from
- * Ethernut distribution
- *
- * Revision 1.2  2003/07/13 19:37:39  haraldkipp
- * Enable application to control decoder interrupts.
- *
- *
- */
-
-#include <sys/nutconfig.h>
-#include <sys/types.h>
-
-/*-------------------------------------------------------------------------*/
-/* global defines                                                          */
-/*-------------------------------------------------------------------------*/
-
-// Instruction opcodes
-#define VS_OPCODE_READ      3
-#define VS_OPCODE_WRITE     2
-
-// Decoder registers VS1011/VS1003
-#define VS_MODE_REG         0
-#define VS_STATUS_REG       1
-#define VS_BASS_REG         2
-#define VS_CLOCKF_REG       3
-#define VS_DECODE_TIME_REG  4
-#define VS_AUDATA_REG       5
-#define VS_WRAM_REG         6
-#define VS_WRAMADDR_REG     7
-#define VS_HDAT0_REG        8
-#define VS_HDAT1_REG        9
-#define VS_AIADDR_REG      10
-#define VS_VOL_REG         11
-#define VS_AICTRL0_REG     12
-#define VS_AICTRL1_REG     13
-#define VS_AICTRL2_REG     14
-#define VS_AICTRL3_REG     15
-
-#define NROF_VS_REGS       (VS_AICTRL3_REG+1)
-
-// SCI Mode register bits VS1011/VS1003
-#define VS_SM_DIFF          0x0001
-#define VS_SM_JUMP          0x0002 /* VS1011 */
-#define VS_SM_SETTOZERO     0x0002 /* VS1003 */
-#define VS_SM_RESET         0x0004
-#define VS_SM_OUTOFWAV      0x0008
-#define VS_SM_PDOWN         0x0010
-#define VS_SM_TESTS         0x0020
-#define VS_SM_STREAM        0x0040
-#define VS_SM_SETTOZERO1    0x0080 /* VS1011 */
-#define VS_SM_PLUSV         0x0080 /* VS1003 */
-#define VS_SM_DACT          0x0100
-#define VS_SM_SDIORD        0x0200 /* VS1011 */
-#define VS_SM_SDISHARE      0x0400 /* VS1011 */
-#define VS_SM_SDINEW        0x0800 /* VS1011 */
-#define VS_SM_SETTOZERO2    0x1000 /* VS1011 */
-#define VS_SM_ADPCM         0x1000 /* VS1003 */
-#define VS_SM_SETTOZERO3    0x2000 /* VS1011 */
-#define VS_SM_ADPCM_HP      0x2000 /* VS1003 */
-#define VS_SM_LINE_IN       0x4000 /* VS1003 */
-
-// SCI Status register bits 6-4 contains the ID number of the chip
-#define VS_VS1001           0   /* not supported by this driver */
-#define VS_VS1011           1
-#define VS_VS1011e          2   /* VS1002 also returns this, but is not supported by this driver */
-#define VS_VS1003           3
-#define VS_VS1053           4
-#define VS_VS1033           5
-
-
-// Status of the decoder
-#define VS_STATUS_STOPPED   0
-#define VS_STATUS_RUNNING   1
-#define VS_STATUS_EOF       2
-#define VS_STATUS_EMPTY     4
-
-/*-------------------------------------------------------------------------*/
-/* typedefs & structs                                                      */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* export global variables                                                 */
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-/* export global routines (interface)                                      */
-/*-------------------------------------------------------------------------*/
-extern int VsPlayerInit(void);
-extern int VsPlayerReset(u_short mode);
-extern int VsPlayerSetMode(u_short mode);
-extern int VsPlayerKick(void);
-extern int VsPlayerStop(void);
-extern u_char VsPlayerInterrupts(u_char enable);
-
-extern u_char VsGetStatus(void);
-extern u_short VsMemoryTest(void);
-extern u_short VsGetType(void);
-extern u_short VsGetTypeHex(void);
-extern int VsSetVolume(u_char left, u_char right);
-extern u_short VsGetVolume(void);
-extern int VsBeep(u_char fsin, u_short ms);
-extern int VsBeepStart(u_char fsin);
-extern int VsBeepStartRaw(u_char Raw);
-extern int VsBeepStop(void);
-extern u_short VsRegInfo(u_char reg);
-extern void VsRegWrite(u_char reg, u_short data);
-extern u_short VsStreamValid(void);
-
-
-/*@}*/
+/*
+ * Copyright (C) 2001-2003 by egnite Software GmbH. 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 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 EGNITE SOFTWARE GMBH 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 EGNITE
+ * SOFTWARE GMBH 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.
+ *
+ * For additional information see http://www.ethernut.de/
+ *
+ * -
+ * Portions Copyright (C) 2001 Jesper Hansen <jesperh@telia.com>.
+ *
+ * This file is part of the yampp system.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/*
+ *
+ * Revision 2.0  2004/09/30 19:37:39  johan van der stoel
+ * Fully rewritten to support VS1011 / VS1003. For VS1001: use driver from
+ * Ethernut distribution
+ *
+ * Revision 1.2  2003/07/13 19:37:39  haraldkipp
+ * Enable application to control decoder interrupts.
+ *
+ *
+ */
+
+#include <sys/nutconfig.h>
+#include <sys/types.h>
+
+/*-------------------------------------------------------------------------*/
+/* global defines                                                          */
+/*-------------------------------------------------------------------------*/
+
+// Instruction opcodes
+#define VS_OPCODE_READ      3
+#define VS_OPCODE_WRITE     2
+
+// Decoder registers VS1011/VS1003
+#define VS_MODE_REG         0
+#define VS_STATUS_REG       1
+#define VS_BASS_REG         2
+#define VS_CLOCKF_REG       3
+#define VS_DECODE_TIME_REG  4
+#define VS_AUDATA_REG       5
+#define VS_WRAM_REG         6
+#define VS_WRAMADDR_REG     7
+#define VS_HDAT0_REG        8
+#define VS_HDAT1_REG        9
+#define VS_AIADDR_REG      10
+#define VS_VOL_REG         11
+#define VS_AICTRL0_REG     12
+#define VS_AICTRL1_REG     13
+#define VS_AICTRL2_REG     14
+#define VS_AICTRL3_REG     15
+
+#define NROF_VS_REGS       (VS_AICTRL3_REG+1)
+
+// SCI Mode register bits VS1011/VS1003
+#define VS_SM_DIFF          0x0001
+#define VS_SM_JUMP          0x0002 /* VS1011 */
+#define VS_SM_SETTOZERO     0x0002 /* VS1003 */
+#define VS_SM_RESET         0x0004
+#define VS_SM_OUTOFWAV      0x0008
+#define VS_SM_PDOWN         0x0010
+#define VS_SM_TESTS         0x0020
+#define VS_SM_STREAM        0x0040
+#define VS_SM_SETTOZERO1    0x0080 /* VS1011 */
+#define VS_SM_PLUSV         0x0080 /* VS1003 */
+#define VS_SM_DACT          0x0100
+#define VS_SM_SDIORD        0x0200 /* VS1011 */
+#define VS_SM_SDISHARE      0x0400 /* VS1011 */
+#define VS_SM_SDINEW        0x0800 /* VS1011 */
+#define VS_SM_SETTOZERO2    0x1000 /* VS1011 */
+#define VS_SM_ADPCM         0x1000 /* VS1003 */
+#define VS_SM_SETTOZERO3    0x2000 /* VS1011 */
+#define VS_SM_ADPCM_HP      0x2000 /* VS1003 */
+#define VS_SM_LINE_IN       0x4000 /* VS1003 */
+
+// SCI Status register bits 6-4 contains the ID number of the chip
+#define VS_VS1001           0   /* not supported by this driver */
+#define VS_VS1011           1
+#define VS_VS1011e          2   /* VS1002 also returns this, but is not supported by this driver */
+#define VS_VS1003           3
+#define VS_VS1053           4
+#define VS_VS1033           5
+
+
+// Status of the decoder
+#define VS_STATUS_STOPPED   0
+#define VS_STATUS_RUNNING   1
+#define VS_STATUS_EOF       2
+#define VS_STATUS_EMPTY     4
+
+/*-------------------------------------------------------------------------*/
+/* typedefs & structs                                                      */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* export global variables                                                 */
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/* export global routines (interface)                                      */
+/*-------------------------------------------------------------------------*/
+extern int VsPlayerInit(void);
+extern int VsPlayerReset(u_short mode);
+extern int VsPlayerSetMode(u_short mode);
+extern int VsPlayerKick(void);
+extern int VsPlayerStop(void);
+extern u_char VsPlayerInterrupts(u_char enable);
+
+extern u_char VsGetStatus(void);
+extern u_short VsMemoryTest(void);
+extern u_short VsGetType(void);
+extern u_short VsGetTypeHex(void);
+extern int VsSetVolume(u_char left, u_char right);
+extern u_short VsGetVolume(void);
+extern int VsBeep(u_char fsin, u_short ms);
+extern int VsBeepStart(u_char fsin);
+extern int VsBeepStartRaw(u_char Raw);
+extern int VsBeepStop(void);
+extern u_short VsRegInfo(u_char reg);
+extern void VsRegWrite(u_char reg, u_short data);
+extern u_short VsStreamValid(void);
+
+
+/*@}*/

+ 46 - 4
main.c

@@ -1,6 +1,48 @@
+#define LOG_MODULE  LOG_MAIN_MODULE
 
+/*--------------------------------------------------------------------------*/
+/*  Include files                                                           */
+/*--------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <string.h>
 
-int main() {
-    printf("test");
-    return 0;
-}
+#include <sys/thread.h>
+#include <sys/timer.h>
+#include <sys/version.h>
+#include <dev/irqreg.h>
+#include <time.h>
+
+/*--------------------------------------------------------------------------*/
+/*  Stream-IT Lib files                                                     */
+/*--------------------------------------------------------------------------*/
+#include "lib/led.h"
+#include "lib/system.h"
+#include "lib/portio.h"
+#include "lib/display.h"
+#include "lib/remcon.h"
+#include "lib/keyboard.h"
+#include "lib/log.h"
+#include "lib/uart0driver.h"
+#include "lib/mmc.h"
+//#include "lib/watchdog.h"
+#include "lib/flash.h"
+#include "lib/spidrv.h"
+#include "lib/rtc.h"
+
+
+int main(void)
+{
+    LedInit();
+    Uart0DriverInit();
+    Uart0DriverStart();
+    LogInit();
+    LogMsg_P(LOG_INFO, PSTR("Hello World"));
+    LcdBackLight(LCD_BACKLIGHT_ON);
+
+    for (;;)
+    {
+        LedControl(LED_TOGGLE);
+        NutSleep(1000);
+    }
+    return(0);
+}

+ 38 - 0
nutos/nut/Makedefs.arm-ecross-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.arm-eCross-gcc $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.arm-ecross-gcc

+ 46 - 0
nutos/nut/Makedefs.arm-ecross-gccdbg

@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.arm-eCross-gccdbg $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.arm-ecross-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -g3
+CXXFLAGS_OPT = -O0 -g3 -fno-delete-null-pointer-checks -fno-exceptions -fno-rtti
+
+# Debug code needs much more stack space.
+DEFS = -DNUT_THREAD_STACK_MULT=3 $(HWDEF)
+

+ 39 - 0
nutos/nut/Makedefs.arm-gcc

@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.arm-gcc 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.arm-gcc

+ 47 - 0
nutos/nut/Makedefs.arm-gccdbg

@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2001-2007 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.arm-gccdbg 5553 2014-01-18 12:10:24Z u_bonnes $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.arm-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -g3
+CXXFLAGS_OPT = -O0 -g3 -fno-delete-null-pointer-checks -fno-exceptions -fno-rtti
+
+# Debug code needs much more stack space.
+DEFS = -DNUT_THREAD_STACK_MULT=3 $(HWDEF)
+

+ 45 - 0
nutos/nut/Makedefs.arm-thumb-gcc

@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009-2011 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.arm-thumb-gcc 4256 2012-06-15 09:04:14Z haraldkipp $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.arm-gcc
+
+# Override compiler options to create thumb code.
+CFLAGS_MCU = $(MCFLAGS) -mthumb -fomit-frame-pointer
+
+# Problems have been reported with -Os.
+CFLAGS_OPT = -O0

+ 39 - 0
nutos/nut/Makedefs.avr-gcc

@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.avr-gcc 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+# Inherit avr-gcc variables.
+include $(top_srcdir)/Makevars.avr-gcc

+ 46 - 0
nutos/nut/Makedefs.avr-gccdbg

@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.avr-gccdbg 5553 2014-01-18 12:10:24Z u_bonnes $
+#
+
+# Inherit avr-gcc variables.
+include $(top_srcdir)/Makevars.avr-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -g3 -fno-delete-null-pointer-checks
+CXXFLAGS_OPT = -O0 -g3 -fno-delete-null-pointer-checks -fno-exceptions -fno-rtti
+
+# Debug code needs much more stack space.
+DEFS  = -DNUT_THREAD_STACK_ADD=256 $(HWDEF)

+ 51 - 0
nutos/nut/Makedefs.avr-icc7

@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2008-2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.avr-icc7 5439 2013-10-25 20:20:35Z olereinhardt $
+#
+
+DEFS = -DATMEGA -D_MCU_$(MCU) $(HWDEF)
+
+INCPRE=-I
+INCDIR = $(INCPRE)$(top_srcdir)/include/crt/iccavr $(INCPRE)$(top_srcdir)/include $(INCPRE)$(top_srcdir)/include/contrib
+
+CC  = iccavr
+AR  = ilibw
+CP  = cp
+AS  = iccavr
+
+CPFLAGS = $(INCFIRST) $(INCPRE). $(INCDIR) $(INCLAST) -e $(DEFS) -l -MLongJump -MHasMul -M$(MCU)
+#CPFLAGS = -I$(INCDIR) -I$(AVR)/include -e $(DEFS) -l -g -Mavr_$(MCU)
+LDFLAGS = -m -Wl,-Map=$(PROJ).map,--cref
+ARFLAGS = -a
+ASFLAGS = $(INCLAST) -e -l -g -Wa-W -Wa-n

+ 40 - 0
nutos/nut/Makedefs.avr32-gcc

@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+# Inherit avr32-gcc variables.
+include $(top_srcdir)/Makevars.avr32-gcc
+

+ 46 - 0
nutos/nut/Makedefs.avr32-gccdbg

@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+# Inherit avr32-gcc variables.
+include $(top_srcdir)/Makevars.avr32-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -g3
+CXXFLAGS_OPT = -O0 -g3 -fno-delete-null-pointer-checks -fno-exceptions -fno-rtti
+
+# Debug code needs much more stack space.
+DEFS  = -DNUT_THREAD_STACK_MULT=3 $(HWDEF)

+ 52 - 0
nutos/nut/Makedefs.avrext-icc7

@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2008-2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.avrext-icc7 5439 2013-10-25 20:20:35Z olereinhardt $
+#
+
+DEFS = -DATMEGA -DATMega2561 -D_EE_EXTIO -D_MCU_$(MCU) $(HWDEF)
+
+# LIBDIR = $(top_srcdir)/lib/icc/$(MCU)
+
+INCPRE=-I
+INCDIR = $(INCPRE)$(top_srcdir)/include/crt/iccavr $(INCPRE)$(top_srcdir)/include $(INCPRE)$(top_srcdir)/include/contrib
+
+CC  = iccavr
+AR  = ilibw
+CP  = cp
+AS  = iccavr
+
+CPFLAGS = $(INCFIRST) $(INCPRE). $(INCDIR) $(INCLAST) -e $(DEFS) -l -g -MLongJump -MHasMul -M$(MCU) -Wf-use_elpm
+LDFLAGS = -m -Wl,-Map=$(PROJ).map,--cref
+ARFLAGS = -a
+ASFLAGS = $(INCLAST) -e -l -g -Wa-W -Wa-n

+ 38 - 0
nutos/nut/Makedefs.cm3-ecross-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.cm3-ecross-gcc $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.cm3-ecross-gcc

+ 52 - 0
nutos/nut/Makedefs.cm3-ecross-gccdbg

@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.cm3-ecross-gccdbg $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.cm3-ecross-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
+CXXFLAGS_OPT = -O0 -fno-delete-null-pointer-checks -fno-exceptions -fno-rtti
+LDFLAGS   = $(MCFLAGS) -g -nostartfiles -L$(LDPATH) -T$(LDSCRIPT) -Wl,-Map=$(PROJ).map,--cref,--no-warn-mismatch -L$(LIBDIR)
+
+ELFCOF    = $(BIN) --debugging \
+	--change-section-address .data-0x08000000 \
+	--change-section-address .bss-0x08000000 \
+	--change-section-address .noinit-0x08000000 \
+	--change-section-address .rodata-0x08000000
+
+# Debug code needs much more stack space.
+DEFS = -DNUT_THREAD_STACK_MULT=3 $(HWDEF)

+ 39 - 0
nutos/nut/Makedefs.cm3-gcc

@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.cm3-gcc 4163 2012-05-15 12:09:43Z olereinhardt $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.cm3-gcc

+ 54 - 0
nutos/nut/Makedefs.cm3-gccdbg

@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2001-2007 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.cm3-gccdbg 5684 2014-05-01 18:34:40Z olereinhardt $
+#
+
+# Inherit arm-gcc variables.
+include $(top_srcdir)/Makevars.cm3-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -g3 -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(MDEBUG)
+CXXFLAGS_OPT = -O0 -g3 -fno-delete-null-pointer-checks -fno-exceptions -fno-rtti
+LDFLAGS   = $(MCFLAGS) -g -nostartfiles -L$(LDPATH) -T$(LDSCRIPT) -Wl,-Map=$(PROJ).map,--cref,--no-warn-mismatch -L$(LIBDIR)
+
+ELFCOF    = $(BIN) --debugging \
+	--change-section-address .data-0x08000000 \
+	--change-section-address .bss-0x08000000 \
+	--change-section-address .noinit-0x08000000 \
+	--change-section-address .rodata-0x08000000
+
+# Debug code needs much more stack space.
+DEFS = -DNUT_THREAD_STACK_MULT=3 $(HWDEF)
+

+ 65 - 0
nutos/nut/Makedefs.h8-gcc

@@ -0,0 +1,65 @@
+#
+# Copyright (C) 2001-2004 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.h8-gcc 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+include $(top_srcdir)/UserConf.mk
+
+DEFS = -DNUT_CPU_FREQ=22118400 $(HWDEF)
+#DEFS = -DNUT_CPU_FREQ=22118400 -DNUTDEBUG $(HWDEF)
+#DEFS  = $(HWDEF)
+#DEFS = -DNUTDEBUG $(HWDEF)
+#DEFS = -DNUT_CPU_FREQ=14745600 $(HWDEF)
+#DEFS = -DNUT_CPU_FREQ=3686400 $(HWDEF)
+
+LIBDIR = $(top_srcdir)/lib/gcc/$(MCU)
+INCDIR = $(top_srcdir)/include
+HWINC = $(top_srcdir)/arch/$(ARCH)/include
+
+MODDIR = $(top_srcdir)/mod
+MODINC = $(MODDIR)/include
+
+include $(top_srcdir)/Makevars.gcc
+
+TRGT   = h8300-elf-
+LD     = $(TRGT)ld
+CP     = cp
+
+MCFLAGS = $(MCUOPTS)
+CPFLAGS = $(MCFLAGS) -Os -fomit-frame-pointer -Wall -Werror -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
+#CPFLAGS = -g $(MCFLAGS) -O1 -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
+LDFLAGS = $(MCFLAGS) -Wl,-T$(LDSCRIPT),-Map=$(PROJ).map,--relax,--sort-common,--strip-all,--cref -L$(LIBDIR) $(LDDIRS)
+ARFLAGS = rsv
+ASFLAGS = $(MCFLAGS) -DROMSTART $(RUNFLAG) -Wa,-amhls=$(<:.S=.lst) $(DEFS)

+ 42 - 0
nutos/nut/Makedefs.m68k-gcc

@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+# Inherit m68k-gcc variables.
+include $(top_srcdir)/Makevars.m68k-gcc
+
+# Override compiler options to create mode detailed listings
+CFLAGS_ASM = -Wa,-aghlms=$(@:.o=.lst)

+ 48 - 0
nutos/nut/Makedefs.m68k-gccdbg

@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+# Inherit m68k-gcc variables.
+include $(top_srcdir)/Makevars.m68k-gcc
+
+# Override compiler options to create debug code.
+CFLAGS_OPT   = -O0 -g3
+
+# Override compiler options to create mode detailed listings
+CFLAGS_ASM = -Wa,-aghlms=$(@:.o=.lst)
+
+# Debug code needs much more stack space.
+DEFS  = -DNUT_THREAD_STACK_MULT=3 $(HWDEF)

+ 63 - 0
nutos/nut/Makedefs.unix-gcc

@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makedefs.unix-gcc 5472 2013-12-06 00:16:28Z olereinhardt $
+#
+
+include $(top_srcdir)/UserConf.mk
+
+DEFS  = $(HWDEF) -D__NUT_EMULATION__
+
+LIBDIR = $(top_srcdir)/lib/gcc/$(MCU)
+INCPRE = -I
+INCDIR = $(top_srcdir)/include
+
+include $(top_srcdir)/Makevars.gcc
+
+TRGT   = 
+CP     = cp
+
+# C++ compiler options.
+CPFLAGS = -g -Os -Wall -Werror -Wstrict-prototypes $(DEFS)
+
+# Linker options and flags.
+LDFLAGS = -L$(LIBDIR) $(LIBS)
+
+# Assembler options.
+ASFLAGS =  -Wa,-amhls=$(<:.S=.lst) $(DEFS)
+
+# Librarian options.
+#ARFLAGS = rsv
+# More silent version
+ARFLAGS = rsc

+ 57 - 0
nutos/nut/Makerules.all

@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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. All advertising materials mentioning features or use of this
+#    software must display the following acknowledgement:
+#
+#    This product includes software developed by egnite Software GmbH
+#    and its contributors.
+#
+# THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH 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 EGNITE
+# SOFTWARE GMBH 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+include $(top_srcdir)/Makerules.licenses
+
+help-libs:
+	$(info 'make all'       Creates all libraries. This is the default.)
+	$(info 'make clean'     Deletes all files that had been created by 'make all')
+	$(info 'make distclean' Deletes everything that can be reconstructed and all temporary files)
+	$(info 'make install'   Creates all libries and installs them for actual use.)
+	$(info 'make uninstall' Removes all installed libraries.)
+
+help: help-libs
+
+cleanedit: tempclean
+
+tempclean:
+	-rm -f $(SRCS:.c=.bak)
+	-rm -f $(SRCS:.c=.c~)
+
+.PHONY: cleanedit tempclean help help-libs help-apps

+ 37 - 0
nutos/nut/Makerules.arm-ecross-gcc

@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.arm-eCross-gcc $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 37 - 0
nutos/nut/Makerules.arm-ecross-gccdbg

@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.arm-eCross-gccdbg $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.arm-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.arm-gcc 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.arm-gccdbg

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2007 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.arm-gccdbg 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.arm-thumb-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009-2011 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.arm-thumb-gcc 4256 2012-06-15 09:04:14Z haraldkipp $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.avr-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.avr-gcc 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.avr-gccdbg

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2005 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.avr-gccdbg 2599 2009-04-15 13:09:02Z haraldkipp $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 72 - 0
nutos/nut/Makerules.avr-icc7

@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2008-2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.avr-icc7 3418 2011-05-16 09:55:13Z haraldkipp $
+#
+
+%.o : %.c
+	$(CC) -c $(CPFLAGS) $<
+
+%.o : %.S
+	$(AS) -c $(ASFLAGS) $< -o $@
+
+%.s : %.c
+	$(CC) -S $(CPFLAGS) $< -o $@
+
+%.elf: $(OBJS)
+	$(CC) $(OBJS) $(LIB) $(LDFLAGS) -o $@
+
+%.obj: %.elf
+	$(BIN) -O avrobj $< $@
+
+%.rom: %.elf
+	$(BIN) -O srec $< $@
+
+%.eep: %.elf
+	$(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load" -O srec $< $@
+
+%.a: $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(?F)
+
+.PHONY: cleancc
+cleancc:
+	-rm -f $(OBJS)
+	-rm -f $(TARG)
+	-rm -f $(SRCS:.c=.lst)
+	-rm -f $(SRCS:.c=.lis)
+	-rm -f $(SRCS:.c=.s)
+
+.PHONY: cleanedit
+cleanedit:
+	-rm -f $(SRCS:.c=.bak)
+	-rm -f $(SRCS:.c=.c~)

+ 38 - 0
nutos/nut/Makerules.avr32-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.avr32-gccdbg

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id$
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 72 - 0
nutos/nut/Makerules.avrext-icc7

@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2008-2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.avrext-icc7 3418 2011-05-16 09:55:13Z haraldkipp $
+#
+
+%.o : %.c
+	$(CC) -c $(CPFLAGS) $<
+
+%.o : %.S
+	$(AS) -c $(ASFLAGS) $< -o $@
+
+%.s : %.c
+	$(CC) -S $(CPFLAGS) $< -o $@
+
+%.elf: $(OBJS)
+	$(CC) $(OBJS) $(LIB) $(LDFLAGS) -o $@
+
+%.obj: %.elf
+	$(BIN) -O avrobj $< $@
+
+%.rom: %.elf
+	$(BIN) -O srec $< $@
+
+%.eep: %.elf
+	$(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load" -O srec $< $@
+
+%.a: $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(?F)
+
+.PHONY: cleancc
+cleancc:
+	-rm -f $(OBJS)
+	-rm -f $(TARG)
+	-rm -f $(SRCS:.c=.lst)
+	-rm -f $(SRCS:.c=.lis)
+	-rm -f $(SRCS:.c=.s)
+
+.PHONY: cleanedit
+cleanedit:
+	-rm -f $(SRCS:.c=.bak)
+	-rm -f $(SRCS:.c=.c~)

+ 37 - 0
nutos/nut/Makerules.cm3-ecross-gcc

@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.cm3-ecross-gcc $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 37 - 0
nutos/nut/Makerules.cm3-ecross-gccdbg

@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2010 by Thermotemp GmbH, Embedded-IT, based on template from Egnite
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.cm3-ecross-gccdbg $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.cm3-gcc

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.cm3-gcc 4163 2012-05-15 12:09:43Z olereinhardt $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 38 - 0
nutos/nut/Makerules.cm3-gccdbg

@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2001-2007 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.cm3-gccdbg 4163 2012-05-15 12:09:43Z olereinhardt $
+#
+
+include $(top_srcdir)/Makerules.gcc

+ 65 - 0
nutos/nut/Makerules.gcc

@@ -0,0 +1,65 @@
+#
+# Copyright (C) 2001-2006 by egnite Software GmbH
+# Copyright (C) 2009 by egnite GmbH
+#
+# 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 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.
+#
+# For additional information see http://www.ethernut.de/
+#
+# $Id: Makerules.gcc 5472 2013-12-06 00:16:28Z olereinhardt $
+#
+
+include $(top_srcdir)/Makerules.all
+CPPFLAGS += -MD -MP
+
+%.o : %.c
+	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+%.o : %.cc
+	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
+
+%.o : %.S
+	$(AS) -c $(CPPFLAGS) $(ASFLAGS) -o $@ $<
+
+%.a: $(OBJS)
+	$(AR) $(ARFLAGS) $@ $?
+
+# No idea why the pattern rule above doesn't work on some
+# make versions (No rule to make...). 
+# This little hack seems to fix it:
+$(PROJ).a: $(OBJS)
+
+cleancc:
+	-rm -f $(OBJS) $(SRCS:%.c=%.d) $(OBJ1:.o=.d)
+	-rm -f $(OBJS:.o=.lst) $(OBJ1:.o=.lst) $(OBJ2:.o=.lst) $(OBJ3:.o=.lst) $(OBJ4:.o=.lst) $(OBJ5:.o=.lst)
+
+ifndef NODEPS
+# http://www.microhowto.info/howto/automatically_generate_makefile_dependencies.html
+-include $(SRCS:%.c=%.d) $(OBJ1:.o=.d)
+endif

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác