Suggested C Development Environment for Teensy 3.0 (Windows or Linux)

Status
Not open for further replies.

sixstring

Member
Hi all,
What C development environment should I use for the Teensy 3.0?

I don't want to use the ArduinoIDE and my OS can either be Windows or Linux.

Thanks!
 
There's a makefile in hardware/teensy/cores/teensy3 to use as a starting point. Documentation is available in the makefile's comments.
 
There's a makefile in hardware/teensy/cores/teensy3 to use as a starting point. Documentation is available in the makefile's comments.
Thanks for the info! Maybe I'm crazy but I'm going to go the C route, time to dig into that Freescale manual :)
 
Bool answerQuery("can I use this with Teensy* 2.0 to make Flight Sim Controls devices?");

if (justTryTheMakefile()) {
buildFlightSimProject();
} else {
postErrorMessage();
if (paulFixesIssue() || dozerFindsSolution()) {
buildFlightSimProject();
} else {
SOL();
}
}
 
if (justTryTheMakefile()) {
buildFlightSimProject();
} else {
postErrorMessage();
if (paulFixesIssue() || dozerFindsSolution()) {
buildFlightSimProject();
} else {
SOL();
}
}

/*
* Info* SOL(ProjectType type)
* Searches the online webs for info repositories. param: Project type enum returns: Pointer to project info struct
*/
Info* SOL(ProjectType type)
{
if(type == FLIGHTSIM_HID)
{
return GoogleForSomeoneElsesCodeToCopyPase();
}
return GetFreescaleMan();
}

lol anywho... I thought this would be a good topic or FAQ entry cuz it took me a few hours of reading the kickstarter comments and the pjrc site before I read that there are some c tools inside the teensyduino ide download... given, I'm not the best googler. While I am a an Arduino noob I'm not new to microcontrollers and usually use Atmel Studio or Eclipse, so I knew I had to get my hands on the toolchain somewhere! :) My shiny new Teensy 3.0 arrived today and I think it will make a great co-pilot for my Raspberry Pi!
 
if (justTryTheMakefile()) {
buildFlightSimProject();
} else {
postErrorMessage();
if (paulFixesIssue() || dozerFindsSolution()) {
buildFlightSimProject();
} else {
SOL();
}
}

Paul,

Very funny. I am still chuckling over this one...
 
Thanks for the info! Maybe I'm crazy but I'm going to go the C route, time to dig into that Freescale manual :)

The programming language that the Arduino uses is C++. Since its a superset of C, you can program it in pure C using it if you like.

The Arduino system provides a set of convenient libraries to make things easy for you, like serial input and output, driving servos, using the SPI and I2C busses, etc. Paul has provided equivalent libraries for the Teensy 3.0 so the code is compatible between AVR-based Arduinos and the Teensy 3.0.

The makefile that Paul mentioned will let you skip the IDE and just compile your C code directly.
 
If you look through the code in hardware/teensy/cores/teensy3, you'll see I've been developing the hardware support code mostly in C. Then I just put a C++ wrapper around it. For example, here's HardwareSerial.h.

The first half is all the C functions, which have all the actual code. The second half is the C++ objects familiar to Arduino users. But if you look in HardwareSerial1.h, it's just 1 line to create the object instance. All the real code is C only.... so if you want to work only in C, you can use most of this stuff I've done for Arduino users. Just discard the C++ wrappers and call the C functions.


Code:
#ifndef HardwareSerial_h
#define HardwareSerial_h

#include "mk20dx128.h"
#include <inttypes.h>

#define BAUD2DIV(baud)  (((F_CPU * 2) + ((baud) >> 1)) / (baud))
#define BAUD2DIV3(baud) (((F_BUS * 2) + ((baud) >> 1)) / (baud))

// C language implementation
//
#ifdef __cplusplus
extern "C" {
#endif
void serial_begin(uint32_t divisor);
void serial_end(void);
void serial_putchar(uint8_t c);
void serial_flush(void);
int serial_available(void);
int serial_getchar(void);
int serial_peek(void);
void serial_clear(void);
void serial_print(const char *p);
void serial_phex(uint32_t n);
void serial_phex16(uint32_t n);
void serial_phex32(uint32_t n);

void serial2_begin(uint32_t divisor);
void serial2_end(void);
void serial2_putchar(uint8_t c);
void serial2_flush(void);
int serial2_available(void);
int serial2_getchar(void);
int serial2_peek(void);
void serial2_clear(void);

void serial3_begin(uint32_t divisor);
void serial3_end(void);
void serial3_putchar(uint8_t c);
void serial3_flush(void);
int serial3_available(void);
int serial3_getchar(void);
int serial3_peek(void);
void serial3_clear(void);

#ifdef __cplusplus
}
#endif
// C++ interface
//
#ifdef __cplusplus
#include "Stream.h"
class HardwareSerial : public Stream
{
public:
        void begin(uint32_t baud)       { serial_begin(BAUD2DIV(baud)); }
        void end(void)                  { serial_end(); }
        virtual int available(void)     { return serial_available(); }
        virtual int peek(void)          { return serial_peek(); }
        virtual int read(void)          { return serial_getchar(); }
        virtual void flush(void)        { serial_flush(); }
        void clear(void)                { serial_clear(); }
        virtual size_t write(uint8_t c) { serial_putchar(c); return 1; }
        using Print::write;
};
extern HardwareSerial Serial1;

class HardwareSerial2 : public HardwareSerial
{
public:
        void begin(uint32_t baud)       { serial2_begin(BAUD2DIV(baud)); }
        void end(void)                  { serial2_end(); }
        virtual int available(void)     { return serial2_available(); }
        virtual int peek(void)          { return serial2_peek(); }
        virtual int read(void)          { return serial2_getchar(); }
        virtual void flush(void)        { serial2_flush(); }
        void clear(void)                { serial2_clear(); }
        virtual size_t write(uint8_t c) { serial2_putchar(c); return 1; }
        using Print::write;
};
extern HardwareSerial2 Serial2;

class HardwareSerial3 : public HardwareSerial
{
public:
        void begin(uint32_t baud)       { serial3_begin(BAUD2DIV3(baud)); }
        void end(void)                  { serial3_end(); }
        virtual int available(void)     { return serial3_available(); }
        virtual int peek(void)          { return serial3_peek(); }
        virtual int read(void)          { return serial3_getchar(); }
        virtual void flush(void)        { serial3_flush(); }
        void clear(void)                { serial3_clear(); }
        virtual size_t write(uint8_t c) { serial3_putchar(c); return 1; }
        using Print::write;
};
extern HardwareSerial3 Serial3;

#endif
#endif
 
Status
Not open for further replies.
Back
Top