Porting to different microcontrollers

To port the Adafruit MP3 library to a different microcontroller, we first need to make sure the helix player can support it. Open the file mp3dec.h and if necessary add an #elif to the switch at the top of the file for your platform.

Next open the file assembly.h and if necessary add an #elif with some assembly code for the required functions:

static __inline int MULSHIFT32(int x, int y);
static __inline int FASTABS(int x);
static __inline int CLZ(int x);
static __inline Word64 MADD64(Word64 sum64, int x, int y);
static __inline Word64 SAR64(Word64 x, int n);

where Word64 is:

typedef signed long long int    Word64;  // 64-bit signed integer.

Adafruit_MP3 class modifications

The Adafruit_MP3 library uses a timer to control playback. This timer should be able to fire at least 44,100 times per second.

Because different microcontroller platforms implement timers differently, you will need to add an #elif to the timer functions in Adafruit_MP3.cpp with instructions on how to configure, enable, and disable timers on your microcontroller platform.

These functions are:

//enable the playback timer
static inline void enableTimer();

//disable the playback timer
static inline void disableTimer();

//configure the playback timer. Make sure to enable the interrupt.
static inline void configureTimer();

//if necessary, clear the interrupt flag.
static inline void acknowledgeInterrupt();

You may also need to redefine the name of the interrupt handler that the timer triggers. This is done in Adafruit_MP3.h. For example, on the SAMD51 (the chip that the Metro / Feather M4 uses), this is done with:

#define MP3_Handler TC2_Handler
Last updated on 2017-11-09 at 04.31.41 PM Published on 2017-11-09 at 04.34.51 PM