We are using only MCASP1 on the BBAI, so you don't really need MCASP2. Also, the define for MCASP1 on the AM335x is not needed, because we never use that.
The MCSPI and GPIO addresses will also need to change between the two boards. The following Table compares the Hex addresses of these pins.
The freq of McASP CLK is, as seen from the Logic Analyzer measurement below, 20MHz
core/PRU.cpp Code for communicating with the Programmable Realtime Unit (PRU) on the BeagleBone AM335x series processors. The PRU loads and runs a separate code image compiled from an assembly file. Here it is used to handle audio and SPI ADC/DAC data. This code is specific to the PRU code in the assembly file; for example, it uses certain GPIO resources that correspond to that image.
It uses the following libprussdrv functions currently: (ref1: Ti_AM33XX_PRUSSv2, prussdrv.h, prussdrv.c, examples )
prussdrv_map_prumem() // Line 101
: under PruManagerUio::map_pru_mem(unsigned int pru_ram_id, char** address)
prussdrv_init() // Line 443
to initialize the PRU andprussdrv_open() // Line 444
are now called using PruManagerUio::start()
prussdrv_exec_code(int prunum, const unsigned int *code, int codelen) // Line 864
andprussdrv_exec_program() // Line 874
which is to execute any example on PRU0 where first argument is the PRU#
and second is the assembly
to execute. These both are now called using PruManager run
(probably, not fixed yet)prussdrv_pru_disable() // Line 1686
replaced with PruManagerUio::stop()
.prussdrv_exit() // Line 1694
is now called in the destructor of PruManagerUIO.PruManager.h
is the header file (currently under development on branch PRUManager) which includes the following classes: PruManager
: which should expose parameters for the relevant paths.PruManagerRprocMmap : public PruManager
: would use rproc for start/stop and mmap for memory sharingPruManagerUio : public PruManager
: is basically a wrapper for libprussdrv for both start/stop and memory sharing,PruManagerAi : public PruManagerRprocMmap
: probably inherit from class PruManagerRproc
and set the appropriate pathsverbose
flag to hide/show my cout
statements. A similar implementation already exists in I2cCode.cpp. If you are wondering what the commas are, they are just C++ Initialization Lists. The Initializer List is used to initialize data members of a class. For further explanation with an example, kindly refer C++ Initialization Lists.
, i(i)
initializes X::i to the value of the parameter i
PruManager
abstract class interface (i.e.: with all the methods virtual … = 0 )PruManagerUio
class with the libprussdrv calls currently present in the codebasePruManagerRprocMmap
class.include/PruManager.h
file and core/PruManager.cpp
file (I'll need to add the build/core/PruManager.o
object to CORE_CORE_OBJS
for libbela
to work as expected)Here is the rough structure as discussed with mentor: (Please refer the actual repo for latest status)
void* PruManagerRprocMmap::getOwnMemory()
{
return ownMemory.map(addr, 0x2000); // addr is full address of the start of the PRU's RAM
}
void* PruManagerRprocMmap::getSharedMemory()
{
return sharedMemory.map(addr2, 0x3000); // addr2 is the address of the start of PRUSS Shared RAM
}
void* PruManagerUio::getOwnMemory()
{
void* pruDataRam;
int ret = prussdrv_map_prumem (pru_num == 0 ? PRUSS0_PRU0_DATARAM : PRUSS0_PRU1_DATARAM, (void**)&pruDataRam);
if(ret)
return NULL;
else
return pruDataRam;
}
void* PruManagerUio::getSharedMemory()
{
void* pruSharedRam;
int ret = prussdrv_map_prumem (PRUSS0_SHARED_DATARAM, (void **)&pruSharedRam);
if(ret)
return NULL;
else
return pruSharedRam;
}
GPIO.cpp
The general-purpose interface combines four general-purpose input/output (GPIO) modules. Each GPIO module provides 32 dedicated general-purpose pins with input and output capabilities; thus, the general- purpose interface supports up to 128 (4 × 32) pins. These pins can be configured for the following applications: • Data input (capture)/output (drive) • Keyboard interface with a debounce cell • Interrupt generation in active mode upon the detection of external events. Detected events are processed by two parallel independent interrupt-generation submodules to support biprocessor operations. • Wake-up request generation in idle mode upon the detection of external events.
bank = num / 32
bit = num % 32
So, if one is to apply the formula it would be like for eg. GPIO 125
which is Bela button on P9_27
GPIO bank = (int)125/32
= GPIO3 bit = 125%32
= 29
(I could not really find a suitable rproc header file and hence did not use the functions as they have been described in this section as such. Please refer section RPROC Implementation for the actual implementation in Bela ) Before we start discussing the cpp files, let's have a brief overview of the User API of rproc, and we will mainly go through the functions specific to our application. (ref1: rproc, ref2: rpmsg, ref3: linux docs)