Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d8bbe2a
mtm_computer: Add DAC audio out module
todbot Mar 21, 2026
38b0233
mtm_hardware.c added
todbot Mar 21, 2026
a5f9f3b
mtm_hardware.dacout: add gain=1 or gain=2 argument
todbot Mar 23, 2026
02675cb
rework mcp4822 module from mtm_hardware.DACOut
todbot Mar 23, 2026
3b9eaf9
mtm_computer: Add DAC audio out module
todbot Mar 21, 2026
f63ea5c
mtm_hardware.c added
todbot Mar 21, 2026
c7fc0c0
mtm_hardware.dacout: add gain=1 or gain=2 argument
todbot Mar 23, 2026
2e4fc89
rework mcp4822 module from mtm_hardware.DACOut
todbot Mar 23, 2026
9fdf9dc
Merge branch 'mtm_computer_dac_audio' of github.com:todbot/circuitpyt…
todbot Mar 23, 2026
6651ac1
restore deleted circuitpython.pot, update translation
todbot Mar 23, 2026
8bf51db
mtm_computer: set DAC gain 2x
todbot Mar 23, 2026
bde1ee4
Revert "mtm_computer: set DAC gain 2x"
todbot Mar 24, 2026
c2395d9
fix zephyr builds by running update_boardnfo.py
todbot Mar 24, 2026
2de067b
mcp4822 gain argument fix, as per requested
todbot Mar 24, 2026
ad21609
mcp4822 gain argument fix, as per requested
todbot Mar 24, 2026
dd1c957
mtm_computer: make board.DAC() an actual singleton
todbot Mar 24, 2026
5bd2a42
mtm_computer: make sure board.DAC() gets deallocated on board deinit
todbot Mar 24, 2026
13d6fea
mcp4822 CS/MOSI argument fix, as per requested
todbot Mar 24, 2026
62ffc25
mcp4822 CS/MOSI argument fix, as per requested
todbot Mar 24, 2026
bec871e
mtm_computer: Add DAC audio out module
todbot Mar 21, 2026
7e66d51
mtm_hardware.c added
todbot Mar 21, 2026
eb3fd70
mtm_hardware.dacout: add gain=1 or gain=2 argument
todbot Mar 23, 2026
8d282d5
rework mcp4822 module from mtm_hardware.DACOut
todbot Mar 23, 2026
d0e286a
restore deleted circuitpython.pot, update translation
todbot Mar 23, 2026
a20f1f9
mtm_computer: set DAC gain 2x
todbot Mar 23, 2026
2793baa
Revert "mtm_computer: set DAC gain 2x"
todbot Mar 24, 2026
32165ce
fix zephyr builds by running update_boardnfo.py
todbot Mar 24, 2026
b66baec
mcp4822 gain argument fix, as per requested
todbot Mar 24, 2026
16285c1
mcp4822 gain argument fix, as per requested
todbot Mar 24, 2026
afb64e0
mtm_computer: make board.DAC() an actual singleton
todbot Mar 24, 2026
072c277
mtm_computer: make sure board.DAC() gets deallocated on board deinit
todbot Mar 24, 2026
8309a23
mcp4822 CS/MOSI argument fix, as per requested
todbot Mar 24, 2026
74aee24
mcp4822 CS/MOSI argument fix, as per requested
todbot Mar 24, 2026
981a818
Merge branch 'mtm_computer_dac_audio' of github.com:todbot/circuitpyt…
todbot Mar 25, 2026
4439b66
Merge branch 'adafruit:main' into mtm_computer_dac_audio
todbot Mar 25, 2026
0f690b7
fix zephyr builds by running update_boardnfo.py
todbot Mar 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ msgstr ""

#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
#: ports/raspberrypi/common-hal/mcp4822/MCP4822.c
msgid "Audio source error"
msgstr ""

Expand Down Expand Up @@ -1300,6 +1301,7 @@ msgstr ""
msgid "Invalid %q"
msgstr ""

#: ports/raspberrypi/common-hal/mcp4822/MCP4822.c
#: ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c
#: shared-module/aurora_epaper/aurora_framebuffer.c
msgid "Invalid %q and %q"
Expand Down Expand Up @@ -1537,6 +1539,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
#: ports/raspberrypi/common-hal/mcp4822/MCP4822.c
msgid "No DMA channel found"
msgstr ""

Expand Down Expand Up @@ -1651,7 +1654,7 @@ msgid "Not connected"
msgstr ""

#: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c
#: shared-bindings/audiopwmio/PWMAudioOut.c
#: shared-bindings/audiopwmio/PWMAudioOut.c shared-bindings/mcp4822/MCP4822.c
msgid "Not playing"
msgstr ""

Expand Down Expand Up @@ -2168,6 +2171,7 @@ msgid "Too many channels in sample"
msgstr ""

#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/mcp4822/MCP4822.c
msgid "Too many channels in sample."
msgstr ""

Expand Down Expand Up @@ -2266,6 +2270,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
#: ports/raspberrypi/common-hal/mcp4822/MCP4822.c
msgid "Unable to allocate buffers for signed conversion"
msgstr ""

Expand Down
31 changes: 31 additions & 0 deletions ports/raspberrypi/boards/mtm_computer/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,36 @@
// SPDX-License-Identifier: MIT

#include "supervisor/board.h"
#include "shared-bindings/mcp4822/MCP4822.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "peripherals/pins.h"
#include "py/runtime.h"

// board.DAC() — factory function that constructs an mcp4822.MCP4822 with
// the MTM Workshop Computer's DAC pins (GP18=SCK, GP19=SDI, GP21=CS).

static mp_obj_t board_dac_singleton = MP_OBJ_NULL;

static mp_obj_t board_dac_factory(void) {
if (board_dac_singleton == MP_OBJ_NULL) {
mcp4822_mcp4822_obj_t *dac = mp_obj_malloc_with_finaliser(
mcp4822_mcp4822_obj_t, &mcp4822_mcp4822_type);
common_hal_mcp4822_mcp4822_construct(
dac,
&pin_GPIO18, // clock (SCK)
&pin_GPIO19, // mosi (SDI)
&pin_GPIO21, // cs
1); // gain 1x
board_dac_singleton = MP_OBJ_FROM_PTR(dac);
}
return board_dac_singleton;
}
MP_DEFINE_CONST_FUN_OBJ_0(board_dac_obj, board_dac_factory);

void board_deinit(void) {
if (board_dac_singleton != MP_OBJ_NULL) {
common_hal_mcp4822_mcp4822_deinit(MP_OBJ_TO_PTR(board_dac_singleton));
board_dac_singleton = MP_OBJ_NULL;
}
}
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
1 change: 1 addition & 0 deletions ports/raspberrypi/boards/mtm_computer/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ"
CIRCUITPY_AUDIOEFFECTS = 1
CIRCUITPY_IMAGECAPTURE = 0
CIRCUITPY_PICODVI = 0
CIRCUITPY_MCP4822 = 1
6 changes: 5 additions & 1 deletion ports/raspberrypi/boards/mtm_computer/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "shared-bindings/board/__init__.h"

extern const mp_obj_fun_builtin_fixed_t board_dac_obj;

static const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS

Expand All @@ -21,7 +23,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_PULSE_2_IN), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) },


{ MP_ROM_QSTR(MP_QSTR_NORM_PROBE), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) },

Expand Down Expand Up @@ -105,6 +106,9 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) },
{ MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) },

// Factory function: dac = board.DAC() returns a configured mcp4822.MCP4822
{ MP_ROM_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&board_dac_obj) },

// { MP_ROM_QSTR(MP_QSTR_EEPROM_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Loading
Loading