Skip to content

Commit fa63c67

Browse files
committed
DM: some I2S stuff
1 parent 7f275e1 commit fa63c67

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

boards.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ adafruit_metro_m4.build.usb_product="Adafruit Metro M4"
176176
adafruit_metro_m4.build.usb_manufacturer="Adafruit LLC"
177177
adafruit_metro_m4.build.board=METRO_M4
178178
adafruit_metro_m4.build.core=arduino
179-
adafruit_metro_m4.build.extra_flags=-D__SAMD51J19A__ -D__SAMD51__ {build.usb_flags} -DARM_MATH_CM4
179+
adafruit_metro_m4.build.extra_flags=-D__SAMD51J19A__ -D__SAMD51__ -DDEBUG {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
180180
adafruit_metro_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
181181
adafruit_metro_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg
182182
adafruit_metro_m4.build.variant=metro_m4
@@ -185,9 +185,6 @@ adafruit_metro_m4.build.vid=0x239A
185185
adafruit_metro_m4.build.pid=0x8020
186186
adafruit_metro_m4.bootloader.tool=openocd
187187
adafruit_metro_m4.bootloader.file=metroM4/METRO_M4_sam_ba.bin
188-
adafruit_metro_m4.compiler.c.elf.extra_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16
189-
adafruit_metro_m4.compiler.c.extra_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16
190-
adafruit_metro_m4.compiler.cpp.extra_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16
191188
adafruit_metro_m4.compiler.arm.cmsis.ldflags="-L{build.variant.path}" -larm_cortexM4lf_math
192189

193190
# Adafruit Feather M4 (SAMD51)

cores/arduino/WVariant.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,19 @@ typedef enum _EPioType
226226
PIO_SERCOM_ALT, /* The pin is controlled by the associated signal of peripheral D. */
227227
PIO_TIMER, /* The pin is controlled by the associated signal of peripheral E. */
228228
PIO_TIMER_ALT, /* The pin is controlled by the associated signal of peripheral F. */
229+
#if defined(__SAMD51__)
230+
PIO_TCC_PDEC, /* The pin is controlled by the associated signal of peripheral G. */
231+
PIO_COM, /* The pin is controlled by the associated signal of peripheral H. */
232+
PIO_SDHC, /* The pin is controlled by the associated signal of peripheral I. */
233+
PIO_I2S, /* The pin is controlled by the associated signal of peripheral J. */
234+
PIO_PCC, /* The pin is controlled by the associated signal of peripheral K. */
235+
PIO_GMAC, /* The pin is controlled by the associated signal of peripheral L. */
236+
PIO_AC_CLK, /* The pin is controlled by the associated signal of peripheral M. */
237+
PIO_CCL, /* The pin is controlled by the associated signal of peripheral N. */
238+
#else
229239
PIO_COM, /* The pin is controlled by the associated signal of peripheral G. */
230240
PIO_AC_CLK, /* The pin is controlled by the associated signal of peripheral H. */
241+
#endif
231242
PIO_DIGITAL, /* The pin is controlled by PORT. */
232243
PIO_INPUT, /* The pin is controlled by PORT and is an input. */
233244
PIO_INPUT_PULLUP, /* The pin is controlled by PORT and is an input with internal pull-up resistor enabled. */

cores/arduino/wiring_private.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,19 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
6767
case PIO_TIMER:
6868
case PIO_TIMER_ALT:
6969
case PIO_EXTINT:
70+
#if defined(__SAMD51__)
71+
case PIO_TCC_PDEC:
7072
case PIO_COM:
73+
case PIO_SDHC:
74+
case PIO_I2S:
75+
case PIO_PCC:
76+
case PIO_GMAC:
7177
case PIO_AC_CLK:
78+
case PIO_CCL:
79+
#else
80+
case PIO_COM:
81+
case PIO_AC_CLK:
82+
#endif
7283
#if 0
7384
// Is the pio pin in the lower 16 ones?
7485
// The WRCONFIG register allows update of only 16 pin max out of 32

platform.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ compiler.warning_flags.all=-Wall -Wextra
3333

3434
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
3535
compiler.c.cmd=arm-none-eabi-gcc
36-
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
36+
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g3 -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
3737
compiler.c.elf.cmd=arm-none-eabi-gcc
3838
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
3939
compiler.S.cmd=arm-none-eabi-gcc
40-
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
40+
compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD
4141
compiler.cpp.cmd=arm-none-eabi-g++
42-
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
42+
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g3 -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
4343
compiler.ar.cmd=arm-none-eabi-ar
4444
compiler.ar.flags=rcs
4545
compiler.objcopy.cmd=arm-none-eabi-objcopy

variants/metro_m4/linker_scripts/gcc/flash_without_bootloader.ld

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
MEMORY
2727
{
28-
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
29-
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000
28+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000
29+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x30000
3030
}
3131

3232
/* Linker script to place sections and symbol values. Should be used together
@@ -68,6 +68,7 @@ SECTIONS
6868
{
6969
__text_start__ = .;
7070

71+
. = ALIGN(4);
7172
KEEP(*(.isr_vector))
7273
*(.text*)
7374

variants/metro_m4/variant.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
/** Master clock frequency */
3333
#define VARIANT_MCK (120000000ul)
3434

35+
#define VARIANT_GCLK0_FREQ (120000000UL)
36+
#define VARIANT_GCLK1_FREQ (48000000UL)
37+
#define VARIANT_GCLK2_FREQ (100000000UL)
38+
3539
/*----------------------------------------------------------------------------
3640
* Headers
3741
*----------------------------------------------------------------------------*/
@@ -190,9 +194,11 @@ static const uint8_t SCL = PIN_WIRE_SCL;
190194
#define I2S_CLOCK_GENERATOR 3
191195

192196
//TODO: these
193-
#define PIN_I2S_SD (13u)
197+
#define PIN_I2S_SDO (13u)
198+
#define PIN_I2S_SDI (1u)
194199
#define PIN_I2S_SCK (3u)
195200
#define PIN_I2S_FS (12u)
201+
#define PIN_I2S_MCK (2u)
196202

197203
#ifdef __cplusplus
198204
}

0 commit comments

Comments
 (0)