Skip to content

Commit

Permalink
Merge branch 'master' into ota-fix-runtimeinit
Browse files Browse the repository at this point in the history
  • Loading branch information
earlephilhower authored Dec 19, 2024
2 parents cfd1ce4 + d5a6888 commit 2878a26
Show file tree
Hide file tree
Showing 23 changed files with 492 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ sphinx:
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
formats:
- pdf
# - epub

# Optional but recommended, declare the Python requirements required
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
* Pimoroni Pico Plus 2
* Pimoroni Pico Plus 2W
* Pimoroni Plasma2040
* Pimoroni Plasma2350
* Pimoroni Tiny2040
* Pimoroni Tiny2350
* Pintronix PinMax
Expand Down
247 changes: 247 additions & 0 deletions boards.txt

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions cores/rp2040/AudioOutputBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Abstract class for audio output devices to allow easy swapping between output devices

#pragma once

#include <Print.h>

class AudioOutputBase : public Print {
public:
virtual ~AudioOutputBase() { }
virtual bool setBuffers(size_t buffers, size_t bufferWords, int32_t silenceSample = 0) = 0;
virtual bool setBitsPerSample(int bps) = 0;
virtual bool setFrequency(int freq) = 0;
virtual bool setStereo(bool stereo = true) = 0;
virtual bool begin() = 0;
virtual bool end() = 0;
virtual bool getUnderflow() = 0;
virtual void onTransmit(void(*)(void *), void *) = 0;
// From Print
virtual size_t write(const uint8_t *buffer, size_t size) = 0;
virtual int availableForWrite() = 0;
};
6 changes: 3 additions & 3 deletions cores/rp2040/RP2040Version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#define ARDUINO_PICO_MAJOR 4
#define ARDUINO_PICO_MINOR 3
#define ARDUINO_PICO_REVISION 1
#define ARDUINO_PICO_VERSION_STR "4.3.1"
#define ARDUINO_PICO_MINOR 4
#define ARDUINO_PICO_REVISION 0
#define ARDUINO_PICO_VERSION_STR "4.4.0"
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = u'4.3.1'
version = u'4.4.0'
# The full version, including alpha/beta/rc tags.
release = u'4.3.1'
release = u'4.4.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 4 additions & 0 deletions docs/fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,19 @@ it using the ``mklittlefs`` tool. A working ``OpenOCD`` setup, DebugProbe, and
To download the raw filesystem, from within ``GDB`` run:

.. code::
^C (break)
(gdb) dump binary memory littlefs.bin &_FS_start &_FS_end
It may take a few seconds as ``GDB`` reads out the flash to the file. Once the raw file is downloaded it can be extracted using the ``mklittlefs`` tool from the BASH/Powershell/command line

.. code::
$ <path-to-mklittlefs>/mklittlefs -u output-dir littlefs.bin
Directory <output-dir> does not exists. Try to create it.
gmon.out > <output-dir>/gmon.out size: 24518 Bytes
gmon.bak > <output-dir>/gmon.bak size: 1 Bytes
The defaults built into ``mklittlefs`` should be appropriate for normal LittleFS filesystems built on the device or using the upload tool.

SD Library Information
Expand Down
1 change: 0 additions & 1 deletion libraries/AudioBufferManager/src/AudioBufferManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class AudioBufferManager {
delete ab;
}

int _bitsPerSample;
size_t _wordsPerBuffer;
size_t _bufferCount;
enum dma_channel_transfer_size _dmaSize;
Expand Down
3 changes: 3 additions & 0 deletions libraries/BluetoothAudio/src/A2DPSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ void A2DPSource::clearPairing() {
size_t A2DPSource::write(const uint8_t *buffer, size_t size) {
BluetoothLock b;

size = std::min((size_t)availableForWrite(), size);

size_t count = 0;
size /= 2;

Expand Down Expand Up @@ -260,6 +262,7 @@ int A2DPSource::availableForWrite() {
} else {
avail = _pcmBufferSize - _pcmWriter + _pcmReader - 1;
}
avail /= sizeof(uint32_t); // availableForWrite always 32b sample pairs in this core...
return avail;
}

Expand Down
27 changes: 22 additions & 5 deletions libraries/BluetoothAudio/src/A2DPSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@
#include <BluetoothHCI.h>
#include <BluetoothLock.h>
#include "BluetoothMediaConfigurationSBC.h"
#include <AudioOutputBase.h>
#include <functional>
#include <list>
#include <memory>


class A2DPSource : public Stream {
class A2DPSource : public Stream, public AudioOutputBase {
public:
A2DPSource() {
}

bool setFrequency(uint32_t rate) {
virtual ~A2DPSource() { }

virtual bool setFrequency(int rate) override {
if (_running || ((rate != 44100) && (rate != 48000))) {
return false;
}
Expand All @@ -51,7 +54,14 @@ class A2DPSource : public Stream {
return true;
}

void onTransmit(void (*cb)(void *), void *cbData = nullptr) {
virtual bool setBitsPerSample(int bps) override {
return bps == 16;
}
virtual bool setStereo(bool stereo = true) override {
return stereo;
}

virtual void onTransmit(void (*cb)(void *), void *cbData = nullptr) override {
_transmitCB = cb;
_transmitData = cbData;
}
Expand Down Expand Up @@ -84,7 +94,11 @@ class A2DPSource : public Stream {
return true;
}

bool getUnderflow() {
virtual bool setBuffers(size_t buffers, size_t bufferWords, int32_t silenceSample = 0) override {
return setBufferSize(buffers * bufferWords * sizeof(int32_t));
}

virtual bool getUnderflow() override {
BluetoothLock b;
if (!_running) {
return false;
Expand All @@ -102,7 +116,10 @@ class A2DPSource : public Stream {
}
}

bool begin();
virtual bool begin() override;
virtual bool end() override {
return false; // We can't actually stop bluetooth on this device
}

std::vector<BTDeviceInfo> scan(uint32_t mask = BluetoothHCI::speaker_cod, int scanTimeSec = 5, bool async = false) {
return _hci.scan(mask, scanTimeSec, async);
Expand Down
8 changes: 3 additions & 5 deletions libraries/I2S/examples/SimpleTone/SimpleTone.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

#include <I2S.h>

// Create the I2S port using a PIO state machine
I2S i2s(OUTPUT);

// GPIO pin numbers
#define pBCLK 20
#define pWS (pBCLK+1)
#define pDOUT 22

// Create the I2S port using a PIO state machine
I2S i2s(OUTPUT, pBCLK, pDOUT);

const int frequency = 440; // frequency of square wave in Hz
const int amplitude = 500; // amplitude of square wave
const int sampleRate = 16000; // minimum for UDA1334A
Expand All @@ -43,8 +43,6 @@ void setup() {
Serial.begin(115200);
Serial.println("I2S simple tone");

i2s.setBCLK(pBCLK);
i2s.setDATA(pDOUT);
i2s.setBitsPerSample(16);

// start I2S at the sample rate with 16-bits per sample
Expand Down
11 changes: 6 additions & 5 deletions libraries/I2S/src/I2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include <pico/stdlib.h>


I2S::I2S(PinMode direction) {
I2S::I2S(PinMode direction, pin_size_t bclk, pin_size_t data, pin_size_t mclk) {
_running = false;
_bps = 16;
_writtenHalf = false;
_isOutput = direction == OUTPUT;
_pinBCLK = 26;
_pinDOUT = 28;
_pinMCLK = 25;
_pinBCLK = bclk;
_pinDOUT = data;
_pinMCLK = mclk;
_MCLKenabled = false;
#ifdef PIN_I2S_BCLK
_pinBCLK = PIN_I2S_BCLK;
Expand Down Expand Up @@ -287,7 +287,7 @@ bool I2S::begin() {
return true;
}

void I2S::end() {
bool I2S::end() {
if (_running) {
if (_MCLKenabled) {
pio_sm_set_enabled(_pioMCLK, _smMCLK, false);
Expand All @@ -301,6 +301,7 @@ void I2S::end() {
delete _i2s;
_i2s = nullptr;
}
return true;
}

int I2S::available() {
Expand Down
23 changes: 15 additions & 8 deletions libraries/I2S/src/I2S.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@

#pragma once
#include <Arduino.h>
#include "AudioBufferManager.h"
#include <AudioBufferManager.h>
#include <AudioOutputBase.h>

class I2S : public Stream {
class I2S : public Stream, public AudioOutputBase {
public:
I2S(PinMode direction = OUTPUT);
I2S(PinMode direction = OUTPUT, pin_size_t bclk = 26, pin_size_t data = 28, pin_size_t mclk = 25);
virtual ~I2S();

bool setBCLK(pin_size_t pin);
bool setDATA(pin_size_t pin);
bool setMCLK(pin_size_t pin);
bool setBitsPerSample(int bps);
bool setBuffers(size_t buffers, size_t bufferWords, int32_t silenceSample = 0);
bool setFrequency(int newFreq);
virtual bool setBitsPerSample(int bps) override;
virtual bool setBuffers(size_t buffers, size_t bufferWords, int32_t silenceSample = 0) override;
virtual bool setFrequency(int newFreq) override;
virtual bool setStereo(bool stereo = true) override {
return stereo;
}
bool setLSBJFormat();
bool setTDMFormat();
bool setTDMChannels(int channels);
Expand All @@ -46,8 +50,11 @@ class I2S : public Stream {
return begin();
}

bool begin();
void end();
virtual bool begin() override;
virtual bool end() override;
virtual bool getUnderflow() override {
return getOverUnderflow();
}

// from Stream
virtual int available() override;
Expand Down
6 changes: 4 additions & 2 deletions libraries/PWMAudio/src/PWMAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ PWMAudio::~PWMAudio() {
end();
}

bool PWMAudio::setBuffers(size_t buffers, size_t bufferWords) {
bool PWMAudio::setBuffers(size_t buffers, size_t bufferWords, int32_t silence) {
(void) silence;
if (_running || (buffers < 3) || (bufferWords < 8)) {
return false;
}
Expand Down Expand Up @@ -176,7 +177,7 @@ bool PWMAudio::begin() {
return true;
}

void PWMAudio::end() {
bool PWMAudio::end() {
if (_running) {
_running = false;
pinMode(_pin, OUTPUT);
Expand All @@ -189,6 +190,7 @@ void PWMAudio::end() {
dma_timer_unclaim(_pacer);
_pacer = -1;
}
return true;
}

int PWMAudio::available() {
Expand Down
18 changes: 11 additions & 7 deletions libraries/PWMAudio/src/PWMAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@

#pragma once
#include <Arduino.h>
#include "AudioBufferManager.h"
#include <AudioOutputBase.h>
#include <AudioBufferManager.h>

class PWMAudio : public Stream {
class PWMAudio : public Stream, public AudioOutputBase {
public:
PWMAudio(pin_size_t pin = 0, bool stereo = false);
virtual ~PWMAudio();

bool setBuffers(size_t buffers, size_t bufferWords);
virtual bool setBuffers(size_t buffers, size_t bufferWords, int32_t silenceSample = 0) override;
/*Sets the frequency of the PWM in hz*/
bool setPWMFrequency(int newFreq);
/*Sets the sample rate frequency in hz*/
bool setFrequency(int frequency);
virtual bool setFrequency(int frequency) override;
bool setPin(pin_size_t pin);
bool setStereo(bool stereo = true);
virtual bool setStereo(bool stereo = true) override;
virtual bool setBitsPerSample(int bits) override {
return bits == 16;
}

bool begin(long sampleRate) {
_sampleRate = sampleRate;
Expand All @@ -47,8 +51,8 @@ class PWMAudio : public Stream {
return begin();
}

bool begin();
void end();
virtual bool begin() override;
virtual bool end() override;

// from Stream
virtual int available() override;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "framework-arduinopico",
"version": "1.40301.0",
"version": "1.40400.0",
"description": "Arduino Wiring-based Framework (RPi Pico RP2040, RP2350)",
"keywords": [
"framework",
Expand Down
3 changes: 3 additions & 0 deletions package/package_pico_index.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
{
"name": "Pimoroni Plasma2040"
},
{
"name": "Pimoroni Plasma2350"
},
{
"name": "Pimoroni Tiny2040"
},
Expand Down
2 changes: 1 addition & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification

name=Raspberry Pi RP2040/RP2350 Boards
version=4.3.1
version=4.4.0

# Required discoveries and monitors
# ---------------------------------
Expand Down
Loading

0 comments on commit 2878a26

Please sign in to comment.