What is DSPPal?


Image showing how applications can be moved across platforms if a common platform absraction API is used

DSPPal is simple API that is designed to assist in the porting of digital signal processing and control algorithms from simulated environments to real time target environments. Targets range from simple microcontrollers to advanced ARM processors. Other platforms such as Linux/Alsa and file based pseudo platform are also supported.
DSPPal also includes a growing set of platform independent library functions encapsulated in a library called DSPLib.
The layered approach to dsppal, dsplib and applications
This library includes functions for filtering, circular buffering, frequency transforms and random number generation. The library is constantly growing.

Where did it come from?


DSPPal was developed in the School of Electrical Engineering Systems in the Dublin Institute of Technology.

Where can I get the code?


A release for the pseudo file based platform that runs on windows is available here
A port to the LPC2148 processor (uses arm-elf-gcc etc on Linux) is here

API definition


The DSPPal header file is listed below:


// The DSPPal header file
// Redefine the base data type to suit your application
typedef int dsp_type;
// start the dsppal system going at the given sampling rate, with so many
// samples per block and with so many channels. Check your platform's capability
int pal_initialize(long SampleRate,long samples_per_block, int num_channels);
// Shutdown the dsppal system, stop interrupts and free buffers
void pal_shutdown(void);
// register a user call back function which will be called when data is available
void pal_registerCallback(void (*cb)(void));
// read a sample or block
int pal_read(dsp_type * Data);
// write a sample or block
int pal_write(dsp_type * Data);
// poll the dsppal system
int pal_poll(void);
// start a time measurement
void pal_tic(void);
// stop a time measurement
void pal_toc(void);

Callbacks



Callbacks provide similar functionality to interrupt service routines. When data is availablel for reading, a callback function may be called, The figure above shows this in action. An interrupt(1) is generated by an Analogue to Digital Converter (or timer perhaps). The interrupt service routine checks to see if a user callback function has been registered and, if so, it is called (2).
Some systems do not allow interrupts to call on user functions for fears of corrupting control data structures should the function be re-entered. To get around this, a dsppal program can call on dsppal_poll which polls the underlying operating system and/or drivers. If data is available, then a registered user callback function is called (from 'user' mode, not 'system' or 'interrupt' modes). A general dsppal compliant function should therefore take the following form:

void MyCallback() {
// do whatever you need to do.
    :
    :
}
int main() {
  pal_registerCallback(MyCallback());
  pal_initialize(SamplingRate,Samples_per_block, num_channels);
  while(1) {
    pal_poll();
  }
  return 0;
}

Sample pass-through application


The following code starts sampling going at 10kHz on a single channel. Each time MyCallback is called, 16 samples are available for reading. These are read and written back out again.

#define SAMP_RATE 10000
#define NUM_SAMPS 16
#define NUM_CHANS 1
void MyCallback() {
  dsp_typs Data[NUM_SAMPS*NUM_CHANS];
  pal_read(Data);
  pal_write(Data);
}
int main() {
  pal_registerCallback(MyCallback());
  pal_initialize(SAMP_RATE,NUM_SAMPS, NUM_CHANS);
  while(1) {
    pal_poll();
  }
  return 0;
}
Note the call to pal_poll in the main while loop. On simple microcontroller systems this function may be implemented simply as a set of instructions that place the processor in a low power state. When an interrupt occurs, the processor wakes up and may call on the callback function. On other systems, the call to pal_poll may poll a sound driver and call the callback function 'MyCallback' if data is available. In either case, the same code is used. Writing code in this style aids portability greatly.

DSPLib


A library of support functions and demo applications is being polished right now. When this is deemed to be good enough it will be relased.
Further information can be obtained from frank dot duignan at dit.ie.

Contacts


If you wish to contribute to, comment on, or support this project in any other way please contact frank dot duignan at dit dot ie