Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Development / Re: Arduino0015+Eclipse problems on: June 17, 2009, 01:31:58 pm
Quote
[...continues from previous post]
The following MS Word Macro will (mostly) extract function definitions from code
Paste the declarations in the space above where suggested
__
Sub ExtractFunctionDefinitions()
'
'  Extract function definitions from C code
'   Open all the relevant documents in word
'   Once finished, copy the declarations to the appropriate location in your code
'
    For Each currDoc In Documents
        currDoc.Select
        ActiveDocument.PageSetup.PageWidth = CentimetersToPoints(55)
        Selection.HomeKey Unit:=wdStory
        Selection.TypeText "/*** " & ActiveDocument.Name & " Declarations ***/"
        Selection.TypeParagraph
        While ActiveDocument.Range.End > Selection.End + 5
            Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
            If InStr(Selection.Text, "::") > 0 Then
                classDec = 1
            Else
                classDec = 0
            End If
            ' Search the first 10 characters of each line for type markers
            curStr = Left(Trim(Selection.Text), 6)
            If InStr(curStr, "void") Or _
              InStr(curStr, "int") Or _
              InStr(curStr, "double") Or _
              InStr(curStr, "bool") Or _
              InStr(curStr, "long") Or _
              InStr(curStr, "int8_t") Or _
              InStr(curStr, "inline") Or _
              InStr(curStr, "static") Then
                ' If it's not a comment
                If Left(curStr, 2) <> "//" Then
                    ' If the rightmost character (excluding return char) is not ';' then
                    curStr = Trim(Replace(Replace(Selection.Text, Chr(13), ""), Chr(10), ""))
                    If InStr(curStr, "(") > 0 And Right(curStr, 1) <> ";" Then
                        curStr = Replace(curStr, "()", "(void)")    ' function declarations should have arguments as void if there are none
                        curStr = curStr & ";" & vbCrLf
                        If classDec = 1 Then
                            ' Don't need to declare class functions
                            curStr = "//" & curStr
                        End If
                        Selection.TypeText curStr
    '                    Selection.MoveRight Unit:=wdCharacter, Count:=1
                    Else
                        Selection.Delete Unit:=wdCharacter, Count:=1
                    End If
                Else
                    Selection.Delete Unit:=wdCharacter, Count:=1
                End If
            Else
                Selection.Delete Unit:=wdCharacter, Count:=1
            End If
        Wend
    Next

    newDoc = Documents.Add(Template:="Normal", NewTemplate:=False, DocumentType:=0)
    For Each currDoc In Documents
        Debug.Print currDoc.Name
        If currDoc.Name = newDoc Then
            currDoc.PageSetup.PageWidth = CentimetersToPoints(55)
        Else
            currDoc.Select
            Selection.WholeStory
            Selection.Cut
            Windows(newDoc).Activate
            Selection.HomeKey Unit:=wdStory
            If InStr(currDoc.Name, ".pde") = 0 Then Selection.TypeText "//"
            Selection.TypeText "#include """ & currDoc.Name & """"
            Selection.TypeParagraph
            Selection.EndKey Unit:=wdStory
            Selection.PasteAndFormat (wdPasteDefault)
            currDoc.Close False
        End If
    Next
End Sub
--------------------------------------------------


/***   LUFA Under Eclipse   ***/
The following are the adjustments to the properties to enable LUFA to build
  with an automatic makefile under Eclipse
  
*** Create a new project on the workbench ***
RCPEW = right click in Project Explorer Window/New/Project
Select: C++ project
Select: AVR Cross Target Application
Give it a name: Template
Set your hardware (eg AT90USB1287 at 8000000Hz)
Click Finish

Copy the LUFA library directory into the project root directory.
  Delete all .c files which are not used (see in the makefile for which these are)
  Optional: Delete Doxygen.conf
            [ProjectName].txt (used by Doxygen)
                  [ProjectName].aps (used by AVR Studio)
                  makefile

Now modify the project properties (RCPEW/Properties)
Set Configuration to [All Configurations]

/***  AVR / Target Hardware  ***/
AT90USB1287
8000000

/***  C/C++ Build / Build Variables  ***/
#MCU = at90usb1287
#BOARD  = USBKEY
#F_CPU = 8000000
#F_CLOCK = 8000000
#FORMAT = ihex
#OBJSRC

/***  C/C++ Build / Settings / AVR Assembler / General / Other GCC Flags  ***/
#-Wa,-adhlns=$(<smiley-draw.S=./%.lst),-gstabs,--listing-cont-lines=100

/***  C/C++ Build / Settings / AVR Assembler / Debugging / Debug Info Format ***/
#dwarf-2

/***  C/C++ Build / Settings / AVR Compiler / Optomization / Optimization Level ***/
Os

/***  C/C++ Build / Settings / AVR Compiler / Language Standard ***/
-std=gnu99      // This is required for LUFA

/***  C/C++ Build / Settings / AVR C Compiler / Miscellaneous / Other Flags ***/
-DF_CLOCK=8000000UL -DBOARD=BOARD_USBKEY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -ffunction-sections -finline-limit=20 -Wall -Wstrict-prototypes -Wundef $(OBJSRC:%.c=$(OBJDIR)/%.o)

/***  C/C++ Build / Settings / AVR C++ Compiler / Miscellaneous / Other Flags ***/
-DF_CLOCK=8000000UL -DBOARD=BOARD_USBKEY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -ffunction-sections -finline-limit=20 -Wall -Wundef $(OBJSRC:%.c=$(OBJDIR)/%.o)

/***  C/C++ Build / Settings / AVR C Linker / General / Other Arguments ***/
-Wl,--relax -Wl,--gc-sections -lm

/***  C/C++ General / Paths and Symbols  ***/
Add an include for the project root directory (so the LUFA includes will be recognised

2  Forum 2005-2010 (read only) / Development / Re: Arduino0015+Eclipse problems on: June 17, 2009, 01:30:57 pm
Here is my personal instruction set for building Arduino 0015 under Eclipse if anyone wants to tidy them up or compact them.

Please note I modify the core to build code for the AT90USB1287 (as per other posts), but the unmodified core still builds with the same instructions.
However I can only get 0015 to build under Eclipse, if I comment out the definition of SIGNAL(SIG_USART_RX_vect) in HardwareSerial.cpp, as it's also defined in wiring.c, and if I don't remove it, I get a linker error "multiple definition of '__vector_25_' which I can't seem to solve otherwise. Haven't experimented to see whether it's important...

The following also includes instructions for building LUFA (the USB library) under Eclipse, as some might like the extra USB functionality of this library. My modifications for the AT90USB1287 to the core (0012 and 0015) is at http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse

Quote
*** Install WinAVR, Eclipse, AVR Eclipse Plugin, and the appropriate Arduino Core ***
(you don't need Arduino to be installed, but you do need the CORE files)
I found that I had to run Eclipse then exit it *before* installing the plugin to avoid
an annoying 'workspace not found' crash

*** Load Eclipse ***
From the welcome screen click the arrow on the righthand side to go to the workbench

****************************************
***** CREATE YOUR PROJECT TEMPLATE *****
****************************************
*** Create a new project on the workbench ***
RCPEW = right click in Project Explorer Window/New/Project
Select: C++ project
Select: AVR Cross Target Application
Give it a name: Template
Set your hardware (eg AT90USB1287 at 8000000Hz)
Click Finish

***  for LUFA create the project as a makefile project as follows ***
*        Skip this step if you wish to use an Eclipse automatic makefile  *
*        (see 'LUFA under Eclipse instructions at the end of this file)   *
*        Skip this step if you're not importing a LUFA demo               *
RCPEW = right click in Project Explorer Window/New/Project
Select: C++ project
Select: Makefile Project/Empty Project
Untick: Use default location
Browse to the appropriate LUFA demo directory
Name it the same as the folder name (and ignore the warning that directory already exists)
Click Finish
[Optional: delete the (eg) CDC.aps, CDC.txt, Doxygen.conf if you wish - they aren't used by Eclipse]

*** Modify the Eclipse workspace properties ***
Menu Bar: Window/Preferences - General - Workspace
Untick Build Automatically
Tick Save Automatically
Tick Refresh Automatically
Click OK

*** Modify the Eclipse project properties ***
RCPEW/Properties
C/C++ Build - Settings - Select [All Configurations]
                  - Settings - AVR Compiler - Optimisation - from -O0 to -Os
            - Settings - AVR C++ Compiler - Optimisations - from -O0 to -Os
            - Settings - AVR C++ Linker : Change:-
                        //Replace Command: avr-gcc // from avr-g++
                        Append to Command Line Pattern: "-lm -Os"      // link in avr-libc math library; Optomise for small code
                               one site recommended using switch -s  but this doesn't seem to be necessary
C/C++ Build - Paths and Symbols - Includes Tab - Add
      - Type name of appropriate Arduino CORE folder (eg D:\My Documents\Eclipse Workspace\Arduino Core for AT90USB1287)
       or Browse to it by clicking "File System"
      - Copy the text to the clipboard to ease the next *** step
      - Tick "Add To All Config..."
      - Tick "Add To All Lang..."
      - Click OK to confirm Include Directory
Click OK to confirm Properties Changes

*** Add the CORE folder as a Source Directories ***
RCPEW/New/Folder
Click Advanced
Tick "Link To..."
Browse to appropriate Arduino CORE folder (eg D:\My Documents\Eclipse Workspace\Arduino Core for AT90USB1287)
Click OK
Click Finish

*** This template project can now be reused if you wish ***
RCPEW/Copy
RCPEW/Paste
Give it your new name
Copy Source files to it as below

*** If you wish to 'hide' the template ***
RCPEW/Delete
DON'T tick the delete from disk tickbox
Click OK

*** To Restore your template (or import it to another workspace) ***
RCPEW/Import
Select Existing Projects
Click Next
Type/Paste/Browse to the root directory of your template workspace
Tick your template under projects
Click Finish

************************************
***** NOW ADD THE SOURCE FILES *****
************************************
*** Create a blank project source code (or see alternative next step) ***
RCPEW/New/Source File
Give it a name (eg F00.cpp)
Click OK

*** Copy Source Files to Project Directory ***
If you already have source files, copy them to the new project directory (with your normal file copier)
  this will be a subdirectory in the in the workspace directory.
RCPEW/Refresh  (or press F5 with the focus on the Project Explorer)

*** If you're building arduino code ***
Change the content type and default editor for .pde files:-
Menu/Window/Preferences/General/Content Type/Text/C Source File/C++ Source File
Click Add: *.pde
Click OK
Menu/Window/Preferences/General/Editors/File Associations
Click Add File Types: *.pde
Click OK
Click Add Associated Editors: C/C++ Editor
Click OK
*
If it's already been built using the arduino IDE build, there will be a
  file in the folder called /applet/F00.cpp. You can copy this as above.
  This will give you a file which has been modified as below by arduino.
  Copy this .pde file  and .h (could be .h.dist) files directly to the appropriate workspace folder.
  If you have a multiple file arduino project, you might wish to keep
  them as .pde in which case, do the following:
OR
  copy the .pde and .h (could be .h.dist) files directly to the appropriate workspace folder.
  OR
  Append the code from the individual .pde files to the above (F00.cpp file)
  THEN:-
Rename the primary .pde to .cpp if not done already:-
    (eg) GCode_Interpreter.cpp
    Don't rename all .pde to .cpp, or your global definitions (see later) won't work,
        and you'll get lots(!!!) of errors. Sadly this means the indexer won't work properly.
Rename all .h.dist to .h

Near the beginning of the primary file (eg after the description comment), paste the following code
-----------------
#define ECLIPSE_BUILD            // includes the code required for Eclipse build (but not for Arduino build)
#ifdef ECLIPSE_BUILD

// This code is required if the project is being built under Eclipse
#include "WProgram.h"

//#include any additional .pde files which are part of the source here eg
//#include "F002.pde"

// Declare functions (including those used in additional .pde source files)
//eg double funcDec(char arg1, char arg2[], int arg3);
void init();
void setup();
void loop();

#endif
------------------
if not added above, at the end of the primary .cpp add includes (eg):-
      #include "cartesian_dda.pde"
      #include "extruder.pde"
      #include "process_g_code.pde"

Now declare all other functions used in the code (I suggest you put them below those for setup and loop)
(this will hopefully just mean copying the function from later in the code, and adding a ';' semicolon
Alternatively use the Microsoft Word macro at the end of this file to extract
  the functions (relatively) automatically then paste them in to the primary .cpp file

If there are additional .pde files in the Arduino sketch, create
#include references for them all (in alphabetical order) to the f00.cpp file where it says //#include F002.pde
Alternatively, these could also be put last in the primary cpp file
#include "cartesian_dda.pde"
#include "extruder.pde"
#include "process_g_code.pde"

At the end (or as part of the above code block if you wish),
append the following 'main' routine (it's at the end here because Arduino put's it at the end)
----------------
#ifdef ECLIPSE_BUILD
int main(void)
{
      init();

      setup();

      for (;smiley-wink
            loop();

      return 0;
}
#endif
----------------

/*** Brief Steps to Modify Reprap Code ***/
A short reminder if you are familiar with the process...
Copy the source files to the appropriate directory (eg GCode_Interpreter)
Rename the primary .pde to .cpp (eg):-
    GCode_Interpreter.cpp
Don't rename all .pde to .cpp, or your global definitions won't work, and you'll get lots(!!!) of errors
  sadly this means the Eclipse indexer won't work properly.
Rename all .h.dist to .h
at the end of the primary .cpp add includes (eg):-
      #include "cartesian_dda.pde"
      #include "extruder.pde"
      #include "process_g_code.pde"

Declare all functions used in the code (I suggest you put them below those for setup and loop)

----------------
The following MS Word Macro will (mostly) extract function definitions from code
Paste the declarations in the space above where suggested
__
...[clipped]
3  Forum 2005-2010 (read only) / Development / Re: Arduino for AT90USB1287 / AT90USBKey with Eclipse on: June 17, 2009, 02:17:38 pm
See http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ for modifications to the 0015 code to build under Eclipse. Also contained there (and in another post on YaBBForum) instructions for building LUFA under Eclipse to enable merging with Arduino code...
Cheers
David
4  Forum 2005-2010 (read only) / Development / Re: Arduino for AT90USB1287 / AT90USBKey with Eclipse on: March 11, 2009, 05:12:43 pm
Cheers aboston
I use Eclipse (Ganymede) with the AVR plugin, but I did test originally with Arduino 0012. Never bothered testing with 0013. I prefer the more sophisticated Eclipse IDE.
I just build the code to a hex file, and load it via USB using FLIP.

The pins file has the same name because noone seemed that interested in integrating it with the main distribution, so I didn't bother making it complementary. Feel free to rename and adjust it if you wish. I also modified most of the Arduino example files to build for the USBKey under Eclipse too.
0013 came out soon after I developed the USBKey fork, but I haven't tried to build using that source.
David
5  Forum 2005-2010 (read only) / Development / Re: Arduino for AT90USB1287 / AT90USBKey with Eclipse on: February 07, 2009, 07:17:41 am
I've uploaded the source to the google codes repository:-
http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse

This was a mod of Arduino 0012 code - I haven't looked at the 0013 core to see if there are any differences.

The upload includes the file 'modifications.txt' which notes what's been changed from the original 0012 core, and 'Novice Instructions for Eclipse.txt' which is how I set up my Eclipse build.

I've also included some 'reprap' source files, since they show how the build can be done under Eclipse. These are obviously unnecessary for other projects

David
6  Forum 2005-2010 (read only) / Development / Re: Arduino for AT90USB1287 / AT90USBKey with Eclipse on: January 30, 2009, 06:31:27 am
I haven't written a bootloader since the ATMEL bootloader works fine for USB upload of firmware, so I don't have a source for that - they provide it as a hex, but the rest is just some slight modifications to the Arduino code, and using the LUFA open source library for USB comms (www.fourwalledcubicle.com/LUFA.php) (not integrated with Arduino code yet, but functions separately).
I don't really think it should be called a 'duino' yet (if ever) since I haven't created a new board (I use ATMELs demo board), and as you note, the bootloader is not open source), but thought it might be of use to someone who wants to do things a little differently, but still make use of the excellent Arduino code library.
Cheers
David
7  Forum 2005-2010 (read only) / Development / Arduino for AT90USB1287 / AT90USBKey with Eclipse on: January 30, 2009, 05:45:45 am
I have modified the Arduino Core code to function with the AT90USB1287. I can build it successfully with the Arduino frontend, or Eclipse (Ganymede) C/C++ IDE).
I haven't got the hardware to test it thoroughtly as I have the AT90USBKey board, but haven't got lots of peripherals or a JTAG/ICE interface.
I'm still working on the USB comms (using LUFA open source code).
Just wondering how I can share it for testing, or even (eventually) get it integrated with the distribution version of the Arduino core?
Thanks
David
8  Forum 2005-2010 (read only) / Development / Re: AVR with embedded USB? on: January 30, 2009, 05:52:16 am
Don't know if anyone's interested, but see my post "Arduino for AT90USB1287 / AT90USBKey demo board with Eclipse"
9  Forum 2005-2010 (read only) / Development / AT90USBKey with Arduino environment on: September 20, 2008, 04:05:57 pm
I'd like to use the AT90USB1287 as a much more powerful chip than the various Arduino variants, and one which has native USB, so I don't have to spend money on an otherwise useless TTL cable.
The AT90USBKey demo board has lots of features and much cheaper than building my own, so this seems the best way to go (only $30).

What do I have to do to enable native USB download for this board under the Arduino environ? (I want it to run a Repstrap 3d printer, and don't want to have to rewrite it under AVR Studio).
Thanks
David
Pages: [1]