Skip to content

Commit

Permalink
Add recording for NRF52840
Browse files Browse the repository at this point in the history
Preliminary support for NRF52840 - only handles recording/ADC sampling
  • Loading branch information
TMRh20 committed May 13, 2023
1 parent cbc4d6d commit fcb2323
Show file tree
Hide file tree
Showing 3 changed files with 387 additions and 4 deletions.
27 changes: 25 additions & 2 deletions src/AutoAnalogAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,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)
uint16_t adcBuffer16[MAX_BUFFER_SIZE];

#else
inline static int16_t adcBuffer16[MAX_BUFFER_SIZE];
#endif

/** Set sample rate. 0 enables the default rate specified in AutoAnalog_config.h
* @param sampRate This sets the defined sample rate ie: 32000 is 32Khz
* @param stereo Only used for the ESP32, this sets stereo or mono output and affects the sample rate
Expand Down Expand Up @@ -184,6 +188,25 @@ class AutoAnalog

/**@}*/

#if defined (ARDUINO_ARCH_NRF52840)
inline static uint8_t aCtr;
inline static uint32_t aSize;
inline static uint16_t *buf0 = NULL;
inline static uint16_t *buf1 = NULL;
inline static void (*_onReceive)(uint16_t *buf, uint32_t buf_len) = NULL;
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];
bool micOn;
int pwrPin;
int dinPin;
int clkPin;
int8_t gain;
inline static uint32_t sampleCounter;
#endif

private:

/**
Expand All @@ -194,7 +217,7 @@ class AutoAnalog
* may want to extend this class.
*/
/**@{*/
#if defined (ARDUINO_ARCH_SAM)
#if defined (ARDUINO_ARCH_SAM)
bool whichDma = 0;
bool whichDac;
bool dacChan;
Expand Down
4 changes: 2 additions & 2 deletions src/AutoAnalog_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

#define MAX_BUFFER_SIZE 256

#elif defined ESP32
#elif defined ESP32 || defined ARDUINO_ARCH_NRF52840

#define MAX_BUFFER_SIZE 512
#define MAX_BUFFER_SIZE 1600

#else

Expand Down
Loading

0 comments on commit fcb2323

Please sign in to comment.