I tried working in arduino IDE and it's such a pain. Eclipse idea is good, but it's still stuck with the bootloader. So I was always interested - why not just flash the good-old way, via USB ASP? Everyone can use at least AVR studio, which is way better, than arduino IDE.
As for files, it is common to divide into plenty of small files. For example, I would create separate file pid.c and pid.h. Create the data structure, used by pid (input, output, integrators, settings etc). So now, one code is being used for all pids. for example like:
- Code: Select all
pAcroRoll_PID_def->input = someVar;
anotherVar = pAcroRoll_PID_def->output;
pAcroPitch_PID_def->input = someVar2;
anotherVar2 = pAcroPitch_PID_def->output;
Amagine, how much space that would save - one chunk of code for all the pids in the quad. This code is very easy to read (all the subcode is in pid.c, not main loop, for example), and also this implementation is very fast, because X Y Z registers are used for indirect addressing, and all data for PID is placed side-by-side in one RAM area. I have no idea, how to implemend that visually enough in current file structure.
Also, a bit offtopic - direct compile for the target hardware has plenty of options. I worked a lot with Cortex M3 and M4 processors and Eclipse IDE - direct compile / upload is awesome. For example, atmel Cortex M3 has USB driver - it can upload firmware by the software, provided by atmel (no programmer needed, just USB). Not only that, I have almost ready to use USB-ready bootloader for Atmel, Ti stellaris and STM32 cortex M4 processors. When the bootloader is there (this might be a problem for some platforms), you connect the board to PC, it detects as flash drive, copy the firmware.bin file, push the button - it is flashed (I used it for other tasks,it'll work this way as well). There should be enough RAM to accept the firmware though.