Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BeagleBone AI #668

Closed
wants to merge 147 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
be75702
Support TDM mode on TLV codec: now working in 256-clock mode with eit…
Aug 8, 2019
951cb0a
First implementation of multiple codec support. PRU code needs to be …
Aug 10, 2019
b5c6f47
Move the multi-TLV codec to the IRQ PRU code. Probably not working at…
Oct 21, 2019
fc5adbb
Multichannel audio output now mostly works, but channels are in the w…
Oct 25, 2019
e39376e
Fixed erroneous TDM slot configuration. Multichannel TLV output now a…
Oct 27, 2019
247a187
Adapted registers for TLV320AIC3106 codec, which differ for the line …
Nov 12, 2019
f4e75e1
Disable DC blocking for TLV320AIC3106 differential analog inputs
Nov 12, 2019
374a004
Changed direction of frame sync so it is generated by McASP, not code…
Dec 28, 2019
d65162f
An empirical set of settings that produces (mostly) stable I/O -- but…
Dec 29, 2019
d040fd0
Go back to recommended McASP settings -- looks like this is more reli…
Jan 2, 2020
dadd20e
Updated PRU IRQ code to work on Bela Mini (with or without multi-codec)
Jan 17, 2020
5322997
Add support to PRU IRQ code for Bela Mini ADC CS line. however, analo…
Jan 17, 2020
bfd8a9e
Skip DAC CS on Bela Mini for IRQ PRU code
Jan 18, 2020
ade1f9d
Fixed ADC memory location in PRU IRQ code on Bela Mini
Jan 18, 2020
47c005d
Cleaned up pru_rtaudio.p
giuliomoro Mar 26, 2020
5f65dfe
Cleanup of stale comments and refactored
giuliomoro Mar 26, 2020
d22e5f4
multi-codec: Handling BelaMiniMultiAudio
giuliomoro Mar 26, 2020
449baef
actually working pru_rtaudio.p
giuliomoro Mar 27, 2020
d6be3f6
I2c_Codec: make transmitSyncBitDelay explicit
giuliomoro Jul 20, 2020
6d947c5
board_detect and core: Bela_hwContains() can be used to test for the …
giuliomoro Mar 27, 2020
53ee9ef
BelaMiniMultiAudio: re-added support
giuliomoro Jul 20, 2020
c5c8828
bitDelay is available as a parameter. Minor refactoring to improve re…
giuliomoro Mar 27, 2020
5440b5e
Allow to run BelaMini as BelaMiniMultiAudio
giuliomoro Mar 28, 2020
6a31f0c
PRU: Factored error codes out to PruArmCommon.h, and handling ARM_ERR…
giuliomoro Mar 30, 2020
88a4285
PRU: NOP, tidying up whitespaces a bit, cleaning out stale comments
giuliomoro Mar 30, 2020
6482d16
PRU: mostly renaming things for clarity, but also adding some QBA for…
giuliomoro Mar 30, 2020
9cc15ae
PRU: using IF_NOT_BELA_TLV32_JMP_TO instead of BELA_NOT_MULTI_TLV_OR_…
giuliomoro Mar 30, 2020
d9fcfe5
PRU: NOP Renamed macros for clarity
giuliomoro Mar 30, 2020
2fb4bd1
PRU: added QBA when done
giuliomoro Mar 30, 2020
610e129
PRU: one extra register filled with zeros for MULTI_TLV
giuliomoro Mar 30, 2020
9883ed5
PRU: NOP, cleaning up unused code
giuliomoro Mar 30, 2020
dc8d444
PRU: Adding offset of the first buffer to the second (it used to work…
giuliomoro Mar 30, 2020
ef9e710
PRU: fixed comments
giuliomoro Mar 30, 2020
aeef1d3
PRU: reg_frame_mcasp_total now makes some sense (at least for MULTI_T…
giuliomoro Mar 31, 2020
834299a
Makefile: when using RUN_WITH_PRU_BIN=true, use pru_rtaudio_irq.bin
giuliomoro Apr 1, 2020
c65e9fa
PRU: all types of boards use the same method for loading I/O channels.
giuliomoro Apr 1, 2020
d6264e7
PRU: Bela/BelaMini should now work with pru_rtraudio_irq.p (assuming …
giuliomoro Apr 1, 2020
153e8ab
core: verbose logging of pru code in use
giuliomoro Apr 1, 2020
539ff32
core/PRU: NOP refactoring, moving out the macro definitions to the Pr…
giuliomoro Apr 1, 2020
65851a5
PRU: the computation of many McASP config registers is now devolved t…
giuliomoro Apr 1, 2020
fe665b5
core: added methods to the codecs to report on channel count and samp…
giuliomoro Apr 1, 2020
a77ca75
core: codec parameters can be set before it is started. This will all…
giuliomoro Apr 2, 2020
2b42e50
core: McaspConfig is now a class in its own right, and it can program…
giuliomoro Apr 3, 2020
644ce1d
board_detect: now compiling
giuliomoro Jul 20, 2020
7c065a0
board_detect: now allowing several different ways of calling board_de…
giuliomoro Apr 1, 2021
9fc1514
core: offloaded the computation of even more McASP registers to ARM
giuliomoro Apr 6, 2020
bfa8688
core: McaspConfig's configuration parameters are now in a McaspConfig…
giuliomoro Apr 6, 2020
52b02b8
board_detect: somewhat rationalisesd the enum<->string conversion usi…
giuliomoro Apr 6, 2020
f542bca
board_detect: added BelaMiniMultiAudio to the enum
giuliomoro Jul 20, 2020
4a608bb
core: Mcasp: fixed and improved error reporting
giuliomoro Apr 6, 2020
55cde7f
PRU: NOP, renamed ...BELA_MULTI_TLV... to ...BELA_GENERIC_TDM...
giuliomoro Apr 6, 2020
98d9394
core: checking whether a valid codec was initalised, otherwise fail w…
giuliomoro Apr 6, 2020
ed83abd
core: CodecParams removed unused element
giuliomoro Apr 6, 2020
950e2cc
core: I2c_Codec be a bit more clever about how you count channels
giuliomoro Apr 6, 2020
efb381b
core: Mcasp added dataSize parameter
giuliomoro Apr 7, 2020
3e11db3
core: I2c_Codec is ready to be inherited from
giuliomoro Apr 7, 2020
2fd9df8
core: added generic multi-tdm codec that uses a Tlv320AIC104 as master
giuliomoro Mar 27, 2020
8b992a0
core: added codec-mode command line option which allows to pass a cod…
giuliomoro Apr 9, 2020
c92e612
core: I2c_Codec more accurate parameter calculation for the PLL (prev…
giuliomoro Apr 9, 2020
3080097
core: allow the codec driver to set Ahclkctl in the Mcasp
giuliomoro Apr 9, 2020
023e50b
pru: we are supposed to poll GBLCTL, not [XR]BLCTL. Given how our SET…
giuliomoro Apr 10, 2020
695f03f
pru: removed stale DBOX_CAPE define
giuliomoro Apr 10, 2020
da2c8bd
core: I2c_MultiTLVAudio mclk initialization
giuliomoro Apr 10, 2020
18735e7
pru: moved bits of code around following the instructions in the TRM …
giuliomoro Apr 10, 2020
1a76723
core: PRU given how resetting the codec is no longer needed to fix Mc…
giuliomoro Apr 10, 2020
85b29a1
make: added MultiTdmCodec to libbela
giuliomoro Apr 13, 2020
3864ff5
core: MultiTdmCodec: a more realistic use case
giuliomoro Apr 17, 2020
83a725e
I2c_Codec: actually using the verbose parameter in the constructor
giuliomoro May 11, 2020
2864206
Mcasp.cpp: compatible with g++-6.3
giuliomoro May 11, 2020
46b7787
I2c_MultiTLVCodec: passing multiple I2C busses and customised TdmConf…
giuliomoro Jun 17, 2020
901d53c
I2c_MultiTLVCodec: prevent copying
giuliomoro Jun 17, 2020
6a46033
MultiTLVCodec: allow children classes to access mcaspConfig, also ren…
giuliomoro Jun 17, 2020
a0d89c0
I2c_MultiTdmCodec: refactoring for multiple codecs. Now inheriting fr…
giuliomoro Jun 17, 2020
c106add
I2c_MultiTdmCodec: use two output serializers
giuliomoro Jun 18, 2020
6d41ce5
Mcasp: added print() method
giuliomoro Jun 22, 2020
a49c989
PRU: ensuring the input does not go out of sync by only reading if th…
giuliomoro Jun 22, 2020
7b635d5
PRU: NOP. Refactoring source (no change in the generated code)
giuliomoro Jun 22, 2020
c5a9b6a
I2c_CodeC: refactored noInit / noDeinit to minimise the number of par…
giuliomoro Jun 30, 2020
c70a08c
I2c_MultiT*Codec: using a configuration string
giuliomoro Jun 30, 2020
d23ecb9
board_detect: fixed docs
giuliomoro Jun 30, 2020
f14ebf4
I2c_MultiTLVCodec: factored common code out to MiscUtilities
giuliomoro Jul 20, 2020
9c76055
board_detect: factored common code out to MiscUtilities
giuliomoro Jul 20, 2020
7f88d89
board_detect: use bela_sw_settings instead of hardcoded paths
giuliomoro Jul 17, 2020
4d6cf27
RTAudio: CODEC_MODE can be picked up from belaconfig
giuliomoro Jun 30, 2020
27db260
RTAudio: updated to take advantage of the MiscUtilities features
giuliomoro Jul 20, 2020
509f72f
board_detect: updated to take advantage of the MiscUtilities
giuliomoro Jul 20, 2020
3a0deba
RTAudio.cpp: no longer accepts CODEC_MODE= in belaconfig: use CL="--c…
giuliomoro Jul 2, 2020
89def20
PRU: removed a couple more defines
giuliomoro Jul 17, 2020
baaa334
I2c_Codec: fixed comments
giuliomoro Jul 3, 2020
fc0a4fa
I2c_MultiTLVCodec: allow to disable codecs
giuliomoro Jul 14, 2020
e27c22d
I2c_MultiTLVCodec: using smart pointers to simplify the code
giuliomoro Jul 14, 2020
51700d7
I2c_MultiTLVCodec: treating all the codecs the same except when neede…
giuliomoro Jul 14, 2020
c743d8e
I2c_MultiTLVCodec: even simpler code
giuliomoro Jul 14, 2020
35c00f1
I2cMultiTLVCodec: _really_ treating all the codecs the same
giuliomoro Jul 14, 2020
5cffec0
I2c_Codec: updates for string preamp board: adjustable sampling rate …
Jul 5, 2020
91b1d6d
board_detect: suppress misleading error
giuliomoro Jul 21, 2020
1ec5e9e
RTAudio: (roughly) fixed fifoFactor for new BelaHws
giuliomoro Aug 17, 2020
7e25ef1
Batch: crude implementation to allow offline batch processing
giuliomoro Aug 22, 2020
17216b3
PRU: BOARD_FLAGS_BELA_MINI only should indicate whether DAC is there,…
giuliomoro Jan 22, 2021
73c5e3a
BelaMultiTdm: added new BelaHw and compatibilities
giuliomoro Jan 22, 2021
0e8c1c6
RTAudio: print mcasp registers when verbose
giuliomoro Apr 2, 2021
0af12aa
I2c_MultiTLVCodec: pass verbosity to codecs
giuliomoro Apr 2, 2021
aec67c3
Mcasp: fixed printing
giuliomoro Apr 2, 2021
f495629
AudioCodec: :print()
giuliomoro Apr 2, 2021
c7e3ba5
AudioCodec: added I2S mode
giuliomoro Apr 2, 2021
2a1e8db
Mcasp: fixed externalSamplesRisingEdge (it was backwards)
giuliomoro Apr 2, 2021
5b92fb2
I2c_Codec: explicitly support I2S, DSP and TDM modes
giuliomoro Apr 5, 2021
2024b22
pru_rtaudio_irq: explicitly empty rx FIFO at startup
giuliomoro Apr 5, 2021
b2c8208
Mcasp: fixed rotation and clarified dataSize (currently ignored)
giuliomoro Apr 6, 2021
9a6d23f
pru_rtaudio_irq.p: enabling Tx and Rx sync generators at the same time
giuliomoro Apr 6, 2021
38fb400
I2c_MultiTdmCodec: dealing better with clock source
giuliomoro Apr 6, 2021
e2dc4ca
Mcasp: initialised struct and fixed NUMEVT
giuliomoro Apr 6, 2021
92230dd
Mcasp: fail upon illegal setting
giuliomoro Apr 7, 2021
e93620f
I2c_Codec: also trying Pll settings for D = 0
giuliomoro Apr 6, 2021
3eb7c52
I2c_Codec: use PLL even when bit clock is generated externally. This …
giuliomoro Apr 6, 2021
e637fa1
I2c_MultiI2sCodec: codec in I2s mode with an extra pair of data lines
giuliomoro Apr 2, 2021
5de6839
I2c_MultiTLVCodec: removed stale comments
giuliomoro Apr 14, 2021
2887efb
I2c_Codec: setMode() takes a comma separated string
giuliomoro Apr 14, 2021
d71ef0e
I2c_Codec: parametrise differential input mode
giuliomoro Apr 14, 2021
1718995
I2c_MultiTLVCodec: pass setMode() to each of the codecs
giuliomoro Apr 14, 2021
018cea9
RTAudioCommandLine: strdup is better
giuliomoro Apr 15, 2021
48dc7e3
Setting gains from command line can be done per-channel
giuliomoro Apr 15, 2021
1d70234
Reverting pru_rtaudio.p to the `dev` branch, with minimal changes to …
giuliomoro Jul 2, 2021
0ce65fb
pru/pru_rtaudio.p: works again
giuliomoro Jul 2, 2021
4d344fb
Removed compiler warnings (g++-8.3.0)
giuliomoro Jul 30, 2021
459cde0
pru: NIT: factored out CLOCK_MCASP_VALUE
giuliomoro Jul 29, 2021
4c33507
pru: wait for a few cycles after enabling McASP module clock in order…
giuliomoro Jul 29, 2021
cc28775
Makefile: BELA_USE_DEFINE is now ?= so it can be overridden more easi…
giuliomoro Jul 29, 2021
c31b7a1
PruManager: factored libprussdrv out of PRU into PruManager. No funct…
DhruvaG2000 Jul 4, 2021
4ee5c20
PruManager: added support for RPROC (though ENABLE_PRU_UIO is still d…
DhruvaG2000 Jul 30, 2021
601f038
PruManager: refactored firwmare name. More error checks in the rproc …
giuliomoro Jul 30, 2021
e2785a5
rproc: create resources/rproc-build which contains helpful files for …
DhruvaG2000 Jul 29, 2021
a5d3bc2
Added initial support for AM572x (BBAI), using rproc for PRU loading.…
DhruvaG2000 Jul 30, 2021
66c0c82
Makefile: simplified checks for IS_AM572x. Distinguished between Rpro…
giuliomoro Jul 29, 2021
637e2d4
Makefile: build .out file via pasm+clpru when ENABLE_PRU_RPROC==1.
giuliomoro Jul 29, 2021
b5b205d
Gpio: added support for AM572x
DhruvaG2000 Jul 31, 2021
0131b06
BBAI: updated most non-Bela GPIOs (except LED)
giuliomoro Jul 31, 2021
26d65f9
Gpio: added getMask()
giuliomoro Jul 31, 2021
a3b3818
PRU: de-hard-coded UserLed name, number and triggers. Also supports BBAI
giuliomoro Jul 31, 2021
5e5a042
pru: NIT: fixed comment
giuliomoro Jul 31, 2021
38cc7fe
pru_rtaudio.p: fix McSPI BASE for BBAI
DhruvaG2000 Aug 1, 2021
8f2b4b6
BBAI: added more than half of the Bela digitals. Currently using only…
giuliomoro Aug 1, 2021
551beb6
pru: added support for SPI analog ADC/DAC on BBAI (data lines are swa…
giuliomoro Aug 1, 2021
ae52646
pru: NIT: assigned real names to AM572x's MCASP and SPI peripherals.
giuliomoro Aug 2, 2021
8b1e0e6
pru: factored out board-specific constants to board_specific.h
giuliomoro Aug 2, 2021
33bd719
pru: ported changes applied to pru/pru_rtaudio.p in a5d3bc27..8b1e0e6…
giuliomoro Aug 2, 2021
b5841d5
I2c_Codec: setting Mcasp serialisers in use depending on board (as us…
giuliomoro Aug 2, 2021
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
96 changes: 81 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ ifeq ($(RUN_WITH_PRU_BIN),true)
ifndef PROJECT
$(warning PROJECT is not defined, so RUN_WITH_PRU_BIN will be ignored)
endif # ifndef PROJECT
COMMAND_LINE_OPTIONS := --pru-file $(BASE_DIR)/pru_rtaudio.bin $(COMMAND_LINE_OPTIONS)
run: pru_rtaudio.bin
COMMAND_LINE_OPTIONS := --pru-file build/pru/pru_rtaudio_irq.bin $(COMMAND_LINE_OPTIONS)
run: build/pru/pru_rtaudio.bin
run: build/pru/pru_rtaudio_irq.bin
else
build/core/PruBinary.o: build/pru/pru_rtaudio_bin.h build/pru/pru_rtaudio_irq_bin.h
endif #ifeq($(RUN_WITH_PRU_BIN),true)
Expand Down Expand Up @@ -287,17 +288,63 @@ LEGACY_INCLUDE_PATH := ./include/legacy

INCLUDES := -I$(PROJECT_DIR) -I$(LEGACY_INCLUDE_PATH) -I./include -I./build/pru/ -I./
ifeq ($(XENOMAI_VERSION),2.6)
BELA_USE_DEFINE=BELA_USE_POLL
BELA_USE_DEFINE?=BELA_USE_POLL
endif
ifeq ($(XENOMAI_VERSION),3)
BELA_USE_DEFINE=BELA_USE_RTDM
BELA_USE_DEFINE?=BELA_USE_RTDM
endif

DEFAULT_COMMON_FLAGS := $(DEFAULT_XENOMAI_CFLAGS) -O3 -g -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math -DNDEBUG -D$(BELA_USE_DEFINE) -I$(BASE_DIR)/resources/$(DEBIAN_VERSION)/include -save-temps=obj
IS_AM572x ?= $(shell grep -q AI /proc/device-tree/model && echo 1 || echo 0)

# Flag for using/ not using (UIO+prussdrv)/(RPROC+Mmap)
ifeq (1,$(strip $(IS_AM572x)))
ENABLE_PRU_UIO = 0
ENABLE_PRU_RPROC = 1
BOARD_COMMON_FLAGS = -DIS_AM572x
else
ENABLE_PRU_UIO = 1
ENABLE_PRU_RPROC = 0
BOARD_COMMON_FLAGS =
endif

ifeq (,$(AT))
$(info BOARD IS_AM572x? $(IS_AM572x))
endif

ifeq (1,$(strip $(ENABLE_PRU_RPROC)))
firmwareBelaRProcNoMcaspIrqRelative ?= build/pru/pru_rtaudio.out
firmwareBelaRProcMcaspIrqRelative ?= build/pru/pru_rtaudio_irq.out
firmwareBelaRProcNoMcaspIrq ?=$(BELA_DIR)/$(strip $(firmwareBelaRProcNoMcaspIrqRelative))
firmwareBelaRProcMcaspIrq ?=$(BELA_DIR)/$(strip $(firmwareBelaRProcMcaspIrqRelative))
BOARD_CORE_LDLIBS =
BOARD_CORE_CORE_OBJS =
RPROC_BUILD_DIR = build/pru/rproc
RPROC_RESOURCES_BASE=$(BELA_DIR)/resources/rproc-build
RPROC_TEMPLATE=$(RPROC_RESOURCES_BASE)/rproc-template.c
RPROC_TMP_FILE=$(RPROC_BUILD_DIR)/temp
RPROC_INCLUDE=$(RPROC_RESOURCES_BASE)/common
RPROC_INCLUDED_ASSEMBLY = $(RPROC_BUILD_DIR)/included_assembly.h
ifeq (1,$(IS_AM572x))
RPROC_CMD:=$(RPROC_RESOURCES_BASE)/am57xx_pru.cmd
else
RPROC_CMD:=$(RPROC_RESOURCES_BASE)/am335x_pru.cmd
endif
else # ENABLE_PRU_RPROC is 0
BOARD_CORE_CPP_SRCS_FILTER_OUT :=
endif

ifeq (1,$(strip $(ENABLE_PRU_UIO)))
BOARD_CORE_LDLIBS = -lprussdrv
BOARD_CORE_CORE_OBJS = build/core/PruBinary.o
else # ENABLE_PRU_UIO is 0
BOARD_CORE_CPP_SRCS_FILTER_OUT := core/PruBinary.cpp
endif

DEFAULT_COMMON_FLAGS := $(DEFAULT_XENOMAI_CFLAGS) -O3 -g -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math -DNDEBUG -D$(BELA_USE_DEFINE) -I$(BASE_DIR)/resources/$(DEBIAN_VERSION)/include -save-temps=obj -DENABLE_PRU_UIO=$(ENABLE_PRU_UIO) -DENABLE_PRU_RPROC=$(ENABLE_PRU_RPROC) -DfirmwareBelaRProcMcaspIrq='"$(firmwareBelaRProcMcaspIrq)"' -DfirmwareBelaRProcNoMcaspIrq='"$(firmwareBelaRProcNoMcaspIrq)"' $(BOARD_COMMON_FLAGS)
DEFAULT_CPPFLAGS := $(DEFAULT_COMMON_FLAGS) -std=c++11
DEFAULT_CFLAGS := $(DEFAULT_COMMON_FLAGS) -std=gnu11
BELA_LDFLAGS = -Llib/
BELA_CORE_LDLIBS = $(DEFAULT_XENOMAI_LDFLAGS) -lprussdrv -lstdc++ # libraries needed by core code (libbela.so)
BELA_CORE_LDLIBS = $(DEFAULT_XENOMAI_LDFLAGS) $(BOARD_CORE_LDLIBS) -lstdc++ # libraries needed by core code (libbela.so)
BELA_EXTRA_LDLIBS =$(DEFAULT_XENOMAI_LDFLAGS) -lasound -lseasocks -lNE10 # additional libraries needed by extra code (libbelaextra.so)
BELA_LDLIBS = $(BELA_CORE_LDLIBS) $(BELA_EXTRA_LDLIBS)
ifeq ($(PROJECT_TYPE),libpd)
Expand Down Expand Up @@ -346,6 +393,8 @@ else
ifeq ($(COMPILER), gcc)
CC=gcc
CXX=g++
DEFAULT_CPPFLAGS += -Wno-psabi
DEFAULT_CFLAGS += -Wno-psabi
LDFLAGS+=-fno-pie -no-pie
endif
endif
Expand Down Expand Up @@ -375,6 +424,7 @@ CPP_OBJS := $(subst $(PROJECT_DIR),$(PROJECT_DIR)/build,$(CPP_SRCS:.cpp=.o))

BUILD_DIRS += $(dir $(C_OBJS))
BUILD_DIRS += $(dir $(CPP_OBJS))
BUILD_DIRS += $(RPROC_BUILD_DIR)
ALL_DEPS += $(addprefix $(PROJECT_DIR)/build/,$(notdir $(CPP_SRCS:.cpp=.d)))
endif # $(PROJECT)
#create build directories, should probably be conditional to PROJECT or li
Expand All @@ -390,9 +440,10 @@ CORE_C_SRCS = $(wildcard core/*.c)
CORE_OBJS := $(addprefix build/core/,$(notdir $(CORE_C_SRCS:.c=.o)))
ALL_DEPS += $(addprefix build/core/,$(notdir $(CORE_C_SRCS:.c=.d)))

CORE_CPP_SRCS = $(filter-out core/default_main.cpp core/default_libpd_render.cpp, $(wildcard core/*.cpp))
CORE_CPP_SRCS := $(filter-out core/default_main.cpp core/default_libpd_render.cpp, $(wildcard core/*.cpp))
CORE_CPP_SRCS := $(filter-out $(BOARD_CORE_CPP_SRCS_FILTER_OUT),$(CORE_CPP_SRCS))
CORE_OBJS := $(CORE_OBJS) $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.o)))
CORE_CORE_OBJS := build/core/RTAudio.o build/core/PRU.o build/core/RTAudioCommandLine.o build/core/I2c_Codec.o build/core/Spi_Codec.o build/core/math_runfast.o build/core/GPIOcontrol.o build/core/PruBinary.o build/core/board_detect.o build/core/DataFifo.o build/core/BelaContextFifo.o build/core/BelaContextSplitter.o build/core/MiscUtilities.o build/core/Mmap.o
CORE_CORE_OBJS := build/core/RTAudio.o build/core/PRU.o build/core/RTAudioCommandLine.o build/core/I2c_Codec.o build/core/I2c_MultiTLVCodec.o build/core/I2c_MultiTdmCodec.o build/core/Spi_Codec.o build/core/math_runfast.o build/core/GPIOcontrol.o build/core/board_detect.o build/core/DataFifo.o build/core/BelaContextFifo.o build/core/BelaContextSplitter.o build/core/MiscUtilities.o build/core/Mmap.o build/core/Mcasp.o build/core/PruManager.o $(BOARD_CORE_CORE_OBJS)
EXTRA_CORE_OBJS := $(filter-out $(CORE_CORE_OBJS), $(CORE_OBJS))
ALL_DEPS += $(addprefix build/core/,$(notdir $(CORE_CPP_SRCS:.cpp=.d)))

Expand All @@ -412,6 +463,9 @@ ALL_DEPS += ./build/core/default_main.d
-include libraries/*/build/*.d # dependencies for each of the libraries' object files

Bela: ## Builds the Bela program with all the optimizations
ifeq (1,$(strip $(ENABLE_PRU_RPROC)))
Bela: $(firmwareBelaRProcNoMcaspIrqRelative) $(firmwareBelaRProcMcaspIrqRelative)
endif
Bela: $(OUTPUT_FILE)

# all = build Bela
Expand Down Expand Up @@ -460,19 +514,30 @@ ifeq (,$(SYNTAX_FLAG))
endif
$(AT) echo ' '

%.bin: pru/%.p
%.out: %.bin
ifeq (,$(SYNTAX_FLAG))
$(AT) echo 'Building $< into $@...'
$(AT) prudis $< | sed 's/^\(.*\)$$/" \1\\n"/' > $(RPROC_INCLUDED_ASSEMBLY)
$(AT) clpru -fe $(RPROC_TMP_FILE).o $(RPROC_TEMPLATE) -v3 --endian=little --include_path=$(RPROC_BUILD_DIR) --include_path=$(RPROC_INCLUDE) --include_path=/usr/lib/ti/pru-software-support-package/include
$(AT) lnkpru -o $(RPROC_TMP_FILE).out $(RPROC_TMP_FILE).o --stack_size=0x0 --heap_size=0x0 -m $(RPROC_TMP_FILE).map $(RPROC_CMD)
$(AT) dd if=$< of=$(RPROC_TMP_FILE).out bs=1 obs=1 seek=52 conv=notrunc status=none
$(AT) mv $(RPROC_TMP_FILE).out $@
$(AT) echo ' ...done'
endif
$(AT) echo ' '

build/pru/%.bin: pru/%.p include/PruArmCommon.h pru/board_specific.h
ifeq (,$(SYNTAX_FLAG))
$(AT) echo 'Building $<...'
$(AT) pasm -V2 -b "$<" > /dev/null
$(AT) echo 'Building $< into $@...'
$(AT) cd $(dir $@) && pasm -V2 -L -c -b $(BOARD_COMMON_FLAGS) $(BELA_DIR)/$< > /dev/null
$(AT) echo ' ...done'
endif
$(AT) echo ' '

build/pru/%_bin.h: pru/%.p
build/pru/%_bin.h: pru/%.p include/PruArmCommon.h pru/board_specific.h
ifeq (,$(SYNTAX_FLAG))
$(AT) echo 'Building $<...'
$(AT) pasm -V2 -L -c "$<" > /dev/null
$(AT) mv "$(@:build/pru/%=%)" build/pru/
$(AT) echo 'Building $< into $@...'
$(AT) cd $(dir $@) && pasm -V2 -L -c $(BOARD_COMMON_FLAGS) $(BELA_DIR)/"$<" > /dev/null
$(AT) echo ' ...done'
endif
$(AT) echo ' '
Expand Down Expand Up @@ -830,3 +895,4 @@ heavy-unzip-archive: stop

.PHONY: all clean distclean help projectclean nostartup startup startuploop debug run runfg runscreen runscreenfg stopstartup stoprunning stop idestart idestop idestartup idenostartup ideconnect connect update checkupdate updateunsafe csoundstart scsynthstart scsynthstop scsynthstartup scsynthnostartup scsynthconnect lib c
-include CustomMakefileBottom.in
.SECONDARY: build/pru/pru_rtaudio.bin build/pru/pru_rtaudio_irq.bin # prevents temporary files from being deleted)
2 changes: 1 addition & 1 deletion core/BelaContextSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bool BelaContextSplitter::test()
// test the actual class
BelaContextSplitter spl1;
BelaContextSplitter spl2;
int factor = 4;
unsigned int factor = 4;
spl1.setup(factor, 1, (BelaContext*)&ctx1);
ctx2 = ctx1;
ctx2.audioFrames *= factor;
Expand Down
6 changes: 3 additions & 3 deletions core/DataFifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ void fillArray(std::vector<T>& vec)
bool DataFifo::test()
{
DataFifo df;
size_t msgSize = 1000;
size_t numMsg = 100;
ssize_t msgSize = 1000;
ssize_t numMsg = 100;
std::vector<char> sent(msgSize * numMsg);
std::vector<char> received(msgSize * numMsg);
for(unsigned int n = 0; n < sent.size(); ++n)
Expand All @@ -146,7 +146,7 @@ bool DataFifo::test()
ret = df.send(sent.data(), msgSize * 2);
assert(-EMSGSIZE == ret);

size_t newsz = msgSize / 2;
ssize_t newsz = msgSize / 2;
ret = df.send(sent.data(), newsz);
assert(0 == ret);
fillArray(received);
Expand Down
58 changes: 46 additions & 12 deletions core/Gpio.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include "../include/Gpio.h"
#include "GPIOcontrol.h"
#include <vector>
#include <stdexcept>
#include <stdio.h>

static const unsigned int kBitsPerGpioBank = 32;
static const uint32_t GPIO_SIZE = 0x198;
static const uint32_t GPIO_ADDRESSES[4] = {
0x44E07000,
0x4804C000,
0x481AC000,
0x481AE000,
};
#ifdef IS_AM572x
static const int kGpioBankIndexed = 1;
#else // IS_AM572x
static const int kGpioBankIndexed = 0;
#endif // IS_AM572x

Gpio::Gpio() : pin(-1), gpio(nullptr)
{}
Expand All @@ -18,7 +21,11 @@ Gpio::~Gpio()
}

int Gpio::open(unsigned int newPin, Direction direction, bool unexport){
if(newPin >= 128){
unsigned int bank = getBankNumber(newPin);
uint32_t gpioBase;
try {
gpioBase = getBankAddress(bank);
} catch (std::exception&) {
return -1;
}
pin = newPin;
Expand All @@ -33,10 +40,7 @@ int Gpio::open(unsigned int newPin, Direction direction, bool unexport){
if(gpio_set_dir(pin, direction) < 0){
return -1;
}
int bank = pin / 32;
pin = pin - bank * 32;
pinMask = 1 << pin;
uint32_t gpioBase = GPIO_ADDRESSES[bank];
pinMask = getMask(pin);
gpio = (uint32_t*)mmap.map(gpioBase, GPIO_SIZE);
if(!gpio)
return -2;
Expand All @@ -58,7 +62,37 @@ void Gpio::close(){
pin = -1;
}

uint32_t Gpio::getMask(unsigned int pin)
{
unsigned int bit = pin % kBitsPerGpioBank;
return 1 << bit;
}

uint32_t Gpio::getBankNumber(unsigned int pin)
{
return pin / kBitsPerGpioBank + kGpioBankIndexed;
}

uint32_t Gpio::getBankAddress(unsigned int bank)
{
return GPIO_ADDRESSES[bank];
// GPIO_ADDRESSES is private to this function so that there is no ambiguity
// about whether it should be 0- or 1- indexed
static const std::vector<uint32_t> GPIO_ADDRESSES = {
#ifdef IS_AM572x
0x4AE10000,
0x48055000,
0x48057000,
0x48059000,
0x4805B000,
0x4805D000,
0x48051000,
0x48053000,
#else // IS_AM572x
0x44E07000,
0x4804C000,
0x481AC000,
0x481AE000,
#endif // IS_AM572x
};
return GPIO_ADDRESSES.at(bank - kGpioBankIndexed);
}
Loading