Skip to content

Commit d66255f

Browse files
committed
Update hardware configs
- Drop GPIO LCD support + Add general I2S config + Pin assignments moved to be more compatible with picoX21H project
1 parent 886a5dc commit d66255f

17 files changed

+4173
-139
lines changed

Platform

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,24 @@ to another I2S DAC
6969
|2|UART-0|Debug console in (UART) RX|
7070
|3|GND|UART GND|
7171
|6|UART-1|MIDI IN|
72-
|19|I2C1|SDA (for I2C LCD)|
73-
|20|I2C1|SCL (for I2C LCD)|
74-
|29|PIO|I2S DATA|
75-
|31|PIO|MCLK (for I2S DAC chip)|
76-
|32|PIO|I2S LR CLK|
77-
|34|PIO|I2S DATA CLK|
72+
|24|I2C1|SDA (for I2C LCD)|
73+
|25|I2C1|SCL (for I2C LCD)|
74+
|31|PIO|I2S DATA|
75+
|32|PIO|I2S DATA CLK|
76+
|33|PIO|I2S LR CLK|
7877

79-
### Alternative hardware targets
78+
### Hardware targets
8079

8180
Software builds for the following hardware targets...
82-
+ PIMORONI_PICO_AUDIO - Use the Pimoroni Pico Audio I2S DAC and an I2C LCD
81+
+ PIMORONI_PICO_AUDIO - Use the Pimoroni Pico Audio I2S DAC
82+
+ I2S_DAC - Any I2S DAC supporting stereo 16-bit samples at 49 KHz (no MCLK)
8383
+ PWM_DAC - DAC implemented using the on-chip PWM and a few external resistors and capacitors on pins 21 and 22 (sound quality is poor)
84-
+ WAVESHARE_GPIO_LCD - The hardware described above
85-
+ WAVESHARE_I2C_LCD - Use an I2C LCD on pins 19+20 instead of the 8-bit parallel interface
84+
+ WAVESHARE_REV2_1 - For the Waveshare I2S DAC (Rev2.1) with I2C LCD on pins 19+20
8685
+ PIMORONI_VGA_DEMO - Support for the Pimoroni Pico VGA Demo Base (!!!! untested !!!!)
8786

8887
NOTE: The LCD and LED displays are optional and will not block operation if not fitted
8988

90-
In addition all the above targets are built for and work with RP2350 Picos as well as the older RP2040 Picos.
89+
In addition the above targets are built for and work with RP2350 Picos as well as the older RP2040 Picos.
9190

9291
### Components
9392

@@ -135,9 +134,9 @@ flashable images will be found under the build sub-directory here...
135134

136135
build/Source/picoX7_PIMORONI_PICO_AUDIO.uf2
137136
build/Source/picoX7_PIMORONI_VGA_DEMO.uf2
137+
build/Source/picoX7_I2S_DAC.uf2
138138
build/Source/picoX7_PWM_DAC.uf2
139-
build/Source/picoX7_WAVESHARE_GPIO_LCD.uf2
140-
build/Source/picoX7_WAVESHARE_I2C_LCD.uf2
139+
build/Source/picoX7_WAVESHARE_REV2_1.uf2
141140

142141
Build the native target...
143142

Source/hw/Adc.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

Source/hw/Audio.h

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626

2727
#include "hw/Config.h"
2828

29-
#if defined(HW_DAC_WAVESHARE)
29+
#if defined(HW_DAC_I2S_WAVESHARE_REV2_1)
3030
#define HW_DAC_I2S
3131

32-
#elif defined(HW_DAC_PIMORONI_VGA_DEMO)
32+
#elif defined(HW_DAC_I2S_PIMORONI_VGA_DEMO)
3333
#define HW_DAC_I2S
3434

35-
#elif defined(HW_DAC_PIMORONI_PICO_AUDIO)
35+
#elif defined(HW_DAC_I2S_PIMORONI_PICO_AUDIO)
36+
#define HW_DAC_I2S
37+
38+
#elif defined(HW_DAC_I2S_ANY)
3639
#define HW_DAC_I2S
3740

3841
#elif defined(HW_DAC_PWM)
@@ -51,12 +54,10 @@
5154

5255
namespace hw {
5356

54-
#if defined(HW_DAC_WAVESHARE)
57+
#if defined(HW_DAC_I2S_WAVESHARE_REV2_1)
5558

56-
#if defined(HW_ADC)
57-
58-
//! I2S DAC, with pinout for Waveshare Pico-Audio (Rev 2.1) adjusted to allow use of ADC0
59-
//! XXX not piggy-back
59+
//! I2S DAC, with pinout for Waveshare Pico-Audio (Rev 2.1)
60+
//! piggy-back
6061
template <unsigned SAMPLES_PER_TICK>
6162
class Audio : public MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>
6263
{
@@ -65,63 +66,60 @@ class Audio : public MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>
6566
: MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>{dac_freq,
6667
MTL::PIN_29, // SD
6768
MTL::PIN_32, // LRCLK + SCLK
68-
MTL::PIN_27, // MCLK
69+
MTL::PIN_31, // MCLK
6970
MTL::Audio::STEREO_PAIRS_16,
7071
true} // LSB LRCLK / MSB SCLK
7172
{
7273
}
7374
};
7475

75-
#else
76+
#elif defined(HW_DAC_I2S_PIMORONI_VGA_DEMO)
7677

77-
//! I2S DAC, with pinout for Waveshare Pico-Audio (Rev 2.1)
78-
//! XXX piggy-back
78+
//! I2S DAC, with pinout for PiMoroni VGA Demo board
7979
template <unsigned SAMPLES_PER_TICK>
8080
class Audio : public MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>
8181
{
8282
public:
8383
Audio(unsigned dac_freq)
8484
: MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>{dac_freq,
85-
MTL::PIN_29, // SD
86-
MTL::PIN_32, // LRCLK + SCLK
87-
MTL::PIN_31, // MCLK
85+
MTL::PIN_31, // SD
86+
MTL::PIN_32, // LRCLK + SCLK
87+
MTL::PIN_IGNORE, // No MCLK
8888
MTL::Audio::STEREO_PAIRS_16,
89-
true} // LSB LRCLK / MSB SCLK
89+
false} // LSB LRCLK / MSB SCLK
9090
{
9191
}
9292
};
9393

94-
#endif
95-
96-
#elif defined(HW_DAC_PIMORONI_VGA_DEMO)
94+
#elif defined(HW_DAC_I2S_PIMORONI_PICO_AUDIO)
9795

98-
//! I2S DAC, with pinout for PiMoroni VGA Demo board
96+
//! I2S DAC, with pinout for PiMoroni Pico Audio (piggy back)
9997
template <unsigned SAMPLES_PER_TICK>
10098
class Audio : public MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>
10199
{
102100
public:
103101
Audio(unsigned dac_freq)
104102
: MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>{dac_freq,
105-
MTL::PIN_31, // SD
106-
MTL::PIN_32, // LRCLK + SCLK
103+
MTL::PIN_12, // SD
104+
MTL::PIN_14, // LRCLK + SCLK
107105
MTL::PIN_IGNORE, // No MCLK
108106
MTL::Audio::STEREO_PAIRS_16,
109107
false} // LSB LRCLK / MSB SCLK
110108
{
111109
}
112110
};
113111

114-
#elif defined(HW_DAC_PIMORONI_PICO_AUDIO)
112+
#elif defined(HW_DAC_I2S_ANY)
115113

116-
//! I2S DAC, with pinout for PiMoroni Pico Audio
114+
//! I2S DAC, with pinout in common with other picoX21H project
117115
template <unsigned SAMPLES_PER_TICK>
118116
class Audio : public MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>
119117
{
120118
public:
121119
Audio(unsigned dac_freq)
122120
: MTL::PioAudio<MTL::Pio0,SAMPLES_PER_TICK>{dac_freq,
123-
MTL::PIN_12, // SD
124-
MTL::PIN_14, // LRCLK + SCLK
121+
MTL::PIN_31, // SD
122+
MTL::PIN_32, // LRCLK + SCLK
125123
MTL::PIN_IGNORE, // No MCLK
126124
MTL::Audio::STEREO_PAIRS_16,
127125
false} // LSB LRCLK / MSB SCLK

Source/hw/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ target_include_directories(HW INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..)
2626
if(${PLT_TARGET} STREQUAL rpipico)
2727

2828
set(hw_config_list
29-
WAVESHARE_GPIO_LCD
30-
WAVESHARE_I2C_LCD
29+
WAVESHARE_REV2_1
3130
PIMORONI_VGA_DEMO
3231
PIMORONI_PICO_AUDIO
32+
I2S_DAC
3333
PWM_DAC
3434
PARENT_SCOPE)
3535

@@ -38,9 +38,9 @@ if(${PLT_TARGET} STREQUAL rpipico)
3838
elseif(${PLT_TARGET} STREQUAL rpipico2)
3939

4040
set(hw_config_list
41-
WAVESHARE_GPIO_LCD
42-
WAVESHARE_I2C_LCD
41+
WAVESHARE_REV2_1
4342
PIMORONI_PICO_AUDIO
43+
I2S_DAC
4444
PWM_DAC
4545
PARENT_SCOPE)
4646

Source/hw/Config.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,59 @@
2424

2525
#pragma once
2626

27-
#if defined(HW_WAVESHARE_GPIO_LCD)
27+
#if defined(HW_WAVESHARE_REV2_1)
2828

29-
#define HW_DESCR "WaveShare Rev2.1 I2S DAC + GPIO LCD"
29+
#define HW_DESCR "WaveShare Rev2.1 I2S DAC"
3030

3131
#define HW_MIDI_USB_DEVICE
3232
#define HW_MIDI_IN_UART1
33-
#define HW_DAC_WAVESHARE
33+
#define HW_DAC_I2S_WAVESHARE_REV2_1
3434
#define HW_LED
3535
#define HW_LED_7_SEG
36-
#define HW_LCD_GPIO
36+
#define HW_LCD_I2C
37+
#define HW_LCD_I2C_ADDR 0x3E
3738

38-
#elif defined(HW_WAVESHARE_I2C_LCD)
39+
#elif defined(HW_PIMORONI_PICO_AUDIO)
3940

40-
#define HW_DESCR "WaveShare Rev2.1 I2S DAC + I2C LCD"
41+
#define HW_DESCR "Pimoroni pico audio I2S DAC"
4142

4243
#define HW_MIDI_USB_DEVICE
4344
#define HW_MIDI_IN_UART1
44-
#define HW_DAC_WAVESHARE
45+
#define HW_DAC_I2S_PIMORONI_PICO_AUDIO
4546
#define HW_LED
4647
#define HW_LED_7_SEG
4748
#define HW_LCD_I2C
4849
#define HW_LCD_I2C_ADDR 0x3E
4950

50-
#elif defined(HW_PIMORONI_PICO_AUDIO)
51+
#elif defined(HW_PIMORONI_VGA_DEMO)
5152

52-
#define HW_DESCR "Pimoroni pico audio + I2C LCD"
53+
#define HW_DESCR "Pimoroni VGA Demo I2S DAC"
5354

5455
#define HW_MIDI_USB_DEVICE
55-
#define HW_MIDI_IN_UART1
56-
#define HW_DAC_PIMORONI_PICO_AUDIO
56+
#define HW_MIDI_IN_FAKE
57+
#define HW_DAC_I2S_PIMORONI_VGA_DEMO
5758
#define HW_LED
5859
#define HW_LED_7_SEG
59-
#define HW_LCD_I2C
60-
#define HW_LCD_I2C_ADDR 0x3E
6160

62-
#elif defined(HW_PIMORONI_VGA_DEMO)
61+
#elif defined(HW_I2S_DAC)
6362

64-
#define HW_DESCR "Pimoroni VGA Demo"
63+
#define HW_DESCR "I2S DAC"
6564

65+
#define HW_DAC_I2S_ANY
6666
#define HW_MIDI_USB_DEVICE
67-
#define HW_MIDI_IN_FAKE
68-
#define HW_DAC_PIMORONI_VGA_DEMO
67+
#define HW_MIDI_IN_UART1
6968
#define HW_LED
7069
#define HW_LED_7_SEG
70+
#define HW_LCD_I2C
71+
#define HW_LCD_I2C_ADDR 0x3E
7172

7273
#elif defined(HW_PWM_DAC)
7374

74-
#define HW_DESCR "Simple PWM DAC"
75+
#define HW_DESCR "PWM DAC"
7576

77+
#define HW_DAC_PWM
7678
#define HW_MIDI_USB_DEVICE
7779
#define HW_MIDI_IN_UART1
78-
#define HW_DAC_PWM
7980
#define HW_LED
8081
#define HW_LED_7_SEG
8182
#define HW_LCD_I2C
@@ -85,8 +86,8 @@
8586

8687
#define HW_DESCR "native"
8788

88-
#define HW_MIDI_IN_NATIVE
8989
#define HW_DAC_NATIVE
90+
#define HW_MIDI_IN_NATIVE
9091

9192
#else
9293

Source/hw/Lcd.h

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626

2727
#include "hw/Config.h"
2828

29-
#if defined(HW_LCD_GPIO)
30-
#include "MTL/AlphaNumLcd_Gpio.h"
31-
32-
#elif defined(HW_LCD_I2C)
29+
#if defined(HW_LCD_I2C)
3330
#include "MTL/AlphaNumLcd_I2C.h"
3431

3532
#elif defined(HW_LCD_I2C_BRIDGE)
@@ -41,32 +38,18 @@
4138

4239
namespace hw {
4340

44-
#if defined(HW_LCD_GPIO)
45-
46-
// pico pin 9-12 : DATA[0:3]
47-
// pico pin 14-17 : DATA[4:7]
48-
// pico pin 19 : RS
49-
// pico pin 20 : E
50-
51-
using Lcd = MTL::AlphaNumLcd</* PIN_DATA */ MTL::PIN_9,
52-
/* PIN_R_S */ MTL::PIN_19,
53-
/* PIN_ENABLE */ MTL::PIN_20,
54-
/* COLS */ 16,
55-
/* ROWS */ 2,
56-
/* DL_8BIT */ true>;
57-
58-
#elif defined(HW_LCD_I2C)
41+
#if defined(HW_LCD_I2C)
5942

60-
// pico pin 19 : SDA
61-
// pico pin 20 : SCL
43+
// pico pin 24 : SDA
44+
// pico pin 25 : SCL
6245

63-
class Lcd : public MTL::AlphaNumLcd<MTL::I2C1_P19_P20,
46+
class Lcd : public MTL::AlphaNumLcd<MTL::I2C1_P24_P25,
6447
/* COLS */ 16,
6548
/* ROWS */ 2>
6649
{
6750
public:
6851
Lcd()
69-
: MTL::AlphaNumLcd<MTL::I2C1_P19_P20,
52+
: MTL::AlphaNumLcd<MTL::I2C1_P24_P25,
7053
/* COLS */ 16,
7154
/* ROWS */ 2>{ HW_LCD_I2C_ADDR }
7255
{
@@ -75,16 +58,16 @@ class Lcd : public MTL::AlphaNumLcd<MTL::I2C1_P19_P20,
7558

7659
#elif defined(HW_LCD_I2C_BRIDGE)
7760

78-
// pico pin 19 : SDA
79-
// pico pin 20 : SCL
61+
// pico pin 24 : SDA
62+
// pico pin 25 : SCL
8063

81-
class Lcd : public MTL::AlphaNumLcd<MTL::I2C1_P19_P20,
64+
class Lcd : public MTL::AlphaNumLcd<MTL::I2C1_P24_P25,
8265
/* COLS */ 16,
8366
/* ROWS */ 2>
8467
{
8568
public:
8669
Lcd()
87-
: MTL::AlphaNumLcd<MTL::I2C1_P19_P20,
70+
: MTL::AlphaNumLcd<MTL::I2C1_P24_P25,
8871
/* COLS */ 16,
8972
/* ROWS */ 2>{ HW_LCD_I2C_ADDR }
9073
{

0 commit comments

Comments
 (0)