Managing Custom Library & Board Control

I am working with the Teensy core libraries and I need to make some modifications for my custom bare-metal board (MK20DX256VLH7).

I have some questions and I don’t understand how to do this:

  1. I have several library files that need modification, but what I would prefer to do is modify copies of these files (i.e., usb_desc.c, usb_desc.h, usb_joystick.c, usb_joystick.h) and force the compiler/linker to use these copies instead. How would I do that?

  2. More importantly I don’t understand how to control the compilation of the program’s attributes such as found in the Arduino Tools menu (Specifically: Board, USB Type, CPU Speed). There must be some file(s) somewhere that sets those definitions or #define statements. Where is that done?

Specifically, what I am trying to accomplish is this: I am trying to modify the Teensy 3.2 Joystick program. I have successfully changed the USB Descriptor report structure to do what I need, but the Teensy also attaches something called Flightsim to the USB packets which include definitions for SEREMU_INTERFACE and FLIGHTSIM_INTERFACE. Again, these appear in the Arduino Tolls menu and there is no option for Joystick by itself.

The SEREMU_INTERFACE is not needed because I debug using J-Link and my board does not use the Teensy boot loader. I’d like to scrap this.

The FLIGHTSIM_INTERFACE is used for X-Plane and not needed. It’s extra baggage I need to get rid of.

If I understood questions 1 and 2 better I might be able to do this on my own, but I am stuck. Any help would be greatly appreciated.

Hi loren,

is possible by several means:

  • renaming them (maybe putting them into your own folder under /lib (?) and then simply #include their new file names
  • If you are using the library manager instead, you’d have to point it to your newly created library using lib_deps (and remove the old ones).

is possible using the PlatformIO tab → Project Tasks
Where you can modify fuses to change clock source, speed etc. But note that many libraries have hard-coded clock speeds via #define F_CPU so that if you change the clock without any other modifications, likely you’ll get in trouble with terminal output or any other clock-dependant stuff (e.g. delays might change). See here for more details.
To modify board type and framework, use the PlatformIO.ini file.

Hope this helps!

1 Like