Kaynağa Gözat

Merge pull request #1 from MarlinFirmware/Development

Sync with upstream
OhmEye 10 yıl önce
ebeveyn
işleme
f3f04e9fd6
100 değiştirilmiş dosya ile 17382 ekleme ve 7 silme
  1. 8
    0
      .gitignore
  2. 160
    0
      .travis.yml
  3. 35
    0
      ArduinoAddons/Arduino_0.xx/Gen6/boards.txt
  4. 713
    0
      ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT.c
  5. 121
    0
      ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT_324P.hex
  6. 120
    0
      ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT_644.hex
  7. 121
    0
      ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT_644P.hex
  8. 56
    0
      ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/Makefile
  9. 3
    0
      ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/README.txt
  10. 1
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Arduino.h
  11. 202
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/HardwareSerial.cpp
  12. 87
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/HardwareSerial.h
  13. 220
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Print.cpp
  14. 77
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Print.h
  15. 35
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Stream.h
  16. 601
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Tone.cpp
  17. 168
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WCharacter.h
  18. 1
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WConstants.h
  19. 249
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WInterrupts.c
  20. 60
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WMath.cpp
  21. 63
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WProgram.h
  22. 443
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WString.cpp
  23. 112
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WString.h
  24. 515
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/binary.h
  25. 14
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/main.cpp
  26. 200
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/pins_arduino.c
  27. 65
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/pins_arduino.h
  28. 289
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring.c
  29. 136
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring.h
  30. 259
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_analog.c
  31. 166
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_digital.c
  32. 68
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_private.h
  33. 69
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_pulse.c
  34. 55
    0
      ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_shift.c
  35. 101
    0
      ArduinoAddons/Arduino_0.xx/Gen7/boards.txt
  36. 113
    0
      ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-1284P-16MHz.hex
  37. 75
    0
      ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644-16MHz.hex
  38. 75
    0
      ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644-20MHz.hex
  39. 75
    0
      ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644P-16MHz.hex
  40. 75
    0
      ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644P-20MHz.hex
  41. 239
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/HardwareSerial.cpp
  42. 69
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/HardwareSerial.h
  43. 243
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Makefile
  44. 203
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Print.cpp
  45. 59
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Print.h
  46. 515
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Tone.cpp
  47. 168
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WCharacter.h
  48. 1
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WConstants.h
  49. 87
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WInterrupts.c
  50. 60
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WMath.cpp
  51. 34
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WProgram.h
  52. 443
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WString.cpp
  53. 112
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WString.h
  54. 515
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/binary.h
  55. 14
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/main.cpp
  56. 12
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/main.cxx
  57. 200
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/pins_arduino.c
  58. 65
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/pins_arduino.h
  59. 30
    3
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring.c
  60. 135
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring.h
  61. 116
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_analog.c
  62. 95
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_digital.c
  63. 60
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_private.h
  64. 66
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_pulse.c
  65. 3
    4
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_serial.c
  66. 40
    0
      ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_shift.c
  67. 99
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/boards.txt
  68. 470
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/Makefile
  69. 848
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/boot.h
  70. 724
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot.c
  71. 33
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot_1284P_20MHz_57k6_baud.hex
  72. 81
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/pin_defs.h
  73. 39
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/stk500.h
  74. 713
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT.c
  75. 121
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT_324P.hex
  76. 120
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT_644.hex
  77. 121
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT_644P.hex
  78. 56
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/Makefile
  79. 3
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/README.txt
  80. 303
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/HardwareSerial.cpp
  81. 76
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/HardwareSerial.h
  82. 220
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Print.cpp
  83. 66
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Print.h
  84. 35
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Stream.h
  85. 601
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Tone.cpp
  86. 168
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WCharacter.h
  87. 1
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WConstants.h
  88. 280
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WInterrupts.c
  89. 60
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WMath.cpp
  90. 63
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WProgram.h
  91. 443
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WString.cpp
  92. 112
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WString.h
  93. 515
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/binary.h
  94. 14
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/main.cpp
  95. 627
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.c
  96. 94
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.h
  97. 289
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring.c
  98. 138
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring.h
  99. 259
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring_analog.c
  100. 0
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring_digital.c

+ 8
- 0
.gitignore Dosyayı Görüntüle

@@ -0,0 +1,8 @@
1
+*.o
2
+applet/
3
+*~
4
+*.orig
5
+*.rej
6
+*.bak
7
+*.DS_Store
8
+*.idea

+ 160
- 0
.travis.yml Dosyayı Görüntüle

@@ -0,0 +1,160 @@
1
+---
2
+language: c
3
+
4
+before_install:
5
+  - pwd
6
+  - wget https://bootstrap.pypa.io/get-pip.py
7
+  - wget https://bintray.com/artifact/download/olikraus/u8glib/u8glib_arduino_v1.17.zip
8
+install:
9
+  - sudo python get-pip.py
10
+  - sudo pip install ino
11
+  # add ppa for newer version of Arduino than available in ubuntu 12.04
12
+  - sudo add-apt-repository ppa:michael-gruz/elektronik -y
13
+  - sudo apt-get update -q 
14
+  - sudo apt-get install arduino
15
+before_script:
16
+ # add U8glib, LiquidCrystal_I2C & LiquidTWI2 libraries 
17
+  - sudo unzip u8glib_arduino_v1.17.zip -d /usr/share/arduino/libraries/
18
+  - cd /usr/share/arduino/libraries/
19
+  - sudo git clone https://github.com/kiyoshigawa/LiquidCrystal_I2C.git
20
+  - ls -la
21
+  - ls -la LiquidCrystal_I2C/
22
+  - sudo git clone https://github.com/lincomatic/LiquidTWI2.git
23
+  # remove Robot_Control library to stop compile error!
24
+  - sudo rm -rf /usr/share/arduino/libraries/Robot_Control
25
+  # change back to home directory for compiling
26
+  - cd $TRAVIS_BUILD_DIR
27
+  # ino needs files in src directory
28
+  - ln -s Marlin src
29
+  # remove Marlin.pde as it confuses ino after it finds Marlin.ino
30
+  - rm Marlin/Marlin.pde
31
+script:
32
+  # build default config
33
+  - ino build -m mega2560
34
+  # backup configuration.h
35
+  - cp Marlin/Configuration.h Marlin/Configuration.h.backup
36
+  - cp Marlin/Configuration_adv.h Marlin/Configuration_adv.h.backup
37
+  # change extruder numbers from 1 to 2
38
+  # commented out for the moment fails build but compiles fine in Arduino
39
+  #- sed -i 's/#define EXTRUDERS 1/#define EXTRUDERS 2/g' Marlin/Configuration.h
40
+  #- rm -rf .build/
41
+  #- ino build -m mega2560
42
+  # change extruder numbers from 2 to 3, needs to be a board with 3 extruders defined in pins.h 
43
+  #- sed -i 's/#define MOTHERBOARD BOARD_ULTIMAKER/#define MOTHERBOARD BOARD_AZTEEG_X3_PRO/g' Marlin/Configuration.h
44
+  #- sed -i 's/#define EXTRUDERS 2/#define EXTRUDERS 3/g' Marlin/Configuration.h
45
+  #- rm -rf .build/
46
+  #- ino build -m mega2560
47
+  # enable PIDTEMPBED 
48
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
49
+  - sed -i 's/\/\/#define PIDTEMPBED/#define PIDTEMPBED/g' Marlin/Configuration.h
50
+  - rm -rf .build/
51
+  - ino build -m mega2560
52
+  # enable THERMAL RUNAWAY PROTECTION for extruders & bed
53
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
54
+  - sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_PERIOD/#define THERMAL_RUNAWAY_PROTECTION_PERIOD/g' Marlin/Configuration.h
55
+  - sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS/#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS/g' Marlin/Configuration.h
56
+  - sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD/#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD/g' Marlin/Configuration.h
57
+  - sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS/#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS/g' Marlin/Configuration.h
58
+  - rm -rf .build/
59
+  - ino build -m mega2560
60
+  # enable AUTO_BED_LEVELING
61
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
62
+  - sed -i 's/\/\/#define ENABLE_AUTO_BED_LEVELING/#define ENABLE_AUTO_BED_LEVELING/g' Marlin/Configuration.h
63
+  - rm -rf .build/
64
+  - ino build -m mega2560
65
+  # enable EEPROM_SETTINGS & EEPROM_CHITCHAT
66
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
67
+  - sed -i 's/\/\/#define EEPROM_SETTINGS/#define EEPROM_SETTINGS/g' Marlin/Configuration.h
68
+  - sed -i 's/\/\/#define EEPROM_CHITCHAT/#define EEPROM_CHITCHAT/g' Marlin/Configuration.h
69
+  - rm -rf .build/
70
+  - ino build -m mega2560
71
+  ### LCDS ###
72
+  # ULTIMAKERCONTROLLER
73
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
74
+  - sed -i 's/\/\/#define ULTIMAKERCONTROLLER/#define ULTIMAKERCONTROLLER/g' Marlin/Configuration.h
75
+  - rm -rf .build/
76
+  - ino build -m mega2560
77
+  # MAKRPANEL
78
+  # Needs to use melzi and sanguino hardware
79
+  #- cp Marlin/Configuration.h.backup Marlin/Configuration.h
80
+  #- sed -i 's/\/\/#define MAKRPANEL/#define MAKRPANEL/g' Marlin/Configuration.h
81
+  #- rm -rf .build/
82
+  #- ino build -m mega2560
83
+  # REPRAP_DISCOUNT_SMART_CONTROLLER
84
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
85
+  - sed -i 's/\/\/#define REPRAP_DISCOUNT_SMART_CONTROLLER/#define REPRAP_DISCOUNT_SMART_CONTROLLER/g' Marlin/Configuration.h
86
+  - rm -rf .build/
87
+  - ino build -m mega2560
88
+  # G3D_PANE
89
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
90
+  - sed -i 's/\/\/#define G3D_PANEL/#define G3D_PANEL/g' Marlin/Configuration.h
91
+  - rm -rf .build/
92
+  - ino build -m mega2560
93
+  # REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
94
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
95
+  - sed -i 's/\/\/#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER/#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER/g' Marlin/Configuration.h
96
+  - rm -rf .build/
97
+  - ino build -m mega2560
98
+  # REPRAPWORLD_KEYPAD 
99
+  # Cant find configuration details to get it to compile
100
+  #- cp Marlin/Configuration.h.backup Marlin/Configuration.h
101
+  #- sed -i 's/\/\/#define ULTRA_LCD/#define ULTRA_LCD/g' Marlin/Configuration.h
102
+  #- sed -i 's/\/\/#define REPRAPWORLD_KEYPAD/#define REPRAPWORLD_KEYPAD/g' Marlin/Configuration.h
103
+  #- sed -i 's/\/\/#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0/#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0/g' Marlin/Configuration.h
104
+  #- rm -rf .build/
105
+  #- ino build -m mega2560
106
+  # RA_CONTROL_PANEL
107
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
108
+  - sed -i 's/\/\/#define RA_CONTROL_PANEL/#define RA_CONTROL_PANEL/g' Marlin/Configuration.h
109
+  - rm -rf .build/
110
+  - ino build -m mega2560
111
+  ### I2C PANELS ###
112
+  # LCD_I2C_SAINSMART_YWROBOT
113
+  # Failing at the moment needs different library 
114
+  #- cp Marlin/Configuration.h.backup Marlin/Configuration.h
115
+  #- sed -i 's/\/\/#define LCD_I2C_SAINSMART_YWROBOT/#define LCD_I2C_SAINSMART_YWROBOT/g' Marlin/Configuration.h
116
+  #- rm -rf .build/
117
+  #- ino build -m mega2560
118
+  # LCD_I2C_PANELOLU2
119
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
120
+  - sed -i 's/\/\/#define LCD_I2C_PANELOLU2/#define LCD_I2C_PANELOLU2/g' Marlin/Configuration.h
121
+  - rm -rf .build/
122
+  - ino build -m mega2560
123
+  # LCD_I2C_VIKI
124
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
125
+  - sed -i 's/\/\/#define LCD_I2C_VIKI/#define LCD_I2C_VIKI/g' Marlin/Configuration.h
126
+  - rm -rf .build/
127
+  - ino build -m mega2560
128
+  # Enable filament sensor
129
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
130
+  - sed -i 's/\/\/#define FILAMENT_SENSOR/#define FILAMENT_SENSOR/g' Marlin/Configuration.h
131
+  - rm -rf .build/
132
+  - ino build -m mega2560
133
+   # Enable filament sensor with LCD display
134
+  - cp Marlin/Configuration.h.backup Marlin/Configuration.h
135
+  - sed -i 's/\/\/#define ULTIMAKERCONTROLLER/#define ULTIMAKERCONTROLLER/g' Marlin/Configuration.h
136
+  - sed -i 's/\/\/#define FILAMENT_SENSOR/#define FILAMENT_SENSOR/g' Marlin/Configuration.h
137
+  - sed -i 's/\/\/#define FILAMENT_LCD_DISPLAY/#define FILAMENT_LCD_DISPLAY/g' Marlin/Configuration.h
138
+  - rm -rf .build/
139
+  - ino build -m mega2560
140
+  ######## Example Configurations ##############
141
+  # Delta Config
142
+  - cp Marlin/example_configurations/delta/Configuration* Marlin/
143
+  - rm -rf .build/
144
+  - ino build -m mega2560
145
+  # Makibox Config  need to check board type for Teensy++ 2.0
146
+  #- cp Marlin/example_configurations/makibox/Configuration* Marlin/
147
+  #- rm -rf .build/
148
+  #- ino build -m mega2560
149
+  # SCARA Config
150
+  - cp Marlin/example_configurations/SCARA/Configuration* Marlin/
151
+  - rm -rf .build/
152
+  - ino build -m mega2560
153
+  # tvrrug Config need to check board type for sanguino atmega644p
154
+  #- cp Marlin/example_configurations/tvrrug/Round2/Configuration* Marlin/
155
+  #- rm -rf .build/
156
+  #- ino build -m mega2560
157
+  ######## Board Types #############
158
+  - sed -i 's/#define MOTHERBOARD BOARD_RAMPS_13_EFB/#define MOTHERBOARD BOARD_DUEMILANOVE_328P/g' Marlin/Configuration.h
159
+  - rm -rf .build/
160
+  - ino build -m atmega328

+ 35
- 0
ArduinoAddons/Arduino_0.xx/Gen6/boards.txt Dosyayı Görüntüle

@@ -0,0 +1,35 @@
1
+##############################################################
2
+
3
+Generation_Series.name=Gen6 & Gen6 Deluxe 
4
+Generation_Series.upload.protocol=stk500
5
+Generation_Series.upload.maximum_size=63488
6
+Generation_Series.upload.speed=38400
7
+Generation_Series.bootloader.low_fuses=0xFF
8
+Generation_Series.bootloader.high_fuses=0xDC
9
+Generation_Series.bootloader.extended_fuses=0xFD
10
+Generation_Series.bootloader.path=atmega644p
11
+Generation_Series.bootloader.file=ATmegaBOOT_644P.hex
12
+Generation_Series.bootloader.unlock_bits=0x3F
13
+Generation_Series.bootloader.lock_bits=0x0F
14
+Generation_Series.build.mcu=atmega644p
15
+Generation_Series.build.f_cpu=16000000L
16
+Generation_Series.build.core=arduino
17
+
18
+
19
+##############################################################
20
+
21
+
22
+Sanguinololu.name=Sanguinololu 1.2 and above
23
+Sanguinololu.upload.protocol=stk500
24
+Sanguinololu.upload.maximum_size=63488
25
+Sanguinololu.upload.speed=38400
26
+Sanguinololu.bootloader.low_fuses=0xFF
27
+Sanguinololu.bootloader.high_fuses=0xDC
28
+Sanguinololu.bootloader.extended_fuses=0xFD
29
+Sanguinololu.bootloader.path=atmega644p
30
+Sanguinololu.bootloader.file=ATmegaBOOT_644P.hex
31
+Sanguinololu.bootloader.unlock_bits=0x3F
32
+Sanguinololu.bootloader.lock_bits=0x0F
33
+Sanguinololu.build.mcu=atmega644p
34
+Sanguinololu.build.f_cpu=16000000L
35
+Sanguinololu.build.core=arduino

+ 713
- 0
ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT.c Dosyayı Görüntüle

@@ -0,0 +1,713 @@
1
+/**********************************************************/
2
+/* Serial Bootloader for Atmel megaAVR Controllers        */
3
+/*                                                        */
4
+/* tested with ATmega644 and ATmega644P                   */
5
+/* should work with other mega's, see code for details    */
6
+/*                                                        */
7
+/* ATmegaBOOT.c                                           */
8
+/*                                                        */
9
+/* 20090131: Added 324P support from Alex Leone           */
10
+/*           Marius Kintel                                */
11
+/* 20080915: applied ADABoot mods for Sanguino 644P       */
12
+/*           Brian Riley                                  */
13
+/* 20080711: hacked for Sanguino by Zach Smith            */
14
+/*           and Justin Day                               */
15
+/* 20070626: hacked for Arduino Diecimila (which auto-    */
16
+/*           resets when a USB connection is made to it)  */
17
+/*           by D. Mellis                                 */
18
+/* 20060802: hacked for Arduino by D. Cuartielles         */
19
+/*           based on a previous hack by D. Mellis        */
20
+/*           and D. Cuartielles                           */
21
+/*                                                        */
22
+/* Monitor and debug functions were added to the original */
23
+/* code by Dr. Erik Lins, chip45.com. (See below)         */
24
+/*                                                        */
25
+/* Thanks to Karl Pitrich for fixing a bootloader pin     */
26
+/* problem and more informative LED blinking!             */
27
+/*                                                        */
28
+/* For the latest version see:                            */
29
+/* http://www.chip45.com/                                 */
30
+/*                                                        */
31
+/* ------------------------------------------------------ */
32
+/*                                                        */
33
+/* based on stk500boot.c                                  */
34
+/* Copyright (c) 2003, Jason P. Kyle                      */
35
+/* All rights reserved.                                   */
36
+/* see avr1.org for original file and information         */
37
+/*                                                        */
38
+/* This program is free software; you can redistribute it */
39
+/* and/or modify it under the terms of the GNU General    */
40
+/* Public License as published by the Free Software       */
41
+/* Foundation; either version 2 of the License, or        */
42
+/* (at your option) any later version.                    */
43
+/*                                                        */
44
+/* This program is distributed in the hope that it will   */
45
+/* be useful, but WITHOUT ANY WARRANTY; without even the  */
46
+/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
47
+/* PARTICULAR PURPOSE.  See the GNU General Public        */
48
+/* License for more details.                              */
49
+/*                                                        */
50
+/* You should have received a copy of the GNU General     */
51
+/* Public License along with this program; if not, write  */
52
+/* to the Free Software Foundation, Inc.,                 */
53
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
54
+/*                                                        */
55
+/* Licence can be viewed at                               */
56
+/* http://www.fsf.org/licenses/gpl.txt                    */
57
+/*                                                        */
58
+/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
59
+/* m8515,m8535. ATmega161 has a very small boot block so  */
60
+/* isn't supported.                                       */
61
+/*                                                        */
62
+/* Tested with m168                                       */
63
+/**********************************************************/
64
+
65
+/* $Id$ */
66
+
67
+
68
+/* some includes */
69
+#include <inttypes.h>
70
+#include <avr/io.h>
71
+#include <avr/pgmspace.h>
72
+#include <avr/interrupt.h>
73
+#include <avr/wdt.h>
74
+#include <avr/boot.h>
75
+
76
+#ifdef ADABOOT
77
+    #define NUM_LED_FLASHES 3
78
+    #define ADABOOT_VER	1
79
+#endif
80
+
81
+
82
+/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
83
+#define MAX_ERROR_COUNT 5
84
+
85
+/* set the UART baud rate */
86
+/* 20080711: hack by Zach Hoeken */
87
+#define BAUD_RATE   38400
88
+
89
+/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
90
+/* never allow AVR Studio to do an update !!!! */
91
+#define HW_VER	 0x02
92
+#define SW_MAJOR 0x01
93
+#define SW_MINOR 0x10
94
+
95
+/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
96
+/* if monitor functions are included, LED goes on after monitor was entered */
97
+#define LED_DDR  DDRB
98
+#define LED_PORT PORTB
99
+#define LED_PIN  PINB
100
+#define LED      PINB0
101
+
102
+/* define various device id's */
103
+/* manufacturer byte is always the same */
104
+#define SIG1	0x1E	// Yep, Atmel is the only manufacturer of AVR micros.  Single source :(
105
+#if defined(__AVR_ATmega644P__)
106
+#define SIG2	0x96
107
+#define SIG3	0x0A
108
+#elif defined(__AVR_ATmega644__)
109
+#define SIG2	0x96
110
+#define SIG3	0x09
111
+#elif defined(__AVR_ATmega324P__)
112
+#define SIG2	0x95
113
+#define SIG3	0x08
114
+#endif
115
+#define PAGE_SIZE		0x080U   //128 words
116
+#define PAGE_SIZE_BYTES	0x100U   //256 bytes
117
+
118
+/* function prototypes */
119
+void putch(char);
120
+char getch(void);
121
+void getNch(uint8_t);
122
+void byte_response(uint8_t);
123
+void nothing_response(void);
124
+char gethex(void);
125
+void puthex(char);
126
+void flash_led(uint8_t);
127
+
128
+/* some variables */
129
+union address_union
130
+{
131
+    uint16_t word;
132
+    uint8_t  byte[2];
133
+} address;
134
+
135
+union length_union
136
+{
137
+    uint16_t word;
138
+    uint8_t  byte[2];
139
+} length;
140
+
141
+struct flags_struct
142
+{
143
+    unsigned eeprom : 1;
144
+    unsigned rampz  : 1;
145
+} flags;
146
+
147
+uint8_t buff[256];
148
+
149
+uint8_t error_count = 0;
150
+uint8_t sreg;
151
+
152
+void (*app_start)(void) = 0x0000;
153
+
154
+/* main program starts here */
155
+int main(void)
156
+{
157
+    uint8_t ch,ch2;
158
+    uint16_t w;
159
+	uint16_t i;
160
+	
161
+    asm volatile("nop\n\t");
162
+
163
+#ifdef ADABOOT		// BBR/LF 10/8/2007 & 9/13/2008
164
+    ch = MCUSR;
165
+    MCUSR = 0;
166
+
167
+    WDTCSR |= _BV(WDCE) | _BV(WDE);
168
+    WDTCSR = 0;
169
+
170
+    // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
171
+    if (! (ch &  _BV(EXTRF))) // if it's a not an external reset...
172
+      app_start();  // skip bootloader
173
+#endif
174
+
175
+
176
+	//initialize our serial port.
177
+    UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
178
+    UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
179
+    UCSR0B = (1<<RXEN0) | (1<<TXEN0);
180
+    UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
181
+
182
+    /* Enable internal pull-up resistor on pin D0 (RX), in order
183
+    to supress line noise that prevents the bootloader from
184
+    timing out (DAM: 20070509) */
185
+    DDRD &= ~_BV(PIND0);
186
+    PORTD |= _BV(PIND0);
187
+
188
+    /* set LED pin as output */
189
+    LED_DDR |= _BV(LED);
190
+
191
+	    /* flash onboard LED to signal entering of bootloader                   */
192
+	    /* ADABOOT will do two series of flashes. first 4 - signifying ADABOOT  */
193
+	    /* then a pause and another flash series signifying ADABOOT sub-version */
194
+
195
+
196
+	flash_led(NUM_LED_FLASHES);
197
+
198
+	#ifdef	ADABOOT
199
+		flash_led(ADABOOT_VER);		// BBR 9/13/2008
200
+	#endif 
201
+
202
+    /* forever loop */
203
+    for (;;)
204
+	{
205
+		/* get character from UART */
206
+		ch = getch();
207
+
208
+		/* A bunch of if...else if... gives smaller code than switch...case ! */
209
+
210
+		/* Hello is anyone home ? */ 
211
+		if(ch=='0')
212
+		    nothing_response();
213
+
214
+
215
+		/* Request programmer ID */
216
+		/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry  */
217
+		/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares.  */
218
+		else if(ch=='1')
219
+		{
220
+		    if (getch() == ' ')
221
+			{
222
+				putch(0x14);
223
+				putch('A');
224
+				putch('V');
225
+				putch('R');
226
+				putch(' ');
227
+				putch('I');
228
+				putch('S');
229
+				putch('P');
230
+				putch(0x10);
231
+		    }
232
+			else
233
+			{
234
+				if (++error_count == MAX_ERROR_COUNT)
235
+				    app_start();
236
+		    }
237
+		}
238
+
239
+
240
+		/* AVR ISP/STK500 board commands  DON'T CARE so default nothing_response */
241
+		else if(ch=='@')
242
+		{
243
+		    ch2 = getch();
244
+		    if (ch2 > 0x85)
245
+				getch();
246
+		    nothing_response();
247
+		}
248
+
249
+
250
+		/* AVR ISP/STK500 board requests */
251
+		else if(ch=='A')
252
+		{
253
+		    ch2 = getch();
254
+		    if(ch2 == 0x80)
255
+				byte_response(HW_VER);		// Hardware version
256
+		    else if(ch2==0x81)
257
+				byte_response(SW_MAJOR);	// Software major version
258
+		    else if(ch2==0x82)
259
+				byte_response(SW_MINOR);	// Software minor version
260
+		    else if(ch2==0x98)
261
+				byte_response(0x03);		// Unknown but seems to be required by avr studio 3.56
262
+		    else
263
+				byte_response(0x00);		// Covers various unnecessary responses we don't care about
264
+		}
265
+
266
+
267
+		/* Device Parameters  DON'T CARE, DEVICE IS FIXED  */
268
+		else if(ch=='B')
269
+		{
270
+		    getNch(20);
271
+		    nothing_response();
272
+		}
273
+
274
+
275
+		/* Parallel programming stuff  DON'T CARE  */
276
+		else if(ch=='E')
277
+		{
278
+		    getNch(5);
279
+		    nothing_response();
280
+		}
281
+
282
+
283
+		/* Enter programming mode  */
284
+		else if(ch=='P')
285
+		{
286
+		    nothing_response();
287
+		}
288
+
289
+
290
+		/* Leave programming mode  */
291
+		else if(ch=='Q')
292
+		{
293
+		    nothing_response();
294
+#ifdef ADABOOT		
295
+			// autoreset via watchdog (sneaky!) BBR/LF 9/13/2008
296
+	  		WDTCSR = _BV(WDE);
297
+	  		while (1); // 16 ms
298
+#endif		
299
+		}
300
+
301
+
302
+		/* Erase device, don't care as we will erase one page at a time anyway.  */
303
+		else if(ch=='R')
304
+		{
305
+		    nothing_response();
306
+		}
307
+
308
+
309
+		/* Set address, little endian. EEPROM in bytes, FLASH in words  */
310
+		/* Perhaps extra address bytes may be added in future to support > 128kB FLASH.  */
311
+		/* This might explain why little endian was used here, big endian used everywhere else.  */
312
+		else if(ch=='U')
313
+		{
314
+		    address.byte[0] = getch();
315
+		    address.byte[1] = getch();
316
+		    nothing_response();
317
+		}
318
+
319
+
320
+		/* Universal SPI programming command, disabled.  Would be used for fuses and lock bits.  */
321
+		else if(ch=='V')
322
+		{
323
+		    getNch(4);
324
+		    byte_response(0x00);
325
+		}
326
+
327
+
328
+		/* Write memory, length is big endian and is in bytes  */
329
+		else if(ch=='d')
330
+		{
331
+		    length.byte[1] = getch();
332
+		    length.byte[0] = getch();
333
+	
334
+		    flags.eeprom = 0;
335
+		    if (getch() == 'E')
336
+				flags.eeprom = 1;
337
+
338
+			for (i=0; i<PAGE_SIZE; i++)
339
+				buff[i] = 0;
340
+		
341
+		    for (w = 0; w < length.word; w++)
342
+			{
343
+				// Store data in buffer, can't keep up with serial data stream whilst programming pages
344
+				buff[w] = getch();
345
+		    }
346
+	
347
+		    if (getch() == ' ')
348
+			{
349
+				if (flags.eeprom)
350
+				{		                
351
+					//Write to EEPROM one byte at a time
352
+				    for(w=0;w<length.word;w++)
353
+					{
354
+						while(EECR & (1<<EEPE));
355
+					
356
+						EEAR = (uint16_t)(void *)address.word;
357
+						EEDR = buff[w];
358
+						EECR |= (1<<EEMPE);
359
+						EECR |= (1<<EEPE);
360
+
361
+						address.word++;
362
+				    }			
363
+				}
364
+				else
365
+				{
366
+					//address * 2 -> byte location
367
+				    address.word = address.word << 1;
368
+			    
369
+					//Even up an odd number of bytes
370
+					if ((length.byte[0] & 0x01))
371
+						length.word++;
372
+				
373
+					// HACKME: EEPE used to be EEWE
374
+				    //Wait for previous EEPROM writes to complete
375
+					//while(bit_is_set(EECR,EEPE));
376
+					while(EECR & (1<<EEPE));
377
+				
378
+				    asm volatile(
379
+						 "clr	r17		\n\t"	//page_word_count
380
+						 "lds	r30,address	\n\t"	//Address of FLASH location (in bytes)
381
+						 "lds	r31,address+1	\n\t"
382
+						 "ldi	r28,lo8(buff)	\n\t"	//Start of buffer array in RAM
383
+						 "ldi	r29,hi8(buff)	\n\t"
384
+						 "lds	r24,length	\n\t"	//Length of data to be written (in bytes)
385
+						 "lds	r25,length+1	\n\t"
386
+						 "length_loop:		\n\t"	//Main loop, repeat for number of words in block							 							 
387
+						 "cpi	r17,0x00	\n\t"	//If page_word_count=0 then erase page
388
+						 "brne	no_page_erase	\n\t"						 
389
+						 "wait_spm1:		\n\t"
390
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
391
+						 "andi	r16,1           \n\t"
392
+						 "cpi	r16,1           \n\t"
393
+						 "breq	wait_spm1       \n\t"
394
+						 "ldi	r16,0x03	\n\t"	//Erase page pointed to by Z
395
+						 "sts	%0,r16		\n\t"
396
+						 "spm			\n\t"							 
397
+						 "wait_spm2:		\n\t"
398
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
399
+						 "andi	r16,1           \n\t"
400
+						 "cpi	r16,1           \n\t"
401
+						 "breq	wait_spm2       \n\t"									 
402
+
403
+						 "ldi	r16,0x11	\n\t"	//Re-enable RWW section
404
+						 "sts	%0,r16		\n\t"						 			 
405
+						 "spm			\n\t"
406
+						 "no_page_erase:		\n\t"							 
407
+						 "ld	r0,Y+		\n\t"	//Write 2 bytes into page buffer
408
+						 "ld	r1,Y+		\n\t"							 
409
+							 
410
+						 "wait_spm3:		\n\t"
411
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
412
+						 "andi	r16,1           \n\t"
413
+						 "cpi	r16,1           \n\t"
414
+						 "breq	wait_spm3       \n\t"
415
+						 "ldi	r16,0x01	\n\t"	//Load r0,r1 into FLASH page buffer
416
+						 "sts	%0,r16		\n\t"
417
+						 "spm			\n\t"
418
+							 
419
+						 "inc	r17		\n\t"	//page_word_count++
420
+						 "cpi r17,%1	        \n\t"
421
+						 "brlo	same_page	\n\t"	//Still same page in FLASH
422
+						 "write_page:		\n\t"
423
+						 "clr	r17		\n\t"	//New page, write current one first
424
+						 "wait_spm4:		\n\t"
425
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
426
+						 "andi	r16,1           \n\t"
427
+						 "cpi	r16,1           \n\t"
428
+						 "breq	wait_spm4       \n\t"						 							 
429
+						 "ldi	r16,0x05	\n\t"	//Write page pointed to by Z
430
+						 "sts	%0,r16		\n\t"
431
+						 "spm			\n\t"
432
+						 "wait_spm5:		\n\t"
433
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
434
+						 "andi	r16,1           \n\t"
435
+						 "cpi	r16,1           \n\t"
436
+						 "breq	wait_spm5       \n\t"									 
437
+						 "ldi	r16,0x11	\n\t"	//Re-enable RWW section
438
+						 "sts	%0,r16		\n\t"						 			 
439
+						 "spm			\n\t"					 		 
440
+						 "same_page:		\n\t"							 
441
+						 "adiw	r30,2		\n\t"	//Next word in FLASH
442
+						 "sbiw	r24,2		\n\t"	//length-2
443
+						 "breq	final_write	\n\t"	//Finished
444
+						 "rjmp	length_loop	\n\t"
445
+						 "final_write:		\n\t"
446
+						 "cpi	r17,0		\n\t"
447
+						 "breq	block_done	\n\t"
448
+						 "adiw	r24,2		\n\t"	//length+2, fool above check on length after short page write
449
+						 "rjmp	write_page	\n\t"
450
+						 "block_done:		\n\t"
451
+						 "clr	__zero_reg__	\n\t"	//restore zero register
452
+						 : "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
453
+
454
+						 );
455
+				}
456
+				putch(0x14);
457
+				putch(0x10);
458
+		    }
459
+			else
460
+			{
461
+				if (++error_count == MAX_ERROR_COUNT)
462
+				    app_start();
463
+		    }		
464
+		}
465
+    
466
+		/* Read memory block mode, length is big endian.  */
467
+		else if(ch=='t')
468
+		{
469
+			length.byte[1] = getch();
470
+			length.byte[0] = getch();
471
+
472
+			if (getch() == 'E')
473
+				flags.eeprom = 1;
474
+			else
475
+			{
476
+				flags.eeprom = 0;
477
+				address.word = address.word << 1;	        // address * 2 -> byte location
478
+			}
479
+
480
+			// Command terminator
481
+			if (getch() == ' ')
482
+			{
483
+				putch(0x14);
484
+				for (w=0; w<length.word; w++)
485
+				{
486
+					// Can handle odd and even lengths okay
487
+				    if (flags.eeprom) 
488
+					{
489
+						// Byte access EEPROM read
490
+						while(EECR & (1<<EEPE));
491
+						EEAR = (uint16_t)(void *)address.word;
492
+						EECR |= (1<<EERE);
493
+						putch(EEDR);
494
+
495
+						address.word++;
496
+				    }
497
+				    else
498
+					{
499
+						if (!flags.rampz)
500
+							putch(pgm_read_byte_near(address.word));
501
+
502
+						address.word++;
503
+				    }
504
+				}
505
+				putch(0x10);
506
+		    }
507
+		}
508
+
509
+
510
+		/* Get device signature bytes  */
511
+		else if(ch=='u')
512
+		{
513
+			if (getch() == ' ')
514
+			{
515
+				putch(0x14);
516
+				putch(SIG1);
517
+				putch(SIG2);
518
+				putch(SIG3);
519
+				putch(0x10);
520
+			}
521
+			else
522
+			{
523
+				if (++error_count == MAX_ERROR_COUNT)
524
+					app_start();
525
+			}
526
+		}
527
+
528
+
529
+		/* Read oscillator calibration byte */
530
+		else if(ch=='v')
531
+			byte_response(0x00);
532
+
533
+		else if (++error_count == MAX_ERROR_COUNT)
534
+		    app_start();
535
+
536
+	}
537
+    /* end of forever loop */
538
+}
539
+
540
+
541
+char gethex(void)
542
+{
543
+    char ah,al;
544
+
545
+    ah = getch();
546
+	putch(ah);
547
+    al = getch();
548
+	putch(al);
549
+    
550
+	if(ah >= 'a')
551
+		ah = ah - 'a' + 0x0a;
552
+	else if(ah >= '0')
553
+		ah -= '0';
554
+    if(al >= 'a')
555
+		al = al - 'a' + 0x0a;
556
+	else if(al >= '0')
557
+		al -= '0';
558
+
559
+    return (ah << 4) + al;
560
+}
561
+
562
+
563
+void puthex(char ch)
564
+{
565
+    char ah,al;
566
+
567
+    ah = (ch & 0xf0) >> 4;
568
+	if(ah >= 0x0a)
569
+		ah = ah - 0x0a + 'a';
570
+	else
571
+		ah += '0';
572
+
573
+    al = (ch & 0x0f);
574
+	if(al >= 0x0a)
575
+		al = al - 0x0a + 'a';
576
+	else
577
+		al += '0';
578
+
579
+    putch(ah);
580
+    putch(al);
581
+}
582
+
583
+
584
+void putch(char ch)
585
+{
586
+    while (!(UCSR0A & _BV(UDRE0)));
587
+    UDR0 = ch;
588
+}
589
+
590
+
591
+
592
+
593
+char getch(void)
594
+{
595
+    uint32_t count = 0;
596
+
597
+#ifdef ADABOOT
598
+	LED_PORT &= ~_BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
599
+#endif
600
+
601
+    while(!(UCSR0A & _BV(RXC0)))
602
+	{
603
+    	/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/               
604
+    	/* HACKME:: here is a good place to count times*/
605
+    	count++;
606
+    	if (count > MAX_TIME_COUNT)
607
+    		app_start();
608
+     }
609
+
610
+#ifdef ADABOOT
611
+	LED_PORT |= _BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
612
+#endif
613
+
614
+    return UDR0;
615
+}
616
+
617
+
618
+void getNch(uint8_t count)
619
+{
620
+    uint8_t i;
621
+    for(i=0;i<count;i++)
622
+	{
623
+		while(!(UCSR0A & _BV(RXC0)));
624
+		UDR0;
625
+    }
626
+}
627
+
628
+
629
+void byte_response(uint8_t val)
630
+{
631
+    if (getch() == ' ')
632
+	{
633
+		putch(0x14);
634
+		putch(val);
635
+		putch(0x10);
636
+    }
637
+	else
638
+	{
639
+		if (++error_count == MAX_ERROR_COUNT)
640
+		    app_start();
641
+    }
642
+}
643
+
644
+
645
+void nothing_response(void)
646
+{
647
+    if (getch() == ' ')
648
+	{
649
+		putch(0x14);
650
+		putch(0x10);
651
+    }
652
+	else
653
+	{
654
+		if (++error_count == MAX_ERROR_COUNT)
655
+		    app_start();
656
+    }
657
+}
658
+
659
+#ifdef ADABOOT
660
+
661
+void flash_led(uint8_t count)
662
+{
663
+    /* flash onboard LED count times to signal entering of bootloader */
664
+	/* l needs to be volatile or the delay loops below might get      */
665
+	/* optimized away if compiling with optimizations (DAM).          */
666
+	
667
+    volatile uint32_t l;
668
+
669
+    if (count == 0) {
670
+      count = ADABOOT;
671
+    }
672
+    
673
+
674
+	int8_t i;
675
+    for (i = 0; i < count; ++i) {
676
+		LED_PORT |= _BV(LED);					// LED on
677
+		for(l = 0; l < (F_CPU / 1000); ++l);		// delay NGvalue was 1000 for both loops - BBR
678
+		LED_PORT &= ~_BV(LED);					// LED off
679
+		for(l = 0; l < (F_CPU / 250); ++l);		// delay asymmteric for ADA BOOT BBR 
680
+	}
681
+
682
+	for(l = 0; l < (F_CPU / 100); ++l);		    // pause ADA BOOT BBR 
683
+		
684
+}
685
+
686
+#else
687
+
688
+void flash_led(uint8_t count)
689
+{
690
+    /* flash onboard LED three times to signal entering of bootloader */
691
+	/* l needs to be volatile or the delay loops below might get
692
+	optimized away if compiling with optimizations (DAM). */
693
+    volatile uint32_t l;
694
+
695
+    if (count == 0) {
696
+      count = 3;
697
+    }
698
+    
699
+	int8_t i;
700
+    for (i = 0; i < count; ++i) {
701
+		LED_PORT |= _BV(LED);
702
+		for(l = 0; l < (F_CPU / 1000); ++l);
703
+		LED_PORT &= ~_BV(LED);
704
+		for(l = 0; l < (F_CPU / 1000); ++l); 
705
+	}
706
+		
707
+}
708
+
709
+
710
+#endif
711
+
712
+
713
+/* end of file ATmegaBOOT.c */

+ 121
- 0
ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT_324P.hex Dosyayı Görüntüle

@@ -0,0 +1,121 @@
1
+:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
2
+:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
3
+:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
4
+:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
5
+:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
6
+:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
7
+:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
8
+:10F870000C945B7C0C945B7C0C945B7C11241FBE11
9
+:10F88000CFEFD8E0DEBFCDBF11E0A0E0B1E0E6E60B
10
+:10F89000FFEF02C005900D92A030B107D9F712E03A
11
+:10F8A000A0E0B1E001C01D92A930B107E1F70E94CC
12
+:10F8B000537D0C94B27F0C94007CCF93DF93CDB733
13
+:10F8C000DEB724970FB6F894DEBF0FBECDBF8823F6
14
+:10F8D00009F481E020E0482F55274115510509F42E
15
+:10F8E0003DC0289A19821A821B821C820BC0898112
16
+:10F8F0009A81AB81BC810196A11DB11D89839A8338
17
+:10F90000AB83BC8389819A81AB81BC8180589E4343
18
+:10F91000A040B04060F3289819821A821B821C8292
19
+:10F920000BC089819A81AB81BC810196A11DB11D5B
20
+:10F9300089839A83AB83BC8389819A81AB81BC81A3
21
+:10F9400080509A4FA040B04060F32F5F822F9927DC
22
+:10F9500087FD9095841795070CF4C3CF19821A82FE
23
+:10F960001B821C8289819A81AB81BC818050914726
24
+:10F97000A240B040A0F489819A81AB81BC810196FC
25
+:10F98000A11DB11D89839A83AB83BC8389819A8130
26
+:10F99000AB81BC8180509147A240B04060F3249677
27
+:10F9A0000FB6F894DEBF0FBECDBFDF91CF910895A3
28
+:10F9B000EF92FF920F931F93EE24FF248701289864
29
+:10F9C0008091C00087FD17C00894E11CF11C011D47
30
+:10F9D000111D81E0E81689E0F8068DE3080780E054
31
+:10F9E000180770F3E0910001F091010109958091F1
32
+:10F9F000C00087FFE9CF289A8091C600992787FD2C
33
+:10FA000090951F910F91FF90EF900895982F8091FE
34
+:10FA1000C00085FFFCCF9093C60008950E94D87C5B
35
+:10FA2000803271F0809102018F5F809302018530F6
36
+:10FA300009F00895E0910001F09101010995089500
37
+:10FA400084E10E94067D80E10E94067D0895CF93A7
38
+:10FA5000C82F0E94D87C803241F0809102018F5FD4
39
+:10FA600080930201853081F40AC084E10E94067D02
40
+:10FA70008C2F0E94067D80E10E94067D05C0E091EA
41
+:10FA80000001F09101010995CF910895282F90E090
42
+:10FA900007C08091C0008823E4F78091C6009F5F73
43
+:10FAA0009217B8F30895CFEFD8E0DEBFCDBF0000C6
44
+:10FAB00094B714BE809160008861809360001092BA
45
+:10FAC000600091FF74C189E18093C4001092C50069
46
+:10FAD00088E18093C10086E08093C2005098589AD4
47
+:10FAE000209A83E00E945D7C81E00E945D7C0E9400
48
+:10FAF000D87C8033B9F18133C1F1803409F456C028
49
+:10FB0000813409F45CC0823409F46EC0853409F490
50
+:10FB100071C0803539F1813509F4F3C0823511F1B6
51
+:10FB2000853509F4D3C0863509F4CBC0843609F491
52
+:10FB300065C0843709F4EBC0853709F4D2C0863735
53
+:10FB400009F44AC0809102018F5F809302018530E1
54
+:10FB500071F6E0910001F091010109950E94D87CB5
55
+:10FB6000803349F60E940E7DC2CF0E94D87CC82FF8
56
+:10FB7000803241F784E10E94067D81E40E94067D87
57
+:10FB800086E50E94067D82E50E94067D8C2F0E94FC
58
+:10FB9000067D89E40E94067D83E50E94067D80E55E
59
+:10FBA0000E94067D80E10E94067DA1CF0E94D87C44
60
+:10FBB0008638C0F20E94D87C0E940E7D98CF0E94A9
61
+:10FBC000D87C803809F407C1813809F400C1823833
62
+:10FBD00009F4F9C0883921F080E00E94277D87CFA1
63
+:10FBE00083E00E94277D83CF84E10E94467D0E94AE
64
+:10FBF0000E7D7DCF85E00E94467DF9CF0E94D87CA6
65
+:10FC0000809306020E94D87C8093050280910802AE
66
+:10FC10008E7F809308020E94D87C853409F44BC003
67
+:10FC2000E5E0F1E0119281E0E438F807D9F3D0F390
68
+:10FC3000C0E0D0E0809105029091060218161906E6
69
+:10FC400078F405E011E00E94D87CF80181938F01DF
70
+:10FC500021968091050290910602C817D90798F362
71
+:10FC60000E94D87C803209F06DCF8091080280FF1D
72
+:10FC7000B6C0C0E0D0E02091050230910602121615
73
+:10FC80001306B8F4E0910301F0910401A5E0B1E09E
74
+:10FC9000F999FECFF2BDE1BD8D9180BDFA9AF99A36
75
+:10FCA00031962196C217D30798F3F0930401E0939D
76
+:10FCB000030184E175CF809108028160809308027E
77
+:10FCC000AFCF84E00E94467D80E087CF0E94D87C41
78
+:10FCD000809303010E94D87C809304010E940E7DD2
79
+:10FCE00006CF0E94D87C803209F02CCF84E10E949C
80
+:10FCF000067D8EE10E94067D85E90E94067D88E0F2
81
+:10FD00004FCF0E940E7D88E080936000FFCF0E945D
82
+:10FD1000D87C809306020E94D87C809305020E94C2
83
+:10FD2000D87C853409F449C0809108028E7F809385
84
+:10FD300008028091030190910401880F991F90930C
85
+:10FD40000401809303010E94D87C803209F0CFCE59
86
+:10FD500084E10E94067DC0E0D0E020910502309150
87
+:10FD600006021216130608F01DCFE0910301F09170
88
+:10FD700004018091080280FF96C0F999FECFF2BD80
89
+:10FD8000E1BDF89A80B50E94067DE0910301F091F3
90
+:10FD900004013196F0930401E093030120910502E0
91
+:10FDA000309106022196C217D30718F3FBCEE091DB
92
+:10FDB0000001F0910101099586CE809108028160D1
93
+:10FDC00080930802C0CF80E10E94277D90CE81E021
94
+:10FDD0000E94277D8CCE82E00E94277D88CE809174
95
+:10FDE000030190910401880F991F9093040180935F
96
+:10FDF00003018091050280FF09C080910502909166
97
+:10FE0000060201969093060280930502F999FECFAF
98
+:10FE10001127E0910301F0910401C5E0D1E0809148
99
+:10FE2000050290910602103091F400915700017084
100
+:10FE30000130D9F303E000935700E8950091570093
101
+:10FE400001700130D9F301E100935700E895099062
102
+:10FE500019900091570001700130D9F301E000932F
103
+:10FE60005700E8951395103898F011270091570026
104
+:10FE700001700130D9F305E000935700E895009137
105
+:10FE8000570001700130D9F301E100935700E89564
106
+:10FE90003296029709F0C7CF103011F00296E5CFE5
107
+:10FEA000112484E17DCE869580FF06C03196F093C3
108
+:10FEB0000401E093030176CF84910E94067D209196
109
+:10FEC000050230910602E0910301F0910401EECFAA
110
+:10FED0001F93CF930E94D87CC82F0E94067D0E945A
111
+:10FEE000D87C182F0E94067DC1362CF0C7551136DC
112
+:10FEF0003CF0175508C0C033D4F3C0531136CCF7CB
113
+:10FF000010330CF01053C295C07FC10F8C2F99276E
114
+:10FF100087FD9095CF911F910895CF93282F992712
115
+:10FF200087FD9095807F907095958795959587959D
116
+:10FF300095958795959587958A303CF0895AC22F7B
117
+:10FF4000CF70CA303CF0C95A06C0805DC22FCF7056
118
+:10FF5000CA30CCF7C05D0E94067D8C2F0E94067DC2
119
+:06FF6000CF910895FFCFD0
120
+:040000030000F80001
121
+:00000001FF

+ 120
- 0
ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT_644.hex Dosyayı Görüntüle

@@ -0,0 +1,120 @@
1
+:10F800000C94387C0C94557C0C94557C0C94557C51
2
+:10F810000C94557C0C94557C0C94557C0C94557C24
3
+:10F820000C94557C0C94557C0C94557C0C94557C14
4
+:10F830000C94557C0C94557C0C94557C0C94557C04
5
+:10F840000C94557C0C94557C0C94557C0C94557CF4
6
+:10F850000C94557C0C94557C0C94557C0C94557CE4
7
+:10F860000C94557C0C94557C0C94557C0C94557CD4
8
+:10F8700011241FBECFEFD0E1DEBFCDBF11E0A0E06D
9
+:10F88000B1E0EAE5FFEF02C005900D92A030B107AC
10
+:10F89000D9F712E0A0E0B1E001C01D92A930B10794
11
+:10F8A000E1F70E944D7D0C94AC7F0C94007CCF93CB
12
+:10F8B000DF93CDB7DEB724970FB6F894DEBF0FBE47
13
+:10F8C000CDBF882309F481E020E0482F552741155A
14
+:10F8D000510509F43DC0289A19821A821B821C82A4
15
+:10F8E0000BC089819A81AB81BC810196A11DB11D9C
16
+:10F8F00089839A83AB83BC8389819A81AB81BC81E4
17
+:10F9000080589E43A040B04060F3289819821A8224
18
+:10F910001B821C820BC089819A81AB81BC810196BC
19
+:10F92000A11DB11D89839A83AB83BC8389819A8190
20
+:10F93000AB81BC8180509A4FA040B04060F32F5FF4
21
+:10F94000822F992787FD9095841795070CF4C3CFD4
22
+:10F9500019821A821B821C8289819A81AB81BC81A7
23
+:10F9600080509147A240B040A0F489819A81AB8138
24
+:10F97000BC810196A11DB11D89839A83AB83BC8391
25
+:10F9800089819A81AB81BC8180509147A240B0406F
26
+:10F9900060F324960FB6F894DEBF0FBECDBFDF91A3
27
+:10F9A000CF910895EF92FF920F931F93EE24FF24BF
28
+:10F9B000870128988091C00087FD17C00894E11C3A
29
+:10F9C000F11C011D111D81E0E81689E0F8068DE3A8
30
+:10F9D000080780E0180770F3E0910001F091010141
31
+:10F9E00009958091C00087FFE9CF289A8091C600D1
32
+:10F9F000992787FD90951F910F91FF90EF900895A3
33
+:10FA0000982F8091C00085FFFCCF9093C600089589
34
+:10FA10000E94D27C803271F0809102018F5F8093CE
35
+:10FA20000201853009F00895E0910001F091010193
36
+:10FA30000995089584E10E94007D80E10E94007D87
37
+:10FA40000895CF93C82F0E94D27C803241F08091DC
38
+:10FA500002018F5F80930201853081F40AC084E146
39
+:10FA60000E94007D8C2F0E94007D80E10E94007D1D
40
+:10FA700005C0E0910001F09101010995CF91089531
41
+:10FA8000282F90E007C08091C0008823E4F7809180
42
+:10FA9000C6009F5F9217B8F30895CFEFD0E1DEBFA5
43
+:10FAA000CDBF000094B714BE809160008861809340
44
+:10FAB00060001092600091FF74C189E18093C400DE
45
+:10FAC0001092C50088E18093C10086E08093C20057
46
+:10FAD0005098589A209A83E00E94577C81E00E94B7
47
+:10FAE000577C0E94D27C8033B9F18133C1F18034DC
48
+:10FAF00009F456C0813409F45CC0823409F46EC044
49
+:10FB0000853409F471C0803539F1813509F4F3C0C9
50
+:10FB1000823511F1853509F4D3C0863509F4CBC09F
51
+:10FB2000843609F465C0843709F4EBC0853709F4DD
52
+:10FB3000D2C0863709F44AC0809102018F5F80935A
53
+:10FB40000201853071F6E0910001F0910101099503
54
+:10FB50000E94D27C803349F60E94087DC2CF0E9469
55
+:10FB6000D27CC82F803241F784E10E94007D81E47D
56
+:10FB70000E94007D86E50E94007D82E50E94007D56
57
+:10FB80008C2F0E94007D89E40E94007D83E50E9405
58
+:10FB9000007D80E50E94007D80E10E94007DA1CF74
59
+:10FBA0000E94D27C8638C0F20E94D27C0E94087DDE
60
+:10FBB00098CF0E94D27C803809F407C1813809F4BB
61
+:10FBC00000C1823809F4F9C0883921F080E00E9430
62
+:10FBD000217D87CF83E00E94217D83CF84E10E9435
63
+:10FBE000407D0E94087D7DCF85E00E94407DF9CF59
64
+:10FBF0000E94D27C809306020E94D27C80930502F0
65
+:10FC0000809108028E7F809308020E94D27C853406
66
+:10FC100009F44BC0E5E0F1E0119281E0E438F80727
67
+:10FC2000D9F3D0F3C0E0D0E08091050290910602B4
68
+:10FC30001816190678F405E011E00E94D27CF8014C
69
+:10FC400081938F0121968091050290910602C81739
70
+:10FC5000D90798F30E94D27C803209F06DCF809151
71
+:10FC6000080280FFB6C0C0E0D0E0209105023091CC
72
+:10FC7000060212161306B8F4E0910301F091040194
73
+:10FC8000A5E0B1E0F999FECFF2BDE1BD8D9180BD57
74
+:10FC9000FA9AF99A31962196C217D30798F3F093FE
75
+:10FCA0000401E093030184E175CF80910802816033
76
+:10FCB00080930802AFCF84E00E94407D80E087CF30
77
+:10FCC0000E94D27C809303010E94D27C8093040125
78
+:10FCD0000E94087D06CF0E94D27C803209F02CCF92
79
+:10FCE00084E10E94007D8EE10E94007D86E90E94F1
80
+:10FCF000007D89E04FCF0E94087D88E080936000FE
81
+:10FD0000FFCF0E94D27C809306020E94D27C809317
82
+:10FD100005020E94D27C853409F449C08091080212
83
+:10FD20008E7F809308028091030190910401880FD7
84
+:10FD3000991F90930401809303010E94D27C80322A
85
+:10FD400009F0CFCE84E10E94007DC0E0D0E0209198
86
+:10FD50000502309106021216130608F01DCFE0913D
87
+:10FD60000301F09104018091080280FF96C0F99987
88
+:10FD7000FECFF2BDE1BDF89A80B50E94007DE09112
89
+:10FD80000301F09104013196F0930401E093030123
90
+:10FD900020910502309106022196C217D30718F36D
91
+:10FDA000FBCEE0910001F0910101099586CE809192
92
+:10FDB0000802816080930802C0CF80E10E94217D0B
93
+:10FDC00090CE81E00E94217D8CCE82E00E94217D38
94
+:10FDD00088CE8091030190910401880F991F909320
95
+:10FDE0000401809303018091050280FF09C0809186
96
+:10FDF00005029091060201969093060280930502F7
97
+:10FE0000F999FECF1127E0910301F0910401C5E0BB
98
+:10FE1000D1E08091050290910602103091F400919A
99
+:10FE2000570001700130D9F303E000935700E895C3
100
+:10FE30000091570001700130D9F301E100935700A0
101
+:10FE4000E895099019900091570001700130D9F39D
102
+:10FE500001E000935700E8951395103898F01127AA
103
+:10FE60000091570001700130D9F305E0009357006D
104
+:10FE7000E8950091570001700130D9F301E100933A
105
+:10FE80005700E8953296029709F0C7CF103011F06D
106
+:10FE90000296E5CF112484E17DCE869580FF06C0D1
107
+:10FEA0003196F0930401E093030176CF84910E9490
108
+:10FEB000007D2091050230910602E0910301F0914E
109
+:10FEC0000401EECF1F93CF930E94D27CC82F0E94D3
110
+:10FED000007D0E94D27C182F0E94007DC1362CF03C
111
+:10FEE000C75511363CF0175508C0C033D4F3C05382
112
+:10FEF0001136CCF710330CF01053C295C07FC10FF0
113
+:10FF00008C2F992787FD9095CF911F910895CF93BE
114
+:10FF1000282F992787FD9095807F907095958795DC
115
+:10FF20009595879595958795959587958A303CF019
116
+:10FF3000895AC22FCF70CA303CF0C95A06C0805DC2
117
+:10FF4000C22FCF70CA30CCF7C05D0E94007D8C2FCD
118
+:0AFF50000E94007DCF910895FFCFBD
119
+:040000030000F80001
120
+:00000001FF

+ 121
- 0
ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/ATmegaBOOT_644P.hex Dosyayı Görüntüle

@@ -0,0 +1,121 @@
1
+:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
2
+:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
3
+:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
4
+:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
5
+:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
6
+:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
7
+:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
8
+:10F870000C945B7C0C945B7C0C945B7C11241FBE11
9
+:10F88000CFEFD0E1DEBFCDBF11E0A0E0B1E0E6E612
10
+:10F89000FFEF02C005900D92A030B107D9F712E03A
11
+:10F8A000A0E0B1E001C01D92A930B107E1F70E94CC
12
+:10F8B000537D0C94B27F0C94007CCF93DF93CDB733
13
+:10F8C000DEB724970FB6F894DEBF0FBECDBF8823F6
14
+:10F8D00009F481E020E0482F55274115510509F42E
15
+:10F8E0003DC0289A19821A821B821C820BC0898112
16
+:10F8F0009A81AB81BC810196A11DB11D89839A8338
17
+:10F90000AB83BC8389819A81AB81BC8180589E4343
18
+:10F91000A040B04060F3289819821A821B821C8292
19
+:10F920000BC089819A81AB81BC810196A11DB11D5B
20
+:10F9300089839A83AB83BC8389819A81AB81BC81A3
21
+:10F9400080509A4FA040B04060F32F5F822F9927DC
22
+:10F9500087FD9095841795070CF4C3CF19821A82FE
23
+:10F960001B821C8289819A81AB81BC818050914726
24
+:10F97000A240B040A0F489819A81AB81BC810196FC
25
+:10F98000A11DB11D89839A83AB83BC8389819A8130
26
+:10F99000AB81BC8180509147A240B04060F3249677
27
+:10F9A0000FB6F894DEBF0FBECDBFDF91CF910895A3
28
+:10F9B000EF92FF920F931F93EE24FF248701289864
29
+:10F9C0008091C00087FD17C00894E11CF11C011D47
30
+:10F9D000111D81E0E81689E0F8068DE3080780E054
31
+:10F9E000180770F3E0910001F091010109958091F1
32
+:10F9F000C00087FFE9CF289A8091C600992787FD2C
33
+:10FA000090951F910F91FF90EF900895982F8091FE
34
+:10FA1000C00085FFFCCF9093C60008950E94D87C5B
35
+:10FA2000803271F0809102018F5F809302018530F6
36
+:10FA300009F00895E0910001F09101010995089500
37
+:10FA400084E10E94067D80E10E94067D0895CF93A7
38
+:10FA5000C82F0E94D87C803241F0809102018F5FD4
39
+:10FA600080930201853081F40AC084E10E94067D02
40
+:10FA70008C2F0E94067D80E10E94067D05C0E091EA
41
+:10FA80000001F09101010995CF910895282F90E090
42
+:10FA900007C08091C0008823E4F78091C6009F5F73
43
+:10FAA0009217B8F30895CFEFD0E1DEBFCDBF0000CD
44
+:10FAB00094B714BE809160008861809360001092BA
45
+:10FAC000600091FF74C189E18093C4001092C50069
46
+:10FAD00088E18093C10086E08093C2005098589AD4
47
+:10FAE000209A83E00E945D7C81E00E945D7C0E9400
48
+:10FAF000D87C8033B9F18133C1F1803409F456C028
49
+:10FB0000813409F45CC0823409F46EC0853409F490
50
+:10FB100071C0803539F1813509F4F3C0823511F1B6
51
+:10FB2000853509F4D3C0863509F4CBC0843609F491
52
+:10FB300065C0843709F4EBC0853709F4D2C0863735
53
+:10FB400009F44AC0809102018F5F809302018530E1
54
+:10FB500071F6E0910001F091010109950E94D87CB5
55
+:10FB6000803349F60E940E7DC2CF0E94D87CC82FF8
56
+:10FB7000803241F784E10E94067D81E40E94067D87
57
+:10FB800086E50E94067D82E50E94067D8C2F0E94FC
58
+:10FB9000067D89E40E94067D83E50E94067D80E55E
59
+:10FBA0000E94067D80E10E94067DA1CF0E94D87C44
60
+:10FBB0008638C0F20E94D87C0E940E7D98CF0E94A9
61
+:10FBC000D87C803809F407C1813809F400C1823833
62
+:10FBD00009F4F9C0883921F080E00E94277D87CFA1
63
+:10FBE00083E00E94277D83CF84E10E94467D0E94AE
64
+:10FBF0000E7D7DCF85E00E94467DF9CF0E94D87CA6
65
+:10FC0000809306020E94D87C8093050280910802AE
66
+:10FC10008E7F809308020E94D87C853409F44BC003
67
+:10FC2000E5E0F1E0119281E0E438F807D9F3D0F390
68
+:10FC3000C0E0D0E0809105029091060218161906E6
69
+:10FC400078F405E011E00E94D87CF80181938F01DF
70
+:10FC500021968091050290910602C817D90798F362
71
+:10FC60000E94D87C803209F06DCF8091080280FF1D
72
+:10FC7000B6C0C0E0D0E02091050230910602121615
73
+:10FC80001306B8F4E0910301F0910401A5E0B1E09E
74
+:10FC9000F999FECFF2BDE1BD8D9180BDFA9AF99A36
75
+:10FCA00031962196C217D30798F3F0930401E0939D
76
+:10FCB000030184E175CF809108028160809308027E
77
+:10FCC000AFCF84E00E94467D80E087CF0E94D87C41
78
+:10FCD000809303010E94D87C809304010E940E7DD2
79
+:10FCE00006CF0E94D87C803209F02CCF84E10E949C
80
+:10FCF000067D8EE10E94067D86E90E94067D8AE0EF
81
+:10FD00004FCF0E940E7D88E080936000FFCF0E945D
82
+:10FD1000D87C809306020E94D87C809305020E94C2
83
+:10FD2000D87C853409F449C0809108028E7F809385
84
+:10FD300008028091030190910401880F991F90930C
85
+:10FD40000401809303010E94D87C803209F0CFCE59
86
+:10FD500084E10E94067DC0E0D0E020910502309150
87
+:10FD600006021216130608F01DCFE0910301F09170
88
+:10FD700004018091080280FF96C0F999FECFF2BD80
89
+:10FD8000E1BDF89A80B50E94067DE0910301F091F3
90
+:10FD900004013196F0930401E093030120910502E0
91
+:10FDA000309106022196C217D30718F3FBCEE091DB
92
+:10FDB0000001F0910101099586CE809108028160D1
93
+:10FDC00080930802C0CF80E10E94277D90CE81E021
94
+:10FDD0000E94277D8CCE82E00E94277D88CE809174
95
+:10FDE000030190910401880F991F9093040180935F
96
+:10FDF00003018091050280FF09C080910502909166
97
+:10FE0000060201969093060280930502F999FECFAF
98
+:10FE10001127E0910301F0910401C5E0D1E0809148
99
+:10FE2000050290910602103091F400915700017084
100
+:10FE30000130D9F303E000935700E8950091570093
101
+:10FE400001700130D9F301E100935700E895099062
102
+:10FE500019900091570001700130D9F301E000932F
103
+:10FE60005700E8951395103898F011270091570026
104
+:10FE700001700130D9F305E000935700E895009137
105
+:10FE8000570001700130D9F301E100935700E89564
106
+:10FE90003296029709F0C7CF103011F00296E5CFE5
107
+:10FEA000112484E17DCE869580FF06C03196F093C3
108
+:10FEB0000401E093030176CF84910E94067D209196
109
+:10FEC000050230910602E0910301F0910401EECFAA
110
+:10FED0001F93CF930E94D87CC82F0E94067D0E945A
111
+:10FEE000D87C182F0E94067DC1362CF0C7551136DC
112
+:10FEF0003CF0175508C0C033D4F3C0531136CCF7CB
113
+:10FF000010330CF01053C295C07FC10F8C2F99276E
114
+:10FF100087FD9095CF911F910895CF93282F992712
115
+:10FF200087FD9095807F907095958795959587959D
116
+:10FF300095958795959587958A303CF0895AC22F7B
117
+:10FF4000CF70CA303CF0C95A06C0805DC22FCF7056
118
+:10FF5000CA30CCF7C05D0E94067D8C2F0E94067DC2
119
+:06FF6000CF910895FFCFD0
120
+:040000030000F80001
121
+:00000001FF

+ 56
- 0
ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/Makefile Dosyayı Görüntüle

@@ -0,0 +1,56 @@
1
+# Makefile for ATmegaBOOT
2
+# E.Lins, 18.7.2005
3
+# $Id$
4
+
5
+
6
+# program name should not be changed...
7
+PROGRAM    = ATmegaBOOT_644P
8
+
9
+# enter the target CPU frequency
10
+AVR_FREQ   = 16000000L
11
+
12
+MCU_TARGET = atmega644p
13
+LDSECTION  = --section-start=.text=0xF800
14
+
15
+OBJ        = $(PROGRAM).o
16
+OPTIMIZE   = -O2
17
+
18
+DEFS       = 
19
+LIBS       = 
20
+
21
+CC         = avr-gcc
22
+
23
+
24
+# Override is only needed by avr-lib build system.
25
+
26
+override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
27
+override LDFLAGS       = -Wl,$(LDSECTION)
28
+#override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
29
+
30
+OBJCOPY        = avr-objcopy
31
+OBJDUMP        = avr-objdump
32
+
33
+all: CFLAGS += '-DMAX_TIME_COUNT=8000000L>>1' -DADABOOT
34
+all: $(PROGRAM).hex
35
+
36
+$(PROGRAM).hex: $(PROGRAM).elf
37
+	$(OBJCOPY) -j .text -j .data -O ihex $< $@
38
+	
39
+$(PROGRAM).elf: $(OBJ)
40
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
41
+	
42
+$(OBJ): ATmegaBOOT.c
43
+	avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -O2 -Wall -mmcu=$(MCU_TARGET) ATmegaBOOT.c -o $(PROGRAM).o
44
+
45
+%.lst: %.elf
46
+	$(OBJDUMP) -h -S $< > $@
47
+
48
+%.srec: %.elf
49
+	$(OBJCOPY) -j .text -j .data -O srec $< $@
50
+
51
+%.bin: %.elf
52
+	$(OBJCOPY) -j .text -j .data -O binary $< $@
53
+
54
+clean:
55
+	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
56
+	

+ 3
- 0
ArduinoAddons/Arduino_0.xx/Gen6/bootloaders/atmega644p/README.txt Dosyayı Görüntüle

@@ -0,0 +1,3 @@
1
+Note: This bootloader support ATmega644, ATmega644P and ATmega324P.
2
+To build, set PROGRAM and MCU_TARGET in the Makefile according to your target device.
3
+

+ 1
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Arduino.h Dosyayı Görüntüle

@@ -0,0 +1 @@
1
+    #include "WProgram.h"

+ 202
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/HardwareSerial.cpp Dosyayı Görüntüle

@@ -0,0 +1,202 @@
1
+/*
2
+  HardwareSerial.cpp - Hardware serial library for Wiring
3
+  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+  
19
+  Modified 23 November 2006 by David A. Mellis
20
+  Modified 28 September 2010 by Mark Sproul
21
+*/
22
+
23
+#include <stdlib.h>
24
+#include <stdio.h>
25
+#include <string.h>
26
+#include <inttypes.h>
27
+#include "wiring.h"
28
+#include "wiring_private.h"
29
+
30
+// this next line disables the entire HardwareSerial.cpp, 
31
+// this is so I can support Attiny series and any other chip without a uart
32
+#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
33
+
34
+#include "HardwareSerial.h"
35
+
36
+// Define constants and variables for buffering incoming serial data.  We're
37
+// using a ring buffer (I think), in which rx_buffer_head is the index of the
38
+// location to which to write the next incoming character and rx_buffer_tail
39
+// is the index of the location from which to read.
40
+#define RX_BUFFER_SIZE 128
41
+
42
+struct ring_buffer
43
+{
44
+  unsigned char buffer[RX_BUFFER_SIZE];
45
+  int head;
46
+  int tail;
47
+};
48
+
49
+ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
50
+
51
+inline void store_char(unsigned char c, ring_buffer *rx_buffer)
52
+{
53
+  int i = (unsigned int)(rx_buffer->head + 1) & (RX_BUFFER_SIZE -1);
54
+
55
+  // if we should be storing the received character into the location
56
+  // just before the tail (meaning that the head would advance to the
57
+  // current location of the tail), we're about to overflow the buffer
58
+  // and so we don't write the character or advance the head.
59
+  if (i != rx_buffer->tail) {
60
+    rx_buffer->buffer[rx_buffer->head] = c;
61
+    rx_buffer->head = i;
62
+  }
63
+}
64
+
65
+// fixed by Mark Sproul this is on the 644/644p
66
+//SIGNAL(SIG_USART_RECV)
67
+SIGNAL(USART0_RX_vect)
68
+{
69
+  unsigned char c  =  UDR0;
70
+  store_char(c, &rx_buffer);
71
+}
72
+
73
+
74
+// Constructors ////////////////////////////////////////////////////////////////
75
+
76
+HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
77
+  volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
78
+  volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
79
+  volatile uint8_t *udr,
80
+  uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
81
+{
82
+  _rx_buffer = rx_buffer;
83
+  _ubrrh = ubrrh;
84
+  _ubrrl = ubrrl;
85
+  _ucsra = ucsra;
86
+  _ucsrb = ucsrb;
87
+  _udr = udr;
88
+  _rxen = rxen;
89
+  _txen = txen;
90
+  _rxcie = rxcie;
91
+  _udre = udre;
92
+  _u2x = u2x;
93
+}
94
+
95
+// Public Methods //////////////////////////////////////////////////////////////
96
+
97
+void HardwareSerial::begin(long baud)
98
+{
99
+  uint16_t baud_setting;
100
+  bool use_u2x = true;
101
+
102
+#if F_CPU == 16000000UL
103
+  // hardcoded exception for compatibility with the bootloader shipped
104
+  // with the Duemilanove and previous boards and the firmware on the 8U2
105
+  // on the Uno and Mega 2560.
106
+  if (baud == 57600) {
107
+    use_u2x = false;
108
+  }
109
+#endif
110
+  
111
+  if (use_u2x) {
112
+    *_ucsra = 1 << _u2x;
113
+    baud_setting = (F_CPU / 4 / baud - 1) / 2;
114
+  } else {
115
+    *_ucsra = 0;
116
+    baud_setting = (F_CPU / 8 / baud - 1) / 2;
117
+  }
118
+
119
+  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
120
+  *_ubrrh = baud_setting >> 8;
121
+  *_ubrrl = baud_setting;
122
+
123
+  sbi(*_ucsrb, _rxen);
124
+  sbi(*_ucsrb, _txen);
125
+  sbi(*_ucsrb, _rxcie);
126
+}
127
+
128
+void HardwareSerial::end()
129
+{
130
+  cbi(*_ucsrb, _rxen);
131
+  cbi(*_ucsrb, _txen);
132
+  cbi(*_ucsrb, _rxcie);  
133
+}
134
+
135
+int HardwareSerial::available(void)
136
+{
137
+  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) & (RX_BUFFER_SIZE-1);
138
+}
139
+
140
+int HardwareSerial::peek(void)
141
+{
142
+  if (_rx_buffer->head == _rx_buffer->tail) {
143
+    return -1;
144
+  } else {
145
+    return _rx_buffer->buffer[_rx_buffer->tail];
146
+  }
147
+}
148
+
149
+int HardwareSerial::read(void)
150
+{
151
+  // if the head isn't ahead of the tail, we don't have any characters
152
+  if (_rx_buffer->head == _rx_buffer->tail) {
153
+    return -1;
154
+  } else {
155
+    unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
156
+    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) & (RX_BUFFER_SIZE-1);
157
+    return c;
158
+  }
159
+}
160
+
161
+void HardwareSerial::flush()
162
+{
163
+  // don't reverse this or there may be problems if the RX interrupt
164
+  // occurs after reading the value of rx_buffer_head but before writing
165
+  // the value to rx_buffer_tail; the previous value of rx_buffer_head
166
+  // may be written to rx_buffer_tail, making it appear as if the buffer
167
+  // don't reverse this or there may be problems if the RX interrupt
168
+  // occurs after reading the value of rx_buffer_head but before writing
169
+  // the value to rx_buffer_tail; the previous value of rx_buffer_head
170
+  // may be written to rx_buffer_tail, making it appear as if the buffer
171
+  // were full, not empty.
172
+  _rx_buffer->head = _rx_buffer->tail;
173
+}
174
+
175
+//
176
+// Drakelive  2012-09-04
177
+//
178
+#if ARDUINO >= 100 
179
+	size_t  HardwareSerial::write(uint8_t c)
180
+	{
181
+	  while (!((*_ucsra) & (1 << _udre)))
182
+	    ;
183
+
184
+	  *_udr = c;
185
+	}
186
+#else
187
+	void HardwareSerial::write(uint8_t c)
188
+	{
189
+	  while (!((*_ucsra) & (1 << _udre)))
190
+		 ;
191
+
192
+	  *_udr = c;
193
+	}        
194
+#endif
195
+
196
+// Drakelive  2012-09-04
197
+
198
+// Preinstantiate Objects //////////////////////////////////////////////////////
199
+HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
200
+
201
+#endif // whole file
202
+

+ 87
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/HardwareSerial.h Dosyayı Görüntüle

@@ -0,0 +1,87 @@
1
+/*
2
+  HardwareSerial.h - Hardware serial library for Wiring
3
+  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+
19
+  Modified 28 September 2010 by Mark Sproul
20
+*/
21
+
22
+#ifndef HardwareSerial_h
23
+#define HardwareSerial_h
24
+
25
+#include <inttypes.h>
26
+
27
+#include "Stream.h"
28
+
29
+struct ring_buffer;
30
+
31
+class HardwareSerial : public Stream
32
+{
33
+  private:
34
+    ring_buffer *_rx_buffer;
35
+    volatile uint8_t *_ubrrh;
36
+    volatile uint8_t *_ubrrl;
37
+    volatile uint8_t *_ucsra;
38
+    volatile uint8_t *_ucsrb;
39
+    volatile uint8_t *_udr;
40
+    uint8_t _rxen;
41
+    uint8_t _txen;
42
+    uint8_t _rxcie;
43
+    uint8_t _udre;
44
+    uint8_t _u2x;
45
+  public:
46
+    HardwareSerial(ring_buffer *rx_buffer,
47
+      volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
48
+      volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
49
+      volatile uint8_t *udr,
50
+      uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
51
+    void begin(long);
52
+    void end();
53
+    virtual int available(void);
54
+    virtual int peek(void);
55
+    virtual int read(void);
56
+    virtual void flush(void);
57
+    
58
+    //
59
+    // Drakelive  2012-09-04
60
+    //
61
+    #if ARDUINO >= 100 
62
+        virtual size_t write(uint8_t);
63
+    #else
64
+        virtual void write(uint8_t);
65
+    #endif
66
+     
67
+    // Drakelive  2012-09-04
68
+
69
+    using Print::write; // pull in write(str) and write(buf, size) from Print
70
+};
71
+
72
+#if defined(UBRRH) || defined(UBRR0H)
73
+  extern HardwareSerial Serial;
74
+#elif defined(USBCON)
75
+  #include "usb_api.h"
76
+#endif
77
+#if defined(UBRR1H)
78
+  extern HardwareSerial Serial1;
79
+#endif
80
+#if defined(UBRR2H)
81
+  extern HardwareSerial Serial2;
82
+#endif
83
+#if defined(UBRR3H)
84
+  extern HardwareSerial Serial3;
85
+#endif
86
+
87
+#endif

+ 220
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Print.cpp Dosyayı Görüntüle

@@ -0,0 +1,220 @@
1
+/*
2
+ Print.cpp - Base class that provides print() and println()
3
+ Copyright (c) 2008 David A. Mellis.  All right reserved.
4
+ 
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+ 
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+ 
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ 
19
+ Modified 23 November 2006 by David A. Mellis
20
+ */
21
+
22
+#include <stdlib.h>
23
+#include <stdio.h>
24
+#include <string.h>
25
+#include <math.h>
26
+#include "wiring.h"
27
+
28
+#include "Print.h"
29
+
30
+// Public Methods //////////////////////////////////////////////////////////////
31
+
32
+/* default implementation: may be overridden */
33
+void Print::write(const char *str)
34
+{
35
+  while (*str)
36
+    write(*str++);
37
+}
38
+
39
+/* default implementation: may be overridden */
40
+void Print::write(const uint8_t *buffer, size_t size)
41
+{
42
+  while (size--)
43
+    write(*buffer++);
44
+}
45
+
46
+void Print::print(const String &s)
47
+{
48
+  for (int i = 0; i < s.length(); i++) {
49
+    write(s[i]);
50
+  }
51
+}
52
+
53
+void Print::print(const char str[])
54
+{
55
+  write(str);
56
+}
57
+
58
+void Print::print(char c, int base)
59
+{
60
+  print((long) c, base);
61
+}
62
+
63
+void Print::print(unsigned char b, int base)
64
+{
65
+  print((unsigned long) b, base);
66
+}
67
+
68
+void Print::print(int n, int base)
69
+{
70
+  print((long) n, base);
71
+}
72
+
73
+void Print::print(unsigned int n, int base)
74
+{
75
+  print((unsigned long) n, base);
76
+}
77
+
78
+void Print::print(long n, int base)
79
+{
80
+  if (base == 0) {
81
+    write(n);
82
+  } else if (base == 10) {
83
+    if (n < 0) {
84
+      print('-');
85
+      n = -n;
86
+    }
87
+    printNumber(n, 10);
88
+  } else {
89
+    printNumber(n, base);
90
+  }
91
+}
92
+
93
+void Print::print(unsigned long n, int base)
94
+{
95
+  if (base == 0) write(n);
96
+  else printNumber(n, base);
97
+}
98
+
99
+void Print::print(double n, int digits)
100
+{
101
+  printFloat(n, digits);
102
+}
103
+
104
+void Print::println(void)
105
+{
106
+  print('\r');
107
+  print('\n');  
108
+}
109
+
110
+void Print::println(const String &s)
111
+{
112
+  print(s);
113
+  println();
114
+}
115
+
116
+void Print::println(const char c[])
117
+{
118
+  print(c);
119
+  println();
120
+}
121
+
122
+void Print::println(char c, int base)
123
+{
124
+  print(c, base);
125
+  println();
126
+}
127
+
128
+void Print::println(unsigned char b, int base)
129
+{
130
+  print(b, base);
131
+  println();
132
+}
133
+
134
+void Print::println(int n, int base)
135
+{
136
+  print(n, base);
137
+  println();
138
+}
139
+
140
+void Print::println(unsigned int n, int base)
141
+{
142
+  print(n, base);
143
+  println();
144
+}
145
+
146
+void Print::println(long n, int base)
147
+{
148
+  print(n, base);
149
+  println();
150
+}
151
+
152
+void Print::println(unsigned long n, int base)
153
+{
154
+  print(n, base);
155
+  println();
156
+}
157
+
158
+void Print::println(double n, int digits)
159
+{
160
+  print(n, digits);
161
+  println();
162
+}
163
+
164
+// Private Methods /////////////////////////////////////////////////////////////
165
+
166
+void Print::printNumber(unsigned long n, uint8_t base)
167
+{
168
+  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
169
+  unsigned long i = 0;
170
+
171
+  if (n == 0) {
172
+    print('0');
173
+    return;
174
+  } 
175
+
176
+  while (n > 0) {
177
+    buf[i++] = n % base;
178
+    n /= base;
179
+  }
180
+
181
+  for (; i > 0; i--)
182
+    print((char) (buf[i - 1] < 10 ?
183
+      '0' + buf[i - 1] :
184
+      'A' + buf[i - 1] - 10));
185
+}
186
+
187
+void Print::printFloat(double number, uint8_t digits) 
188
+{ 
189
+  // Handle negative numbers
190
+  if (number < 0.0)
191
+  {
192
+     print('-');
193
+     number = -number;
194
+  }
195
+
196
+  // Round correctly so that print(1.999, 2) prints as "2.00"
197
+  double rounding = 0.5;
198
+  for (uint8_t i=0; i<digits; ++i)
199
+    rounding /= 10.0;
200
+  
201
+  number += rounding;
202
+
203
+  // Extract the integer part of the number and print it
204
+  unsigned long int_part = (unsigned long)number;
205
+  double remainder = number - (double)int_part;
206
+  print(int_part);
207
+
208
+  // Print the decimal point, but only if there are digits beyond
209
+  if (digits > 0)
210
+    print("."); 
211
+
212
+  // Extract digits from the remainder one at a time
213
+  while (digits-- > 0)
214
+  {
215
+    remainder *= 10.0;
216
+    int toPrint = int(remainder);
217
+    print(toPrint);
218
+    remainder -= toPrint; 
219
+  } 
220
+}

+ 77
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Print.h Dosyayı Görüntüle

@@ -0,0 +1,77 @@
1
+/*
2
+  Print.h - Base class that provides print() and println()
3
+  Copyright (c) 2008 David A. Mellis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef Print_h
21
+#define Print_h
22
+
23
+#include <inttypes.h>
24
+#include <stdio.h> // for size_t
25
+
26
+#include "WString.h"
27
+
28
+#define DEC 10
29
+#define HEX 16
30
+#define OCT 8
31
+#define BIN 2
32
+#define BYTE 0
33
+
34
+class Print
35
+{
36
+  private:
37
+    void printNumber(unsigned long, uint8_t);
38
+    void printFloat(double, uint8_t);
39
+  public:
40
+     
41
+    //
42
+    // Drakelive  2012-09-04
43
+    //
44
+    #if ARDUINO >= 100 
45
+        virtual size_t write(uint8_t) = 0;
46
+    #else
47
+        virtual void write(uint8_t) = 0;
48
+    #endif
49
+     
50
+    // Drakelive  2012-09-04     
51
+
52
+    virtual void write(const char *str);
53
+    virtual void write(const uint8_t *buffer, size_t size);
54
+    
55
+    void print(const String &);
56
+    void print(const char[]);
57
+    void print(char, int = BYTE);
58
+    void print(unsigned char, int = BYTE);
59
+    void print(int, int = DEC);
60
+    void print(unsigned int, int = DEC);
61
+    void print(long, int = DEC);
62
+    void print(unsigned long, int = DEC);
63
+    void print(double, int = 2);
64
+
65
+    void println(const String &s);
66
+    void println(const char[]);
67
+    void println(char, int = BYTE);
68
+    void println(unsigned char, int = BYTE);
69
+    void println(int, int = DEC);
70
+    void println(unsigned int, int = DEC);
71
+    void println(long, int = DEC);
72
+    void println(unsigned long, int = DEC);
73
+    void println(double, int = 2);
74
+    void println(void);
75
+};
76
+
77
+#endif

+ 35
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Stream.h Dosyayı Görüntüle

@@ -0,0 +1,35 @@
1
+/*
2
+  Stream.h - base class for character-based streams.
3
+  Copyright (c) 2010 David A. Mellis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef Stream_h
21
+#define Stream_h
22
+
23
+#include <inttypes.h>
24
+#include "Print.h"
25
+
26
+class Stream : public Print
27
+{
28
+  public:
29
+    virtual int available() = 0;
30
+    virtual int read() = 0;
31
+    virtual int peek() = 0;
32
+    virtual void flush() = 0;
33
+};
34
+
35
+#endif

+ 601
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/Tone.cpp Dosyayı Görüntüle

@@ -0,0 +1,601 @@
1
+/* Tone.cpp
2
+
3
+  A Tone Generator Library
4
+
5
+  Written by Brett Hagman
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General Public
18
+  License along with this library; if not, write to the Free Software
19
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
+
21
+Version Modified By Date     Comments
22
+------- ----------- -------- --------
23
+0001    B Hagman    09/08/02 Initial coding
24
+0002    B Hagman    09/08/18 Multiple pins
25
+0003    B Hagman    09/08/18 Moved initialization from constructor to begin()
26
+0004    B Hagman    09/09/26 Fixed problems with ATmega8
27
+0005    B Hagman    09/11/23 Scanned prescalars for best fit on 8 bit timers
28
+                    09/11/25 Changed pin toggle method to XOR
29
+                    09/11/25 Fixed timer0 from being excluded
30
+0006    D Mellis    09/12/29 Replaced objects with functions
31
+0007    M Sproul    10/08/29 Changed #ifdefs from cpu to register
32
+*************************************************/
33
+
34
+#include <avr/interrupt.h>
35
+#include <avr/pgmspace.h>
36
+#include "wiring.h"
37
+#include "pins_arduino.h"
38
+
39
+#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
40
+#define TCCR2A TCCR2
41
+#define TCCR2B TCCR2
42
+#define COM2A1 COM21
43
+#define COM2A0 COM20
44
+#define OCR2A OCR2
45
+#define TIMSK2 TIMSK
46
+#define OCIE2A OCIE2
47
+#define TIMER2_COMPA_vect TIMER2_COMP_vect
48
+#define TIMSK1 TIMSK
49
+#endif
50
+
51
+// timerx_toggle_count:
52
+//  > 0 - duration specified
53
+//  = 0 - stopped
54
+//  < 0 - infinitely (until stop() method called, or new play() called)
55
+
56
+#if !defined(__AVR_ATmega8__)
57
+volatile long timer0_toggle_count;
58
+volatile uint8_t *timer0_pin_port;
59
+volatile uint8_t timer0_pin_mask;
60
+#endif
61
+
62
+volatile long timer1_toggle_count;
63
+volatile uint8_t *timer1_pin_port;
64
+volatile uint8_t timer1_pin_mask;
65
+volatile long timer2_toggle_count;
66
+volatile uint8_t *timer2_pin_port;
67
+volatile uint8_t timer2_pin_mask;
68
+
69
+#if defined(TIMSK3)
70
+volatile long timer3_toggle_count;
71
+volatile uint8_t *timer3_pin_port;
72
+volatile uint8_t timer3_pin_mask;
73
+#endif
74
+
75
+#if defined(TIMSK4)
76
+volatile long timer4_toggle_count;
77
+volatile uint8_t *timer4_pin_port;
78
+volatile uint8_t timer4_pin_mask;
79
+#endif
80
+
81
+#if defined(TIMSK5)
82
+volatile long timer5_toggle_count;
83
+volatile uint8_t *timer5_pin_port;
84
+volatile uint8_t timer5_pin_mask;
85
+#endif
86
+
87
+
88
+// MLS: This does not make sense, the 3 options are the same
89
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
90
+
91
+#define AVAILABLE_TONE_PINS 1
92
+
93
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
94
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
95
+
96
+#elif defined(__AVR_ATmega8__)
97
+
98
+#define AVAILABLE_TONE_PINS 1
99
+
100
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
101
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
102
+
103
+#else
104
+
105
+#define AVAILABLE_TONE_PINS 1
106
+
107
+// Leave timer 0 to last.
108
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
109
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
110
+
111
+#endif
112
+
113
+
114
+
115
+static int8_t toneBegin(uint8_t _pin)
116
+{
117
+  int8_t _timer = -1;
118
+
119
+  // if we're already using the pin, the timer should be configured.  
120
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
121
+    if (tone_pins[i] == _pin) {
122
+      return pgm_read_byte(tone_pin_to_timer_PGM + i);
123
+    }
124
+  }
125
+  
126
+  // search for an unused timer.
127
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
128
+    if (tone_pins[i] == 255) {
129
+      tone_pins[i] = _pin;
130
+      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
131
+      break;
132
+    }
133
+  }
134
+  
135
+  if (_timer != -1)
136
+  {
137
+    // Set timer specific stuff
138
+    // All timers in CTC mode
139
+    // 8 bit timers will require changing prescalar values,
140
+    // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
141
+    switch (_timer)
142
+    {
143
+      #if defined(TCCR0A) && defined(TCCR0B)
144
+      case 0:
145
+        // 8 bit timer
146
+        TCCR0A = 0;
147
+        TCCR0B = 0;
148
+        bitWrite(TCCR0A, WGM01, 1);
149
+        bitWrite(TCCR0B, CS00, 1);
150
+        timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
151
+        timer0_pin_mask = digitalPinToBitMask(_pin);
152
+        break;
153
+      #endif
154
+
155
+      #if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12)
156
+      case 1:
157
+        // 16 bit timer
158
+        TCCR1A = 0;
159
+        TCCR1B = 0;
160
+        bitWrite(TCCR1B, WGM12, 1);
161
+        bitWrite(TCCR1B, CS10, 1);
162
+        timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
163
+        timer1_pin_mask = digitalPinToBitMask(_pin);
164
+        break;
165
+      #endif
166
+
167
+      #if defined(TCCR2A) && defined(TCCR2B)
168
+      case 2:
169
+        // 8 bit timer
170
+        TCCR2A = 0;
171
+        TCCR2B = 0;
172
+        bitWrite(TCCR2A, WGM21, 1);
173
+        bitWrite(TCCR2B, CS20, 1);
174
+        timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
175
+        timer2_pin_mask = digitalPinToBitMask(_pin);
176
+        break;
177
+      #endif
178
+
179
+      #if defined(TCCR3A) && defined(TCCR3B) &&  defined(TIMSK3)
180
+      case 3:
181
+        // 16 bit timer
182
+        TCCR3A = 0;
183
+        TCCR3B = 0;
184
+        bitWrite(TCCR3B, WGM32, 1);
185
+        bitWrite(TCCR3B, CS30, 1);
186
+        timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
187
+        timer3_pin_mask = digitalPinToBitMask(_pin);
188
+        break;
189
+      #endif
190
+
191
+      #if defined(TCCR4A) && defined(TCCR4B) &&  defined(TIMSK4)
192
+      case 4:
193
+        // 16 bit timer
194
+        TCCR4A = 0;
195
+        TCCR4B = 0;
196
+        #if defined(WGM42)
197
+          bitWrite(TCCR4B, WGM42, 1);
198
+        #elif defined(CS43)
199
+          #warning this may not be correct
200
+          // atmega32u4
201
+          bitWrite(TCCR4B, CS43, 1);
202
+        #endif
203
+        bitWrite(TCCR4B, CS40, 1);
204
+        timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
205
+        timer4_pin_mask = digitalPinToBitMask(_pin);
206
+        break;
207
+      #endif
208
+
209
+      #if defined(TCCR5A) && defined(TCCR5B) &&  defined(TIMSK5)
210
+      case 5:
211
+        // 16 bit timer
212
+        TCCR5A = 0;
213
+        TCCR5B = 0;
214
+        bitWrite(TCCR5B, WGM52, 1);
215
+        bitWrite(TCCR5B, CS50, 1);
216
+        timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
217
+        timer5_pin_mask = digitalPinToBitMask(_pin);
218
+        break;
219
+      #endif
220
+    }
221
+  }
222
+
223
+  return _timer;
224
+}
225
+
226
+
227
+
228
+// frequency (in hertz) and duration (in milliseconds).
229
+
230
+void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
231
+{
232
+  uint8_t prescalarbits = 0b001;
233
+  long toggle_count = 0;
234
+  uint32_t ocr = 0;
235
+  int8_t _timer;
236
+
237
+  _timer = toneBegin(_pin);
238
+
239
+  if (_timer >= 0)
240
+  {
241
+    // Set the pinMode as OUTPUT
242
+    pinMode(_pin, OUTPUT);
243
+    
244
+    // if we are using an 8 bit timer, scan through prescalars to find the best fit
245
+    if (_timer == 0 || _timer == 2)
246
+    {
247
+      ocr = F_CPU / frequency / 2 - 1;
248
+      prescalarbits = 0b001;  // ck/1: same for both timers
249
+      if (ocr > 255)
250
+      {
251
+        ocr = F_CPU / frequency / 2 / 8 - 1;
252
+        prescalarbits = 0b010;  // ck/8: same for both timers
253
+
254
+        if (_timer == 2 && ocr > 255)
255
+        {
256
+          ocr = F_CPU / frequency / 2 / 32 - 1;
257
+          prescalarbits = 0b011;
258
+        }
259
+
260
+        if (ocr > 255)
261
+        {
262
+          ocr = F_CPU / frequency / 2 / 64 - 1;
263
+          prescalarbits = _timer == 0 ? 0b011 : 0b100;
264
+
265
+          if (_timer == 2 && ocr > 255)
266
+          {
267
+            ocr = F_CPU / frequency / 2 / 128 - 1;
268
+            prescalarbits = 0b101;
269
+          }
270
+
271
+          if (ocr > 255)
272
+          {
273
+            ocr = F_CPU / frequency / 2 / 256 - 1;
274
+            prescalarbits = _timer == 0 ? 0b100 : 0b110;
275
+            if (ocr > 255)
276
+            {
277
+              // can't do any better than /1024
278
+              ocr = F_CPU / frequency / 2 / 1024 - 1;
279
+              prescalarbits = _timer == 0 ? 0b101 : 0b111;
280
+            }
281
+          }
282
+        }
283
+      }
284
+
285
+#if defined(TCCR0B)
286
+      if (_timer == 0)
287
+      {
288
+        TCCR0B = prescalarbits;
289
+      }
290
+      else
291
+#endif
292
+#if defined(TCCR2B)
293
+      {
294
+        TCCR2B = prescalarbits;
295
+      }
296
+#else
297
+      {
298
+        // dummy place holder to make the above ifdefs work
299
+      }
300
+#endif
301
+    }
302
+    else
303
+    {
304
+      // two choices for the 16 bit timers: ck/1 or ck/64
305
+      ocr = F_CPU / frequency / 2 - 1;
306
+
307
+      prescalarbits = 0b001;
308
+      if (ocr > 0xffff)
309
+      {
310
+        ocr = F_CPU / frequency / 2 / 64 - 1;
311
+        prescalarbits = 0b011;
312
+      }
313
+
314
+      if (_timer == 1)
315
+      {
316
+#if defined(TCCR1B)
317
+        TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
318
+#endif
319
+      }
320
+#if defined(TCCR3B)
321
+      else if (_timer == 3)
322
+        TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
323
+#endif
324
+#if defined(TCCR4B)
325
+      else if (_timer == 4)
326
+        TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
327
+#endif
328
+#if defined(TCCR5B)
329
+      else if (_timer == 5)
330
+        TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
331
+#endif
332
+
333
+    }
334
+    
335
+
336
+    // Calculate the toggle count
337
+    if (duration > 0)
338
+    {
339
+      toggle_count = 2 * frequency * duration / 1000;
340
+    }
341
+    else
342
+    {
343
+      toggle_count = -1;
344
+    }
345
+
346
+    // Set the OCR for the given timer,
347
+    // set the toggle count,
348
+    // then turn on the interrupts
349
+    switch (_timer)
350
+    {
351
+
352
+#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A)
353
+      case 0:
354
+        OCR0A = ocr;
355
+        timer0_toggle_count = toggle_count;
356
+        bitWrite(TIMSK0, OCIE0A, 1);
357
+        break;
358
+#endif
359
+
360
+      case 1:
361
+#if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A)
362
+        OCR1A = ocr;
363
+        timer1_toggle_count = toggle_count;
364
+        bitWrite(TIMSK1, OCIE1A, 1);
365
+#elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A)
366
+        // this combination is for at least the ATmega32
367
+        OCR1A = ocr;
368
+        timer1_toggle_count = toggle_count;
369
+        bitWrite(TIMSK, OCIE1A, 1);
370
+#endif
371
+        break;
372
+
373
+#if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A)
374
+      case 2:
375
+        OCR2A = ocr;
376
+        timer2_toggle_count = toggle_count;
377
+        bitWrite(TIMSK2, OCIE2A, 1);
378
+        break;
379
+#endif
380
+
381
+#if defined(TIMSK3)
382
+      case 3:
383
+        OCR3A = ocr;
384
+        timer3_toggle_count = toggle_count;
385
+        bitWrite(TIMSK3, OCIE3A, 1);
386
+        break;
387
+#endif
388
+
389
+#if defined(TIMSK4)
390
+      case 4:
391
+        OCR4A = ocr;
392
+        timer4_toggle_count = toggle_count;
393
+        bitWrite(TIMSK4, OCIE4A, 1);
394
+        break;
395
+#endif
396
+
397
+#if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A)
398
+      case 5:
399
+        OCR5A = ocr;
400
+        timer5_toggle_count = toggle_count;
401
+        bitWrite(TIMSK5, OCIE5A, 1);
402
+        break;
403
+#endif
404
+
405
+    }
406
+  }
407
+}
408
+
409
+
410
+// XXX: this function only works properly for timer 2 (the only one we use
411
+// currently).  for the others, it should end the tone, but won't restore
412
+// proper PWM functionality for the timer.
413
+void disableTimer(uint8_t _timer)
414
+{
415
+  switch (_timer)
416
+  {
417
+    case 0:
418
+      #if defined(TIMSK0)
419
+        TIMSK0 = 0;
420
+      #elif defined(TIMSK)
421
+        TIMSK = 0; // atmega32
422
+      #endif
423
+      break;
424
+
425
+#if defined(TIMSK1) && defined(OCIE1A)
426
+    case 1:
427
+      bitWrite(TIMSK1, OCIE1A, 0);
428
+      break;
429
+#endif
430
+
431
+    case 2:
432
+      #if defined(TIMSK2) && defined(OCIE2A)
433
+        bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt
434
+      #endif
435
+      #if defined(TCCR2A) && defined(WGM20)
436
+        TCCR2A = (1 << WGM20);
437
+      #endif
438
+      #if defined(TCCR2B) && defined(CS22)
439
+        TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
440
+      #endif
441
+      #if defined(OCR2A)
442
+        OCR2A = 0;
443
+      #endif
444
+      break;
445
+
446
+#if defined(TIMSK3)
447
+    case 3:
448
+      TIMSK3 = 0;
449
+      break;
450
+#endif
451
+
452
+#if defined(TIMSK4)
453
+    case 4:
454
+      TIMSK4 = 0;
455
+      break;
456
+#endif
457
+
458
+#if defined(TIMSK5)
459
+    case 5:
460
+      TIMSK5 = 0;
461
+      break;
462
+#endif
463
+  }
464
+}
465
+
466
+
467
+void noTone(uint8_t _pin)
468
+{
469
+  int8_t _timer = -1;
470
+  
471
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
472
+    if (tone_pins[i] == _pin) {
473
+      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
474
+      tone_pins[i] = 255;
475
+    }
476
+  }
477
+  
478
+  disableTimer(_timer);
479
+
480
+  digitalWrite(_pin, 0);
481
+}
482
+
483
+#if 0
484
+#if !defined(__AVR_ATmega8__)
485
+ISR(TIMER0_COMPA_vect)
486
+{
487
+  if (timer0_toggle_count != 0)
488
+  {
489
+    // toggle the pin
490
+    *timer0_pin_port ^= timer0_pin_mask;
491
+
492
+    if (timer0_toggle_count > 0)
493
+      timer0_toggle_count--;
494
+  }
495
+  else
496
+  {
497
+    disableTimer(0);
498
+    *timer0_pin_port &= ~(timer0_pin_mask);  // keep pin low after stop
499
+  }
500
+}
501
+#endif
502
+
503
+
504
+ISR(TIMER1_COMPA_vect)
505
+{
506
+  if (timer1_toggle_count != 0)
507
+  {
508
+    // toggle the pin
509
+    *timer1_pin_port ^= timer1_pin_mask;
510
+
511
+    if (timer1_toggle_count > 0)
512
+      timer1_toggle_count--;
513
+  }
514
+  else
515
+  {
516
+    disableTimer(1);
517
+    *timer1_pin_port &= ~(timer1_pin_mask);  // keep pin low after stop
518
+  }
519
+}
520
+#endif
521
+
522
+
523
+ISR(TIMER2_COMPA_vect)
524
+{
525
+
526
+  if (timer2_toggle_count != 0)
527
+  {
528
+    // toggle the pin
529
+    *timer2_pin_port ^= timer2_pin_mask;
530
+
531
+    if (timer2_toggle_count > 0)
532
+      timer2_toggle_count--;
533
+  }
534
+  else
535
+  {
536
+    // need to call noTone() so that the tone_pins[] entry is reset, so the
537
+    // timer gets initialized next time we call tone().
538
+    // XXX: this assumes timer 2 is always the first one used.
539
+    noTone(tone_pins[0]);
540
+//    disableTimer(2);
541
+//    *timer2_pin_port &= ~(timer2_pin_mask);  // keep pin low after stop
542
+  }
543
+}
544
+
545
+
546
+
547
+//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
548
+#if 0
549
+
550
+ISR(TIMER3_COMPA_vect)
551
+{
552
+  if (timer3_toggle_count != 0)
553
+  {
554
+    // toggle the pin
555
+    *timer3_pin_port ^= timer3_pin_mask;
556
+
557
+    if (timer3_toggle_count > 0)
558
+      timer3_toggle_count--;
559
+  }
560
+  else
561
+  {
562
+    disableTimer(3);
563
+    *timer3_pin_port &= ~(timer3_pin_mask);  // keep pin low after stop
564
+  }
565
+}
566
+
567
+ISR(TIMER4_COMPA_vect)
568
+{
569
+  if (timer4_toggle_count != 0)
570
+  {
571
+    // toggle the pin
572
+    *timer4_pin_port ^= timer4_pin_mask;
573
+
574
+    if (timer4_toggle_count > 0)
575
+      timer4_toggle_count--;
576
+  }
577
+  else
578
+  {
579
+    disableTimer(4);
580
+    *timer4_pin_port &= ~(timer4_pin_mask);  // keep pin low after stop
581
+  }
582
+}
583
+
584
+ISR(TIMER5_COMPA_vect)
585
+{
586
+  if (timer5_toggle_count != 0)
587
+  {
588
+    // toggle the pin
589
+    *timer5_pin_port ^= timer5_pin_mask;
590
+
591
+    if (timer5_toggle_count > 0)
592
+      timer5_toggle_count--;
593
+  }
594
+  else
595
+  {
596
+    disableTimer(5);
597
+    *timer5_pin_port &= ~(timer5_pin_mask);  // keep pin low after stop
598
+  }
599
+}
600
+
601
+#endif

+ 168
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WCharacter.h Dosyayı Görüntüle

@@ -0,0 +1,168 @@
1
+/*
2
+ WCharacter.h - Character utility functions for Wiring & Arduino
3
+ Copyright (c) 2010 Hernando Barragan.  All right reserved.
4
+ 
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+ 
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+ 
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ */
19
+
20
+#ifndef Character_h
21
+#define Character_h
22
+
23
+#include <ctype.h>
24
+
25
+// WCharacter.h prototypes
26
+inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
27
+inline boolean isAlpha(int c) __attribute__((always_inline));
28
+inline boolean isAscii(int c) __attribute__((always_inline));
29
+inline boolean isWhitespace(int c) __attribute__((always_inline));
30
+inline boolean isControl(int c) __attribute__((always_inline));
31
+inline boolean isDigit(int c) __attribute__((always_inline));
32
+inline boolean isGraph(int c) __attribute__((always_inline));
33
+inline boolean isLowerCase(int c) __attribute__((always_inline));
34
+inline boolean isPrintable(int c) __attribute__((always_inline));
35
+inline boolean isPunct(int c) __attribute__((always_inline));
36
+inline boolean isSpace(int c) __attribute__((always_inline));
37
+inline boolean isUpperCase(int c) __attribute__((always_inline));
38
+inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
39
+inline int toAscii(int c) __attribute__((always_inline));
40
+inline int toLowerCase(int c) __attribute__((always_inline));
41
+inline int toUpperCase(int c)__attribute__((always_inline));
42
+
43
+
44
+// Checks for an alphanumeric character. 
45
+// It is equivalent to (isalpha(c) || isdigit(c)).
46
+inline boolean isAlphaNumeric(int c) 
47
+{
48
+  return ( isalnum(c) == 0 ? false : true);
49
+}
50
+
51
+
52
+// Checks for an alphabetic character. 
53
+// It is equivalent to (isupper(c) || islower(c)).
54
+inline boolean isAlpha(int c)
55
+{
56
+  return ( isalpha(c) == 0 ? false : true);
57
+}
58
+
59
+
60
+// Checks whether c is a 7-bit unsigned char value 
61
+// that fits into the ASCII character set.
62
+inline boolean isAscii(int c)
63
+{
64
+  return ( isascii (c) == 0 ? false : true);
65
+}
66
+
67
+
68
+// Checks for a blank character, that is, a space or a tab.
69
+inline boolean isWhitespace(int c)
70
+{
71
+  return ( isblank (c) == 0 ? false : true);
72
+}
73
+
74
+
75
+// Checks for a control character.
76
+inline boolean isControl(int c)
77
+{
78
+  return ( iscntrl (c) == 0 ? false : true);
79
+}
80
+
81
+
82
+// Checks for a digit (0 through 9).
83
+inline boolean isDigit(int c)
84
+{
85
+  return ( isdigit (c) == 0 ? false : true);
86
+}
87
+
88
+
89
+// Checks for any printable character except space.
90
+inline boolean isGraph(int c)
91
+{
92
+  return ( isgraph (c) == 0 ? false : true);
93
+}
94
+
95
+
96
+// Checks for a lower-case character.
97
+inline boolean isLowerCase(int c)
98
+{
99
+  return (islower (c) == 0 ? false : true);
100
+}
101
+
102
+
103
+// Checks for any printable character including space.
104
+inline boolean isPrintable(int c)
105
+{
106
+  return ( isprint (c) == 0 ? false : true);
107
+}
108
+
109
+
110
+// Checks for any printable character which is not a space 
111
+// or an alphanumeric character.
112
+inline boolean isPunct(int c)
113
+{
114
+  return ( ispunct (c) == 0 ? false : true);
115
+}
116
+
117
+
118
+// Checks for white-space characters. For the avr-libc library, 
119
+// these are: space, formfeed ('\f'), newline ('\n'), carriage 
120
+// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
121
+inline boolean isSpace(int c)
122
+{
123
+  return ( isspace (c) == 0 ? false : true);
124
+}
125
+
126
+
127
+// Checks for an uppercase letter.
128
+inline boolean isUpperCase(int c)
129
+{
130
+  return ( isupper (c) == 0 ? false : true);
131
+}
132
+
133
+
134
+// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 
135
+// 8 9 a b c d e f A B C D E F.
136
+inline boolean isHexadecimalDigit(int c)
137
+{
138
+  return ( isxdigit (c) == 0 ? false : true);
139
+}
140
+
141
+
142
+// Converts c to a 7-bit unsigned char value that fits into the 
143
+// ASCII character set, by clearing the high-order bits.
144
+inline int toAscii(int c)
145
+{
146
+  return toascii (c);
147
+}
148
+
149
+
150
+// Warning:
151
+// Many people will be unhappy if you use this function. 
152
+// This function will convert accented letters into random 
153
+// characters.
154
+
155
+// Converts the letter c to lower case, if possible.
156
+inline int toLowerCase(int c)
157
+{
158
+  return tolower (c);
159
+}
160
+
161
+
162
+// Converts the letter c to upper case, if possible.
163
+inline int toUpperCase(int c)
164
+{
165
+  return toupper (c);
166
+}
167
+
168
+#endif

+ 1
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WConstants.h Dosyayı Görüntüle

@@ -0,0 +1 @@
1
+#include "wiring.h"

+ 249
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WInterrupts.c Dosyayı Görüntüle

@@ -0,0 +1,249 @@
1
+/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+/*
4
+  Part of the Wiring project - http://wiring.uniandes.edu.co
5
+
6
+  Copyright (c) 2004-05 Hernando Barragan
7
+
8
+  This library is free software; you can redistribute it and/or
9
+  modify it under the terms of the GNU Lesser General Public
10
+  License as published by the Free Software Foundation; either
11
+  version 2.1 of the License, or (at your option) any later version.
12
+
13
+  This library is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+  Lesser General Public License for more details.
17
+
18
+  You should have received a copy of the GNU Lesser General
19
+  Public License along with this library; if not, write to the
20
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+  Boston, MA  02111-1307  USA
22
+  
23
+  Modified 24 November 2006 by David A. Mellis
24
+  Modified 1 August 2010 by Mark Sproul
25
+*/
26
+
27
+#include <inttypes.h>
28
+#include <avr/io.h>
29
+#include <avr/interrupt.h>
30
+#include <avr/pgmspace.h>
31
+#include <stdio.h>
32
+
33
+#include "WConstants.h"
34
+#include "wiring_private.h"
35
+
36
+volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
37
+// volatile static voidFuncPtr twiIntFunc;
38
+
39
+void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
40
+  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
41
+    intFunc[interruptNum] = userFunc;
42
+    
43
+    // Configure the interrupt mode (trigger on low input, any change, rising
44
+    // edge, or falling edge).  The mode constants were chosen to correspond
45
+    // to the configuration bits in the hardware register, so we simply shift
46
+    // the mode into place.
47
+      
48
+    // Enable the interrupt.
49
+      
50
+    switch (interruptNum) {
51
+#if defined(EICRA) && defined(EICRB) && defined(EIMSK)
52
+    case 2:
53
+      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
54
+      EIMSK |= (1 << INT0);
55
+      break;
56
+    case 3:
57
+      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
58
+      EIMSK |= (1 << INT1);
59
+      break;
60
+    case 4:
61
+      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
62
+      EIMSK |= (1 << INT2);
63
+      break;
64
+    case 5:
65
+      EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
66
+      EIMSK |= (1 << INT3);
67
+      break;
68
+    case 0:
69
+      EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
70
+      EIMSK |= (1 << INT4);
71
+      break;
72
+    case 1:
73
+      EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
74
+      EIMSK |= (1 << INT5);
75
+      break;
76
+    case 6:
77
+      EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
78
+      EIMSK |= (1 << INT6);
79
+      break;
80
+    case 7:
81
+      EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
82
+      EIMSK |= (1 << INT7);
83
+      break;
84
+#else
85
+    case 0:
86
+    #if defined(EICRA) && defined(ISC00) && defined(EIMSK)
87
+      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
88
+      EIMSK |= (1 << INT0);
89
+    #elif defined(MCUCR) && defined(ISC00) && defined(GICR)
90
+      MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
91
+      GICR |= (1 << INT0);
92
+    #elif defined(MCUCR) && defined(ISC00) && defined(GIMSK)
93
+      MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
94
+      GIMSK |= (1 << INT0);
95
+    #else
96
+      #error attachInterrupt not finished for this CPU (case 0)
97
+    #endif
98
+      break;
99
+
100
+    case 1:
101
+    #if defined(EICRA) && defined(ISC10) && defined(ISC11) && defined(EIMSK)
102
+      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
103
+      EIMSK |= (1 << INT1);
104
+    #elif defined(MCUCR) && defined(ISC10) && defined(ISC11) && defined(GICR)
105
+      MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
106
+      GICR |= (1 << INT1);
107
+    #elif defined(MCUCR) && defined(ISC10) && defined(GIMSK) && defined(GIMSK)
108
+      MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
109
+      GIMSK |= (1 << INT1);
110
+    #else
111
+      #warning attachInterrupt may need some more work for this cpu (case 1)
112
+    #endif
113
+      break;
114
+#endif
115
+    }
116
+  }
117
+}
118
+
119
+void detachInterrupt(uint8_t interruptNum) {
120
+  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
121
+    // Disable the interrupt.  (We can't assume that interruptNum is equal
122
+    // to the number of the EIMSK bit to clear, as this isn't true on the 
123
+    // ATmega8.  There, INT0 is 6 and INT1 is 7.)
124
+    switch (interruptNum) {
125
+#if defined(EICRA) && defined(EICRB) && defined(EIMSK)
126
+    case 2:
127
+      EIMSK &= ~(1 << INT0);
128
+      break;
129
+    case 3:
130
+      EIMSK &= ~(1 << INT1);
131
+      break;
132
+    case 4:
133
+      EIMSK &= ~(1 << INT2);
134
+      break;
135
+    case 5:
136
+      EIMSK &= ~(1 << INT3);
137
+      break;
138
+    case 0:
139
+      EIMSK &= ~(1 << INT4);
140
+      break;
141
+    case 1:
142
+      EIMSK &= ~(1 << INT5);
143
+      break;
144
+    case 6:
145
+      EIMSK &= ~(1 << INT6);
146
+      break;
147
+    case 7:
148
+      EIMSK &= ~(1 << INT7);
149
+      break;
150
+#else
151
+    case 0:
152
+    #if defined(EIMSK) && defined(INT0)
153
+      EIMSK &= ~(1 << INT0);
154
+    #elif defined(GICR) && defined(ISC00)
155
+      GICR &= ~(1 << INT0); // atmega32
156
+    #elif defined(GIMSK) && defined(INT0)
157
+      GIMSK &= ~(1 << INT0);
158
+    #else
159
+      #error detachInterrupt not finished for this cpu
160
+    #endif
161
+      break;
162
+
163
+    case 1:
164
+    #if defined(EIMSK) && defined(INT1)
165
+      EIMSK &= ~(1 << INT1);
166
+    #elif defined(GICR) && defined(INT1)
167
+      GICR &= ~(1 << INT1); // atmega32
168
+    #elif defined(GIMSK) && defined(INT1)
169
+      GIMSK &= ~(1 << INT1);
170
+    #else
171
+      #warning detachInterrupt may need some more work for this cpu (case 1)
172
+    #endif
173
+      break;
174
+#endif
175
+    }
176
+      
177
+    intFunc[interruptNum] = 0;
178
+  }
179
+}
180
+
181
+/*
182
+void attachInterruptTwi(void (*userFunc)(void) ) {
183
+  twiIntFunc = userFunc;
184
+}
185
+*/
186
+
187
+#if defined(EICRA) && defined(EICRB)
188
+
189
+SIGNAL(INT0_vect) {
190
+  if(intFunc[EXTERNAL_INT_2])
191
+    intFunc[EXTERNAL_INT_2]();
192
+}
193
+
194
+SIGNAL(INT1_vect) {
195
+  if(intFunc[EXTERNAL_INT_3])
196
+    intFunc[EXTERNAL_INT_3]();
197
+}
198
+
199
+SIGNAL(INT2_vect) {
200
+  if(intFunc[EXTERNAL_INT_4])
201
+    intFunc[EXTERNAL_INT_4]();
202
+}
203
+
204
+SIGNAL(INT3_vect) {
205
+  if(intFunc[EXTERNAL_INT_5])
206
+    intFunc[EXTERNAL_INT_5]();
207
+}
208
+
209
+SIGNAL(INT4_vect) {
210
+  if(intFunc[EXTERNAL_INT_0])
211
+    intFunc[EXTERNAL_INT_0]();
212
+}
213
+
214
+SIGNAL(INT5_vect) {
215
+  if(intFunc[EXTERNAL_INT_1])
216
+    intFunc[EXTERNAL_INT_1]();
217
+}
218
+
219
+SIGNAL(INT6_vect) {
220
+  if(intFunc[EXTERNAL_INT_6])
221
+    intFunc[EXTERNAL_INT_6]();
222
+}
223
+
224
+SIGNAL(INT7_vect) {
225
+  if(intFunc[EXTERNAL_INT_7])
226
+    intFunc[EXTERNAL_INT_7]();
227
+}
228
+
229
+#else
230
+
231
+SIGNAL(INT0_vect) {
232
+  if(intFunc[EXTERNAL_INT_0])
233
+    intFunc[EXTERNAL_INT_0]();
234
+}
235
+
236
+SIGNAL(INT1_vect) {
237
+  if(intFunc[EXTERNAL_INT_1])
238
+    intFunc[EXTERNAL_INT_1]();
239
+}
240
+
241
+#endif
242
+
243
+/*
244
+SIGNAL(SIG_2WIRE_SERIAL) {
245
+  if(twiIntFunc)
246
+    twiIntFunc();
247
+}
248
+*/
249
+

+ 60
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WMath.cpp Dosyayı Görüntüle

@@ -0,0 +1,60 @@
1
+/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+/*
4
+  Part of the Wiring project - http://wiring.org.co
5
+  Copyright (c) 2004-06 Hernando Barragan
6
+  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
7
+  
8
+  This library is free software; you can redistribute it and/or
9
+  modify it under the terms of the GNU Lesser General Public
10
+  License as published by the Free Software Foundation; either
11
+  version 2.1 of the License, or (at your option) any later version.
12
+
13
+  This library is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+  Lesser General Public License for more details.
17
+
18
+  You should have received a copy of the GNU Lesser General
19
+  Public License along with this library; if not, write to the
20
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+  Boston, MA  02111-1307  USA
22
+  
23
+  $Id$
24
+*/
25
+
26
+extern "C" {
27
+  #include "stdlib.h"
28
+}
29
+
30
+void randomSeed(unsigned int seed)
31
+{
32
+  if (seed != 0) {
33
+    srandom(seed);
34
+  }
35
+}
36
+
37
+long random(long howbig)
38
+{
39
+  if (howbig == 0) {
40
+    return 0;
41
+  }
42
+  return random() % howbig;
43
+}
44
+
45
+long random(long howsmall, long howbig)
46
+{
47
+  if (howsmall >= howbig) {
48
+    return howsmall;
49
+  }
50
+  long diff = howbig - howsmall;
51
+  return random(diff) + howsmall;
52
+}
53
+
54
+long map(long x, long in_min, long in_max, long out_min, long out_max)
55
+{
56
+  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
57
+}
58
+
59
+unsigned int makeWord(unsigned int w) { return w; }
60
+unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 63
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WProgram.h Dosyayı Görüntüle

@@ -0,0 +1,63 @@
1
+#ifndef WProgram_h
2
+#define WProgram_h
3
+
4
+#include <stdlib.h>
5
+#include <string.h>
6
+#include <math.h>
7
+
8
+#include <avr/interrupt.h>
9
+
10
+#include "wiring.h"
11
+
12
+#ifdef __cplusplus
13
+#include "WCharacter.h"
14
+#include "WString.h"
15
+#include "HardwareSerial.h"
16
+
17
+uint16_t makeWord(uint16_t w);
18
+uint16_t makeWord(byte h, byte l);
19
+
20
+#define word(...) makeWord(__VA_ARGS__)
21
+
22
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
23
+
24
+void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
25
+void noTone(uint8_t _pin);
26
+
27
+// WMath prototypes
28
+long random(long);
29
+long random(long, long);
30
+void randomSeed(unsigned int);
31
+long map(long, long, long, long, long);
32
+
33
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
34
+const static uint8_t A0 = 54;
35
+const static uint8_t A1 = 55;
36
+const static uint8_t A2 = 56;
37
+const static uint8_t A3 = 57;
38
+const static uint8_t A4 = 58;
39
+const static uint8_t A5 = 59;
40
+const static uint8_t A6 = 60;
41
+const static uint8_t A7 = 61;
42
+const static uint8_t A8 = 62;
43
+const static uint8_t A9 = 63;
44
+const static uint8_t A10 = 64;
45
+const static uint8_t A11 = 65;
46
+const static uint8_t A12 = 66;
47
+const static uint8_t A13 = 67;
48
+const static uint8_t A14 = 68;
49
+const static uint8_t A15 = 69;
50
+#else
51
+const static uint8_t A0 = 14;
52
+const static uint8_t A1 = 15;
53
+const static uint8_t A2 = 16;
54
+const static uint8_t A3 = 17;
55
+const static uint8_t A4 = 18;
56
+const static uint8_t A5 = 19;
57
+const static uint8_t A6 = 20;
58
+const static uint8_t A7 = 21;
59
+#endif
60
+
61
+#endif
62
+
63
+#endif

+ 443
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WString.cpp Dosyayı Görüntüle

@@ -0,0 +1,443 @@
1
+/*
2
+  WString.cpp - String library for Wiring & Arduino
3
+  Copyright (c) 2009-10 Hernando Barragan.  All rights reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#include <stdlib.h>
21
+#include "WProgram.h"
22
+#include "WString.h"
23
+
24
+
25
+String::String( const char *value )
26
+{
27
+  if ( value == NULL )
28
+    value = "";
29
+  getBuffer( _length = strlen( value ) );
30
+  if ( _buffer != NULL )
31
+    strcpy( _buffer, value );
32
+}
33
+
34
+String::String( const String &value )
35
+{
36
+  getBuffer( _length = value._length );
37
+  if ( _buffer != NULL )
38
+    strcpy( _buffer, value._buffer );
39
+}
40
+
41
+String::String( const char value )
42
+{
43
+  _length = 1;
44
+  getBuffer(1);
45
+  if ( _buffer != NULL ) {
46
+    _buffer[0] = value;
47
+    _buffer[1] = 0;
48
+  }
49
+}
50
+
51
+String::String( const unsigned char value )
52
+{
53
+  _length = 1;
54
+  getBuffer(1);
55
+  if ( _buffer != NULL) {
56
+    _buffer[0] = value;
57
+    _buffer[1] = 0;
58
+  }
59
+}
60
+
61
+String::String( const int value, const int base )
62
+{
63
+  char buf[33];   
64
+  itoa((signed long)value, buf, base);
65
+  getBuffer( _length = strlen(buf) );
66
+  if ( _buffer != NULL )
67
+    strcpy( _buffer, buf );
68
+}
69
+
70
+String::String( const unsigned int value, const int base )
71
+{
72
+  char buf[33];   
73
+  ultoa((unsigned long)value, buf, base);
74
+  getBuffer( _length = strlen(buf) );
75
+  if ( _buffer != NULL )
76
+    strcpy( _buffer, buf );
77
+}
78
+
79
+String::String( const long value, const int base )
80
+{
81
+  char buf[33];   
82
+  ltoa(value, buf, base);
83
+  getBuffer( _length = strlen(buf) );
84
+  if ( _buffer != NULL )
85
+    strcpy( _buffer, buf );
86
+}
87
+
88
+String::String( const unsigned long value, const int base )
89
+{
90
+  char buf[33];   
91
+  ultoa(value, buf, 10);
92
+  getBuffer( _length = strlen(buf) );
93
+  if ( _buffer != NULL )
94
+    strcpy( _buffer, buf );
95
+}
96
+
97
+char String::charAt( unsigned int loc ) const
98
+{
99
+  return operator[]( loc );
100
+}
101
+
102
+void String::setCharAt( unsigned int loc, const char aChar ) 
103
+{
104
+  if(_buffer == NULL) return;
105
+  if(_length > loc) {
106
+    _buffer[loc] = aChar;
107
+  }
108
+}
109
+
110
+int String::compareTo( const String &s2 ) const
111
+{
112
+  return strcmp( _buffer, s2._buffer );
113
+}
114
+
115
+const String & String::concat( const String &s2 )
116
+{
117
+  return (*this) += s2;
118
+}
119
+
120
+const String & String::operator=( const String &rhs )
121
+{
122
+  if ( this == &rhs )
123
+    return *this;
124
+
125
+  if ( rhs._length > _length )
126
+  {
127
+    free(_buffer);
128
+    getBuffer( rhs._length );
129
+  }
130
+  
131
+  if ( _buffer != NULL ) {
132
+    _length = rhs._length;
133
+    strcpy( _buffer, rhs._buffer );
134
+  }
135
+  return *this;
136
+}
137
+
138
+//const String & String::operator+=( const char aChar )
139
+//{
140
+//  if ( _length == _capacity )
141
+//    doubleBuffer();
142
+//
143
+//  _buffer[ _length++ ] = aChar;
144
+//  _buffer[ _length ] = '\0';
145
+//  return *this;
146
+//}
147
+
148
+const String & String::operator+=( const String &other )
149
+{
150
+  _length += other._length;
151
+  if ( _length > _capacity )
152
+  {
153
+    char *temp = (char *)realloc(_buffer, _length + 1);
154
+    if ( temp != NULL ) {
155
+      _buffer = temp;
156
+      _capacity = _length;
157
+    } else {
158
+      _length -= other._length;
159
+      return *this;
160
+    }
161
+  }
162
+  strcat( _buffer, other._buffer );
163
+  return *this;
164
+}
165
+
166
+
167
+int String::operator==( const String &rhs ) const
168
+{
169
+  return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 );
170
+}
171
+
172
+int String::operator!=( const String &rhs ) const
173
+{
174
+  return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 );
175
+}
176
+
177
+int String::operator<( const String &rhs ) const
178
+{
179
+  return strcmp( _buffer, rhs._buffer ) < 0;
180
+}
181
+
182
+int String::operator>( const String &rhs ) const
183
+{
184
+  return strcmp( _buffer, rhs._buffer ) > 0;
185
+}
186
+
187
+int String::operator<=( const String &rhs ) const
188
+{
189
+  return strcmp( _buffer, rhs._buffer ) <= 0;
190
+}
191
+
192
+int String::operator>=( const String & rhs ) const
193
+{
194
+  return strcmp( _buffer, rhs._buffer ) >= 0;
195
+}
196
+
197
+char & String::operator[]( unsigned int index )
198
+{
199
+  static char dummy_writable_char;
200
+  if (index >= _length || !_buffer) {
201
+    dummy_writable_char = 0;
202
+    return dummy_writable_char;
203
+  }
204
+  return _buffer[ index ];
205
+}
206
+
207
+char String::operator[]( unsigned int index ) const
208
+{
209
+  // need to check for valid index, to do later
210
+  return _buffer[ index ];
211
+}
212
+
213
+boolean String::endsWith( const String &s2 ) const
214
+{
215
+  if ( _length < s2._length )
216
+    return 0;
217
+
218
+  return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0;
219
+}
220
+
221
+boolean String::equals( const String &s2 ) const
222
+{
223
+  return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 );
224
+}
225
+
226
+boolean String::equalsIgnoreCase( const String &s2 ) const
227
+{
228
+  if ( this == &s2 )
229
+    return true; //1;
230
+  else if ( _length != s2._length )
231
+    return false; //0;
232
+
233
+  return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
234
+}
235
+
236
+String String::replace( char findChar, char replaceChar )
237
+{
238
+  if ( _buffer == NULL ) return *this;
239
+  String theReturn = _buffer;
240
+  char* temp = theReturn._buffer;
241
+  while( (temp = strchr( temp, findChar )) != 0 )
242
+    *temp = replaceChar;
243
+
244
+  return theReturn;
245
+}
246
+
247
+String String::replace( const String& match, const String& replace )
248
+{
249
+  if ( _buffer == NULL ) return *this;
250
+  String temp = _buffer, newString;
251
+
252
+  int loc;
253
+  while ( (loc = temp.indexOf( match )) != -1 )
254
+  {
255
+    newString += temp.substring( 0, loc );
256
+    newString += replace;
257
+    temp = temp.substring( loc + match._length );
258
+  }
259
+  newString += temp;  
260
+  return newString;
261
+}
262
+
263
+int String::indexOf( char temp ) const
264
+{
265
+  return indexOf( temp, 0 );
266
+}
267
+
268
+int String::indexOf( char ch, unsigned int fromIndex ) const
269
+{
270
+  if ( fromIndex >= _length )
271
+    return -1;
272
+
273
+  const char* temp = strchr( &_buffer[fromIndex], ch );
274
+  if ( temp == NULL )
275
+    return -1;
276
+
277
+  return temp - _buffer;
278
+}
279
+
280
+int String::indexOf( const String &s2 ) const
281
+{
282
+  return indexOf( s2, 0 );
283
+}
284
+
285
+int String::indexOf( const String &s2, unsigned int fromIndex ) const
286
+{
287
+  if ( fromIndex >= _length )
288
+    return -1;
289
+
290
+  const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer );
291
+
292
+  if ( theFind == NULL )
293
+    return -1;
294
+
295
+  return theFind - _buffer; // pointer subtraction
296
+}
297
+
298
+int String::lastIndexOf( char theChar ) const
299
+{
300
+  return lastIndexOf( theChar, _length - 1 );
301
+}
302
+
303
+int String::lastIndexOf( char ch, unsigned int fromIndex ) const
304
+{
305
+  if ( fromIndex >= _length )
306
+    return -1;
307
+
308
+  char tempchar = _buffer[fromIndex + 1];
309
+  _buffer[fromIndex + 1] = '\0';
310
+  char* temp = strrchr( _buffer, ch );
311
+  _buffer[fromIndex + 1] = tempchar;
312
+
313
+  if ( temp == NULL )
314
+    return -1;
315
+
316
+  return temp - _buffer;
317
+}
318
+
319
+int String::lastIndexOf( const String &s2 ) const
320
+{
321
+  return lastIndexOf( s2, _length - s2._length );
322
+}
323
+
324
+int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const
325
+{
326
+  // check for empty strings
327
+  if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length )
328
+    return -1;
329
+
330
+  // matching first character
331
+  char temp = s2[ 0 ];
332
+
333
+  for ( int i = fromIndex; i >= 0; i-- )
334
+  {
335
+    if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) )
336
+    return i;
337
+  }
338
+  return -1;
339
+}
340
+
341
+boolean String::startsWith( const String &s2 ) const
342
+{
343
+  if ( _length < s2._length )
344
+    return 0;
345
+
346
+  return startsWith( s2, 0 );
347
+}
348
+
349
+boolean String::startsWith( const String &s2, unsigned int offset ) const
350
+{
351
+  if ( offset > _length - s2._length )
352
+    return 0;
353
+
354
+  return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0;
355
+}
356
+
357
+String String::substring( unsigned int left ) const
358
+{
359
+  return substring( left, _length );
360
+}
361
+
362
+String String::substring( unsigned int left, unsigned int right ) const
363
+{
364
+  if ( left > right )
365
+  {
366
+    int temp = right;
367
+    right = left;
368
+    left = temp;
369
+  }
370
+
371
+  if ( right > _length )
372
+  {
373
+    right = _length;
374
+  } 
375
+
376
+  char temp = _buffer[ right ];  // save the replaced character
377
+  _buffer[ right ] = '\0';	
378
+  String outPut = ( _buffer + left );  // pointer arithmetic
379
+  _buffer[ right ] = temp;  //restore character
380
+  return outPut;
381
+}
382
+
383
+String String::toLowerCase() const
384
+{
385
+  String temp = _buffer;
386
+
387
+  for ( unsigned int i = 0; i < _length; i++ )
388
+    temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] );
389
+  return temp;
390
+}
391
+
392
+String String::toUpperCase() const
393
+{
394
+  String temp = _buffer;
395
+
396
+  for ( unsigned int i = 0; i < _length; i++ )
397
+    temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
398
+  return temp;
399
+}
400
+
401
+String String::trim() const
402
+{
403
+  if ( _buffer == NULL ) return *this;
404
+  String temp = _buffer;
405
+  unsigned int i,j;
406
+
407
+  for ( i = 0; i < _length; i++ )
408
+  {
409
+    if ( !isspace(_buffer[i]) )
410
+      break;
411
+  }
412
+
413
+  for ( j = temp._length - 1; j > i; j-- )
414
+  {
415
+    if ( !isspace(_buffer[j]) )
416
+      break;
417
+  }
418
+
419
+  return temp.substring( i, j + 1);
420
+}
421
+
422
+void String::getBytes(unsigned char *buf, unsigned int bufsize)
423
+{
424
+  if (!bufsize || !buf) return;
425
+  unsigned int len = bufsize - 1;
426
+  if (len > _length) len = _length;
427
+  strncpy((char *)buf, _buffer, len);
428
+  buf[len] = 0;
429
+}
430
+
431
+void String::toCharArray(char *buf, unsigned int bufsize)
432
+{
433
+  if (!bufsize || !buf) return;
434
+  unsigned int len = bufsize - 1;
435
+  if (len > _length) len = _length;
436
+  strncpy(buf, _buffer, len);
437
+  buf[len] = 0;
438
+}
439
+
440
+
441
+long String::toInt() {
442
+  return atol(_buffer);
443
+}

+ 112
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/WString.h Dosyayı Görüntüle

@@ -0,0 +1,112 @@
1
+/*
2
+  WString.h - String library for Wiring & Arduino
3
+  Copyright (c) 2009-10 Hernando Barragan.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef String_h
21
+#define String_h
22
+
23
+//#include "WProgram.h"
24
+#include <stdlib.h>
25
+#include <string.h>
26
+#include <ctype.h>
27
+
28
+class String
29
+{
30
+  public:
31
+    // constructors
32
+    String( const char *value = "" );
33
+    String( const String &value );
34
+    String( const char );
35
+    String( const unsigned char );
36
+    String( const int, const int base=10);
37
+    String( const unsigned int, const int base=10 );
38
+    String( const long, const int base=10 );
39
+    String( const unsigned long, const int base=10 );
40
+    ~String() { free(_buffer); _length = _capacity = 0;}     //added _length = _capacity = 0;
41
+
42
+    // operators
43
+    const String & operator = ( const String &rhs );
44
+    const String & operator +=( const String &rhs );
45
+    //const String & operator +=( const char );
46
+    int operator ==( const String &rhs ) const;
47
+    int	operator !=( const String &rhs ) const;
48
+    int	operator < ( const String &rhs ) const;
49
+    int	operator > ( const String &rhs ) const;
50
+    int	operator <=( const String &rhs ) const;
51
+    int	operator >=( const String &rhs ) const;
52
+    char operator []( unsigned int index ) const;
53
+    char& operator []( unsigned int index );
54
+    //operator const char *() const { return _buffer; }
55
+    
56
+    // general methods
57
+    char charAt( unsigned int index ) const;
58
+    int	compareTo( const String &anotherString ) const;
59
+    unsigned char endsWith( const String &suffix ) const;
60
+    unsigned char equals( const String &anObject ) const;
61
+    unsigned char equalsIgnoreCase( const String &anotherString ) const;
62
+    int	indexOf( char ch ) const;
63
+    int	indexOf( char ch, unsigned int fromIndex ) const;
64
+    int	indexOf( const String &str ) const;
65
+    int	indexOf( const String &str, unsigned int fromIndex ) const;
66
+    int	lastIndexOf( char ch ) const;
67
+    int	lastIndexOf( char ch, unsigned int fromIndex ) const;
68
+    int	lastIndexOf( const String &str ) const;
69
+    int	lastIndexOf( const String &str, unsigned int fromIndex ) const;
70
+    const unsigned int length( ) const { return _length; }
71
+    void setCharAt(unsigned int index, const char ch);
72
+    unsigned char startsWith( const String &prefix ) const;
73
+    unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
74
+    String substring( unsigned int beginIndex ) const;
75
+    String substring( unsigned int beginIndex, unsigned int endIndex ) const;
76
+    String toLowerCase( ) const;
77
+    String toUpperCase( ) const;
78
+    String trim( ) const;
79
+    void getBytes(unsigned char *buf, unsigned int bufsize);
80
+    void toCharArray(char *buf, unsigned int bufsize);
81
+    long toInt( );
82
+    const String& concat( const String &str );
83
+    String replace( char oldChar, char newChar );
84
+    String replace( const String& match, const String& replace );
85
+    friend String operator + ( String lhs, const String &rhs );
86
+
87
+  protected:
88
+    char *_buffer;	     // the actual char array
89
+    unsigned int _capacity;  // the array length minus one (for the '\0')
90
+    unsigned int _length;    // the String length (not counting the '\0')
91
+
92
+    void getBuffer(unsigned int maxStrLen);
93
+
94
+  private:
95
+
96
+};
97
+
98
+// allocate buffer space
99
+inline void String::getBuffer(unsigned int maxStrLen)
100
+{
101
+  _capacity = maxStrLen;
102
+  _buffer = (char *) malloc(_capacity + 1);
103
+  if (_buffer == NULL) _length = _capacity = 0;
104
+}
105
+
106
+inline String operator+( String lhs, const String &rhs )
107
+{
108
+  return lhs += rhs;
109
+}
110
+
111
+
112
+#endif

+ 515
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/binary.h Dosyayı Görüntüle

@@ -0,0 +1,515 @@
1
+#ifndef Binary_h
2
+#define Binary_h
3
+
4
+#define B0 0
5
+#define B00 0
6
+#define B000 0
7
+#define B0000 0
8
+#define B00000 0
9
+#define B000000 0
10
+#define B0000000 0
11
+#define B00000000 0
12
+#define B1 1
13
+#define B01 1
14
+#define B001 1
15
+#define B0001 1
16
+#define B00001 1
17
+#define B000001 1
18
+#define B0000001 1
19
+#define B00000001 1
20
+#define B10 2
21
+#define B010 2
22
+#define B0010 2
23
+#define B00010 2
24
+#define B000010 2
25
+#define B0000010 2
26
+#define B00000010 2
27
+#define B11 3
28
+#define B011 3
29
+#define B0011 3
30
+#define B00011 3
31
+#define B000011 3
32
+#define B0000011 3
33
+#define B00000011 3
34
+#define B100 4
35
+#define B0100 4
36
+#define B00100 4
37
+#define B000100 4
38
+#define B0000100 4
39
+#define B00000100 4
40
+#define B101 5
41
+#define B0101 5
42
+#define B00101 5
43
+#define B000101 5
44
+#define B0000101 5
45
+#define B00000101 5
46
+#define B110 6
47
+#define B0110 6
48
+#define B00110 6
49
+#define B000110 6
50
+#define B0000110 6
51
+#define B00000110 6
52
+#define B111 7
53
+#define B0111 7
54
+#define B00111 7
55
+#define B000111 7
56
+#define B0000111 7
57
+#define B00000111 7
58
+#define B1000 8
59
+#define B01000 8
60
+#define B001000 8
61
+#define B0001000 8
62
+#define B00001000 8
63
+#define B1001 9
64
+#define B01001 9
65
+#define B001001 9
66
+#define B0001001 9
67
+#define B00001001 9
68
+#define B1010 10
69
+#define B01010 10
70
+#define B001010 10
71
+#define B0001010 10
72
+#define B00001010 10
73
+#define B1011 11
74
+#define B01011 11
75
+#define B001011 11
76
+#define B0001011 11
77
+#define B00001011 11
78
+#define B1100 12
79
+#define B01100 12
80
+#define B001100 12
81
+#define B0001100 12
82
+#define B00001100 12
83
+#define B1101 13
84
+#define B01101 13
85
+#define B001101 13
86
+#define B0001101 13
87
+#define B00001101 13
88
+#define B1110 14
89
+#define B01110 14
90
+#define B001110 14
91
+#define B0001110 14
92
+#define B00001110 14
93
+#define B1111 15
94
+#define B01111 15
95
+#define B001111 15
96
+#define B0001111 15
97
+#define B00001111 15
98
+#define B10000 16
99
+#define B010000 16
100
+#define B0010000 16
101
+#define B00010000 16
102
+#define B10001 17
103
+#define B010001 17
104
+#define B0010001 17
105
+#define B00010001 17
106
+#define B10010 18
107
+#define B010010 18
108
+#define B0010010 18
109
+#define B00010010 18
110
+#define B10011 19
111
+#define B010011 19
112
+#define B0010011 19
113
+#define B00010011 19
114
+#define B10100 20
115
+#define B010100 20
116
+#define B0010100 20
117
+#define B00010100 20
118
+#define B10101 21
119
+#define B010101 21
120
+#define B0010101 21
121
+#define B00010101 21
122
+#define B10110 22
123
+#define B010110 22
124
+#define B0010110 22
125
+#define B00010110 22
126
+#define B10111 23
127
+#define B010111 23
128
+#define B0010111 23
129
+#define B00010111 23
130
+#define B11000 24
131
+#define B011000 24
132
+#define B0011000 24
133
+#define B00011000 24
134
+#define B11001 25
135
+#define B011001 25
136
+#define B0011001 25
137
+#define B00011001 25
138
+#define B11010 26
139
+#define B011010 26
140
+#define B0011010 26
141
+#define B00011010 26
142
+#define B11011 27
143
+#define B011011 27
144
+#define B0011011 27
145
+#define B00011011 27
146
+#define B11100 28
147
+#define B011100 28
148
+#define B0011100 28
149
+#define B00011100 28
150
+#define B11101 29
151
+#define B011101 29
152
+#define B0011101 29
153
+#define B00011101 29
154
+#define B11110 30
155
+#define B011110 30
156
+#define B0011110 30
157
+#define B00011110 30
158
+#define B11111 31
159
+#define B011111 31
160
+#define B0011111 31
161
+#define B00011111 31
162
+#define B100000 32
163
+#define B0100000 32
164
+#define B00100000 32
165
+#define B100001 33
166
+#define B0100001 33
167
+#define B00100001 33
168
+#define B100010 34
169
+#define B0100010 34
170
+#define B00100010 34
171
+#define B100011 35
172
+#define B0100011 35
173
+#define B00100011 35
174
+#define B100100 36
175
+#define B0100100 36
176
+#define B00100100 36
177
+#define B100101 37
178
+#define B0100101 37
179
+#define B00100101 37
180
+#define B100110 38
181
+#define B0100110 38
182
+#define B00100110 38
183
+#define B100111 39
184
+#define B0100111 39
185
+#define B00100111 39
186
+#define B101000 40
187
+#define B0101000 40
188
+#define B00101000 40
189
+#define B101001 41
190
+#define B0101001 41
191
+#define B00101001 41
192
+#define B101010 42
193
+#define B0101010 42
194
+#define B00101010 42
195
+#define B101011 43
196
+#define B0101011 43
197
+#define B00101011 43
198
+#define B101100 44
199
+#define B0101100 44
200
+#define B00101100 44
201
+#define B101101 45
202
+#define B0101101 45
203
+#define B00101101 45
204
+#define B101110 46
205
+#define B0101110 46
206
+#define B00101110 46
207
+#define B101111 47
208
+#define B0101111 47
209
+#define B00101111 47
210
+#define B110000 48
211
+#define B0110000 48
212
+#define B00110000 48
213
+#define B110001 49
214
+#define B0110001 49
215
+#define B00110001 49
216
+#define B110010 50
217
+#define B0110010 50
218
+#define B00110010 50
219
+#define B110011 51
220
+#define B0110011 51
221
+#define B00110011 51
222
+#define B110100 52
223
+#define B0110100 52
224
+#define B00110100 52
225
+#define B110101 53
226
+#define B0110101 53
227
+#define B00110101 53
228
+#define B110110 54
229
+#define B0110110 54
230
+#define B00110110 54
231
+#define B110111 55
232
+#define B0110111 55
233
+#define B00110111 55
234
+#define B111000 56
235
+#define B0111000 56
236
+#define B00111000 56
237
+#define B111001 57
238
+#define B0111001 57
239
+#define B00111001 57
240
+#define B111010 58
241
+#define B0111010 58
242
+#define B00111010 58
243
+#define B111011 59
244
+#define B0111011 59
245
+#define B00111011 59
246
+#define B111100 60
247
+#define B0111100 60
248
+#define B00111100 60
249
+#define B111101 61
250
+#define B0111101 61
251
+#define B00111101 61
252
+#define B111110 62
253
+#define B0111110 62
254
+#define B00111110 62
255
+#define B111111 63
256
+#define B0111111 63
257
+#define B00111111 63
258
+#define B1000000 64
259
+#define B01000000 64
260
+#define B1000001 65
261
+#define B01000001 65
262
+#define B1000010 66
263
+#define B01000010 66
264
+#define B1000011 67
265
+#define B01000011 67
266
+#define B1000100 68
267
+#define B01000100 68
268
+#define B1000101 69
269
+#define B01000101 69
270
+#define B1000110 70
271
+#define B01000110 70
272
+#define B1000111 71
273
+#define B01000111 71
274
+#define B1001000 72
275
+#define B01001000 72
276
+#define B1001001 73
277
+#define B01001001 73
278
+#define B1001010 74
279
+#define B01001010 74
280
+#define B1001011 75
281
+#define B01001011 75
282
+#define B1001100 76
283
+#define B01001100 76
284
+#define B1001101 77
285
+#define B01001101 77
286
+#define B1001110 78
287
+#define B01001110 78
288
+#define B1001111 79
289
+#define B01001111 79
290
+#define B1010000 80
291
+#define B01010000 80
292
+#define B1010001 81
293
+#define B01010001 81
294
+#define B1010010 82
295
+#define B01010010 82
296
+#define B1010011 83
297
+#define B01010011 83
298
+#define B1010100 84
299
+#define B01010100 84
300
+#define B1010101 85
301
+#define B01010101 85
302
+#define B1010110 86
303
+#define B01010110 86
304
+#define B1010111 87
305
+#define B01010111 87
306
+#define B1011000 88
307
+#define B01011000 88
308
+#define B1011001 89
309
+#define B01011001 89
310
+#define B1011010 90
311
+#define B01011010 90
312
+#define B1011011 91
313
+#define B01011011 91
314
+#define B1011100 92
315
+#define B01011100 92
316
+#define B1011101 93
317
+#define B01011101 93
318
+#define B1011110 94
319
+#define B01011110 94
320
+#define B1011111 95
321
+#define B01011111 95
322
+#define B1100000 96
323
+#define B01100000 96
324
+#define B1100001 97
325
+#define B01100001 97
326
+#define B1100010 98
327
+#define B01100010 98
328
+#define B1100011 99
329
+#define B01100011 99
330
+#define B1100100 100
331
+#define B01100100 100
332
+#define B1100101 101
333
+#define B01100101 101
334
+#define B1100110 102
335
+#define B01100110 102
336
+#define B1100111 103
337
+#define B01100111 103
338
+#define B1101000 104
339
+#define B01101000 104
340
+#define B1101001 105
341
+#define B01101001 105
342
+#define B1101010 106
343
+#define B01101010 106
344
+#define B1101011 107
345
+#define B01101011 107
346
+#define B1101100 108
347
+#define B01101100 108
348
+#define B1101101 109
349
+#define B01101101 109
350
+#define B1101110 110
351
+#define B01101110 110
352
+#define B1101111 111
353
+#define B01101111 111
354
+#define B1110000 112
355
+#define B01110000 112
356
+#define B1110001 113
357
+#define B01110001 113
358
+#define B1110010 114
359
+#define B01110010 114
360
+#define B1110011 115
361
+#define B01110011 115
362
+#define B1110100 116
363
+#define B01110100 116
364
+#define B1110101 117
365
+#define B01110101 117
366
+#define B1110110 118
367
+#define B01110110 118
368
+#define B1110111 119
369
+#define B01110111 119
370
+#define B1111000 120
371
+#define B01111000 120
372
+#define B1111001 121
373
+#define B01111001 121
374
+#define B1111010 122
375
+#define B01111010 122
376
+#define B1111011 123
377
+#define B01111011 123
378
+#define B1111100 124
379
+#define B01111100 124
380
+#define B1111101 125
381
+#define B01111101 125
382
+#define B1111110 126
383
+#define B01111110 126
384
+#define B1111111 127
385
+#define B01111111 127
386
+#define B10000000 128
387
+#define B10000001 129
388
+#define B10000010 130
389
+#define B10000011 131
390
+#define B10000100 132
391
+#define B10000101 133
392
+#define B10000110 134
393
+#define B10000111 135
394
+#define B10001000 136
395
+#define B10001001 137
396
+#define B10001010 138
397
+#define B10001011 139
398
+#define B10001100 140
399
+#define B10001101 141
400
+#define B10001110 142
401
+#define B10001111 143
402
+#define B10010000 144
403
+#define B10010001 145
404
+#define B10010010 146
405
+#define B10010011 147
406
+#define B10010100 148
407
+#define B10010101 149
408
+#define B10010110 150
409
+#define B10010111 151
410
+#define B10011000 152
411
+#define B10011001 153
412
+#define B10011010 154
413
+#define B10011011 155
414
+#define B10011100 156
415
+#define B10011101 157
416
+#define B10011110 158
417
+#define B10011111 159
418
+#define B10100000 160
419
+#define B10100001 161
420
+#define B10100010 162
421
+#define B10100011 163
422
+#define B10100100 164
423
+#define B10100101 165
424
+#define B10100110 166
425
+#define B10100111 167
426
+#define B10101000 168
427
+#define B10101001 169
428
+#define B10101010 170
429
+#define B10101011 171
430
+#define B10101100 172
431
+#define B10101101 173
432
+#define B10101110 174
433
+#define B10101111 175
434
+#define B10110000 176
435
+#define B10110001 177
436
+#define B10110010 178
437
+#define B10110011 179
438
+#define B10110100 180
439
+#define B10110101 181
440
+#define B10110110 182
441
+#define B10110111 183
442
+#define B10111000 184
443
+#define B10111001 185
444
+#define B10111010 186
445
+#define B10111011 187
446
+#define B10111100 188
447
+#define B10111101 189
448
+#define B10111110 190
449
+#define B10111111 191
450
+#define B11000000 192
451
+#define B11000001 193
452
+#define B11000010 194
453
+#define B11000011 195
454
+#define B11000100 196
455
+#define B11000101 197
456
+#define B11000110 198
457
+#define B11000111 199
458
+#define B11001000 200
459
+#define B11001001 201
460
+#define B11001010 202
461
+#define B11001011 203
462
+#define B11001100 204
463
+#define B11001101 205
464
+#define B11001110 206
465
+#define B11001111 207
466
+#define B11010000 208
467
+#define B11010001 209
468
+#define B11010010 210
469
+#define B11010011 211
470
+#define B11010100 212
471
+#define B11010101 213
472
+#define B11010110 214
473
+#define B11010111 215
474
+#define B11011000 216
475
+#define B11011001 217
476
+#define B11011010 218
477
+#define B11011011 219
478
+#define B11011100 220
479
+#define B11011101 221
480
+#define B11011110 222
481
+#define B11011111 223
482
+#define B11100000 224
483
+#define B11100001 225
484
+#define B11100010 226
485
+#define B11100011 227
486
+#define B11100100 228
487
+#define B11100101 229
488
+#define B11100110 230
489
+#define B11100111 231
490
+#define B11101000 232
491
+#define B11101001 233
492
+#define B11101010 234
493
+#define B11101011 235
494
+#define B11101100 236
495
+#define B11101101 237
496
+#define B11101110 238
497
+#define B11101111 239
498
+#define B11110000 240
499
+#define B11110001 241
500
+#define B11110010 242
501
+#define B11110011 243
502
+#define B11110100 244
503
+#define B11110101 245
504
+#define B11110110 246
505
+#define B11110111 247
506
+#define B11111000 248
507
+#define B11111001 249
508
+#define B11111010 250
509
+#define B11111011 251
510
+#define B11111100 252
511
+#define B11111101 253
512
+#define B11111110 254
513
+#define B11111111 255
514
+
515
+#endif

+ 14
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/main.cpp Dosyayı Görüntüle

@@ -0,0 +1,14 @@
1
+#include <WProgram.h>
2
+
3
+int main(void)
4
+{
5
+	init();
6
+
7
+	setup();
8
+    
9
+	for (;;)
10
+		loop();
11
+        
12
+	return 0;
13
+}
14
+

+ 200
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/pins_arduino.c Dosyayı Görüntüle

@@ -0,0 +1,200 @@
1
+/*
2
+  pins_arduino.c - pin definitions for the Arduino board
3
+  Part of Arduino / Wiring Lite
4
+
5
+  Copyright (c) 2005 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
23
+*/
24
+
25
+#include <avr/io.h>
26
+#include "wiring_private.h"
27
+#include "pins_arduino.h"
28
+
29
+// On the Sanguino board, digital pins are also used
30
+// for the analog output (software PWM).  Analog input
31
+// pins are a separate set.
32
+
33
+// ATMEL ATMEGA644P / SANGUINO
34
+//
35
+//                   +---\/---+
36
+//  INT0 (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
37
+//  INT1 (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
38
+//  INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
39
+//   PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
40
+//   PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
41
+//  MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
42
+//  MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
43
+//   SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
44
+//             RST  9|        |32  AREF
45
+//             VCC 10|        |31  GND 
46
+//             GND 11|        |30  AVCC
47
+//           XTAL2 12|        |29  PC7 (D 23)
48
+//           XTAL1 13|        |28  PC6 (D 22)
49
+//  RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
50
+//  TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
51
+//  RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
52
+//  TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
53
+//  PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
54
+//  PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
55
+//  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
56
+//                   +--------+
57
+//
58
+
59
+#define PA 1
60
+#define PB 2
61
+#define PC 3
62
+#define PD 4
63
+
64
+// these arrays map port names (e.g. port B) to the
65
+// appropriate addresses for various functions (e.g. reading
66
+// and writing)
67
+const uint8_t PROGMEM port_to_mode_PGM[] =
68
+{
69
+	NOT_A_PORT,
70
+	(uint8_t) (uint16_t) &DDRA,
71
+	(uint8_t) (uint16_t) &DDRB,
72
+	(uint8_t) (uint16_t) &DDRC,
73
+	(uint8_t) (uint16_t) &DDRD,
74
+};
75
+
76
+const uint8_t PROGMEM port_to_output_PGM[] =
77
+{
78
+	NOT_A_PORT,
79
+	(uint8_t) (uint16_t) &PORTA,
80
+	(uint8_t) (uint16_t) &PORTB,
81
+	(uint8_t) (uint16_t) &PORTC,
82
+	(uint8_t) (uint16_t) &PORTD,
83
+};
84
+
85
+const uint8_t PROGMEM port_to_input_PGM[] =
86
+{
87
+	NOT_A_PORT,
88
+	(uint8_t) (uint16_t) &PINA,
89
+	(uint8_t) (uint16_t) &PINB,
90
+	(uint8_t) (uint16_t) &PINC,
91
+	(uint8_t) (uint16_t) &PIND,
92
+};
93
+
94
+const uint8_t PROGMEM digital_pin_to_port_PGM[] =
95
+{
96
+	PB, /* 0 */
97
+	PB,
98
+	PB,
99
+	PB,
100
+	PB,
101
+	PB,
102
+	PB,
103
+	PB,
104
+	PD, /* 8 */
105
+	PD,
106
+	PD,
107
+	PD,
108
+	PD,
109
+	PD,
110
+	PD,
111
+	PD,
112
+	PC, /* 16 */
113
+	PC,
114
+	PC,
115
+	PC,
116
+	PC,
117
+	PC,
118
+   	PC,
119
+	PC,
120
+	PA, /* 24 */
121
+	PA,
122
+	PA,
123
+	PA,
124
+	PA,
125
+	PA,
126
+	PA,
127
+	PA  /* 31 */
128
+};
129
+
130
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
131
+{
132
+	_BV(0), /* 0, port B */
133
+	_BV(1),
134
+	_BV(2),
135
+	_BV(3),
136
+	_BV(4),
137
+	_BV(5),
138
+	_BV(6),
139
+	_BV(7),
140
+	_BV(0), /* 8, port D */
141
+	_BV(1),
142
+	_BV(2),
143
+	_BV(3),
144
+	_BV(4),
145
+	_BV(5),
146
+	_BV(6),
147
+	_BV(7),
148
+	_BV(0), /* 16, port C */
149
+	_BV(1),
150
+	_BV(2),
151
+	_BV(3),
152
+	_BV(4),
153
+	_BV(5),
154
+	_BV(6),
155
+	_BV(7),
156
+	_BV(7), /* 24, port A */
157
+	_BV(6),
158
+	_BV(5),
159
+	_BV(4),
160
+	_BV(3),
161
+	_BV(2),
162
+	_BV(1),
163
+	_BV(0)
164
+};
165
+
166
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
167
+{
168
+	NOT_ON_TIMER, 	/* 0  - PB0 */
169
+	NOT_ON_TIMER, 	/* 1  - PB1 */
170
+	NOT_ON_TIMER, 	/* 2  - PB2 */
171
+	TIMER0A,     	/* 3  - PB3 */
172
+	TIMER0B, 		/* 4  - PB4 */
173
+	NOT_ON_TIMER, 	/* 5  - PB5 */
174
+	NOT_ON_TIMER, 	/* 6  - PB6 */
175
+	NOT_ON_TIMER,	/* 7  - PB7 */
176
+	NOT_ON_TIMER, 	/* 8  - PD0 */
177
+	NOT_ON_TIMER, 	/* 9  - PD1 */
178
+	NOT_ON_TIMER, 	/* 10 - PD2 */
179
+	NOT_ON_TIMER, 	/* 11 - PD3 */
180
+	TIMER1B,     	/* 12 - PD4 */
181
+	TIMER1A,     	/* 13 - PD5 */
182
+	TIMER2B,     	/* 14 - PD6 */
183
+	TIMER2A,     	/* 15 - PD7 */
184
+	NOT_ON_TIMER, 	/* 16 - PC0 */
185
+	NOT_ON_TIMER,   /* 17 - PC1 */
186
+	NOT_ON_TIMER,   /* 18 - PC2 */
187
+	NOT_ON_TIMER,   /* 19 - PC3 */
188
+	NOT_ON_TIMER,   /* 20 - PC4 */
189
+	NOT_ON_TIMER,   /* 21 - PC5 */
190
+	NOT_ON_TIMER,   /* 22 - PC6 */
191
+	NOT_ON_TIMER,   /* 23 - PC7 */
192
+	NOT_ON_TIMER,   /* 24 - PA0 */
193
+	NOT_ON_TIMER,   /* 25 - PA1 */
194
+	NOT_ON_TIMER,   /* 26 - PA2 */
195
+	NOT_ON_TIMER,   /* 27 - PA3 */
196
+	NOT_ON_TIMER,   /* 28 - PA4 */
197
+	NOT_ON_TIMER,   /* 29 - PA5 */
198
+	NOT_ON_TIMER,   /* 30 - PA6 */
199
+	NOT_ON_TIMER   /* 31 - PA7 */
200
+};

+ 65
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/pins_arduino.h Dosyayı Görüntüle

@@ -0,0 +1,65 @@
1
+/*
2
+  pins_arduino.h - Pin definition functions for Arduino
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2007 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
+*/
24
+
25
+#ifndef Pins_Arduino_h
26
+#define Pins_Arduino_h
27
+
28
+#include <avr/pgmspace.h>
29
+
30
+#define NOT_A_PIN 0
31
+#define NOT_A_PORT 0
32
+
33
+#define NOT_ON_TIMER 0
34
+#define TIMER0A 1
35
+#define TIMER0B 2
36
+#define TIMER1A 3
37
+#define TIMER1B 4
38
+#define TIMER2  5
39
+#define TIMER2A 6
40
+#define TIMER2B 7
41
+
42
+extern const uint8_t PROGMEM port_to_mode_PGM[];
43
+extern const uint8_t PROGMEM port_to_input_PGM[];
44
+extern const uint8_t PROGMEM port_to_output_PGM[];
45
+
46
+extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
47
+extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
48
+extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
49
+
50
+extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
51
+
52
+// Get the bit location within the hardware port of the given virtual pin.
53
+// This comes from the pins_*.c file for the active board configuration.
54
+// 
55
+// These perform slightly better as macros compared to inline functions
56
+//
57
+#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
58
+#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
59
+#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
60
+#define analogInPinToBit(P) (P)
61
+#define portOutputRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_output_PGM + (P))) )
62
+#define portInputRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_input_PGM + (P))) )
63
+#define portModeRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_mode_PGM + (P))) )
64
+
65
+#endif

+ 289
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring.c Dosyayı Görüntüle

@@ -0,0 +1,289 @@
1
+/*
2
+  wiring.c - Partial implementation of the Wiring API for the ATmega8.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id$
23
+*/
24
+
25
+#include "wiring_private.h"
26
+
27
+// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
28
+// the overflow handler is called every 256 ticks.
29
+#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
30
+
31
+// the whole number of milliseconds per timer0 overflow
32
+#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
33
+
34
+// the fractional number of milliseconds per timer0 overflow. we shift right
35
+// by three to fit these numbers into a byte. (for the clock speeds we care
36
+// about - 8 and 16 MHz - this doesn't lose precision.)
37
+#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
38
+#define FRACT_MAX (1000 >> 3)
39
+
40
+volatile unsigned long timer0_overflow_count = 0;
41
+volatile unsigned long timer0_millis = 0;
42
+static unsigned char timer0_fract = 0;
43
+
44
+SIGNAL(TIMER0_OVF_vect)
45
+{
46
+	// copy these to local variables so they can be stored in registers
47
+	// (volatile variables must be read from memory on every access)
48
+	unsigned long m = timer0_millis;
49
+	unsigned char f = timer0_fract;
50
+
51
+	m += MILLIS_INC;
52
+	f += FRACT_INC;
53
+	if (f >= FRACT_MAX) {
54
+		f -= FRACT_MAX;
55
+		m += 1;
56
+	}
57
+
58
+	timer0_fract = f;
59
+	timer0_millis = m;
60
+	timer0_overflow_count++;
61
+}
62
+
63
+unsigned long millis()
64
+{
65
+	unsigned long m;
66
+	uint8_t oldSREG = SREG;
67
+
68
+	// disable interrupts while we read timer0_millis or we might get an
69
+	// inconsistent value (e.g. in the middle of a write to timer0_millis)
70
+	cli();
71
+	m = timer0_millis;
72
+	SREG = oldSREG;
73
+
74
+	return m;
75
+}
76
+
77
+unsigned long micros() {
78
+	unsigned long m;
79
+	uint8_t oldSREG = SREG, t;
80
+	
81
+	cli();
82
+	m = timer0_overflow_count;
83
+#if defined(TCNT0)
84
+	t = TCNT0;
85
+#elif defined(TCNT0L)
86
+	t = TCNT0L;
87
+#else
88
+	#error TIMER 0 not defined
89
+#endif
90
+
91
+  
92
+#ifdef TIFR0
93
+	if ((TIFR0 & _BV(TOV0)) && (t < 255))
94
+		m++;
95
+#else
96
+	if ((TIFR & _BV(TOV0)) && (t < 255))
97
+		m++;
98
+#endif
99
+
100
+	SREG = oldSREG;
101
+	
102
+	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
103
+}
104
+
105
+void delay(unsigned long ms)
106
+{
107
+	uint16_t start = (uint16_t)micros();
108
+
109
+	while (ms > 0) {
110
+		if (((uint16_t)micros() - start) >= 1000) {
111
+			ms--;
112
+			start += 1000;
113
+		}
114
+	}
115
+}
116
+
117
+/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
118
+void delayMicroseconds(unsigned int us)
119
+{
120
+	// calling avrlib's delay_us() function with low values (e.g. 1 or
121
+	// 2 microseconds) gives delays longer than desired.
122
+	//delay_us(us);
123
+
124
+#if F_CPU >= 16000000L
125
+	// for the 16 MHz clock on most Arduino boards
126
+
127
+	// for a one-microsecond delay, simply return.  the overhead
128
+	// of the function call yields a delay of approximately 1 1/8 us.
129
+	if (--us == 0)
130
+		return;
131
+
132
+	// the following loop takes a quarter of a microsecond (4 cycles)
133
+	// per iteration, so execute it four times for each microsecond of
134
+	// delay requested.
135
+	us <<= 2;
136
+
137
+	// account for the time taken in the preceeding commands.
138
+	us -= 2;
139
+#else
140
+	// for the 8 MHz internal clock on the ATmega168
141
+
142
+	// for a one- or two-microsecond delay, simply return.  the overhead of
143
+	// the function calls takes more than two microseconds.  can't just
144
+	// subtract two, since us is unsigned; we'd overflow.
145
+	if (--us == 0)
146
+		return;
147
+	if (--us == 0)
148
+		return;
149
+
150
+	// the following loop takes half of a microsecond (4 cycles)
151
+	// per iteration, so execute it twice for each microsecond of
152
+	// delay requested.
153
+	us <<= 1;
154
+    
155
+	// partially compensate for the time taken by the preceeding commands.
156
+	// we can't subtract any more than this or we'd overflow w/ small delays.
157
+	us--;
158
+#endif
159
+
160
+	// busy wait
161
+	__asm__ __volatile__ (
162
+		"1: sbiw %0,1" "\n\t" // 2 cycles
163
+		"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
164
+	);
165
+}
166
+
167
+void init()
168
+{
169
+	// this needs to be called before setup() or some functions won't
170
+	// work there
171
+	sei();
172
+	
173
+	// on the ATmega168, timer 0 is also used for fast hardware pwm
174
+	// (using phase-correct PWM would mean that timer 0 overflowed half as often
175
+	// resulting in different millis() behavior on the ATmega8 and ATmega168)
176
+#if defined(TCCR0A) && defined(WGM01)
177
+	sbi(TCCR0A, WGM01);
178
+	sbi(TCCR0A, WGM00);
179
+#endif  
180
+
181
+	// set timer 0 prescale factor to 64
182
+#if defined(__AVR_ATmega128__)
183
+	// CPU specific: different values for the ATmega128
184
+	sbi(TCCR0, CS02);
185
+#elif defined(TCCR0) && defined(CS01) && defined(CS00)
186
+	// this combination is for the standard atmega8
187
+	sbi(TCCR0, CS01);
188
+	sbi(TCCR0, CS00);
189
+#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
190
+	// this combination is for the standard 168/328/1280/2560
191
+	sbi(TCCR0B, CS01);
192
+	sbi(TCCR0B, CS00);
193
+#elif defined(TCCR0A) && defined(CS01) && defined(CS00)
194
+	// this combination is for the __AVR_ATmega645__ series
195
+	sbi(TCCR0A, CS01);
196
+	sbi(TCCR0A, CS00);
197
+#else
198
+	#error Timer 0 prescale factor 64 not set correctly
199
+#endif
200
+
201
+	// enable timer 0 overflow interrupt
202
+#if defined(TIMSK) && defined(TOIE0)
203
+	sbi(TIMSK, TOIE0);
204
+#elif defined(TIMSK0) && defined(TOIE0)
205
+	sbi(TIMSK0, TOIE0);
206
+#else
207
+	#error	Timer 0 overflow interrupt not set correctly
208
+#endif
209
+
210
+	// timers 1 and 2 are used for phase-correct hardware pwm
211
+	// this is better for motors as it ensures an even waveform
212
+	// note, however, that fast pwm mode can achieve a frequency of up
213
+	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
214
+
215
+	TCCR1B = 0;
216
+
217
+	// set timer 1 prescale factor to 64
218
+#if defined(TCCR1B) && defined(CS11) && defined(CS10)
219
+	sbi(TCCR1B, CS11);
220
+	sbi(TCCR1B, CS10);
221
+#elif defined(TCCR1) && defined(CS11) && defined(CS10)
222
+	sbi(TCCR1, CS11);
223
+	sbi(TCCR1, CS10);
224
+#endif
225
+	// put timer 1 in 8-bit phase correct pwm mode
226
+#if defined(TCCR1A) && defined(WGM10)
227
+	sbi(TCCR1A, WGM10);
228
+#elif defined(TCCR1)
229
+	#warning this needs to be finished
230
+#endif
231
+
232
+	// set timer 2 prescale factor to 64
233
+#if defined(TCCR2) && defined(CS22)
234
+	sbi(TCCR2, CS22);
235
+#elif defined(TCCR2B) && defined(CS22)
236
+	sbi(TCCR2B, CS22);
237
+#else
238
+	#warning Timer 2 not finished (may not be present on this CPU)
239
+#endif
240
+
241
+	// configure timer 2 for phase correct pwm (8-bit)
242
+#if defined(TCCR2) && defined(WGM20)
243
+	sbi(TCCR2, WGM20);
244
+#elif defined(TCCR2A) && defined(WGM20)
245
+	sbi(TCCR2A, WGM20);
246
+#else
247
+	#warning Timer 2 not finished (may not be present on this CPU)
248
+#endif
249
+
250
+#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
251
+	sbi(TCCR3B, CS31);		// set timer 3 prescale factor to 64
252
+	sbi(TCCR3B, CS30);
253
+	sbi(TCCR3A, WGM30);		// put timer 3 in 8-bit phase correct pwm mode
254
+#endif
255
+	
256
+#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
257
+	sbi(TCCR4B, CS41);		// set timer 4 prescale factor to 64
258
+	sbi(TCCR4B, CS40);
259
+	sbi(TCCR4A, WGM40);		// put timer 4 in 8-bit phase correct pwm mode
260
+#endif
261
+
262
+#if defined(TCCR5B) && defined(CS51) && defined(WGM50)
263
+	sbi(TCCR5B, CS51);		// set timer 5 prescale factor to 64
264
+	sbi(TCCR5B, CS50);
265
+	sbi(TCCR5A, WGM50);		// put timer 5 in 8-bit phase correct pwm mode
266
+#endif
267
+
268
+#if defined(ADCSRA)
269
+	// set a2d prescale factor to 128
270
+	// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
271
+	// XXX: this will not work properly for other clock speeds, and
272
+	// this code should use F_CPU to determine the prescale factor.
273
+	sbi(ADCSRA, ADPS2);
274
+	sbi(ADCSRA, ADPS1);
275
+	sbi(ADCSRA, ADPS0);
276
+
277
+	// enable a2d conversions
278
+	sbi(ADCSRA, ADEN);
279
+#endif
280
+
281
+	// the bootloader connects pins 0 and 1 to the USART; disconnect them
282
+	// here so they can be used as normal digital i/o; they will be
283
+	// reconnected in Serial.begin()
284
+#if defined(UCSRB)
285
+	UCSRB = 0;
286
+#elif defined(UCSR0B)
287
+	UCSR0B = 0;
288
+#endif
289
+}

+ 136
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring.h Dosyayı Görüntüle

@@ -0,0 +1,136 @@
1
+/*
2
+  wiring.h - Partial implementation of the Wiring API for the ATmega8.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id$
23
+*/
24
+
25
+#ifndef Wiring_h
26
+#define Wiring_h
27
+
28
+#include <math.h>
29
+#include <avr/io.h>
30
+#include <stdlib.h>
31
+#include "binary.h"
32
+
33
+#ifdef __cplusplus
34
+extern "C"{
35
+#endif
36
+
37
+#define HIGH 0x1
38
+#define LOW  0x0
39
+
40
+#define INPUT 0x0
41
+#define OUTPUT 0x1
42
+
43
+#define true 0x1
44
+#define false 0x0
45
+
46
+#define PI 3.1415926535897932384626433832795
47
+#define HALF_PI 1.5707963267948966192313216916398
48
+#define TWO_PI 6.283185307179586476925286766559
49
+#define DEG_TO_RAD 0.017453292519943295769236907684886
50
+#define RAD_TO_DEG 57.295779513082320876798154814105
51
+
52
+#define SERIAL  0x0
53
+#define DISPLAY 0x1
54
+
55
+#define LSBFIRST 0
56
+#define MSBFIRST 1
57
+
58
+#define CHANGE 1
59
+#define FALLING 2
60
+#define RISING 3
61
+
62
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
63
+#define INTERNAL1V1 2
64
+#define INTERNAL2V56 3
65
+#else
66
+#define INTERNAL 3
67
+#endif
68
+#define DEFAULT 1
69
+#define EXTERNAL 0
70
+
71
+// undefine stdlib's abs if encountered
72
+#ifdef abs
73
+#undef abs
74
+#endif
75
+
76
+#define min(a,b) ((a)<(b)?(a):(b))
77
+#define max(a,b) ((a)>(b)?(a):(b))
78
+#define abs(x) ((x)>0?(x):-(x))
79
+#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
80
+#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
81
+#define radians(deg) ((deg)*DEG_TO_RAD)
82
+#define degrees(rad) ((rad)*RAD_TO_DEG)
83
+#define sq(x) ((x)*(x))
84
+
85
+#define interrupts() sei()
86
+#define noInterrupts() cli()
87
+
88
+#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
89
+#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
90
+#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
91
+
92
+#define lowByte(w) ((uint8_t) ((w) & 0xff))
93
+#define highByte(w) ((uint8_t) ((w) >> 8))
94
+
95
+#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
96
+#define bitSet(value, bit) ((value) |= (1UL << (bit)))
97
+#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
98
+#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
99
+
100
+
101
+typedef unsigned int word;
102
+
103
+#define bit(b) (1UL << (b))
104
+
105
+typedef uint8_t boolean;
106
+typedef uint8_t byte;
107
+
108
+void init(void);
109
+
110
+void pinMode(uint8_t, uint8_t);
111
+void digitalWrite(uint8_t, uint8_t);
112
+int digitalRead(uint8_t);
113
+int analogRead(uint8_t);
114
+void analogReference(uint8_t mode);
115
+void analogWrite(uint8_t, int);
116
+
117
+unsigned long millis(void);
118
+unsigned long micros(void);
119
+void delay(unsigned long);
120
+void delayMicroseconds(unsigned int us);
121
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
122
+
123
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
124
+uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
125
+
126
+void attachInterrupt(uint8_t, void (*)(void), int mode);
127
+void detachInterrupt(uint8_t);
128
+
129
+void setup(void);
130
+void loop(void);
131
+
132
+#ifdef __cplusplus
133
+} // extern "C"
134
+#endif
135
+
136
+#endif

+ 259
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_analog.c Dosyayı Görüntüle

@@ -0,0 +1,259 @@
1
+/*
2
+  wiring_analog.c - analog input and output
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  Modified 28 September 2010 by Mark Sproul
23
+
24
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
25
+*/
26
+
27
+#include "wiring_private.h"
28
+#include "pins_arduino.h"
29
+
30
+uint8_t analog_reference = DEFAULT;
31
+
32
+void analogReference(uint8_t mode)
33
+{
34
+	// can't actually set the register here because the default setting
35
+	// will connect AVCC and the AREF pin, which would cause a short if
36
+	// there's something connected to AREF.
37
+	analog_reference = mode;
38
+}
39
+
40
+int analogRead(uint8_t pin)
41
+{
42
+	uint8_t low, high;
43
+
44
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
45
+	if (pin >= 54) pin -= 54; // allow for channel or pin numbers
46
+#else
47
+	if (pin >= 14) pin -= 14; // allow for channel or pin numbers
48
+#endif
49
+
50
+#if defined(ADCSRB) && defined(MUX5)
51
+	// the MUX5 bit of ADCSRB selects whether we're reading from channels
52
+	// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
53
+	ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
54
+#endif
55
+  
56
+	// set the analog reference (high two bits of ADMUX) and select the
57
+	// channel (low 4 bits).  this also sets ADLAR (left-adjust result)
58
+	// to 0 (the default).
59
+#if defined(ADMUX)
60
+	ADMUX = (analog_reference << 6) | (pin & 0x07);
61
+#endif
62
+
63
+	// without a delay, we seem to read from the wrong channel
64
+	//delay(1);
65
+
66
+#if defined(ADCSRA) && defined(ADCL)
67
+	// start the conversion
68
+	sbi(ADCSRA, ADSC);
69
+
70
+	// ADSC is cleared when the conversion finishes
71
+	while (bit_is_set(ADCSRA, ADSC));
72
+
73
+	// we have to read ADCL first; doing so locks both ADCL
74
+	// and ADCH until ADCH is read.  reading ADCL second would
75
+	// cause the results of each conversion to be discarded,
76
+	// as ADCL and ADCH would be locked when it completed.
77
+	low  = ADCL;
78
+	high = ADCH;
79
+#else
80
+	// we dont have an ADC, return 0
81
+	low  = 0;
82
+	high = 0;
83
+#endif
84
+
85
+	// combine the two bytes
86
+	return (high << 8) | low;
87
+}
88
+
89
+// Right now, PWM output only works on the pins with
90
+// hardware support.  These are defined in the appropriate
91
+// pins_*.c file.  For the rest of the pins, we default
92
+// to digital output.
93
+void analogWrite(uint8_t pin, int val)
94
+{
95
+	// We need to make sure the PWM output is enabled for those pins
96
+	// that support it, as we turn it off when digitally reading or
97
+	// writing with them.  Also, make sure the pin is in output mode
98
+	// for consistenty with Wiring, which doesn't require a pinMode
99
+	// call for the analog output pins.
100
+	pinMode(pin, OUTPUT);
101
+	if (val == 0)
102
+	{
103
+		digitalWrite(pin, LOW);
104
+	}
105
+	else if (val == 255)
106
+	{
107
+		digitalWrite(pin, HIGH);
108
+	}
109
+	else
110
+	{
111
+		switch(digitalPinToTimer(pin))
112
+		{
113
+			// XXX fix needed for atmega8
114
+			#if defined(TCCR0) && defined(COM00) && !defined(__AVR_ATmega8__)
115
+			case TIMER0A:
116
+				// connect pwm to pin on timer 0
117
+				sbi(TCCR0, COM00);
118
+				OCR0 = val; // set pwm duty
119
+				break;
120
+			#endif
121
+
122
+			#if defined(TCCR0A) && defined(COM0A1)
123
+			case TIMER0A:
124
+				// connect pwm to pin on timer 0, channel A
125
+				sbi(TCCR0A, COM0A1);
126
+				OCR0A = val; // set pwm duty
127
+				break;
128
+			#endif
129
+
130
+			#if defined(TCCR0A) && defined(COM0B1)
131
+			case TIMER0B:
132
+				// connect pwm to pin on timer 0, channel B
133
+				sbi(TCCR0A, COM0B1);
134
+				OCR0B = val; // set pwm duty
135
+				break;
136
+			#endif
137
+
138
+			#if defined(TCCR1A) && defined(COM1A1)
139
+			case TIMER1A:
140
+				// connect pwm to pin on timer 1, channel A
141
+				sbi(TCCR1A, COM1A1);
142
+				OCR1A = val; // set pwm duty
143
+				break;
144
+			#endif
145
+
146
+			#if defined(TCCR1A) && defined(COM1B1)
147
+			case TIMER1B:
148
+				// connect pwm to pin on timer 1, channel B
149
+				sbi(TCCR1A, COM1B1);
150
+				OCR1B = val; // set pwm duty
151
+				break;
152
+			#endif
153
+
154
+			#if defined(TCCR2) && defined(COM21)
155
+			case TIMER2:
156
+				// connect pwm to pin on timer 2
157
+				sbi(TCCR2, COM21);
158
+				OCR2 = val; // set pwm duty
159
+				break;
160
+			#endif
161
+
162
+			#if defined(TCCR2A) && defined(COM2A1)
163
+			case TIMER2A:
164
+				// connect pwm to pin on timer 2, channel A
165
+				sbi(TCCR2A, COM2A1);
166
+				OCR2A = val; // set pwm duty
167
+				break;
168
+			#endif
169
+
170
+			#if defined(TCCR2A) && defined(COM2B1)
171
+			case TIMER2B:
172
+				// connect pwm to pin on timer 2, channel B
173
+				sbi(TCCR2A, COM2B1);
174
+				OCR2B = val; // set pwm duty
175
+				break;
176
+			#endif
177
+
178
+			#if defined(TCCR3A) && defined(COM3A1)
179
+			case TIMER3A:
180
+				// connect pwm to pin on timer 3, channel A
181
+				sbi(TCCR3A, COM3A1);
182
+				OCR3A = val; // set pwm duty
183
+				break;
184
+			#endif
185
+
186
+			#if defined(TCCR3A) && defined(COM3B1)
187
+			case TIMER3B:
188
+				// connect pwm to pin on timer 3, channel B
189
+				sbi(TCCR3A, COM3B1);
190
+				OCR3B = val; // set pwm duty
191
+				break;
192
+			#endif
193
+
194
+			#if defined(TCCR3A) && defined(COM3C1)
195
+			case TIMER3C:
196
+				// connect pwm to pin on timer 3, channel C
197
+				sbi(TCCR3A, COM3C1);
198
+				OCR3C = val; // set pwm duty
199
+				break;
200
+			#endif
201
+
202
+			#if defined(TCCR4A) && defined(COM4A1)
203
+			case TIMER4A:
204
+				// connect pwm to pin on timer 4, channel A
205
+				sbi(TCCR4A, COM4A1);
206
+				OCR4A = val; // set pwm duty
207
+				break;
208
+			#endif
209
+
210
+			#if defined(TCCR4A) && defined(COM4B1)
211
+			case TIMER4B:
212
+				// connect pwm to pin on timer 4, channel B
213
+				sbi(TCCR4A, COM4B1);
214
+				OCR4B = val; // set pwm duty
215
+				break;
216
+			#endif
217
+
218
+			#if defined(TCCR4A) && defined(COM4C1)
219
+			case TIMER4C:
220
+				// connect pwm to pin on timer 4, channel C
221
+				sbi(TCCR4A, COM4C1);
222
+				OCR4C = val; // set pwm duty
223
+				break;
224
+			#endif
225
+
226
+			#if defined(TCCR5A) && defined(COM5A1)
227
+			case TIMER5A:
228
+				// connect pwm to pin on timer 5, channel A
229
+				sbi(TCCR5A, COM5A1);
230
+				OCR5A = val; // set pwm duty
231
+				break;
232
+			#endif
233
+
234
+			#if defined(TCCR5A) && defined(COM5B1)
235
+			case TIMER5B:
236
+				// connect pwm to pin on timer 5, channel B
237
+				sbi(TCCR5A, COM5B1);
238
+				OCR5B = val; // set pwm duty
239
+				break;
240
+			#endif
241
+
242
+			#if defined(TCCR5A) && defined(COM5C1)
243
+			case TIMER5C:
244
+				// connect pwm to pin on timer 5, channel C
245
+				sbi(TCCR5A, COM5C1);
246
+				OCR5C = val; // set pwm duty
247
+				break;
248
+			#endif
249
+
250
+			case NOT_ON_TIMER:
251
+			default:
252
+				if (val < 128) {
253
+					digitalWrite(pin, LOW);
254
+				} else {
255
+					digitalWrite(pin, HIGH);
256
+				}
257
+		}
258
+	}
259
+}

+ 166
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_digital.c Dosyayı Görüntüle

@@ -0,0 +1,166 @@
1
+/*
2
+  wiring_digital.c - digital input and output functions
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  Modified 28 September 2010 by Mark Sproul
23
+
24
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
25
+*/
26
+
27
+#include "wiring_private.h"
28
+#include "pins_arduino.h"
29
+
30
+void pinMode(uint8_t pin, uint8_t mode)
31
+{
32
+	uint8_t bit = digitalPinToBitMask(pin);
33
+	uint8_t port = digitalPinToPort(pin);
34
+	volatile uint8_t *reg;
35
+
36
+	if (port == NOT_A_PIN) return;
37
+
38
+	// JWS: can I let the optimizer do this?
39
+	reg = portModeRegister(port);
40
+
41
+	if (mode == INPUT) { 
42
+		uint8_t oldSREG = SREG;
43
+                cli();
44
+		*reg &= ~bit;
45
+		SREG = oldSREG;
46
+	} else {
47
+		uint8_t oldSREG = SREG;
48
+                cli();
49
+		*reg |= bit;
50
+		SREG = oldSREG;
51
+	}
52
+}
53
+
54
+// Forcing this inline keeps the callers from having to push their own stuff
55
+// on the stack. It is a good performance win and only takes 1 more byte per
56
+// user than calling. (It will take more bytes on the 168.)
57
+//
58
+// But shouldn't this be moved into pinMode? Seems silly to check and do on
59
+// each digitalread or write.
60
+//
61
+// Mark Sproul:
62
+// - Removed inline. Save 170 bytes on atmega1280
63
+// - changed to a switch statment; added 32 bytes but much easier to read and maintain.
64
+// - Added more #ifdefs, now compiles for atmega645
65
+//
66
+//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
67
+//static inline void turnOffPWM(uint8_t timer)
68
+static void turnOffPWM(uint8_t timer)
69
+{
70
+	switch (timer)
71
+	{
72
+		#if defined(TCCR1A) && defined(COM1A1)
73
+		case TIMER1A:   cbi(TCCR1A, COM1A1);    break;
74
+		#endif
75
+		#if defined(TCCR1A) && defined(COM1B1)
76
+		case TIMER1B:   cbi(TCCR1A, COM1B1);    break;
77
+		#endif
78
+		
79
+		#if defined(TCCR2) && defined(COM21)
80
+		case  TIMER2:   cbi(TCCR2, COM21);      break;
81
+		#endif
82
+		
83
+		#if defined(TCCR0A) && defined(COM0A1)
84
+		case  TIMER0A:  cbi(TCCR0A, COM0A1);    break;
85
+		#endif
86
+		
87
+		#if defined(TIMER0B) && defined(COM0B1)
88
+		case  TIMER0B:  cbi(TCCR0A, COM0B1);    break;
89
+		#endif
90
+		#if defined(TCCR2A) && defined(COM2A1)
91
+		case  TIMER2A:  cbi(TCCR2A, COM2A1);    break;
92
+		#endif
93
+		#if defined(TCCR2A) && defined(COM2B1)
94
+		case  TIMER2B:  cbi(TCCR2A, COM2B1);    break;
95
+		#endif
96
+		
97
+		#if defined(TCCR3A) && defined(COM3A1)
98
+		case  TIMER3A:  cbi(TCCR3A, COM3A1);    break;
99
+		#endif
100
+		#if defined(TCCR3A) && defined(COM3B1)
101
+		case  TIMER3B:  cbi(TCCR3A, COM3B1);    break;
102
+		#endif
103
+		#if defined(TCCR3A) && defined(COM3C1)
104
+		case  TIMER3C:  cbi(TCCR3A, COM3C1);    break;
105
+		#endif
106
+
107
+		#if defined(TCCR4A) && defined(COM4A1)
108
+		case  TIMER4A:  cbi(TCCR4A, COM4A1);    break;
109
+		#endif
110
+		#if defined(TCCR4A) && defined(COM4B1)
111
+		case  TIMER4B:  cbi(TCCR4A, COM4B1);    break;
112
+		#endif
113
+		#if defined(TCCR4A) && defined(COM4C1)
114
+		case  TIMER4C:  cbi(TCCR4A, COM4C1);    break;
115
+		#endif
116
+		#if defined(TCCR5A)
117
+		case  TIMER5A:  cbi(TCCR5A, COM5A1);    break;
118
+		case  TIMER5B:  cbi(TCCR5A, COM5B1);    break;
119
+		case  TIMER5C:  cbi(TCCR5A, COM5C1);    break;
120
+		#endif
121
+	}
122
+}
123
+
124
+void digitalWrite(uint8_t pin, uint8_t val)
125
+{
126
+	uint8_t timer = digitalPinToTimer(pin);
127
+	uint8_t bit = digitalPinToBitMask(pin);
128
+	uint8_t port = digitalPinToPort(pin);
129
+	volatile uint8_t *out;
130
+
131
+	if (port == NOT_A_PIN) return;
132
+
133
+	// If the pin that support PWM output, we need to turn it off
134
+	// before doing a digital write.
135
+	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
136
+
137
+	out = portOutputRegister(port);
138
+
139
+	if (val == LOW) {
140
+		uint8_t oldSREG = SREG;
141
+                cli();
142
+		*out &= ~bit;
143
+		SREG = oldSREG;
144
+	} else {
145
+		uint8_t oldSREG = SREG;
146
+                cli();
147
+		*out |= bit;
148
+		SREG = oldSREG;
149
+	}
150
+}
151
+
152
+int digitalRead(uint8_t pin)
153
+{
154
+	uint8_t timer = digitalPinToTimer(pin);
155
+	uint8_t bit = digitalPinToBitMask(pin);
156
+	uint8_t port = digitalPinToPort(pin);
157
+
158
+	if (port == NOT_A_PIN) return LOW;
159
+
160
+	// If the pin that support PWM output, we need to turn it off
161
+	// before getting a digital reading.
162
+	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
163
+
164
+	if (*portInputRegister(port) & bit) return HIGH;
165
+	return LOW;
166
+}

+ 68
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_private.h Dosyayı Görüntüle

@@ -0,0 +1,68 @@
1
+/*
2
+  wiring_private.h - Internal header file.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
23
+*/
24
+
25
+#ifndef WiringPrivate_h
26
+#define WiringPrivate_h
27
+#include <math.h>
28
+#include <avr/io.h>
29
+#include <avr/interrupt.h>
30
+#include <util/delay.h>
31
+#include <stdio.h>
32
+#include <stdarg.h>
33
+
34
+#include "wiring.h"
35
+
36
+#ifdef __cplusplus
37
+extern "C"{
38
+#endif
39
+
40
+#ifndef cbi
41
+#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
42
+#endif
43
+#ifndef sbi
44
+#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
45
+#endif
46
+
47
+#define EXTERNAL_INT_0 0
48
+#define EXTERNAL_INT_1 1
49
+#define EXTERNAL_INT_2 2
50
+#define EXTERNAL_INT_3 3
51
+#define EXTERNAL_INT_4 4
52
+#define EXTERNAL_INT_5 5
53
+#define EXTERNAL_INT_6 6
54
+#define EXTERNAL_INT_7 7
55
+
56
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
57
+#define EXTERNAL_NUM_INTERRUPTS 8
58
+#else
59
+#define EXTERNAL_NUM_INTERRUPTS 2
60
+#endif
61
+
62
+typedef void (*voidFuncPtr)(void);
63
+
64
+#ifdef __cplusplus
65
+} // extern "C"
66
+#endif
67
+
68
+#endif

+ 69
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_pulse.c Dosyayı Görüntüle

@@ -0,0 +1,69 @@
1
+/*
2
+  wiring_pulse.c - pulseIn() function
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
+*/
24
+
25
+#include "wiring_private.h"
26
+#include "pins_arduino.h"
27
+
28
+/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
29
+ * or LOW, the type of pulse to measure.  Works on pulses from 2-3 microseconds
30
+ * to 3 minutes in length, but must be called at least a few dozen microseconds
31
+ * before the start of the pulse. */
32
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
33
+{
34
+	// cache the port and bit of the pin in order to speed up the
35
+	// pulse width measuring loop and achieve finer resolution.  calling
36
+	// digitalRead() instead yields much coarser resolution.
37
+	uint8_t bit = digitalPinToBitMask(pin);
38
+	uint8_t port = digitalPinToPort(pin);
39
+	uint8_t stateMask = (state ? bit : 0);
40
+	unsigned long width = 0; // keep initialization out of time critical area
41
+	
42
+	// convert the timeout from microseconds to a number of times through
43
+	// the initial loop; it takes 16 clock cycles per iteration.
44
+	unsigned long numloops = 0;
45
+	unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
46
+	
47
+	// wait for any previous pulse to end
48
+	while ((*portInputRegister(port) & bit) == stateMask)
49
+		if (numloops++ == maxloops)
50
+			return 0;
51
+	
52
+	// wait for the pulse to start
53
+	while ((*portInputRegister(port) & bit) != stateMask)
54
+		if (numloops++ == maxloops)
55
+			return 0;
56
+	
57
+	// wait for the pulse to stop
58
+	while ((*portInputRegister(port) & bit) == stateMask) {
59
+		if (numloops++ == maxloops)
60
+			return 0;
61
+		width++;
62
+	}
63
+
64
+	// convert the reading to microseconds. The loop has been determined
65
+	// to be 20 clock cycles long and have about 16 clocks between the edge
66
+	// and the start of the loop. There will be some error introduced by
67
+	// the interrupt handlers.
68
+	return clockCyclesToMicroseconds(width * 21 + 16); 
69
+}

+ 55
- 0
ArduinoAddons/Arduino_0.xx/Gen6/cores/arduino/wiring_shift.c Dosyayı Görüntüle

@@ -0,0 +1,55 @@
1
+/*
2
+  wiring_shift.c - shiftOut() function
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
+*/
24
+
25
+#include "wiring_private.h"
26
+
27
+uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
28
+	uint8_t value = 0;
29
+	uint8_t i;
30
+
31
+	for (i = 0; i < 8; ++i) {
32
+		digitalWrite(clockPin, HIGH);
33
+		if (bitOrder == LSBFIRST)
34
+			value |= digitalRead(dataPin) << i;
35
+		else
36
+			value |= digitalRead(dataPin) << (7 - i);
37
+		digitalWrite(clockPin, LOW);
38
+	}
39
+	return value;
40
+}
41
+
42
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
43
+{
44
+	uint8_t i;
45
+
46
+	for (i = 0; i < 8; i++)  {
47
+		if (bitOrder == LSBFIRST)
48
+			digitalWrite(dataPin, !!(val & (1 << i)));
49
+		else	
50
+			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
51
+			
52
+		digitalWrite(clockPin, HIGH);
53
+		digitalWrite(clockPin, LOW);		
54
+	}
55
+}

+ 101
- 0
ArduinoAddons/Arduino_0.xx/Gen7/boards.txt Dosyayı Görüntüle

@@ -0,0 +1,101 @@
1
+##############################################################
2
+
3
+Gen7-644-16.name=Gen7 with ATmega644 and 16 MHz
4
+Gen7-644-16.upload.protocol=stk500v2
5
+Gen7-644-16.upload.maximum_size=63488
6
+Gen7-644-16.upload.speed=115200
7
+Gen7-644-16.bootloader.low_fuses=0xF7
8
+Gen7-644-16.bootloader.high_fuses=0xD4
9
+Gen7-644-16.bootloader.extended_fuses=0xFD
10
+Gen7-644-16.bootloader.path=Gen7
11
+Gen7-644-16.bootloader.file=bootloader-644-16MHz.hex
12
+Gen7-644-16.bootloader.unlock_bits=0x3F
13
+Gen7-644-16.bootloader.lock_bits=0x0F
14
+Gen7-644-16.build.mcu=atmega644
15
+Gen7-644-16.build.f_cpu=16000000L
16
+Gen7-644-16.build.core=arduino
17
+
18
+##############################################################
19
+
20
+Gen7-644-20.name=Gen7 with ATmega644 and 20 MHz
21
+Gen7-644-20.upload.protocol=stk500v2
22
+Gen7-644-20.upload.maximum_size=63488
23
+Gen7-644-20.upload.speed=115200
24
+Gen7-644-20.bootloader.low_fuses=0xF7
25
+Gen7-644-20.bootloader.high_fuses=0xD4
26
+Gen7-644-20.bootloader.extended_fuses=0xFD
27
+Gen7-644-20.bootloader.path=Gen7
28
+Gen7-644-20.bootloader.file=bootloader-644-20MHz.hex
29
+Gen7-644-20.bootloader.unlock_bits=0x3F
30
+Gen7-644-20.bootloader.lock_bits=0x0F
31
+Gen7-644-20.build.mcu=atmega644
32
+Gen7-644-20.build.f_cpu=20000000L
33
+Gen7-644-20.build.core=arduino
34
+
35
+##############################################################
36
+
37
+Gen7-644P-16.name=Gen7 with ATmega644P and 16 MHz
38
+Gen7-644P-16.upload.protocol=stk500v2
39
+Gen7-644P-16.upload.maximum_size=63488
40
+Gen7-644P-16.upload.speed=115200
41
+Gen7-644P-16.bootloader.low_fuses=0xF7
42
+Gen7-644P-16.bootloader.high_fuses=0xD4
43
+Gen7-644P-16.bootloader.extended_fuses=0xFD
44
+Gen7-644P-16.bootloader.path=Gen7
45
+Gen7-644P-16.bootloader.file=bootloader-644P-16MHz.hex
46
+Gen7-644P-16.bootloader.unlock_bits=0x3F
47
+Gen7-644P-16.bootloader.lock_bits=0x0F
48
+Gen7-644P-16.build.mcu=atmega644p
49
+Gen7-644P-16.build.f_cpu=16000000L
50
+Gen7-644P-16.build.core=arduino
51
+
52
+##############################################################
53
+
54
+Gen7-644P-20.name=Gen7 with ATmega644P and 20 MHz
55
+Gen7-644P-20.upload.protocol=stk500v2
56
+Gen7-644P-20.upload.maximum_size=63488
57
+Gen7-644P-20.upload.speed=115200
58
+Gen7-644P-20.bootloader.low_fuses=0xF7
59
+Gen7-644P-20.bootloader.high_fuses=0xD4
60
+Gen7-644P-20.bootloader.extended_fuses=0xFD
61
+Gen7-644P-20.bootloader.path=Gen7
62
+Gen7-644P-20.bootloader.file=bootloader-644P-20MHz.hex
63
+Gen7-644P-20.bootloader.unlock_bits=0x3F
64
+Gen7-644P-20.bootloader.lock_bits=0x0F
65
+Gen7-644P-20.build.mcu=atmega644p
66
+Gen7-644P-20.build.f_cpu=20000000L
67
+Gen7-644P-20.build.core=arduino
68
+
69
+##############################################################
70
+
71
+Gen7-1284p-16.name=Gen7 with ATmega1284 and 16 MHz
72
+Gen7-1284p-16.upload.protocol=stk500v2
73
+Gen7-1284p-16.upload.maximum_size=129024
74
+Gen7-1284p-16.upload.speed=115200
75
+Gen7-1284p-16.bootloader.low_fuses=0xF7
76
+Gen7-1284p-16.bootloader.high_fuses=0xD4
77
+Gen7-1284p-16.bootloader.extended_fuses=0xFD
78
+Gen7-1284p-16.bootloader.path=Gen7
79
+Gen7-1284p-16.bootloader.file=bootloader-1284P-16MHz.hex
80
+Gen7-1284p-16.bootloader.unlock_bits=0x3F
81
+Gen7-1284p-16.bootloader.lock_bits=0x2F
82
+Gen7-1284p-16.build.mcu=atmega1284p
83
+Gen7-1284p-16.build.f_cpu=16000000L
84
+Gen7-1284p-16.build.core=arduino
85
+
86
+##############################################################
87
+
88
+Gen7-1284p-20.name=Gen7 with ATmega1284 and 20 MHz
89
+Gen7-1284p-20.upload.protocol=stk500v2
90
+Gen7-1284p-20.upload.maximum_size=129024
91
+Gen7-1284p-20.upload.speed=115200
92
+Gen7-1284p-20.bootloader.low_fuses=0xF7
93
+Gen7-1284p-20.bootloader.high_fuses=0xD4
94
+Gen7-1284p-20.bootloader.extended_fuses=0xFD
95
+Gen7-1284p-20.bootloader.path=Gen7
96
+Gen7-1284p-20.bootloader.file=bootloader-1284P-16MHz.hex
97
+Gen7-1284p-20.bootloader.unlock_bits=0x3F
98
+Gen7-1284p-20.bootloader.lock_bits=0x2F
99
+Gen7-1284p-20.build.mcu=atmega1284p
100
+Gen7-1284p-20.build.f_cpu=20000000L
101
+Gen7-1284p-20.build.core=arduino

+ 113
- 0
ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-1284P-16MHz.hex Dosyayı Görüntüle

@@ -0,0 +1,113 @@
1
+:020000021000EC
2
+:10F8000011241FBE8FEF90E49EBF8DBF01C32F92C6
3
+:10F810003F924F925F926F927F928F929F92AF92A0
4
+:10F82000BF92CF92DF92EF92FF920F931F93DF93DD
5
+:10F83000CF93CDB7DEB7C252D1400FB6F894DEBF3A
6
+:10F840000FBECDBF44245524DD24C25EDE4F188296
7
+:10F85000CE51D1408824992454013AC20E9428FFF5
8
+:10F86000282F133059F1143028F4113081F0123060
9
+:10F8700000F507C0153081F1153030F1163071F701
10
+:10F880003DC08B3159F711E05BE1D52EE7CF8130D8
11
+:10F8900041F0C25EDE4F3881CE51D140831709F06E
12
+:10F8A00019C2D226C25EDE4F2883CE51D14012E06B
13
+:10F8B000D5CFF82EEE24D82613E0D0CF90E0E82A5A
14
+:10F8C000F92AD22614E0CACF8E3009F003C2D82616
15
+:10F8D00015E044245524C2CFE1E0F0E0EC0FFD1F19
16
+:10F8E000E40DF51D80830894411C511CD8264E144C
17
+:10F8F0005F0409F0B3CF720116E0B0CF8D1509F0A7
18
+:10F90000E9C1EAC1CC2447C08D81803311F090E079
19
+:10F910000AC08F81882311F49EE105C0813011F067
20
+:10F9200095E001C097E91A821B828D818C838E81BC
21
+:10F930008D839E831F8247E0E42EF12C88C11A82BA
22
+:10F9400068E06B8383E58C8394E59D83EBE4EE8331
23
+:10F9500085E38F8380E3888789878FE58A8782E3C1
24
+:10F960008B873BE0E32EF12C72C18A81813941F013
25
+:10F97000823941F0803911F48FE005C080E003C086
26
+:10F9800082E001C08AE01A828B8323E0E22EF12C10
27
+:10F990005EC1CC24C3941A8292E0E92EF12C58C1A6
28
+:10F9A0008D81882311F48EE128C0813011F085E02B
29
+:10F9B00024C087E922C01A8229E0E1E0F0E0209328
30
+:10F9C000570084911BC08B81803589F48C818830ED
31
+:10F9D00039F439E0E2E0F0E03093570084910DC053
32
+:10F9E00069E0E0E0F0E060935700849106C099E0A0
33
+:10F9F000E3E0F0E09093570084911A828B831C829D
34
+:10FA000084E0E82EF12C23C18A8190E0A0E0B0E0F0
35
+:10FA1000B82EAA24992488248B8190E0A0E0B0E03D
36
+:10FA2000DC0199278827882A992AAA2ABB2A8D814E
37
+:10FA300090E0A0E0B0E0882A992AAA2ABB2A8C810B
38
+:10FA400090E0A0E0B0E0BA2FA92F982F8827882A4D
39
+:10FA5000992AAA2ABB2A88C0EA81C05EDE4FE883C1
40
+:10FA6000C052D140C15EDE4F1882CF51D1408B8150
41
+:10FA7000A82FB0E0C15EDE4F28813981CF51D1403F
42
+:10FA8000A22BB32B933109F042C075016401CC0C59
43
+:10FA9000DD1CEE1CFF1C33E0F601E0925B003093AE
44
+:10FAA0005700E89507B600FCFDCF8E01055F1F4F9C
45
+:10FAB000F801808161810E5F1F4FA5019401220F23
46
+:10FAC000331F441F551F362E222490E0822993298C
47
+:10FAD00061E00C01F90140935B0060935700E895E9
48
+:10FAE00011240894811C911CA11CB11C129701F7D0
49
+:10FAF00085E0F601E0925B0080935700E89507B639
50
+:10FB000000FCFDCF81E180935700E8952DC0FE01F8
51
+:10FB10003B9620E030E040E050E011977D0100E0AE
52
+:10FB200010E00894E11CF11C011D111D6081F99980
53
+:10FB3000FECF1FBAC901880D991D92BD81BD60BD60
54
+:10FB40000FB6F894FA9AF99A0FBE2F5F3F4F4F4FB6
55
+:10FB50005F4F2E153F054007510711F03196E6CF54
56
+:10FB6000820E931EA41EB51E1A826EC09A81CE5DAF
57
+:10FB7000DE4F9883C252D140CF5DDE4F1882C15212
58
+:10FB8000D1408B81C82EDD24CF5DDE4FE881F98125
59
+:10FB9000C152D140CE2ADF2A1A8289818431E1F410
60
+:10FBA0009601BE016D5F7F4FD501C401880F991F7B
61
+:10FBB000AA1FBB1FABBFFC0187919691FB018083FD
62
+:10FBC00091836E5F7F4F0894811C911CA11CB11C16
63
+:10FBD0002250304049F72EC0BE016D5F7F4F20E0BC
64
+:10FBE00030E040E050E00894C108D108760100E020
65
+:10FBF00010E00894C11CD11C0894E11CF11C011DEB
66
+:10FC0000111DF999FECFC901880D991D92BD81BDC5
67
+:10FC1000F89A80B5FB018193BF012F5F3F4F4F4F93
68
+:10FC20005F4F2E153F054007510759F7820E931E6F
69
+:10FC3000A41EB51E23E0E22EF12CEC0CFD1CFB01F2
70
+:10FC4000108205C080EC8A8392E0E92EF12CCC244E
71
+:10FC50008BE10E94C7FEC25EDE4F8881CE51D1404B
72
+:10FC60000E94C7FE8F2D0E94C7FE8E2D0E94C7FEE8
73
+:10FC70008EE00E94C7FE85E1D82EC25EDE4FF8817D
74
+:10FC8000CE51D140DF26DE24DF243E010894611CE2
75
+:10FC9000711C0AC0F30111913F01812F0E94C7FE20
76
+:10FCA000D1260894E108F108E114F10499F78D2DAB
77
+:10FCB0000E94C7FECC2009F044C0C25EDE4FF8812E
78
+:10FCC000CE51D140FF5FC25EDE4FF883CE51D140AE
79
+:10FCD000EE24FF2410E0C2CD9981933109F4BCCE0B
80
+:10FCE0009431B0F4933009F440CE943038F491302C
81
+:10FCF00009F425CE923009F0A5CF04CE903109F455
82
+:10FD000001CE913109F445CE963009F09BCF7CCEDF
83
+:10FD1000983109F458CE993150F4953109F49CCEBC
84
+:10FD2000953108F423CF963109F08CCF1FCF9B314A
85
+:10FD300009F436CE9D3109F4E7CD9A3109F082CF2E
86
+:10FD40003ACECE5DDE4F0FB6F894DEBF0FBECDBF0C
87
+:10FD5000CF91DF911F910F91FF90EF90DF90CF90A7
88
+:10FD6000BF90AF909F908F907F906F905F904F90DB
89
+:10FD70003F902F9008958091C00087FFFCCF089599
90
+:10FD80008091C00087FFFCCF8091C6000895982F16
91
+:10FD90008091C00085FFFCCF9093C60008959B0121
92
+:10FDA000AC0197FF11C08091C00082608093C000B9
93
+:10FDB00050954095309521953F4F4F4F5F4F60E0F4
94
+:10FDC00074E284EF90E009C08091C0008D7F809341
95
+:10FDD000C00060E072E18AE790E00E9447FF2C5F7C
96
+:10FDE0003F4F4F4F5F4F83E0569547953795279587
97
+:10FDF0008A95D1F7215030403093C5002093C4003C
98
+:10FE0000089518B817B81F921F921F920895FFCF38
99
+:10FE100084B714BE90E083709070892B39F418B8C1
100
+:10FE200017B81F921F921F920895FFCF88E1809309
101
+:10FE3000C10060E07EE38EEF9FEF0E94CFFE0E9444
102
+:10FE400007FC18B817B81F921F921F920895FFCF92
103
+:10FE500020E030E040E050E013C02F5F3F4F4F4FB5
104
+:10FE60005F4F21308AE6380788E1480780E058076D
105
+:10FE700039F418B817B81F921F921F920895FFCF38
106
+:10FE80008091C00087FFE9CF0E94C0FE0895A1E2E3
107
+:10FE90001A2EAA1BBB1BFD010DC0AA1FBB1FEE1F04
108
+:10FEA000FF1FA217B307E407F50720F0A21BB30B4F
109
+:10FEB000E40BF50B661F771F881F991F1A9469F7CB
110
+:10FEC00060957095809590959B01AC01BD01CF0127
111
+:02FED000089593
112
+:040000031000F800F1
113
+:00000001FF

+ 75
- 0
ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644-16MHz.hex Dosyayı Görüntüle

@@ -0,0 +1,75 @@
1
+:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
2
+:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
3
+:10F8200088E08093C40088E18093C100EE24FF2427
4
+:10F8300020E0552400E010E039E0432E9BE0292E23
5
+:10F84000312C2C0E3D1ECFC14150504060407040C5
6
+:10F8500011F43FE206C08091C00087FFF5CF3091E0
7
+:10F86000C600933021F1943028F4913099F0923011
8
+:10F87000C8F407C0953049F1953000F19630D1F5C4
9
+:10F8800035C03B3119F491E02BE134C03F3291F5A2
10
+:10F890003983BBC1313011F0351559F52327532E6B
11
+:10F8A00092E028C0B32FA0E0232793E023C0832F4A
12
+:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
13
+:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
14
+:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
15
+:10F8E000EA16FB0639F4D70196E004C0321709F492
16
+:10F8F0008CC190E044E755E962E470E0ACCF90E061
17
+:10F9000044C08D81803311F090E00AC08F8188233C
18
+:10F9100011F49EE105C0813011F099E001C096E933
19
+:10F920001A821B828D818C838E818D839E831F82A0
20
+:10F9300047E050E0F4C01A8288E08B8381E48C8336
21
+:10F9400086E58D8382E58E8389E48F8383E58887CE
22
+:10F9500080E589878FE58A8782E38B874BE050E0DB
23
+:10F96000DEC08A81813941F0823941F0803911F459
24
+:10F970008FE005C080E003C082E001C08AE01A8207
25
+:10F980008B8343E050E0CBC091E01A8242E050E02C
26
+:10F99000C7C08D81882311F48EE124C0813011F01D
27
+:10F9A00089E020C086E91EC01A82E1E0F0E04092C2
28
+:10F9B0005700849118C08B81803579F48C81883010
29
+:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
30
+:10F9D000F0E040925700849105C0E3E0F0E04092EF
31
+:10F9E000570084911A828B831C8244E050E097C0B8
32
+:10F9F000BC80AA248D81082F10E00A291B29000F42
33
+:10FA0000111F1A828AC09A8088248B81682F70E027
34
+:10FA100068297929933109F033C0F7EF0F3F1F07A9
35
+:10FA200010F0A8013FC023E0F80120935700E895AB
36
+:10FA300007B600FCFDCFA801D1018C9111962C9145
37
+:10FA400011971296D22ECC2490E08C299D2921E08A
38
+:10FA5000FA010C0120935700E89511244E5F5F4F87
39
+:10FA60006250704051F725E0F80120935700E89567
40
+:10FA700007B600FCFDCF81E180935700E89512C0E6
41
+:10FA8000A801FB01D10141BD52BD4F5F5F4F8D9178
42
+:10FA900080BDFA9AF99AF999FECF3197A1F7A8019A
43
+:10FAA000460F571F1A828A0138C07A8066248B81DC
44
+:10FAB000A82FB0E0A629B7291A828981843191F450
45
+:10FAC000BD019E012D5F3F4FF80185919491F90191
46
+:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
47
+:10FAE00099F713C0A801BD019E012D5F3F4F41BD95
48
+:10FAF00052BD4F5F5F4FF89A80B5F90181939F0126
49
+:10FB000061507040A1F70A0F1B1FAD014D5F5F4FA1
50
+:10FB1000F901108204C080EC8A8342E050E090E05A
51
+:10FB2000FBE1F093C6008091C00086FFFCCF80917E
52
+:10FB3000C00080648093C0005092C6008091C000D5
53
+:10FB400086FFFCCF8091C00080648093C000652F49
54
+:10FB50005093C6008091C00086FFFCCF8091C0000A
55
+:10FB600080648093C000342F4093C6008091C00011
56
+:10FB700086FFFCCF8091C00080648093C0008EE03F
57
+:10FB80008093C6008091C00086FFFCCF8091C000AA
58
+:10FB900080648093C00025E1252523272627FE01C8
59
+:10FBA000319610C030813093C6008091C00086FF2E
60
+:10FBB000FCCF31968091C00080648093C0002327E1
61
+:10FBC000415050404115510569F72093C60080917E
62
+:10FBD000C00086FFFCCF8091C00080648093C0008D
63
+:10FBE000992349F4539444E755E962E470E090E0C6
64
+:10FBF000A0E0B0E030CE5A9881E180935700E895BC
65
+:10FC000011241F921F920895FFCF9981933109F417
66
+:10FC1000FACE9431C8F4963009F4EACE973050F415
67
+:10FC2000923009F46CCE933009F49BCE913009F0F8
68
+:10FC300072CF81CE913109F4A7CE923108F0E1CE96
69
+:10FC4000903109F068CF5BCE983109F4B4CE993188
70
+:10FC500050F4953109F4D7CE953108F426CF96317A
71
+:10FC600009F059CF22CF9B3109F493CE9C3120F477
72
+:10FC70009A3109F050CF98CE9D3109F442CE9F328F
73
+:06FC800009F049CFB8CFE6
74
+:040000030000F80001
75
+:00000001FF

+ 75
- 0
ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644-20MHz.hex Dosyayı Görüntüle

@@ -0,0 +1,75 @@
1
+:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
2
+:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
3
+:10F820008AE08093C40088E18093C100EE24FF2425
4
+:10F8300020E0552400E010E039E0432E9BE0292E23
5
+:10F84000312C2C0E3D1ECFC14150504060407040C5
6
+:10F8500011F43FE206C08091C00087FFF5CF3091E0
7
+:10F86000C600933021F1943028F4913099F0923011
8
+:10F87000C8F407C0953049F1953000F19630D1F5C4
9
+:10F8800035C03B3119F491E02BE134C03F3291F5A2
10
+:10F890003983BBC1313011F0351559F52327532E6B
11
+:10F8A00092E028C0B32FA0E0232793E023C0832F4A
12
+:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
13
+:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
14
+:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
15
+:10F8E000EA16FB0639F4D70196E004C0321709F492
16
+:10F8F0008CC190E041ED5AE363E570E0ACCF90E05D
17
+:10F9000044C08D81803311F090E00AC08F8188233C
18
+:10F9100011F49EE105C0813011F099E001C096E933
19
+:10F920001A821B828D818C838E818D839E831F82A0
20
+:10F9300047E050E0F4C01A8288E08B8381E48C8336
21
+:10F9400086E58D8382E58E8389E48F8383E58887CE
22
+:10F9500080E589878FE58A8782E38B874BE050E0DB
23
+:10F96000DEC08A81813941F0823941F0803911F459
24
+:10F970008FE005C080E003C082E001C08AE01A8207
25
+:10F980008B8343E050E0CBC091E01A8242E050E02C
26
+:10F99000C7C08D81882311F48EE124C0813011F01D
27
+:10F9A00089E020C086E91EC01A82E1E0F0E04092C2
28
+:10F9B0005700849118C08B81803579F48C81883010
29
+:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
30
+:10F9D000F0E040925700849105C0E3E0F0E04092EF
31
+:10F9E000570084911A828B831C8244E050E097C0B8
32
+:10F9F000BC80AA248D81082F10E00A291B29000F42
33
+:10FA0000111F1A828AC09A8088248B81682F70E027
34
+:10FA100068297929933109F033C0F7EF0F3F1F07A9
35
+:10FA200010F0A8013FC023E0F80120935700E895AB
36
+:10FA300007B600FCFDCFA801D1018C9111962C9145
37
+:10FA400011971296D22ECC2490E08C299D2921E08A
38
+:10FA5000FA010C0120935700E89511244E5F5F4F87
39
+:10FA60006250704051F725E0F80120935700E89567
40
+:10FA700007B600FCFDCF81E180935700E89512C0E6
41
+:10FA8000A801FB01D10141BD52BD4F5F5F4F8D9178
42
+:10FA900080BDFA9AF99AF999FECF3197A1F7A8019A
43
+:10FAA000460F571F1A828A0138C07A8066248B81DC
44
+:10FAB000A82FB0E0A629B7291A828981843191F450
45
+:10FAC000BD019E012D5F3F4FF80185919491F90191
46
+:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
47
+:10FAE00099F713C0A801BD019E012D5F3F4F41BD95
48
+:10FAF00052BD4F5F5F4FF89A80B5F90181939F0126
49
+:10FB000061507040A1F70A0F1B1FAD014D5F5F4FA1
50
+:10FB1000F901108204C080EC8A8342E050E090E05A
51
+:10FB2000FBE1F093C6008091C00086FFFCCF80917E
52
+:10FB3000C00080648093C0005092C6008091C000D5
53
+:10FB400086FFFCCF8091C00080648093C000652F49
54
+:10FB50005093C6008091C00086FFFCCF8091C0000A
55
+:10FB600080648093C000342F4093C6008091C00011
56
+:10FB700086FFFCCF8091C00080648093C0008EE03F
57
+:10FB80008093C6008091C00086FFFCCF8091C000AA
58
+:10FB900080648093C00025E1252523272627FE01C8
59
+:10FBA000319610C030813093C6008091C00086FF2E
60
+:10FBB000FCCF31968091C00080648093C0002327E1
61
+:10FBC000415050404115510569F72093C60080917E
62
+:10FBD000C00086FFFCCF8091C00080648093C0008D
63
+:10FBE000992349F4539441ED5AE363E570E090E0C2
64
+:10FBF000A0E0B0E030CE5A9881E180935700E895BC
65
+:10FC000011241F921F920895FFCF9981933109F417
66
+:10FC1000FACE9431C8F4963009F4EACE973050F415
67
+:10FC2000923009F46CCE933009F49BCE913009F0F8
68
+:10FC300072CF81CE913109F4A7CE923108F0E1CE96
69
+:10FC4000903109F068CF5BCE983109F4B4CE993188
70
+:10FC500050F4953109F4D7CE953108F426CF96317A
71
+:10FC600009F059CF22CF9B3109F493CE9C3120F477
72
+:10FC70009A3109F050CF98CE9D3109F442CE9F328F
73
+:06FC800009F049CFB8CFE6
74
+:040000030000F80001
75
+:00000001FF

+ 75
- 0
ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644P-16MHz.hex Dosyayı Görüntüle

@@ -0,0 +1,75 @@
1
+:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
2
+:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
3
+:10F8200088E08093C40088E18093C100EE24FF2427
4
+:10F8300020E0552400E010E039E0432E93E0292E2B
5
+:10F84000312C2C0E3D1ECDC14150504060407040C7
6
+:10F8500011F43FE206C08091C00087FFF5CF3091E0
7
+:10F86000C600933021F1943028F4913099F0923011
8
+:10F87000C8F407C0953049F1953000F19630D1F5C4
9
+:10F8800035C03B3119F491E02BE134C03F3291F5A2
10
+:10F890003983B9C1313011F0351559F52327532E6D
11
+:10F8A00092E028C0B32FA0E0232793E023C0832F4A
12
+:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
13
+:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
14
+:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
15
+:10F8E000EA16FB0639F4D70196E004C0321709F492
16
+:10F8F0008AC190E044E755E962E470E0ACCF90E063
17
+:10F9000044C08D81803311F090E00AC08F8188233C
18
+:10F9100011F49EE105C0813011F09AE001C096E932
19
+:10F920001A821B828D818C838E818D839E831F82A0
20
+:10F9300047E050E0F2C01A8288E08B8381E48C8338
21
+:10F9400086E58D8382E58E8389E48F8383E58887CE
22
+:10F9500080E589878FE58A8782E38B874BE050E0DB
23
+:10F96000DCC08A81813941F0823941F0803911F45B
24
+:10F970008FE005C080E003C082E001C08AE01A8207
25
+:10F980008B8343E050E0C9C091E01A8242E050E02E
26
+:10F99000C5C08D81882311F48EE124C0813011F01F
27
+:10F9A0008AE020C086E91EC01A82E1E0F0E04092C1
28
+:10F9B0005700849118C08B81803579F48C81883010
29
+:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
30
+:10F9D000F0E040925700849105C0E3E0F0E04092EF
31
+:10F9E000570084911A828B831C8244E050E095C0BA
32
+:10F9F000BC80AA248D81082F10E00A291B29000F42
33
+:10FA0000111F1A8288C09A8088248B81682F70E029
34
+:10FA100068297929933109F034C0F7EF0F3F1F07A8
35
+:10FA200010F0A80141C023E0F80120935700E895A9
36
+:10FA300007B600FCFDCFA801DE011B968C91119644
37
+:10FA40002C9111971296D22ECC2490E08C299D29CE
38
+:10FA500021E0FA010C0120935700E89511244E5F34
39
+:10FA60005F4F6250704051F725E0F8012093570036
40
+:10FA7000E89507B600FCFDCF81E180935700E8953B
41
+:10FA800013C0A801FB01DE011B9641BD52BD4F5FB3
42
+:10FA90005F4F8D9180BDFA9AF99AF999FECF31970F
43
+:10FAA000A1F7A801460F571F1A828A0134C07A8035
44
+:10FAB00066248B81A82FB0E0A629B7291A828981F4
45
+:10FAC000843181F4BD019101F80185919491F9018E
46
+:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
47
+:10FAE00099F711C0A801BD01910141BD52BD4F5F01
48
+:10FAF0005F4FF89A80B5F90181939F016150704082
49
+:10FB0000A1F70A0F1B1FAD014D5F5F4FF901108276
50
+:10FB100004C080EC8A8342E050E090E0FBE1F09387
51
+:10FB2000C6008091C00086FFFCCF8091C000806439
52
+:10FB30008093C0005092C6008091C00086FFFCCF29
53
+:10FB40008091C00080648093C000652F5093C600F0
54
+:10FB50008091C00086FFFCCF8091C00080648093BC
55
+:10FB6000C000342F4093C6008091C00086FFFCCFB8
56
+:10FB70008091C00080648093C0008EE08093C600B6
57
+:10FB80008091C00086FFFCCF8091C000806480938C
58
+:10FB9000C00025E1252523272627FE01319610C028
59
+:10FBA00030813093C6008091C00086FFFCCF319633
60
+:10FBB0008091C00080648093C00023274150504052
61
+:10FBC0004115510569F72093C6008091C00086FF5A
62
+:10FBD000FCCF8091C00080648093C000992349F4D9
63
+:10FBE000539444E755E962E470E090E0A0E0B0E0AF
64
+:10FBF00032CE5A9881E180935700E89511241F92E4
65
+:10FC00001F920895FFCF9981933109F4FCCE94316E
66
+:10FC1000C8F4963009F4ECCE973050F4923009F4E1
67
+:10FC20006ECE933009F49DCE913009F072CF83CE21
68
+:10FC3000913109F4A9CE923108F0E3CE903109F068
69
+:10FC400068CF5DCE983109F4B6CE993150F4953134
70
+:10FC500009F4D9CE953108F42ACF963109F059CF5D
71
+:10FC600026CF9B3109F495CE9C3120F49A3109F0CE
72
+:10FC700050CF9ACE9D3109F444CE9F3209F049CF3E
73
+:02FC8000B8CFFB
74
+:040000030000F80001
75
+:00000001FF

+ 75
- 0
ArduinoAddons/Arduino_0.xx/Gen7/bootloaders/Gen7/bootloader-644P-20MHz.hex Dosyayı Görüntüle

@@ -0,0 +1,75 @@
1
+:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A
2
+:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010
3
+:10F820008AE08093C40088E18093C100EE24FF2425
4
+:10F8300020E0552400E010E039E0432E93E0292E2B
5
+:10F84000312C2C0E3D1ECDC14150504060407040C7
6
+:10F8500011F43FE206C08091C00087FFF5CF3091E0
7
+:10F86000C600933021F1943028F4913099F0923011
8
+:10F87000C8F407C0953049F1953000F19630D1F5C4
9
+:10F8800035C03B3119F491E02BE134C03F3291F5A2
10
+:10F890003983B9C1313011F0351559F52327532E6D
11
+:10F8A00092E028C0B32FA0E0232793E023C0832F4A
12
+:10F8B00090E0A82BB92B232794E01CC03E30C9F45C
13
+:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3
14
+:10F8D000FD1FEE0DFF1D30830894E11CF11C232752
15
+:10F8E000EA16FB0639F4D70196E004C0321709F492
16
+:10F8F0008AC190E041ED5AE363E570E0ACCF90E05F
17
+:10F9000044C08D81803311F090E00AC08F8188233C
18
+:10F9100011F49EE105C0813011F09AE001C096E932
19
+:10F920001A821B828D818C838E818D839E831F82A0
20
+:10F9300047E050E0F2C01A8288E08B8381E48C8338
21
+:10F9400086E58D8382E58E8389E48F8383E58887CE
22
+:10F9500080E589878FE58A8782E38B874BE050E0DB
23
+:10F96000DCC08A81813941F0823941F0803911F45B
24
+:10F970008FE005C080E003C082E001C08AE01A8207
25
+:10F980008B8343E050E0C9C091E01A8242E050E02E
26
+:10F99000C5C08D81882311F48EE124C0813011F01F
27
+:10F9A0008AE020C086E91EC01A82E1E0F0E04092C1
28
+:10F9B0005700849118C08B81803579F48C81883010
29
+:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7
30
+:10F9D000F0E040925700849105C0E3E0F0E04092EF
31
+:10F9E000570084911A828B831C8244E050E095C0BA
32
+:10F9F000BC80AA248D81082F10E00A291B29000F42
33
+:10FA0000111F1A8288C09A8088248B81682F70E029
34
+:10FA100068297929933109F034C0F7EF0F3F1F07A8
35
+:10FA200010F0A80141C023E0F80120935700E895A9
36
+:10FA300007B600FCFDCFA801DE011B968C91119644
37
+:10FA40002C9111971296D22ECC2490E08C299D29CE
38
+:10FA500021E0FA010C0120935700E89511244E5F34
39
+:10FA60005F4F6250704051F725E0F8012093570036
40
+:10FA7000E89507B600FCFDCF81E180935700E8953B
41
+:10FA800013C0A801FB01DE011B9641BD52BD4F5FB3
42
+:10FA90005F4F8D9180BDFA9AF99AF999FECF31970F
43
+:10FAA000A1F7A801460F571F1A828A0134C07A8035
44
+:10FAB00066248B81A82FB0E0A629B7291A828981F4
45
+:10FAC000843181F4BD019101F80185919491F9018E
46
+:10FAD000808391832E5F3F4F0E5F1F4F62507040B7
47
+:10FAE00099F711C0A801BD01910141BD52BD4F5F01
48
+:10FAF0005F4FF89A80B5F90181939F016150704082
49
+:10FB0000A1F70A0F1B1FAD014D5F5F4FF901108276
50
+:10FB100004C080EC8A8342E050E090E0FBE1F09387
51
+:10FB2000C6008091C00086FFFCCF8091C000806439
52
+:10FB30008093C0005092C6008091C00086FFFCCF29
53
+:10FB40008091C00080648093C000652F5093C600F0
54
+:10FB50008091C00086FFFCCF8091C00080648093BC
55
+:10FB6000C000342F4093C6008091C00086FFFCCFB8
56
+:10FB70008091C00080648093C0008EE08093C600B6
57
+:10FB80008091C00086FFFCCF8091C000806480938C
58
+:10FB9000C00025E1252523272627FE01319610C028
59
+:10FBA00030813093C6008091C00086FFFCCF319633
60
+:10FBB0008091C00080648093C00023274150504052
61
+:10FBC0004115510569F72093C6008091C00086FF5A
62
+:10FBD000FCCF8091C00080648093C000992349F4D9
63
+:10FBE000539441ED5AE363E570E090E0A0E0B0E0AB
64
+:10FBF00032CE5A9881E180935700E89511241F92E4
65
+:10FC00001F920895FFCF9981933109F4FCCE94316E
66
+:10FC1000C8F4963009F4ECCE973050F4923009F4E1
67
+:10FC20006ECE933009F49DCE913009F072CF83CE21
68
+:10FC3000913109F4A9CE923108F0E3CE903109F068
69
+:10FC400068CF5DCE983109F4B6CE993150F4953134
70
+:10FC500009F4D9CE953108F42ACF963109F059CF5D
71
+:10FC600026CF9B3109F495CE9C3120F49A3109F0CE
72
+:10FC700050CF9ACE9D3109F444CE9F3209F049CF3E
73
+:02FC8000B8CFFB
74
+:040000030000F80001
75
+:00000001FF

+ 239
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/HardwareSerial.cpp Dosyayı Görüntüle

@@ -0,0 +1,239 @@
1
+/*
2
+  HardwareSerial.cpp - Hardware serial library for Wiring
3
+  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+  
19
+  Modified 23 November 2006 by David A. Mellis
20
+*/
21
+
22
+#include <stdio.h>
23
+#include <string.h>
24
+#include <inttypes.h>
25
+#include "wiring.h"
26
+#include "wiring_private.h"
27
+
28
+#include "HardwareSerial.h"
29
+
30
+// Define constants and variables for buffering incoming serial data.  We're
31
+// using a ring buffer (I think), in which rx_buffer_head is the index of the
32
+// location to which to write the next incoming character and rx_buffer_tail
33
+// is the index of the location from which to read.
34
+#define RX_BUFFER_SIZE 128
35
+
36
+struct ring_buffer {
37
+  unsigned char buffer[RX_BUFFER_SIZE];
38
+  int head;
39
+  int tail;
40
+};
41
+
42
+ring_buffer rx_buffer = { { 0 }, 0, 0 };
43
+
44
+#ifdef UDR1
45
+ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
46
+#endif
47
+
48
+#ifdef UDR2
49
+ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
50
+#endif
51
+#ifdef UDR3
52
+ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
53
+#endif
54
+
55
+inline void store_char(unsigned char c, ring_buffer *rx_buffer)
56
+{
57
+  int i = (rx_buffer->head + 1) % RX_BUFFER_SIZE;
58
+
59
+  // if we should be storing the received character into the location
60
+  // just before the tail (meaning that the head would advance to the
61
+  // current location of the tail), we're about to overflow the buffer
62
+  // and so we don't write the character or advance the head.
63
+  if (i != rx_buffer->tail) {
64
+    rx_buffer->buffer[rx_buffer->head] = c;
65
+    rx_buffer->head = i;
66
+  }
67
+}
68
+
69
+ISR(USART0_RX_vect)
70
+{
71
+  unsigned char c = UDR0;
72
+  store_char(c, &rx_buffer);
73
+}
74
+
75
+#ifdef UDR1
76
+ISR(USART1_RX_vect)
77
+{
78
+  unsigned char c = UDR1;
79
+  store_char(c, &rx_buffer1);
80
+}
81
+
82
+#ifdef UDR2
83
+ISR(USART2_RX_vect)
84
+{
85
+  unsigned char c = UDR2;
86
+  store_char(c, &rx_buffer2);
87
+}
88
+
89
+#ifdef UDR2
90
+ISR(USART3_RX_vect)
91
+{
92
+  unsigned char c = UDR3;
93
+  store_char(c, &rx_buffer3);
94
+}
95
+#endif
96
+#endif
97
+
98
+#else
99
+
100
+#if defined(__AVR_ATmega8__)
101
+SIGNAL(SIG_UART_RECV)
102
+#else
103
+SIGNAL(USART_RX_vect)
104
+#endif
105
+{
106
+#if defined(__AVR_ATmega8__)
107
+  unsigned char c = UDR;
108
+#else
109
+  unsigned char c = UDR0;
110
+#endif
111
+  store_char(c, &rx_buffer);
112
+}
113
+
114
+#endif
115
+
116
+// Constructors ////////////////////////////////////////////////////////////////
117
+
118
+HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
119
+  volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
120
+  volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
121
+  volatile uint8_t *udr,
122
+  uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
123
+{
124
+  _rx_buffer = rx_buffer;
125
+  _ubrrh = ubrrh;
126
+  _ubrrl = ubrrl;
127
+  _ucsra = ucsra;
128
+  _ucsrb = ucsrb;
129
+  _udr = udr;
130
+  _rxen = rxen;
131
+  _txen = txen;
132
+  _rxcie = rxcie;
133
+  _udre = udre;
134
+  _u2x = u2x;
135
+}
136
+
137
+// Public Methods //////////////////////////////////////////////////////////////
138
+
139
+void HardwareSerial::begin(long baud)
140
+{
141
+  uint16_t baud_setting;
142
+  bool use_u2x;
143
+
144
+  // U2X mode is needed for baud rates higher than (CPU Hz / 16)
145
+  if (baud > F_CPU / 16) {
146
+    use_u2x = true;
147
+  } else {
148
+    // figure out if U2X mode would allow for a better connection
149
+    
150
+    // calculate the percent difference between the baud-rate specified and
151
+    // the real baud rate for both U2X and non-U2X mode (0-255 error percent)
152
+    uint8_t nonu2x_baud_error = abs((int)(255-((F_CPU/(16*(((F_CPU/8/baud-1)/2)+1))*255)/baud)));
153
+    uint8_t u2x_baud_error = abs((int)(255-((F_CPU/(8*(((F_CPU/4/baud-1)/2)+1))*255)/baud)));
154
+    
155
+    // prefer non-U2X mode because it handles clock skew better
156
+    use_u2x = (nonu2x_baud_error > u2x_baud_error);
157
+  }
158
+  
159
+  if (use_u2x) {
160
+    *_ucsra = 1 << _u2x;
161
+    baud_setting = (F_CPU / 4 / baud - 1) / 2;
162
+  } else {
163
+    *_ucsra = 0;
164
+    baud_setting = (F_CPU / 8 / baud - 1) / 2;
165
+  }
166
+
167
+  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
168
+  *_ubrrh = baud_setting >> 8;
169
+  *_ubrrl = baud_setting;
170
+
171
+  sbi(*_ucsrb, _rxen);
172
+  sbi(*_ucsrb, _txen);
173
+  sbi(*_ucsrb, _rxcie);
174
+}
175
+
176
+void HardwareSerial::end()
177
+{
178
+  cbi(*_ucsrb, _rxen);
179
+  cbi(*_ucsrb, _txen);
180
+  cbi(*_ucsrb, _rxcie);  
181
+}
182
+
183
+uint8_t HardwareSerial::available(void)
184
+{
185
+  return (RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
186
+}
187
+
188
+int HardwareSerial::read(void)
189
+{
190
+  // if the head isn't ahead of the tail, we don't have any characters
191
+  if (_rx_buffer->head == _rx_buffer->tail) {
192
+    return -1;
193
+  } else {
194
+    unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
195
+    _rx_buffer->tail = (_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
196
+    return c;
197
+  }
198
+}
199
+
200
+void HardwareSerial::flush()
201
+{
202
+  // don't reverse this or there may be problems if the RX interrupt
203
+  // occurs after reading the value of rx_buffer_head but before writing
204
+  // the value to rx_buffer_tail; the previous value of rx_buffer_head
205
+  // may be written to rx_buffer_tail, making it appear as if the buffer
206
+  // don't reverse this or there may be problems if the RX interrupt
207
+  // occurs after reading the value of rx_buffer_head but before writing
208
+  // the value to rx_buffer_tail; the previous value of rx_buffer_head
209
+  // may be written to rx_buffer_tail, making it appear as if the buffer
210
+  // were full, not empty.
211
+  _rx_buffer->head = _rx_buffer->tail;
212
+}
213
+
214
+void HardwareSerial::write(uint8_t c)
215
+{
216
+  while (!((*_ucsra) & (1 << _udre)))
217
+    ;
218
+
219
+  *_udr = c;
220
+}
221
+
222
+// Preinstantiate Objects //////////////////////////////////////////////////////
223
+
224
+#if defined(__AVR_ATmega8__)
225
+HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
226
+#else
227
+HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
228
+#endif
229
+
230
+#ifdef UDR1
231
+HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
232
+#endif
233
+
234
+#ifdef UDR2
235
+HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
236
+#endif
237
+#ifdef UDR3
238
+HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
239
+#endif

+ 69
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/HardwareSerial.h Dosyayı Görüntüle

@@ -0,0 +1,69 @@
1
+/*
2
+  HardwareSerial.h - Hardware serial library for Wiring
3
+  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef HardwareSerial_h
21
+#define HardwareSerial_h
22
+
23
+#include <inttypes.h>
24
+
25
+#include "Print.h"
26
+
27
+struct ring_buffer;
28
+
29
+class HardwareSerial : public Print
30
+{
31
+  private:
32
+    ring_buffer *_rx_buffer;
33
+    volatile uint8_t *_ubrrh;
34
+    volatile uint8_t *_ubrrl;
35
+    volatile uint8_t *_ucsra;
36
+    volatile uint8_t *_ucsrb;
37
+    volatile uint8_t *_udr;
38
+    uint8_t _rxen;
39
+    uint8_t _txen;
40
+    uint8_t _rxcie;
41
+    uint8_t _udre;
42
+    uint8_t _u2x;
43
+  public:
44
+    HardwareSerial(ring_buffer *rx_buffer,
45
+      volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
46
+      volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
47
+      volatile uint8_t *udr,
48
+      uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
49
+    void begin(long);
50
+    void end();
51
+    uint8_t available(void);
52
+    int read(void);
53
+    void flush(void);
54
+    virtual void write(uint8_t);
55
+    using Print::write; // pull in write(str) and write(buf, size) from Print
56
+};
57
+
58
+extern HardwareSerial Serial;
59
+
60
+#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1280__)
61
+extern HardwareSerial Serial1;
62
+#endif
63
+
64
+#if defined(__AVR_ATmega1280__)
65
+extern HardwareSerial Serial2;
66
+extern HardwareSerial Serial3;
67
+#endif
68
+
69
+#endif

+ 243
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Makefile Dosyayı Görüntüle

@@ -0,0 +1,243 @@
1
+# Arduino 0011 Makefile
2
+# Arduino adaptation by mellis, eighthave, oli.keller
3
+#
4
+# This makefile allows you to build sketches from the command line
5
+# without the Arduino environment (or Java).
6
+#
7
+# Detailed instructions for using the makefile:
8
+#
9
+#  1. Copy this file into the folder with your sketch. There should be a
10
+#     file with the same name as the folder and with the extension .pde
11
+#     (e.g. foo.pde in the foo/ folder).
12
+#
13
+#  2. Modify the line containg "INSTALL_DIR" to point to the directory that
14
+#     contains the Arduino installation (for example, under Mac OS X, this
15
+#     might be /Applications/arduino-0012).
16
+#
17
+#  3. Modify the line containing "PORT" to refer to the filename
18
+#     representing the USB or serial connection to your Arduino board
19
+#     (e.g. PORT = /dev/tty.USB0).  If the exact name of this file
20
+#     changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
21
+#
22
+#  4. Set the line containing "MCU" to match your board's processor. 
23
+#     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
24
+#     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
25
+#     change F_CPU to 8000000.
26
+#
27
+#  5. At the command line, change to the directory containing your
28
+#     program's file and the makefile.
29
+#
30
+#  6. Type "make" and press enter to compile/verify your program.
31
+#
32
+#  7. Type "make upload", reset your Arduino board, and press enter to
33
+#     upload your program to the Arduino board.
34
+#
35
+# $Id$
36
+
37
+TARGET = $(notdir $(CURDIR))
38
+INSTALL_DIR = /Users/dmellis/Source/arduino/trunk/build/macosx/build/work
39
+PORT = /dev/tty.usb*
40
+UPLOAD_RATE = 19200
41
+AVRDUDE_PROGRAMMER = stk500v1
42
+MCU = atmega168
43
+F_CPU = 16000000
44
+
45
+############################################################################
46
+# Below here nothing should be changed...
47
+
48
+ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
49
+AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
50
+SRC =  $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
51
+$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
52
+$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
53
+$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
54
+CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp
55
+FORMAT = ihex
56
+
57
+
58
+# Name of this Makefile (used for "make depend").
59
+MAKEFILE = Makefile
60
+
61
+# Debugging format.
62
+# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
63
+# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
64
+DEBUG = stabs
65
+
66
+OPT = s
67
+
68
+# Place -D or -U options here
69
+CDEFS = -DF_CPU=$(F_CPU)
70
+CXXDEFS = -DF_CPU=$(F_CPU)
71
+
72
+# Place -I options here
73
+CINCS = -I$(ARDUINO)
74
+CXXINCS = -I$(ARDUINO)
75
+
76
+# Compiler flag to set the C Standard level.
77
+# c89   - "ANSI" C
78
+# gnu89 - c89 plus GCC extensions
79
+# c99   - ISO C99 standard (not yet fully implemented)
80
+# gnu99 - c99 plus GCC extensions
81
+CSTANDARD = -std=gnu99
82
+CDEBUG = -g$(DEBUG)
83
+CWARN = -Wall -Wstrict-prototypes
84
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
85
+#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
86
+
87
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
88
+CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
89
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
90
+LDFLAGS = -lm
91
+
92
+
93
+# Programming support using avrdude. Settings and variables.
94
+AVRDUDE_PORT = $(PORT)
95
+AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
96
+AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
97
+-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
98
+-b $(UPLOAD_RATE)
99
+
100
+# Program settings
101
+CC = $(AVR_TOOLS_PATH)/avr-gcc
102
+CXX = $(AVR_TOOLS_PATH)/avr-g++
103
+OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
104
+OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
105
+AR  = $(AVR_TOOLS_PATH)/avr-ar
106
+SIZE = $(AVR_TOOLS_PATH)/avr-size
107
+NM = $(AVR_TOOLS_PATH)/avr-nm
108
+AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
109
+REMOVE = rm -f
110
+MV = mv -f
111
+
112
+# Define all object files.
113
+OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) 
114
+
115
+# Define all listing files.
116
+LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
117
+
118
+# Combine all necessary flags and optional flags.
119
+# Add target processor to flags.
120
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
121
+ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
122
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
123
+
124
+
125
+# Default target.
126
+all: applet_files build sizeafter
127
+
128
+build: elf hex 
129
+
130
+applet_files: $(TARGET).pde
131
+	# Here is the "preprocessing".
132
+	# It creates a .cpp file based with the same name as the .pde file.
133
+	# On top of the new .cpp file comes the WProgram.h header.
134
+	# At the end there is a generic main() function attached.
135
+	# Then the .cpp file will be compiled. Errors during compile will
136
+	# refer to this new, automatically generated, file. 
137
+	# Not the original .pde file you actually edit...
138
+	test -d applet || mkdir applet
139
+	echo '#include "WProgram.h"' > applet/$(TARGET).cpp
140
+	cat $(TARGET).pde >> applet/$(TARGET).cpp
141
+	cat $(ARDUINO)/main.cxx >> applet/$(TARGET).cpp
142
+
143
+elf: applet/$(TARGET).elf
144
+hex: applet/$(TARGET).hex
145
+eep: applet/$(TARGET).eep
146
+lss: applet/$(TARGET).lss 
147
+sym: applet/$(TARGET).sym
148
+
149
+# Program the device.  
150
+upload: applet/$(TARGET).hex
151
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
152
+
153
+
154
+	# Display size of file.
155
+HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
156
+ELFSIZE = $(SIZE)  applet/$(TARGET).elf
157
+sizebefore:
158
+	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
159
+
160
+sizeafter:
161
+	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
162
+
163
+
164
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
165
+COFFCONVERT=$(OBJCOPY) --debugging \
166
+--change-section-address .data-0x800000 \
167
+--change-section-address .bss-0x800000 \
168
+--change-section-address .noinit-0x800000 \
169
+--change-section-address .eeprom-0x810000 
170
+
171
+
172
+coff: applet/$(TARGET).elf
173
+	$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
174
+
175
+
176
+extcoff: $(TARGET).elf
177
+	$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
178
+
179
+
180
+.SUFFIXES: .elf .hex .eep .lss .sym
181
+
182
+.elf.hex:
183
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
184
+
185
+.elf.eep:
186
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
187
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
188
+
189
+# Create extended listing file from ELF output file.
190
+.elf.lss:
191
+	$(OBJDUMP) -h -S $< > $@
192
+
193
+# Create a symbol table from ELF output file.
194
+.elf.sym:
195
+	$(NM) -n $< > $@
196
+
197
+	# Link: create ELF output file from library.
198
+applet/$(TARGET).elf: $(TARGET).pde applet/core.a 
199
+	$(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
200
+
201
+applet/core.a: $(OBJ)
202
+	@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
203
+
204
+
205
+
206
+# Compile: create object files from C++ source files.
207
+.cpp.o:
208
+	$(CXX) -c $(ALL_CXXFLAGS) $< -o $@ 
209
+
210
+# Compile: create object files from C source files.
211
+.c.o:
212
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
213
+
214
+
215
+# Compile: create assembler files from C source files.
216
+.c.s:
217
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
218
+
219
+
220
+# Assemble: create object files from assembler source files.
221
+.S.o:
222
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
223
+
224
+
225
+
226
+# Target: clean project.
227
+clean:
228
+	$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
229
+	applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
230
+	$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
231
+
232
+depend:
233
+	if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
234
+	then \
235
+		sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
236
+			$(MAKEFILE).$$$$ && \
237
+		$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
238
+	fi
239
+	echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
240
+		>> $(MAKEFILE); \
241
+	$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
242
+
243
+.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter

+ 203
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Print.cpp Dosyayı Görüntüle

@@ -0,0 +1,203 @@
1
+/*
2
+ Print.cpp - Base class that provides print() and println()
3
+ Copyright (c) 2008 David A. Mellis.  All right reserved.
4
+ 
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+ 
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+ 
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ 
19
+ Modified 23 November 2006 by David A. Mellis
20
+ */
21
+
22
+#include <stdio.h>
23
+#include <string.h>
24
+#include <inttypes.h>
25
+#include <math.h>
26
+#include "wiring.h"
27
+
28
+#include "Print.h"
29
+
30
+// Public Methods //////////////////////////////////////////////////////////////
31
+
32
+void Print::print(uint8_t b)
33
+{
34
+  this->write(b);
35
+}
36
+
37
+void Print::print(char c)
38
+{
39
+  print((byte) c);
40
+}
41
+
42
+void Print::print(const char c[])
43
+{
44
+  while (*c)
45
+    print(*c++);
46
+}
47
+
48
+void Print::print(int n)
49
+{
50
+  print((long) n);
51
+}
52
+
53
+void Print::print(unsigned int n)
54
+{
55
+  print((unsigned long) n);
56
+}
57
+
58
+void Print::print(long n)
59
+{
60
+  if (n < 0) {
61
+    print('-');
62
+    n = -n;
63
+  }
64
+  printNumber(n, 10);
65
+}
66
+
67
+void Print::print(unsigned long n)
68
+{
69
+  printNumber(n, 10);
70
+}
71
+
72
+void Print::print(long n, int base)
73
+{
74
+  if (base == 0)
75
+    print((char) n);
76
+  else if (base == 10)
77
+    print(n);
78
+  else
79
+    printNumber(n, base);
80
+}
81
+
82
+void Print::print(double n)
83
+{
84
+  printFloat(n, 2);
85
+}
86
+
87
+void Print::println(void)
88
+{
89
+  print('\r');
90
+  print('\n');  
91
+}
92
+
93
+void Print::println(char c)
94
+{
95
+  print(c);
96
+  println();  
97
+}
98
+
99
+void Print::println(const char c[])
100
+{
101
+  print(c);
102
+  println();
103
+}
104
+
105
+void Print::println(uint8_t b)
106
+{
107
+  print(b);
108
+  println();
109
+}
110
+
111
+void Print::println(int n)
112
+{
113
+  print(n);
114
+  println();
115
+}
116
+
117
+void Print::println(unsigned int n)
118
+{
119
+  print(n);
120
+  println();
121
+}
122
+
123
+void Print::println(long n)
124
+{
125
+  print(n);
126
+  println();  
127
+}
128
+
129
+void Print::println(unsigned long n)
130
+{
131
+  print(n);
132
+  println();  
133
+}
134
+
135
+void Print::println(long n, int base)
136
+{
137
+  print(n, base);
138
+  println();
139
+}
140
+
141
+void Print::println(double n)
142
+{
143
+  print(n);
144
+  println();
145
+}
146
+
147
+// Private Methods /////////////////////////////////////////////////////////////
148
+
149
+void Print::printNumber(unsigned long n, uint8_t base)
150
+{
151
+  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
152
+  unsigned long i = 0;
153
+
154
+  if (n == 0) {
155
+    print('0');
156
+    return;
157
+  } 
158
+
159
+  while (n > 0) {
160
+    buf[i++] = n % base;
161
+    n /= base;
162
+  }
163
+
164
+  for (; i > 0; i--)
165
+    print((char) (buf[i - 1] < 10 ?
166
+      '0' + buf[i - 1] :
167
+      'A' + buf[i - 1] - 10));
168
+}
169
+
170
+void Print::printFloat(double number, uint8_t digits) 
171
+{ 
172
+  // Handle negative numbers
173
+  if (number < 0.0)
174
+  {
175
+     print('-');
176
+     number = -number;
177
+  }
178
+
179
+  // Round correctly so that print(1.999, 2) prints as "2.00"
180
+  double rounding = 0.5;
181
+  for (uint8_t i=0; i<digits; ++i)
182
+    rounding /= 10.0;
183
+  
184
+  number += rounding;
185
+
186
+  // Extract the integer part of the number and print it
187
+  unsigned long int_part = (unsigned long)number;
188
+  double remainder = number - (double)int_part;
189
+  print(int_part);
190
+
191
+  // Print the decimal point, but only if there are digits beyond
192
+  if (digits > 0)
193
+    print("."); 
194
+
195
+  // Extract digits from the remainder one at a time
196
+  while (digits-- > 0)
197
+  {
198
+    remainder *= 10.0;
199
+    int toPrint = int(remainder);
200
+    print(toPrint);
201
+    remainder -= toPrint; 
202
+  } 
203
+}

+ 59
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Print.h Dosyayı Görüntüle

@@ -0,0 +1,59 @@
1
+/*
2
+  Print.h - Base class that provides print() and println()
3
+  Copyright (c) 2008 David A. Mellis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef Print_h
21
+#define Print_h
22
+
23
+#include <inttypes.h>
24
+
25
+#define DEC 10
26
+#define HEX 16
27
+#define OCT 8
28
+#define BIN 2
29
+#define BYTE 0
30
+
31
+class Print
32
+{
33
+  private:
34
+    void printNumber(unsigned long, uint8_t);
35
+    void printFloat(double, uint8_t);
36
+  public:
37
+    virtual void write(uint8_t);
38
+    void print(char);
39
+    void print(const char[]);
40
+    void print(uint8_t);
41
+    void print(int);
42
+    void print(unsigned int);
43
+    void print(long);
44
+    void print(unsigned long);
45
+    void print(long, int);
46
+    void print(double);
47
+    void println(void);
48
+    void println(char);
49
+    void println(const char[]);
50
+    void println(uint8_t);
51
+    void println(int);
52
+    void println(unsigned int);
53
+    void println(long);
54
+    void println(unsigned long);
55
+    void println(long, int);
56
+    void println(double);
57
+};
58
+
59
+#endif

+ 515
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/Tone.cpp Dosyayı Görüntüle

@@ -0,0 +1,515 @@
1
+/* Tone.cpp
2
+
3
+  A Tone Generator Library
4
+
5
+  Written by Brett Hagman
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General Public
18
+  License along with this library; if not, write to the Free Software
19
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
+
21
+Version Modified By Date     Comments
22
+------- ----------- -------- --------
23
+0001    B Hagman    09/08/02 Initial coding
24
+0002    B Hagman    09/08/18 Multiple pins
25
+0003    B Hagman    09/08/18 Moved initialization from constructor to begin()
26
+0004    B Hagman    09/09/26 Fixed problems with ATmega8
27
+0005    B Hagman    09/11/23 Scanned prescalars for best fit on 8 bit timers
28
+                    09/11/25 Changed pin toggle method to XOR
29
+                    09/11/25 Fixed timer0 from being excluded
30
+0006    D Mellis    09/12/29 Replaced objects with functions
31
+
32
+*************************************************/
33
+
34
+#include <avr/interrupt.h>
35
+#include <avr/pgmspace.h>
36
+#include <wiring.h>
37
+#include <pins_arduino.h>
38
+
39
+#if defined(__AVR_ATmega8__)
40
+#define TCCR2A TCCR2
41
+#define TCCR2B TCCR2
42
+#define COM2A1 COM21
43
+#define COM2A0 COM20
44
+#define OCR2A OCR2
45
+#define TIMSK2 TIMSK
46
+#define OCIE2A OCIE2
47
+#define TIMER2_COMPA_vect TIMER2_COMP_vect
48
+#define TIMSK1 TIMSK
49
+#endif
50
+
51
+// timerx_toggle_count:
52
+//  > 0 - duration specified
53
+//  = 0 - stopped
54
+//  < 0 - infinitely (until stop() method called, or new play() called)
55
+
56
+#if !defined(__AVR_ATmega8__)
57
+volatile long timer0_toggle_count;
58
+volatile uint8_t *timer0_pin_port;
59
+volatile uint8_t timer0_pin_mask;
60
+#endif
61
+
62
+volatile long timer1_toggle_count;
63
+volatile uint8_t *timer1_pin_port;
64
+volatile uint8_t timer1_pin_mask;
65
+volatile long timer2_toggle_count;
66
+volatile uint8_t *timer2_pin_port;
67
+volatile uint8_t timer2_pin_mask;
68
+
69
+#if defined(__AVR_ATmega1280__)
70
+volatile long timer3_toggle_count;
71
+volatile uint8_t *timer3_pin_port;
72
+volatile uint8_t timer3_pin_mask;
73
+volatile long timer4_toggle_count;
74
+volatile uint8_t *timer4_pin_port;
75
+volatile uint8_t timer4_pin_mask;
76
+volatile long timer5_toggle_count;
77
+volatile uint8_t *timer5_pin_port;
78
+volatile uint8_t timer5_pin_mask;
79
+#endif
80
+
81
+
82
+#if defined(__AVR_ATmega1280__)
83
+
84
+#define AVAILABLE_TONE_PINS 1
85
+
86
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
87
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
88
+
89
+#elif defined(__AVR_ATmega8__)
90
+
91
+#define AVAILABLE_TONE_PINS 1
92
+
93
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
94
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
95
+
96
+#else
97
+
98
+#define AVAILABLE_TONE_PINS 1
99
+
100
+// Leave timer 0 to last.
101
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
102
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
103
+
104
+#endif
105
+
106
+
107
+
108
+static int8_t toneBegin(uint8_t _pin)
109
+{
110
+  int8_t _timer = -1;
111
+
112
+  // if we're already using the pin, the timer should be configured.  
113
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
114
+    if (tone_pins[i] == _pin) {
115
+      return pgm_read_byte(tone_pin_to_timer_PGM + i);
116
+    }
117
+  }
118
+  
119
+  // search for an unused timer.
120
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
121
+    if (tone_pins[i] == 255) {
122
+      tone_pins[i] = _pin;
123
+      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
124
+      break;
125
+    }
126
+  }
127
+  
128
+  if (_timer != -1)
129
+  {
130
+    // Set timer specific stuff
131
+    // All timers in CTC mode
132
+    // 8 bit timers will require changing prescalar values,
133
+    // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
134
+    switch (_timer)
135
+    {
136
+#if !defined(__AVR_ATmega8__)
137
+      case 0:
138
+        // 8 bit timer
139
+        TCCR0A = 0;
140
+        TCCR0B = 0;
141
+        bitWrite(TCCR0A, WGM01, 1);
142
+        bitWrite(TCCR0B, CS00, 1);
143
+        timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
144
+        timer0_pin_mask = digitalPinToBitMask(_pin);
145
+        break;
146
+#endif
147
+
148
+      case 1:
149
+        // 16 bit timer
150
+        TCCR1A = 0;
151
+        TCCR1B = 0;
152
+        bitWrite(TCCR1B, WGM12, 1);
153
+        bitWrite(TCCR1B, CS10, 1);
154
+        timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
155
+        timer1_pin_mask = digitalPinToBitMask(_pin);
156
+        break;
157
+      case 2:
158
+        // 8 bit timer
159
+        TCCR2A = 0;
160
+        TCCR2B = 0;
161
+        bitWrite(TCCR2A, WGM21, 1);
162
+        bitWrite(TCCR2B, CS20, 1);
163
+        timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
164
+        timer2_pin_mask = digitalPinToBitMask(_pin);
165
+        break;
166
+
167
+#if defined(__AVR_ATmega1280__)
168
+      case 3:
169
+        // 16 bit timer
170
+        TCCR3A = 0;
171
+        TCCR3B = 0;
172
+        bitWrite(TCCR3B, WGM32, 1);
173
+        bitWrite(TCCR3B, CS30, 1);
174
+        timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
175
+        timer3_pin_mask = digitalPinToBitMask(_pin);
176
+        break;
177
+      case 4:
178
+        // 16 bit timer
179
+        TCCR4A = 0;
180
+        TCCR4B = 0;
181
+        bitWrite(TCCR4B, WGM42, 1);
182
+        bitWrite(TCCR4B, CS40, 1);
183
+        timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
184
+        timer4_pin_mask = digitalPinToBitMask(_pin);
185
+        break;
186
+      case 5:
187
+        // 16 bit timer
188
+        TCCR5A = 0;
189
+        TCCR5B = 0;
190
+        bitWrite(TCCR5B, WGM52, 1);
191
+        bitWrite(TCCR5B, CS50, 1);
192
+        timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
193
+        timer5_pin_mask = digitalPinToBitMask(_pin);
194
+        break;
195
+#endif
196
+    }
197
+  }
198
+
199
+  return _timer;
200
+}
201
+
202
+
203
+
204
+// frequency (in hertz) and duration (in milliseconds).
205
+
206
+void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
207
+{
208
+  uint8_t prescalarbits = 0b001;
209
+  long toggle_count = 0;
210
+  uint32_t ocr = 0;
211
+  int8_t _timer;
212
+
213
+  _timer = toneBegin(_pin);
214
+
215
+  if (_timer >= 0)
216
+  {
217
+    // Set the pinMode as OUTPUT
218
+    pinMode(_pin, OUTPUT);
219
+    
220
+    // if we are using an 8 bit timer, scan through prescalars to find the best fit
221
+    if (_timer == 0 || _timer == 2)
222
+    {
223
+      ocr = F_CPU / frequency / 2 - 1;
224
+      prescalarbits = 0b001;  // ck/1: same for both timers
225
+      if (ocr > 255)
226
+      {
227
+        ocr = F_CPU / frequency / 2 / 8 - 1;
228
+        prescalarbits = 0b010;  // ck/8: same for both timers
229
+
230
+        if (_timer == 2 && ocr > 255)
231
+        {
232
+          ocr = F_CPU / frequency / 2 / 32 - 1;
233
+          prescalarbits = 0b011;
234
+        }
235
+
236
+        if (ocr > 255)
237
+        {
238
+          ocr = F_CPU / frequency / 2 / 64 - 1;
239
+          prescalarbits = _timer == 0 ? 0b011 : 0b100;
240
+
241
+          if (_timer == 2 && ocr > 255)
242
+          {
243
+            ocr = F_CPU / frequency / 2 / 128 - 1;
244
+            prescalarbits = 0b101;
245
+          }
246
+
247
+          if (ocr > 255)
248
+          {
249
+            ocr = F_CPU / frequency / 2 / 256 - 1;
250
+            prescalarbits = _timer == 0 ? 0b100 : 0b110;
251
+            if (ocr > 255)
252
+            {
253
+              // can't do any better than /1024
254
+              ocr = F_CPU / frequency / 2 / 1024 - 1;
255
+              prescalarbits = _timer == 0 ? 0b101 : 0b111;
256
+            }
257
+          }
258
+        }
259
+      }
260
+
261
+#if !defined(__AVR_ATmega8__)
262
+      if (_timer == 0)
263
+        TCCR0B = prescalarbits;
264
+      else
265
+#endif
266
+        TCCR2B = prescalarbits;
267
+    }
268
+    else
269
+    {
270
+      // two choices for the 16 bit timers: ck/1 or ck/64
271
+      ocr = F_CPU / frequency / 2 - 1;
272
+
273
+      prescalarbits = 0b001;
274
+      if (ocr > 0xffff)
275
+      {
276
+        ocr = F_CPU / frequency / 2 / 64 - 1;
277
+        prescalarbits = 0b011;
278
+      }
279
+
280
+      if (_timer == 1)
281
+        TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
282
+#if defined(__AVR_ATmega1280__)
283
+      else if (_timer == 3)
284
+        TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
285
+      else if (_timer == 4)
286
+        TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
287
+      else if (_timer == 5)
288
+        TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
289
+#endif
290
+
291
+    }
292
+    
293
+
294
+    // Calculate the toggle count
295
+    if (duration > 0)
296
+    {
297
+      toggle_count = 2 * frequency * duration / 1000;
298
+    }
299
+    else
300
+    {
301
+      toggle_count = -1;
302
+    }
303
+
304
+    // Set the OCR for the given timer,
305
+    // set the toggle count,
306
+    // then turn on the interrupts
307
+    switch (_timer)
308
+    {
309
+
310
+#if !defined(__AVR_ATmega8__)
311
+      case 0:
312
+        OCR0A = ocr;
313
+        timer0_toggle_count = toggle_count;
314
+        bitWrite(TIMSK0, OCIE0A, 1);
315
+        break;
316
+#endif
317
+
318
+      case 1:
319
+        OCR1A = ocr;
320
+        timer1_toggle_count = toggle_count;
321
+        bitWrite(TIMSK1, OCIE1A, 1);
322
+        break;
323
+      case 2:
324
+        OCR2A = ocr;
325
+        timer2_toggle_count = toggle_count;
326
+        bitWrite(TIMSK2, OCIE2A, 1);
327
+        break;
328
+
329
+#if defined(__AVR_ATmega1280__)
330
+      case 3:
331
+        OCR3A = ocr;
332
+        timer3_toggle_count = toggle_count;
333
+        bitWrite(TIMSK3, OCIE3A, 1);
334
+        break;
335
+      case 4:
336
+        OCR4A = ocr;
337
+        timer4_toggle_count = toggle_count;
338
+        bitWrite(TIMSK4, OCIE4A, 1);
339
+        break;
340
+      case 5:
341
+        OCR5A = ocr;
342
+        timer5_toggle_count = toggle_count;
343
+        bitWrite(TIMSK5, OCIE5A, 1);
344
+        break;
345
+#endif
346
+
347
+    }
348
+  }
349
+}
350
+
351
+
352
+void noTone(uint8_t _pin)
353
+{
354
+  int8_t _timer = -1;
355
+  
356
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
357
+    if (tone_pins[i] == _pin) {
358
+      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
359
+      tone_pins[i] = 255;
360
+    }
361
+  }
362
+  
363
+  switch (_timer)
364
+  {
365
+#if defined(__AVR_ATmega8__)
366
+    case 1:
367
+      bitWrite(TIMSK1, OCIE1A, 0);
368
+      break;
369
+    case 2:
370
+      bitWrite(TIMSK2, OCIE2A, 0);
371
+      break;
372
+
373
+#else
374
+    case 0:
375
+      TIMSK0 = 0;
376
+      break;
377
+    case 1:
378
+      TIMSK1 = 0;
379
+      break;
380
+    case 2:
381
+      TIMSK2 = 0;
382
+      break;
383
+#endif
384
+
385
+#if defined(__AVR_ATmega1280__)
386
+    case 3:
387
+      TIMSK3 = 0;
388
+      break;
389
+    case 4:
390
+      TIMSK4 = 0;
391
+      break;
392
+    case 5:
393
+      TIMSK5 = 0;
394
+      break;
395
+#endif
396
+  }
397
+
398
+  digitalWrite(_pin, 0);
399
+}
400
+
401
+#if 0
402
+#if !defined(__AVR_ATmega8__)
403
+ISR(TIMER0_COMPA_vect)
404
+{
405
+  if (timer0_toggle_count != 0)
406
+  {
407
+    // toggle the pin
408
+    *timer0_pin_port ^= timer0_pin_mask;
409
+
410
+    if (timer0_toggle_count > 0)
411
+      timer0_toggle_count--;
412
+  }
413
+  else
414
+  {
415
+    TIMSK0 = 0;   // disable the interrupt
416
+    *timer0_pin_port &= ~(timer0_pin_mask);  // keep pin low after stop
417
+  }
418
+}
419
+#endif
420
+
421
+
422
+ISR(TIMER1_COMPA_vect)
423
+{
424
+  if (timer1_toggle_count != 0)
425
+  {
426
+    // toggle the pin
427
+    *timer1_pin_port ^= timer1_pin_mask;
428
+
429
+    if (timer1_toggle_count > 0)
430
+      timer1_toggle_count--;
431
+  }
432
+  else
433
+  {
434
+    TIMSK1 = 0;   // disable the interrupt
435
+    *timer1_pin_port &= ~(timer1_pin_mask);  // keep pin low after stop
436
+  }
437
+}
438
+#endif
439
+
440
+
441
+ISR(TIMER2_COMPA_vect)
442
+{
443
+
444
+  if (timer2_toggle_count != 0)
445
+  {
446
+    // toggle the pin
447
+    *timer2_pin_port ^= timer2_pin_mask;
448
+
449
+    if (timer2_toggle_count > 0)
450
+      timer2_toggle_count--;
451
+  }
452
+  else
453
+  {
454
+    TIMSK2 = 0;   // disable the interrupt
455
+    *timer2_pin_port &= ~(timer2_pin_mask);  // keep pin low after stop
456
+  }
457
+}
458
+
459
+
460
+
461
+//#if defined(__AVR_ATmega1280__)
462
+#if 0
463
+
464
+ISR(TIMER3_COMPA_vect)
465
+{
466
+  if (timer3_toggle_count != 0)
467
+  {
468
+    // toggle the pin
469
+    *timer3_pin_port ^= timer3_pin_mask;
470
+
471
+    if (timer3_toggle_count > 0)
472
+      timer3_toggle_count--;
473
+  }
474
+  else
475
+  {
476
+    TIMSK3 = 0;   // disable the interrupt
477
+    *timer3_pin_port &= ~(timer3_pin_mask);  // keep pin low after stop
478
+  }
479
+}
480
+
481
+ISR(TIMER4_COMPA_vect)
482
+{
483
+  if (timer4_toggle_count != 0)
484
+  {
485
+    // toggle the pin
486
+    *timer4_pin_port ^= timer4_pin_mask;
487
+
488
+    if (timer4_toggle_count > 0)
489
+      timer4_toggle_count--;
490
+  }
491
+  else
492
+  {
493
+    TIMSK4 = 0;   // disable the interrupt
494
+    *timer4_pin_port &= ~(timer4_pin_mask);  // keep pin low after stop
495
+  }
496
+}
497
+
498
+ISR(TIMER5_COMPA_vect)
499
+{
500
+  if (timer5_toggle_count != 0)
501
+  {
502
+    // toggle the pin
503
+    *timer5_pin_port ^= timer5_pin_mask;
504
+
505
+    if (timer5_toggle_count > 0)
506
+      timer5_toggle_count--;
507
+  }
508
+  else
509
+  {
510
+    TIMSK5 = 0;   // disable the interrupt
511
+    *timer5_pin_port &= ~(timer5_pin_mask);  // keep pin low after stop
512
+  }
513
+}
514
+
515
+#endif

+ 168
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WCharacter.h Dosyayı Görüntüle

@@ -0,0 +1,168 @@
1
+/*
2
+ WCharacter.h - Character utility functions for Wiring & Arduino
3
+ Copyright (c) 2010 Hernando Barragan.  All right reserved.
4
+ 
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+ 
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+ 
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ */
19
+
20
+#ifndef Character_h
21
+#define Character_h
22
+
23
+#include <ctype.h>
24
+
25
+// WCharacter.h prototypes
26
+inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
27
+inline boolean isAlpha(int c) __attribute__((always_inline));
28
+inline boolean isAscii(int c) __attribute__((always_inline));
29
+inline boolean isWhitespace(int c) __attribute__((always_inline));
30
+inline boolean isControl(int c) __attribute__((always_inline));
31
+inline boolean isDigit(int c) __attribute__((always_inline));
32
+inline boolean isGraph(int c) __attribute__((always_inline));
33
+inline boolean isLowerCase(int c) __attribute__((always_inline));
34
+inline boolean isPrintable(int c) __attribute__((always_inline));
35
+inline boolean isPunct(int c) __attribute__((always_inline));
36
+inline boolean isSpace(int c) __attribute__((always_inline));
37
+inline boolean isUpperCase(int c) __attribute__((always_inline));
38
+inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
39
+inline int toAscii(int c) __attribute__((always_inline));
40
+inline int toLowerCase(int c) __attribute__((always_inline));
41
+inline int toUpperCase(int c)__attribute__((always_inline));
42
+
43
+
44
+// Checks for an alphanumeric character. 
45
+// It is equivalent to (isalpha(c) || isdigit(c)).
46
+inline boolean isAlphaNumeric(int c) 
47
+{
48
+  return ( isalnum(c) == 0 ? false : true);
49
+}
50
+
51
+
52
+// Checks for an alphabetic character. 
53
+// It is equivalent to (isupper(c) || islower(c)).
54
+inline boolean isAlpha(int c)
55
+{
56
+  return ( isalpha(c) == 0 ? false : true);
57
+}
58
+
59
+
60
+// Checks whether c is a 7-bit unsigned char value 
61
+// that fits into the ASCII character set.
62
+inline boolean isAscii(int c)
63
+{
64
+  return ( isascii (c) == 0 ? false : true);
65
+}
66
+
67
+
68
+// Checks for a blank character, that is, a space or a tab.
69
+inline boolean isWhitespace(int c)
70
+{
71
+  return ( isblank (c) == 0 ? false : true);
72
+}
73
+
74
+
75
+// Checks for a control character.
76
+inline boolean isControl(int c)
77
+{
78
+  return ( iscntrl (c) == 0 ? false : true);
79
+}
80
+
81
+
82
+// Checks for a digit (0 through 9).
83
+inline boolean isDigit(int c)
84
+{
85
+  return ( isdigit (c) == 0 ? false : true);
86
+}
87
+
88
+
89
+// Checks for any printable character except space.
90
+inline boolean isGraph(int c)
91
+{
92
+  return ( isgraph (c) == 0 ? false : true);
93
+}
94
+
95
+
96
+// Checks for a lower-case character.
97
+inline boolean isLowerCase(int c)
98
+{
99
+  return (islower (c) == 0 ? false : true);
100
+}
101
+
102
+
103
+// Checks for any printable character including space.
104
+inline boolean isPrintable(int c)
105
+{
106
+  return ( isprint (c) == 0 ? false : true);
107
+}
108
+
109
+
110
+// Checks for any printable character which is not a space 
111
+// or an alphanumeric character.
112
+inline boolean isPunct(int c)
113
+{
114
+  return ( ispunct (c) == 0 ? false : true);
115
+}
116
+
117
+
118
+// Checks for white-space characters. For the avr-libc library, 
119
+// these are: space, formfeed ('\f'), newline ('\n'), carriage 
120
+// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
121
+inline boolean isSpace(int c)
122
+{
123
+  return ( isspace (c) == 0 ? false : true);
124
+}
125
+
126
+
127
+// Checks for an uppercase letter.
128
+inline boolean isUpperCase(int c)
129
+{
130
+  return ( isupper (c) == 0 ? false : true);
131
+}
132
+
133
+
134
+// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 
135
+// 8 9 a b c d e f A B C D E F.
136
+inline boolean isHexadecimalDigit(int c)
137
+{
138
+  return ( isxdigit (c) == 0 ? false : true);
139
+}
140
+
141
+
142
+// Converts c to a 7-bit unsigned char value that fits into the 
143
+// ASCII character set, by clearing the high-order bits.
144
+inline int toAscii(int c)
145
+{
146
+  return toascii (c);
147
+}
148
+
149
+
150
+// Warning:
151
+// Many people will be unhappy if you use this function. 
152
+// This function will convert accented letters into random 
153
+// characters.
154
+
155
+// Converts the letter c to lower case, if possible.
156
+inline int toLowerCase(int c)
157
+{
158
+  return tolower (c);
159
+}
160
+
161
+
162
+// Converts the letter c to upper case, if possible.
163
+inline int toUpperCase(int c)
164
+{
165
+  return toupper (c);
166
+}
167
+
168
+#endif

+ 1
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WConstants.h Dosyayı Görüntüle

@@ -0,0 +1 @@
1
+#include "wiring.h"

+ 87
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WInterrupts.c Dosyayı Görüntüle

@@ -0,0 +1,87 @@
1
+/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+/*
4
+  Part of the Wiring project - http://wiring.uniandes.edu.co
5
+
6
+  Copyright (c) 2004-05 Hernando Barragan
7
+
8
+  This library is free software; you can redistribute it and/or
9
+  modify it under the terms of the GNU Lesser General Public
10
+  License as published by the Free Software Foundation; either
11
+  version 2.1 of the License, or (at your option) any later version.
12
+
13
+  This library is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+  Lesser General Public License for more details.
17
+
18
+  You should have received a copy of the GNU Lesser General
19
+  Public License along with this library; if not, write to the
20
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+  Boston, MA  02111-1307  USA
22
+  
23
+  Modified 24 November 2006 by David A. Mellis
24
+*/
25
+
26
+#include <inttypes.h>
27
+#include <avr/io.h>
28
+#include <avr/interrupt.h>
29
+#include <avr/pgmspace.h>
30
+#include <stdio.h>
31
+
32
+#include "WConstants.h"
33
+#include "wiring_private.h"
34
+
35
+volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
36
+// volatile static voidFuncPtr twiIntFunc;
37
+
38
+void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)
39
+{
40
+	if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
41
+	{
42
+		intFunc[interruptNum] = userFunc;
43
+
44
+		//clear the config for the change settings
45
+		EICRA &= ~(B00000011 << (interruptNum * 2));
46
+
47
+		//set our mode.
48
+		EICRA |= (mode << (interruptNum * 2));
49
+
50
+		// Enable the interrupt.
51
+		EIMSK |= (1 << interruptNum);
52
+	}
53
+}
54
+
55
+void detachInterrupt(uint8_t interruptNum)
56
+{
57
+	if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
58
+	{
59
+		// Disable the interrupt.
60
+		EIMSK &= ~(1 << interruptNum);
61
+
62
+		intFunc[interruptNum] = 0;
63
+	}
64
+}
65
+
66
+ISR(INT0_vect) {
67
+  if(intFunc[EXTERNAL_INT_0])
68
+    intFunc[EXTERNAL_INT_0]();
69
+}
70
+
71
+ISR(INT1_vect) {
72
+  if(intFunc[EXTERNAL_INT_1])
73
+    intFunc[EXTERNAL_INT_1]();
74
+}
75
+
76
+ISR(INT2_vect) {
77
+  if(intFunc[EXTERNAL_INT_2])
78
+    intFunc[EXTERNAL_INT_2]();
79
+}
80
+
81
+/*
82
+SIGNAL(SIG_2WIRE_SERIAL) {
83
+  if(twiIntFunc)
84
+    twiIntFunc();
85
+}
86
+*/
87
+

+ 60
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WMath.cpp Dosyayı Görüntüle

@@ -0,0 +1,60 @@
1
+/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+/*
4
+  Part of the Wiring project - http://wiring.org.co
5
+  Copyright (c) 2004-06 Hernando Barragan
6
+  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
7
+  
8
+  This library is free software; you can redistribute it and/or
9
+  modify it under the terms of the GNU Lesser General Public
10
+  License as published by the Free Software Foundation; either
11
+  version 2.1 of the License, or (at your option) any later version.
12
+
13
+  This library is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+  Lesser General Public License for more details.
17
+
18
+  You should have received a copy of the GNU Lesser General
19
+  Public License along with this library; if not, write to the
20
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+  Boston, MA  02111-1307  USA
22
+  
23
+  $Id$
24
+*/
25
+
26
+extern "C" {
27
+  #include "stdlib.h"
28
+}
29
+
30
+void randomSeed(unsigned int seed)
31
+{
32
+  if (seed != 0){
33
+    srandom(seed);
34
+  }
35
+}
36
+
37
+long random(long howbig)
38
+{
39
+  if (howbig == 0) {
40
+    return 0;
41
+  }
42
+  return random() % howbig;
43
+}
44
+
45
+long random(long howsmall, long howbig)
46
+{
47
+  if (howsmall >= howbig) {
48
+    return howsmall;
49
+  }
50
+  long diff = howbig - howsmall;
51
+  return random(diff) + howsmall;
52
+}
53
+
54
+long map(long x, long in_min, long in_max, long out_min, long out_max)
55
+{
56
+  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
57
+}
58
+
59
+unsigned int makeWord(unsigned int w) { return w; }
60
+unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 34
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WProgram.h Dosyayı Görüntüle

@@ -0,0 +1,34 @@
1
+#ifndef WProgram_h
2
+#define WProgram_h
3
+
4
+#include <stdlib.h>
5
+#include <string.h>
6
+#include <math.h>
7
+
8
+#include <avr/interrupt.h>
9
+
10
+#include "wiring.h"
11
+
12
+#ifdef __cplusplus
13
+#include "WCharacter.h"
14
+#include "WString.h"
15
+#include "HardwareSerial.h"
16
+
17
+uint16_t makeWord(uint16_t w);
18
+uint16_t makeWord(byte h, byte l);
19
+
20
+#define word(...) makeWord(__VA_ARGS__)
21
+
22
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
23
+
24
+void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
25
+void noTone(uint8_t _pin);
26
+
27
+// WMath prototypes
28
+long random(long);
29
+long random(long, long);
30
+void randomSeed(unsigned int);
31
+long map(long, long, long, long, long);
32
+#endif
33
+
34
+#endif

+ 443
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WString.cpp Dosyayı Görüntüle

@@ -0,0 +1,443 @@
1
+/*
2
+  WString.cpp - String library for Wiring & Arduino
3
+  Copyright (c) 2009-10 Hernando Barragan.  All rights reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#include <stdlib.h>
21
+#include "WProgram.h"
22
+#include "WString.h"
23
+
24
+
25
+String::String( const char *value )
26
+{
27
+  if ( value == NULL )
28
+    value = "";
29
+  getBuffer( _length = strlen( value ) );
30
+  if ( _buffer != NULL )
31
+    strcpy( _buffer, value );
32
+}
33
+
34
+String::String( const String &value )
35
+{
36
+  getBuffer( _length = value._length );
37
+  if ( _buffer != NULL )
38
+    strcpy( _buffer, value._buffer );
39
+}
40
+
41
+String::String( const char value )
42
+{
43
+  _length = 1;
44
+  getBuffer(1);
45
+  if ( _buffer != NULL ) {
46
+    _buffer[0] = value;
47
+    _buffer[1] = 0;
48
+  }
49
+}
50
+
51
+String::String( const unsigned char value )
52
+{
53
+  _length = 1;
54
+  getBuffer(1);
55
+  if ( _buffer != NULL) {
56
+    _buffer[0] = value;
57
+    _buffer[1] = 0;
58
+  }
59
+}
60
+
61
+String::String( const int value, const int base )
62
+{
63
+  char buf[33];   
64
+  itoa((signed long)value, buf, base);
65
+  getBuffer( _length = strlen(buf) );
66
+  if ( _buffer != NULL )
67
+    strcpy( _buffer, buf );
68
+}
69
+
70
+String::String( const unsigned int value, const int base )
71
+{
72
+  char buf[33];   
73
+  ultoa((unsigned long)value, buf, base);
74
+  getBuffer( _length = strlen(buf) );
75
+  if ( _buffer != NULL )
76
+    strcpy( _buffer, buf );
77
+}
78
+
79
+String::String( const long value, const int base )
80
+{
81
+  char buf[33];   
82
+  ltoa(value, buf, base);
83
+  getBuffer( _length = strlen(buf) );
84
+  if ( _buffer != NULL )
85
+    strcpy( _buffer, buf );
86
+}
87
+
88
+String::String( const unsigned long value, const int base )
89
+{
90
+  char buf[33];   
91
+  ultoa(value, buf, 10);
92
+  getBuffer( _length = strlen(buf) );
93
+  if ( _buffer != NULL )
94
+    strcpy( _buffer, buf );
95
+}
96
+
97
+char String::charAt( unsigned int loc ) const
98
+{
99
+  return operator[]( loc );
100
+}
101
+
102
+void String::setCharAt( unsigned int loc, const char aChar ) 
103
+{
104
+  if(_buffer == NULL) return;
105
+  if(_length > loc) {
106
+    _buffer[loc] = aChar;
107
+  }
108
+}
109
+
110
+int String::compareTo( const String &s2 ) const
111
+{
112
+  return strcmp( _buffer, s2._buffer );
113
+}
114
+
115
+const String & String::concat( const String &s2 )
116
+{
117
+  return (*this) += s2;
118
+}
119
+
120
+const String & String::operator=( const String &rhs )
121
+{
122
+  if ( this == &rhs )
123
+    return *this;
124
+
125
+  if ( rhs._length > _length )
126
+  {
127
+    free(_buffer);
128
+    getBuffer( rhs._length );
129
+  }
130
+  
131
+  if ( _buffer != NULL ) {
132
+    _length = rhs._length;
133
+    strcpy( _buffer, rhs._buffer );
134
+  }
135
+  return *this;
136
+}
137
+
138
+//const String & String::operator+=( const char aChar )
139
+//{
140
+//  if ( _length == _capacity )
141
+//    doubleBuffer();
142
+//
143
+//  _buffer[ _length++ ] = aChar;
144
+//  _buffer[ _length ] = '\0';
145
+//  return *this;
146
+//}
147
+
148
+const String & String::operator+=( const String &other )
149
+{
150
+  _length += other._length;
151
+  if ( _length > _capacity )
152
+  {
153
+    char *temp = (char *)realloc(_buffer, _length + 1);
154
+    if ( temp != NULL ) {
155
+      _buffer = temp;
156
+      _capacity = _length;
157
+    } else {
158
+      _length -= other._length;
159
+      return *this;
160
+    }
161
+  }
162
+  strcat( _buffer, other._buffer );
163
+  return *this;
164
+}
165
+
166
+
167
+int String::operator==( const String &rhs ) const
168
+{
169
+  return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 );
170
+}
171
+
172
+int String::operator!=( const String &rhs ) const
173
+{
174
+  return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 );
175
+}
176
+
177
+int String::operator<( const String &rhs ) const
178
+{
179
+  return strcmp( _buffer, rhs._buffer ) < 0;
180
+}
181
+
182
+int String::operator>( const String &rhs ) const
183
+{
184
+  return strcmp( _buffer, rhs._buffer ) > 0;
185
+}
186
+
187
+int String::operator<=( const String &rhs ) const
188
+{
189
+  return strcmp( _buffer, rhs._buffer ) <= 0;
190
+}
191
+
192
+int String::operator>=( const String & rhs ) const
193
+{
194
+  return strcmp( _buffer, rhs._buffer ) >= 0;
195
+}
196
+
197
+char & String::operator[]( unsigned int index )
198
+{
199
+  static char dummy_writable_char;
200
+  if (index >= _length || !_buffer) {
201
+    dummy_writable_char = 0;
202
+    return dummy_writable_char;
203
+  }
204
+  return _buffer[ index ];
205
+}
206
+
207
+char String::operator[]( unsigned int index ) const
208
+{
209
+  // need to check for valid index, to do later
210
+  return _buffer[ index ];
211
+}
212
+
213
+boolean String::endsWith( const String &s2 ) const
214
+{
215
+  if ( _length < s2._length )
216
+    return 0;
217
+
218
+  return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0;
219
+}
220
+
221
+boolean String::equals( const String &s2 ) const
222
+{
223
+  return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 );
224
+}
225
+
226
+boolean String::equalsIgnoreCase( const String &s2 ) const
227
+{
228
+  if ( this == &s2 )
229
+    return true; //1;
230
+  else if ( _length != s2._length )
231
+    return false; //0;
232
+
233
+  return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
234
+}
235
+
236
+String String::replace( char findChar, char replaceChar )
237
+{
238
+  if ( _buffer == NULL ) return *this;
239
+  String theReturn = _buffer;
240
+  char* temp = theReturn._buffer;
241
+  while( (temp = strchr( temp, findChar )) != 0 )
242
+    *temp = replaceChar;
243
+
244
+  return theReturn;
245
+}
246
+
247
+String String::replace( const String& match, const String& replace )
248
+{
249
+  if ( _buffer == NULL ) return *this;
250
+  String temp = _buffer, newString;
251
+
252
+  int loc;
253
+  while ( (loc = temp.indexOf( match )) != -1 )
254
+  {
255
+    newString += temp.substring( 0, loc );
256
+    newString += replace;
257
+    temp = temp.substring( loc + match._length );
258
+  }
259
+  newString += temp;  
260
+  return newString;
261
+}
262
+
263
+int String::indexOf( char temp ) const
264
+{
265
+  return indexOf( temp, 0 );
266
+}
267
+
268
+int String::indexOf( char ch, unsigned int fromIndex ) const
269
+{
270
+  if ( fromIndex >= _length )
271
+    return -1;
272
+
273
+  const char* temp = strchr( &_buffer[fromIndex], ch );
274
+  if ( temp == NULL )
275
+    return -1;
276
+
277
+  return temp - _buffer;
278
+}
279
+
280
+int String::indexOf( const String &s2 ) const
281
+{
282
+  return indexOf( s2, 0 );
283
+}
284
+
285
+int String::indexOf( const String &s2, unsigned int fromIndex ) const
286
+{
287
+  if ( fromIndex >= _length )
288
+    return -1;
289
+
290
+  const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer );
291
+
292
+  if ( theFind == NULL )
293
+    return -1;
294
+
295
+  return theFind - _buffer; // pointer subtraction
296
+}
297
+
298
+int String::lastIndexOf( char theChar ) const
299
+{
300
+  return lastIndexOf( theChar, _length - 1 );
301
+}
302
+
303
+int String::lastIndexOf( char ch, unsigned int fromIndex ) const
304
+{
305
+  if ( fromIndex >= _length )
306
+    return -1;
307
+
308
+  char tempchar = _buffer[fromIndex + 1];
309
+  _buffer[fromIndex + 1] = '\0';
310
+  char* temp = strrchr( _buffer, ch );
311
+  _buffer[fromIndex + 1] = tempchar;
312
+
313
+  if ( temp == NULL )
314
+    return -1;
315
+
316
+  return temp - _buffer;
317
+}
318
+
319
+int String::lastIndexOf( const String &s2 ) const
320
+{
321
+  return lastIndexOf( s2, _length - s2._length );
322
+}
323
+
324
+int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const
325
+{
326
+  // check for empty strings
327
+  if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length )
328
+    return -1;
329
+
330
+  // matching first character
331
+  char temp = s2[ 0 ];
332
+
333
+  for ( int i = fromIndex; i >= 0; i-- )
334
+  {
335
+    if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) )
336
+    return i;
337
+  }
338
+  return -1;
339
+}
340
+
341
+boolean String::startsWith( const String &s2 ) const
342
+{
343
+  if ( _length < s2._length )
344
+    return 0;
345
+
346
+  return startsWith( s2, 0 );
347
+}
348
+
349
+boolean String::startsWith( const String &s2, unsigned int offset ) const
350
+{
351
+  if ( offset > _length - s2._length )
352
+    return 0;
353
+
354
+  return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0;
355
+}
356
+
357
+String String::substring( unsigned int left ) const
358
+{
359
+  return substring( left, _length );
360
+}
361
+
362
+String String::substring( unsigned int left, unsigned int right ) const
363
+{
364
+  if ( left > right )
365
+  {
366
+    int temp = right;
367
+    right = left;
368
+    left = temp;
369
+  }
370
+
371
+  if ( right > _length )
372
+  {
373
+    right = _length;
374
+  } 
375
+
376
+  char temp = _buffer[ right ];  // save the replaced character
377
+  _buffer[ right ] = '\0';	
378
+  String outPut = ( _buffer + left );  // pointer arithmetic
379
+  _buffer[ right ] = temp;  //restore character
380
+  return outPut;
381
+}
382
+
383
+String String::toLowerCase() const
384
+{
385
+  String temp = _buffer;
386
+
387
+  for ( unsigned int i = 0; i < _length; i++ )
388
+    temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] );
389
+  return temp;
390
+}
391
+
392
+String String::toUpperCase() const
393
+{
394
+  String temp = _buffer;
395
+
396
+  for ( unsigned int i = 0; i < _length; i++ )
397
+    temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
398
+  return temp;
399
+}
400
+
401
+String String::trim() const
402
+{
403
+  if ( _buffer == NULL ) return *this;
404
+  String temp = _buffer;
405
+  unsigned int i,j;
406
+
407
+  for ( i = 0; i < _length; i++ )
408
+  {
409
+    if ( !isspace(_buffer[i]) )
410
+      break;
411
+  }
412
+
413
+  for ( j = temp._length - 1; j > i; j-- )
414
+  {
415
+    if ( !isspace(_buffer[j]) )
416
+      break;
417
+  }
418
+
419
+  return temp.substring( i, j + 1);
420
+}
421
+
422
+void String::getBytes(unsigned char *buf, unsigned int bufsize)
423
+{
424
+  if (!bufsize || !buf) return;
425
+  unsigned int len = bufsize - 1;
426
+  if (len > _length) len = _length;
427
+  strncpy((char *)buf, _buffer, len);
428
+  buf[len] = 0;
429
+}
430
+
431
+void String::toCharArray(char *buf, unsigned int bufsize)
432
+{
433
+  if (!bufsize || !buf) return;
434
+  unsigned int len = bufsize - 1;
435
+  if (len > _length) len = _length;
436
+  strncpy(buf, _buffer, len);
437
+  buf[len] = 0;
438
+}
439
+
440
+
441
+long String::toInt() {
442
+  return atol(_buffer);
443
+}

+ 112
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/WString.h Dosyayı Görüntüle

@@ -0,0 +1,112 @@
1
+/*
2
+  WString.h - String library for Wiring & Arduino
3
+  Copyright (c) 2009-10 Hernando Barragan.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef String_h
21
+#define String_h
22
+
23
+//#include "WProgram.h"
24
+#include <stdlib.h>
25
+#include <string.h>
26
+#include <ctype.h>
27
+
28
+class String
29
+{
30
+  public:
31
+    // constructors
32
+    String( const char *value = "" );
33
+    String( const String &value );
34
+    String( const char );
35
+    String( const unsigned char );
36
+    String( const int, const int base=10);
37
+    String( const unsigned int, const int base=10 );
38
+    String( const long, const int base=10 );
39
+    String( const unsigned long, const int base=10 );
40
+    ~String() { free(_buffer); _length = _capacity = 0;}     //added _length = _capacity = 0;
41
+
42
+    // operators
43
+    const String & operator = ( const String &rhs );
44
+    const String & operator +=( const String &rhs );
45
+    //const String & operator +=( const char );
46
+    int operator ==( const String &rhs ) const;
47
+    int	operator !=( const String &rhs ) const;
48
+    int	operator < ( const String &rhs ) const;
49
+    int	operator > ( const String &rhs ) const;
50
+    int	operator <=( const String &rhs ) const;
51
+    int	operator >=( const String &rhs ) const;
52
+    char operator []( unsigned int index ) const;
53
+    char& operator []( unsigned int index );
54
+    //operator const char *() const { return _buffer; }
55
+    
56
+    // general methods
57
+    char charAt( unsigned int index ) const;
58
+    int	compareTo( const String &anotherString ) const;
59
+    unsigned char endsWith( const String &suffix ) const;
60
+    unsigned char equals( const String &anObject ) const;
61
+    unsigned char equalsIgnoreCase( const String &anotherString ) const;
62
+    int	indexOf( char ch ) const;
63
+    int	indexOf( char ch, unsigned int fromIndex ) const;
64
+    int	indexOf( const String &str ) const;
65
+    int	indexOf( const String &str, unsigned int fromIndex ) const;
66
+    int	lastIndexOf( char ch ) const;
67
+    int	lastIndexOf( char ch, unsigned int fromIndex ) const;
68
+    int	lastIndexOf( const String &str ) const;
69
+    int	lastIndexOf( const String &str, unsigned int fromIndex ) const;
70
+    const unsigned int length( ) const { return _length; }
71
+    void setCharAt(unsigned int index, const char ch);
72
+    unsigned char startsWith( const String &prefix ) const;
73
+    unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
74
+    String substring( unsigned int beginIndex ) const;
75
+    String substring( unsigned int beginIndex, unsigned int endIndex ) const;
76
+    String toLowerCase( ) const;
77
+    String toUpperCase( ) const;
78
+    String trim( ) const;
79
+    void getBytes(unsigned char *buf, unsigned int bufsize);
80
+    void toCharArray(char *buf, unsigned int bufsize);
81
+    long toInt( );
82
+    const String& concat( const String &str );
83
+    String replace( char oldChar, char newChar );
84
+    String replace( const String& match, const String& replace );
85
+    friend String operator + ( String lhs, const String &rhs );
86
+
87
+  protected:
88
+    char *_buffer;	     // the actual char array
89
+    unsigned int _capacity;  // the array length minus one (for the '\0')
90
+    unsigned int _length;    // the String length (not counting the '\0')
91
+
92
+    void getBuffer(unsigned int maxStrLen);
93
+
94
+  private:
95
+
96
+};
97
+
98
+// allocate buffer space
99
+inline void String::getBuffer(unsigned int maxStrLen)
100
+{
101
+  _capacity = maxStrLen;
102
+  _buffer = (char *) malloc(_capacity + 1);
103
+  if (_buffer == NULL) _length = _capacity = 0;
104
+}
105
+
106
+inline String operator+( String lhs, const String &rhs )
107
+{
108
+  return lhs += rhs;
109
+}
110
+
111
+
112
+#endif

+ 515
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/binary.h Dosyayı Görüntüle

@@ -0,0 +1,515 @@
1
+#ifndef Binary_h
2
+#define Binary_h
3
+
4
+#define B0 0
5
+#define B00 0
6
+#define B000 0
7
+#define B0000 0
8
+#define B00000 0
9
+#define B000000 0
10
+#define B0000000 0
11
+#define B00000000 0
12
+#define B1 1
13
+#define B01 1
14
+#define B001 1
15
+#define B0001 1
16
+#define B00001 1
17
+#define B000001 1
18
+#define B0000001 1
19
+#define B00000001 1
20
+#define B10 2
21
+#define B010 2
22
+#define B0010 2
23
+#define B00010 2
24
+#define B000010 2
25
+#define B0000010 2
26
+#define B00000010 2
27
+#define B11 3
28
+#define B011 3
29
+#define B0011 3
30
+#define B00011 3
31
+#define B000011 3
32
+#define B0000011 3
33
+#define B00000011 3
34
+#define B100 4
35
+#define B0100 4
36
+#define B00100 4
37
+#define B000100 4
38
+#define B0000100 4
39
+#define B00000100 4
40
+#define B101 5
41
+#define B0101 5
42
+#define B00101 5
43
+#define B000101 5
44
+#define B0000101 5
45
+#define B00000101 5
46
+#define B110 6
47
+#define B0110 6
48
+#define B00110 6
49
+#define B000110 6
50
+#define B0000110 6
51
+#define B00000110 6
52
+#define B111 7
53
+#define B0111 7
54
+#define B00111 7
55
+#define B000111 7
56
+#define B0000111 7
57
+#define B00000111 7
58
+#define B1000 8
59
+#define B01000 8
60
+#define B001000 8
61
+#define B0001000 8
62
+#define B00001000 8
63
+#define B1001 9
64
+#define B01001 9
65
+#define B001001 9
66
+#define B0001001 9
67
+#define B00001001 9
68
+#define B1010 10
69
+#define B01010 10
70
+#define B001010 10
71
+#define B0001010 10
72
+#define B00001010 10
73
+#define B1011 11
74
+#define B01011 11
75
+#define B001011 11
76
+#define B0001011 11
77
+#define B00001011 11
78
+#define B1100 12
79
+#define B01100 12
80
+#define B001100 12
81
+#define B0001100 12
82
+#define B00001100 12
83
+#define B1101 13
84
+#define B01101 13
85
+#define B001101 13
86
+#define B0001101 13
87
+#define B00001101 13
88
+#define B1110 14
89
+#define B01110 14
90
+#define B001110 14
91
+#define B0001110 14
92
+#define B00001110 14
93
+#define B1111 15
94
+#define B01111 15
95
+#define B001111 15
96
+#define B0001111 15
97
+#define B00001111 15
98
+#define B10000 16
99
+#define B010000 16
100
+#define B0010000 16
101
+#define B00010000 16
102
+#define B10001 17
103
+#define B010001 17
104
+#define B0010001 17
105
+#define B00010001 17
106
+#define B10010 18
107
+#define B010010 18
108
+#define B0010010 18
109
+#define B00010010 18
110
+#define B10011 19
111
+#define B010011 19
112
+#define B0010011 19
113
+#define B00010011 19
114
+#define B10100 20
115
+#define B010100 20
116
+#define B0010100 20
117
+#define B00010100 20
118
+#define B10101 21
119
+#define B010101 21
120
+#define B0010101 21
121
+#define B00010101 21
122
+#define B10110 22
123
+#define B010110 22
124
+#define B0010110 22
125
+#define B00010110 22
126
+#define B10111 23
127
+#define B010111 23
128
+#define B0010111 23
129
+#define B00010111 23
130
+#define B11000 24
131
+#define B011000 24
132
+#define B0011000 24
133
+#define B00011000 24
134
+#define B11001 25
135
+#define B011001 25
136
+#define B0011001 25
137
+#define B00011001 25
138
+#define B11010 26
139
+#define B011010 26
140
+#define B0011010 26
141
+#define B00011010 26
142
+#define B11011 27
143
+#define B011011 27
144
+#define B0011011 27
145
+#define B00011011 27
146
+#define B11100 28
147
+#define B011100 28
148
+#define B0011100 28
149
+#define B00011100 28
150
+#define B11101 29
151
+#define B011101 29
152
+#define B0011101 29
153
+#define B00011101 29
154
+#define B11110 30
155
+#define B011110 30
156
+#define B0011110 30
157
+#define B00011110 30
158
+#define B11111 31
159
+#define B011111 31
160
+#define B0011111 31
161
+#define B00011111 31
162
+#define B100000 32
163
+#define B0100000 32
164
+#define B00100000 32
165
+#define B100001 33
166
+#define B0100001 33
167
+#define B00100001 33
168
+#define B100010 34
169
+#define B0100010 34
170
+#define B00100010 34
171
+#define B100011 35
172
+#define B0100011 35
173
+#define B00100011 35
174
+#define B100100 36
175
+#define B0100100 36
176
+#define B00100100 36
177
+#define B100101 37
178
+#define B0100101 37
179
+#define B00100101 37
180
+#define B100110 38
181
+#define B0100110 38
182
+#define B00100110 38
183
+#define B100111 39
184
+#define B0100111 39
185
+#define B00100111 39
186
+#define B101000 40
187
+#define B0101000 40
188
+#define B00101000 40
189
+#define B101001 41
190
+#define B0101001 41
191
+#define B00101001 41
192
+#define B101010 42
193
+#define B0101010 42
194
+#define B00101010 42
195
+#define B101011 43
196
+#define B0101011 43
197
+#define B00101011 43
198
+#define B101100 44
199
+#define B0101100 44
200
+#define B00101100 44
201
+#define B101101 45
202
+#define B0101101 45
203
+#define B00101101 45
204
+#define B101110 46
205
+#define B0101110 46
206
+#define B00101110 46
207
+#define B101111 47
208
+#define B0101111 47
209
+#define B00101111 47
210
+#define B110000 48
211
+#define B0110000 48
212
+#define B00110000 48
213
+#define B110001 49
214
+#define B0110001 49
215
+#define B00110001 49
216
+#define B110010 50
217
+#define B0110010 50
218
+#define B00110010 50
219
+#define B110011 51
220
+#define B0110011 51
221
+#define B00110011 51
222
+#define B110100 52
223
+#define B0110100 52
224
+#define B00110100 52
225
+#define B110101 53
226
+#define B0110101 53
227
+#define B00110101 53
228
+#define B110110 54
229
+#define B0110110 54
230
+#define B00110110 54
231
+#define B110111 55
232
+#define B0110111 55
233
+#define B00110111 55
234
+#define B111000 56
235
+#define B0111000 56
236
+#define B00111000 56
237
+#define B111001 57
238
+#define B0111001 57
239
+#define B00111001 57
240
+#define B111010 58
241
+#define B0111010 58
242
+#define B00111010 58
243
+#define B111011 59
244
+#define B0111011 59
245
+#define B00111011 59
246
+#define B111100 60
247
+#define B0111100 60
248
+#define B00111100 60
249
+#define B111101 61
250
+#define B0111101 61
251
+#define B00111101 61
252
+#define B111110 62
253
+#define B0111110 62
254
+#define B00111110 62
255
+#define B111111 63
256
+#define B0111111 63
257
+#define B00111111 63
258
+#define B1000000 64
259
+#define B01000000 64
260
+#define B1000001 65
261
+#define B01000001 65
262
+#define B1000010 66
263
+#define B01000010 66
264
+#define B1000011 67
265
+#define B01000011 67
266
+#define B1000100 68
267
+#define B01000100 68
268
+#define B1000101 69
269
+#define B01000101 69
270
+#define B1000110 70
271
+#define B01000110 70
272
+#define B1000111 71
273
+#define B01000111 71
274
+#define B1001000 72
275
+#define B01001000 72
276
+#define B1001001 73
277
+#define B01001001 73
278
+#define B1001010 74
279
+#define B01001010 74
280
+#define B1001011 75
281
+#define B01001011 75
282
+#define B1001100 76
283
+#define B01001100 76
284
+#define B1001101 77
285
+#define B01001101 77
286
+#define B1001110 78
287
+#define B01001110 78
288
+#define B1001111 79
289
+#define B01001111 79
290
+#define B1010000 80
291
+#define B01010000 80
292
+#define B1010001 81
293
+#define B01010001 81
294
+#define B1010010 82
295
+#define B01010010 82
296
+#define B1010011 83
297
+#define B01010011 83
298
+#define B1010100 84
299
+#define B01010100 84
300
+#define B1010101 85
301
+#define B01010101 85
302
+#define B1010110 86
303
+#define B01010110 86
304
+#define B1010111 87
305
+#define B01010111 87
306
+#define B1011000 88
307
+#define B01011000 88
308
+#define B1011001 89
309
+#define B01011001 89
310
+#define B1011010 90
311
+#define B01011010 90
312
+#define B1011011 91
313
+#define B01011011 91
314
+#define B1011100 92
315
+#define B01011100 92
316
+#define B1011101 93
317
+#define B01011101 93
318
+#define B1011110 94
319
+#define B01011110 94
320
+#define B1011111 95
321
+#define B01011111 95
322
+#define B1100000 96
323
+#define B01100000 96
324
+#define B1100001 97
325
+#define B01100001 97
326
+#define B1100010 98
327
+#define B01100010 98
328
+#define B1100011 99
329
+#define B01100011 99
330
+#define B1100100 100
331
+#define B01100100 100
332
+#define B1100101 101
333
+#define B01100101 101
334
+#define B1100110 102
335
+#define B01100110 102
336
+#define B1100111 103
337
+#define B01100111 103
338
+#define B1101000 104
339
+#define B01101000 104
340
+#define B1101001 105
341
+#define B01101001 105
342
+#define B1101010 106
343
+#define B01101010 106
344
+#define B1101011 107
345
+#define B01101011 107
346
+#define B1101100 108
347
+#define B01101100 108
348
+#define B1101101 109
349
+#define B01101101 109
350
+#define B1101110 110
351
+#define B01101110 110
352
+#define B1101111 111
353
+#define B01101111 111
354
+#define B1110000 112
355
+#define B01110000 112
356
+#define B1110001 113
357
+#define B01110001 113
358
+#define B1110010 114
359
+#define B01110010 114
360
+#define B1110011 115
361
+#define B01110011 115
362
+#define B1110100 116
363
+#define B01110100 116
364
+#define B1110101 117
365
+#define B01110101 117
366
+#define B1110110 118
367
+#define B01110110 118
368
+#define B1110111 119
369
+#define B01110111 119
370
+#define B1111000 120
371
+#define B01111000 120
372
+#define B1111001 121
373
+#define B01111001 121
374
+#define B1111010 122
375
+#define B01111010 122
376
+#define B1111011 123
377
+#define B01111011 123
378
+#define B1111100 124
379
+#define B01111100 124
380
+#define B1111101 125
381
+#define B01111101 125
382
+#define B1111110 126
383
+#define B01111110 126
384
+#define B1111111 127
385
+#define B01111111 127
386
+#define B10000000 128
387
+#define B10000001 129
388
+#define B10000010 130
389
+#define B10000011 131
390
+#define B10000100 132
391
+#define B10000101 133
392
+#define B10000110 134
393
+#define B10000111 135
394
+#define B10001000 136
395
+#define B10001001 137
396
+#define B10001010 138
397
+#define B10001011 139
398
+#define B10001100 140
399
+#define B10001101 141
400
+#define B10001110 142
401
+#define B10001111 143
402
+#define B10010000 144
403
+#define B10010001 145
404
+#define B10010010 146
405
+#define B10010011 147
406
+#define B10010100 148
407
+#define B10010101 149
408
+#define B10010110 150
409
+#define B10010111 151
410
+#define B10011000 152
411
+#define B10011001 153
412
+#define B10011010 154
413
+#define B10011011 155
414
+#define B10011100 156
415
+#define B10011101 157
416
+#define B10011110 158
417
+#define B10011111 159
418
+#define B10100000 160
419
+#define B10100001 161
420
+#define B10100010 162
421
+#define B10100011 163
422
+#define B10100100 164
423
+#define B10100101 165
424
+#define B10100110 166
425
+#define B10100111 167
426
+#define B10101000 168
427
+#define B10101001 169
428
+#define B10101010 170
429
+#define B10101011 171
430
+#define B10101100 172
431
+#define B10101101 173
432
+#define B10101110 174
433
+#define B10101111 175
434
+#define B10110000 176
435
+#define B10110001 177
436
+#define B10110010 178
437
+#define B10110011 179
438
+#define B10110100 180
439
+#define B10110101 181
440
+#define B10110110 182
441
+#define B10110111 183
442
+#define B10111000 184
443
+#define B10111001 185
444
+#define B10111010 186
445
+#define B10111011 187
446
+#define B10111100 188
447
+#define B10111101 189
448
+#define B10111110 190
449
+#define B10111111 191
450
+#define B11000000 192
451
+#define B11000001 193
452
+#define B11000010 194
453
+#define B11000011 195
454
+#define B11000100 196
455
+#define B11000101 197
456
+#define B11000110 198
457
+#define B11000111 199
458
+#define B11001000 200
459
+#define B11001001 201
460
+#define B11001010 202
461
+#define B11001011 203
462
+#define B11001100 204
463
+#define B11001101 205
464
+#define B11001110 206
465
+#define B11001111 207
466
+#define B11010000 208
467
+#define B11010001 209
468
+#define B11010010 210
469
+#define B11010011 211
470
+#define B11010100 212
471
+#define B11010101 213
472
+#define B11010110 214
473
+#define B11010111 215
474
+#define B11011000 216
475
+#define B11011001 217
476
+#define B11011010 218
477
+#define B11011011 219
478
+#define B11011100 220
479
+#define B11011101 221
480
+#define B11011110 222
481
+#define B11011111 223
482
+#define B11100000 224
483
+#define B11100001 225
484
+#define B11100010 226
485
+#define B11100011 227
486
+#define B11100100 228
487
+#define B11100101 229
488
+#define B11100110 230
489
+#define B11100111 231
490
+#define B11101000 232
491
+#define B11101001 233
492
+#define B11101010 234
493
+#define B11101011 235
494
+#define B11101100 236
495
+#define B11101101 237
496
+#define B11101110 238
497
+#define B11101111 239
498
+#define B11110000 240
499
+#define B11110001 241
500
+#define B11110010 242
501
+#define B11110011 243
502
+#define B11110100 244
503
+#define B11110101 245
504
+#define B11110110 246
505
+#define B11110111 247
506
+#define B11111000 248
507
+#define B11111001 249
508
+#define B11111010 250
509
+#define B11111011 251
510
+#define B11111100 252
511
+#define B11111101 253
512
+#define B11111110 254
513
+#define B11111111 255
514
+
515
+#endif

+ 14
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/main.cpp Dosyayı Görüntüle

@@ -0,0 +1,14 @@
1
+#include <WProgram.h>
2
+
3
+int main(void)
4
+{
5
+	init();
6
+
7
+	setup();
8
+    
9
+	for (;;)
10
+		loop();
11
+        
12
+	return 0;
13
+}
14
+

+ 12
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/main.cxx Dosyayı Görüntüle

@@ -0,0 +1,12 @@
1
+int main(void)
2
+{
3
+	init();
4
+
5
+	setup();
6
+    
7
+	for (;;)
8
+		loop();
9
+        
10
+	return 0;
11
+}
12
+

+ 200
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/pins_arduino.c Dosyayı Görüntüle

@@ -0,0 +1,200 @@
1
+/*
2
+  pins_arduino.c - pin definitions for the Arduino board
3
+  Part of Arduino / Wiring Lite
4
+
5
+  Copyright (c) 2005 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
23
+*/
24
+
25
+#include <avr/io.h>
26
+#include "wiring_private.h"
27
+#include "pins_arduino.h"
28
+
29
+// On the Sanguino board, digital pins are also used
30
+// for the analog output (software PWM).  Analog input
31
+// pins are a separate set.
32
+
33
+// ATMEL ATMEGA644P / SANGUINO
34
+//
35
+//                   +---\/---+
36
+//  INT0 (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
37
+//  INT1 (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
38
+//  INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
39
+//   PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
40
+//   PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
41
+//  MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
42
+//  MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
43
+//   SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
44
+//             RST  9|        |32  AREF
45
+//             VCC 10|        |31  GND 
46
+//             GND 11|        |30  AVCC
47
+//           XTAL2 12|        |29  PC7 (D 23)
48
+//           XTAL1 13|        |28  PC6 (D 22)
49
+//  RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
50
+//  TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
51
+//  RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
52
+//  TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
53
+//  PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
54
+//  PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
55
+//  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
56
+//                   +--------+
57
+//
58
+
59
+#define PA 1
60
+#define PB 2
61
+#define PC 3
62
+#define PD 4
63
+
64
+// these arrays map port names (e.g. port B) to the
65
+// appropriate addresses for various functions (e.g. reading
66
+// and writing)
67
+const uint8_t PROGMEM port_to_mode_PGM[] =
68
+{
69
+	NOT_A_PORT,
70
+        (uint8_t) &DDRA,
71
+	(uint8_t) &DDRB,
72
+	(uint8_t) &DDRC,
73
+	(uint8_t) &DDRD,
74
+};
75
+
76
+const uint8_t PROGMEM port_to_output_PGM[] =
77
+{
78
+	NOT_A_PORT,
79
+	(uint8_t) &PORTA,
80
+	(uint8_t) &PORTB,
81
+	(uint8_t) &PORTC,
82
+	(uint8_t) &PORTD,
83
+};
84
+
85
+const uint8_t PROGMEM port_to_input_PGM[] =
86
+{
87
+	NOT_A_PORT,
88
+	(uint8_t) &PINA,
89
+	(uint8_t) &PINB,
90
+	(uint8_t) &PINC,
91
+	(uint8_t) &PIND,
92
+};
93
+
94
+const uint8_t PROGMEM digital_pin_to_port_PGM[] =
95
+{
96
+	PB, /* 0 */
97
+	PB,
98
+	PB,
99
+	PB,
100
+	PB,
101
+	PB,
102
+	PB,
103
+	PB,
104
+	PD, /* 8 */
105
+	PD,
106
+	PD,
107
+	PD,
108
+	PD,
109
+	PD,
110
+	PD,
111
+	PD,
112
+	PC, /* 16 */
113
+	PC,
114
+	PC,
115
+	PC,
116
+	PC,
117
+	PC,
118
+   	PC,
119
+	PC,
120
+	PA, /* 24 */
121
+	PA,
122
+	PA,
123
+	PA,
124
+	PA,
125
+	PA,
126
+	PA,
127
+	PA  /* 31 */
128
+};
129
+
130
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
131
+{
132
+	_BV(0), /* 0, port B */
133
+	_BV(1),
134
+	_BV(2),
135
+	_BV(3),
136
+	_BV(4),
137
+	_BV(5),
138
+	_BV(6),
139
+	_BV(7),
140
+	_BV(0), /* 8, port D */
141
+	_BV(1),
142
+	_BV(2),
143
+	_BV(3),
144
+	_BV(4),
145
+	_BV(5),
146
+	_BV(6),
147
+	_BV(7),
148
+	_BV(0), /* 16, port C */
149
+	_BV(1),
150
+	_BV(2),
151
+	_BV(3),
152
+	_BV(4),
153
+	_BV(5),
154
+	_BV(6),
155
+	_BV(7),
156
+	_BV(7), /* 24, port A */
157
+	_BV(6),
158
+	_BV(5),
159
+	_BV(4),
160
+	_BV(3),
161
+	_BV(2),
162
+	_BV(1),
163
+	_BV(0)
164
+};
165
+
166
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
167
+{
168
+	NOT_ON_TIMER, 	/* 0  - PB0 */
169
+	NOT_ON_TIMER, 	/* 1  - PB1 */
170
+	NOT_ON_TIMER, 	/* 2  - PB2 */
171
+	TIMER0A,     	/* 3  - PB3 */
172
+	TIMER0B, 		/* 4  - PB4 */
173
+	NOT_ON_TIMER, 	/* 5  - PB5 */
174
+	NOT_ON_TIMER, 	/* 6  - PB6 */
175
+	NOT_ON_TIMER,	/* 7  - PB7 */
176
+	NOT_ON_TIMER, 	/* 8  - PD0 */
177
+	NOT_ON_TIMER, 	/* 9  - PD1 */
178
+	NOT_ON_TIMER, 	/* 10 - PD2 */
179
+	NOT_ON_TIMER, 	/* 11 - PD3 */
180
+	TIMER1B,     	/* 12 - PD4 */
181
+	TIMER1A,     	/* 13 - PD5 */
182
+	TIMER2B,     	/* 14 - PD6 */
183
+	TIMER2A,     	/* 15 - PD7 */
184
+	NOT_ON_TIMER, 	/* 16 - PC0 */
185
+	NOT_ON_TIMER,   /* 17 - PC1 */
186
+	NOT_ON_TIMER,   /* 18 - PC2 */
187
+	NOT_ON_TIMER,   /* 19 - PC3 */
188
+	NOT_ON_TIMER,   /* 20 - PC4 */
189
+	NOT_ON_TIMER,   /* 21 - PC5 */
190
+	NOT_ON_TIMER,   /* 22 - PC6 */
191
+	NOT_ON_TIMER,   /* 23 - PC7 */
192
+	NOT_ON_TIMER,   /* 24 - PA0 */
193
+	NOT_ON_TIMER,   /* 25 - PA1 */
194
+	NOT_ON_TIMER,   /* 26 - PA2 */
195
+	NOT_ON_TIMER,   /* 27 - PA3 */
196
+	NOT_ON_TIMER,   /* 28 - PA4 */
197
+	NOT_ON_TIMER,   /* 29 - PA5 */
198
+	NOT_ON_TIMER,   /* 30 - PA6 */
199
+	NOT_ON_TIMER   /* 31 - PA7 */
200
+};

+ 65
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/pins_arduino.h Dosyayı Görüntüle

@@ -0,0 +1,65 @@
1
+/*
2
+  pins_arduino.h - Pin definition functions for Arduino
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2007 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
+*/
24
+
25
+#ifndef Pins_Arduino_h
26
+#define Pins_Arduino_h
27
+
28
+#include <avr/pgmspace.h>
29
+
30
+#define NOT_A_PIN 0
31
+#define NOT_A_PORT 0
32
+
33
+#define NOT_ON_TIMER 0
34
+#define TIMER0A 1
35
+#define TIMER0B 2
36
+#define TIMER1A 3
37
+#define TIMER1B 4
38
+#define TIMER2  5
39
+#define TIMER2A 6
40
+#define TIMER2B 7
41
+
42
+extern const uint8_t PROGMEM port_to_mode_PGM[];
43
+extern const uint8_t PROGMEM port_to_input_PGM[];
44
+extern const uint8_t PROGMEM port_to_output_PGM[];
45
+
46
+extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
47
+extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
48
+extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
49
+
50
+extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
51
+
52
+// Get the bit location within the hardware port of the given virtual pin.
53
+// This comes from the pins_*.c file for the active board configuration.
54
+// 
55
+// These perform slightly better as macros compared to inline functions
56
+//
57
+#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
58
+#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
59
+#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
60
+#define analogInPinToBit(P) (P)
61
+#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
62
+#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
63
+#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
64
+
65
+#endif

Marlin/wiring.c → ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring.c Dosyayı Görüntüle

@@ -24,12 +24,19 @@
24 24
 
25 25
 #include "wiring_private.h"
26 26
 
27
+volatile unsigned long timer0_overflow_count = 0;
28
+volatile unsigned long timer0_clock_cycles = 0;
27 29
 volatile unsigned long timer0_millis = 0;
28 30
 
29 31
 SIGNAL(TIMER0_OVF_vect)
30 32
 {
33
+	timer0_overflow_count++;
31 34
 	// timer 0 prescale factor is 64 and the timer overflows at 256
32
-        timer0_millis++;
35
+	timer0_clock_cycles += 64UL * 256UL;
36
+	while (timer0_clock_cycles > clockCyclesPerMicrosecond() * 1000UL) {
37
+		timer0_clock_cycles -= clockCyclesPerMicrosecond() * 1000UL;
38
+		timer0_millis++;
39
+	}
33 40
 }
34 41
 
35 42
 unsigned long millis()
@@ -46,6 +53,27 @@ unsigned long millis()
46 53
 	return m;
47 54
 }
48 55
 
56
+unsigned long micros() {
57
+	unsigned long m, t;
58
+	uint8_t oldSREG = SREG;
59
+	
60
+	cli();	
61
+	t = TCNT0;
62
+  
63
+#ifdef TIFR0
64
+	if ((TIFR0 & _BV(TOV0)) && (t == 0))
65
+		t = 256;
66
+#else
67
+	if ((TIFR & _BV(TOV0)) && (t == 0))
68
+		t = 256;
69
+#endif
70
+
71
+	m = timer0_overflow_count;
72
+	SREG = oldSREG;
73
+	
74
+	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
75
+}
76
+
49 77
 void delay(unsigned long ms)
50 78
 {
51 79
 	unsigned long start = millis();
@@ -139,7 +167,7 @@ void init()
139 167
 	// this is better for motors as it ensures an even waveform
140 168
 	// note, however, that fast pwm mode can achieve a frequency of up
141 169
 	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
142
-#if 0
170
+
143 171
 	// set timer 1 prescale factor to 64
144 172
 	sbi(TCCR1B, CS11);
145 173
 	sbi(TCCR1B, CS10);
@@ -172,5 +200,4 @@ void init()
172 200
 	//TODO: test to see if disabling this helps?
173 201
 	//UCSR1B = 0;
174 202
 	#endif
175
-#endif
176 203
 }

+ 135
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring.h Dosyayı Görüntüle

@@ -0,0 +1,135 @@
1
+/*
2
+  wiring.h - Partial implementation of the Wiring API for the ATmega8.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.h 387 2008-03-08 21:30:00Z mellis $
23
+*/
24
+
25
+#ifndef Wiring_h
26
+#define Wiring_h
27
+
28
+#include <avr/io.h>
29
+#include "binary.h"
30
+
31
+#ifdef __cplusplus
32
+extern "C"{
33
+#endif
34
+
35
+#define HIGH 0x1
36
+#define LOW  0x0
37
+
38
+#define INPUT 0x0
39
+#define OUTPUT 0x1
40
+
41
+#define true 0x1
42
+#define false 0x0
43
+
44
+#define PI 3.14159265
45
+#define HALF_PI 1.57079
46
+#define TWO_PI 6.283185
47
+#define DEG_TO_RAD 0.01745329
48
+#define RAD_TO_DEG 57.2957786
49
+
50
+#define SERIAL  0x0
51
+#define DISPLAY 0x1
52
+
53
+#define LSBFIRST 0
54
+#define MSBFIRST 1
55
+
56
+#define CHANGE 1
57
+#define FALLING 2
58
+#define RISING 3
59
+
60
+#define INTERNAL 3
61
+#define DEFAULT 1
62
+#define EXTERNAL 0
63
+
64
+// undefine stdlib's abs if encountered
65
+#ifdef abs
66
+#undef abs
67
+#endif
68
+
69
+#define min(a,b) ((a)<(b)?(a):(b))
70
+#define max(a,b) ((a)>(b)?(a):(b))
71
+#define abs(x) ((x)>0?(x):-(x))
72
+#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
73
+#if __AVR_LIBC_VERSION__ < 10701UL
74
+#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
75
+#endif
76
+#define radians(deg) ((deg)*DEG_TO_RAD)
77
+#define degrees(rad) ((rad)*RAD_TO_DEG)
78
+#define sq(x) ((x)*(x))
79
+
80
+#define interrupts() sei()
81
+#define noInterrupts() cli()
82
+
83
+#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
84
+#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
85
+#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
86
+
87
+#define lowByte(w) ((w) & 0xff)
88
+#define highByte(w) ((w) >> 8)
89
+
90
+#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
91
+#define bitSet(value, bit) ((value) |= (1UL << (bit)))
92
+#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
93
+#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
94
+
95
+typedef unsigned int word;
96
+
97
+#define bit(b) (1 << (b))
98
+
99
+typedef uint8_t boolean;
100
+typedef uint8_t byte;
101
+
102
+void init(void);
103
+
104
+void pinMode(uint8_t, uint8_t);
105
+void digitalWrite(uint8_t, uint8_t);
106
+int digitalRead(uint8_t);
107
+int analogRead(uint8_t);
108
+void analogReference(uint8_t mode);
109
+void analogWrite(uint8_t, int);
110
+
111
+void beginSerial(uint8_t, long);
112
+void serialWrite(uint8_t, unsigned char);
113
+int serialAvailable(uint8_t);
114
+int serialRead(uint8_t);
115
+void serialFlush(uint8_t);
116
+
117
+unsigned long millis(void);
118
+unsigned long micros(void);
119
+void delay(unsigned long);
120
+void delayMicroseconds(unsigned int us);
121
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
122
+
123
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val);
124
+
125
+void attachInterrupt(uint8_t, void (*)(void), int mode);
126
+void detachInterrupt(uint8_t);
127
+
128
+void setup(void);
129
+void loop(void);
130
+
131
+#ifdef __cplusplus
132
+} // extern "C"
133
+#endif
134
+
135
+#endif

+ 116
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_analog.c Dosyayı Görüntüle

@@ -0,0 +1,116 @@
1
+/*
2
+  wiring_analog.c - analog input and output
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
+*/
24
+
25
+#include "wiring_private.h"
26
+#include "pins_arduino.h"
27
+
28
+uint8_t analog_reference = DEFAULT;
29
+
30
+void analogReference(uint8_t mode)
31
+{
32
+	// can't actually set the register here because the default setting
33
+	// will connect AVCC and the AREF pin, which would cause a short if
34
+	// there's something connected to AREF.
35
+	analog_reference = mode;
36
+}
37
+
38
+int analogRead(uint8_t pin)
39
+{
40
+	uint8_t low, high, ch = analogInPinToBit(pin);
41
+
42
+	// set the analog reference (high two bits of ADMUX) and select the
43
+	// channel (low 4 bits).  this also sets ADLAR (left-adjust result)
44
+	// to 0 (the default).
45
+	// the final AND is to clear the pos/neg reference bits
46
+	ADMUX = ((analog_reference << 6) | (pin & 0x0f)) & B11000111;
47
+
48
+	// without a delay, we seem to read from the wrong channel
49
+	//delay(1);
50
+
51
+	// start the conversion
52
+	sbi(ADCSRA, ADSC);
53
+
54
+	// ADSC is cleared when the conversion finishes
55
+	while (bit_is_set(ADCSRA, ADSC));
56
+
57
+	// we have to read ADCL first; doing so locks both ADCL
58
+	// and ADCH until ADCH is read.  reading ADCL second would
59
+	// cause the results of each conversion to be discarded,
60
+	// as ADCL and ADCH would be locked when it completed.
61
+	low = ADCL;
62
+	high = ADCH;
63
+
64
+	// combine the two bytes
65
+	return (high << 8) | low;
66
+}
67
+
68
+// Right now, PWM output only works on the pins with
69
+// hardware support.  These are defined in the appropriate
70
+// pins_*.c file.  For the rest of the pins, we default
71
+// to digital output.
72
+void analogWrite(uint8_t pin, int val)
73
+{
74
+	// We need to make sure the PWM output is enabled for those pins
75
+	// that support it, as we turn it off when digitally reading or
76
+	// writing with them.  Also, make sure the pin is in output mode
77
+	// for consistenty with Wiring, which doesn't require a pinMode
78
+	// call for the analog output pins.
79
+	pinMode(pin, OUTPUT);
80
+	
81
+	if (digitalPinToTimer(pin) == TIMER1A) {
82
+		// connect pwm to pin on timer 1, channel A
83
+		sbi(TCCR1A, COM1A1);
84
+		// set pwm duty
85
+		OCR1A = val;
86
+	} else if (digitalPinToTimer(pin) == TIMER1B) {
87
+		// connect pwm to pin on timer 1, channel B
88
+		sbi(TCCR1A, COM1B1);
89
+		// set pwm duty
90
+		OCR1B = val;
91
+	} else if (digitalPinToTimer(pin) == TIMER0A) {
92
+		// connect pwm to pin on timer 0, channel A
93
+		sbi(TCCR0A, COM0A1);
94
+		// set pwm duty
95
+		OCR0A = val;	
96
+	} else if (digitalPinToTimer(pin) == TIMER0B) {
97
+		// connect pwm to pin on timer 0, channel B
98
+		sbi(TCCR0A, COM0B1);
99
+		// set pwm duty
100
+		OCR0B = val;
101
+	} else if (digitalPinToTimer(pin) == TIMER2A) {
102
+		// connect pwm to pin on timer 2, channel A
103
+		sbi(TCCR2A, COM2A1);
104
+		// set pwm duty
105
+		OCR2A = val;	
106
+	} else if (digitalPinToTimer(pin) == TIMER2B) {
107
+		// connect pwm to pin on timer 2, channel B
108
+		sbi(TCCR2A, COM2B1);
109
+		// set pwm duty
110
+		OCR2B = val;
111
+	} else if (val < 128)
112
+	//fail semi-intelligently
113
+		digitalWrite(pin, LOW);
114
+	else
115
+		digitalWrite(pin, HIGH);
116
+}

+ 95
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_digital.c Dosyayı Görüntüle

@@ -0,0 +1,95 @@
1
+/*
2
+  wiring_digital.c - digital input and output functions
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
+*/
24
+
25
+#include "wiring_private.h"
26
+#include "pins_arduino.h"
27
+
28
+void pinMode(uint8_t pin, uint8_t mode)
29
+{
30
+	uint8_t bit = digitalPinToBitMask(pin);
31
+	uint8_t port = digitalPinToPort(pin);
32
+	volatile uint8_t *reg;
33
+
34
+	if (port == NOT_A_PIN) return;
35
+
36
+	// JWS: can I let the optimizer do this?
37
+	reg = portModeRegister(port);
38
+
39
+	if (mode == INPUT) *reg &= ~bit;
40
+	else *reg |= bit;
41
+}
42
+
43
+// Forcing this inline keeps the callers from having to push their own stuff
44
+// on the stack. It is a good performance win and only takes 1 more byte per
45
+// user than calling. (It will take more bytes on the 168.)
46
+//
47
+// But shouldn't this be moved into pinMode? Seems silly to check and do on
48
+// each digitalread or write.
49
+//
50
+static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
51
+static inline void turnOffPWM(uint8_t timer)
52
+{
53
+	if (timer == TIMER0A) cbi(TCCR0A, COM0A1);
54
+	if (timer == TIMER0B) cbi(TCCR0A, COM0B1);
55
+	if (timer == TIMER1A) cbi(TCCR1A, COM1A1);
56
+	if (timer == TIMER1B) cbi(TCCR1A, COM1B1);
57
+	if (timer == TIMER2A) cbi(TCCR2A, COM2A1);
58
+	if (timer == TIMER2B) cbi(TCCR2A, COM2B1);
59
+}
60
+
61
+void digitalWrite(uint8_t pin, uint8_t val)
62
+{
63
+	uint8_t timer = digitalPinToTimer(pin);
64
+	uint8_t bit = digitalPinToBitMask(pin);
65
+	uint8_t port = digitalPinToPort(pin);
66
+	volatile uint8_t *out;
67
+
68
+	if (port == NOT_A_PIN) return;
69
+
70
+	// If the pin that support PWM output, we need to turn it off
71
+	// before doing a digital write.
72
+	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
73
+
74
+	out = portOutputRegister(port);
75
+
76
+	if (val == LOW) *out &= ~bit;
77
+	else *out |= bit;
78
+}
79
+
80
+int digitalRead(uint8_t pin)
81
+{
82
+	uint8_t timer = digitalPinToTimer(pin);
83
+	uint8_t bit = digitalPinToBitMask(pin);
84
+	uint8_t port = digitalPinToPort(pin);
85
+
86
+	if (port == NOT_A_PIN) return LOW;
87
+
88
+	// If the pin that support PWM output, we need to turn it off
89
+	// before getting a digital reading.
90
+	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
91
+
92
+	if (*portInputRegister(port) & bit) return HIGH;
93
+	
94
+	return LOW;
95
+}

+ 60
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_private.h Dosyayı Görüntüle

@@ -0,0 +1,60 @@
1
+/*
2
+  wiring_private.h - Internal header file.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
23
+*/
24
+
25
+#ifndef WiringPrivate_h
26
+#define WiringPrivate_h
27
+
28
+#include <avr/io.h>
29
+#include <avr/interrupt.h>
30
+#include <avr/signal.h>
31
+#include <avr/delay.h>
32
+#include <stdio.h>
33
+#include <stdarg.h>
34
+
35
+#include "wiring.h"
36
+
37
+#ifdef __cplusplus
38
+extern "C"{
39
+#endif
40
+
41
+#ifndef cbi
42
+#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
43
+#endif
44
+#ifndef sbi
45
+#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
46
+#endif
47
+
48
+#define EXTERNAL_INT_0 0
49
+#define EXTERNAL_INT_1 1
50
+#define EXTERNAL_INT_2 2
51
+
52
+#define EXTERNAL_NUM_INTERRUPTS 3
53
+
54
+typedef void (*voidFuncPtr)(void);
55
+
56
+#ifdef __cplusplus
57
+} // extern "C"
58
+#endif
59
+
60
+#endif

+ 66
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_pulse.c Dosyayı Görüntüle

@@ -0,0 +1,66 @@
1
+/*
2
+  wiring_pulse.c - pulseIn() function
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
+*/
24
+
25
+#include "wiring_private.h"
26
+#include "pins_arduino.h"
27
+
28
+/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
29
+ * or LOW, the type of pulse to measure.  Works on pulses from 2-3 microseconds
30
+ * to 3 minutes in length, but must be called at least a few dozen microseconds
31
+ * before the start of the pulse. */
32
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
33
+{
34
+	// cache the port and bit of the pin in order to speed up the
35
+	// pulse width measuring loop and achieve finer resolution.  calling
36
+	// digitalRead() instead yields much coarser resolution.
37
+	uint8_t bit = digitalPinToBitMask(pin);
38
+	uint8_t port = digitalPinToPort(pin);
39
+	uint8_t stateMask = (state ? bit : 0);
40
+	unsigned long width = 0; // keep initialization out of time critical area
41
+	
42
+	// convert the timeout from microseconds to a number of times through
43
+	// the initial loop; it takes 16 clock cycles per iteration.
44
+	unsigned long numloops = 0;
45
+	unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
46
+	
47
+	// wait for any previous pulse to end
48
+	while ((*portInputRegister(port) & bit) == stateMask)
49
+		if (numloops++ == maxloops)
50
+			return 0;
51
+	
52
+	// wait for the pulse to start
53
+	while ((*portInputRegister(port) & bit) != stateMask)
54
+		if (numloops++ == maxloops)
55
+			return 0;
56
+	
57
+	// wait for the pulse to stop
58
+	while ((*portInputRegister(port) & bit) == stateMask)
59
+		width++;
60
+
61
+	// convert the reading to microseconds. The loop has been determined
62
+	// to be 10 clock cycles long and have about 16 clocks between the edge
63
+	// and the start of the loop. There will be some error introduced by
64
+	// the interrupt handlers.
65
+	return clockCyclesToMicroseconds(width * 10 + 16); 
66
+}

Marlin/wiring_serial.c → ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_serial.c Dosyayı Görüntüle

@@ -31,7 +31,6 @@
31 31
 // location to which to write the next incoming character and rx_buffer_tail
32 32
 // is the index of the location from which to read.
33 33
 #define RX_BUFFER_SIZE 128
34
-#define RX_BUFFER_MASK 0x7f
35 34
 
36 35
 #if defined(__AVR_ATmega644P__)
37 36
 unsigned char rx_buffer[2][RX_BUFFER_SIZE];
@@ -91,7 +90,7 @@ void serialWrite(uint8_t uart, unsigned char c)
91 90
 
92 91
 int serialAvailable(uint8_t uart)
93 92
 {
94
-  return (RX_BUFFER_SIZE + rx_buffer_head[uart] - rx_buffer_tail[uart]) & RX_BUFFER_MASK;
93
+  return (RX_BUFFER_SIZE + rx_buffer_head[uart] - rx_buffer_tail[uart]) % RX_BUFFER_SIZE;
95 94
 }
96 95
 
97 96
 int serialRead(uint8_t uart)
@@ -101,7 +100,7 @@ int serialRead(uint8_t uart)
101 100
     return -1;
102 101
   } else {
103 102
     unsigned char c = rx_buffer[uart][rx_buffer_tail[uart]];
104
-    rx_buffer_tail[uart] = (rx_buffer_tail[uart] + 1) & RX_BUFFER_MASK;
103
+    rx_buffer_tail[uart] = (rx_buffer_tail[uart] + 1) % RX_BUFFER_SIZE;
105 104
     return c;
106 105
   }
107 106
 }
@@ -121,7 +120,7 @@ ISR(USART##uart_##_RX_vect) \
121 120
 { \
122 121
   unsigned char c = UDR##uart_; \
123 122
   \
124
-  int i = (rx_buffer_head[uart_] + 1) & RX_BUFFER_MASK; \
123
+  int i = (rx_buffer_head[uart_] + 1) % RX_BUFFER_SIZE; \
125 124
   \  
126 125
   /* if we should be storing the received character into the location \
127 126
      just before the tail (meaning that the head would advance to the \

+ 40
- 0
ArduinoAddons/Arduino_0.xx/Gen7/cores/arduino/wiring_shift.c Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+/*
2
+  wiring_shift.c - shiftOut() function
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
+*/
24
+
25
+#include "wiring_private.h"
26
+
27
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)
28
+{
29
+	int i;
30
+
31
+	for (i = 0; i < 8; i++)  {
32
+		if (bitOrder == LSBFIRST)
33
+			digitalWrite(dataPin, !!(val & (1 << i)));
34
+		else	
35
+			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
36
+			
37
+		digitalWrite(clockPin, HIGH);
38
+		digitalWrite(clockPin, LOW);		
39
+	}
40
+}

+ 99
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/boards.txt Dosyayı Görüntüle

@@ -0,0 +1,99 @@
1
+##############################################################
2
+
3
+sanguino.name=Sanguino
4
+sanguino.upload.protocol=stk500
5
+sanguino.upload.maximum_size=63488
6
+sanguino.upload.speed=38400
7
+sanguino.bootloader.low_fuses=0xFF
8
+sanguino.bootloader.high_fuses=0xDC
9
+sanguino.bootloader.extended_fuses=0xFD
10
+sanguino.bootloader.path=atmega644p
11
+sanguino.bootloader.file=ATmegaBOOT_644P.hex
12
+sanguino.bootloader.unlock_bits=0x3F
13
+sanguino.bootloader.lock_bits=0x0F
14
+sanguino.build.mcu=atmega644p
15
+sanguino.build.f_cpu=16000000L
16
+sanguino.build.core=arduino
17
+
18
+##############################################################
19
+
20
+atmega644.name=Sanguino W/ ATmega644P
21
+
22
+atmega644.upload.protocol=stk500
23
+atmega644.upload.maximum_size=63488
24
+atmega644.upload.speed=57600
25
+
26
+atmega644.bootloader.low_fuses=0xFF
27
+atmega644.bootloader.high_fuses=0x9A
28
+atmega644.bootloader.extended_fuses=0xFF
29
+atmega644.bootloader.path=atmega
30
+atmega644.bootloader.file=ATmegaBOOT_168_atmega644p.hex
31
+#atmega644.bootloader.file=ATmegaBOOT_644P.hex
32
+atmega644.bootloader.unlock_bits=0x3F
33
+atmega644.bootloader.lock_bits=0x0F
34
+
35
+atmega644.build.mcu=atmega644p
36
+atmega644.build.f_cpu=16000000L
37
+atmega644.build.core=arduino
38
+
39
+##############################################################
40
+
41
+atmega12848m.name=Sanguino W/ ATmega1284p 8mhz
42
+
43
+atmega12848m.upload.protocol=stk500
44
+atmega12848m.upload.maximum_size=131072
45
+atmega12848m.upload.speed=19200
46
+
47
+atmega12848m.bootloader.low_fuses=0xD6
48
+atmega12848m.bootloader.high_fuses=0xDA
49
+atmega12848m.bootloader.extended_fuses=0xFD
50
+atmega12848m.bootloader.path=atmega
51
+atmega12848m.bootloader.file=ATmegaBOOT_168_atmega1284p_8m.hex
52
+atmega12848m.bootloader.unlock_bits=0x3F
53
+atmega12848m.bootloader.lock_bits=0x0F
54
+
55
+atmega12848m.build.mcu=atmega1284p
56
+atmega12848m.build.f_cpu=8000000L
57
+atmega12848m.build.core=arduino
58
+
59
+##############################################################
60
+
61
+atmega1284.name=Sanguino W/ ATmega1284p 16mhz
62
+
63
+atmega1284.upload.protocol=stk500
64
+atmega1284.upload.maximum_size=131072
65
+atmega1284.upload.speed=57600
66
+
67
+atmega1284.bootloader.low_fuses=0xD6
68
+atmega1284.bootloader.high_fuses=0xDA
69
+atmega1284.bootloader.extended_fuses=0xFD
70
+atmega1284.bootloader.path=atmega
71
+atmega1284.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
72
+atmega1284.bootloader.unlock_bits=0x3F
73
+atmega1284.bootloader.lock_bits=0x0F
74
+
75
+atmega1284.build.mcu=atmega1284p
76
+atmega1284.build.f_cpu=16000000L
77
+atmega1284.build.core=arduino
78
+
79
+
80
+##############################################################
81
+
82
+atmega1284s.name=Sanguino W/ ATmega1284p 20mhz
83
+
84
+atmega1284s.upload.protocol=stk500
85
+atmega1284s.upload.maximum_size=131072
86
+atmega1284s.upload.speed=57600
87
+
88
+atmega1284s.bootloader.low_fuses=0xD6
89
+atmega1284s.bootloader.high_fuses=0xDA
90
+atmega1284s.bootloader.extended_fuses=0xFD
91
+atmega1284s.bootloader.path=atmega
92
+atmega1284s.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
93
+atmega1284s.bootloader.unlock_bits=0x3F
94
+atmega1284s.bootloader.lock_bits=0x0F
95
+
96
+atmega1284s.build.mcu=atmega1284p
97
+atmega1284s.build.f_cpu=20000000L
98
+atmega1284s.build.core=arduino
99
+#

+ 470
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/Makefile Dosyayı Görüntüle

@@ -0,0 +1,470 @@
1
+# Makefile for ATmegaBOOT
2
+# E.Lins, 18.7.2005
3
+# $Id$
4
+#
5
+# Instructions
6
+#
7
+# To make bootloader .hex file:
8
+# make diecimila
9
+# make lilypad
10
+# make ng
11
+# etc...
12
+#
13
+# To burn bootloader .hex file:
14
+# make diecimila_isp
15
+# make lilypad_isp
16
+# make ng_isp
17
+# etc...
18
+
19
+# program name should not be changed...
20
+PROGRAM    = optiboot
21
+
22
+# The default behavior is to build using tools that are in the users
23
+# current path variables, but we can also build using an installed
24
+# Arduino user IDE setup, or the Arduino source tree.
25
+# Uncomment this next lines to build within the arduino environment,
26
+# using the arduino-included avrgcc toolset (mac and pc)
27
+# ENV ?= arduino
28
+# ENV ?= arduinodev
29
+# OS ?= macosx
30
+# OS ?= windows
31
+
32
+
33
+# enter the parameters for the avrdude isp tool
34
+ISPTOOL    = stk500v2
35
+ISPPORT    = usb
36
+ISPSPEED   = -b 115200
37
+
38
+MCU_TARGET = atmega168
39
+LDSECTIONS  = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
40
+
41
+# Build environments
42
+# Start of some ugly makefile-isms to allow optiboot to be built
43
+# in several different environments.  See the README.TXT file for
44
+# details.
45
+
46
+# default
47
+fixpath = $(1)
48
+
49
+ifeq ($(ENV), arduino)
50
+# For Arduino, we assume that we're connected to the optiboot directory
51
+# included with the arduino distribution, which means that the full set
52
+# of avr-tools are "right up there" in standard places.
53
+TOOLROOT = ../../../tools
54
+GCCROOT = $(TOOLROOT)/avr/bin/
55
+AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
56
+
57
+ifeq ($(OS), windows)
58
+# On windows, SOME of the tool paths will need to have backslashes instead
59
+# of forward slashes (because they use windows cmd.exe for execution instead
60
+# of a unix/mingw shell?)  We also have to ensure that a consistent shell
61
+# is used even if a unix shell is installed (ie as part of WINAVR)
62
+fixpath = $(subst /,\,$1)
63
+SHELL = cmd.exe
64
+endif
65
+
66
+else ifeq ($(ENV), arduinodev)
67
+# Arduino IDE source code environment.  Use the unpacked compilers created
68
+# by the build (you'll need to do "ant build" first.)
69
+ifeq ($(OS), macosx)
70
+TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
71
+endif
72
+ifeq ($(OS), windows)
73
+TOOLROOT = ../../../../build/windows/work/hardware/tools
74
+endif
75
+
76
+GCCROOT = $(TOOLROOT)/avr/bin/
77
+AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
78
+
79
+else
80
+GCCROOT =
81
+AVRDUDE_CONF =
82
+endif
83
+#
84
+# End of build environment code.
85
+
86
+
87
+# the efuse should really be 0xf8; since, however, only the lower
88
+# three bits of that byte are used on the atmega168, avrdude gets
89
+# confused if you specify 1's for the higher bits, see:
90
+# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
91
+#
92
+# similarly, the lock bits should be 0xff instead of 0x3f (to
93
+# unlock the bootloader section) and 0xcf instead of 0x2f (to
94
+# lock it), but since the high two bits of the lock byte are
95
+# unused, avrdude would get confused.
96
+
97
+ISPFUSES    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
98
+              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
99
+              -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
100
+              -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
101
+ISPFLASH    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
102
+              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
103
+              -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
104
+
105
+STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
106
+STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
107
+-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
108
+STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
109
+
110
+OBJ        = $(PROGRAM).o
111
+OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
112
+
113
+DEFS       = 
114
+LIBS       =
115
+
116
+CC         = $(GCCROOT)avr-gcc
117
+
118
+# Override is only needed by avr-lib build system.
119
+
120
+override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
121
+override LDFLAGS       = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
122
+
123
+OBJCOPY        = $(GCCROOT)avr-objcopy
124
+OBJDUMP        = $(call fixpath,$(GCCROOT)avr-objdump)
125
+
126
+SIZE           = $(GCCROOT)avr-size
127
+
128
+# Test platforms
129
+# Virtual boot block test
130
+virboot328: TARGET = atmega328
131
+virboot328: MCU_TARGET = atmega328p
132
+virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT'
133
+virboot328: AVR_FREQ = 16000000L
134
+virboot328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
135
+virboot328: $(PROGRAM)_atmega328.hex
136
+virboot328: $(PROGRAM)_atmega328.lst
137
+
138
+# 20MHz clocked platforms
139
+#
140
+# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
141
+#
142
+
143
+pro20: TARGET = pro_20mhz
144
+pro20: MCU_TARGET = atmega168
145
+pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
146
+pro20: AVR_FREQ = 20000000L
147
+pro20: $(PROGRAM)_pro_20mhz.hex
148
+pro20: $(PROGRAM)_pro_20mhz.lst
149
+
150
+pro20_isp: pro20
151
+pro20_isp: TARGET = pro_20mhz
152
+# 2.7V brownout
153
+pro20_isp: HFUSE = DD
154
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
155
+pro20_isp: LFUSE = C6
156
+# 512 byte boot
157
+pro20_isp: EFUSE = 04
158
+pro20_isp: isp
159
+
160
+# 16MHz clocked platforms
161
+#
162
+# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
163
+#
164
+
165
+pro16: TARGET = pro_16MHz
166
+pro16: MCU_TARGET = atmega168
167
+pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
168
+pro16: AVR_FREQ = 16000000L
169
+pro16: $(PROGRAM)_pro_16MHz.hex
170
+pro16: $(PROGRAM)_pro_16MHz.lst
171
+
172
+pro16_isp: pro16
173
+pro16_isp: TARGET = pro_16MHz
174
+# 2.7V brownout
175
+pro16_isp: HFUSE = DD
176
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
177
+pro16_isp: LFUSE = C6
178
+# 512 byte boot
179
+pro16_isp: EFUSE = 04
180
+pro16_isp: isp
181
+
182
+# Diecimila, Duemilanove with m168, and NG use identical bootloaders
183
+# Call it "atmega168" for generality and clarity, keep "diecimila" for
184
+# backward compatibility of makefile
185
+#
186
+atmega168: TARGET = atmega168
187
+atmega168: MCU_TARGET = atmega168
188
+atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
189
+atmega168: AVR_FREQ = 16000000L 
190
+atmega168: $(PROGRAM)_atmega168.hex
191
+atmega168: $(PROGRAM)_atmega168.lst
192
+
193
+atmega168_isp: atmega168
194
+atmega168_isp: TARGET = atmega168
195
+# 2.7V brownout
196
+atmega168_isp: HFUSE = DD
197
+# Low power xtal (16MHz) 16KCK/14CK+65ms
198
+atmega168_isp: LFUSE = FF
199
+# 512 byte boot
200
+atmega168_isp: EFUSE = 04
201
+atmega168_isp: isp
202
+
203
+diecimila: TARGET = diecimila
204
+diecimila: MCU_TARGET = atmega168
205
+diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
206
+diecimila: AVR_FREQ = 16000000L 
207
+diecimila: $(PROGRAM)_diecimila.hex
208
+diecimila: $(PROGRAM)_diecimila.lst
209
+
210
+diecimila_isp: diecimila
211
+diecimila_isp: TARGET = diecimila
212
+# 2.7V brownout
213
+diecimila_isp: HFUSE = DD
214
+# Low power xtal (16MHz) 16KCK/14CK+65ms
215
+diecimila_isp: LFUSE = FF
216
+# 512 byte boot
217
+diecimila_isp: EFUSE = 04
218
+diecimila_isp: isp
219
+
220
+atmega328: TARGET = atmega328
221
+atmega328: MCU_TARGET = atmega328p
222
+atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
223
+atmega328: AVR_FREQ = 16000000L
224
+atmega328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
225
+atmega328: $(PROGRAM)_atmega328.hex
226
+atmega328: $(PROGRAM)_atmega328.lst
227
+
228
+atmega328_isp: atmega328
229
+atmega328_isp: TARGET = atmega328
230
+atmega328_isp: MCU_TARGET = atmega328p
231
+# 512 byte boot, SPIEN
232
+atmega328_isp: HFUSE = DE
233
+# Low power xtal (16MHz) 16KCK/14CK+65ms
234
+atmega328_isp: LFUSE = FF
235
+# 2.7V brownout
236
+atmega328_isp: EFUSE = 05
237
+atmega328_isp: isp
238
+
239
+atmega1284: TARGET = atmega1284p
240
+atmega1284: MCU_TARGET = atmega1284p
241
+atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
242
+atmega1284: AVR_FREQ = 16000000L
243
+atmega1284: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
244
+atmega1284: $(PROGRAM)_atmega1284p.hex
245
+atmega1284: $(PROGRAM)_atmega1284p.lst
246
+
247
+atmega1284_isp: atmega1284
248
+atmega1284_isp: TARGET = atmega1284p
249
+atmega1284_isp: MCU_TARGET = atmega1284p
250
+# 1024 byte boot
251
+atmega1284_isp: HFUSE = DE
252
+# Low power xtal (16MHz) 16KCK/14CK+65ms
253
+atmega1284_isp: LFUSE = FF
254
+# 2.7V brownout
255
+atmega1284_isp: EFUSE = FD
256
+atmega1284_isp: isp
257
+
258
+# Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
259
+#
260
+sanguino: TARGET = atmega644p
261
+sanguino: MCU_TARGET = atmega644p
262
+sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
263
+sanguino: AVR_FREQ = 16000000L
264
+sanguino: LDSECTIONS  = -Wl,--section-start=.text=0xfc00
265
+sanguino: $(PROGRAM)_atmega644p.hex
266
+sanguino: $(PROGRAM)_atmega644p.lst
267
+
268
+sanguino_isp: sanguino
269
+sanguino_isp: TARGET = atmega644p
270
+sanguino_isp: MCU_TARGET = atmega644p
271
+# 1024 byte boot
272
+sanguino_isp: HFUSE = DE
273
+# Low power xtal (16MHz) 16KCK/14CK+65ms
274
+sanguino_isp: LFUSE = FF
275
+# 2.7V brownout
276
+sanguino_isp: EFUSE = 05
277
+sanguino_isp: isp
278
+
279
+# Mega has a minimum boot size of 1024 bytes, so enable extra functions
280
+#mega: TARGET = atmega1280
281
+mega: MCU_TARGET = atmega1280
282
+mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
283
+mega: AVR_FREQ = 16000000L
284
+mega: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
285
+mega: $(PROGRAM)_atmega1280.hex
286
+mega: $(PROGRAM)_atmega1280.lst
287
+
288
+mega_isp: mega
289
+mega_isp: TARGET = atmega1280
290
+mega_isp: MCU_TARGET = atmega1280
291
+# 1024 byte boot
292
+mega_isp: HFUSE = DE
293
+# Low power xtal (16MHz) 16KCK/14CK+65ms
294
+mega_isp: LFUSE = FF
295
+# 2.7V brownout
296
+mega_isp: EFUSE = 05
297
+mega_isp: isp
298
+
299
+# ATmega8
300
+#
301
+atmega8: TARGET = atmega8
302
+atmega8: MCU_TARGET = atmega8
303
+atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
304
+atmega8: AVR_FREQ = 16000000L 
305
+atmega8: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
306
+atmega8: $(PROGRAM)_atmega8.hex
307
+atmega8: $(PROGRAM)_atmega8.lst
308
+
309
+atmega8_isp: atmega8
310
+atmega8_isp: TARGET = atmega8
311
+atmega8_isp: MCU_TARGET = atmega8
312
+# SPIEN, CKOPT, Bootsize=512B
313
+atmega8_isp: HFUSE = CC
314
+# 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms
315
+atmega8_isp: LFUSE = BF
316
+atmega8_isp: isp
317
+
318
+# ATmega88
319
+#
320
+atmega88: TARGET = atmega88
321
+atmega88: MCU_TARGET = atmega88
322
+atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
323
+atmega88: AVR_FREQ = 16000000L 
324
+atmega88: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
325
+atmega88: $(PROGRAM)_atmega88.hex
326
+atmega88: $(PROGRAM)_atmega88.lst
327
+
328
+atmega88_isp: atmega88
329
+atmega88_isp: TARGET = atmega88
330
+atmega88_isp: MCU_TARGET = atmega88
331
+# 2.7V brownout
332
+atmega88_isp: HFUSE = DD
333
+# Low power xtal (16MHz) 16KCK/14CK+65ms
334
+atemga88_isp: LFUSE = FF
335
+# 512 byte boot
336
+atmega88_isp: EFUSE = 04
337
+atmega88_isp: isp
338
+
339
+
340
+# 8MHz clocked platforms
341
+#
342
+# These are capable of 115200 baud
343
+#
344
+
345
+lilypad: TARGET = lilypad
346
+lilypad: MCU_TARGET = atmega168
347
+lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
348
+lilypad: AVR_FREQ = 8000000L
349
+lilypad: $(PROGRAM)_lilypad.hex
350
+lilypad: $(PROGRAM)_lilypad.lst
351
+
352
+lilypad_isp: lilypad
353
+lilypad_isp: TARGET = lilypad
354
+# 2.7V brownout
355
+lilypad_isp: HFUSE = DD
356
+# Internal 8MHz osc (8MHz) Slow rising power
357
+lilypad_isp: LFUSE = E2
358
+# 512 byte boot
359
+lilypad_isp: EFUSE = 04
360
+lilypad_isp: isp
361
+
362
+lilypad_resonator: TARGET = lilypad_resonator
363
+lilypad_resonator: MCU_TARGET = atmega168
364
+lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
365
+lilypad_resonator: AVR_FREQ = 8000000L
366
+lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
367
+lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
368
+
369
+lilypad_resonator_isp: lilypad_resonator
370
+lilypad_resonator_isp: TARGET = lilypad_resonator
371
+# 2.7V brownout
372
+lilypad_resonator_isp: HFUSE = DD
373
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
374
+lilypad_resonator_isp: LFUSE = C6
375
+# 512 byte boot
376
+lilypad_resonator_isp: EFUSE = 04
377
+lilypad_resonator_isp: isp
378
+
379
+pro8: TARGET = pro_8MHz
380
+pro8: MCU_TARGET = atmega168
381
+pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
382
+pro8: AVR_FREQ = 8000000L
383
+pro8: $(PROGRAM)_pro_8MHz.hex
384
+pro8: $(PROGRAM)_pro_8MHz.lst
385
+
386
+pro8_isp: pro8
387
+pro8_isp: TARGET = pro_8MHz
388
+# 2.7V brownout
389
+pro8_isp: HFUSE = DD
390
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
391
+pro8_isp: LFUSE = C6
392
+# 512 byte boot
393
+pro8_isp: EFUSE = 04
394
+pro8_isp: isp
395
+
396
+atmega328_pro8: TARGET = atmega328_pro_8MHz
397
+atmega328_pro8: MCU_TARGET = atmega328p
398
+atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
399
+atmega328_pro8: AVR_FREQ = 8000000L
400
+atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
401
+atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
402
+atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
403
+
404
+atmega328_pro8_isp: atmega328_pro8
405
+atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
406
+atmega328_pro8_isp: MCU_TARGET = atmega328p
407
+# 512 byte boot, SPIEN
408
+atmega328_pro8_isp: HFUSE = DE
409
+# Low power xtal (16MHz) 16KCK/14CK+65ms
410
+atmega328_pro8_isp: LFUSE = FF
411
+# 2.7V brownout
412
+atmega328_pro8_isp: EFUSE = 05
413
+atmega328_pro8_isp: isp
414
+
415
+# 1MHz clocked platforms
416
+#
417
+# These are capable of 9600 baud
418
+#
419
+
420
+luminet: TARGET = luminet
421
+luminet: MCU_TARGET = attiny84
422
+luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
423
+luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
424
+luminet: AVR_FREQ = 1000000L
425
+luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
426
+luminet: $(PROGRAM)_luminet.hex
427
+luminet: $(PROGRAM)_luminet.lst
428
+
429
+luminet_isp: luminet
430
+luminet_isp: TARGET = luminet
431
+luminet_isp: MCU_TARGET = attiny84
432
+# Brownout disabled
433
+luminet_isp: HFUSE = DF
434
+# 1MHz internal oscillator, slowly rising power
435
+luminet_isp: LFUSE = 62
436
+# Self-programming enable
437
+luminet_isp: EFUSE = FE
438
+luminet_isp: isp
439
+
440
+#
441
+# Generic build instructions
442
+#
443
+#
444
+
445
+isp: $(TARGET)
446
+        $(ISPFUSES)
447
+        $(ISPFLASH)
448
+
449
+isp-stk500: $(PROGRAM)_$(TARGET).hex
450
+        $(STK500-1)
451
+        $(STK500-2)
452
+
453
+%.elf: $(OBJ)
454
+        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
455
+        $(SIZE) $@
456
+
457
+clean:
458
+        rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
459
+
460
+%.lst: %.elf
461
+        $(OBJDUMP) -h -S $< > $@
462
+
463
+%.hex: %.elf
464
+        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
465
+
466
+%.srec: %.elf
467
+        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
468
+
469
+%.bin: %.elf
470
+        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@

+ 848
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/boot.h Dosyayı Görüntüle

@@ -0,0 +1,848 @@
1
+/* Modified to use out for SPM access
2
+** Peter Knight, Optiboot project http://optiboot.googlecode.com
3
+**
4
+** Todo: Tidy up
5
+**
6
+** "_short" routines execute 1 cycle faster and use 1 less word of flash
7
+** by using "out" instruction instead of "sts".
8
+**
9
+** Additional elpm variants that trust the value of RAMPZ
10
+*/
11
+
12
+/* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007  Eric B. Weddington
13
+   All rights reserved.
14
+
15
+   Redistribution and use in source and binary forms, with or without
16
+   modification, are permitted provided that the following conditions are met:
17
+
18
+   * Redistributions of source code must retain the above copyright
19
+     notice, this list of conditions and the following disclaimer.
20
+   * Redistributions in binary form must reproduce the above copyright
21
+     notice, this list of conditions and the following disclaimer in
22
+     the documentation and/or other materials provided with the
23
+     distribution.
24
+   * Neither the name of the copyright holders nor the names of
25
+     contributors may be used to endorse or promote products derived
26
+     from this software without specific prior written permission.
27
+
28
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
+  POSSIBILITY OF SUCH DAMAGE. */
39
+
40
+/* $Id: boot.h,v 1.27.2.3 2008/09/30 13:58:48 arcanum Exp $ */
41
+
42
+#ifndef _AVR_BOOT_H_
43
+#define _AVR_BOOT_H_    1
44
+
45
+/** \file */
46
+/** \defgroup avr_boot <avr/boot.h>: Bootloader Support Utilities
47
+    \code
48
+    #include <avr/io.h>
49
+    #include <avr/boot.h>
50
+    \endcode
51
+
52
+    The macros in this module provide a C language interface to the
53
+    bootloader support functionality of certain AVR processors. These
54
+    macros are designed to work with all sizes of flash memory.
55
+
56
+    Global interrupts are not automatically disabled for these macros. It
57
+    is left up to the programmer to do this. See the code example below. 
58
+    Also see the processor datasheet for caveats on having global interrupts 
59
+    enabled during writing of the Flash.
60
+
61
+    \note Not all AVR processors provide bootloader support. See your
62
+    processor datasheet to see if it provides bootloader support.
63
+
64
+    \todo From email with Marek: On smaller devices (all except ATmega64/128),
65
+    __SPM_REG is in the I/O space, accessible with the shorter "in" and "out"
66
+    instructions - since the boot loader has a limited size, this could be an
67
+    important optimization.
68
+
69
+    \par API Usage Example
70
+    The following code shows typical usage of the boot API.
71
+
72
+    \code
73
+    #include <inttypes.h>
74
+    #include <avr/interrupt.h>
75
+    #include <avr/pgmspace.h>
76
+    
77
+    void boot_program_page (uint32_t page, uint8_t *buf)
78
+    {
79
+        uint16_t i;
80
+        uint8_t sreg;
81
+
82
+        // Disable interrupts.
83
+
84
+        sreg = SREG;
85
+        cli();
86
+    
87
+        eeprom_busy_wait ();
88
+
89
+        boot_page_erase (page);
90
+        boot_spm_busy_wait ();      // Wait until the memory is erased.
91
+
92
+        for (i=0; i<SPM_PAGESIZE; i+=2)
93
+        {
94
+            // Set up little-endian word.
95
+
96
+            uint16_t w = *buf++;
97
+            w += (*buf++) << 8;
98
+        
99
+            boot_page_fill (page + i, w);
100
+        }
101
+
102
+        boot_page_write (page);     // Store buffer in flash page.
103
+        boot_spm_busy_wait();       // Wait until the memory is written.
104
+
105
+        // Reenable RWW-section again. We need this if we want to jump back
106
+        // to the application after bootloading.
107
+
108
+        boot_rww_enable ();
109
+
110
+        // Re-enable interrupts (if they were ever enabled).
111
+
112
+        SREG = sreg;
113
+    }\endcode */
114
+
115
+#include <avr/eeprom.h>
116
+#include <avr/io.h>
117
+#include <inttypes.h>
118
+#include <limits.h>
119
+
120
+/* Check for SPM Control Register in processor. */
121
+#if defined (SPMCSR)
122
+#  define __SPM_REG    SPMCSR
123
+#elif defined (SPMCR)
124
+#  define __SPM_REG    SPMCR
125
+#else
126
+#  error AVR processor does not provide bootloader support!
127
+#endif
128
+
129
+
130
+/* Check for SPM Enable bit. */
131
+#if defined(SPMEN)
132
+#  define __SPM_ENABLE  SPMEN
133
+#elif defined(SELFPRGEN)
134
+#  define __SPM_ENABLE  SELFPRGEN
135
+#else
136
+#  error Cannot find SPM Enable bit definition!
137
+#endif
138
+
139
+/** \ingroup avr_boot
140
+    \def BOOTLOADER_SECTION
141
+
142
+    Used to declare a function or variable to be placed into a
143
+    new section called .bootloader. This section and its contents
144
+    can then be relocated to any address (such as the bootloader
145
+    NRWW area) at link-time. */
146
+
147
+#define BOOTLOADER_SECTION    __attribute__ ((section (".bootloader")))
148
+
149
+/* Create common bit definitions. */
150
+#ifdef ASB
151
+#define __COMMON_ASB    ASB
152
+#else
153
+#define __COMMON_ASB    RWWSB
154
+#endif
155
+
156
+#ifdef ASRE
157
+#define __COMMON_ASRE   ASRE
158
+#else
159
+#define __COMMON_ASRE   RWWSRE
160
+#endif
161
+
162
+/* Define the bit positions of the Boot Lock Bits. */
163
+
164
+#define BLB12           5
165
+#define BLB11           4
166
+#define BLB02           3
167
+#define BLB01           2
168
+
169
+/** \ingroup avr_boot
170
+    \def boot_spm_interrupt_enable()
171
+    Enable the SPM interrupt. */
172
+
173
+#define boot_spm_interrupt_enable()   (__SPM_REG |= (uint8_t)_BV(SPMIE))
174
+
175
+/** \ingroup avr_boot
176
+    \def boot_spm_interrupt_disable()
177
+    Disable the SPM interrupt. */
178
+
179
+#define boot_spm_interrupt_disable()  (__SPM_REG &= (uint8_t)~_BV(SPMIE))
180
+
181
+/** \ingroup avr_boot
182
+    \def boot_is_spm_interrupt()
183
+    Check if the SPM interrupt is enabled. */
184
+
185
+#define boot_is_spm_interrupt()       (__SPM_REG & (uint8_t)_BV(SPMIE))
186
+
187
+/** \ingroup avr_boot
188
+    \def boot_rww_busy()
189
+    Check if the RWW section is busy. */
190
+
191
+#define boot_rww_busy()          (__SPM_REG & (uint8_t)_BV(__COMMON_ASB))
192
+
193
+/** \ingroup avr_boot
194
+    \def boot_spm_busy()
195
+    Check if the SPM instruction is busy. */
196
+
197
+#define boot_spm_busy()               (__SPM_REG & (uint8_t)_BV(__SPM_ENABLE))
198
+
199
+/** \ingroup avr_boot
200
+    \def boot_spm_busy_wait()
201
+    Wait while the SPM instruction is busy. */
202
+
203
+#define boot_spm_busy_wait()          do{}while(boot_spm_busy())
204
+
205
+#define __BOOT_PAGE_ERASE         (_BV(__SPM_ENABLE) | _BV(PGERS))
206
+#define __BOOT_PAGE_WRITE         (_BV(__SPM_ENABLE) | _BV(PGWRT))
207
+#define __BOOT_PAGE_FILL          _BV(__SPM_ENABLE)
208
+#define __BOOT_RWW_ENABLE         (_BV(__SPM_ENABLE) | _BV(__COMMON_ASRE))
209
+#define __BOOT_LOCK_BITS_SET      (_BV(__SPM_ENABLE) | _BV(BLBSET))
210
+
211
+#define __boot_page_fill_short(address, data)   \
212
+(__extension__({                                 \
213
+    __asm__ __volatile__                         \
214
+    (                                            \
215
+        "movw  r0, %3\n\t"                       \
216
+        "out %0, %1\n\t"                         \
217
+        "spm\n\t"                                \
218
+        "clr  r1\n\t"                            \
219
+        :                                        \
220
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
221
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
222
+          "z" ((uint16_t)address),               \
223
+          "r" ((uint16_t)data)                   \
224
+        : "r0"                                   \
225
+    );                                           \
226
+}))
227
+
228
+#define __boot_page_fill_normal(address, data)   \
229
+(__extension__({                                 \
230
+    __asm__ __volatile__                         \
231
+    (                                            \
232
+        "movw  r0, %3\n\t"                       \
233
+        "sts %0, %1\n\t"                         \
234
+        "spm\n\t"                                \
235
+        "clr  r1\n\t"                            \
236
+        :                                        \
237
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
238
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
239
+          "z" ((uint16_t)address),               \
240
+          "r" ((uint16_t)data)                   \
241
+        : "r0"                                   \
242
+    );                                           \
243
+}))
244
+
245
+#define __boot_page_fill_alternate(address, data)\
246
+(__extension__({                                 \
247
+    __asm__ __volatile__                         \
248
+    (                                            \
249
+        "movw  r0, %3\n\t"                       \
250
+        "sts %0, %1\n\t"                         \
251
+        "spm\n\t"                                \
252
+        ".word 0xffff\n\t"                       \
253
+        "nop\n\t"                                \
254
+        "clr  r1\n\t"                            \
255
+        :                                        \
256
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
257
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
258
+          "z" ((uint16_t)address),               \
259
+          "r" ((uint16_t)data)                   \
260
+        : "r0"                                   \
261
+    );                                           \
262
+}))
263
+
264
+#define __boot_page_fill_extended(address, data) \
265
+(__extension__({                                 \
266
+    __asm__ __volatile__                         \
267
+    (                                            \
268
+        "movw  r0, %4\n\t"                       \
269
+        "movw r30, %A3\n\t"                      \
270
+        "sts %1, %C3\n\t"                        \
271
+        "sts %0, %2\n\t"                         \
272
+        "spm\n\t"                                \
273
+        "clr  r1\n\t"                            \
274
+        :                                        \
275
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
276
+          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
277
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
278
+          "r" ((uint32_t)address),               \
279
+          "r" ((uint16_t)data)                   \
280
+        : "r0", "r30", "r31"                     \
281
+    );                                           \
282
+}))
283
+
284
+#define __boot_page_fill_extended_short(address, data) \
285
+(__extension__({                                 \
286
+    __asm__ __volatile__                         \
287
+    (                                            \
288
+        "movw  r0, %4\n\t"                       \
289
+        "movw r30, %A3\n\t"                      \
290
+        "out %1, %C3\n\t"                        \
291
+        "out %0, %2\n\t"                         \
292
+        "spm\n\t"                                \
293
+        "clr  r1\n\t"                            \
294
+        :                                        \
295
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
296
+          "i" (_SFR_IO_ADDR(RAMPZ)),            \
297
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
298
+          "r" ((uint32_t)address),               \
299
+          "r" ((uint16_t)data)                   \
300
+        : "r0", "r30", "r31"                     \
301
+    );                                           \
302
+}))
303
+
304
+#define __boot_page_erase_short(address)        \
305
+(__extension__({                                 \
306
+    __asm__ __volatile__                         \
307
+    (                                            \
308
+        "out %0, %1\n\t"                         \
309
+        "spm\n\t"                                \
310
+        :                                        \
311
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
312
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
313
+          "z" ((uint16_t)address)                \
314
+    );                                           \
315
+}))
316
+
317
+
318
+#define __boot_page_erase_normal(address)        \
319
+(__extension__({                                 \
320
+    __asm__ __volatile__                         \
321
+    (                                            \
322
+        "sts %0, %1\n\t"                         \
323
+        "spm\n\t"                                \
324
+        :                                        \
325
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
326
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
327
+          "z" ((uint16_t)address)                \
328
+    );                                           \
329
+}))
330
+
331
+#define __boot_page_erase_alternate(address)     \
332
+(__extension__({                                 \
333
+    __asm__ __volatile__                         \
334
+    (                                            \
335
+        "sts %0, %1\n\t"                         \
336
+        "spm\n\t"                                \
337
+        ".word 0xffff\n\t"                       \
338
+        "nop\n\t"                                \
339
+        :                                        \
340
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
341
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
342
+          "z" ((uint16_t)address)                \
343
+    );                                           \
344
+}))
345
+
346
+#define __boot_page_erase_extended(address)      \
347
+(__extension__({                                 \
348
+    __asm__ __volatile__                         \
349
+    (                                            \
350
+        "movw r30, %A3\n\t"                      \
351
+        "sts  %1, %C3\n\t"                       \
352
+        "sts %0, %2\n\t"                         \
353
+        "spm\n\t"                                \
354
+        :                                        \
355
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
356
+          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
357
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
358
+          "r" ((uint32_t)address)                \
359
+        : "r30", "r31"                           \
360
+    );                                           \
361
+}))
362
+#define __boot_page_erase_extended_short(address)      \
363
+(__extension__({                                 \
364
+    __asm__ __volatile__                         \
365
+    (                                            \
366
+        "movw r30, %A3\n\t"                      \
367
+        "out  %1, %C3\n\t"                       \
368
+        "out %0, %2\n\t"                         \
369
+        "spm\n\t"                                \
370
+        :                                        \
371
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
372
+          "i" (_SFR_IO_ADDR(RAMPZ)),            \
373
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
374
+          "r" ((uint32_t)address)                \
375
+        : "r30", "r31"                           \
376
+    );                                           \
377
+}))
378
+
379
+#define __boot_page_write_short(address)        \
380
+(__extension__({                                 \
381
+    __asm__ __volatile__                         \
382
+    (                                            \
383
+        "out %0, %1\n\t"                         \
384
+        "spm\n\t"                                \
385
+        :                                        \
386
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
387
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
388
+          "z" ((uint16_t)address)                \
389
+    );                                           \
390
+}))
391
+
392
+#define __boot_page_write_normal(address)        \
393
+(__extension__({                                 \
394
+    __asm__ __volatile__                         \
395
+    (                                            \
396
+        "sts %0, %1\n\t"                         \
397
+        "spm\n\t"                                \
398
+        :                                        \
399
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
400
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
401
+          "z" ((uint16_t)address)                \
402
+    );                                           \
403
+}))
404
+
405
+#define __boot_page_write_alternate(address)     \
406
+(__extension__({                                 \
407
+    __asm__ __volatile__                         \
408
+    (                                            \
409
+        "sts %0, %1\n\t"                         \
410
+        "spm\n\t"                                \
411
+        ".word 0xffff\n\t"                       \
412
+        "nop\n\t"                                \
413
+        :                                        \
414
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
415
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
416
+          "z" ((uint16_t)address)                \
417
+    );                                           \
418
+}))
419
+
420
+#define __boot_page_write_extended(address)      \
421
+(__extension__({                                 \
422
+    __asm__ __volatile__                         \
423
+    (                                            \
424
+        "movw r30, %A3\n\t"                      \
425
+        "sts %1, %C3\n\t"                        \
426
+        "sts %0, %2\n\t"                         \
427
+        "spm\n\t"                                \
428
+        :                                        \
429
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
430
+          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
431
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
432
+          "r" ((uint32_t)address)                \
433
+        : "r30", "r31"                           \
434
+    );                                           \
435
+}))
436
+#define __boot_page_write_extended_short(address)      \
437
+(__extension__({                                 \
438
+    __asm__ __volatile__                         \
439
+    (                                            \
440
+        "movw r30, %A3\n\t"                      \
441
+        "out %1, %C3\n\t"                        \
442
+        "out %0, %2\n\t"                         \
443
+        "spm\n\t"                                \
444
+        :                                        \
445
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
446
+          "i" (_SFR_IO_ADDR(RAMPZ)),            \
447
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
448
+          "r" ((uint32_t)address)                \
449
+        : "r30", "r31"                           \
450
+    );                                           \
451
+}))
452
+
453
+#define __boot_rww_enable_short()                      \
454
+(__extension__({                                 \
455
+    __asm__ __volatile__                         \
456
+    (                                            \
457
+        "out %0, %1\n\t"                         \
458
+        "spm\n\t"                                \
459
+        :                                        \
460
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
461
+          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
462
+    );                                           \
463
+}))
464
+
465
+#define __boot_rww_enable()                      \
466
+(__extension__({                                 \
467
+    __asm__ __volatile__                         \
468
+    (                                            \
469
+        "sts %0, %1\n\t"                         \
470
+        "spm\n\t"                                \
471
+        :                                        \
472
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
473
+          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
474
+    );                                           \
475
+}))
476
+
477
+#define __boot_rww_enable_alternate()            \
478
+(__extension__({                                 \
479
+    __asm__ __volatile__                         \
480
+    (                                            \
481
+        "sts %0, %1\n\t"                         \
482
+        "spm\n\t"                                \
483
+        ".word 0xffff\n\t"                       \
484
+        "nop\n\t"                                \
485
+        :                                        \
486
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
487
+          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
488
+    );                                           \
489
+}))
490
+
491
+/* From the mega16/mega128 data sheets (maybe others):
492
+
493
+     Bits by SPM To set the Boot Loader Lock bits, write the desired data to
494
+     R0, write "X0001001" to SPMCR and execute SPM within four clock cycles
495
+     after writing SPMCR. The only accessible Lock bits are the Boot Lock bits
496
+     that may prevent the Application and Boot Loader section from any
497
+     software update by the MCU.
498
+
499
+     If bits 5..2 in R0 are cleared (zero), the corresponding Boot Lock bit
500
+     will be programmed if an SPM instruction is executed within four cycles
501
+     after BLBSET and SPMEN (or SELFPRGEN) are set in SPMCR. The Z-pointer is 
502
+     don't care during this operation, but for future compatibility it is 
503
+     recommended to load the Z-pointer with $0001 (same as used for reading the 
504
+     Lock bits). For future compatibility It is also recommended to set bits 7, 
505
+     6, 1, and 0 in R0 to 1 when writing the Lock bits. When programming the 
506
+     Lock bits the entire Flash can be read during the operation. */
507
+
508
+#define __boot_lock_bits_set_short(lock_bits)                    \
509
+(__extension__({                                           \
510
+    uint8_t value = (uint8_t)(~(lock_bits));               \
511
+    __asm__ __volatile__                                   \
512
+    (                                                      \
513
+        "ldi r30, 1\n\t"                                   \
514
+        "ldi r31, 0\n\t"                                   \
515
+        "mov r0, %2\n\t"                                   \
516
+        "out %0, %1\n\t"                                   \
517
+        "spm\n\t"                                          \
518
+        :                                                  \
519
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),                  \
520
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
521
+          "r" (value)                                      \
522
+        : "r0", "r30", "r31"                               \
523
+    );                                                     \
524
+}))
525
+
526
+#define __boot_lock_bits_set(lock_bits)                    \
527
+(__extension__({                                           \
528
+    uint8_t value = (uint8_t)(~(lock_bits));               \
529
+    __asm__ __volatile__                                   \
530
+    (                                                      \
531
+        "ldi r30, 1\n\t"                                   \
532
+        "ldi r31, 0\n\t"                                   \
533
+        "mov r0, %2\n\t"                                   \
534
+        "sts %0, %1\n\t"                                   \
535
+        "spm\n\t"                                          \
536
+        :                                                  \
537
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
538
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
539
+          "r" (value)                                      \
540
+        : "r0", "r30", "r31"                               \
541
+    );                                                     \
542
+}))
543
+
544
+#define __boot_lock_bits_set_alternate(lock_bits)          \
545
+(__extension__({                                           \
546
+    uint8_t value = (uint8_t)(~(lock_bits));               \
547
+    __asm__ __volatile__                                   \
548
+    (                                                      \
549
+        "ldi r30, 1\n\t"                                   \
550
+        "ldi r31, 0\n\t"                                   \
551
+        "mov r0, %2\n\t"                                   \
552
+        "sts %0, %1\n\t"                                   \
553
+        "spm\n\t"                                          \
554
+        ".word 0xffff\n\t"                                 \
555
+        "nop\n\t"                                          \
556
+        :                                                  \
557
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
558
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
559
+          "r" (value)                                      \
560
+        : "r0", "r30", "r31"                               \
561
+    );                                                     \
562
+}))
563
+
564
+/*
565
+   Reading lock and fuse bits:
566
+
567
+     Similarly to writing the lock bits above, set BLBSET and SPMEN (or 
568
+     SELFPRGEN) bits in __SPMREG, and then (within four clock cycles) issue an 
569
+     LPM instruction.
570
+
571
+     Z address:       contents:
572
+     0x0000           low fuse bits
573
+     0x0001           lock bits
574
+     0x0002           extended fuse bits
575
+     0x0003           high fuse bits
576
+
577
+     Sounds confusing, doesn't it?
578
+
579
+     Unlike the macros in pgmspace.h, no need to care for non-enhanced
580
+     cores here as these old cores do not provide SPM support anyway.
581
+ */
582
+
583
+/** \ingroup avr_boot
584
+    \def GET_LOW_FUSE_BITS
585
+    address to read the low fuse bits, using boot_lock_fuse_bits_get
586
+ */
587
+#define GET_LOW_FUSE_BITS           (0x0000)
588
+/** \ingroup avr_boot
589
+    \def GET_LOCK_BITS
590
+    address to read the lock bits, using boot_lock_fuse_bits_get
591
+ */
592
+#define GET_LOCK_BITS               (0x0001)
593
+/** \ingroup avr_boot
594
+    \def GET_EXTENDED_FUSE_BITS
595
+    address to read the extended fuse bits, using boot_lock_fuse_bits_get
596
+ */
597
+#define GET_EXTENDED_FUSE_BITS      (0x0002)
598
+/** \ingroup avr_boot
599
+    \def GET_HIGH_FUSE_BITS
600
+    address to read the high fuse bits, using boot_lock_fuse_bits_get
601
+ */
602
+#define GET_HIGH_FUSE_BITS          (0x0003)
603
+
604
+/** \ingroup avr_boot
605
+    \def boot_lock_fuse_bits_get(address)
606
+
607
+    Read the lock or fuse bits at \c address.
608
+
609
+    Parameter \c address can be any of GET_LOW_FUSE_BITS,
610
+    GET_LOCK_BITS, GET_EXTENDED_FUSE_BITS, or GET_HIGH_FUSE_BITS.
611
+
612
+    \note The lock and fuse bits returned are the physical values,
613
+    i.e. a bit returned as 0 means the corresponding fuse or lock bit
614
+    is programmed.
615
+ */
616
+#define boot_lock_fuse_bits_get_short(address)                   \
617
+(__extension__({                                           \
618
+    uint8_t __result;                                      \
619
+    __asm__ __volatile__                                   \
620
+    (                                                      \
621
+        "ldi r30, %3\n\t"                                  \
622
+        "ldi r31, 0\n\t"                                   \
623
+        "out %1, %2\n\t"                                   \
624
+        "lpm %0, Z\n\t"                                    \
625
+        : "=r" (__result)                                  \
626
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),                  \
627
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
628
+          "M" (address)                                    \
629
+        : "r0", "r30", "r31"                               \
630
+    );                                                     \
631
+    __result;                                              \
632
+}))
633
+
634
+#define boot_lock_fuse_bits_get(address)                   \
635
+(__extension__({                                           \
636
+    uint8_t __result;                                      \
637
+    __asm__ __volatile__                                   \
638
+    (                                                      \
639
+        "ldi r30, %3\n\t"                                  \
640
+        "ldi r31, 0\n\t"                                   \
641
+        "sts %1, %2\n\t"                                   \
642
+        "lpm %0, Z\n\t"                                    \
643
+        : "=r" (__result)                                  \
644
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
645
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
646
+          "M" (address)                                    \
647
+        : "r0", "r30", "r31"                               \
648
+    );                                                     \
649
+    __result;                                              \
650
+}))
651
+
652
+/** \ingroup avr_boot
653
+    \def boot_signature_byte_get(address)
654
+
655
+    Read the Signature Row byte at \c address.  For some MCU types,
656
+    this function can also retrieve the factory-stored oscillator
657
+    calibration bytes.
658
+
659
+    Parameter \c address can be 0-0x1f as documented by the datasheet.
660
+    \note The values are MCU type dependent.
661
+*/
662
+
663
+#define __BOOT_SIGROW_READ (_BV(__SPM_ENABLE) | _BV(SIGRD))
664
+
665
+#define boot_signature_byte_get_short(addr) \
666
+(__extension__({                      \
667
+      uint16_t __addr16 = (uint16_t)(addr);     \
668
+      uint8_t __result;                         \
669
+      __asm__ __volatile__                      \
670
+      (                                         \
671
+        "out %1, %2\n\t"                        \
672
+        "lpm %0, Z" "\n\t"                      \
673
+        : "=r" (__result)                       \
674
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
675
+          "r" ((uint8_t) __BOOT_SIGROW_READ),   \
676
+          "z" (__addr16)                        \
677
+      );                                        \
678
+      __result;                                 \
679
+}))
680
+
681
+#define boot_signature_byte_get(addr) \
682
+(__extension__({                      \
683
+      uint16_t __addr16 = (uint16_t)(addr);     \
684
+      uint8_t __result;                         \
685
+      __asm__ __volatile__                      \
686
+      (                                         \
687
+        "sts %1, %2\n\t"                        \
688
+        "lpm %0, Z" "\n\t"                      \
689
+        : "=r" (__result)                       \
690
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),       \
691
+          "r" ((uint8_t) __BOOT_SIGROW_READ),   \
692
+          "z" (__addr16)                        \
693
+      );                                        \
694
+      __result;                                 \
695
+}))
696
+
697
+/** \ingroup avr_boot
698
+    \def boot_page_fill(address, data)
699
+
700
+    Fill the bootloader temporary page buffer for flash 
701
+    address with data word. 
702
+
703
+    \note The address is a byte address. The data is a word. The AVR 
704
+    writes data to the buffer a word at a time, but addresses the buffer
705
+    per byte! So, increment your address by 2 between calls, and send 2
706
+    data bytes in a word format! The LSB of the data is written to the lower 
707
+    address; the MSB of the data is written to the higher address.*/
708
+
709
+/** \ingroup avr_boot
710
+    \def boot_page_erase(address)
711
+
712
+    Erase the flash page that contains address.
713
+
714
+    \note address is a byte address in flash, not a word address. */
715
+
716
+/** \ingroup avr_boot
717
+    \def boot_page_write(address)
718
+
719
+    Write the bootloader temporary page buffer 
720
+    to flash page that contains address.
721
+    
722
+    \note address is a byte address in flash, not a word address. */
723
+
724
+/** \ingroup avr_boot
725
+    \def boot_rww_enable()
726
+
727
+    Enable the Read-While-Write memory section. */
728
+
729
+/** \ingroup avr_boot
730
+    \def boot_lock_bits_set(lock_bits)
731
+
732
+    Set the bootloader lock bits.
733
+
734
+    \param lock_bits A mask of which Boot Loader Lock Bits to set.
735
+
736
+    \note In this context, a 'set bit' will be written to a zero value.
737
+    Note also that only BLBxx bits can be programmed by this command.
738
+
739
+    For example, to disallow the SPM instruction from writing to the Boot
740
+    Loader memory section of flash, you would use this macro as such:
741
+
742
+    \code
743
+    boot_lock_bits_set (_BV (BLB11));
744
+    \endcode
745
+
746
+    \note Like any lock bits, the Boot Loader Lock Bits, once set,
747
+    cannot be cleared again except by a chip erase which will in turn
748
+    also erase the boot loader itself. */
749
+
750
+/* Normal versions of the macros use 16-bit addresses.
751
+   Extended versions of the macros use 32-bit addresses.
752
+   Alternate versions of the macros use 16-bit addresses and require special
753
+   instruction sequences after LPM.
754
+
755
+   FLASHEND is defined in the ioXXXX.h file.
756
+   USHRT_MAX is defined in <limits.h>. */ 
757
+
758
+#if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \
759
+    || defined(__AVR_ATmega323__)
760
+
761
+/* Alternate: ATmega161/163/323 and 16 bit address */
762
+#define boot_page_fill(address, data) __boot_page_fill_alternate(address, data)
763
+#define boot_page_erase(address)      __boot_page_erase_alternate(address)
764
+#define boot_page_write(address)      __boot_page_write_alternate(address)
765
+#define boot_rww_enable()             __boot_rww_enable_alternate()
766
+#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits)
767
+
768
+#elif (FLASHEND > USHRT_MAX)
769
+
770
+/* Extended: >16 bit address */
771
+#define boot_page_fill(address, data) __boot_page_fill_extended_short(address, data)
772
+#define boot_page_erase(address)      __boot_page_erase_extended_short(address)
773
+#define boot_page_write(address)      __boot_page_write_extended_short(address)
774
+#define boot_rww_enable()             __boot_rww_enable_short()
775
+#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits)
776
+
777
+#else
778
+
779
+/* Normal: 16 bit address */
780
+#define boot_page_fill(address, data) __boot_page_fill_short(address, data)
781
+#define boot_page_erase(address)      __boot_page_erase_short(address)
782
+#define boot_page_write(address)      __boot_page_write_short(address)
783
+#define boot_rww_enable()             __boot_rww_enable_short()
784
+#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits)
785
+
786
+#endif
787
+
788
+/** \ingroup avr_boot
789
+
790
+    Same as boot_page_fill() except it waits for eeprom and spm operations to
791
+    complete before filling the page. */
792
+
793
+#define boot_page_fill_safe(address, data) \
794
+do { \
795
+    boot_spm_busy_wait();                       \
796
+    eeprom_busy_wait();                         \
797
+    boot_page_fill(address, data);              \
798
+} while (0)
799
+
800
+/** \ingroup avr_boot
801
+
802
+    Same as boot_page_erase() except it waits for eeprom and spm operations to
803
+    complete before erasing the page. */
804
+
805
+#define boot_page_erase_safe(address) \
806
+do { \
807
+    boot_spm_busy_wait();                       \
808
+    eeprom_busy_wait();                         \
809
+    boot_page_erase (address);                  \
810
+} while (0)
811
+
812
+/** \ingroup avr_boot
813
+
814
+    Same as boot_page_write() except it waits for eeprom and spm operations to
815
+    complete before writing the page. */
816
+
817
+#define boot_page_write_safe(address) \
818
+do { \
819
+    boot_spm_busy_wait();                       \
820
+    eeprom_busy_wait();                         \
821
+    boot_page_write (address);                  \
822
+} while (0)
823
+
824
+/** \ingroup avr_boot
825
+
826
+    Same as boot_rww_enable() except waits for eeprom and spm operations to
827
+    complete before enabling the RWW mameory. */
828
+
829
+#define boot_rww_enable_safe() \
830
+do { \
831
+    boot_spm_busy_wait();                       \
832
+    eeprom_busy_wait();                         \
833
+    boot_rww_enable();                          \
834
+} while (0)
835
+
836
+/** \ingroup avr_boot
837
+
838
+    Same as boot_lock_bits_set() except waits for eeprom and spm operations to
839
+    complete before setting the lock bits. */
840
+
841
+#define boot_lock_bits_set_safe(lock_bits) \
842
+do { \
843
+    boot_spm_busy_wait();                       \
844
+    eeprom_busy_wait();                         \
845
+    boot_lock_bits_set (lock_bits);             \
846
+} while (0)
847
+
848
+#endif /* _AVR_BOOT_H_ */

+ 724
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot.c Dosyayı Görüntüle

@@ -0,0 +1,724 @@
1
+/**********************************************************/
2
+/* -Wl,-section-start=bootloader=0x1fc00 */
3
+/* Optiboot bootloader for Arduino                        */
4
+/*                                                        */
5
+/* http://optiboot.googlecode.com                         */
6
+/*                                                        */
7
+/* Arduino-maintained version : See README.TXT            */
8
+/* http://code.google.com/p/arduino/                      */
9
+/*                                                        */
10
+/* Heavily optimised bootloader that is faster and        */
11
+/* smaller than the Arduino standard bootloader           */
12
+/*                                                        */
13
+/* Enhancements:                                          */
14
+/*   Fits in 512 bytes, saving 1.5K of code space         */
15
+/*   Background page erasing speeds up programming        */
16
+/*   Higher baud rate speeds up programming               */
17
+/*   Written almost entirely in C                         */
18
+/*   Customisable timeout with accurate timeconstant      */
19
+/*   Optional virtual UART. No hardware UART required.    */
20
+/*   Optional virtual boot partition for devices without. */
21
+/*                                                        */
22
+/* What you lose:                                         */
23
+/*   Implements a skeleton STK500 protocol which is       */
24
+/*     missing several features including EEPROM          */
25
+/*     programming and non-page-aligned writes            */
26
+/*   High baud rate breaks compatibility with standard    */
27
+/*     Arduino flash settings                             */
28
+/*                                                        */
29
+/* Fully supported:                                       */
30
+/*   ATmega168 based devices  (Diecimila etc)             */
31
+/*   ATmega328P based devices (Duemilanove etc)           */
32
+/*                                                        */
33
+/* Alpha test                                             */
34
+/*   ATmega1280 based devices (Arduino Mega)              */
35
+/*                                                        */
36
+/* Work in progress:                                      */
37
+/*   ATmega644P based devices (Sanguino)                  */
38
+/*   ATtiny84 based devices (Luminet)                     */
39
+/*                                                        */
40
+/* Does not support:                                      */
41
+/*   USB based devices (eg. Teensy)                       */
42
+/*                                                        */
43
+/* Assumptions:                                           */
44
+/*   The code makes several assumptions that reduce the   */
45
+/*   code size. They are all true after a hardware reset, */
46
+/*   but may not be true if the bootloader is called by   */
47
+/*   other means or on other hardware.                    */
48
+/*     No interrupts can occur                            */
49
+/*     UART and Timer 1 are set to their reset state      */
50
+/*     SP points to RAMEND                                */
51
+/*                                                        */
52
+/* Code builds on code, libraries and optimisations from: */
53
+/*   stk500boot.c          by Jason P. Kyle               */
54
+/*   Arduino bootloader    http://arduino.cc              */
55
+/*   Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */
56
+/*   avr-libc project      http://nongnu.org/avr-libc     */
57
+/*   Adaboot               http://www.ladyada.net/library/arduino/bootloader.html */
58
+/*   AVR305                Atmel Application Note         */
59
+/*                                                        */
60
+/* This program is free software; you can redistribute it */
61
+/* and/or modify it under the terms of the GNU General    */
62
+/* Public License as published by the Free Software       */
63
+/* Foundation; either version 2 of the License, or        */
64
+/* (at your option) any later version.                    */
65
+/*                                                        */
66
+/* This program is distributed in the hope that it will   */
67
+/* be useful, but WITHOUT ANY WARRANTY; without even the  */
68
+/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
69
+/* PARTICULAR PURPOSE.  See the GNU General Public        */
70
+/* License for more details.                              */
71
+/*                                                        */
72
+/* You should have received a copy of the GNU General     */
73
+/* Public License along with this program; if not, write  */
74
+/* to the Free Software Foundation, Inc.,                 */
75
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
76
+/*                                                        */
77
+/* Licence can be viewed at                               */
78
+/* http://www.fsf.org/licenses/gpl.txt                    */
79
+/*                                                        */
80
+/**********************************************************/
81
+
82
+
83
+/**********************************************************/
84
+/*                                                        */
85
+/* Optional defines:                                      */
86
+/*                                                        */
87
+/**********************************************************/
88
+/*                                                        */
89
+/* BIG_BOOT:                                              */
90
+/* Build a 1k bootloader, not 512 bytes. This turns on    */
91
+/* extra functionality.                                   */
92
+/*                                                        */
93
+/* BAUD_RATE:                                             */
94
+/* Set bootloader baud rate.                              */
95
+/*                                                        */
96
+/* LUDICROUS_SPEED:                                       */
97
+/* 230400 baud :-)                                        */
98
+/*                                                        */
99
+/* SOFT_UART:                                             */
100
+/* Use AVR305 soft-UART instead of hardware UART.         */
101
+/*                                                        */
102
+/* LED_START_FLASHES:                                     */
103
+/* Number of LED flashes on bootup.                       */
104
+/*                                                        */
105
+/* LED_DATA_FLASH:                                        */
106
+/* Flash LED when transferring data. For boards without   */
107
+/* TX or RX LEDs, or for people who like blinky lights.   */
108
+/*                                                        */
109
+/* SUPPORT_EEPROM:                                        */
110
+/* Support reading and writing from EEPROM. This is not   */
111
+/* used by Arduino, so off by default.                    */
112
+/*                                                        */
113
+/* TIMEOUT_MS:                                            */
114
+/* Bootloader timeout period, in milliseconds.            */
115
+/* 500,1000,2000,4000,8000 supported.                     */
116
+/*                                                        */
117
+/**********************************************************/
118
+
119
+/**********************************************************/
120
+/* Version Numbers!                                       */
121
+/*                                                        */
122
+/* Arduino Optiboot now includes this Version number in   */
123
+/* the source and object code.                            */
124
+/*                                                        */
125
+/* Version 3 was released as zip from the optiboot        */
126
+/*  repository and was distributed with Arduino 0022.     */
127
+/* Version 4 starts with the arduino repository commit    */
128
+/*  that brought the arduino repository up-to-date with   */
129
+/* the optiboot source tree changes since v3.             */
130
+/*                                                        */
131
+/**********************************************************/
132
+
133
+/**********************************************************/
134
+/* Edit History:                                          */
135
+/*                                                        */
136
+/* Jan 2012:                                              */
137
+/* 4.5 WestfW: fix NRWW value for m1284.                  */
138
+/* 4.4 WestfW: use attribute OS_main instead of naked for */
139
+/*             main().  This allows optimizations that we */
140
+/*             count on, which are prohibited in naked    */
141
+/*             functions due to PR42240.  (keeps us less  */
142
+/*             than 512 bytes when compiler is gcc4.5     */
143
+/*             (code from 4.3.2 remains the same.)        */
144
+/* 4.4 WestfW and Maniacbug:  Add m1284 support.  This    */
145
+/*             does not change the 328 binary, so the     */
146
+/*             version number didn't change either. (?)   */
147
+/* June 2011:                                             */
148
+/* 4.4 WestfW: remove automatic soft_uart detect (didn't  */
149
+/*             know what it was doing or why.)  Added a   */
150
+/*             check of the calculated BRG value instead. */
151
+/*             Version stays 4.4; existing binaries are   */
152
+/*             not changed.                               */
153
+/* 4.4 WestfW: add initialization of address to keep      */
154
+/*             the compiler happy.  Change SC'ed targets. */
155
+/*             Return the SW version via READ PARAM       */
156
+/* 4.3 WestfW: catch framing errors in getch(), so that   */
157
+/*             AVRISP works without HW kludges.           */
158
+/*  http://code.google.com/p/arduino/issues/detail?id=368n*/
159
+/* 4.2 WestfW: reduce code size, fix timeouts, change     */
160
+/*             verifySpace to use WDT instead of appstart */
161
+/* 4.1 WestfW: put version number in binary.              */
162
+/**********************************************************/
163
+
164
+#define OPTIBOOT_MAJVER 4
165
+#define OPTIBOOT_MINVER 5
166
+
167
+#define MAKESTR(a) #a
168
+#define MAKEVER(a, b) MAKESTR(a*256+b)
169
+
170
+asm("  .section .version\n"
171
+    "optiboot_version:  .word " MAKEVER(OPTIBOOT_MAJVER, OPTIBOOT_MINVER) "\n"
172
+    "  .section .text\n");
173
+
174
+#include <inttypes.h>
175
+#include <avr/io.h>
176
+#include <avr/pgmspace.h>
177
+
178
+// <avr/boot.h> uses sts instructions, but this version uses out instructions
179
+// This saves cycles and program memory.
180
+#include "boot.h"
181
+
182
+
183
+// We don't use <avr/wdt.h> as those routines have interrupt overhead we don't need.
184
+
185
+#include "pin_defs.h"
186
+#include "stk500.h"
187
+
188
+#ifndef LED_START_FLASHES
189
+#define LED_START_FLASHES 0
190
+#endif
191
+
192
+#ifdef LUDICROUS_SPEED
193
+#define BAUD_RATE 230400L
194
+#endif
195
+
196
+/* set the UART baud rate defaults */
197
+#ifndef BAUD_RATE
198
+#if F_CPU >= 8000000L
199
+#define BAUD_RATE   115200L // Highest rate Avrdude win32 will support
200
+#elsif F_CPU >= 1000000L
201
+#define BAUD_RATE   9600L   // 19200 also supported, but with significant error
202
+#elsif F_CPU >= 128000L
203
+#define BAUD_RATE   4800L   // Good for 128kHz internal RC
204
+#else
205
+#define BAUD_RATE 1200L     // Good even at 32768Hz
206
+#endif
207
+#endif
208
+
209
+#if 0
210
+/* Switch in soft UART for hard baud rates */
211
+/*
212
+ * I don't understand what this was supposed to accomplish, where the
213
+ * constant "280" came from, or why automatically (and perhaps unexpectedly)
214
+ * switching to a soft uart is a good thing, so I'm undoing this in favor
215
+ * of a range check using the same calc used to config the BRG...
216
+ */
217
+#if (F_CPU/BAUD_RATE) > 280 // > 57600 for 16MHz
218
+#ifndef SOFT_UART
219
+#define SOFT_UART
220
+#endif
221
+#endif
222
+#else // 0
223
+#if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 > 250
224
+#error Unachievable baud rate (too slow) BAUD_RATE 
225
+#endif // baud rate slow check
226
+#if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 < 3
227
+#error Unachievable baud rate (too fast) BAUD_RATE 
228
+#endif // baud rate fastn check
229
+#endif
230
+
231
+/* Watchdog settings */
232
+#define WATCHDOG_OFF    (0)
233
+#define WATCHDOG_16MS   (_BV(WDE))
234
+#define WATCHDOG_32MS   (_BV(WDP0) | _BV(WDE))
235
+#define WATCHDOG_64MS   (_BV(WDP1) | _BV(WDE))
236
+#define WATCHDOG_125MS  (_BV(WDP1) | _BV(WDP0) | _BV(WDE))
237
+#define WATCHDOG_250MS  (_BV(WDP2) | _BV(WDE))
238
+#define WATCHDOG_500MS  (_BV(WDP2) | _BV(WDP0) | _BV(WDE))
239
+#define WATCHDOG_1S     (_BV(WDP2) | _BV(WDP1) | _BV(WDE))
240
+#define WATCHDOG_2S     (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE))
241
+#ifndef __AVR_ATmega8__
242
+#define WATCHDOG_4S     (_BV(WDP3) | _BV(WDE))
243
+#define WATCHDOG_8S     (_BV(WDP3) | _BV(WDP0) | _BV(WDE))
244
+#endif
245
+
246
+/* Function Prototypes */
247
+/* The main function is in init9, which removes the interrupt vector table */
248
+/* we don't need. It is also 'naked', which means the compiler does not    */
249
+/* generate any entry or exit code itself. */
250
+int main(void) __attribute__ ((OS_main)) __attribute__ ((section (".init9")));
251
+void putch(char);
252
+uint8_t getch(void);
253
+static inline void getNch(uint8_t); /* "static inline" is a compiler hint to reduce code size */
254
+void verifySpace();
255
+static inline void flash_led(uint8_t);
256
+uint8_t getLen();
257
+static inline void watchdogReset();
258
+void watchdogConfig(uint8_t x);
259
+#ifdef SOFT_UART
260
+void uartDelay() __attribute__ ((naked));
261
+#endif
262
+void appStart() __attribute__ ((naked));
263
+
264
+/*
265
+ * NRWW memory
266
+ * Addresses below NRWW (Non-Read-While-Write) can be programmed while
267
+ * continuing to run code from flash, slightly speeding up programming
268
+ * time.  Beware that Atmel data sheets specify this as a WORD address,
269
+ * while optiboot will be comparing against a 16-bit byte address.  This
270
+ * means that on a part with 128kB of memory, the upper part of the lower
271
+ * 64k will get NRWW processing as well, even though it doesn't need it.
272
+ * That's OK.  In fact, you can disable the overlapping processing for
273
+ * a part entirely by setting NRWWSTART to zero.  This reduces code
274
+ * space a bit, at the expense of being slightly slower, overall.
275
+ *
276
+ * RAMSTART should be self-explanatory.  It's bigger on parts with a
277
+ * lot of peripheral registers.
278
+ */
279
+#if defined(__AVR_ATmega168__)
280
+#define RAMSTART (0x100)
281
+#define NRWWSTART (0x3800)
282
+#elif defined(__AVR_ATmega328P__)
283
+#define RAMSTART (0x100)
284
+#define NRWWSTART (0x7000)
285
+#elif defined (__AVR_ATmega644P__)
286
+#define RAMSTART (0x100)
287
+#define NRWWSTART (0xE000)
288
+#elif defined (__AVR_ATmega1284P__)
289
+#define RAMSTART (0x100)
290
+#define NRWWSTART (0xE000)
291
+#elif defined(__AVR_ATtiny84__)
292
+#define RAMSTART (0x100)
293
+#define NRWWSTART (0x0000)
294
+#elif defined(__AVR_ATmega1280__)
295
+#define RAMSTART (0x200)
296
+#define NRWWSTART (0xE000)
297
+#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
298
+#define RAMSTART (0x100)
299
+#define NRWWSTART (0x1800)
300
+#endif
301
+
302
+/* C zero initialises all global variables. However, that requires */
303
+/* These definitions are NOT zero initialised, but that doesn't matter */
304
+/* This allows us to drop the zero init code, saving us memory */
305
+#define buff    ((uint8_t*)(RAMSTART))
306
+#ifdef VIRTUAL_BOOT_PARTITION
307
+#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
308
+#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
309
+#endif
310
+
311
+/* main program starts here */
312
+int main(void) {
313
+  uint8_t ch;
314
+
315
+  /*
316
+   * Making these local and in registers prevents the need for initializing
317
+   * them, and also saves space because code no longer stores to memory.
318
+   * (initializing address keeps the compiler happy, but isn't really
319
+   *  necessary, and uses 4 bytes of flash.)
320
+   */
321
+  register uint16_t address = 0;
322
+  register uint8_t  length;
323
+
324
+  // After the zero init loop, this is the first code to run.
325
+  //
326
+  // This code makes the following assumptions:
327
+  //  No interrupts will execute
328
+  //  SP points to RAMEND
329
+  //  r1 contains zero
330
+  //
331
+  // If not, uncomment the following instructions:
332
+  // cli();
333
+  asm volatile ("clr __zero_reg__");
334
+#ifdef __AVR_ATmega8__
335
+  SP=RAMEND;  // This is done by hardware reset
336
+#endif
337
+
338
+  // Adaboot no-wait mod
339
+  ch = MCUSR;
340
+  MCUSR = 0;
341
+  if (!(ch & _BV(EXTRF))) appStart();
342
+
343
+#if LED_START_FLASHES > 0
344
+  // Set up Timer 1 for timeout counter
345
+  TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
346
+#endif
347
+#ifndef SOFT_UART
348
+#ifdef __AVR_ATmega8__
349
+  UCSRA = _BV(U2X); //Double speed mode USART
350
+  UCSRB = _BV(RXEN) | _BV(TXEN);  // enable Rx & Tx
351
+  UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1
352
+  UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
353
+#else
354
+  UCSR0A = _BV(U2X0); //Double speed mode USART0
355
+  UCSR0B = _BV(RXEN0) | _BV(TXEN0);
356
+  UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
357
+  UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
358
+#endif
359
+#endif
360
+
361
+  // Set up watchdog to trigger after 500ms
362
+  watchdogConfig(WATCHDOG_1S);
363
+
364
+  /* Set LED pin as output */
365
+  LED_DDR |= _BV(LED);
366
+
367
+#ifdef SOFT_UART
368
+  /* Set TX pin as output */
369
+  UART_DDR |= _BV(UART_TX_BIT);
370
+#endif
371
+
372
+#if LED_START_FLASHES > 0
373
+  /* Flash onboard LED to signal entering of bootloader */
374
+  flash_led(LED_START_FLASHES * 2);
375
+#endif
376
+
377
+  /* Forever loop */
378
+  for (;;) {
379
+    /* get character from UART */
380
+    ch = getch();
381
+
382
+    if(ch == STK_GET_PARAMETER) {
383
+      unsigned char which = getch();
384
+      verifySpace();
385
+      if (which == 0x82) {
386
+        /*
387
+         * Send optiboot version as "minor SW version"
388
+         */
389
+        putch(OPTIBOOT_MINVER);
390
+      } else if (which == 0x81) {
391
+          putch(OPTIBOOT_MAJVER);
392
+      } else {
393
+        /*
394
+         * GET PARAMETER returns a generic 0x03 reply for
395
+         * other parameters - enough to keep Avrdude happy
396
+         */
397
+        putch(0x03);
398
+      }
399
+    }
400
+    else if(ch == STK_SET_DEVICE) {
401
+      // SET DEVICE is ignored
402
+      getNch(20);
403
+    }
404
+    else if(ch == STK_SET_DEVICE_EXT) {
405
+      // SET DEVICE EXT is ignored
406
+      getNch(5);
407
+    }
408
+    else if(ch == STK_LOAD_ADDRESS) {
409
+      // LOAD ADDRESS
410
+      uint16_t newAddress;
411
+      newAddress = getch();
412
+      newAddress = (newAddress & 0xff) | (getch() << 8);
413
+#ifdef RAMPZ
414
+      // Transfer top bit to RAMPZ
415
+      RAMPZ = (newAddress & 0x8000) ? 1 : 0;
416
+#endif
417
+      newAddress += newAddress; // Convert from word address to byte address
418
+      address = newAddress;
419
+      verifySpace();
420
+    }
421
+    else if(ch == STK_UNIVERSAL) {
422
+      // UNIVERSAL command is ignored
423
+      getNch(4);
424
+      putch(0x00);
425
+    }
426
+    /* Write memory, length is big endian and is in bytes */
427
+    else if(ch == STK_PROG_PAGE) {
428
+      // PROGRAM PAGE - we support flash programming only, not EEPROM
429
+      uint8_t *bufPtr;
430
+      uint16_t addrPtr;
431
+
432
+      getch();                  /* getlen() */
433
+      length = getch();
434
+      getch();
435
+
436
+      // If we are in RWW section, immediately start page erase
437
+      if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
438
+
439
+      // While that is going on, read in page contents
440
+      bufPtr = buff;
441
+      do *bufPtr++ = getch();
442
+      while (--length);
443
+
444
+      // If we are in NRWW section, page erase has to be delayed until now.
445
+      // Todo: Take RAMPZ into account
446
+      if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
447
+
448
+      // Read command terminator, start reply
449
+      verifySpace();
450
+
451
+      // If only a partial page is to be programmed, the erase might not be complete.
452
+      // So check that here
453
+      boot_spm_busy_wait();
454
+
455
+#ifdef VIRTUAL_BOOT_PARTITION
456
+      if ((uint16_t)(void*)address == 0) {
457
+        // This is the reset vector page. We need to live-patch the code so the
458
+        // bootloader runs.
459
+        //
460
+        // Move RESET vector to WDT vector
461
+        uint16_t vect = buff[0] | (buff[1]<<8);
462
+        rstVect = vect;
463
+        wdtVect = buff[8] | (buff[9]<<8);
464
+        vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
465
+        buff[8] = vect & 0xff;
466
+        buff[9] = vect >> 8;
467
+
468
+        // Add jump to bootloader at RESET vector
469
+        buff[0] = 0x7f;
470
+        buff[1] = 0xce; // rjmp 0x1d00 instruction
471
+      }
472
+#endif
473
+
474
+      // Copy buffer into programming buffer
475
+      bufPtr = buff;
476
+      addrPtr = (uint16_t)(void*)address;
477
+      ch = SPM_PAGESIZE / 2;
478
+      do {
479
+        uint16_t a;
480
+        a = *bufPtr++;
481
+        a |= (*bufPtr++) << 8;
482
+        __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
483
+        addrPtr += 2;
484
+      } while (--ch);
485
+
486
+      // Write from programming buffer
487
+      __boot_page_write_short((uint16_t)(void*)address);
488
+      boot_spm_busy_wait();
489
+
490
+#if defined(RWWSRE)
491
+      // Reenable read access to flash
492
+      boot_rww_enable();
493
+#endif
494
+
495
+    }
496
+    /* Read memory block mode, length is big endian.  */
497
+    else if(ch == STK_READ_PAGE) {
498
+      // READ PAGE - we only read flash
499
+      getch();                  /* getlen() */
500
+      length = getch();
501
+      getch();
502
+
503
+      verifySpace();
504
+#ifdef VIRTUAL_BOOT_PARTITION
505
+      do {
506
+        // Undo vector patch in bottom page so verify passes
507
+        if (address == 0)       ch=rstVect & 0xff;
508
+        else if (address == 1)  ch=rstVect >> 8;
509
+        else if (address == 8)  ch=wdtVect & 0xff;
510
+        else if (address == 9) ch=wdtVect >> 8;
511
+        else ch = pgm_read_byte_near(address);
512
+        address++;
513
+        putch(ch);
514
+      } while (--length);
515
+#else
516
+#ifdef RAMPZ
517
+// Since RAMPZ should already be set, we need to use EPLM directly.
518
+//      do putch(pgm_read_byte_near(address++));
519
+//      while (--length);
520
+      do {
521
+        uint8_t result;
522
+        __asm__ ("elpm %0,Z\n":"=r"(result):"z"(address));
523
+        putch(result);
524
+        address++;
525
+      }
526
+      while (--length);
527
+#else
528
+      do putch(pgm_read_byte_near(address++));
529
+      while (--length);
530
+#endif
531
+#endif
532
+    }
533
+
534
+    /* Get device signature bytes  */
535
+    else if(ch == STK_READ_SIGN) {
536
+      // READ SIGN - return what Avrdude wants to hear
537
+      verifySpace();
538
+      putch(SIGNATURE_0);
539
+      putch(SIGNATURE_1);
540
+      putch(SIGNATURE_2);
541
+    }
542
+    else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
543
+      // Adaboot no-wait mod
544
+      watchdogConfig(WATCHDOG_16MS);
545
+      verifySpace();
546
+    }
547
+    else {
548
+      // This covers the response to commands like STK_ENTER_PROGMODE
549
+      verifySpace();
550
+    }
551
+    putch(STK_OK);
552
+  }
553
+}
554
+
555
+void putch(char ch) {
556
+#ifndef SOFT_UART
557
+  while (!(UCSR0A & _BV(UDRE0)));
558
+  UDR0 = ch;
559
+#else
560
+  __asm__ __volatile__ (
561
+    "   com %[ch]\n" // ones complement, carry set
562
+    "   sec\n"
563
+    "1: brcc 2f\n"
564
+    "   cbi %[uartPort],%[uartBit]\n"
565
+    "   rjmp 3f\n"
566
+    "2: sbi %[uartPort],%[uartBit]\n"
567
+    "   nop\n"
568
+    "3: rcall uartDelay\n"
569
+    "   rcall uartDelay\n"
570
+    "   lsr %[ch]\n"
571
+    "   dec %[bitcnt]\n"
572
+    "   brne 1b\n"
573
+    :
574
+    :
575
+      [bitcnt] "d" (10),
576
+      [ch] "r" (ch),
577
+      [uartPort] "I" (_SFR_IO_ADDR(UART_PORT)),
578
+      [uartBit] "I" (UART_TX_BIT)
579
+    :
580
+      "r25"
581
+  );
582
+#endif
583
+}
584
+
585
+uint8_t getch(void) {
586
+  uint8_t ch;
587
+
588
+#ifdef LED_DATA_FLASH
589
+#ifdef __AVR_ATmega8__
590
+  LED_PORT ^= _BV(LED);
591
+#else
592
+  LED_PIN |= _BV(LED);
593
+#endif
594
+#endif
595
+
596
+#ifdef SOFT_UART
597
+  __asm__ __volatile__ (
598
+    "1: sbic  %[uartPin],%[uartBit]\n"  // Wait for start edge
599
+    "   rjmp  1b\n"
600
+    "   rcall uartDelay\n"          // Get to middle of start bit
601
+    "2: rcall uartDelay\n"              // Wait 1 bit period
602
+    "   rcall uartDelay\n"              // Wait 1 bit period
603
+    "   clc\n"
604
+    "   sbic  %[uartPin],%[uartBit]\n"
605
+    "   sec\n"
606
+    "   dec   %[bitCnt]\n"
607
+    "   breq  3f\n"
608
+    "   ror   %[ch]\n"
609
+    "   rjmp  2b\n"
610
+    "3:\n"
611
+    :
612
+      [ch] "=r" (ch)
613
+    :
614
+      [bitCnt] "d" (9),
615
+      [uartPin] "I" (_SFR_IO_ADDR(UART_PIN)),
616
+      [uartBit] "I" (UART_RX_BIT)
617
+    :
618
+      "r25"
619
+);
620
+#else
621
+  while(!(UCSR0A & _BV(RXC0)))
622
+    ;
623
+  if (!(UCSR0A & _BV(FE0))) {
624
+      /*
625
+       * A Framing Error indicates (probably) that something is talking
626
+       * to us at the wrong bit rate.  Assume that this is because it
627
+       * expects to be talking to the application, and DON'T reset the
628
+       * watchdog.  This should cause the bootloader to abort and run
629
+       * the application "soon", if it keeps happening.  (Note that we
630
+       * don't care that an invalid char is returned...)
631
+       */
632
+    watchdogReset();
633
+  }
634
+  
635
+  ch = UDR0;
636
+#endif
637
+
638
+#ifdef LED_DATA_FLASH
639
+#ifdef __AVR_ATmega8__
640
+  LED_PORT ^= _BV(LED);
641
+#else
642
+  LED_PIN |= _BV(LED);
643
+#endif
644
+#endif
645
+
646
+  return ch;
647
+}
648
+
649
+#ifdef SOFT_UART
650
+// AVR305 equation: #define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6)
651
+// Adding 3 to numerator simulates nearest rounding for more accurate baud rates
652
+#define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6)
653
+#if UART_B_VALUE > 255
654
+#error Baud rate too slow for soft UART
655
+#endif
656
+
657
+void uartDelay() {
658
+  __asm__ __volatile__ (
659
+    "ldi r25,%[count]\n"
660
+    "1:dec r25\n"
661
+    "brne 1b\n"
662
+    "ret\n"
663
+    ::[count] "M" (UART_B_VALUE)
664
+  );
665
+}
666
+#endif
667
+
668
+void getNch(uint8_t count) {
669
+  do getch(); while (--count);
670
+  verifySpace();
671
+}
672
+
673
+void verifySpace() {
674
+  if (getch() != CRC_EOP) {
675
+    watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
676
+    while (1)                         // and busy-loop so that WD causes
677
+      ;                               //  a reset and app start.
678
+  }
679
+  putch(STK_INSYNC);
680
+}
681
+
682
+#if LED_START_FLASHES > 0
683
+void flash_led(uint8_t count) {
684
+  do {
685
+    TCNT1 = -(F_CPU/(1024*16));
686
+    TIFR1 = _BV(TOV1);
687
+    while(!(TIFR1 & _BV(TOV1)));
688
+#ifdef __AVR_ATmega8__
689
+    LED_PORT ^= _BV(LED);
690
+#else
691
+    LED_PIN |= _BV(LED);
692
+#endif
693
+    watchdogReset();
694
+  } while (--count);
695
+}
696
+#endif
697
+
698
+// Watchdog functions. These are only safe with interrupts turned off.
699
+void watchdogReset() {
700
+  __asm__ __volatile__ (
701
+    "wdr\n"
702
+  );
703
+}
704
+
705
+void watchdogConfig(uint8_t x) {
706
+  WDTCSR = _BV(WDCE) | _BV(WDE);
707
+  WDTCSR = x;
708
+}
709
+
710
+void appStart() {
711
+  watchdogConfig(WATCHDOG_OFF);
712
+  __asm__ __volatile__ (
713
+#ifdef VIRTUAL_BOOT_PARTITION
714
+    // Jump to WDT vector
715
+    "ldi r30,4\n"
716
+    "clr r31\n"
717
+#else
718
+    // Jump to RST vector
719
+    "clr r30\n"
720
+    "clr r31\n"
721
+#endif
722
+    "ijmp\n"
723
+  );
724
+}

+ 33
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot_1284P_20MHz_57k6_baud.hex Dosyayı Görüntüle

@@ -0,0 +1,33 @@
1
+:020000021000EC
2
+:10FE00000F92CDB7DEB7112484B714BE81FFDFD0C7
3
+:10FE100082E08093C00088E18093C10086E08093F7
4
+:10FE2000C2008AE28093C4008EE0BBD0209A00E03A
5
+:10FE300010E0EE24E394E1E1DE2EF3E0FF2EA5D006
6
+:10FE4000813471F4A2D08983B2D08981823809F4D7
7
+:10FE50008BC0813811F484E001C083E08FD08BC067
8
+:10FE6000823411F484E103C0853419F485E0A7D00D
9
+:10FE700082C0853591F489D0A82EBB2486D0082F66
10
+:10FE800010E0102F00270A291B29812F881F88279F
11
+:10FE9000881F8BBF000F111F6DC0863521F484E0D1
12
+:10FEA0008ED080E0DBCF843609F040C06ED06DD0BC
13
+:10FEB000C82E6BD080EE0030180718F4F801F7BE9A
14
+:10FEC000E895A12C51E0B52E60D0F50181935F013A
15
+:10FED000CE16D1F7F0EE00301F0718F0F801F7BE8C
16
+:10FEE000E89565D007B600FCFDCFF801A0E0B1E0D1
17
+:10FEF0002C9130E011968C91119790E0982F8827E3
18
+:10FF0000822B932B12960C01E7BEE89511243296B2
19
+:10FF100082E0A030B80761F785E0F80187BFE89577
20
+:10FF200007B600FCFDCFD7BEE89525C08437A9F4FD
21
+:10FF30002CD02BD0B82E29D03AD0CB2C4801F401AC
22
+:10FF400086911CD00894811C911CCA94C1F70F5F44
23
+:10FF50001F4FBA940B0D111D0EC0853739F427D0F1
24
+:10FF60008EE10CD087E90AD085E078CF813511F495
25
+:10FF700088E017D01CD080E101D061CF9091C00003
26
+:10FF800095FFFCCF8093C60008958091C00087FF45
27
+:10FF9000FCCF8091C00084FD01C0A8958091C6006F
28
+:10FFA0000895E0E6F0E098E1908380830895EDDF26
29
+:10FFB000803219F088E0F5DFFFCF84E1DFCFCF9307
30
+:10FFC000C82FE3DFC150E9F7F2DFCF91089580E059
31
+:08FFD000E8DFEE27FF2709948A
32
+:040000031000FE00EB
33
+:00000001FF

+ 81
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/pin_defs.h Dosyayı Görüntüle

@@ -0,0 +1,81 @@
1
+#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
2
+/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
3
+#define LED_DDR     DDRB
4
+#define LED_PORT    PORTB
5
+#define LED_PIN     PINB
6
+#define LED         PINB5
7
+
8
+/* Ports for soft UART */
9
+#ifdef SOFT_UART
10
+#define UART_PORT   PORTD
11
+#define UART_PIN    PIND
12
+#define UART_DDR    DDRD
13
+#define UART_TX_BIT 1
14
+#define UART_RX_BIT 0
15
+#endif
16
+#endif
17
+
18
+#if defined(__AVR_ATmega8__)
19
+  //Name conversion R.Wiersma
20
+  #define UCSR0A        UCSRA
21
+  #define UDR0          UDR
22
+  #define UDRE0         UDRE
23
+  #define RXC0          RXC
24
+  #define FE0           FE
25
+  #define TIFR1         TIFR
26
+  #define WDTCSR        WDTCR
27
+#endif
28
+
29
+/* Luminet support */
30
+#if defined(__AVR_ATtiny84__)
31
+/* Red LED is connected to pin PA4 */
32
+#define LED_DDR     DDRA
33
+#define LED_PORT    PORTA
34
+#define LED_PIN     PINA
35
+#define LED         PINA4
36
+/* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */
37
+#ifdef SOFT_UART
38
+#define UART_PORT   PORTA
39
+#define UART_PIN    PINA
40
+#define UART_DDR    DDRA
41
+#define UART_TX_BIT 2
42
+#define UART_RX_BIT 3
43
+#endif
44
+#endif
45
+
46
+/* Sanguino support */
47
+#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
48
+/* Onboard LED is connected to pin PB0 on Sanguino */
49
+#define LED_DDR     DDRB
50
+#define LED_PORT    PORTB
51
+#define LED_PIN     PINB
52
+#define LED         PINB0
53
+
54
+/* Ports for soft UART */
55
+#ifdef SOFT_UART
56
+#define UART_PORT   PORTD
57
+#define UART_PIN    PIND
58
+#define UART_DDR    DDRD
59
+#define UART_TX_BIT 1
60
+#define UART_RX_BIT 0
61
+#endif
62
+#endif
63
+
64
+/* Mega support */
65
+#if defined(__AVR_ATmega1280__)
66
+/* Onboard LED is connected to pin PB7 on Arduino Mega */
67
+#define LED_DDR     DDRB
68
+#define LED_PORT    PORTB
69
+#define LED_PIN     PINB
70
+#define LED         PINB7
71
+
72
+/* Ports for soft UART */
73
+#ifdef SOFT_UART
74
+#define UART_PORT   PORTE
75
+#define UART_PIN    PINE
76
+#define UART_DDR    DDRE
77
+#define UART_TX_BIT 1
78
+#define UART_RX_BIT 0
79
+#endif
80
+#endif
81
+

+ 39
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/stk500.h Dosyayı Görüntüle

@@ -0,0 +1,39 @@
1
+/* STK500 constants list, from AVRDUDE */
2
+#define STK_OK              0x10
3
+#define STK_FAILED          0x11  // Not used
4
+#define STK_UNKNOWN         0x12  // Not used
5
+#define STK_NODEVICE        0x13  // Not used
6
+#define STK_INSYNC          0x14  // ' '
7
+#define STK_NOSYNC          0x15  // Not used
8
+#define ADC_CHANNEL_ERROR   0x16  // Not used
9
+#define ADC_MEASURE_OK      0x17  // Not used
10
+#define PWM_CHANNEL_ERROR   0x18  // Not used
11
+#define PWM_ADJUST_OK       0x19  // Not used
12
+#define CRC_EOP             0x20  // 'SPACE'
13
+#define STK_GET_SYNC        0x30  // '0'
14
+#define STK_GET_SIGN_ON     0x31  // '1'
15
+#define STK_SET_PARAMETER   0x40  // '@'
16
+#define STK_GET_PARAMETER   0x41  // 'A'
17
+#define STK_SET_DEVICE      0x42  // 'B'
18
+#define STK_SET_DEVICE_EXT  0x45  // 'E'
19
+#define STK_ENTER_PROGMODE  0x50  // 'P'
20
+#define STK_LEAVE_PROGMODE  0x51  // 'Q'
21
+#define STK_CHIP_ERASE      0x52  // 'R'
22
+#define STK_CHECK_AUTOINC   0x53  // 'S'
23
+#define STK_LOAD_ADDRESS    0x55  // 'U'
24
+#define STK_UNIVERSAL       0x56  // 'V'
25
+#define STK_PROG_FLASH      0x60  // '`'
26
+#define STK_PROG_DATA       0x61  // 'a'
27
+#define STK_PROG_FUSE       0x62  // 'b'
28
+#define STK_PROG_LOCK       0x63  // 'c'
29
+#define STK_PROG_PAGE       0x64  // 'd'
30
+#define STK_PROG_FUSE_EXT   0x65  // 'e'
31
+#define STK_READ_FLASH      0x70  // 'p'
32
+#define STK_READ_DATA       0x71  // 'q'
33
+#define STK_READ_FUSE       0x72  // 'r'
34
+#define STK_READ_LOCK       0x73  // 's'
35
+#define STK_READ_PAGE       0x74  // 't'
36
+#define STK_READ_SIGN       0x75  // 'u'
37
+#define STK_READ_OSCCAL     0x76  // 'v'
38
+#define STK_READ_FUSE_EXT   0x77  // 'w'
39
+#define STK_READ_OSCCAL_EXT 0x78  // 'x'

+ 713
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT.c Dosyayı Görüntüle

@@ -0,0 +1,713 @@
1
+/**********************************************************/
2
+/* Serial Bootloader for Atmel megaAVR Controllers        */
3
+/*                                                        */
4
+/* tested with ATmega644 and ATmega644P                   */
5
+/* should work with other mega's, see code for details    */
6
+/*                                                        */
7
+/* ATmegaBOOT.c                                           */
8
+/*                                                        */
9
+/* 20090131: Added 324P support from Alex Leone           */
10
+/*           Marius Kintel                                */
11
+/* 20080915: applied ADABoot mods for Sanguino 644P       */
12
+/*           Brian Riley                                  */
13
+/* 20080711: hacked for Sanguino by Zach Smith            */
14
+/*           and Justin Day                               */
15
+/* 20070626: hacked for Arduino Diecimila (which auto-    */
16
+/*           resets when a USB connection is made to it)  */
17
+/*           by D. Mellis                                 */
18
+/* 20060802: hacked for Arduino by D. Cuartielles         */
19
+/*           based on a previous hack by D. Mellis        */
20
+/*           and D. Cuartielles                           */
21
+/*                                                        */
22
+/* Monitor and debug functions were added to the original */
23
+/* code by Dr. Erik Lins, chip45.com. (See below)         */
24
+/*                                                        */
25
+/* Thanks to Karl Pitrich for fixing a bootloader pin     */
26
+/* problem and more informative LED blinking!             */
27
+/*                                                        */
28
+/* For the latest version see:                            */
29
+/* http://www.chip45.com/                                 */
30
+/*                                                        */
31
+/* ------------------------------------------------------ */
32
+/*                                                        */
33
+/* based on stk500boot.c                                  */
34
+/* Copyright (c) 2003, Jason P. Kyle                      */
35
+/* All rights reserved.                                   */
36
+/* see avr1.org for original file and information         */
37
+/*                                                        */
38
+/* This program is free software; you can redistribute it */
39
+/* and/or modify it under the terms of the GNU General    */
40
+/* Public License as published by the Free Software       */
41
+/* Foundation; either version 2 of the License, or        */
42
+/* (at your option) any later version.                    */
43
+/*                                                        */
44
+/* This program is distributed in the hope that it will   */
45
+/* be useful, but WITHOUT ANY WARRANTY; without even the  */
46
+/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
47
+/* PARTICULAR PURPOSE.  See the GNU General Public        */
48
+/* License for more details.                              */
49
+/*                                                        */
50
+/* You should have received a copy of the GNU General     */
51
+/* Public License along with this program; if not, write  */
52
+/* to the Free Software Foundation, Inc.,                 */
53
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
54
+/*                                                        */
55
+/* Licence can be viewed at                               */
56
+/* http://www.fsf.org/licenses/gpl.txt                    */
57
+/*                                                        */
58
+/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
59
+/* m8515,m8535. ATmega161 has a very small boot block so  */
60
+/* isn't supported.                                       */
61
+/*                                                        */
62
+/* Tested with m168                                       */
63
+/**********************************************************/
64
+
65
+/* $Id$ */
66
+
67
+
68
+/* some includes */
69
+#include <inttypes.h>
70
+#include <avr/io.h>
71
+#include <avr/pgmspace.h>
72
+#include <avr/interrupt.h>
73
+#include <avr/wdt.h>
74
+#include <avr/boot.h>
75
+
76
+#ifdef ADABOOT
77
+    #define NUM_LED_FLASHES 3
78
+    #define ADABOOT_VER	1
79
+#endif
80
+
81
+
82
+/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
83
+#define MAX_ERROR_COUNT 5
84
+
85
+/* set the UART baud rate */
86
+/* 20080711: hack by Zach Hoeken */
87
+#define BAUD_RATE   38400
88
+
89
+/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
90
+/* never allow AVR Studio to do an update !!!! */
91
+#define HW_VER	 0x02
92
+#define SW_MAJOR 0x01
93
+#define SW_MINOR 0x10
94
+
95
+/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
96
+/* if monitor functions are included, LED goes on after monitor was entered */
97
+#define LED_DDR  DDRB
98
+#define LED_PORT PORTB
99
+#define LED_PIN  PINB
100
+#define LED      PINB0
101
+
102
+/* define various device id's */
103
+/* manufacturer byte is always the same */
104
+#define SIG1	0x1E	// Yep, Atmel is the only manufacturer of AVR micros.  Single source :(
105
+#if defined(__AVR_ATmega644P__)
106
+#define SIG2	0x96
107
+#define SIG3	0x0A
108
+#elif defined(__AVR_ATmega644__)
109
+#define SIG2	0x96
110
+#define SIG3	0x09
111
+#elif defined(__AVR_ATmega324P__)
112
+#define SIG2	0x95
113
+#define SIG3	0x08
114
+#endif
115
+#define PAGE_SIZE		0x080U   //128 words
116
+#define PAGE_SIZE_BYTES	0x100U   //256 bytes
117
+
118
+/* function prototypes */
119
+void putch(char);
120
+char getch(void);
121
+void getNch(uint8_t);
122
+void byte_response(uint8_t);
123
+void nothing_response(void);
124
+char gethex(void);
125
+void puthex(char);
126
+void flash_led(uint8_t);
127
+
128
+/* some variables */
129
+union address_union
130
+{
131
+    uint16_t word;
132
+    uint8_t  byte[2];
133
+} address;
134
+
135
+union length_union
136
+{
137
+    uint16_t word;
138
+    uint8_t  byte[2];
139
+} length;
140
+
141
+struct flags_struct
142
+{
143
+    unsigned eeprom : 1;
144
+    unsigned rampz  : 1;
145
+} flags;
146
+
147
+uint8_t buff[256];
148
+
149
+uint8_t error_count = 0;
150
+uint8_t sreg;
151
+
152
+void (*app_start)(void) = 0x0000;
153
+
154
+/* main program starts here */
155
+int main(void)
156
+{
157
+    uint8_t ch,ch2;
158
+    uint16_t w;
159
+	uint16_t i;
160
+	
161
+    asm volatile("nop\n\t");
162
+
163
+#ifdef ADABOOT		// BBR/LF 10/8/2007 & 9/13/2008
164
+    ch = MCUSR;
165
+    MCUSR = 0;
166
+
167
+    WDTCSR |= _BV(WDCE) | _BV(WDE);
168
+    WDTCSR = 0;
169
+
170
+    // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
171
+    if (! (ch &  _BV(EXTRF))) // if it's a not an external reset...
172
+      app_start();  // skip bootloader
173
+#endif
174
+
175
+
176
+	//initialize our serial port.
177
+    UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
178
+    UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
179
+    UCSR0B = (1<<RXEN0) | (1<<TXEN0);
180
+    UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
181
+
182
+    /* Enable internal pull-up resistor on pin D0 (RX), in order
183
+    to supress line noise that prevents the bootloader from
184
+    timing out (DAM: 20070509) */
185
+    DDRD &= ~_BV(PIND0);
186
+    PORTD |= _BV(PIND0);
187
+
188
+    /* set LED pin as output */
189
+    LED_DDR |= _BV(LED);
190
+
191
+	    /* flash onboard LED to signal entering of bootloader                   */
192
+	    /* ADABOOT will do two series of flashes. first 4 - signifying ADABOOT  */
193
+	    /* then a pause and another flash series signifying ADABOOT sub-version */
194
+
195
+
196
+	flash_led(NUM_LED_FLASHES);
197
+
198
+	#ifdef	ADABOOT
199
+		flash_led(ADABOOT_VER);		// BBR 9/13/2008
200
+	#endif 
201
+
202
+    /* forever loop */
203
+    for (;;)
204
+	{
205
+		/* get character from UART */
206
+		ch = getch();
207
+
208
+		/* A bunch of if...else if... gives smaller code than switch...case ! */
209
+
210
+		/* Hello is anyone home ? */ 
211
+		if(ch=='0')
212
+		    nothing_response();
213
+
214
+
215
+		/* Request programmer ID */
216
+		/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry  */
217
+		/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares.  */
218
+		else if(ch=='1')
219
+		{
220
+		    if (getch() == ' ')
221
+			{
222
+				putch(0x14);
223
+				putch('A');
224
+				putch('V');
225
+				putch('R');
226
+				putch(' ');
227
+				putch('I');
228
+				putch('S');
229
+				putch('P');
230
+				putch(0x10);
231
+		    }
232
+			else
233
+			{
234
+				if (++error_count == MAX_ERROR_COUNT)
235
+				    app_start();
236
+		    }
237
+		}
238
+
239
+
240
+		/* AVR ISP/STK500 board commands  DON'T CARE so default nothing_response */
241
+		else if(ch=='@')
242
+		{
243
+		    ch2 = getch();
244
+		    if (ch2 > 0x85)
245
+				getch();
246
+		    nothing_response();
247
+		}
248
+
249
+
250
+		/* AVR ISP/STK500 board requests */
251
+		else if(ch=='A')
252
+		{
253
+		    ch2 = getch();
254
+		    if(ch2 == 0x80)
255
+				byte_response(HW_VER);		// Hardware version
256
+		    else if(ch2==0x81)
257
+				byte_response(SW_MAJOR);	// Software major version
258
+		    else if(ch2==0x82)
259
+				byte_response(SW_MINOR);	// Software minor version
260
+		    else if(ch2==0x98)
261
+				byte_response(0x03);		// Unknown but seems to be required by avr studio 3.56
262
+		    else
263
+				byte_response(0x00);		// Covers various unnecessary responses we don't care about
264
+		}
265
+
266
+
267
+		/* Device Parameters  DON'T CARE, DEVICE IS FIXED  */
268
+		else if(ch=='B')
269
+		{
270
+		    getNch(20);
271
+		    nothing_response();
272
+		}
273
+
274
+
275
+		/* Parallel programming stuff  DON'T CARE  */
276
+		else if(ch=='E')
277
+		{
278
+		    getNch(5);
279
+		    nothing_response();
280
+		}
281
+
282
+
283
+		/* Enter programming mode  */
284
+		else if(ch=='P')
285
+		{
286
+		    nothing_response();
287
+		}
288
+
289
+
290
+		/* Leave programming mode  */
291
+		else if(ch=='Q')
292
+		{
293
+		    nothing_response();
294
+#ifdef ADABOOT		
295
+			// autoreset via watchdog (sneaky!) BBR/LF 9/13/2008
296
+	  		WDTCSR = _BV(WDE);
297
+	  		while (1); // 16 ms
298
+#endif		
299
+		}
300
+
301
+
302
+		/* Erase device, don't care as we will erase one page at a time anyway.  */
303
+		else if(ch=='R')
304
+		{
305
+		    nothing_response();
306
+		}
307
+
308
+
309
+		/* Set address, little endian. EEPROM in bytes, FLASH in words  */
310
+		/* Perhaps extra address bytes may be added in future to support > 128kB FLASH.  */
311
+		/* This might explain why little endian was used here, big endian used everywhere else.  */
312
+		else if(ch=='U')
313
+		{
314
+		    address.byte[0] = getch();
315
+		    address.byte[1] = getch();
316
+		    nothing_response();
317
+		}
318
+
319
+
320
+		/* Universal SPI programming command, disabled.  Would be used for fuses and lock bits.  */
321
+		else if(ch=='V')
322
+		{
323
+		    getNch(4);
324
+		    byte_response(0x00);
325
+		}
326
+
327
+
328
+		/* Write memory, length is big endian and is in bytes  */
329
+		else if(ch=='d')
330
+		{
331
+		    length.byte[1] = getch();
332
+		    length.byte[0] = getch();
333
+	
334
+		    flags.eeprom = 0;
335
+		    if (getch() == 'E')
336
+				flags.eeprom = 1;
337
+
338
+			for (i=0; i<PAGE_SIZE; i++)
339
+				buff[i] = 0;
340
+		
341
+		    for (w = 0; w < length.word; w++)
342
+			{
343
+				// Store data in buffer, can't keep up with serial data stream whilst programming pages
344
+				buff[w] = getch();
345
+		    }
346
+	
347
+		    if (getch() == ' ')
348
+			{
349
+				if (flags.eeprom)
350
+				{		                
351
+					//Write to EEPROM one byte at a time
352
+				    for(w=0;w<length.word;w++)
353
+					{
354
+						while(EECR & (1<<EEPE));
355
+					
356
+						EEAR = (uint16_t)(void *)address.word;
357
+						EEDR = buff[w];
358
+						EECR |= (1<<EEMPE);
359
+						EECR |= (1<<EEPE);
360
+
361
+						address.word++;
362
+				    }			
363
+				}
364
+				else
365
+				{
366
+					//address * 2 -> byte location
367
+				    address.word = address.word << 1;
368
+			    
369
+					//Even up an odd number of bytes
370
+					if ((length.byte[0] & 0x01))
371
+						length.word++;
372
+				
373
+					// HACKME: EEPE used to be EEWE
374
+				    //Wait for previous EEPROM writes to complete
375
+					//while(bit_is_set(EECR,EEPE));
376
+					while(EECR & (1<<EEPE));
377
+				
378
+				    asm volatile(
379
+						 "clr	r17		\n\t"	//page_word_count
380
+						 "lds	r30,address	\n\t"	//Address of FLASH location (in bytes)
381
+						 "lds	r31,address+1	\n\t"
382
+						 "ldi	r28,lo8(buff)	\n\t"	//Start of buffer array in RAM
383
+						 "ldi	r29,hi8(buff)	\n\t"
384
+						 "lds	r24,length	\n\t"	//Length of data to be written (in bytes)
385
+						 "lds	r25,length+1	\n\t"
386
+						 "length_loop:		\n\t"	//Main loop, repeat for number of words in block							 							 
387
+						 "cpi	r17,0x00	\n\t"	//If page_word_count=0 then erase page
388
+						 "brne	no_page_erase	\n\t"						 
389
+						 "wait_spm1:		\n\t"
390
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
391
+						 "andi	r16,1           \n\t"
392
+						 "cpi	r16,1           \n\t"
393
+						 "breq	wait_spm1       \n\t"
394
+						 "ldi	r16,0x03	\n\t"	//Erase page pointed to by Z
395
+						 "sts	%0,r16		\n\t"
396
+						 "spm			\n\t"							 
397
+						 "wait_spm2:		\n\t"
398
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
399
+						 "andi	r16,1           \n\t"
400
+						 "cpi	r16,1           \n\t"
401
+						 "breq	wait_spm2       \n\t"									 
402
+
403
+						 "ldi	r16,0x11	\n\t"	//Re-enable RWW section
404
+						 "sts	%0,r16		\n\t"						 			 
405
+						 "spm			\n\t"
406
+						 "no_page_erase:		\n\t"							 
407
+						 "ld	r0,Y+		\n\t"	//Write 2 bytes into page buffer
408
+						 "ld	r1,Y+		\n\t"							 
409
+							 
410
+						 "wait_spm3:		\n\t"
411
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
412
+						 "andi	r16,1           \n\t"
413
+						 "cpi	r16,1           \n\t"
414
+						 "breq	wait_spm3       \n\t"
415
+						 "ldi	r16,0x01	\n\t"	//Load r0,r1 into FLASH page buffer
416
+						 "sts	%0,r16		\n\t"
417
+						 "spm			\n\t"
418
+							 
419
+						 "inc	r17		\n\t"	//page_word_count++
420
+						 "cpi r17,%1	        \n\t"
421
+						 "brlo	same_page	\n\t"	//Still same page in FLASH
422
+						 "write_page:		\n\t"
423
+						 "clr	r17		\n\t"	//New page, write current one first
424
+						 "wait_spm4:		\n\t"
425
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
426
+						 "andi	r16,1           \n\t"
427
+						 "cpi	r16,1           \n\t"
428
+						 "breq	wait_spm4       \n\t"						 							 
429
+						 "ldi	r16,0x05	\n\t"	//Write page pointed to by Z
430
+						 "sts	%0,r16		\n\t"
431
+						 "spm			\n\t"
432
+						 "wait_spm5:		\n\t"
433
+						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
434
+						 "andi	r16,1           \n\t"
435
+						 "cpi	r16,1           \n\t"
436
+						 "breq	wait_spm5       \n\t"									 
437
+						 "ldi	r16,0x11	\n\t"	//Re-enable RWW section
438
+						 "sts	%0,r16		\n\t"						 			 
439
+						 "spm			\n\t"					 		 
440
+						 "same_page:		\n\t"							 
441
+						 "adiw	r30,2		\n\t"	//Next word in FLASH
442
+						 "sbiw	r24,2		\n\t"	//length-2
443
+						 "breq	final_write	\n\t"	//Finished
444
+						 "rjmp	length_loop	\n\t"
445
+						 "final_write:		\n\t"
446
+						 "cpi	r17,0		\n\t"
447
+						 "breq	block_done	\n\t"
448
+						 "adiw	r24,2		\n\t"	//length+2, fool above check on length after short page write
449
+						 "rjmp	write_page	\n\t"
450
+						 "block_done:		\n\t"
451
+						 "clr	__zero_reg__	\n\t"	//restore zero register
452
+						 : "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
453
+
454
+						 );
455
+				}
456
+				putch(0x14);
457
+				putch(0x10);
458
+		    }
459
+			else
460
+			{
461
+				if (++error_count == MAX_ERROR_COUNT)
462
+				    app_start();
463
+		    }		
464
+		}
465
+    
466
+		/* Read memory block mode, length is big endian.  */
467
+		else if(ch=='t')
468
+		{
469
+			length.byte[1] = getch();
470
+			length.byte[0] = getch();
471
+
472
+			if (getch() == 'E')
473
+				flags.eeprom = 1;
474
+			else
475
+			{
476
+				flags.eeprom = 0;
477
+				address.word = address.word << 1;	        // address * 2 -> byte location
478
+			}
479
+
480
+			// Command terminator
481
+			if (getch() == ' ')
482
+			{
483
+				putch(0x14);
484
+				for (w=0; w<length.word; w++)
485
+				{
486
+					// Can handle odd and even lengths okay
487
+				    if (flags.eeprom) 
488
+					{
489
+						// Byte access EEPROM read
490
+						while(EECR & (1<<EEPE));
491
+						EEAR = (uint16_t)(void *)address.word;
492
+						EECR |= (1<<EERE);
493
+						putch(EEDR);
494
+
495
+						address.word++;
496
+				    }
497
+				    else
498
+					{
499
+						if (!flags.rampz)
500
+							putch(pgm_read_byte_near(address.word));
501
+
502
+						address.word++;
503
+				    }
504
+				}
505
+				putch(0x10);
506
+		    }
507
+		}
508
+
509
+
510
+		/* Get device signature bytes  */
511
+		else if(ch=='u')
512
+		{
513
+			if (getch() == ' ')
514
+			{
515
+				putch(0x14);
516
+				putch(SIG1);
517
+				putch(SIG2);
518
+				putch(SIG3);
519
+				putch(0x10);
520
+			}
521
+			else
522
+			{
523
+				if (++error_count == MAX_ERROR_COUNT)
524
+					app_start();
525
+			}
526
+		}
527
+
528
+
529
+		/* Read oscillator calibration byte */
530
+		else if(ch=='v')
531
+			byte_response(0x00);
532
+
533
+		else if (++error_count == MAX_ERROR_COUNT)
534
+		    app_start();
535
+
536
+	}
537
+    /* end of forever loop */
538
+}
539
+
540
+
541
+char gethex(void)
542
+{
543
+    char ah,al;
544
+
545
+    ah = getch();
546
+	putch(ah);
547
+    al = getch();
548
+	putch(al);
549
+    
550
+	if(ah >= 'a')
551
+		ah = ah - 'a' + 0x0a;
552
+	else if(ah >= '0')
553
+		ah -= '0';
554
+    if(al >= 'a')
555
+		al = al - 'a' + 0x0a;
556
+	else if(al >= '0')
557
+		al -= '0';
558
+
559
+    return (ah << 4) + al;
560
+}
561
+
562
+
563
+void puthex(char ch)
564
+{
565
+    char ah,al;
566
+
567
+    ah = (ch & 0xf0) >> 4;
568
+	if(ah >= 0x0a)
569
+		ah = ah - 0x0a + 'a';
570
+	else
571
+		ah += '0';
572
+
573
+    al = (ch & 0x0f);
574
+	if(al >= 0x0a)
575
+		al = al - 0x0a + 'a';
576
+	else
577
+		al += '0';
578
+
579
+    putch(ah);
580
+    putch(al);
581
+}
582
+
583
+
584
+void putch(char ch)
585
+{
586
+    while (!(UCSR0A & _BV(UDRE0)));
587
+    UDR0 = ch;
588
+}
589
+
590
+
591
+
592
+
593
+char getch(void)
594
+{
595
+    uint32_t count = 0;
596
+
597
+#ifdef ADABOOT
598
+	LED_PORT &= ~_BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
599
+#endif
600
+
601
+    while(!(UCSR0A & _BV(RXC0)))
602
+	{
603
+    	/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/               
604
+    	/* HACKME:: here is a good place to count times*/
605
+    	count++;
606
+    	if (count > MAX_TIME_COUNT)
607
+    		app_start();
608
+     }
609
+
610
+#ifdef ADABOOT
611
+	LED_PORT |= _BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
612
+#endif
613
+
614
+    return UDR0;
615
+}
616
+
617
+
618
+void getNch(uint8_t count)
619
+{
620
+    uint8_t i;
621
+    for(i=0;i<count;i++)
622
+	{
623
+		while(!(UCSR0A & _BV(RXC0)));
624
+		UDR0;
625
+    }
626
+}
627
+
628
+
629
+void byte_response(uint8_t val)
630
+{
631
+    if (getch() == ' ')
632
+	{
633
+		putch(0x14);
634
+		putch(val);
635
+		putch(0x10);
636
+    }
637
+	else
638
+	{
639
+		if (++error_count == MAX_ERROR_COUNT)
640
+		    app_start();
641
+    }
642
+}
643
+
644
+
645
+void nothing_response(void)
646
+{
647
+    if (getch() == ' ')
648
+	{
649
+		putch(0x14);
650
+		putch(0x10);
651
+    }
652
+	else
653
+	{
654
+		if (++error_count == MAX_ERROR_COUNT)
655
+		    app_start();
656
+    }
657
+}
658
+
659
+#ifdef ADABOOT
660
+
661
+void flash_led(uint8_t count)
662
+{
663
+    /* flash onboard LED count times to signal entering of bootloader */
664
+	/* l needs to be volatile or the delay loops below might get      */
665
+	/* optimized away if compiling with optimizations (DAM).          */
666
+	
667
+    volatile uint32_t l;
668
+
669
+    if (count == 0) {
670
+      count = ADABOOT;
671
+    }
672
+    
673
+
674
+	int8_t i;
675
+    for (i = 0; i < count; ++i) {
676
+		LED_PORT |= _BV(LED);					// LED on
677
+		for(l = 0; l < (F_CPU / 1000); ++l);		// delay NGvalue was 1000 for both loops - BBR
678
+		LED_PORT &= ~_BV(LED);					// LED off
679
+		for(l = 0; l < (F_CPU / 250); ++l);		// delay asymmteric for ADA BOOT BBR 
680
+	}
681
+
682
+	for(l = 0; l < (F_CPU / 100); ++l);		    // pause ADA BOOT BBR 
683
+		
684
+}
685
+
686
+#else
687
+
688
+void flash_led(uint8_t count)
689
+{
690
+    /* flash onboard LED three times to signal entering of bootloader */
691
+	/* l needs to be volatile or the delay loops below might get
692
+	optimized away if compiling with optimizations (DAM). */
693
+    volatile uint32_t l;
694
+
695
+    if (count == 0) {
696
+      count = 3;
697
+    }
698
+    
699
+	int8_t i;
700
+    for (i = 0; i < count; ++i) {
701
+		LED_PORT |= _BV(LED);
702
+		for(l = 0; l < (F_CPU / 1000); ++l);
703
+		LED_PORT &= ~_BV(LED);
704
+		for(l = 0; l < (F_CPU / 1000); ++l); 
705
+	}
706
+		
707
+}
708
+
709
+
710
+#endif
711
+
712
+
713
+/* end of file ATmegaBOOT.c */

+ 121
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT_324P.hex Dosyayı Görüntüle

@@ -0,0 +1,121 @@
1
+:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
2
+:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
3
+:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
4
+:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
5
+:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
6
+:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
7
+:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
8
+:10F870000C945B7C0C945B7C0C945B7C11241FBE11
9
+:10F88000CFEFD8E0DEBFCDBF11E0A0E0B1E0E6E60B
10
+:10F89000FFEF02C005900D92A030B107D9F712E03A
11
+:10F8A000A0E0B1E001C01D92A930B107E1F70E94CC
12
+:10F8B000537D0C94B27F0C94007CCF93DF93CDB733
13
+:10F8C000DEB724970FB6F894DEBF0FBECDBF8823F6
14
+:10F8D00009F481E020E0482F55274115510509F42E
15
+:10F8E0003DC0289A19821A821B821C820BC0898112
16
+:10F8F0009A81AB81BC810196A11DB11D89839A8338
17
+:10F90000AB83BC8389819A81AB81BC8180589E4343
18
+:10F91000A040B04060F3289819821A821B821C8292
19
+:10F920000BC089819A81AB81BC810196A11DB11D5B
20
+:10F9300089839A83AB83BC8389819A81AB81BC81A3
21
+:10F9400080509A4FA040B04060F32F5F822F9927DC
22
+:10F9500087FD9095841795070CF4C3CF19821A82FE
23
+:10F960001B821C8289819A81AB81BC818050914726
24
+:10F97000A240B040A0F489819A81AB81BC810196FC
25
+:10F98000A11DB11D89839A83AB83BC8389819A8130
26
+:10F99000AB81BC8180509147A240B04060F3249677
27
+:10F9A0000FB6F894DEBF0FBECDBFDF91CF910895A3
28
+:10F9B000EF92FF920F931F93EE24FF248701289864
29
+:10F9C0008091C00087FD17C00894E11CF11C011D47
30
+:10F9D000111D81E0E81689E0F8068DE3080780E054
31
+:10F9E000180770F3E0910001F091010109958091F1
32
+:10F9F000C00087FFE9CF289A8091C600992787FD2C
33
+:10FA000090951F910F91FF90EF900895982F8091FE
34
+:10FA1000C00085FFFCCF9093C60008950E94D87C5B
35
+:10FA2000803271F0809102018F5F809302018530F6
36
+:10FA300009F00895E0910001F09101010995089500
37
+:10FA400084E10E94067D80E10E94067D0895CF93A7
38
+:10FA5000C82F0E94D87C803241F0809102018F5FD4
39
+:10FA600080930201853081F40AC084E10E94067D02
40
+:10FA70008C2F0E94067D80E10E94067D05C0E091EA
41
+:10FA80000001F09101010995CF910895282F90E090
42
+:10FA900007C08091C0008823E4F78091C6009F5F73
43
+:10FAA0009217B8F30895CFEFD8E0DEBFCDBF0000C6
44
+:10FAB00094B714BE809160008861809360001092BA
45
+:10FAC000600091FF74C189E18093C4001092C50069
46
+:10FAD00088E18093C10086E08093C2005098589AD4
47
+:10FAE000209A83E00E945D7C81E00E945D7C0E9400
48
+:10FAF000D87C8033B9F18133C1F1803409F456C028
49
+:10FB0000813409F45CC0823409F46EC0853409F490
50
+:10FB100071C0803539F1813509F4F3C0823511F1B6
51
+:10FB2000853509F4D3C0863509F4CBC0843609F491
52
+:10FB300065C0843709F4EBC0853709F4D2C0863735
53
+:10FB400009F44AC0809102018F5F809302018530E1
54
+:10FB500071F6E0910001F091010109950E94D87CB5
55
+:10FB6000803349F60E940E7DC2CF0E94D87CC82FF8
56
+:10FB7000803241F784E10E94067D81E40E94067D87
57
+:10FB800086E50E94067D82E50E94067D8C2F0E94FC
58
+:10FB9000067D89E40E94067D83E50E94067D80E55E
59
+:10FBA0000E94067D80E10E94067DA1CF0E94D87C44
60
+:10FBB0008638C0F20E94D87C0E940E7D98CF0E94A9
61
+:10FBC000D87C803809F407C1813809F400C1823833
62
+:10FBD00009F4F9C0883921F080E00E94277D87CFA1
63
+:10FBE00083E00E94277D83CF84E10E94467D0E94AE
64
+:10FBF0000E7D7DCF85E00E94467DF9CF0E94D87CA6
65
+:10FC0000809306020E94D87C8093050280910802AE
66
+:10FC10008E7F809308020E94D87C853409F44BC003
67
+:10FC2000E5E0F1E0119281E0E438F807D9F3D0F390
68
+:10FC3000C0E0D0E0809105029091060218161906E6
69
+:10FC400078F405E011E00E94D87CF80181938F01DF
70
+:10FC500021968091050290910602C817D90798F362
71
+:10FC60000E94D87C803209F06DCF8091080280FF1D
72
+:10FC7000B6C0C0E0D0E02091050230910602121615
73
+:10FC80001306B8F4E0910301F0910401A5E0B1E09E
74
+:10FC9000F999FECFF2BDE1BD8D9180BDFA9AF99A36
75
+:10FCA00031962196C217D30798F3F0930401E0939D
76
+:10FCB000030184E175CF809108028160809308027E
77
+:10FCC000AFCF84E00E94467D80E087CF0E94D87C41
78
+:10FCD000809303010E94D87C809304010E940E7DD2
79
+:10FCE00006CF0E94D87C803209F02CCF84E10E949C
80
+:10FCF000067D8EE10E94067D85E90E94067D88E0F2
81
+:10FD00004FCF0E940E7D88E080936000FFCF0E945D
82
+:10FD1000D87C809306020E94D87C809305020E94C2
83
+:10FD2000D87C853409F449C0809108028E7F809385
84
+:10FD300008028091030190910401880F991F90930C
85
+:10FD40000401809303010E94D87C803209F0CFCE59
86
+:10FD500084E10E94067DC0E0D0E020910502309150
87
+:10FD600006021216130608F01DCFE0910301F09170
88
+:10FD700004018091080280FF96C0F999FECFF2BD80
89
+:10FD8000E1BDF89A80B50E94067DE0910301F091F3
90
+:10FD900004013196F0930401E093030120910502E0
91
+:10FDA000309106022196C217D30718F3FBCEE091DB
92
+:10FDB0000001F0910101099586CE809108028160D1
93
+:10FDC00080930802C0CF80E10E94277D90CE81E021
94
+:10FDD0000E94277D8CCE82E00E94277D88CE809174
95
+:10FDE000030190910401880F991F9093040180935F
96
+:10FDF00003018091050280FF09C080910502909166
97
+:10FE0000060201969093060280930502F999FECFAF
98
+:10FE10001127E0910301F0910401C5E0D1E0809148
99
+:10FE2000050290910602103091F400915700017084
100
+:10FE30000130D9F303E000935700E8950091570093
101
+:10FE400001700130D9F301E100935700E895099062
102
+:10FE500019900091570001700130D9F301E000932F
103
+:10FE60005700E8951395103898F011270091570026
104
+:10FE700001700130D9F305E000935700E895009137
105
+:10FE8000570001700130D9F301E100935700E89564
106
+:10FE90003296029709F0C7CF103011F00296E5CFE5
107
+:10FEA000112484E17DCE869580FF06C03196F093C3
108
+:10FEB0000401E093030176CF84910E94067D209196
109
+:10FEC000050230910602E0910301F0910401EECFAA
110
+:10FED0001F93CF930E94D87CC82F0E94067D0E945A
111
+:10FEE000D87C182F0E94067DC1362CF0C7551136DC
112
+:10FEF0003CF0175508C0C033D4F3C0531136CCF7CB
113
+:10FF000010330CF01053C295C07FC10F8C2F99276E
114
+:10FF100087FD9095CF911F910895CF93282F992712
115
+:10FF200087FD9095807F907095958795959587959D
116
+:10FF300095958795959587958A303CF0895AC22F7B
117
+:10FF4000CF70CA303CF0C95A06C0805DC22FCF7056
118
+:10FF5000CA30CCF7C05D0E94067D8C2F0E94067DC2
119
+:06FF6000CF910895FFCFD0
120
+:040000030000F80001
121
+:00000001FF

+ 120
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT_644.hex Dosyayı Görüntüle

@@ -0,0 +1,120 @@
1
+:10F800000C94387C0C94557C0C94557C0C94557C51
2
+:10F810000C94557C0C94557C0C94557C0C94557C24
3
+:10F820000C94557C0C94557C0C94557C0C94557C14
4
+:10F830000C94557C0C94557C0C94557C0C94557C04
5
+:10F840000C94557C0C94557C0C94557C0C94557CF4
6
+:10F850000C94557C0C94557C0C94557C0C94557CE4
7
+:10F860000C94557C0C94557C0C94557C0C94557CD4
8
+:10F8700011241FBECFEFD0E1DEBFCDBF11E0A0E06D
9
+:10F88000B1E0EAE5FFEF02C005900D92A030B107AC
10
+:10F89000D9F712E0A0E0B1E001C01D92A930B10794
11
+:10F8A000E1F70E944D7D0C94AC7F0C94007CCF93CB
12
+:10F8B000DF93CDB7DEB724970FB6F894DEBF0FBE47
13
+:10F8C000CDBF882309F481E020E0482F552741155A
14
+:10F8D000510509F43DC0289A19821A821B821C82A4
15
+:10F8E0000BC089819A81AB81BC810196A11DB11D9C
16
+:10F8F00089839A83AB83BC8389819A81AB81BC81E4
17
+:10F9000080589E43A040B04060F3289819821A8224
18
+:10F910001B821C820BC089819A81AB81BC810196BC
19
+:10F92000A11DB11D89839A83AB83BC8389819A8190
20
+:10F93000AB81BC8180509A4FA040B04060F32F5FF4
21
+:10F94000822F992787FD9095841795070CF4C3CFD4
22
+:10F9500019821A821B821C8289819A81AB81BC81A7
23
+:10F9600080509147A240B040A0F489819A81AB8138
24
+:10F97000BC810196A11DB11D89839A83AB83BC8391
25
+:10F9800089819A81AB81BC8180509147A240B0406F
26
+:10F9900060F324960FB6F894DEBF0FBECDBFDF91A3
27
+:10F9A000CF910895EF92FF920F931F93EE24FF24BF
28
+:10F9B000870128988091C00087FD17C00894E11C3A
29
+:10F9C000F11C011D111D81E0E81689E0F8068DE3A8
30
+:10F9D000080780E0180770F3E0910001F091010141
31
+:10F9E00009958091C00087FFE9CF289A8091C600D1
32
+:10F9F000992787FD90951F910F91FF90EF900895A3
33
+:10FA0000982F8091C00085FFFCCF9093C600089589
34
+:10FA10000E94D27C803271F0809102018F5F8093CE
35
+:10FA20000201853009F00895E0910001F091010193
36
+:10FA30000995089584E10E94007D80E10E94007D87
37
+:10FA40000895CF93C82F0E94D27C803241F08091DC
38
+:10FA500002018F5F80930201853081F40AC084E146
39
+:10FA60000E94007D8C2F0E94007D80E10E94007D1D
40
+:10FA700005C0E0910001F09101010995CF91089531
41
+:10FA8000282F90E007C08091C0008823E4F7809180
42
+:10FA9000C6009F5F9217B8F30895CFEFD0E1DEBFA5
43
+:10FAA000CDBF000094B714BE809160008861809340
44
+:10FAB00060001092600091FF74C189E18093C400DE
45
+:10FAC0001092C50088E18093C10086E08093C20057
46
+:10FAD0005098589A209A83E00E94577C81E00E94B7
47
+:10FAE000577C0E94D27C8033B9F18133C1F18034DC
48
+:10FAF00009F456C0813409F45CC0823409F46EC044
49
+:10FB0000853409F471C0803539F1813509F4F3C0C9
50
+:10FB1000823511F1853509F4D3C0863509F4CBC09F
51
+:10FB2000843609F465C0843709F4EBC0853709F4DD
52
+:10FB3000D2C0863709F44AC0809102018F5F80935A
53
+:10FB40000201853071F6E0910001F0910101099503
54
+:10FB50000E94D27C803349F60E94087DC2CF0E9469
55
+:10FB6000D27CC82F803241F784E10E94007D81E47D
56
+:10FB70000E94007D86E50E94007D82E50E94007D56
57
+:10FB80008C2F0E94007D89E40E94007D83E50E9405
58
+:10FB9000007D80E50E94007D80E10E94007DA1CF74
59
+:10FBA0000E94D27C8638C0F20E94D27C0E94087DDE
60
+:10FBB00098CF0E94D27C803809F407C1813809F4BB
61
+:10FBC00000C1823809F4F9C0883921F080E00E9430
62
+:10FBD000217D87CF83E00E94217D83CF84E10E9435
63
+:10FBE000407D0E94087D7DCF85E00E94407DF9CF59
64
+:10FBF0000E94D27C809306020E94D27C80930502F0
65
+:10FC0000809108028E7F809308020E94D27C853406
66
+:10FC100009F44BC0E5E0F1E0119281E0E438F80727
67
+:10FC2000D9F3D0F3C0E0D0E08091050290910602B4
68
+:10FC30001816190678F405E011E00E94D27CF8014C
69
+:10FC400081938F0121968091050290910602C81739
70
+:10FC5000D90798F30E94D27C803209F06DCF809151
71
+:10FC6000080280FFB6C0C0E0D0E0209105023091CC
72
+:10FC7000060212161306B8F4E0910301F091040194
73
+:10FC8000A5E0B1E0F999FECFF2BDE1BD8D9180BD57
74
+:10FC9000FA9AF99A31962196C217D30798F3F093FE
75
+:10FCA0000401E093030184E175CF80910802816033
76
+:10FCB00080930802AFCF84E00E94407D80E087CF30
77
+:10FCC0000E94D27C809303010E94D27C8093040125
78
+:10FCD0000E94087D06CF0E94D27C803209F02CCF92
79
+:10FCE00084E10E94007D8EE10E94007D86E90E94F1
80
+:10FCF000007D89E04FCF0E94087D88E080936000FE
81
+:10FD0000FFCF0E94D27C809306020E94D27C809317
82
+:10FD100005020E94D27C853409F449C08091080212
83
+:10FD20008E7F809308028091030190910401880FD7
84
+:10FD3000991F90930401809303010E94D27C80322A
85
+:10FD400009F0CFCE84E10E94007DC0E0D0E0209198
86
+:10FD50000502309106021216130608F01DCFE0913D
87
+:10FD60000301F09104018091080280FF96C0F99987
88
+:10FD7000FECFF2BDE1BDF89A80B50E94007DE09112
89
+:10FD80000301F09104013196F0930401E093030123
90
+:10FD900020910502309106022196C217D30718F36D
91
+:10FDA000FBCEE0910001F0910101099586CE809192
92
+:10FDB0000802816080930802C0CF80E10E94217D0B
93
+:10FDC00090CE81E00E94217D8CCE82E00E94217D38
94
+:10FDD00088CE8091030190910401880F991F909320
95
+:10FDE0000401809303018091050280FF09C0809186
96
+:10FDF00005029091060201969093060280930502F7
97
+:10FE0000F999FECF1127E0910301F0910401C5E0BB
98
+:10FE1000D1E08091050290910602103091F400919A
99
+:10FE2000570001700130D9F303E000935700E895C3
100
+:10FE30000091570001700130D9F301E100935700A0
101
+:10FE4000E895099019900091570001700130D9F39D
102
+:10FE500001E000935700E8951395103898F01127AA
103
+:10FE60000091570001700130D9F305E0009357006D
104
+:10FE7000E8950091570001700130D9F301E100933A
105
+:10FE80005700E8953296029709F0C7CF103011F06D
106
+:10FE90000296E5CF112484E17DCE869580FF06C0D1
107
+:10FEA0003196F0930401E093030176CF84910E9490
108
+:10FEB000007D2091050230910602E0910301F0914E
109
+:10FEC0000401EECF1F93CF930E94D27CC82F0E94D3
110
+:10FED000007D0E94D27C182F0E94007DC1362CF03C
111
+:10FEE000C75511363CF0175508C0C033D4F3C05382
112
+:10FEF0001136CCF710330CF01053C295C07FC10FF0
113
+:10FF00008C2F992787FD9095CF911F910895CF93BE
114
+:10FF1000282F992787FD9095807F907095958795DC
115
+:10FF20009595879595958795959587958A303CF019
116
+:10FF3000895AC22FCF70CA303CF0C95A06C0805DC2
117
+:10FF4000C22FCF70CA30CCF7C05D0E94007D8C2FCD
118
+:0AFF50000E94007DCF910895FFCFBD
119
+:040000030000F80001
120
+:00000001FF

+ 121
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/ATmegaBOOT_644P.hex Dosyayı Görüntüle

@@ -0,0 +1,121 @@
1
+:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
2
+:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
3
+:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
4
+:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
5
+:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
6
+:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
7
+:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
8
+:10F870000C945B7C0C945B7C0C945B7C11241FBE11
9
+:10F88000CFEFD0E1DEBFCDBF11E0A0E0B1E0E6E612
10
+:10F89000FFEF02C005900D92A030B107D9F712E03A
11
+:10F8A000A0E0B1E001C01D92A930B107E1F70E94CC
12
+:10F8B000537D0C94B27F0C94007CCF93DF93CDB733
13
+:10F8C000DEB724970FB6F894DEBF0FBECDBF8823F6
14
+:10F8D00009F481E020E0482F55274115510509F42E
15
+:10F8E0003DC0289A19821A821B821C820BC0898112
16
+:10F8F0009A81AB81BC810196A11DB11D89839A8338
17
+:10F90000AB83BC8389819A81AB81BC8180589E4343
18
+:10F91000A040B04060F3289819821A821B821C8292
19
+:10F920000BC089819A81AB81BC810196A11DB11D5B
20
+:10F9300089839A83AB83BC8389819A81AB81BC81A3
21
+:10F9400080509A4FA040B04060F32F5F822F9927DC
22
+:10F9500087FD9095841795070CF4C3CF19821A82FE
23
+:10F960001B821C8289819A81AB81BC818050914726
24
+:10F97000A240B040A0F489819A81AB81BC810196FC
25
+:10F98000A11DB11D89839A83AB83BC8389819A8130
26
+:10F99000AB81BC8180509147A240B04060F3249677
27
+:10F9A0000FB6F894DEBF0FBECDBFDF91CF910895A3
28
+:10F9B000EF92FF920F931F93EE24FF248701289864
29
+:10F9C0008091C00087FD17C00894E11CF11C011D47
30
+:10F9D000111D81E0E81689E0F8068DE3080780E054
31
+:10F9E000180770F3E0910001F091010109958091F1
32
+:10F9F000C00087FFE9CF289A8091C600992787FD2C
33
+:10FA000090951F910F91FF90EF900895982F8091FE
34
+:10FA1000C00085FFFCCF9093C60008950E94D87C5B
35
+:10FA2000803271F0809102018F5F809302018530F6
36
+:10FA300009F00895E0910001F09101010995089500
37
+:10FA400084E10E94067D80E10E94067D0895CF93A7
38
+:10FA5000C82F0E94D87C803241F0809102018F5FD4
39
+:10FA600080930201853081F40AC084E10E94067D02
40
+:10FA70008C2F0E94067D80E10E94067D05C0E091EA
41
+:10FA80000001F09101010995CF910895282F90E090
42
+:10FA900007C08091C0008823E4F78091C6009F5F73
43
+:10FAA0009217B8F30895CFEFD0E1DEBFCDBF0000CD
44
+:10FAB00094B714BE809160008861809360001092BA
45
+:10FAC000600091FF74C189E18093C4001092C50069
46
+:10FAD00088E18093C10086E08093C2005098589AD4
47
+:10FAE000209A83E00E945D7C81E00E945D7C0E9400
48
+:10FAF000D87C8033B9F18133C1F1803409F456C028
49
+:10FB0000813409F45CC0823409F46EC0853409F490
50
+:10FB100071C0803539F1813509F4F3C0823511F1B6
51
+:10FB2000853509F4D3C0863509F4CBC0843609F491
52
+:10FB300065C0843709F4EBC0853709F4D2C0863735
53
+:10FB400009F44AC0809102018F5F809302018530E1
54
+:10FB500071F6E0910001F091010109950E94D87CB5
55
+:10FB6000803349F60E940E7DC2CF0E94D87CC82FF8
56
+:10FB7000803241F784E10E94067D81E40E94067D87
57
+:10FB800086E50E94067D82E50E94067D8C2F0E94FC
58
+:10FB9000067D89E40E94067D83E50E94067D80E55E
59
+:10FBA0000E94067D80E10E94067DA1CF0E94D87C44
60
+:10FBB0008638C0F20E94D87C0E940E7D98CF0E94A9
61
+:10FBC000D87C803809F407C1813809F400C1823833
62
+:10FBD00009F4F9C0883921F080E00E94277D87CFA1
63
+:10FBE00083E00E94277D83CF84E10E94467D0E94AE
64
+:10FBF0000E7D7DCF85E00E94467DF9CF0E94D87CA6
65
+:10FC0000809306020E94D87C8093050280910802AE
66
+:10FC10008E7F809308020E94D87C853409F44BC003
67
+:10FC2000E5E0F1E0119281E0E438F807D9F3D0F390
68
+:10FC3000C0E0D0E0809105029091060218161906E6
69
+:10FC400078F405E011E00E94D87CF80181938F01DF
70
+:10FC500021968091050290910602C817D90798F362
71
+:10FC60000E94D87C803209F06DCF8091080280FF1D
72
+:10FC7000B6C0C0E0D0E02091050230910602121615
73
+:10FC80001306B8F4E0910301F0910401A5E0B1E09E
74
+:10FC9000F999FECFF2BDE1BD8D9180BDFA9AF99A36
75
+:10FCA00031962196C217D30798F3F0930401E0939D
76
+:10FCB000030184E175CF809108028160809308027E
77
+:10FCC000AFCF84E00E94467D80E087CF0E94D87C41
78
+:10FCD000809303010E94D87C809304010E940E7DD2
79
+:10FCE00006CF0E94D87C803209F02CCF84E10E949C
80
+:10FCF000067D8EE10E94067D86E90E94067D8AE0EF
81
+:10FD00004FCF0E940E7D88E080936000FFCF0E945D
82
+:10FD1000D87C809306020E94D87C809305020E94C2
83
+:10FD2000D87C853409F449C0809108028E7F809385
84
+:10FD300008028091030190910401880F991F90930C
85
+:10FD40000401809303010E94D87C803209F0CFCE59
86
+:10FD500084E10E94067DC0E0D0E020910502309150
87
+:10FD600006021216130608F01DCFE0910301F09170
88
+:10FD700004018091080280FF96C0F999FECFF2BD80
89
+:10FD8000E1BDF89A80B50E94067DE0910301F091F3
90
+:10FD900004013196F0930401E093030120910502E0
91
+:10FDA000309106022196C217D30718F3FBCEE091DB
92
+:10FDB0000001F0910101099586CE809108028160D1
93
+:10FDC00080930802C0CF80E10E94277D90CE81E021
94
+:10FDD0000E94277D8CCE82E00E94277D88CE809174
95
+:10FDE000030190910401880F991F9093040180935F
96
+:10FDF00003018091050280FF09C080910502909166
97
+:10FE0000060201969093060280930502F999FECFAF
98
+:10FE10001127E0910301F0910401C5E0D1E0809148
99
+:10FE2000050290910602103091F400915700017084
100
+:10FE30000130D9F303E000935700E8950091570093
101
+:10FE400001700130D9F301E100935700E895099062
102
+:10FE500019900091570001700130D9F301E000932F
103
+:10FE60005700E8951395103898F011270091570026
104
+:10FE700001700130D9F305E000935700E895009137
105
+:10FE8000570001700130D9F301E100935700E89564
106
+:10FE90003296029709F0C7CF103011F00296E5CFE5
107
+:10FEA000112484E17DCE869580FF06C03196F093C3
108
+:10FEB0000401E093030176CF84910E94067D209196
109
+:10FEC000050230910602E0910301F0910401EECFAA
110
+:10FED0001F93CF930E94D87CC82F0E94067D0E945A
111
+:10FEE000D87C182F0E94067DC1362CF0C7551136DC
112
+:10FEF0003CF0175508C0C033D4F3C0531136CCF7CB
113
+:10FF000010330CF01053C295C07FC10F8C2F99276E
114
+:10FF100087FD9095CF911F910895CF93282F992712
115
+:10FF200087FD9095807F907095958795959587959D
116
+:10FF300095958795959587958A303CF0895AC22F7B
117
+:10FF4000CF70CA303CF0C95A06C0805DC22FCF7056
118
+:10FF5000CA30CCF7C05D0E94067D8C2F0E94067DC2
119
+:06FF6000CF910895FFCFD0
120
+:040000030000F80001
121
+:00000001FF

+ 56
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/Makefile Dosyayı Görüntüle

@@ -0,0 +1,56 @@
1
+# Makefile for ATmegaBOOT
2
+# E.Lins, 18.7.2005
3
+# $Id$
4
+
5
+
6
+# program name should not be changed...
7
+PROGRAM    = ATmegaBOOT_644P
8
+
9
+# enter the target CPU frequency
10
+AVR_FREQ   = 16000000L
11
+
12
+MCU_TARGET = atmega644p
13
+LDSECTION  = --section-start=.text=0xF800
14
+
15
+OBJ        = $(PROGRAM).o
16
+OPTIMIZE   = -O2
17
+
18
+DEFS       = 
19
+LIBS       = 
20
+
21
+CC         = avr-gcc
22
+
23
+
24
+# Override is only needed by avr-lib build system.
25
+
26
+override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
27
+override LDFLAGS       = -Wl,$(LDSECTION)
28
+#override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
29
+
30
+OBJCOPY        = avr-objcopy
31
+OBJDUMP        = avr-objdump
32
+
33
+all: CFLAGS += '-DMAX_TIME_COUNT=8000000L>>1' -DADABOOT
34
+all: $(PROGRAM).hex
35
+
36
+$(PROGRAM).hex: $(PROGRAM).elf
37
+	$(OBJCOPY) -j .text -j .data -O ihex $< $@
38
+	
39
+$(PROGRAM).elf: $(OBJ)
40
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
41
+	
42
+$(OBJ): ATmegaBOOT.c
43
+	avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -O2 -Wall -mmcu=$(MCU_TARGET) ATmegaBOOT.c -o $(PROGRAM).o
44
+
45
+%.lst: %.elf
46
+	$(OBJDUMP) -h -S $< > $@
47
+
48
+%.srec: %.elf
49
+	$(OBJCOPY) -j .text -j .data -O srec $< $@
50
+
51
+%.bin: %.elf
52
+	$(OBJCOPY) -j .text -j .data -O binary $< $@
53
+
54
+clean:
55
+	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
56
+	

+ 3
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega644p/README.txt Dosyayı Görüntüle

@@ -0,0 +1,3 @@
1
+Note: This bootloader support ATmega644, ATmega644P and ATmega324P.
2
+To build, set PROGRAM and MCU_TARGET in the Makefile according to your target device.
3
+

+ 303
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/HardwareSerial.cpp Dosyayı Görüntüle

@@ -0,0 +1,303 @@
1
+/*
2
+  HardwareSerial.cpp - Hardware serial library for Wiring
3
+  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+  
19
+  Modified 23 November 2006 by David A. Mellis
20
+  Modified 28 September 2010 by Mark Sproul
21
+*/
22
+
23
+#include <stdlib.h>
24
+#include <stdio.h>
25
+#include <string.h>
26
+#include <inttypes.h>
27
+#include "wiring.h"
28
+#include "wiring_private.h"
29
+
30
+// this next line disables the entire HardwareSerial.cpp, 
31
+// this is so I can support Attiny series and any other chip without a uart
32
+#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
33
+
34
+#include "HardwareSerial.h"
35
+
36
+// Define constants and variables for buffering incoming serial data.  We're
37
+// using a ring buffer (I think), in which rx_buffer_head is the index of the
38
+// location to which to write the next incoming character and rx_buffer_tail
39
+// is the index of the location from which to read.
40
+#if (RAMEND < 1000)
41
+  #define RX_BUFFER_SIZE 32
42
+#else
43
+  #define RX_BUFFER_SIZE 128
44
+#endif
45
+
46
+struct ring_buffer
47
+{
48
+  unsigned char buffer[RX_BUFFER_SIZE];
49
+  int head;
50
+  int tail;
51
+};
52
+
53
+#if defined(UBRRH) || defined(UBRR0H)
54
+  ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
55
+#endif
56
+#if defined(UBRR1H)
57
+  ring_buffer rx_buffer1  =  { { 0 }, 0, 0 };
58
+#endif
59
+#if defined(UBRR2H)
60
+  ring_buffer rx_buffer2  =  { { 0 }, 0, 0 };
61
+#endif
62
+#if defined(UBRR3H)
63
+  ring_buffer rx_buffer3  =  { { 0 }, 0, 0 };
64
+#endif
65
+
66
+inline void store_char(unsigned char c, ring_buffer *rx_buffer)
67
+{
68
+  int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE;
69
+
70
+  // if we should be storing the received character into the location
71
+  // just before the tail (meaning that the head would advance to the
72
+  // current location of the tail), we're about to overflow the buffer
73
+  // and so we don't write the character or advance the head.
74
+  if (i != rx_buffer->tail) {
75
+    rx_buffer->buffer[rx_buffer->head] = c;
76
+    rx_buffer->head = i;
77
+  }
78
+}
79
+
80
+#if defined(USART_RX_vect)
81
+  SIGNAL(USART_RX_vect)
82
+  {
83
+  #if defined(UDR0)
84
+    unsigned char c  =  UDR0;
85
+  #elif defined(UDR)
86
+    unsigned char c  =  UDR;  //  atmega8535
87
+  #else
88
+    #error UDR not defined
89
+  #endif
90
+    store_char(c, &rx_buffer);
91
+  }
92
+#elif defined(SIG_USART0_RECV) && defined(UDR0)
93
+  SIGNAL(SIG_USART0_RECV)
94
+  {
95
+    unsigned char c  =  UDR0;
96
+    store_char(c, &rx_buffer);
97
+  }
98
+#elif defined(SIG_UART0_RECV) && defined(UDR0)
99
+  SIGNAL(SIG_UART0_RECV)
100
+  {
101
+    unsigned char c  =  UDR0;
102
+    store_char(c, &rx_buffer);
103
+  }
104
+//#elif defined(SIG_USART_RECV)
105
+#elif defined(USART0_RX_vect)
106
+  // fixed by Mark Sproul this is on the 644/644p
107
+  //SIGNAL(SIG_USART_RECV)
108
+  SIGNAL(USART0_RX_vect)
109
+  {
110
+  #if defined(UDR0)
111
+    unsigned char c  =  UDR0;
112
+  #elif defined(UDR)
113
+    unsigned char c  =  UDR;  //  atmega8, atmega32
114
+  #else
115
+    #error UDR not defined
116
+  #endif
117
+    store_char(c, &rx_buffer);
118
+  }
119
+#elif defined(SIG_UART_RECV)
120
+  // this is for atmega8
121
+  SIGNAL(SIG_UART_RECV)
122
+  {
123
+  #if defined(UDR0)
124
+    unsigned char c  =  UDR0;  //  atmega645
125
+  #elif defined(UDR)
126
+    unsigned char c  =  UDR;  //  atmega8
127
+  #endif
128
+    store_char(c, &rx_buffer);
129
+  }
130
+#elif defined(USBCON)
131
+  #warning No interrupt handler for usart 0
132
+  #warning Serial(0) is on USB interface
133
+#else
134
+  #error No interrupt handler for usart 0
135
+#endif
136
+
137
+//#if defined(SIG_USART1_RECV)
138
+#if defined(USART1_RX_vect)
139
+  //SIGNAL(SIG_USART1_RECV)
140
+  SIGNAL(USART1_RX_vect)
141
+  {
142
+    unsigned char c = UDR1;
143
+    store_char(c, &rx_buffer1);
144
+  }
145
+#elif defined(SIG_USART1_RECV)
146
+  #error SIG_USART1_RECV
147
+#endif
148
+
149
+#if defined(USART2_RX_vect) && defined(UDR2)
150
+  SIGNAL(USART2_RX_vect)
151
+  {
152
+    unsigned char c = UDR2;
153
+    store_char(c, &rx_buffer2);
154
+  }
155
+#elif defined(SIG_USART2_RECV)
156
+  #error SIG_USART2_RECV
157
+#endif
158
+
159
+#if defined(USART3_RX_vect) && defined(UDR3)
160
+  SIGNAL(USART3_RX_vect)
161
+  {
162
+    unsigned char c = UDR3;
163
+    store_char(c, &rx_buffer3);
164
+  }
165
+#elif defined(SIG_USART3_RECV)
166
+  #error SIG_USART3_RECV
167
+#endif
168
+
169
+
170
+
171
+// Constructors ////////////////////////////////////////////////////////////////
172
+
173
+HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
174
+  volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
175
+  volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
176
+  volatile uint8_t *udr,
177
+  uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
178
+{
179
+  _rx_buffer = rx_buffer;
180
+  _ubrrh = ubrrh;
181
+  _ubrrl = ubrrl;
182
+  _ucsra = ucsra;
183
+  _ucsrb = ucsrb;
184
+  _udr = udr;
185
+  _rxen = rxen;
186
+  _txen = txen;
187
+  _rxcie = rxcie;
188
+  _udre = udre;
189
+  _u2x = u2x;
190
+}
191
+
192
+// Public Methods //////////////////////////////////////////////////////////////
193
+
194
+void HardwareSerial::begin(long baud)
195
+{
196
+  uint16_t baud_setting;
197
+  bool use_u2x = true;
198
+
199
+#if F_CPU == 16000000UL
200
+  // hardcoded exception for compatibility with the bootloader shipped
201
+  // with the Duemilanove and previous boards and the firmware on the 8U2
202
+  // on the Uno and Mega 2560.
203
+  if (baud == 57600) {
204
+    use_u2x = false;
205
+  }
206
+#endif
207
+  
208
+  if (use_u2x) {
209
+    *_ucsra = 1 << _u2x;
210
+    baud_setting = (F_CPU / 4 / baud - 1) / 2;
211
+  } else {
212
+    *_ucsra = 0;
213
+    baud_setting = (F_CPU / 8 / baud - 1) / 2;
214
+  }
215
+
216
+  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
217
+  *_ubrrh = baud_setting >> 8;
218
+  *_ubrrl = baud_setting;
219
+
220
+  sbi(*_ucsrb, _rxen);
221
+  sbi(*_ucsrb, _txen);
222
+  sbi(*_ucsrb, _rxcie);
223
+}
224
+
225
+void HardwareSerial::end()
226
+{
227
+  cbi(*_ucsrb, _rxen);
228
+  cbi(*_ucsrb, _txen);
229
+  cbi(*_ucsrb, _rxcie);  
230
+}
231
+
232
+int HardwareSerial::available(void)
233
+{
234
+  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
235
+}
236
+
237
+int HardwareSerial::peek(void)
238
+{
239
+  if (_rx_buffer->head == _rx_buffer->tail) {
240
+    return -1;
241
+  } else {
242
+    return _rx_buffer->buffer[_rx_buffer->tail];
243
+  }
244
+}
245
+
246
+int HardwareSerial::read(void)
247
+{
248
+  // if the head isn't ahead of the tail, we don't have any characters
249
+  if (_rx_buffer->head == _rx_buffer->tail) {
250
+    return -1;
251
+  } else {
252
+    unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
253
+    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
254
+    return c;
255
+  }
256
+}
257
+
258
+void HardwareSerial::flush()
259
+{
260
+  // don't reverse this or there may be problems if the RX interrupt
261
+  // occurs after reading the value of rx_buffer_head but before writing
262
+  // the value to rx_buffer_tail; the previous value of rx_buffer_head
263
+  // may be written to rx_buffer_tail, making it appear as if the buffer
264
+  // don't reverse this or there may be problems if the RX interrupt
265
+  // occurs after reading the value of rx_buffer_head but before writing
266
+  // the value to rx_buffer_tail; the previous value of rx_buffer_head
267
+  // may be written to rx_buffer_tail, making it appear as if the buffer
268
+  // were full, not empty.
269
+  _rx_buffer->head = _rx_buffer->tail;
270
+}
271
+
272
+void HardwareSerial::write(uint8_t c)
273
+{
274
+  while (!((*_ucsra) & (1 << _udre)))
275
+    ;
276
+
277
+  *_udr = c;
278
+}
279
+
280
+// Preinstantiate Objects //////////////////////////////////////////////////////
281
+
282
+#if defined(UBRRH) && defined(UBRRL)
283
+  HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
284
+#elif defined(UBRR0H) && defined(UBRR0L)
285
+  HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
286
+#elif defined(USBCON)
287
+  #warning no serial port defined  (port 0)
288
+#else
289
+  #error no serial port defined  (port 0)
290
+#endif
291
+
292
+#if defined(UBRR1H)
293
+  HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
294
+#endif
295
+#if defined(UBRR2H)
296
+  HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
297
+#endif
298
+#if defined(UBRR3H)
299
+  HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
300
+#endif
301
+
302
+#endif // whole file
303
+

+ 76
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/HardwareSerial.h Dosyayı Görüntüle

@@ -0,0 +1,76 @@
1
+/*
2
+  HardwareSerial.h - Hardware serial library for Wiring
3
+  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+
19
+  Modified 28 September 2010 by Mark Sproul
20
+*/
21
+
22
+#ifndef HardwareSerial_h
23
+#define HardwareSerial_h
24
+
25
+#include <inttypes.h>
26
+
27
+#include "Stream.h"
28
+
29
+struct ring_buffer;
30
+
31
+class HardwareSerial : public Stream
32
+{
33
+  private:
34
+    ring_buffer *_rx_buffer;
35
+    volatile uint8_t *_ubrrh;
36
+    volatile uint8_t *_ubrrl;
37
+    volatile uint8_t *_ucsra;
38
+    volatile uint8_t *_ucsrb;
39
+    volatile uint8_t *_udr;
40
+    uint8_t _rxen;
41
+    uint8_t _txen;
42
+    uint8_t _rxcie;
43
+    uint8_t _udre;
44
+    uint8_t _u2x;
45
+  public:
46
+    HardwareSerial(ring_buffer *rx_buffer,
47
+      volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
48
+      volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
49
+      volatile uint8_t *udr,
50
+      uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
51
+    void begin(long);
52
+    void end();
53
+    virtual int available(void);
54
+    virtual int peek(void);
55
+    virtual int read(void);
56
+    virtual void flush(void);
57
+    virtual void write(uint8_t);
58
+    using Print::write; // pull in write(str) and write(buf, size) from Print
59
+};
60
+
61
+#if defined(UBRRH) || defined(UBRR0H)
62
+  extern HardwareSerial Serial;
63
+#elif defined(USBCON)
64
+  #include "usb_api.h"
65
+#endif
66
+#if defined(UBRR1H)
67
+  extern HardwareSerial Serial1;
68
+#endif
69
+#if defined(UBRR2H)
70
+  extern HardwareSerial Serial2;
71
+#endif
72
+#if defined(UBRR3H)
73
+  extern HardwareSerial Serial3;
74
+#endif
75
+
76
+#endif

+ 220
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Print.cpp Dosyayı Görüntüle

@@ -0,0 +1,220 @@
1
+/*
2
+ Print.cpp - Base class that provides print() and println()
3
+ Copyright (c) 2008 David A. Mellis.  All right reserved.
4
+ 
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+ 
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+ 
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ 
19
+ Modified 23 November 2006 by David A. Mellis
20
+ */
21
+
22
+#include <stdlib.h>
23
+#include <stdio.h>
24
+#include <string.h>
25
+#include <math.h>
26
+#include "wiring.h"
27
+
28
+#include "Print.h"
29
+
30
+// Public Methods //////////////////////////////////////////////////////////////
31
+
32
+/* default implementation: may be overridden */
33
+void Print::write(const char *str)
34
+{
35
+  while (*str)
36
+    write(*str++);
37
+}
38
+
39
+/* default implementation: may be overridden */
40
+void Print::write(const uint8_t *buffer, size_t size)
41
+{
42
+  while (size--)
43
+    write(*buffer++);
44
+}
45
+
46
+void Print::print(const String &s)
47
+{
48
+  for (int i = 0; i < s.length(); i++) {
49
+    write(s[i]);
50
+  }
51
+}
52
+
53
+void Print::print(const char str[])
54
+{
55
+  write(str);
56
+}
57
+
58
+void Print::print(char c, int base)
59
+{
60
+  print((long) c, base);
61
+}
62
+
63
+void Print::print(unsigned char b, int base)
64
+{
65
+  print((unsigned long) b, base);
66
+}
67
+
68
+void Print::print(int n, int base)
69
+{
70
+  print((long) n, base);
71
+}
72
+
73
+void Print::print(unsigned int n, int base)
74
+{
75
+  print((unsigned long) n, base);
76
+}
77
+
78
+void Print::print(long n, int base)
79
+{
80
+  if (base == 0) {
81
+    write(n);
82
+  } else if (base == 10) {
83
+    if (n < 0) {
84
+      print('-');
85
+      n = -n;
86
+    }
87
+    printNumber(n, 10);
88
+  } else {
89
+    printNumber(n, base);
90
+  }
91
+}
92
+
93
+void Print::print(unsigned long n, int base)
94
+{
95
+  if (base == 0) write(n);
96
+  else printNumber(n, base);
97
+}
98
+
99
+void Print::print(double n, int digits)
100
+{
101
+  printFloat(n, digits);
102
+}
103
+
104
+void Print::println(void)
105
+{
106
+  print('\r');
107
+  print('\n');  
108
+}
109
+
110
+void Print::println(const String &s)
111
+{
112
+  print(s);
113
+  println();
114
+}
115
+
116
+void Print::println(const char c[])
117
+{
118
+  print(c);
119
+  println();
120
+}
121
+
122
+void Print::println(char c, int base)
123
+{
124
+  print(c, base);
125
+  println();
126
+}
127
+
128
+void Print::println(unsigned char b, int base)
129
+{
130
+  print(b, base);
131
+  println();
132
+}
133
+
134
+void Print::println(int n, int base)
135
+{
136
+  print(n, base);
137
+  println();
138
+}
139
+
140
+void Print::println(unsigned int n, int base)
141
+{
142
+  print(n, base);
143
+  println();
144
+}
145
+
146
+void Print::println(long n, int base)
147
+{
148
+  print(n, base);
149
+  println();
150
+}
151
+
152
+void Print::println(unsigned long n, int base)
153
+{
154
+  print(n, base);
155
+  println();
156
+}
157
+
158
+void Print::println(double n, int digits)
159
+{
160
+  print(n, digits);
161
+  println();
162
+}
163
+
164
+// Private Methods /////////////////////////////////////////////////////////////
165
+
166
+void Print::printNumber(unsigned long n, uint8_t base)
167
+{
168
+  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
169
+  unsigned long i = 0;
170
+
171
+  if (n == 0) {
172
+    print('0');
173
+    return;
174
+  } 
175
+
176
+  while (n > 0) {
177
+    buf[i++] = n % base;
178
+    n /= base;
179
+  }
180
+
181
+  for (; i > 0; i--)
182
+    print((char) (buf[i - 1] < 10 ?
183
+      '0' + buf[i - 1] :
184
+      'A' + buf[i - 1] - 10));
185
+}
186
+
187
+void Print::printFloat(double number, uint8_t digits) 
188
+{ 
189
+  // Handle negative numbers
190
+  if (number < 0.0)
191
+  {
192
+     print('-');
193
+     number = -number;
194
+  }
195
+
196
+  // Round correctly so that print(1.999, 2) prints as "2.00"
197
+  double rounding = 0.5;
198
+  for (uint8_t i=0; i<digits; ++i)
199
+    rounding /= 10.0;
200
+  
201
+  number += rounding;
202
+
203
+  // Extract the integer part of the number and print it
204
+  unsigned long int_part = (unsigned long)number;
205
+  double remainder = number - (double)int_part;
206
+  print(int_part);
207
+
208
+  // Print the decimal point, but only if there are digits beyond
209
+  if (digits > 0)
210
+    print("."); 
211
+
212
+  // Extract digits from the remainder one at a time
213
+  while (digits-- > 0)
214
+  {
215
+    remainder *= 10.0;
216
+    int toPrint = int(remainder);
217
+    print(toPrint);
218
+    remainder -= toPrint; 
219
+  } 
220
+}

+ 66
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Print.h Dosyayı Görüntüle

@@ -0,0 +1,66 @@
1
+/*
2
+  Print.h - Base class that provides print() and println()
3
+  Copyright (c) 2008 David A. Mellis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef Print_h
21
+#define Print_h
22
+
23
+#include <inttypes.h>
24
+#include <stdio.h> // for size_t
25
+
26
+#include "WString.h"
27
+
28
+#define DEC 10
29
+#define HEX 16
30
+#define OCT 8
31
+#define BIN 2
32
+#define BYTE 0
33
+
34
+class Print
35
+{
36
+  private:
37
+    void printNumber(unsigned long, uint8_t);
38
+    void printFloat(double, uint8_t);
39
+  public:
40
+    virtual void write(uint8_t) = 0;
41
+    virtual void write(const char *str);
42
+    virtual void write(const uint8_t *buffer, size_t size);
43
+    
44
+    void print(const String &);
45
+    void print(const char[]);
46
+    void print(char, int = BYTE);
47
+    void print(unsigned char, int = BYTE);
48
+    void print(int, int = DEC);
49
+    void print(unsigned int, int = DEC);
50
+    void print(long, int = DEC);
51
+    void print(unsigned long, int = DEC);
52
+    void print(double, int = 2);
53
+
54
+    void println(const String &s);
55
+    void println(const char[]);
56
+    void println(char, int = BYTE);
57
+    void println(unsigned char, int = BYTE);
58
+    void println(int, int = DEC);
59
+    void println(unsigned int, int = DEC);
60
+    void println(long, int = DEC);
61
+    void println(unsigned long, int = DEC);
62
+    void println(double, int = 2);
63
+    void println(void);
64
+};
65
+
66
+#endif

+ 35
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Stream.h Dosyayı Görüntüle

@@ -0,0 +1,35 @@
1
+/*
2
+  Stream.h - base class for character-based streams.
3
+  Copyright (c) 2010 David A. Mellis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef Stream_h
21
+#define Stream_h
22
+
23
+#include <inttypes.h>
24
+#include "Print.h"
25
+
26
+class Stream : public Print
27
+{
28
+  public:
29
+    virtual int available() = 0;
30
+    virtual int read() = 0;
31
+    virtual int peek() = 0;
32
+    virtual void flush() = 0;
33
+};
34
+
35
+#endif

+ 601
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Tone.cpp Dosyayı Görüntüle

@@ -0,0 +1,601 @@
1
+/* Tone.cpp
2
+
3
+  A Tone Generator Library
4
+
5
+  Written by Brett Hagman
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General Public
18
+  License along with this library; if not, write to the Free Software
19
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
+
21
+Version Modified By Date     Comments
22
+------- ----------- -------- --------
23
+0001    B Hagman    09/08/02 Initial coding
24
+0002    B Hagman    09/08/18 Multiple pins
25
+0003    B Hagman    09/08/18 Moved initialization from constructor to begin()
26
+0004    B Hagman    09/09/26 Fixed problems with ATmega8
27
+0005    B Hagman    09/11/23 Scanned prescalars for best fit on 8 bit timers
28
+                    09/11/25 Changed pin toggle method to XOR
29
+                    09/11/25 Fixed timer0 from being excluded
30
+0006    D Mellis    09/12/29 Replaced objects with functions
31
+0007    M Sproul    10/08/29 Changed #ifdefs from cpu to register
32
+*************************************************/
33
+
34
+#include <avr/interrupt.h>
35
+#include <avr/pgmspace.h>
36
+#include "wiring.h"
37
+#include "pins_arduino.h"
38
+
39
+#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
40
+#define TCCR2A TCCR2
41
+#define TCCR2B TCCR2
42
+#define COM2A1 COM21
43
+#define COM2A0 COM20
44
+#define OCR2A OCR2
45
+#define TIMSK2 TIMSK
46
+#define OCIE2A OCIE2
47
+#define TIMER2_COMPA_vect TIMER2_COMP_vect
48
+#define TIMSK1 TIMSK
49
+#endif
50
+
51
+// timerx_toggle_count:
52
+//  > 0 - duration specified
53
+//  = 0 - stopped
54
+//  < 0 - infinitely (until stop() method called, or new play() called)
55
+
56
+#if !defined(__AVR_ATmega8__)
57
+volatile long timer0_toggle_count;
58
+volatile uint8_t *timer0_pin_port;
59
+volatile uint8_t timer0_pin_mask;
60
+#endif
61
+
62
+volatile long timer1_toggle_count;
63
+volatile uint8_t *timer1_pin_port;
64
+volatile uint8_t timer1_pin_mask;
65
+volatile long timer2_toggle_count;
66
+volatile uint8_t *timer2_pin_port;
67
+volatile uint8_t timer2_pin_mask;
68
+
69
+#if defined(TIMSK3)
70
+volatile long timer3_toggle_count;
71
+volatile uint8_t *timer3_pin_port;
72
+volatile uint8_t timer3_pin_mask;
73
+#endif
74
+
75
+#if defined(TIMSK4)
76
+volatile long timer4_toggle_count;
77
+volatile uint8_t *timer4_pin_port;
78
+volatile uint8_t timer4_pin_mask;
79
+#endif
80
+
81
+#if defined(TIMSK5)
82
+volatile long timer5_toggle_count;
83
+volatile uint8_t *timer5_pin_port;
84
+volatile uint8_t timer5_pin_mask;
85
+#endif
86
+
87
+
88
+// MLS: This does not make sense, the 3 options are the same
89
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
90
+
91
+#define AVAILABLE_TONE_PINS 1
92
+
93
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
94
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
95
+
96
+#elif defined(__AVR_ATmega8__)
97
+
98
+#define AVAILABLE_TONE_PINS 1
99
+
100
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
101
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
102
+
103
+#else
104
+
105
+#define AVAILABLE_TONE_PINS 1
106
+
107
+// Leave timer 0 to last.
108
+const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
109
+static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
110
+
111
+#endif
112
+
113
+
114
+
115
+static int8_t toneBegin(uint8_t _pin)
116
+{
117
+  int8_t _timer = -1;
118
+
119
+  // if we're already using the pin, the timer should be configured.  
120
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
121
+    if (tone_pins[i] == _pin) {
122
+      return pgm_read_byte(tone_pin_to_timer_PGM + i);
123
+    }
124
+  }
125
+  
126
+  // search for an unused timer.
127
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
128
+    if (tone_pins[i] == 255) {
129
+      tone_pins[i] = _pin;
130
+      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
131
+      break;
132
+    }
133
+  }
134
+  
135
+  if (_timer != -1)
136
+  {
137
+    // Set timer specific stuff
138
+    // All timers in CTC mode
139
+    // 8 bit timers will require changing prescalar values,
140
+    // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
141
+    switch (_timer)
142
+    {
143
+      #if defined(TCCR0A) && defined(TCCR0B)
144
+      case 0:
145
+        // 8 bit timer
146
+        TCCR0A = 0;
147
+        TCCR0B = 0;
148
+        bitWrite(TCCR0A, WGM01, 1);
149
+        bitWrite(TCCR0B, CS00, 1);
150
+        timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
151
+        timer0_pin_mask = digitalPinToBitMask(_pin);
152
+        break;
153
+      #endif
154
+
155
+      #if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12)
156
+      case 1:
157
+        // 16 bit timer
158
+        TCCR1A = 0;
159
+        TCCR1B = 0;
160
+        bitWrite(TCCR1B, WGM12, 1);
161
+        bitWrite(TCCR1B, CS10, 1);
162
+        timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
163
+        timer1_pin_mask = digitalPinToBitMask(_pin);
164
+        break;
165
+      #endif
166
+
167
+      #if defined(TCCR2A) && defined(TCCR2B)
168
+      case 2:
169
+        // 8 bit timer
170
+        TCCR2A = 0;
171
+        TCCR2B = 0;
172
+        bitWrite(TCCR2A, WGM21, 1);
173
+        bitWrite(TCCR2B, CS20, 1);
174
+        timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
175
+        timer2_pin_mask = digitalPinToBitMask(_pin);
176
+        break;
177
+      #endif
178
+
179
+      #if defined(TCCR3A) && defined(TCCR3B) &&  defined(TIMSK3)
180
+      case 3:
181
+        // 16 bit timer
182
+        TCCR3A = 0;
183
+        TCCR3B = 0;
184
+        bitWrite(TCCR3B, WGM32, 1);
185
+        bitWrite(TCCR3B, CS30, 1);
186
+        timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
187
+        timer3_pin_mask = digitalPinToBitMask(_pin);
188
+        break;
189
+      #endif
190
+
191
+      #if defined(TCCR4A) && defined(TCCR4B) &&  defined(TIMSK4)
192
+      case 4:
193
+        // 16 bit timer
194
+        TCCR4A = 0;
195
+        TCCR4B = 0;
196
+        #if defined(WGM42)
197
+          bitWrite(TCCR4B, WGM42, 1);
198
+        #elif defined(CS43)
199
+          #warning this may not be correct
200
+          // atmega32u4
201
+          bitWrite(TCCR4B, CS43, 1);
202
+        #endif
203
+        bitWrite(TCCR4B, CS40, 1);
204
+        timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
205
+        timer4_pin_mask = digitalPinToBitMask(_pin);
206
+        break;
207
+      #endif
208
+
209
+      #if defined(TCCR5A) && defined(TCCR5B) &&  defined(TIMSK5)
210
+      case 5:
211
+        // 16 bit timer
212
+        TCCR5A = 0;
213
+        TCCR5B = 0;
214
+        bitWrite(TCCR5B, WGM52, 1);
215
+        bitWrite(TCCR5B, CS50, 1);
216
+        timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
217
+        timer5_pin_mask = digitalPinToBitMask(_pin);
218
+        break;
219
+      #endif
220
+    }
221
+  }
222
+
223
+  return _timer;
224
+}
225
+
226
+
227
+
228
+// frequency (in hertz) and duration (in milliseconds).
229
+
230
+void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
231
+{
232
+  uint8_t prescalarbits = 0b001;
233
+  long toggle_count = 0;
234
+  uint32_t ocr = 0;
235
+  int8_t _timer;
236
+
237
+  _timer = toneBegin(_pin);
238
+
239
+  if (_timer >= 0)
240
+  {
241
+    // Set the pinMode as OUTPUT
242
+    pinMode(_pin, OUTPUT);
243
+    
244
+    // if we are using an 8 bit timer, scan through prescalars to find the best fit
245
+    if (_timer == 0 || _timer == 2)
246
+    {
247
+      ocr = F_CPU / frequency / 2 - 1;
248
+      prescalarbits = 0b001;  // ck/1: same for both timers
249
+      if (ocr > 255)
250
+      {
251
+        ocr = F_CPU / frequency / 2 / 8 - 1;
252
+        prescalarbits = 0b010;  // ck/8: same for both timers
253
+
254
+        if (_timer == 2 && ocr > 255)
255
+        {
256
+          ocr = F_CPU / frequency / 2 / 32 - 1;
257
+          prescalarbits = 0b011;
258
+        }
259
+
260
+        if (ocr > 255)
261
+        {
262
+          ocr = F_CPU / frequency / 2 / 64 - 1;
263
+          prescalarbits = _timer == 0 ? 0b011 : 0b100;
264
+
265
+          if (_timer == 2 && ocr > 255)
266
+          {
267
+            ocr = F_CPU / frequency / 2 / 128 - 1;
268
+            prescalarbits = 0b101;
269
+          }
270
+
271
+          if (ocr > 255)
272
+          {
273
+            ocr = F_CPU / frequency / 2 / 256 - 1;
274
+            prescalarbits = _timer == 0 ? 0b100 : 0b110;
275
+            if (ocr > 255)
276
+            {
277
+              // can't do any better than /1024
278
+              ocr = F_CPU / frequency / 2 / 1024 - 1;
279
+              prescalarbits = _timer == 0 ? 0b101 : 0b111;
280
+            }
281
+          }
282
+        }
283
+      }
284
+
285
+#if defined(TCCR0B)
286
+      if (_timer == 0)
287
+      {
288
+        TCCR0B = prescalarbits;
289
+      }
290
+      else
291
+#endif
292
+#if defined(TCCR2B)
293
+      {
294
+        TCCR2B = prescalarbits;
295
+      }
296
+#else
297
+      {
298
+        // dummy place holder to make the above ifdefs work
299
+      }
300
+#endif
301
+    }
302
+    else
303
+    {
304
+      // two choices for the 16 bit timers: ck/1 or ck/64
305
+      ocr = F_CPU / frequency / 2 - 1;
306
+
307
+      prescalarbits = 0b001;
308
+      if (ocr > 0xffff)
309
+      {
310
+        ocr = F_CPU / frequency / 2 / 64 - 1;
311
+        prescalarbits = 0b011;
312
+      }
313
+
314
+      if (_timer == 1)
315
+      {
316
+#if defined(TCCR1B)
317
+        TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
318
+#endif
319
+      }
320
+#if defined(TCCR3B)
321
+      else if (_timer == 3)
322
+        TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
323
+#endif
324
+#if defined(TCCR4B)
325
+      else if (_timer == 4)
326
+        TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
327
+#endif
328
+#if defined(TCCR5B)
329
+      else if (_timer == 5)
330
+        TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
331
+#endif
332
+
333
+    }
334
+    
335
+
336
+    // Calculate the toggle count
337
+    if (duration > 0)
338
+    {
339
+      toggle_count = 2 * frequency * duration / 1000;
340
+    }
341
+    else
342
+    {
343
+      toggle_count = -1;
344
+    }
345
+
346
+    // Set the OCR for the given timer,
347
+    // set the toggle count,
348
+    // then turn on the interrupts
349
+    switch (_timer)
350
+    {
351
+
352
+#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A)
353
+      case 0:
354
+        OCR0A = ocr;
355
+        timer0_toggle_count = toggle_count;
356
+        bitWrite(TIMSK0, OCIE0A, 1);
357
+        break;
358
+#endif
359
+
360
+      case 1:
361
+#if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A)
362
+        OCR1A = ocr;
363
+        timer1_toggle_count = toggle_count;
364
+        bitWrite(TIMSK1, OCIE1A, 1);
365
+#elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A)
366
+        // this combination is for at least the ATmega32
367
+        OCR1A = ocr;
368
+        timer1_toggle_count = toggle_count;
369
+        bitWrite(TIMSK, OCIE1A, 1);
370
+#endif
371
+        break;
372
+
373
+#if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A)
374
+      case 2:
375
+        OCR2A = ocr;
376
+        timer2_toggle_count = toggle_count;
377
+        bitWrite(TIMSK2, OCIE2A, 1);
378
+        break;
379
+#endif
380
+
381
+#if defined(TIMSK3)
382
+      case 3:
383
+        OCR3A = ocr;
384
+        timer3_toggle_count = toggle_count;
385
+        bitWrite(TIMSK3, OCIE3A, 1);
386
+        break;
387
+#endif
388
+
389
+#if defined(TIMSK4)
390
+      case 4:
391
+        OCR4A = ocr;
392
+        timer4_toggle_count = toggle_count;
393
+        bitWrite(TIMSK4, OCIE4A, 1);
394
+        break;
395
+#endif
396
+
397
+#if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A)
398
+      case 5:
399
+        OCR5A = ocr;
400
+        timer5_toggle_count = toggle_count;
401
+        bitWrite(TIMSK5, OCIE5A, 1);
402
+        break;
403
+#endif
404
+
405
+    }
406
+  }
407
+}
408
+
409
+
410
+// XXX: this function only works properly for timer 2 (the only one we use
411
+// currently).  for the others, it should end the tone, but won't restore
412
+// proper PWM functionality for the timer.
413
+void disableTimer(uint8_t _timer)
414
+{
415
+  switch (_timer)
416
+  {
417
+    case 0:
418
+      #if defined(TIMSK0)
419
+        TIMSK0 = 0;
420
+      #elif defined(TIMSK)
421
+        TIMSK = 0; // atmega32
422
+      #endif
423
+      break;
424
+
425
+#if defined(TIMSK1) && defined(OCIE1A)
426
+    case 1:
427
+      bitWrite(TIMSK1, OCIE1A, 0);
428
+      break;
429
+#endif
430
+
431
+    case 2:
432
+      #if defined(TIMSK2) && defined(OCIE2A)
433
+        bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt
434
+      #endif
435
+      #if defined(TCCR2A) && defined(WGM20)
436
+        TCCR2A = (1 << WGM20);
437
+      #endif
438
+      #if defined(TCCR2B) && defined(CS22)
439
+        TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
440
+      #endif
441
+      #if defined(OCR2A)
442
+        OCR2A = 0;
443
+      #endif
444
+      break;
445
+
446
+#if defined(TIMSK3)
447
+    case 3:
448
+      TIMSK3 = 0;
449
+      break;
450
+#endif
451
+
452
+#if defined(TIMSK4)
453
+    case 4:
454
+      TIMSK4 = 0;
455
+      break;
456
+#endif
457
+
458
+#if defined(TIMSK5)
459
+    case 5:
460
+      TIMSK5 = 0;
461
+      break;
462
+#endif
463
+  }
464
+}
465
+
466
+
467
+void noTone(uint8_t _pin)
468
+{
469
+  int8_t _timer = -1;
470
+  
471
+  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
472
+    if (tone_pins[i] == _pin) {
473
+      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
474
+      tone_pins[i] = 255;
475
+    }
476
+  }
477
+  
478
+  disableTimer(_timer);
479
+
480
+  digitalWrite(_pin, 0);
481
+}
482
+
483
+#if 0
484
+#if !defined(__AVR_ATmega8__)
485
+ISR(TIMER0_COMPA_vect)
486
+{
487
+  if (timer0_toggle_count != 0)
488
+  {
489
+    // toggle the pin
490
+    *timer0_pin_port ^= timer0_pin_mask;
491
+
492
+    if (timer0_toggle_count > 0)
493
+      timer0_toggle_count--;
494
+  }
495
+  else
496
+  {
497
+    disableTimer(0);
498
+    *timer0_pin_port &= ~(timer0_pin_mask);  // keep pin low after stop
499
+  }
500
+}
501
+#endif
502
+
503
+
504
+ISR(TIMER1_COMPA_vect)
505
+{
506
+  if (timer1_toggle_count != 0)
507
+  {
508
+    // toggle the pin
509
+    *timer1_pin_port ^= timer1_pin_mask;
510
+
511
+    if (timer1_toggle_count > 0)
512
+      timer1_toggle_count--;
513
+  }
514
+  else
515
+  {
516
+    disableTimer(1);
517
+    *timer1_pin_port &= ~(timer1_pin_mask);  // keep pin low after stop
518
+  }
519
+}
520
+#endif
521
+
522
+
523
+ISR(TIMER2_COMPA_vect)
524
+{
525
+
526
+  if (timer2_toggle_count != 0)
527
+  {
528
+    // toggle the pin
529
+    *timer2_pin_port ^= timer2_pin_mask;
530
+
531
+    if (timer2_toggle_count > 0)
532
+      timer2_toggle_count--;
533
+  }
534
+  else
535
+  {
536
+    // need to call noTone() so that the tone_pins[] entry is reset, so the
537
+    // timer gets initialized next time we call tone().
538
+    // XXX: this assumes timer 2 is always the first one used.
539
+    noTone(tone_pins[0]);
540
+//    disableTimer(2);
541
+//    *timer2_pin_port &= ~(timer2_pin_mask);  // keep pin low after stop
542
+  }
543
+}
544
+
545
+
546
+
547
+//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
548
+#if 0
549
+
550
+ISR(TIMER3_COMPA_vect)
551
+{
552
+  if (timer3_toggle_count != 0)
553
+  {
554
+    // toggle the pin
555
+    *timer3_pin_port ^= timer3_pin_mask;
556
+
557
+    if (timer3_toggle_count > 0)
558
+      timer3_toggle_count--;
559
+  }
560
+  else
561
+  {
562
+    disableTimer(3);
563
+    *timer3_pin_port &= ~(timer3_pin_mask);  // keep pin low after stop
564
+  }
565
+}
566
+
567
+ISR(TIMER4_COMPA_vect)
568
+{
569
+  if (timer4_toggle_count != 0)
570
+  {
571
+    // toggle the pin
572
+    *timer4_pin_port ^= timer4_pin_mask;
573
+
574
+    if (timer4_toggle_count > 0)
575
+      timer4_toggle_count--;
576
+  }
577
+  else
578
+  {
579
+    disableTimer(4);
580
+    *timer4_pin_port &= ~(timer4_pin_mask);  // keep pin low after stop
581
+  }
582
+}
583
+
584
+ISR(TIMER5_COMPA_vect)
585
+{
586
+  if (timer5_toggle_count != 0)
587
+  {
588
+    // toggle the pin
589
+    *timer5_pin_port ^= timer5_pin_mask;
590
+
591
+    if (timer5_toggle_count > 0)
592
+      timer5_toggle_count--;
593
+  }
594
+  else
595
+  {
596
+    disableTimer(5);
597
+    *timer5_pin_port &= ~(timer5_pin_mask);  // keep pin low after stop
598
+  }
599
+}
600
+
601
+#endif

+ 168
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WCharacter.h Dosyayı Görüntüle

@@ -0,0 +1,168 @@
1
+/*
2
+ WCharacter.h - Character utility functions for Wiring & Arduino
3
+ Copyright (c) 2010 Hernando Barragan.  All right reserved.
4
+ 
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+ 
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+ 
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ */
19
+
20
+#ifndef Character_h
21
+#define Character_h
22
+
23
+#include <ctype.h>
24
+
25
+// WCharacter.h prototypes
26
+inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
27
+inline boolean isAlpha(int c) __attribute__((always_inline));
28
+inline boolean isAscii(int c) __attribute__((always_inline));
29
+inline boolean isWhitespace(int c) __attribute__((always_inline));
30
+inline boolean isControl(int c) __attribute__((always_inline));
31
+inline boolean isDigit(int c) __attribute__((always_inline));
32
+inline boolean isGraph(int c) __attribute__((always_inline));
33
+inline boolean isLowerCase(int c) __attribute__((always_inline));
34
+inline boolean isPrintable(int c) __attribute__((always_inline));
35
+inline boolean isPunct(int c) __attribute__((always_inline));
36
+inline boolean isSpace(int c) __attribute__((always_inline));
37
+inline boolean isUpperCase(int c) __attribute__((always_inline));
38
+inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
39
+inline int toAscii(int c) __attribute__((always_inline));
40
+inline int toLowerCase(int c) __attribute__((always_inline));
41
+inline int toUpperCase(int c)__attribute__((always_inline));
42
+
43
+
44
+// Checks for an alphanumeric character. 
45
+// It is equivalent to (isalpha(c) || isdigit(c)).
46
+inline boolean isAlphaNumeric(int c) 
47
+{
48
+  return ( isalnum(c) == 0 ? false : true);
49
+}
50
+
51
+
52
+// Checks for an alphabetic character. 
53
+// It is equivalent to (isupper(c) || islower(c)).
54
+inline boolean isAlpha(int c)
55
+{
56
+  return ( isalpha(c) == 0 ? false : true);
57
+}
58
+
59
+
60
+// Checks whether c is a 7-bit unsigned char value 
61
+// that fits into the ASCII character set.
62
+inline boolean isAscii(int c)
63
+{
64
+  return ( isascii (c) == 0 ? false : true);
65
+}
66
+
67
+
68
+// Checks for a blank character, that is, a space or a tab.
69
+inline boolean isWhitespace(int c)
70
+{
71
+  return ( isblank (c) == 0 ? false : true);
72
+}
73
+
74
+
75
+// Checks for a control character.
76
+inline boolean isControl(int c)
77
+{
78
+  return ( iscntrl (c) == 0 ? false : true);
79
+}
80
+
81
+
82
+// Checks for a digit (0 through 9).
83
+inline boolean isDigit(int c)
84
+{
85
+  return ( isdigit (c) == 0 ? false : true);
86
+}
87
+
88
+
89
+// Checks for any printable character except space.
90
+inline boolean isGraph(int c)
91
+{
92
+  return ( isgraph (c) == 0 ? false : true);
93
+}
94
+
95
+
96
+// Checks for a lower-case character.
97
+inline boolean isLowerCase(int c)
98
+{
99
+  return (islower (c) == 0 ? false : true);
100
+}
101
+
102
+
103
+// Checks for any printable character including space.
104
+inline boolean isPrintable(int c)
105
+{
106
+  return ( isprint (c) == 0 ? false : true);
107
+}
108
+
109
+
110
+// Checks for any printable character which is not a space 
111
+// or an alphanumeric character.
112
+inline boolean isPunct(int c)
113
+{
114
+  return ( ispunct (c) == 0 ? false : true);
115
+}
116
+
117
+
118
+// Checks for white-space characters. For the avr-libc library, 
119
+// these are: space, formfeed ('\f'), newline ('\n'), carriage 
120
+// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
121
+inline boolean isSpace(int c)
122
+{
123
+  return ( isspace (c) == 0 ? false : true);
124
+}
125
+
126
+
127
+// Checks for an uppercase letter.
128
+inline boolean isUpperCase(int c)
129
+{
130
+  return ( isupper (c) == 0 ? false : true);
131
+}
132
+
133
+
134
+// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 
135
+// 8 9 a b c d e f A B C D E F.
136
+inline boolean isHexadecimalDigit(int c)
137
+{
138
+  return ( isxdigit (c) == 0 ? false : true);
139
+}
140
+
141
+
142
+// Converts c to a 7-bit unsigned char value that fits into the 
143
+// ASCII character set, by clearing the high-order bits.
144
+inline int toAscii(int c)
145
+{
146
+  return toascii (c);
147
+}
148
+
149
+
150
+// Warning:
151
+// Many people will be unhappy if you use this function. 
152
+// This function will convert accented letters into random 
153
+// characters.
154
+
155
+// Converts the letter c to lower case, if possible.
156
+inline int toLowerCase(int c)
157
+{
158
+  return tolower (c);
159
+}
160
+
161
+
162
+// Converts the letter c to upper case, if possible.
163
+inline int toUpperCase(int c)
164
+{
165
+  return toupper (c);
166
+}
167
+
168
+#endif

+ 1
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WConstants.h Dosyayı Görüntüle

@@ -0,0 +1 @@
1
+#include "wiring.h"

+ 280
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WInterrupts.c Dosyayı Görüntüle

@@ -0,0 +1,280 @@
1
+/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+/*
4
+  Part of the Wiring project - http://wiring.uniandes.edu.co
5
+
6
+  Copyright (c) 2004-05 Hernando Barragan
7
+
8
+  This library is free software; you can redistribute it and/or
9
+  modify it under the terms of the GNU Lesser General Public
10
+  License as published by the Free Software Foundation; either
11
+  version 2.1 of the License, or (at your option) any later version.
12
+
13
+  This library is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+  Lesser General Public License for more details.
17
+
18
+  You should have received a copy of the GNU Lesser General
19
+  Public License along with this library; if not, write to the
20
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+  Boston, MA  02111-1307  USA
22
+  
23
+  Modified 24 November 2006 by David A. Mellis
24
+  Modified 1 August 2010 by Mark Sproul
25
+*/
26
+
27
+#include <inttypes.h>
28
+#include <avr/io.h>
29
+#include <avr/interrupt.h>
30
+#include <avr/pgmspace.h>
31
+#include <stdio.h>
32
+
33
+#include "WConstants.h"
34
+#include "wiring_private.h"
35
+
36
+volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
37
+// volatile static voidFuncPtr twiIntFunc;
38
+
39
+void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
40
+  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
41
+    intFunc[interruptNum] = userFunc;
42
+    
43
+    // Configure the interrupt mode (trigger on low input, any change, rising
44
+    // edge, or falling edge).  The mode constants were chosen to correspond
45
+    // to the configuration bits in the hardware register, so we simply shift
46
+    // the mode into place.
47
+      
48
+    // Enable the interrupt.
49
+    switch (interruptNum) {
50
+#if defined(EICRA) && defined(EICRB) && defined(EIMSK)
51
+    case 2:
52
+      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
53
+      EIMSK |= (1 << INT0);
54
+      break;
55
+    case 3:
56
+      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
57
+      EIMSK |= (1 << INT1);
58
+      break;
59
+    case 4:
60
+      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
61
+      EIMSK |= (1 << INT2);
62
+      break;
63
+    case 5:
64
+      EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
65
+      EIMSK |= (1 << INT3);
66
+      break;
67
+    case 0:
68
+      EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
69
+      EIMSK |= (1 << INT4);
70
+      break;
71
+    case 1:
72
+      EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
73
+      EIMSK |= (1 << INT5);
74
+      break;
75
+    case 6:
76
+      EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
77
+      EIMSK |= (1 << INT6);
78
+      break;
79
+    case 7:
80
+      EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
81
+      EIMSK |= (1 << INT7);
82
+      break;
83
+#elif defined(EICRA) && defined(EIMSK)
84
+    case 0:
85
+      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
86
+      EIMSK |= (1 << INT0);
87
+      break;
88
+    case 1:
89
+      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
90
+      EIMSK |= (1 << INT1);
91
+      break;
92
+    case 2:
93
+      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
94
+      EIMSK |= (1 << INT2);
95
+      break;
96
+#else
97
+    case 0:
98
+    #if defined(EICRA) && defined(ISC00) && defined(EIMSK)
99
+      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
100
+      EIMSK |= (1 << INT0);
101
+    #elif defined(MCUCR) && defined(ISC00) && defined(GICR)
102
+      MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
103
+      GICR |= (1 << INT0);
104
+    #elif defined(MCUCR) && defined(ISC00) && defined(GIMSK)
105
+      MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
106
+      GIMSK |= (1 << INT0);
107
+    #else
108
+      #error attachInterrupt not finished for this CPU (case 0)
109
+    #endif
110
+      break;
111
+
112
+    case 1:
113
+    #if defined(EICRA) && defined(ISC10) && defined(ISC11) && defined(EIMSK)
114
+      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
115
+      EIMSK |= (1 << INT1);
116
+    #elif defined(MCUCR) && defined(ISC10) && defined(ISC11) && defined(GICR)
117
+      MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
118
+      GICR |= (1 << INT1);
119
+    #elif defined(MCUCR) && defined(ISC10) && defined(GIMSK) && defined(GIMSK)
120
+      MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
121
+      GIMSK |= (1 << INT1);
122
+    #else
123
+      #warning attachInterrupt may need some more work for this cpu (case 1)
124
+    #endif
125
+      break;
126
+#endif
127
+    }
128
+  }
129
+}
130
+
131
+void detachInterrupt(uint8_t interruptNum) {
132
+  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
133
+    // Disable the interrupt.  (We can't assume that interruptNum is equal
134
+    // to the number of the EIMSK bit to clear, as this isn't true on the 
135
+    // ATmega8.  There, INT0 is 6 and INT1 is 7.)
136
+    switch (interruptNum) {
137
+#if defined(EICRA) && defined(EICRB) && defined(EIMSK)
138
+    case 5:
139
+      EIMSK &= ~(1 << INT3);
140
+      break;
141
+    case 0:
142
+      EIMSK &= ~(1 << INT4);
143
+      break;
144
+    case 1:
145
+      EIMSK &= ~(1 << INT5);
146
+      break;
147
+    case 6:
148
+      EIMSK &= ~(1 << INT6);
149
+      break;
150
+    case 7:
151
+      EIMSK &= ~(1 << INT7);
152
+      break;
153
+#elif defined(EICRA) && defined(EIMSK)
154
+    case 0:
155
+      EIMSK &= ~(1 << INT0);
156
+      break;
157
+    case 1:
158
+      EIMSK &= ~(1 << INT1);
159
+      break;
160
+    case 2:
161
+      EIMSK &= ~(1 << INT2);
162
+      break;
163
+
164
+#else
165
+    case 0:
166
+    #if defined(EIMSK) && defined(INT0)
167
+      EIMSK &= ~(1 << INT0);
168
+    #elif defined(GICR) && defined(ISC00)
169
+      GICR &= ~(1 << INT0); // atmega32
170
+    #elif defined(GIMSK) && defined(INT0)
171
+      GIMSK &= ~(1 << INT0);
172
+    #else
173
+      #error detachInterrupt not finished for this cpu
174
+    #endif
175
+      break;
176
+
177
+    case 1:
178
+    #if defined(EIMSK) && defined(INT1)
179
+      EIMSK &= ~(1 << INT1);
180
+    #elif defined(GICR) && defined(INT1)
181
+      GICR &= ~(1 << INT1); // atmega32
182
+    #elif defined(GIMSK) && defined(INT1)
183
+      GIMSK &= ~(1 << INT1);
184
+    #else
185
+      #warning detachInterrupt may need some more work for this cpu (case 1)
186
+    #endif
187
+      break;
188
+#endif
189
+    }
190
+      
191
+    intFunc[interruptNum] = 0;
192
+  }
193
+}
194
+
195
+/*
196
+void attachInterruptTwi(void (*userFunc)(void) ) {
197
+  twiIntFunc = userFunc;
198
+}
199
+*/
200
+
201
+
202
+#if defined(EICRA) && defined(EICRB)
203
+SIGNAL(INT0_vect) {
204
+  if(intFunc[EXTERNAL_INT_2])
205
+    intFunc[EXTERNAL_INT_2]();
206
+}
207
+
208
+SIGNAL(INT1_vect) {
209
+  if(intFunc[EXTERNAL_INT_3])
210
+    intFunc[EXTERNAL_INT_3]();
211
+}
212
+
213
+SIGNAL(INT2_vect) {
214
+  if(intFunc[EXTERNAL_INT_4])
215
+    intFunc[EXTERNAL_INT_4]();
216
+}
217
+
218
+SIGNAL(INT3_vect) {
219
+  if(intFunc[EXTERNAL_INT_5])
220
+    intFunc[EXTERNAL_INT_5]();
221
+}
222
+
223
+SIGNAL(INT4_vect) {
224
+  if(intFunc[EXTERNAL_INT_0])
225
+    intFunc[EXTERNAL_INT_0]();
226
+}
227
+
228
+SIGNAL(INT5_vect) {
229
+  if(intFunc[EXTERNAL_INT_1])
230
+    intFunc[EXTERNAL_INT_1]();
231
+}
232
+
233
+SIGNAL(INT6_vect) {
234
+  if(intFunc[EXTERNAL_INT_6])
235
+    intFunc[EXTERNAL_INT_6]();
236
+}
237
+
238
+SIGNAL(INT7_vect) {
239
+  if(intFunc[EXTERNAL_INT_7])
240
+    intFunc[EXTERNAL_INT_7]();
241
+}
242
+
243
+#elif defined(EICRA)
244
+
245
+SIGNAL(INT0_vect) {
246
+  if(intFunc[EXTERNAL_INT_0])
247
+    intFunc[EXTERNAL_INT_0]();
248
+}
249
+
250
+SIGNAL(INT1_vect) {
251
+  if(intFunc[EXTERNAL_INT_1])
252
+    intFunc[EXTERNAL_INT_1]();
253
+}
254
+
255
+SIGNAL(INT2_vect) {
256
+  if(intFunc[EXTERNAL_INT_2])
257
+    intFunc[EXTERNAL_INT_2]();
258
+}
259
+
260
+#else
261
+
262
+SIGNAL(INT0_vect) {
263
+  if(intFunc[EXTERNAL_INT_0])
264
+    intFunc[EXTERNAL_INT_0]();
265
+}
266
+
267
+SIGNAL(INT1_vect) {
268
+  if(intFunc[EXTERNAL_INT_1])
269
+    intFunc[EXTERNAL_INT_1]();
270
+}
271
+
272
+#endif
273
+
274
+/*
275
+SIGNAL(SIG_2WIRE_SERIAL) {
276
+  if(twiIntFunc)
277
+    twiIntFunc();
278
+}
279
+*/
280
+

+ 60
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WMath.cpp Dosyayı Görüntüle

@@ -0,0 +1,60 @@
1
+/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+/*
4
+  Part of the Wiring project - http://wiring.org.co
5
+  Copyright (c) 2004-06 Hernando Barragan
6
+  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
7
+  
8
+  This library is free software; you can redistribute it and/or
9
+  modify it under the terms of the GNU Lesser General Public
10
+  License as published by the Free Software Foundation; either
11
+  version 2.1 of the License, or (at your option) any later version.
12
+
13
+  This library is distributed in the hope that it will be useful,
14
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+  Lesser General Public License for more details.
17
+
18
+  You should have received a copy of the GNU Lesser General
19
+  Public License along with this library; if not, write to the
20
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+  Boston, MA  02111-1307  USA
22
+  
23
+  $Id$
24
+*/
25
+
26
+extern "C" {
27
+  #include "stdlib.h"
28
+}
29
+
30
+void randomSeed(unsigned int seed)
31
+{
32
+  if (seed != 0) {
33
+    srandom(seed);
34
+  }
35
+}
36
+
37
+long random(long howbig)
38
+{
39
+  if (howbig == 0) {
40
+    return 0;
41
+  }
42
+  return random() % howbig;
43
+}
44
+
45
+long random(long howsmall, long howbig)
46
+{
47
+  if (howsmall >= howbig) {
48
+    return howsmall;
49
+  }
50
+  long diff = howbig - howsmall;
51
+  return random(diff) + howsmall;
52
+}
53
+
54
+long map(long x, long in_min, long in_max, long out_min, long out_max)
55
+{
56
+  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
57
+}
58
+
59
+unsigned int makeWord(unsigned int w) { return w; }
60
+unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 63
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WProgram.h Dosyayı Görüntüle

@@ -0,0 +1,63 @@
1
+#ifndef WProgram_h
2
+#define WProgram_h
3
+
4
+#include <stdlib.h>
5
+#include <string.h>
6
+#include <math.h>
7
+
8
+#include <avr/interrupt.h>
9
+
10
+#include "wiring.h"
11
+
12
+#ifdef __cplusplus
13
+#include "WCharacter.h"
14
+#include "WString.h"
15
+#include "HardwareSerial.h"
16
+
17
+uint16_t makeWord(uint16_t w);
18
+uint16_t makeWord(byte h, byte l);
19
+
20
+#define word(...) makeWord(__VA_ARGS__)
21
+
22
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
23
+
24
+void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
25
+void noTone(uint8_t _pin);
26
+
27
+// WMath prototypes
28
+long random(long);
29
+long random(long, long);
30
+void randomSeed(unsigned int);
31
+long map(long, long, long, long, long);
32
+
33
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
34
+const static uint8_t A0 = 54;
35
+const static uint8_t A1 = 55;
36
+const static uint8_t A2 = 56;
37
+const static uint8_t A3 = 57;
38
+const static uint8_t A4 = 58;
39
+const static uint8_t A5 = 59;
40
+const static uint8_t A6 = 60;
41
+const static uint8_t A7 = 61;
42
+const static uint8_t A8 = 62;
43
+const static uint8_t A9 = 63;
44
+const static uint8_t A10 = 64;
45
+const static uint8_t A11 = 65;
46
+const static uint8_t A12 = 66;
47
+const static uint8_t A13 = 67;
48
+const static uint8_t A14 = 68;
49
+const static uint8_t A15 = 69;
50
+#else
51
+const static uint8_t A0 = 14;
52
+const static uint8_t A1 = 15;
53
+const static uint8_t A2 = 16;
54
+const static uint8_t A3 = 17;
55
+const static uint8_t A4 = 18;
56
+const static uint8_t A5 = 19;
57
+const static uint8_t A6 = 20;
58
+const static uint8_t A7 = 21;
59
+#endif
60
+
61
+#endif
62
+
63
+#endif

+ 443
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WString.cpp Dosyayı Görüntüle

@@ -0,0 +1,443 @@
1
+/*
2
+  WString.cpp - String library for Wiring & Arduino
3
+  Copyright (c) 2009-10 Hernando Barragan.  All rights reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#include <stdlib.h>
21
+#include "WProgram.h"
22
+#include "WString.h"
23
+
24
+
25
+String::String( const char *value )
26
+{
27
+  if ( value == NULL )
28
+    value = "";
29
+  getBuffer( _length = strlen( value ) );
30
+  if ( _buffer != NULL )
31
+    strcpy( _buffer, value );
32
+}
33
+
34
+String::String( const String &value )
35
+{
36
+  getBuffer( _length = value._length );
37
+  if ( _buffer != NULL )
38
+    strcpy( _buffer, value._buffer );
39
+}
40
+
41
+String::String( const char value )
42
+{
43
+  _length = 1;
44
+  getBuffer(1);
45
+  if ( _buffer != NULL ) {
46
+    _buffer[0] = value;
47
+    _buffer[1] = 0;
48
+  }
49
+}
50
+
51
+String::String( const unsigned char value )
52
+{
53
+  _length = 1;
54
+  getBuffer(1);
55
+  if ( _buffer != NULL) {
56
+    _buffer[0] = value;
57
+    _buffer[1] = 0;
58
+  }
59
+}
60
+
61
+String::String( const int value, const int base )
62
+{
63
+  char buf[33];   
64
+  itoa((signed long)value, buf, base);
65
+  getBuffer( _length = strlen(buf) );
66
+  if ( _buffer != NULL )
67
+    strcpy( _buffer, buf );
68
+}
69
+
70
+String::String( const unsigned int value, const int base )
71
+{
72
+  char buf[33];   
73
+  ultoa((unsigned long)value, buf, base);
74
+  getBuffer( _length = strlen(buf) );
75
+  if ( _buffer != NULL )
76
+    strcpy( _buffer, buf );
77
+}
78
+
79
+String::String( const long value, const int base )
80
+{
81
+  char buf[33];   
82
+  ltoa(value, buf, base);
83
+  getBuffer( _length = strlen(buf) );
84
+  if ( _buffer != NULL )
85
+    strcpy( _buffer, buf );
86
+}
87
+
88
+String::String( const unsigned long value, const int base )
89
+{
90
+  char buf[33];   
91
+  ultoa(value, buf, 10);
92
+  getBuffer( _length = strlen(buf) );
93
+  if ( _buffer != NULL )
94
+    strcpy( _buffer, buf );
95
+}
96
+
97
+char String::charAt( unsigned int loc ) const
98
+{
99
+  return operator[]( loc );
100
+}
101
+
102
+void String::setCharAt( unsigned int loc, const char aChar ) 
103
+{
104
+  if(_buffer == NULL) return;
105
+  if(_length > loc) {
106
+    _buffer[loc] = aChar;
107
+  }
108
+}
109
+
110
+int String::compareTo( const String &s2 ) const
111
+{
112
+  return strcmp( _buffer, s2._buffer );
113
+}
114
+
115
+const String & String::concat( const String &s2 )
116
+{
117
+  return (*this) += s2;
118
+}
119
+
120
+const String & String::operator=( const String &rhs )
121
+{
122
+  if ( this == &rhs )
123
+    return *this;
124
+
125
+  if ( rhs._length > _length )
126
+  {
127
+    free(_buffer);
128
+    getBuffer( rhs._length );
129
+  }
130
+  
131
+  if ( _buffer != NULL ) {
132
+    _length = rhs._length;
133
+    strcpy( _buffer, rhs._buffer );
134
+  }
135
+  return *this;
136
+}
137
+
138
+//const String & String::operator+=( const char aChar )
139
+//{
140
+//  if ( _length == _capacity )
141
+//    doubleBuffer();
142
+//
143
+//  _buffer[ _length++ ] = aChar;
144
+//  _buffer[ _length ] = '\0';
145
+//  return *this;
146
+//}
147
+
148
+const String & String::operator+=( const String &other )
149
+{
150
+  _length += other._length;
151
+  if ( _length > _capacity )
152
+  {
153
+    char *temp = (char *)realloc(_buffer, _length + 1);
154
+    if ( temp != NULL ) {
155
+      _buffer = temp;
156
+      _capacity = _length;
157
+    } else {
158
+      _length -= other._length;
159
+      return *this;
160
+    }
161
+  }
162
+  strcat( _buffer, other._buffer );
163
+  return *this;
164
+}
165
+
166
+
167
+int String::operator==( const String &rhs ) const
168
+{
169
+  return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 );
170
+}
171
+
172
+int String::operator!=( const String &rhs ) const
173
+{
174
+  return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 );
175
+}
176
+
177
+int String::operator<( const String &rhs ) const
178
+{
179
+  return strcmp( _buffer, rhs._buffer ) < 0;
180
+}
181
+
182
+int String::operator>( const String &rhs ) const
183
+{
184
+  return strcmp( _buffer, rhs._buffer ) > 0;
185
+}
186
+
187
+int String::operator<=( const String &rhs ) const
188
+{
189
+  return strcmp( _buffer, rhs._buffer ) <= 0;
190
+}
191
+
192
+int String::operator>=( const String & rhs ) const
193
+{
194
+  return strcmp( _buffer, rhs._buffer ) >= 0;
195
+}
196
+
197
+char & String::operator[]( unsigned int index )
198
+{
199
+  static char dummy_writable_char;
200
+  if (index >= _length || !_buffer) {
201
+    dummy_writable_char = 0;
202
+    return dummy_writable_char;
203
+  }
204
+  return _buffer[ index ];
205
+}
206
+
207
+char String::operator[]( unsigned int index ) const
208
+{
209
+  // need to check for valid index, to do later
210
+  return _buffer[ index ];
211
+}
212
+
213
+boolean String::endsWith( const String &s2 ) const
214
+{
215
+  if ( _length < s2._length )
216
+    return 0;
217
+
218
+  return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0;
219
+}
220
+
221
+boolean String::equals( const String &s2 ) const
222
+{
223
+  return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 );
224
+}
225
+
226
+boolean String::equalsIgnoreCase( const String &s2 ) const
227
+{
228
+  if ( this == &s2 )
229
+    return true; //1;
230
+  else if ( _length != s2._length )
231
+    return false; //0;
232
+
233
+  return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
234
+}
235
+
236
+String String::replace( char findChar, char replaceChar )
237
+{
238
+  if ( _buffer == NULL ) return *this;
239
+  String theReturn = _buffer;
240
+  char* temp = theReturn._buffer;
241
+  while( (temp = strchr( temp, findChar )) != 0 )
242
+    *temp = replaceChar;
243
+
244
+  return theReturn;
245
+}
246
+
247
+String String::replace( const String& match, const String& replace )
248
+{
249
+  if ( _buffer == NULL ) return *this;
250
+  String temp = _buffer, newString;
251
+
252
+  int loc;
253
+  while ( (loc = temp.indexOf( match )) != -1 )
254
+  {
255
+    newString += temp.substring( 0, loc );
256
+    newString += replace;
257
+    temp = temp.substring( loc + match._length );
258
+  }
259
+  newString += temp;  
260
+  return newString;
261
+}
262
+
263
+int String::indexOf( char temp ) const
264
+{
265
+  return indexOf( temp, 0 );
266
+}
267
+
268
+int String::indexOf( char ch, unsigned int fromIndex ) const
269
+{
270
+  if ( fromIndex >= _length )
271
+    return -1;
272
+
273
+  const char* temp = strchr( &_buffer[fromIndex], ch );
274
+  if ( temp == NULL )
275
+    return -1;
276
+
277
+  return temp - _buffer;
278
+}
279
+
280
+int String::indexOf( const String &s2 ) const
281
+{
282
+  return indexOf( s2, 0 );
283
+}
284
+
285
+int String::indexOf( const String &s2, unsigned int fromIndex ) const
286
+{
287
+  if ( fromIndex >= _length )
288
+    return -1;
289
+
290
+  const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer );
291
+
292
+  if ( theFind == NULL )
293
+    return -1;
294
+
295
+  return theFind - _buffer; // pointer subtraction
296
+}
297
+
298
+int String::lastIndexOf( char theChar ) const
299
+{
300
+  return lastIndexOf( theChar, _length - 1 );
301
+}
302
+
303
+int String::lastIndexOf( char ch, unsigned int fromIndex ) const
304
+{
305
+  if ( fromIndex >= _length )
306
+    return -1;
307
+
308
+  char tempchar = _buffer[fromIndex + 1];
309
+  _buffer[fromIndex + 1] = '\0';
310
+  char* temp = strrchr( _buffer, ch );
311
+  _buffer[fromIndex + 1] = tempchar;
312
+
313
+  if ( temp == NULL )
314
+    return -1;
315
+
316
+  return temp - _buffer;
317
+}
318
+
319
+int String::lastIndexOf( const String &s2 ) const
320
+{
321
+  return lastIndexOf( s2, _length - s2._length );
322
+}
323
+
324
+int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const
325
+{
326
+  // check for empty strings
327
+  if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length )
328
+    return -1;
329
+
330
+  // matching first character
331
+  char temp = s2[ 0 ];
332
+
333
+  for ( int i = fromIndex; i >= 0; i-- )
334
+  {
335
+    if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) )
336
+    return i;
337
+  }
338
+  return -1;
339
+}
340
+
341
+boolean String::startsWith( const String &s2 ) const
342
+{
343
+  if ( _length < s2._length )
344
+    return 0;
345
+
346
+  return startsWith( s2, 0 );
347
+}
348
+
349
+boolean String::startsWith( const String &s2, unsigned int offset ) const
350
+{
351
+  if ( offset > _length - s2._length )
352
+    return 0;
353
+
354
+  return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0;
355
+}
356
+
357
+String String::substring( unsigned int left ) const
358
+{
359
+  return substring( left, _length );
360
+}
361
+
362
+String String::substring( unsigned int left, unsigned int right ) const
363
+{
364
+  if ( left > right )
365
+  {
366
+    int temp = right;
367
+    right = left;
368
+    left = temp;
369
+  }
370
+
371
+  if ( right > _length )
372
+  {
373
+    right = _length;
374
+  } 
375
+
376
+  char temp = _buffer[ right ];  // save the replaced character
377
+  _buffer[ right ] = '\0';	
378
+  String outPut = ( _buffer + left );  // pointer arithmetic
379
+  _buffer[ right ] = temp;  //restore character
380
+  return outPut;
381
+}
382
+
383
+String String::toLowerCase() const
384
+{
385
+  String temp = _buffer;
386
+
387
+  for ( unsigned int i = 0; i < _length; i++ )
388
+    temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] );
389
+  return temp;
390
+}
391
+
392
+String String::toUpperCase() const
393
+{
394
+  String temp = _buffer;
395
+
396
+  for ( unsigned int i = 0; i < _length; i++ )
397
+    temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
398
+  return temp;
399
+}
400
+
401
+String String::trim() const
402
+{
403
+  if ( _buffer == NULL ) return *this;
404
+  String temp = _buffer;
405
+  unsigned int i,j;
406
+
407
+  for ( i = 0; i < _length; i++ )
408
+  {
409
+    if ( !isspace(_buffer[i]) )
410
+      break;
411
+  }
412
+
413
+  for ( j = temp._length - 1; j > i; j-- )
414
+  {
415
+    if ( !isspace(_buffer[j]) )
416
+      break;
417
+  }
418
+
419
+  return temp.substring( i, j + 1);
420
+}
421
+
422
+void String::getBytes(unsigned char *buf, unsigned int bufsize)
423
+{
424
+  if (!bufsize || !buf) return;
425
+  unsigned int len = bufsize - 1;
426
+  if (len > _length) len = _length;
427
+  strncpy((char *)buf, _buffer, len);
428
+  buf[len] = 0;
429
+}
430
+
431
+void String::toCharArray(char *buf, unsigned int bufsize)
432
+{
433
+  if (!bufsize || !buf) return;
434
+  unsigned int len = bufsize - 1;
435
+  if (len > _length) len = _length;
436
+  strncpy(buf, _buffer, len);
437
+  buf[len] = 0;
438
+}
439
+
440
+
441
+long String::toInt() {
442
+  return atol(_buffer);
443
+}

+ 112
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WString.h Dosyayı Görüntüle

@@ -0,0 +1,112 @@
1
+/*
2
+  WString.h - String library for Wiring & Arduino
3
+  Copyright (c) 2009-10 Hernando Barragan.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+#ifndef String_h
21
+#define String_h
22
+
23
+//#include "WProgram.h"
24
+#include <stdlib.h>
25
+#include <string.h>
26
+#include <ctype.h>
27
+
28
+class String
29
+{
30
+  public:
31
+    // constructors
32
+    String( const char *value = "" );
33
+    String( const String &value );
34
+    String( const char );
35
+    String( const unsigned char );
36
+    String( const int, const int base=10);
37
+    String( const unsigned int, const int base=10 );
38
+    String( const long, const int base=10 );
39
+    String( const unsigned long, const int base=10 );
40
+    ~String() { free(_buffer); _length = _capacity = 0;}     //added _length = _capacity = 0;
41
+
42
+    // operators
43
+    const String & operator = ( const String &rhs );
44
+    const String & operator +=( const String &rhs );
45
+    //const String & operator +=( const char );
46
+    int operator ==( const String &rhs ) const;
47
+    int	operator !=( const String &rhs ) const;
48
+    int	operator < ( const String &rhs ) const;
49
+    int	operator > ( const String &rhs ) const;
50
+    int	operator <=( const String &rhs ) const;
51
+    int	operator >=( const String &rhs ) const;
52
+    char operator []( unsigned int index ) const;
53
+    char& operator []( unsigned int index );
54
+    //operator const char *() const { return _buffer; }
55
+    
56
+    // general methods
57
+    char charAt( unsigned int index ) const;
58
+    int	compareTo( const String &anotherString ) const;
59
+    unsigned char endsWith( const String &suffix ) const;
60
+    unsigned char equals( const String &anObject ) const;
61
+    unsigned char equalsIgnoreCase( const String &anotherString ) const;
62
+    int	indexOf( char ch ) const;
63
+    int	indexOf( char ch, unsigned int fromIndex ) const;
64
+    int	indexOf( const String &str ) const;
65
+    int	indexOf( const String &str, unsigned int fromIndex ) const;
66
+    int	lastIndexOf( char ch ) const;
67
+    int	lastIndexOf( char ch, unsigned int fromIndex ) const;
68
+    int	lastIndexOf( const String &str ) const;
69
+    int	lastIndexOf( const String &str, unsigned int fromIndex ) const;
70
+    const unsigned int length( ) const { return _length; }
71
+    void setCharAt(unsigned int index, const char ch);
72
+    unsigned char startsWith( const String &prefix ) const;
73
+    unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
74
+    String substring( unsigned int beginIndex ) const;
75
+    String substring( unsigned int beginIndex, unsigned int endIndex ) const;
76
+    String toLowerCase( ) const;
77
+    String toUpperCase( ) const;
78
+    String trim( ) const;
79
+    void getBytes(unsigned char *buf, unsigned int bufsize);
80
+    void toCharArray(char *buf, unsigned int bufsize);
81
+    long toInt( );
82
+    const String& concat( const String &str );
83
+    String replace( char oldChar, char newChar );
84
+    String replace( const String& match, const String& replace );
85
+    friend String operator + ( String lhs, const String &rhs );
86
+
87
+  protected:
88
+    char *_buffer;	     // the actual char array
89
+    unsigned int _capacity;  // the array length minus one (for the '\0')
90
+    unsigned int _length;    // the String length (not counting the '\0')
91
+
92
+    void getBuffer(unsigned int maxStrLen);
93
+
94
+  private:
95
+
96
+};
97
+
98
+// allocate buffer space
99
+inline void String::getBuffer(unsigned int maxStrLen)
100
+{
101
+  _capacity = maxStrLen;
102
+  _buffer = (char *) malloc(_capacity + 1);
103
+  if (_buffer == NULL) _length = _capacity = 0;
104
+}
105
+
106
+inline String operator+( String lhs, const String &rhs )
107
+{
108
+  return lhs += rhs;
109
+}
110
+
111
+
112
+#endif

+ 515
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/binary.h Dosyayı Görüntüle

@@ -0,0 +1,515 @@
1
+#ifndef Binary_h
2
+#define Binary_h
3
+
4
+#define B0 0
5
+#define B00 0
6
+#define B000 0
7
+#define B0000 0
8
+#define B00000 0
9
+#define B000000 0
10
+#define B0000000 0
11
+#define B00000000 0
12
+#define B1 1
13
+#define B01 1
14
+#define B001 1
15
+#define B0001 1
16
+#define B00001 1
17
+#define B000001 1
18
+#define B0000001 1
19
+#define B00000001 1
20
+#define B10 2
21
+#define B010 2
22
+#define B0010 2
23
+#define B00010 2
24
+#define B000010 2
25
+#define B0000010 2
26
+#define B00000010 2
27
+#define B11 3
28
+#define B011 3
29
+#define B0011 3
30
+#define B00011 3
31
+#define B000011 3
32
+#define B0000011 3
33
+#define B00000011 3
34
+#define B100 4
35
+#define B0100 4
36
+#define B00100 4
37
+#define B000100 4
38
+#define B0000100 4
39
+#define B00000100 4
40
+#define B101 5
41
+#define B0101 5
42
+#define B00101 5
43
+#define B000101 5
44
+#define B0000101 5
45
+#define B00000101 5
46
+#define B110 6
47
+#define B0110 6
48
+#define B00110 6
49
+#define B000110 6
50
+#define B0000110 6
51
+#define B00000110 6
52
+#define B111 7
53
+#define B0111 7
54
+#define B00111 7
55
+#define B000111 7
56
+#define B0000111 7
57
+#define B00000111 7
58
+#define B1000 8
59
+#define B01000 8
60
+#define B001000 8
61
+#define B0001000 8
62
+#define B00001000 8
63
+#define B1001 9
64
+#define B01001 9
65
+#define B001001 9
66
+#define B0001001 9
67
+#define B00001001 9
68
+#define B1010 10
69
+#define B01010 10
70
+#define B001010 10
71
+#define B0001010 10
72
+#define B00001010 10
73
+#define B1011 11
74
+#define B01011 11
75
+#define B001011 11
76
+#define B0001011 11
77
+#define B00001011 11
78
+#define B1100 12
79
+#define B01100 12
80
+#define B001100 12
81
+#define B0001100 12
82
+#define B00001100 12
83
+#define B1101 13
84
+#define B01101 13
85
+#define B001101 13
86
+#define B0001101 13
87
+#define B00001101 13
88
+#define B1110 14
89
+#define B01110 14
90
+#define B001110 14
91
+#define B0001110 14
92
+#define B00001110 14
93
+#define B1111 15
94
+#define B01111 15
95
+#define B001111 15
96
+#define B0001111 15
97
+#define B00001111 15
98
+#define B10000 16
99
+#define B010000 16
100
+#define B0010000 16
101
+#define B00010000 16
102
+#define B10001 17
103
+#define B010001 17
104
+#define B0010001 17
105
+#define B00010001 17
106
+#define B10010 18
107
+#define B010010 18
108
+#define B0010010 18
109
+#define B00010010 18
110
+#define B10011 19
111
+#define B010011 19
112
+#define B0010011 19
113
+#define B00010011 19
114
+#define B10100 20
115
+#define B010100 20
116
+#define B0010100 20
117
+#define B00010100 20
118
+#define B10101 21
119
+#define B010101 21
120
+#define B0010101 21
121
+#define B00010101 21
122
+#define B10110 22
123
+#define B010110 22
124
+#define B0010110 22
125
+#define B00010110 22
126
+#define B10111 23
127
+#define B010111 23
128
+#define B0010111 23
129
+#define B00010111 23
130
+#define B11000 24
131
+#define B011000 24
132
+#define B0011000 24
133
+#define B00011000 24
134
+#define B11001 25
135
+#define B011001 25
136
+#define B0011001 25
137
+#define B00011001 25
138
+#define B11010 26
139
+#define B011010 26
140
+#define B0011010 26
141
+#define B00011010 26
142
+#define B11011 27
143
+#define B011011 27
144
+#define B0011011 27
145
+#define B00011011 27
146
+#define B11100 28
147
+#define B011100 28
148
+#define B0011100 28
149
+#define B00011100 28
150
+#define B11101 29
151
+#define B011101 29
152
+#define B0011101 29
153
+#define B00011101 29
154
+#define B11110 30
155
+#define B011110 30
156
+#define B0011110 30
157
+#define B00011110 30
158
+#define B11111 31
159
+#define B011111 31
160
+#define B0011111 31
161
+#define B00011111 31
162
+#define B100000 32
163
+#define B0100000 32
164
+#define B00100000 32
165
+#define B100001 33
166
+#define B0100001 33
167
+#define B00100001 33
168
+#define B100010 34
169
+#define B0100010 34
170
+#define B00100010 34
171
+#define B100011 35
172
+#define B0100011 35
173
+#define B00100011 35
174
+#define B100100 36
175
+#define B0100100 36
176
+#define B00100100 36
177
+#define B100101 37
178
+#define B0100101 37
179
+#define B00100101 37
180
+#define B100110 38
181
+#define B0100110 38
182
+#define B00100110 38
183
+#define B100111 39
184
+#define B0100111 39
185
+#define B00100111 39
186
+#define B101000 40
187
+#define B0101000 40
188
+#define B00101000 40
189
+#define B101001 41
190
+#define B0101001 41
191
+#define B00101001 41
192
+#define B101010 42
193
+#define B0101010 42
194
+#define B00101010 42
195
+#define B101011 43
196
+#define B0101011 43
197
+#define B00101011 43
198
+#define B101100 44
199
+#define B0101100 44
200
+#define B00101100 44
201
+#define B101101 45
202
+#define B0101101 45
203
+#define B00101101 45
204
+#define B101110 46
205
+#define B0101110 46
206
+#define B00101110 46
207
+#define B101111 47
208
+#define B0101111 47
209
+#define B00101111 47
210
+#define B110000 48
211
+#define B0110000 48
212
+#define B00110000 48
213
+#define B110001 49
214
+#define B0110001 49
215
+#define B00110001 49
216
+#define B110010 50
217
+#define B0110010 50
218
+#define B00110010 50
219
+#define B110011 51
220
+#define B0110011 51
221
+#define B00110011 51
222
+#define B110100 52
223
+#define B0110100 52
224
+#define B00110100 52
225
+#define B110101 53
226
+#define B0110101 53
227
+#define B00110101 53
228
+#define B110110 54
229
+#define B0110110 54
230
+#define B00110110 54
231
+#define B110111 55
232
+#define B0110111 55
233
+#define B00110111 55
234
+#define B111000 56
235
+#define B0111000 56
236
+#define B00111000 56
237
+#define B111001 57
238
+#define B0111001 57
239
+#define B00111001 57
240
+#define B111010 58
241
+#define B0111010 58
242
+#define B00111010 58
243
+#define B111011 59
244
+#define B0111011 59
245
+#define B00111011 59
246
+#define B111100 60
247
+#define B0111100 60
248
+#define B00111100 60
249
+#define B111101 61
250
+#define B0111101 61
251
+#define B00111101 61
252
+#define B111110 62
253
+#define B0111110 62
254
+#define B00111110 62
255
+#define B111111 63
256
+#define B0111111 63
257
+#define B00111111 63
258
+#define B1000000 64
259
+#define B01000000 64
260
+#define B1000001 65
261
+#define B01000001 65
262
+#define B1000010 66
263
+#define B01000010 66
264
+#define B1000011 67
265
+#define B01000011 67
266
+#define B1000100 68
267
+#define B01000100 68
268
+#define B1000101 69
269
+#define B01000101 69
270
+#define B1000110 70
271
+#define B01000110 70
272
+#define B1000111 71
273
+#define B01000111 71
274
+#define B1001000 72
275
+#define B01001000 72
276
+#define B1001001 73
277
+#define B01001001 73
278
+#define B1001010 74
279
+#define B01001010 74
280
+#define B1001011 75
281
+#define B01001011 75
282
+#define B1001100 76
283
+#define B01001100 76
284
+#define B1001101 77
285
+#define B01001101 77
286
+#define B1001110 78
287
+#define B01001110 78
288
+#define B1001111 79
289
+#define B01001111 79
290
+#define B1010000 80
291
+#define B01010000 80
292
+#define B1010001 81
293
+#define B01010001 81
294
+#define B1010010 82
295
+#define B01010010 82
296
+#define B1010011 83
297
+#define B01010011 83
298
+#define B1010100 84
299
+#define B01010100 84
300
+#define B1010101 85
301
+#define B01010101 85
302
+#define B1010110 86
303
+#define B01010110 86
304
+#define B1010111 87
305
+#define B01010111 87
306
+#define B1011000 88
307
+#define B01011000 88
308
+#define B1011001 89
309
+#define B01011001 89
310
+#define B1011010 90
311
+#define B01011010 90
312
+#define B1011011 91
313
+#define B01011011 91
314
+#define B1011100 92
315
+#define B01011100 92
316
+#define B1011101 93
317
+#define B01011101 93
318
+#define B1011110 94
319
+#define B01011110 94
320
+#define B1011111 95
321
+#define B01011111 95
322
+#define B1100000 96
323
+#define B01100000 96
324
+#define B1100001 97
325
+#define B01100001 97
326
+#define B1100010 98
327
+#define B01100010 98
328
+#define B1100011 99
329
+#define B01100011 99
330
+#define B1100100 100
331
+#define B01100100 100
332
+#define B1100101 101
333
+#define B01100101 101
334
+#define B1100110 102
335
+#define B01100110 102
336
+#define B1100111 103
337
+#define B01100111 103
338
+#define B1101000 104
339
+#define B01101000 104
340
+#define B1101001 105
341
+#define B01101001 105
342
+#define B1101010 106
343
+#define B01101010 106
344
+#define B1101011 107
345
+#define B01101011 107
346
+#define B1101100 108
347
+#define B01101100 108
348
+#define B1101101 109
349
+#define B01101101 109
350
+#define B1101110 110
351
+#define B01101110 110
352
+#define B1101111 111
353
+#define B01101111 111
354
+#define B1110000 112
355
+#define B01110000 112
356
+#define B1110001 113
357
+#define B01110001 113
358
+#define B1110010 114
359
+#define B01110010 114
360
+#define B1110011 115
361
+#define B01110011 115
362
+#define B1110100 116
363
+#define B01110100 116
364
+#define B1110101 117
365
+#define B01110101 117
366
+#define B1110110 118
367
+#define B01110110 118
368
+#define B1110111 119
369
+#define B01110111 119
370
+#define B1111000 120
371
+#define B01111000 120
372
+#define B1111001 121
373
+#define B01111001 121
374
+#define B1111010 122
375
+#define B01111010 122
376
+#define B1111011 123
377
+#define B01111011 123
378
+#define B1111100 124
379
+#define B01111100 124
380
+#define B1111101 125
381
+#define B01111101 125
382
+#define B1111110 126
383
+#define B01111110 126
384
+#define B1111111 127
385
+#define B01111111 127
386
+#define B10000000 128
387
+#define B10000001 129
388
+#define B10000010 130
389
+#define B10000011 131
390
+#define B10000100 132
391
+#define B10000101 133
392
+#define B10000110 134
393
+#define B10000111 135
394
+#define B10001000 136
395
+#define B10001001 137
396
+#define B10001010 138
397
+#define B10001011 139
398
+#define B10001100 140
399
+#define B10001101 141
400
+#define B10001110 142
401
+#define B10001111 143
402
+#define B10010000 144
403
+#define B10010001 145
404
+#define B10010010 146
405
+#define B10010011 147
406
+#define B10010100 148
407
+#define B10010101 149
408
+#define B10010110 150
409
+#define B10010111 151
410
+#define B10011000 152
411
+#define B10011001 153
412
+#define B10011010 154
413
+#define B10011011 155
414
+#define B10011100 156
415
+#define B10011101 157
416
+#define B10011110 158
417
+#define B10011111 159
418
+#define B10100000 160
419
+#define B10100001 161
420
+#define B10100010 162
421
+#define B10100011 163
422
+#define B10100100 164
423
+#define B10100101 165
424
+#define B10100110 166
425
+#define B10100111 167
426
+#define B10101000 168
427
+#define B10101001 169
428
+#define B10101010 170
429
+#define B10101011 171
430
+#define B10101100 172
431
+#define B10101101 173
432
+#define B10101110 174
433
+#define B10101111 175
434
+#define B10110000 176
435
+#define B10110001 177
436
+#define B10110010 178
437
+#define B10110011 179
438
+#define B10110100 180
439
+#define B10110101 181
440
+#define B10110110 182
441
+#define B10110111 183
442
+#define B10111000 184
443
+#define B10111001 185
444
+#define B10111010 186
445
+#define B10111011 187
446
+#define B10111100 188
447
+#define B10111101 189
448
+#define B10111110 190
449
+#define B10111111 191
450
+#define B11000000 192
451
+#define B11000001 193
452
+#define B11000010 194
453
+#define B11000011 195
454
+#define B11000100 196
455
+#define B11000101 197
456
+#define B11000110 198
457
+#define B11000111 199
458
+#define B11001000 200
459
+#define B11001001 201
460
+#define B11001010 202
461
+#define B11001011 203
462
+#define B11001100 204
463
+#define B11001101 205
464
+#define B11001110 206
465
+#define B11001111 207
466
+#define B11010000 208
467
+#define B11010001 209
468
+#define B11010010 210
469
+#define B11010011 211
470
+#define B11010100 212
471
+#define B11010101 213
472
+#define B11010110 214
473
+#define B11010111 215
474
+#define B11011000 216
475
+#define B11011001 217
476
+#define B11011010 218
477
+#define B11011011 219
478
+#define B11011100 220
479
+#define B11011101 221
480
+#define B11011110 222
481
+#define B11011111 223
482
+#define B11100000 224
483
+#define B11100001 225
484
+#define B11100010 226
485
+#define B11100011 227
486
+#define B11100100 228
487
+#define B11100101 229
488
+#define B11100110 230
489
+#define B11100111 231
490
+#define B11101000 232
491
+#define B11101001 233
492
+#define B11101010 234
493
+#define B11101011 235
494
+#define B11101100 236
495
+#define B11101101 237
496
+#define B11101110 238
497
+#define B11101111 239
498
+#define B11110000 240
499
+#define B11110001 241
500
+#define B11110010 242
501
+#define B11110011 243
502
+#define B11110100 244
503
+#define B11110101 245
504
+#define B11110110 246
505
+#define B11110111 247
506
+#define B11111000 248
507
+#define B11111001 249
508
+#define B11111010 250
509
+#define B11111011 251
510
+#define B11111100 252
511
+#define B11111101 253
512
+#define B11111110 254
513
+#define B11111111 255
514
+
515
+#endif

+ 14
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/main.cpp Dosyayı Görüntüle

@@ -0,0 +1,14 @@
1
+#include <WProgram.h>
2
+
3
+int main(void)
4
+{
5
+	init();
6
+
7
+	setup();
8
+    
9
+	for (;;)
10
+		loop();
11
+        
12
+	return 0;
13
+}
14
+

+ 627
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.c Dosyayı Görüntüle

@@ -0,0 +1,627 @@
1
+/*
2
+  pins_arduino.c - pin definitions for the Arduino board
3
+  Part of Arduino / Wiring Lite
4
+
5
+  Copyright (c) 2005 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  Changelog
23
+  -----------
24
+  11/25/11  - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P
25
+  $Id$
26
+*/
27
+
28
+#include <avr/io.h>
29
+#include "wiring_private.h"
30
+#include "pins_arduino.h"
31
+
32
+// On the Arduino board, digital pins are also used
33
+// for the analog output (software PWM).  Analog input
34
+// pins are a separate set.
35
+
36
+// ATMEL ATMEGA8 & 168 / ARDUINO
37
+//
38
+//                  +-\/-+
39
+//            PC6  1|    |28  PC5 (AI 5)
40
+//      (D 0) PD0  2|    |27  PC4 (AI 4)
41
+//      (D 1) PD1  3|    |26  PC3 (AI 3)
42
+//      (D 2) PD2  4|    |25  PC2 (AI 2)
43
+// PWM+ (D 3) PD3  5|    |24  PC1 (AI 1)
44
+//      (D 4) PD4  6|    |23  PC0 (AI 0)
45
+//            VCC  7|    |22  GND
46
+//            GND  8|    |21  AREF
47
+//            PB6  9|    |20  AVCC
48
+//            PB7 10|    |19  PB5 (D 13)
49
+// PWM+ (D 5) PD5 11|    |18  PB4 (D 12)
50
+// PWM+ (D 6) PD6 12|    |17  PB3 (D 11) PWM
51
+//      (D 7) PD7 13|    |16  PB2 (D 10) PWM
52
+//      (D 8) PB0 14|    |15  PB1 (D 9) PWM
53
+//                  +----+
54
+//
55
+// (PWM+ indicates the additional PWM pins on the ATmega168.)
56
+
57
+// ATMEL ATMEGA1280 / ARDUINO
58
+//
59
+// 0-7 PE0-PE7   works
60
+// 8-13 PB0-PB5  works
61
+// 14-21 PA0-PA7 works 
62
+// 22-29 PH0-PH7 works
63
+// 30-35 PG5-PG0 works
64
+// 36-43 PC7-PC0 works
65
+// 44-51 PJ7-PJ0 works
66
+// 52-59 PL7-PL0 works
67
+// 60-67 PD7-PD0 works
68
+// A0-A7 PF0-PF7
69
+// A8-A15 PK0-PK7
70
+// ATMEL ATMEGA644P / SANGUINO
71
+//
72
+//                   +---\/---+
73
+//  INT0 (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
74
+//  INT1 (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
75
+//  INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
76
+//   PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
77
+//   PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
78
+//  MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
79
+//  MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
80
+//   SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
81
+//             RST  9|        |32  AREF
82
+//             VCC 10|        |31  GND 
83
+//             GND 11|        |30  AVCC
84
+//           XTAL2 12|        |29  PC7 (D 23)
85
+//           XTAL1 13|        |28  PC6 (D 22)
86
+//  RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
87
+//  TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
88
+//  RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
89
+//  TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
90
+//  PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
91
+//  PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
92
+//  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
93
+//                   +--------+
94
+//
95
+#define PA 1
96
+#define PB 2
97
+#define PC 3
98
+#define PD 4
99
+#define PE 5
100
+#define PF 6
101
+#define PG 7
102
+#define PH 8
103
+#define PJ 10
104
+#define PK 11
105
+#define PL 12
106
+
107
+
108
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
109
+const uint16_t PROGMEM port_to_mode_PGM[] = {
110
+	NOT_A_PORT,
111
+	&DDRA,
112
+	&DDRB,
113
+	&DDRC,
114
+	&DDRD,
115
+	&DDRE,
116
+	&DDRF,
117
+	&DDRG,
118
+	&DDRH,
119
+	NOT_A_PORT,
120
+	&DDRJ,
121
+	&DDRK,
122
+	&DDRL,
123
+};
124
+
125
+const uint16_t PROGMEM port_to_output_PGM[] = {
126
+	NOT_A_PORT,
127
+	&PORTA,
128
+	&PORTB,
129
+	&PORTC,
130
+	&PORTD,
131
+	&PORTE,
132
+	&PORTF,
133
+	&PORTG,
134
+	&PORTH,
135
+	NOT_A_PORT,
136
+	&PORTJ,
137
+	&PORTK,
138
+	&PORTL,
139
+};
140
+
141
+const uint16_t PROGMEM port_to_input_PGM[] = {
142
+	NOT_A_PIN,
143
+	&PINA,
144
+	&PINB,
145
+	&PINC,
146
+	&PIND,
147
+	&PINE,
148
+	&PINF,
149
+	&PING,
150
+	&PINH,
151
+	NOT_A_PIN,
152
+	&PINJ,
153
+	&PINK,
154
+	&PINL,
155
+};
156
+
157
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
158
+	// PORTLIST		
159
+	// -------------------------------------------		
160
+	PE	, // PE 0 ** 0 ** USART0_RX	
161
+	PE	, // PE 1 ** 1 ** USART0_TX	
162
+	PE	, // PE 4 ** 2 ** PWM2	
163
+	PE	, // PE 5 ** 3 ** PWM3	
164
+	PG	, // PG 5 ** 4 ** PWM4	
165
+	PE	, // PE 3 ** 5 ** PWM5	
166
+	PH	, // PH 3 ** 6 ** PWM6	
167
+	PH	, // PH 4 ** 7 ** PWM7	
168
+	PH	, // PH 5 ** 8 ** PWM8	
169
+	PH	, // PH 6 ** 9 ** PWM9	
170
+	PB	, // PB 4 ** 10 ** PWM10	
171
+	PB	, // PB 5 ** 11 ** PWM11	
172
+	PB	, // PB 6 ** 12 ** PWM12	
173
+	PB	, // PB 7 ** 13 ** PWM13	
174
+	PJ	, // PJ 1 ** 14 ** USART3_TX	
175
+	PJ	, // PJ 0 ** 15 ** USART3_RX	
176
+	PH	, // PH 1 ** 16 ** USART2_TX	
177
+	PH	, // PH 0 ** 17 ** USART2_RX	
178
+	PD	, // PD 3 ** 18 ** USART1_TX	
179
+	PD	, // PD 2 ** 19 ** USART1_RX	
180
+	PD	, // PD 1 ** 20 ** I2C_SDA	
181
+	PD	, // PD 0 ** 21 ** I2C_SCL	
182
+	PA	, // PA 0 ** 22 ** D22	
183
+	PA	, // PA 1 ** 23 ** D23	
184
+	PA	, // PA 2 ** 24 ** D24	
185
+	PA	, // PA 3 ** 25 ** D25	
186
+	PA	, // PA 4 ** 26 ** D26	
187
+	PA	, // PA 5 ** 27 ** D27	
188
+	PA	, // PA 6 ** 28 ** D28	
189
+	PA	, // PA 7 ** 29 ** D29	
190
+	PC	, // PC 7 ** 30 ** D30	
191
+	PC	, // PC 6 ** 31 ** D31	
192
+	PC	, // PC 5 ** 32 ** D32	
193
+	PC	, // PC 4 ** 33 ** D33	
194
+	PC	, // PC 3 ** 34 ** D34	
195
+	PC	, // PC 2 ** 35 ** D35	
196
+	PC	, // PC 1 ** 36 ** D36	
197
+	PC	, // PC 0 ** 37 ** D37	
198
+	PD	, // PD 7 ** 38 ** D38	
199
+	PG	, // PG 2 ** 39 ** D39	
200
+	PG	, // PG 1 ** 40 ** D40	
201
+	PG	, // PG 0 ** 41 ** D41	
202
+	PL	, // PL 7 ** 42 ** D42	
203
+	PL	, // PL 6 ** 43 ** D43	
204
+	PL	, // PL 5 ** 44 ** D44	
205
+	PL	, // PL 4 ** 45 ** D45	
206
+	PL	, // PL 3 ** 46 ** D46	
207
+	PL	, // PL 2 ** 47 ** D47	
208
+	PL	, // PL 1 ** 48 ** D48	
209
+	PL	, // PL 0 ** 49 ** D49	
210
+	PB	, // PB 3 ** 50 ** SPI_MISO	
211
+	PB	, // PB 2 ** 51 ** SPI_MOSI	
212
+	PB	, // PB 1 ** 52 ** SPI_SCK	
213
+	PB	, // PB 0 ** 53 ** SPI_SS	
214
+	PF	, // PF 0 ** 54 ** A0	
215
+	PF	, // PF 1 ** 55 ** A1	
216
+	PF	, // PF 2 ** 56 ** A2	
217
+	PF	, // PF 3 ** 57 ** A3	
218
+	PF	, // PF 4 ** 58 ** A4	
219
+	PF	, // PF 5 ** 59 ** A5	
220
+	PF	, // PF 6 ** 60 ** A6	
221
+	PF	, // PF 7 ** 61 ** A7	
222
+	PK	, // PK 0 ** 62 ** A8	
223
+	PK	, // PK 1 ** 63 ** A9	
224
+	PK	, // PK 2 ** 64 ** A10	
225
+	PK	, // PK 3 ** 65 ** A11	
226
+	PK	, // PK 4 ** 66 ** A12	
227
+	PK	, // PK 5 ** 67 ** A13	
228
+	PK	, // PK 6 ** 68 ** A14	
229
+	PK	, // PK 7 ** 69 ** A15	
230
+};
231
+
232
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
233
+	// PIN IN PORT		
234
+	// -------------------------------------------		
235
+	_BV( 0 )	, // PE 0 ** 0 ** USART0_RX	
236
+	_BV( 1 )	, // PE 1 ** 1 ** USART0_TX	
237
+	_BV( 4 )	, // PE 4 ** 2 ** PWM2	
238
+	_BV( 5 )	, // PE 5 ** 3 ** PWM3	
239
+	_BV( 5 )	, // PG 5 ** 4 ** PWM4	
240
+	_BV( 3 )	, // PE 3 ** 5 ** PWM5	
241
+	_BV( 3 )	, // PH 3 ** 6 ** PWM6	
242
+	_BV( 4 )	, // PH 4 ** 7 ** PWM7	
243
+	_BV( 5 )	, // PH 5 ** 8 ** PWM8	
244
+	_BV( 6 )	, // PH 6 ** 9 ** PWM9	
245
+	_BV( 4 )	, // PB 4 ** 10 ** PWM10	
246
+	_BV( 5 )	, // PB 5 ** 11 ** PWM11	
247
+	_BV( 6 )	, // PB 6 ** 12 ** PWM12	
248
+	_BV( 7 )	, // PB 7 ** 13 ** PWM13	
249
+	_BV( 1 )	, // PJ 1 ** 14 ** USART3_TX	
250
+	_BV( 0 )	, // PJ 0 ** 15 ** USART3_RX	
251
+	_BV( 1 )	, // PH 1 ** 16 ** USART2_TX	
252
+	_BV( 0 )	, // PH 0 ** 17 ** USART2_RX	
253
+	_BV( 3 )	, // PD 3 ** 18 ** USART1_TX	
254
+	_BV( 2 )	, // PD 2 ** 19 ** USART1_RX	
255
+	_BV( 1 )	, // PD 1 ** 20 ** I2C_SDA	
256
+	_BV( 0 )	, // PD 0 ** 21 ** I2C_SCL	
257
+	_BV( 0 )	, // PA 0 ** 22 ** D22	
258
+	_BV( 1 )	, // PA 1 ** 23 ** D23	
259
+	_BV( 2 )	, // PA 2 ** 24 ** D24	
260
+	_BV( 3 )	, // PA 3 ** 25 ** D25	
261
+	_BV( 4 )	, // PA 4 ** 26 ** D26	
262
+	_BV( 5 )	, // PA 5 ** 27 ** D27	
263
+	_BV( 6 )	, // PA 6 ** 28 ** D28	
264
+	_BV( 7 )	, // PA 7 ** 29 ** D29	
265
+	_BV( 7 )	, // PC 7 ** 30 ** D30	
266
+	_BV( 6 )	, // PC 6 ** 31 ** D31	
267
+	_BV( 5 )	, // PC 5 ** 32 ** D32	
268
+	_BV( 4 )	, // PC 4 ** 33 ** D33	
269
+	_BV( 3 )	, // PC 3 ** 34 ** D34	
270
+	_BV( 2 )	, // PC 2 ** 35 ** D35	
271
+	_BV( 1 )	, // PC 1 ** 36 ** D36	
272
+	_BV( 0 )	, // PC 0 ** 37 ** D37	
273
+	_BV( 7 )	, // PD 7 ** 38 ** D38	
274
+	_BV( 2 )	, // PG 2 ** 39 ** D39	
275
+	_BV( 1 )	, // PG 1 ** 40 ** D40	
276
+	_BV( 0 )	, // PG 0 ** 41 ** D41	
277
+	_BV( 7 )	, // PL 7 ** 42 ** D42	
278
+	_BV( 6 )	, // PL 6 ** 43 ** D43	
279
+	_BV( 5 )	, // PL 5 ** 44 ** D44	
280
+	_BV( 4 )	, // PL 4 ** 45 ** D45	
281
+	_BV( 3 )	, // PL 3 ** 46 ** D46	
282
+	_BV( 2 )	, // PL 2 ** 47 ** D47	
283
+	_BV( 1 )	, // PL 1 ** 48 ** D48	
284
+	_BV( 0 )	, // PL 0 ** 49 ** D49	
285
+	_BV( 3 )	, // PB 3 ** 50 ** SPI_MISO	
286
+	_BV( 2 )	, // PB 2 ** 51 ** SPI_MOSI	
287
+	_BV( 1 )	, // PB 1 ** 52 ** SPI_SCK	
288
+	_BV( 0 )	, // PB 0 ** 53 ** SPI_SS	
289
+	_BV( 0 )	, // PF 0 ** 54 ** A0	
290
+	_BV( 1 )	, // PF 1 ** 55 ** A1	
291
+	_BV( 2 )	, // PF 2 ** 56 ** A2	
292
+	_BV( 3 )	, // PF 3 ** 57 ** A3	
293
+	_BV( 4 )	, // PF 4 ** 58 ** A4	
294
+	_BV( 5 )	, // PF 5 ** 59 ** A5	
295
+	_BV( 6 )	, // PF 6 ** 60 ** A6	
296
+	_BV( 7 )	, // PF 7 ** 61 ** A7	
297
+	_BV( 0 )	, // PK 0 ** 62 ** A8	
298
+	_BV( 1 )	, // PK 1 ** 63 ** A9	
299
+	_BV( 2 )	, // PK 2 ** 64 ** A10	
300
+	_BV( 3 )	, // PK 3 ** 65 ** A11	
301
+	_BV( 4 )	, // PK 4 ** 66 ** A12	
302
+	_BV( 5 )	, // PK 5 ** 67 ** A13	
303
+	_BV( 6 )	, // PK 6 ** 68 ** A14	
304
+	_BV( 7 )	, // PK 7 ** 69 ** A15	
305
+};
306
+
307
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
308
+	// TIMERS		
309
+	// -------------------------------------------		
310
+	NOT_ON_TIMER	, // PE 0 ** 0 ** USART0_RX	
311
+	NOT_ON_TIMER	, // PE 1 ** 1 ** USART0_TX	
312
+	TIMER3B	, // PE 4 ** 2 ** PWM2	
313
+	TIMER3C	, // PE 5 ** 3 ** PWM3	
314
+	TIMER0B	, // PG 5 ** 4 ** PWM4	
315
+	TIMER3A	, // PE 3 ** 5 ** PWM5	
316
+	TIMER4A	, // PH 3 ** 6 ** PWM6	
317
+	TIMER4B	, // PH 4 ** 7 ** PWM7	
318
+	TIMER4C	, // PH 5 ** 8 ** PWM8	
319
+	TIMER2B	, // PH 6 ** 9 ** PWM9	
320
+	TIMER2A	, // PB 4 ** 10 ** PWM10	
321
+	TIMER1A	, // PB 5 ** 11 ** PWM11	
322
+	TIMER1B	, // PB 6 ** 12 ** PWM12	
323
+	TIMER0A	, // PB 7 ** 13 ** PWM13	
324
+	NOT_ON_TIMER	, // PJ 1 ** 14 ** USART3_TX	
325
+	NOT_ON_TIMER	, // PJ 0 ** 15 ** USART3_RX	
326
+	NOT_ON_TIMER	, // PH 1 ** 16 ** USART2_TX	
327
+	NOT_ON_TIMER	, // PH 0 ** 17 ** USART2_RX	
328
+	NOT_ON_TIMER	, // PD 3 ** 18 ** USART1_TX	
329
+	NOT_ON_TIMER	, // PD 2 ** 19 ** USART1_RX	
330
+	NOT_ON_TIMER	, // PD 1 ** 20 ** I2C_SDA	
331
+	NOT_ON_TIMER	, // PD 0 ** 21 ** I2C_SCL	
332
+	NOT_ON_TIMER	, // PA 0 ** 22 ** D22	
333
+	NOT_ON_TIMER	, // PA 1 ** 23 ** D23	
334
+	NOT_ON_TIMER	, // PA 2 ** 24 ** D24	
335
+	NOT_ON_TIMER	, // PA 3 ** 25 ** D25	
336
+	NOT_ON_TIMER	, // PA 4 ** 26 ** D26	
337
+	NOT_ON_TIMER	, // PA 5 ** 27 ** D27	
338
+	NOT_ON_TIMER	, // PA 6 ** 28 ** D28	
339
+	NOT_ON_TIMER	, // PA 7 ** 29 ** D29	
340
+	NOT_ON_TIMER	, // PC 7 ** 30 ** D30	
341
+	NOT_ON_TIMER	, // PC 6 ** 31 ** D31	
342
+	NOT_ON_TIMER	, // PC 5 ** 32 ** D32	
343
+	NOT_ON_TIMER	, // PC 4 ** 33 ** D33	
344
+	NOT_ON_TIMER	, // PC 3 ** 34 ** D34	
345
+	NOT_ON_TIMER	, // PC 2 ** 35 ** D35	
346
+	NOT_ON_TIMER	, // PC 1 ** 36 ** D36	
347
+	NOT_ON_TIMER	, // PC 0 ** 37 ** D37	
348
+	NOT_ON_TIMER	, // PD 7 ** 38 ** D38	
349
+	NOT_ON_TIMER	, // PG 2 ** 39 ** D39	
350
+	NOT_ON_TIMER	, // PG 1 ** 40 ** D40	
351
+	NOT_ON_TIMER	, // PG 0 ** 41 ** D41	
352
+	NOT_ON_TIMER	, // PL 7 ** 42 ** D42	
353
+	NOT_ON_TIMER	, // PL 6 ** 43 ** D43	
354
+	TIMER5C	, // PL 5 ** 44 ** D44	
355
+	TIMER5B	, // PL 4 ** 45 ** D45	
356
+	TIMER5A	, // PL 3 ** 46 ** D46	
357
+	NOT_ON_TIMER	, // PL 2 ** 47 ** D47	
358
+	NOT_ON_TIMER	, // PL 1 ** 48 ** D48	
359
+	NOT_ON_TIMER	, // PL 0 ** 49 ** D49	
360
+	NOT_ON_TIMER	, // PB 3 ** 50 ** SPI_MISO	
361
+	NOT_ON_TIMER	, // PB 2 ** 51 ** SPI_MOSI	
362
+	NOT_ON_TIMER	, // PB 1 ** 52 ** SPI_SCK	
363
+	NOT_ON_TIMER	, // PB 0 ** 53 ** SPI_SS	
364
+	NOT_ON_TIMER	, // PF 0 ** 54 ** A0	
365
+	NOT_ON_TIMER	, // PF 1 ** 55 ** A1	
366
+	NOT_ON_TIMER	, // PF 2 ** 56 ** A2	
367
+	NOT_ON_TIMER	, // PF 3 ** 57 ** A3	
368
+	NOT_ON_TIMER	, // PF 4 ** 58 ** A4	
369
+	NOT_ON_TIMER	, // PF 5 ** 59 ** A5	
370
+	NOT_ON_TIMER	, // PF 6 ** 60 ** A6	
371
+	NOT_ON_TIMER	, // PF 7 ** 61 ** A7	
372
+	NOT_ON_TIMER	, // PK 0 ** 62 ** A8	
373
+	NOT_ON_TIMER	, // PK 1 ** 63 ** A9	
374
+	NOT_ON_TIMER	, // PK 2 ** 64 ** A10	
375
+	NOT_ON_TIMER	, // PK 3 ** 65 ** A11	
376
+	NOT_ON_TIMER	, // PK 4 ** 66 ** A12	
377
+	NOT_ON_TIMER	, // PK 5 ** 67 ** A13	
378
+	NOT_ON_TIMER	, // PK 6 ** 68 ** A14	
379
+	NOT_ON_TIMER	, // PK 7 ** 69 ** A15	
380
+};
381
+#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
382
+// these arrays map port names (e.g. port B) to the
383
+// appropriate addresses for various functions (e.g. reading
384
+// and writing)
385
+const uint16_t PROGMEM port_to_mode_PGM[] =
386
+{
387
+        NOT_A_PORT,
388
+    &DDRA,
389
+        &DDRB,
390
+        &DDRC,
391
+        &DDRD,
392
+};
393
+
394
+const uint16_t PROGMEM port_to_output_PGM[] =
395
+{
396
+        NOT_A_PORT,
397
+        &PORTA,
398
+        &PORTB,
399
+        &PORTC,
400
+        &PORTD,
401
+};
402
+const uint16_t PROGMEM port_to_input_PGM[] =
403
+{
404
+        NOT_A_PORT,
405
+        &PINA,
406
+        &PINB,
407
+        &PINC,
408
+        &PIND,
409
+};
410
+const uint8_t PROGMEM digital_pin_to_port_PGM[] =
411
+{
412
+        PB, /* 0 */
413
+        PB,
414
+        PB,
415
+        PB,
416
+        PB,
417
+        PB,
418
+        PB,
419
+        PB,
420
+        PD, /* 8 */
421
+        PD,
422
+        PD,
423
+        PD,
424
+        PD,
425
+        PD,
426
+        PD,
427
+        PD,
428
+        PC, /* 16 */
429
+        PC,
430
+        PC,
431
+        PC,
432
+        PC,
433
+        PC,
434
+        PC,
435
+        PC,
436
+        PA, /* 24 */
437
+        PA,
438
+        PA,
439
+        PA,
440
+        PA,
441
+        PA,
442
+        PA,
443
+        PA  /* 31 */
444
+};
445
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
446
+{
447
+        _BV(0), /* 0, port B */
448
+        _BV(1),
449
+        _BV(2),
450
+        _BV(3),
451
+        _BV(4),
452
+        _BV(5),
453
+        _BV(6),
454
+        _BV(7),
455
+        _BV(0), /* 8, port D */
456
+        _BV(1),
457
+        _BV(2),
458
+        _BV(3),
459
+        _BV(4),
460
+        _BV(5),
461
+        _BV(6),
462
+        _BV(7),
463
+        _BV(0), /* 16, port C */
464
+        _BV(1),
465
+        _BV(2),
466
+        _BV(3),
467
+        _BV(4),
468
+        _BV(5),
469
+        _BV(6),
470
+        _BV(7),
471
+        _BV(7), /* 24, port A */
472
+        _BV(6),
473
+        _BV(5),
474
+        _BV(4),
475
+        _BV(3),
476
+        _BV(2),
477
+        _BV(1),
478
+        _BV(0)
479
+};
480
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
481
+{
482
+        NOT_ON_TIMER,   /* 0  - PB0 */
483
+        NOT_ON_TIMER,   /* 1  - PB1 */
484
+        NOT_ON_TIMER,   /* 2  - PB2 */
485
+        TIMER0A,        /* 3  - PB3 */
486
+        TIMER0B,                /* 4  - PB4 */
487
+        NOT_ON_TIMER,   /* 5  - PB5 */
488
+        NOT_ON_TIMER,   /* 6  - PB6 */
489
+        NOT_ON_TIMER,   /* 7  - PB7 */
490
+        NOT_ON_TIMER,   /* 8  - PD0 */
491
+        NOT_ON_TIMER,   /* 9  - PD1 */
492
+        NOT_ON_TIMER,   /* 10 - PD2 */
493
+        NOT_ON_TIMER,   /* 11 - PD3 */
494
+        TIMER1B,        /* 12 - PD4 */
495
+        TIMER1A,        /* 13 - PD5 */
496
+        TIMER2B,        /* 14 - PD6 */
497
+        TIMER2A,        /* 15 - PD7 */
498
+        NOT_ON_TIMER,   /* 16 - PC0 */
499
+        NOT_ON_TIMER,   /* 17 - PC1 */
500
+        NOT_ON_TIMER,   /* 18 - PC2 */
501
+        NOT_ON_TIMER,   /* 19 - PC3 */
502
+        NOT_ON_TIMER,   /* 20 - PC4 */
503
+        NOT_ON_TIMER,   /* 21 - PC5 */
504
+        NOT_ON_TIMER,   /* 22 - PC6 */
505
+        NOT_ON_TIMER,   /* 23 - PC7 */
506
+        NOT_ON_TIMER,   /* 24 - PA0 */
507
+        NOT_ON_TIMER,   /* 25 - PA1 */
508
+        NOT_ON_TIMER,   /* 26 - PA2 */
509
+        NOT_ON_TIMER,   /* 27 - PA3 */
510
+        NOT_ON_TIMER,   /* 28 - PA4 */
511
+        NOT_ON_TIMER,   /* 29 - PA5 */
512
+        NOT_ON_TIMER,   /* 30 - PA6 */
513
+        NOT_ON_TIMER   /* 31 - PA7 */
514
+};
515
+
516
+#else
517
+// these arrays map port names (e.g. port B) to the
518
+// appropriate addresses for various functions (e.g. reading
519
+// and writing)
520
+const uint16_t PROGMEM port_to_mode_PGM[] = {
521
+	NOT_A_PORT,
522
+	NOT_A_PORT,
523
+	&DDRB,
524
+	&DDRC,
525
+	&DDRD,
526
+};
527
+
528
+const uint16_t PROGMEM port_to_output_PGM[] = {
529
+	NOT_A_PORT,
530
+	NOT_A_PORT,
531
+	&PORTB,
532
+	&PORTC,
533
+	&PORTD,
534
+};
535
+
536
+const uint16_t PROGMEM port_to_input_PGM[] = {
537
+	NOT_A_PORT,
538
+	NOT_A_PORT,
539
+	&PINB,
540
+	&PINC,
541
+	&PIND,
542
+};
543
+
544
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
545
+	PD, /* 0 */
546
+	PD,
547
+	PD,
548
+	PD,
549
+	PD,
550
+	PD,
551
+	PD,
552
+	PD,
553
+	PB, /* 8 */
554
+	PB,
555
+	PB,
556
+	PB,
557
+	PB,
558
+	PB,
559
+	PC, /* 14 */
560
+	PC,
561
+	PC,
562
+	PC,
563
+	PC,
564
+	PC,
565
+};
566
+
567
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
568
+	_BV(0), /* 0, port D */
569
+	_BV(1),
570
+	_BV(2),
571
+	_BV(3),
572
+	_BV(4),
573
+	_BV(5),
574
+	_BV(6),
575
+	_BV(7),
576
+	_BV(0), /* 8, port B */
577
+	_BV(1),
578
+	_BV(2),
579
+	_BV(3),
580
+	_BV(4),
581
+	_BV(5),
582
+	_BV(0), /* 14, port C */
583
+	_BV(1),
584
+	_BV(2),
585
+	_BV(3),
586
+	_BV(4),
587
+	_BV(5),
588
+};
589
+
590
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
591
+	NOT_ON_TIMER, /* 0 - port D */
592
+	NOT_ON_TIMER,
593
+	NOT_ON_TIMER,
594
+	// on the ATmega168, digital pin 3 has hardware pwm
595
+#if defined(__AVR_ATmega8__)
596
+	NOT_ON_TIMER,
597
+#else
598
+	TIMER2B,
599
+#endif
600
+	NOT_ON_TIMER,
601
+	// on the ATmega168, digital pins 5 and 6 have hardware pwm
602
+#if defined(__AVR_ATmega8__)
603
+	NOT_ON_TIMER,
604
+	NOT_ON_TIMER,
605
+#else
606
+	TIMER0B,
607
+	TIMER0A,
608
+#endif
609
+	NOT_ON_TIMER,
610
+	NOT_ON_TIMER, /* 8 - port B */
611
+	TIMER1A,
612
+	TIMER1B,
613
+#if defined(__AVR_ATmega8__)
614
+	TIMER2,
615
+#else
616
+	TIMER2A,
617
+#endif
618
+	NOT_ON_TIMER,
619
+	NOT_ON_TIMER,
620
+	NOT_ON_TIMER,
621
+	NOT_ON_TIMER, /* 14 - port C */
622
+	NOT_ON_TIMER,
623
+	NOT_ON_TIMER,
624
+	NOT_ON_TIMER,
625
+	NOT_ON_TIMER,
626
+};
627
+#endif

+ 94
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.h Dosyayı Görüntüle

@@ -0,0 +1,94 @@
1
+/*
2
+  pins_arduino.h - Pin definition functions for Arduino
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2007 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
+*/
24
+
25
+#ifndef Pins_Arduino_h
26
+#define Pins_Arduino_h
27
+
28
+#include <avr/pgmspace.h>
29
+
30
+#define NOT_A_PIN 0
31
+#define NOT_A_PORT 0
32
+
33
+#define NOT_ON_TIMER 0
34
+#define TIMER0A 1
35
+#define TIMER0B 2
36
+#define TIMER1A 3
37
+#define TIMER1B 4
38
+#define TIMER2  5
39
+#define TIMER2A 6
40
+#define TIMER2B 7
41
+
42
+#define TIMER3A 8
43
+#define TIMER3B 9
44
+#define TIMER3C 10
45
+#define TIMER4A 11
46
+#define TIMER4B 12
47
+#define TIMER4C 13
48
+#define TIMER5A 14
49
+#define TIMER5B 15
50
+#define TIMER5C 16
51
+
52
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
53
+const static uint8_t SS   = 53;
54
+const static uint8_t MOSI = 51;
55
+const static uint8_t MISO = 50;
56
+const static uint8_t SCK  = 52;
57
+#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
58
+const static uint8_t SS   = 4;
59
+const static uint8_t MOSI = 5;
60
+const static uint8_t MISO = 6;
61
+const static uint8_t SCK  = 7;
62
+
63
+#else
64
+const static uint8_t SS   = 10;
65
+const static uint8_t MOSI = 11;
66
+const static uint8_t MISO = 12;
67
+const static uint8_t SCK  = 13;
68
+#endif
69
+
70
+// On the ATmega1280, the addresses of some of the port registers are
71
+// greater than 255, so we can't store them in uint8_t's.
72
+extern const uint16_t PROGMEM port_to_mode_PGM[];
73
+extern const uint16_t PROGMEM port_to_input_PGM[];
74
+extern const uint16_t PROGMEM port_to_output_PGM[];
75
+
76
+extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
77
+// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
78
+extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
79
+extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
80
+
81
+// Get the bit location within the hardware port of the given virtual pin.
82
+// This comes from the pins_*.c file for the active board configuration.
83
+// 
84
+// These perform slightly better as macros compared to inline functions
85
+//
86
+#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
87
+#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
88
+#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
89
+#define analogInPinToBit(P) (P)
90
+#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
91
+#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
92
+#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
93
+
94
+#endif

+ 289
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring.c Dosyayı Görüntüle

@@ -0,0 +1,289 @@
1
+/*
2
+  wiring.c - Partial implementation of the Wiring API for the ATmega8.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id$
23
+*/
24
+
25
+#include "wiring_private.h"
26
+
27
+// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
28
+// the overflow handler is called every 256 ticks.
29
+#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
30
+
31
+// the whole number of milliseconds per timer0 overflow
32
+#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
33
+
34
+// the fractional number of milliseconds per timer0 overflow. we shift right
35
+// by three to fit these numbers into a byte. (for the clock speeds we care
36
+// about - 8 and 16 MHz - this doesn't lose precision.)
37
+#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
38
+#define FRACT_MAX (1000 >> 3)
39
+
40
+volatile unsigned long timer0_overflow_count = 0;
41
+volatile unsigned long timer0_millis = 0;
42
+static unsigned char timer0_fract = 0;
43
+
44
+SIGNAL(TIMER0_OVF_vect)
45
+{
46
+	// copy these to local variables so they can be stored in registers
47
+	// (volatile variables must be read from memory on every access)
48
+	unsigned long m = timer0_millis;
49
+	unsigned char f = timer0_fract;
50
+
51
+	m += MILLIS_INC;
52
+	f += FRACT_INC;
53
+	if (f >= FRACT_MAX) {
54
+		f -= FRACT_MAX;
55
+		m += 1;
56
+	}
57
+
58
+	timer0_fract = f;
59
+	timer0_millis = m;
60
+	timer0_overflow_count++;
61
+}
62
+
63
+unsigned long millis()
64
+{
65
+	unsigned long m;
66
+	uint8_t oldSREG = SREG;
67
+
68
+	// disable interrupts while we read timer0_millis or we might get an
69
+	// inconsistent value (e.g. in the middle of a write to timer0_millis)
70
+	cli();
71
+	m = timer0_millis;
72
+	SREG = oldSREG;
73
+
74
+	return m;
75
+}
76
+
77
+unsigned long micros() {
78
+	unsigned long m;
79
+	uint8_t oldSREG = SREG, t;
80
+	
81
+	cli();
82
+	m = timer0_overflow_count;
83
+#if defined(TCNT0)
84
+	t = TCNT0;
85
+#elif defined(TCNT0L)
86
+	t = TCNT0L;
87
+#else
88
+	#error TIMER 0 not defined
89
+#endif
90
+
91
+  
92
+#ifdef TIFR0
93
+	if ((TIFR0 & _BV(TOV0)) && (t < 255))
94
+		m++;
95
+#else
96
+	if ((TIFR & _BV(TOV0)) && (t < 255))
97
+		m++;
98
+#endif
99
+
100
+	SREG = oldSREG;
101
+	
102
+	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
103
+}
104
+
105
+void delay(unsigned long ms)
106
+{
107
+	uint16_t start = (uint16_t)micros();
108
+
109
+	while (ms > 0) {
110
+		if (((uint16_t)micros() - start) >= 1000) {
111
+			ms--;
112
+			start += 1000;
113
+		}
114
+	}
115
+}
116
+
117
+/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
118
+void delayMicroseconds(unsigned int us)
119
+{
120
+	// calling avrlib's delay_us() function with low values (e.g. 1 or
121
+	// 2 microseconds) gives delays longer than desired.
122
+	//delay_us(us);
123
+
124
+#if F_CPU >= 16000000L
125
+	// for the 16 MHz clock on most Arduino boards
126
+
127
+	// for a one-microsecond delay, simply return.  the overhead
128
+	// of the function call yields a delay of approximately 1 1/8 us.
129
+	if (--us == 0)
130
+		return;
131
+
132
+	// the following loop takes a quarter of a microsecond (4 cycles)
133
+	// per iteration, so execute it four times for each microsecond of
134
+	// delay requested.
135
+	us <<= 2;
136
+
137
+	// account for the time taken in the preceeding commands.
138
+	us -= 2;
139
+#else
140
+	// for the 8 MHz internal clock on the ATmega168
141
+
142
+	// for a one- or two-microsecond delay, simply return.  the overhead of
143
+	// the function calls takes more than two microseconds.  can't just
144
+	// subtract two, since us is unsigned; we'd overflow.
145
+	if (--us == 0)
146
+		return;
147
+	if (--us == 0)
148
+		return;
149
+
150
+	// the following loop takes half of a microsecond (4 cycles)
151
+	// per iteration, so execute it twice for each microsecond of
152
+	// delay requested.
153
+	us <<= 1;
154
+    
155
+	// partially compensate for the time taken by the preceeding commands.
156
+	// we can't subtract any more than this or we'd overflow w/ small delays.
157
+	us--;
158
+#endif
159
+
160
+	// busy wait
161
+	__asm__ __volatile__ (
162
+		"1: sbiw %0,1" "\n\t" // 2 cycles
163
+		"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
164
+	);
165
+}
166
+
167
+void init()
168
+{
169
+	// this needs to be called before setup() or some functions won't
170
+	// work there
171
+	sei();
172
+	
173
+	// on the ATmega168, timer 0 is also used for fast hardware pwm
174
+	// (using phase-correct PWM would mean that timer 0 overflowed half as often
175
+	// resulting in different millis() behavior on the ATmega8 and ATmega168)
176
+#if defined(TCCR0A) && defined(WGM01)
177
+	sbi(TCCR0A, WGM01);
178
+	sbi(TCCR0A, WGM00);
179
+#endif  
180
+
181
+	// set timer 0 prescale factor to 64
182
+#if defined(__AVR_ATmega128__)
183
+	// CPU specific: different values for the ATmega128
184
+	sbi(TCCR0, CS02);
185
+#elif defined(TCCR0) && defined(CS01) && defined(CS00)
186
+	// this combination is for the standard atmega8
187
+	sbi(TCCR0, CS01);
188
+	sbi(TCCR0, CS00);
189
+#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
190
+	// this combination is for the standard 168/328/1280/2560
191
+	sbi(TCCR0B, CS01);
192
+	sbi(TCCR0B, CS00);
193
+#elif defined(TCCR0A) && defined(CS01) && defined(CS00)
194
+	// this combination is for the __AVR_ATmega645__ series
195
+	sbi(TCCR0A, CS01);
196
+	sbi(TCCR0A, CS00);
197
+#else
198
+	#error Timer 0 prescale factor 64 not set correctly
199
+#endif
200
+
201
+	// enable timer 0 overflow interrupt
202
+#if defined(TIMSK) && defined(TOIE0)
203
+	sbi(TIMSK, TOIE0);
204
+#elif defined(TIMSK0) && defined(TOIE0)
205
+	sbi(TIMSK0, TOIE0);
206
+#else
207
+	#error	Timer 0 overflow interrupt not set correctly
208
+#endif
209
+
210
+	// timers 1 and 2 are used for phase-correct hardware pwm
211
+	// this is better for motors as it ensures an even waveform
212
+	// note, however, that fast pwm mode can achieve a frequency of up
213
+	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
214
+
215
+	TCCR1B = 0;
216
+
217
+	// set timer 1 prescale factor to 64
218
+#if defined(TCCR1B) && defined(CS11) && defined(CS10)
219
+	sbi(TCCR1B, CS11);
220
+	sbi(TCCR1B, CS10);
221
+#elif defined(TCCR1) && defined(CS11) && defined(CS10)
222
+	sbi(TCCR1, CS11);
223
+	sbi(TCCR1, CS10);
224
+#endif
225
+	// put timer 1 in 8-bit phase correct pwm mode
226
+#if defined(TCCR1A) && defined(WGM10)
227
+	sbi(TCCR1A, WGM10);
228
+#elif defined(TCCR1)
229
+	#warning this needs to be finished
230
+#endif
231
+
232
+	// set timer 2 prescale factor to 64
233
+#if defined(TCCR2) && defined(CS22)
234
+	sbi(TCCR2, CS22);
235
+#elif defined(TCCR2B) && defined(CS22)
236
+	sbi(TCCR2B, CS22);
237
+#else
238
+	#warning Timer 2 not finished (may not be present on this CPU)
239
+#endif
240
+
241
+	// configure timer 2 for phase correct pwm (8-bit)
242
+#if defined(TCCR2) && defined(WGM20)
243
+	sbi(TCCR2, WGM20);
244
+#elif defined(TCCR2A) && defined(WGM20)
245
+	sbi(TCCR2A, WGM20);
246
+#else
247
+	#warning Timer 2 not finished (may not be present on this CPU)
248
+#endif
249
+
250
+#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
251
+	sbi(TCCR3B, CS31);		// set timer 3 prescale factor to 64
252
+	sbi(TCCR3B, CS30);
253
+	sbi(TCCR3A, WGM30);		// put timer 3 in 8-bit phase correct pwm mode
254
+#endif
255
+	
256
+#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
257
+	sbi(TCCR4B, CS41);		// set timer 4 prescale factor to 64
258
+	sbi(TCCR4B, CS40);
259
+	sbi(TCCR4A, WGM40);		// put timer 4 in 8-bit phase correct pwm mode
260
+#endif
261
+
262
+#if defined(TCCR5B) && defined(CS51) && defined(WGM50)
263
+	sbi(TCCR5B, CS51);		// set timer 5 prescale factor to 64
264
+	sbi(TCCR5B, CS50);
265
+	sbi(TCCR5A, WGM50);		// put timer 5 in 8-bit phase correct pwm mode
266
+#endif
267
+
268
+#if defined(ADCSRA)
269
+	// set a2d prescale factor to 128
270
+	// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
271
+	// XXX: this will not work properly for other clock speeds, and
272
+	// this code should use F_CPU to determine the prescale factor.
273
+	sbi(ADCSRA, ADPS2);
274
+	sbi(ADCSRA, ADPS1);
275
+	sbi(ADCSRA, ADPS0);
276
+
277
+	// enable a2d conversions
278
+	sbi(ADCSRA, ADEN);
279
+#endif
280
+
281
+	// the bootloader connects pins 0 and 1 to the USART; disconnect them
282
+	// here so they can be used as normal digital i/o; they will be
283
+	// reconnected in Serial.begin()
284
+#if defined(UCSRB)
285
+	UCSRB = 0;
286
+#elif defined(UCSR0B)
287
+	UCSR0B = 0;
288
+#endif
289
+}

+ 138
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring.h Dosyayı Görüntüle

@@ -0,0 +1,138 @@
1
+/*
2
+  wiring.h - Partial implementation of the Wiring API for the ATmega8.
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  $Id$
23
+*/
24
+
25
+#ifndef Wiring_h
26
+#define Wiring_h
27
+
28
+#include <avr/io.h>
29
+#include <stdlib.h>
30
+#include "binary.h"
31
+
32
+#ifdef __cplusplus
33
+extern "C"{
34
+#endif
35
+
36
+#define HIGH 0x1
37
+#define LOW  0x0
38
+
39
+#define INPUT 0x0
40
+#define OUTPUT 0x1
41
+
42
+#define true 0x1
43
+#define false 0x0
44
+
45
+#define PI 3.1415926535897932384626433832795
46
+#define HALF_PI 1.5707963267948966192313216916398
47
+#define TWO_PI 6.283185307179586476925286766559
48
+#define DEG_TO_RAD 0.017453292519943295769236907684886
49
+#define RAD_TO_DEG 57.295779513082320876798154814105
50
+
51
+#define SERIAL  0x0
52
+#define DISPLAY 0x1
53
+
54
+#define LSBFIRST 0
55
+#define MSBFIRST 1
56
+
57
+#define CHANGE 1
58
+#define FALLING 2
59
+#define RISING 3
60
+
61
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
62
+#define INTERNAL1V1 2
63
+#define INTERNAL2V56 3
64
+#else
65
+#define INTERNAL 3
66
+#endif
67
+#define DEFAULT 1
68
+#define EXTERNAL 0
69
+
70
+// undefine stdlib's abs if encountered
71
+#ifdef abs
72
+#undef abs
73
+#endif
74
+
75
+#define min(a,b) ((a)<(b)?(a):(b))
76
+#define max(a,b) ((a)>(b)?(a):(b))
77
+#define abs(x) ((x)>0?(x):-(x))
78
+#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
79
+
80
+// Removed to work with newer AVRLIBC
81
+//#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
82
+
83
+#define radians(deg) ((deg)*DEG_TO_RAD)
84
+#define degrees(rad) ((rad)*RAD_TO_DEG)
85
+#define sq(x) ((x)*(x))
86
+
87
+#define interrupts() sei()
88
+#define noInterrupts() cli()
89
+
90
+#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
91
+#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
92
+#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
93
+
94
+#define lowByte(w) ((uint8_t) ((w) & 0xff))
95
+#define highByte(w) ((uint8_t) ((w) >> 8))
96
+
97
+#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
98
+#define bitSet(value, bit) ((value) |= (1UL << (bit)))
99
+#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
100
+#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
101
+
102
+
103
+typedef unsigned int word;
104
+
105
+#define bit(b) (1UL << (b))
106
+
107
+typedef uint8_t boolean;
108
+typedef uint8_t byte;
109
+
110
+void init(void);
111
+
112
+void pinMode(uint8_t, uint8_t);
113
+void digitalWrite(uint8_t, uint8_t);
114
+int digitalRead(uint8_t);
115
+int analogRead(uint8_t);
116
+void analogReference(uint8_t mode);
117
+void analogWrite(uint8_t, int);
118
+
119
+unsigned long millis(void);
120
+unsigned long micros(void);
121
+void delay(unsigned long);
122
+void delayMicroseconds(unsigned int us);
123
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
124
+
125
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
126
+uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
127
+
128
+void attachInterrupt(uint8_t, void (*)(void), int mode);
129
+void detachInterrupt(uint8_t);
130
+
131
+void setup(void);
132
+void loop(void);
133
+
134
+#ifdef __cplusplus
135
+} // extern "C"
136
+#endif
137
+
138
+#endif

+ 259
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring_analog.c Dosyayı Görüntüle

@@ -0,0 +1,259 @@
1
+/*
2
+  wiring_analog.c - analog input and output
3
+  Part of Arduino - http://www.arduino.cc/
4
+
5
+  Copyright (c) 2005-2006 David A. Mellis
6
+
7
+  This library is free software; you can redistribute it and/or
8
+  modify it under the terms of the GNU Lesser General Public
9
+  License as published by the Free Software Foundation; either
10
+  version 2.1 of the License, or (at your option) any later version.
11
+
12
+  This library is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+  Lesser General Public License for more details.
16
+
17
+  You should have received a copy of the GNU Lesser General
18
+  Public License along with this library; if not, write to the
19
+  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+  Boston, MA  02111-1307  USA
21
+
22
+  Modified 28 September 2010 by Mark Sproul
23
+
24
+  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
25
+*/
26
+
27
+#include "wiring_private.h"
28
+#include "pins_arduino.h"
29
+
30
+uint8_t analog_reference = DEFAULT;
31
+
32
+void analogReference(uint8_t mode)
33
+{
34
+	// can't actually set the register here because the default setting
35
+	// will connect AVCC and the AREF pin, which would cause a short if
36
+	// there's something connected to AREF.
37
+	analog_reference = mode;
38
+}
39
+
40
+int analogRead(uint8_t pin)
41
+{
42
+	uint8_t low, high;
43
+
44
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
45
+	if (pin >= 54) pin -= 54; // allow for channel or pin numbers
46
+#else
47
+	if (pin >= 14) pin -= 14; // allow for channel or pin numbers
48
+#endif
49
+
50
+#if defined(ADCSRB) && defined(MUX5)
51
+	// the MUX5 bit of ADCSRB selects whether we're reading from channels
52
+	// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
53
+	ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
54
+#endif
55
+  
56
+	// set the analog reference (high two bits of ADMUX) and select the
57
+	// channel (low 4 bits).  this also sets ADLAR (left-adjust result)
58
+	// to 0 (the default).
59
+#if defined(ADMUX)
60
+	ADMUX = (analog_reference << 6) | (pin & 0x07);
61
+#endif
62
+
63
+	// without a delay, we seem to read from the wrong channel
64
+	//delay(1);
65
+
66
+#if defined(ADCSRA) && defined(ADCL)
67
+	// start the conversion
68
+	sbi(ADCSRA, ADSC);
69
+
70
+	// ADSC is cleared when the conversion finishes
71
+	while (bit_is_set(ADCSRA, ADSC));
72
+
73
+	// we have to read ADCL first; doing so locks both ADCL
74
+	// and ADCH until ADCH is read.  reading ADCL second would
75
+	// cause the results of each conversion to be discarded,
76
+	// as ADCL and ADCH would be locked when it completed.
77
+	low  = ADCL;
78
+	high = ADCH;
79
+#else
80
+	// we dont have an ADC, return 0
81
+	low  = 0;
82
+	high = 0;
83
+#endif
84
+
85
+	// combine the two bytes
86
+	return (high << 8) | low;
87
+}
88
+
89
+// Right now, PWM output only works on the pins with
90
+// hardware support.  These are defined in the appropriate
91
+// pins_*.c file.  For the rest of the pins, we default
92
+// to digital output.
93
+void analogWrite(uint8_t pin, int val)
94
+{
95
+	// We need to make sure the PWM output is enabled for those pins
96
+	// that support it, as we turn it off when digitally reading or
97
+	// writing with them.  Also, make sure the pin is in output mode
98
+	// for consistenty with Wiring, which doesn't require a pinMode
99
+	// call for the analog output pins.
100
+	pinMode(pin, OUTPUT);
101
+	if (val == 0)
102
+	{
103
+		digitalWrite(pin, LOW);
104
+	}
105
+	else if (val == 255)
106
+	{
107
+		digitalWrite(pin, HIGH);
108
+	}
109
+	else
110
+	{
111
+		switch(digitalPinToTimer(pin))
112
+		{
113
+			// XXX fix needed for atmega8
114
+			#if defined(TCCR0) && defined(COM00) && !defined(__AVR_ATmega8__)
115
+			case TIMER0A:
116
+				// connect pwm to pin on timer 0
117
+				sbi(TCCR0, COM00);
118
+				OCR0 = val; // set pwm duty
119
+				break;
120
+			#endif
121
+
122
+			#if defined(TCCR0A) && defined(COM0A1)
123
+			case TIMER0A:
124
+				// connect pwm to pin on timer 0, channel A
125
+				sbi(TCCR0A, COM0A1);
126
+				OCR0A = val; // set pwm duty
127
+				break;
128
+			#endif
129
+
130
+			#if defined(TCCR0A) && defined(COM0B1)
131
+			case TIMER0B:
132
+				// connect pwm to pin on timer 0, channel B
133
+				sbi(TCCR0A, COM0B1);
134
+				OCR0B = val; // set pwm duty
135
+				break;
136
+			#endif
137
+
138
+			#if defined(TCCR1A) && defined(COM1A1)
139
+			case TIMER1A:
140
+				// connect pwm to pin on timer 1, channel A
141
+				sbi(TCCR1A, COM1A1);
142
+				OCR1A = val; // set pwm duty
143
+				break;
144
+			#endif
145
+
146
+			#if defined(TCCR1A) && defined(COM1B1)
147
+			case TIMER1B:
148
+				// connect pwm to pin on timer 1, channel B
149
+				sbi(TCCR1A, COM1B1);
150
+				OCR1B = val; // set pwm duty
151
+				break;
152
+			#endif
153
+
154
+			#if defined(TCCR2) && defined(COM21)
155
+			case TIMER2:
156
+				// connect pwm to pin on timer 2
157
+				sbi(TCCR2, COM21);
158
+				OCR2 = val; // set pwm duty
159
+				break;
160
+			#endif
161
+
162
+			#if defined(TCCR2A) && defined(COM2A1)
163
+			case TIMER2A:
164
+				// connect pwm to pin on timer 2, channel A
165
+				sbi(TCCR2A, COM2A1);
166
+				OCR2A = val; // set pwm duty
167
+				break;
168
+			#endif
169
+
170
+			#if defined(TCCR2A) && defined(COM2B1)
171
+			case TIMER2B:
172
+				// connect pwm to pin on timer 2, channel B
173
+				sbi(TCCR2A, COM2B1);
174
+				OCR2B = val; // set pwm duty
175
+				break;
176
+			#endif
177
+
178
+			#if defined(TCCR3A) && defined(COM3A1)
179
+			case TIMER3A:
180
+				// connect pwm to pin on timer 3, channel A
181
+				sbi(TCCR3A, COM3A1);
182
+				OCR3A = val; // set pwm duty
183
+				break;
184
+			#endif
185
+
186
+			#if defined(TCCR3A) && defined(COM3B1)
187
+			case TIMER3B:
188
+				// connect pwm to pin on timer 3, channel B
189
+				sbi(TCCR3A, COM3B1);
190
+				OCR3B = val; // set pwm duty
191
+				break;
192
+			#endif
193
+
194
+			#if defined(TCCR3A) && defined(COM3C1)
195
+			case TIMER3C:
196
+				// connect pwm to pin on timer 3, channel C
197
+				sbi(TCCR3A, COM3C1);
198
+				OCR3C = val; // set pwm duty
199
+				break;
200
+			#endif
201
+
202
+			#if defined(TCCR4A) && defined(COM4A1)
203
+			case TIMER4A:
204
+				// connect pwm to pin on timer 4, channel A
205
+				sbi(TCCR4A, COM4A1);
206
+				OCR4A = val; // set pwm duty
207
+				break;
208
+			#endif
209
+
210
+			#if defined(TCCR4A) && defined(COM4B1)
211
+			case TIMER4B:
212
+				// connect pwm to pin on timer 4, channel B
213
+				sbi(TCCR4A, COM4B1);
214
+				OCR4B = val; // set pwm duty
215
+				break;
216
+			#endif
217
+
218
+			#if defined(TCCR4A) && defined(COM4C1)
219
+			case TIMER4C:
220
+				// connect pwm to pin on timer 4, channel C
221
+				sbi(TCCR4A, COM4C1);
222
+				OCR4C = val; // set pwm duty
223
+				break;
224
+			#endif
225
+
226
+			#if defined(TCCR5A) && defined(COM5A1)
227
+			case TIMER5A:
228
+				// connect pwm to pin on timer 5, channel A
229
+				sbi(TCCR5A, COM5A1);
230
+				OCR5A = val; // set pwm duty
231
+				break;
232
+			#endif
233
+
234
+			#if defined(TCCR5A) && defined(COM5B1)
235
+			case TIMER5B:
236
+				// connect pwm to pin on timer 5, channel B
237
+				sbi(TCCR5A, COM5B1);
238
+				OCR5B = val; // set pwm duty
239
+				break;
240
+			#endif
241
+
242
+			#if defined(TCCR5A) && defined(COM5C1)
243
+			case TIMER5C:
244
+				// connect pwm to pin on timer 5, channel C
245
+				sbi(TCCR5A, COM5C1);
246
+				OCR5C = val; // set pwm duty
247
+				break;
248
+			#endif
249
+
250
+			case NOT_ON_TIMER:
251
+			default:
252
+				if (val < 128) {
253
+					digitalWrite(pin, LOW);
254
+				} else {
255
+					digitalWrite(pin, HIGH);
256
+				}
257
+		}
258
+	}
259
+}

+ 0
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring_digital.c Dosyayı Görüntüle


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor

Loading…
İptal
Kaydet