Hello. Yes, Atmel Studio supports C++ and there is nothing stopping you from using it on our programmable AVR products. Unfortunately, it is not easy to adapt our templates to C++ so you will have to start from scratch and configure Atmel Studio yourself:
- Create a new project in Atmel Studio and select the “GCC C++ Executable Project” template provided by Atmel. This can be found in the “C/C++” template category.
- In the Device Selection dialog, choose the model of AVR you are trying to program. For a recently-made 3pi, this would be the ATmega328P.
- Select Project > Properties… to open up the project properties window so you can properly configure your project to use the AVR libraries.
- Under “AVR/GNU Linker > Libraries”, click the little green icon to add the right library for your device. For ATmega328P-based devices like the 3pi, you would type “pololu_atmega328p”.
- Under “AVR/GNU C++ Compiler > Optimization”, check “Prepare functions for garbage collection (-ffunction-sections)”.
- Under “AVR/GNU Linker > Optimization”, check “Garbage collect unused sections (-Wl,–gc-sections).”
For more information about what these settings are and why you need them, see the “Using the Pololu AVR Library for your own projects” section of the Pololu AVR C/C++ Library User’s Guide.
Here is some fun code to get you started:
#include <pololu/orangutan.h>
class Output
{
public:
uint8_t pin;
Output(uint8_t pin) : pin(pin) { }
void operator<<(uint8_t value){ set_digital_output(pin, value); }
};
Output led(IO_D1);
int main(void)
{
while(1)
{
led << 1;
delay_ms(300);
led << 0;
delay_ms(300);
}
}
–David
