Skip to content

Commit

Permalink
Support for non-MBED cores
Browse files Browse the repository at this point in the history
ADC and PWM working now on non-mbed cores
  • Loading branch information
TMRh20 committed Apr 2, 2024
1 parent da5fa41 commit 3f7b94d
Show file tree
Hide file tree
Showing 2 changed files with 238 additions and 51 deletions.
30 changes: 22 additions & 8 deletions src/AutoAnalogAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ class AutoAnalog
* 10 or 12-bit samples are read directly from this buffer after calling getADC() <br>
* @see adcBitsPerSample
*/
#if !defined(ARDUINO_ARCH_NRF52840) && !defined (ARDUINO_ARCH_NRF52) || defined ARDUINO_NRF52840_FEATHER
#if !defined (ARDUINO_ARCH_NRF52840) && !defined (ARDUINO_ARCH_NRF52) && !defined ARDUINO_NRF52840_FEATHER
uint16_t adcBuffer16[MAX_BUFFER_SIZE];
#elif defined __MBED__
inline static uint16_t adcBuffer16[MAX_BUFFER_SIZE];
#else
inline static int16_t adcBuffer16[MAX_BUFFER_SIZE];
static uint16_t adcBuffer16[MAX_BUFFER_SIZE];
#endif

/** Set sample rate. 0 enables the default rate specified in AutoAnalog_config.h
Expand Down Expand Up @@ -189,7 +191,7 @@ class AutoAnalog

/**@}*/

#if defined (ARDUINO_ARCH_NRF52840) || defined (ARDUINO_ARCH_NRF52) && !defined ARDUINO_NRF52840_FEATHER
#if defined (ARDUINO_ARCH_NRF52840) || defined (ARDUINO_ARCH_NRF52) && !defined ARDUINO_NRF52840_FEATHER && defined __MBED__
inline static uint8_t aCtr;
inline static uint32_t aSize;
inline static uint16_t *buf0 = NULL;
Expand All @@ -198,19 +200,31 @@ class AutoAnalog
inline static void adcCallback(uint16_t *buf, uint32_t buf_len);
inline static void set_callback(void(*function)(uint16_t *buf, uint32_t buf_len));
inline static bool adcReady;
inline static uint16_t dacBuf0[MAX_BUFFER_SIZE];
inline static uint16_t dacBuf1[MAX_BUFFER_SIZE];
inline static int16_t dacBuf0[MAX_BUFFER_SIZE];
inline static int16_t dacBuf1[MAX_BUFFER_SIZE];
bool micOn;
int pwrPin;
int dinPin;
int clkPin;
int8_t gain;
inline static uint32_t sampleCounter;
#endif

#if defined ARDUINO_NRF52840_FEATHER
#elif defined (ARDUINO_ARCH_NRF52840) || defined (ARDUINO_ARCH_NRF52) || defined (ARDUINO_NRF52840_FEATHER) && !defined __MBED__
uint16_t dacBuf0[MAX_BUFFER_SIZE];
uint16_t dacBuf1[MAX_BUFFER_SIZE];
static uint8_t aCtr;
static uint32_t aSize;
static uint16_t *buf0;
static uint16_t *buf1;
static void (*_onReceive)(uint16_t *buf, uint32_t buf_len);
static void adcCallback(uint16_t *buf, uint32_t buf_len);
void set_callback(void(*function)(uint16_t *buf, uint32_t buf_len));
static bool adcReady;
bool micOn;
int pwrPin;
int dinPin;
int clkPin;
int8_t gain;
uint32_t sampleCounter;
#endif

private:
Expand Down
Loading

0 comments on commit 3f7b94d

Please sign in to comment.