dsp_debug.h File Reference


Detailed Description

DSP library debbuging functions.

This file defines a useful set of debugging functions for the DSP library

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file SRCS/dsp_debug.h.

#include "dsp.h"

Go to the source code of this file.

Defines

#define dsp_debug_initialization(x)   dsp_debug_initialization__(__DATE__, __TIME__, x)
 This define permits to print the date and the time of the last compilation of the dsp_debug_initialization__ function.

Typedefs

typedef void(* dsp_debug_print_str_t )(char *)
 This type definition is a pointer on a function that permits to print a string of a device.
It is used to separate the debug module to a printer device module.

Functions

void dsp_debug_print_fct (char *str)
 This function is used to print a string through the peripheral used by the debugging module.
int dsp_debug_sprint_after_radix (char **out, unsigned int num, unsigned int den, int nb_digits)
 This functions permits to copy the digits after the radix of a division's result in the specified buffer.
Q formatted number printing functions
These function permits to print a signed fixed point Q formatted number.



void dsp16_debug_print (dsp16_t n)
 This functions permits to print a dsp16_t typed number.
void dsp32_debug_print (dsp32_t n)
 This functions permits to print a dsp32_t typed number.
void dsp_debug_print (int nb_bits, int q, int n)
 Generic function to print all kind of Q formatted numbers.
int dsp_debug_sprint (char **out, int nb_bits, int q, int i)
 Generic function to print all kind of Q formatted numbers.
Complex number printing functions
These function permits to print a complex signed fixed point Q formatted number.



void dsp16_debug_print_complex (dsp16_complex_t *n)
 This functions permits to print a dsp16_complex_t typed number.
void dsp32_debug_print_complex (dsp32_complex_t *n)
 This functions permits to print a dsp32_complex_t typed number.
void dsp_debug_print_complex (int nb_bits, int q, int real, int imag)
 Generic function to print all kind of complex Q formatted numbers.
Vector printing functions
These function permits to print vectors.
All these functions print a vector the same way.

 1  0.02556
 2  -0.60125
 ...
For a real type vector.
 1  0.02556 + -0.08965i
 2  -0.65064 + 0.i
 ...
For a complex type vector.

void dsp16_debug_print_complex_vect (dsp16_complex_t *vect, int size)
 This functions permits to print a dsp16_complex_t typed vector.
void dsp16_debug_print_vect (dsp16_t *vect, int size)
 This functions permits to print a dsp16_t typed vector.
void dsp32_debug_print_complex_vect (dsp32_complex_t *vect, int size)
 This functions permits to print a dsp32_complex_t typed vector.
void dsp32_debug_print_vect (dsp32_t *vect, int size)
 This functions permits to print a dsp32_t typed vector.
Printf functions
These function permits to print any data on a printing device.
These functions work as the printf function, except that they include the fixed point Q formatted format notion. The following attributes are currently implemented:

  • s : The const char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating null byte ('\0'); if a precision is specified, no more than the number specified are written. If a precision is given, no null byte need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating null byte.
  • d ,i : The int argument is converted to signed decimal notation. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros. The default precision is 1. When 0 is printed with an explicit precision 0, the output is empty.
  • o ,u ,x ,X : The unsigned int argument is converted to unsigned octal (o ), unsigned decimal (u ), or unsigned hexadecimal (x and X ) notation. The letters abcdef are used for x conversions; the letters ABCDEF are used for X conversions. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros. The default precision is 1. When 0 is printed with an explicit precision 0, the output is empty.
  • c : The int argument is converted to an unsigned char, and the resulting character is written.
  • f : The fixed point argument is converted to decimal notation in the style [-]ddd.ddd, [THE FOLLOWING IS NOT IMPLEMENTED YET!] where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it.


int dsp16_debug_printf (const char *format,...)
 This function is the printf version for 16-bit Q formatted signed numbers.
int dsp16_debug_sprintf (char *out, const char *format,...)
 This function is the sprintf version for 16-bit Q formatted signed numbers.
int dsp32_debug_printf (const char *format,...)
 This function is the printf version for 32-bit Q formatted signed numbers.
int dsp32_debug_sprintf (char *out, const char *format,...)
 This function is the sprintf version for 32-bit Q formatted signed numbers.
Peripheral function
These function are used to make an abstraction of the driver used to control the debugging periferal.



void dsp_debug_init (int fosc)
 This function permits to initialize the peripheral that is used to debug. It is automatically called by the dsp_debug_initialization__ function.
char dsp_debug_read_fct ()
 This function is used to get a character through the peripheral used by the debugging module.
void dsp_debug_write_fct (char c)
 This function is used to print a character through the peripheral used by the debugging module.
Initialization function
This function permits to initialize the debugging module.

Parameters:
date A string containing today's date.
time A string containing the current time.
fosc The frequency of the oscillator.
Note:
This function has to be called before using all the other functions.
It is highly recommended to use the define dsp_debug_initialization instead of using directly this function.


void dsp_debug_initialization__ (char *date, char *time, int fosc)
Reading functions
These function are used to recieve data from the user.



void dsp_debug_read (char *str, int size, char end_char)
 This function is used to get a string through the peripheral used by the debugging module.
int dsp_debug_read_q (int a, int b)
 This function is used to read a Q formatted number.
int dsp_debug_read_ui ()
 This function is used to get an unsigned integer through the peripheral used by the debugging module.


Typedef Documentation

typedef void(* dsp_debug_print_str_t)(char *)

This type definition is a pointer on a function that permits to print a string of a device.
It is used to separate the debug module to a printer device module.

Definition at line 106 of file SRCS/dsp_debug.h.


Function Documentation

void dsp_debug_initialization__ ( char *  date,
char *  time,
int  fosc 
)

Definition at line 105 of file dsp_debug_print.c.

References dsp_debug_init().

00106 {
00107   // initialization
00108   dsp_debug_init(fosc);
00109 }

void dsp_debug_read ( char *  str,
int  size,
char  end_char 
)

This function is used to get a string through the peripheral used by the debugging module.

Parameters:
str The output buffer to store the string.
size The size of the buffer.
end_char The ending character.
Precondition:
The dsp_debug_initialization__ function has to be called before using this function.

Definition at line 74 of file dsp_debug_read.c.

References dsp_debug_read_fct().

00075 {
00076   int i = 0;
00077   char c;
00078 
00079   while(i < size-1)
00080   {
00081     c = dsp_debug_read_fct();
00082     if (c == end_char)
00083       break;
00084     str[i++] = c;
00085   }
00086   str[i] = '\0';
00087 }

int dsp_debug_read_q ( int  a,
int  b 
)

This function is used to read a Q formatted number.

Parameters:
a The length in byte of the integer part of the Q formatted number.
b The length in byte of the decimal part of the Q formatted number.
Returns:
The Q formatted number read.
Precondition:
The dsp_debug_initialization__ function has to be called before using this function.

Definition at line 107 of file dsp_debug_read.c.

References dsp_debug_parse_int(), dsp_debug_read_fct(), DSP_Q_MAX, and DSP_Q_MIN.

00108 {
00109   int i = 0;
00110   int zeros = 1;
00111   int q_num;
00112   char c;
00113   int integer = 0, decimal = 0, sign = 1;
00114   int _10log10;
00115   char data[32], *pdata;
00116   S64 temp;
00117 
00118   while(i < sizeof(data))
00119   {
00120     c = dsp_debug_read_fct();
00121     data[i++] = c;
00122     if ((c < '0' || c > '9') && (c != '.' && c != ',' && c != '-'))
00123       break;
00124   }
00125   // Take care of the sign
00126   pdata = data;
00127   if (*pdata == '-')
00128   {
00129     sign = -1;
00130     pdata++;
00131   }
00132 
00133   if ((integer = dsp_debug_parse_int(pdata)) == -1)
00134     integer = 0;
00135 
00136   // If overflow
00137   if (integer >= (1 << (a-1)))
00138   {
00139     if (sign == 1)
00140       return DSP_Q_MAX(a, b);
00141     else
00142       return DSP_Q_MIN(a, b);
00143   }
00144 
00145   // Switch to decimal data
00146   for(i=0; (pdata[i] >= '0' && pdata[i] <= '9') || pdata[i] <= '-'; i++);
00147 
00148   if (pdata[i] == '.' || pdata[i] == ',')
00149   {
00150     // Count the number of zeros before the first plain number
00151     for(; pdata[i+1] == '0'; i++, zeros *= 10);
00152     if ((decimal = dsp_debug_parse_int(&pdata[i+1])) == -1)
00153       decimal = 0;
00154   }
00155 
00156   // decimal/(10^(log10(decimal)+1))
00157   // Calculation of the integer part of log10
00158   _10log10 = 1;
00159   while(_10log10 <= decimal)
00160     _10log10 *= 10;
00161   _10log10 *= zeros;
00162 
00163   temp = decimal;
00164   temp <<= b;
00165   temp /= _10log10;
00166 
00167   q_num = temp + (integer << b);
00168   q_num *= sign;
00169 
00170   return q_num;
00171 }

int dsp_debug_read_ui (  ) 

This function is used to get an unsigned integer through the peripheral used by the debugging module.

Returns:
The number read.
Precondition:
The dsp_debug_initialization__ function has to be called before using this function.

Definition at line 90 of file dsp_debug_read.c.

References dsp_debug_buffer, dsp_debug_parse_int(), and dsp_debug_read_fct().

00091 {
00092   int i = 0;
00093   char c;
00094 
00095   while(1)
00096   {
00097     c = dsp_debug_read_fct();
00098     dsp_debug_buffer[i++] = c;
00099     if (c < '0' || c > '9')
00100       break;
00101   }
00102 
00103   return dsp_debug_parse_int(dsp_debug_buffer);
00104 }


Generated on Fri Feb 19 02:23:18 2010 for AVR32 UC3 - EVK1104 DSPLib Demo Documentation by  doxygen 1.5.5