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 ... 1 0.02556 + -0.08965i 2 -0.65064 + 0.i ... | |
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:
| |
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. | |
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. | |
#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. | |
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. |
#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.
Definition at line 111 of file SRCS/dsp_debug.h.
#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.
Definition at line 114 of file LIB/INCLUDE/dsp_debug.h.
void dsp16_debug_print | ( | dsp16_t | n | ) | [inline] |
This functions permits to print a dsp16_t typed number.
n | The 16 bits signed fixed point Q formatted number to print. |
Definition at line 112 of file dsp_debug_print.c.
References DSP16_QA, and dsp_debug_print().
Referenced by dsp16_debug_print_vect().
00113 { 00114 dsp_debug_print(16, DSP16_QA, (int) n); 00115 }
void dsp16_debug_print_complex | ( | dsp16_complex_t * | n | ) | [inline] |
This functions permits to print a dsp16_complex_t typed number.
n | The 16 bits signed fixed point Q formatted complex number to print. |
Definition at line 124 of file dsp_debug_print.c.
References DSP16_QA, dsp_debug_print_complex(), dsp16_complex_t::imag, and dsp16_complex_t::real.
Referenced by dsp16_debug_print_complex_vect().
00125 { 00126 dsp_debug_print_complex(16, DSP16_QA, n->real, n->imag); 00127 }
void dsp16_debug_print_complex_vect | ( | dsp16_complex_t * | vect, | |
int | size | |||
) |
This functions permits to print a dsp16_complex_t typed vector.
vect | the vector to print. | |
size | The size of the vector (vect). |
Definition at line 174 of file dsp_debug_print.c.
References dsp16_debug_print_complex(), dsp_debug_print_fct(), and dsp_debug_print_ui().
00175 { 00176 int i; 00177 char *pdsp_debug_buffer; 00178 00179 // Main loop 00180 for(i=0; i<size; i++) 00181 { 00182 // Print the index of the current value of the vector to print 00183 pdsp_debug_buffer = dsp_debug_print_ui(i+1); 00184 dsp_debug_print_fct(pdsp_debug_buffer); 00185 dsp_debug_print_fct("\t"); 00186 // Print the value of the "i"th element of the vector 00187 dsp16_debug_print_complex(&vect[i]); 00188 dsp_debug_print_fct("\n"); 00189 } 00190 }
void dsp16_debug_print_vect | ( | dsp16_t * | vect, | |
int | size | |||
) |
This functions permits to print a dsp16_t typed vector.
vect | the vector to print. | |
size | The size of the vector (vect). |
Definition at line 136 of file dsp_debug_print.c.
References dsp16_debug_print(), dsp_debug_print_fct(), and dsp_debug_print_ui().
00137 { 00138 int i; 00139 char *pdsp_debug_buffer; 00140 00141 // Main loop 00142 for(i=0; i<size; i++) 00143 { 00144 // Print the index of the current value of the vector to print 00145 pdsp_debug_buffer = dsp_debug_print_ui(i+1); 00146 dsp_debug_print_fct(pdsp_debug_buffer); 00147 dsp_debug_print_fct("\t"); 00148 // Print the value of the "i"th element of the vector 00149 dsp16_debug_print(vect[i]); 00150 dsp_debug_print_fct("\n"); 00151 } 00152 }
int dsp16_debug_printf | ( | const char * | format, | |
... | ||||
) |
This function is the printf version for 16-bit Q formatted signed numbers.
format | The number of bits of the complex number to print. |
Definition at line 358 of file dsp_debug_printf.c.
References dsp_debug_buffer, dsp_debug_print_fct(), and print().
00359 { 00360 va_list args; 00361 int n; 00362 char *pdsp_debug_buffer; 00363 00364 // Point on the default buffer 00365 pdsp_debug_buffer = dsp_debug_buffer; 00366 00367 // Compute the printf with specifics arguments 00368 va_start(args, format); 00369 n = print(16, &pdsp_debug_buffer, format, args); 00370 va_end(args); 00371 00372 // Print the result on the default output 00373 dsp_debug_print_fct(dsp_debug_buffer); 00374 00375 return n; 00376 }
int dsp16_debug_sprintf | ( | char * | out, | |
const char * | format, | |||
... | ||||
) |
This function is the sprintf version for 16-bit Q formatted signed numbers.
out | The output buffer where the result will be stored. | |
format | The number of bits of the complex number to print. |
Definition at line 322 of file dsp_debug_printf.c.
References print().
00323 { 00324 va_list args; 00325 int n; 00326 char *pdsp_debug_buffer; 00327 00328 // Point on the default buffer 00329 pdsp_debug_buffer = out; 00330 00331 // Compute the printf with specifics arguments 00332 va_start(args, format); 00333 n = print(16, &pdsp_debug_buffer, format, args); 00334 va_end(args); 00335 00336 return n; 00337 }
void dsp32_debug_print | ( | dsp32_t | n | ) | [inline] |
This functions permits to print a dsp32_t typed number.
n | The 32 bits signed fixed point Q formatted number to print. |
Definition at line 118 of file dsp_debug_print.c.
References DSP32_QA, and dsp_debug_print().
Referenced by dsp32_debug_print_vect().
00119 { 00120 dsp_debug_print(32, DSP32_QA, (int) n); 00121 }
void dsp32_debug_print_complex | ( | dsp32_complex_t * | n | ) | [inline] |
This functions permits to print a dsp32_complex_t typed number.
n | The 32 bits signed fixed point Q formatted complex number to print. |
Definition at line 130 of file dsp_debug_print.c.
References DSP32_QA, dsp_debug_print_complex(), dsp32_complex_t::imag, and dsp32_complex_t::real.
Referenced by dsp32_debug_print_complex_vect().
00131 { 00132 dsp_debug_print_complex(32, DSP32_QA, n->real, n->imag); 00133 }
void dsp32_debug_print_complex_vect | ( | dsp32_complex_t * | vect, | |
int | size | |||
) |
This functions permits to print a dsp32_complex_t typed vector.
vect | the vector to print. | |
size | The size of the vector (vect). |
Definition at line 193 of file dsp_debug_print.c.
References dsp32_debug_print_complex(), dsp_debug_print_fct(), and dsp_debug_print_ui().
00194 { 00195 int i; 00196 char *pdsp_debug_buffer; 00197 00198 // Main loop 00199 for(i=0; i<size; i++) 00200 { 00201 // Print the index of the current value of the vector to print 00202 pdsp_debug_buffer = dsp_debug_print_ui(i+1); 00203 dsp_debug_print_fct(pdsp_debug_buffer); 00204 dsp_debug_print_fct("\t"); 00205 // Print the value of the "i"th element of the vector 00206 dsp32_debug_print_complex(&vect[i]); 00207 dsp_debug_print_fct("\n"); 00208 } 00209 }
void dsp32_debug_print_vect | ( | dsp32_t * | vect, | |
int | size | |||
) |
This functions permits to print a dsp32_t typed vector.
vect | the vector to print. | |
size | The size of the vector (vect). |
Definition at line 155 of file dsp_debug_print.c.
References dsp32_debug_print(), dsp_debug_print_fct(), and dsp_debug_print_ui().
00156 { 00157 int i; 00158 char *pdsp_debug_buffer; 00159 00160 // Main loop 00161 for(i=0; i<size; i++) 00162 { 00163 // Print the index of the current value of the vector to print 00164 pdsp_debug_buffer = dsp_debug_print_ui(i+1); 00165 dsp_debug_print_fct(pdsp_debug_buffer); 00166 dsp_debug_print_fct("\t"); 00167 // Print the value of the "i"th element of the vector 00168 dsp32_debug_print(vect[i]); 00169 dsp_debug_print_fct("\n"); 00170 } 00171 }
int dsp32_debug_printf | ( | const char * | format, | |
... | ||||
) |
This function is the printf version for 32-bit Q formatted signed numbers.
format | The number of bits of the complex number to print. |
Definition at line 379 of file dsp_debug_printf.c.
References dsp_debug_buffer, dsp_debug_print_fct(), and print().
00380 { 00381 va_list args; 00382 int n; 00383 char *pdsp_debug_buffer; 00384 00385 pdsp_debug_buffer = dsp_debug_buffer; 00386 00387 // Compute the printf with specifics arguments 00388 va_start(args, format); 00389 n = print(32, &pdsp_debug_buffer, format, args); 00390 va_end(args); 00391 00392 // Print the result on the default output 00393 dsp_debug_print_fct(dsp_debug_buffer); 00394 00395 return n; 00396 }
int dsp32_debug_sprintf | ( | char * | out, | |
const char * | format, | |||
... | ||||
) |
This function is the sprintf version for 32-bit Q formatted signed numbers.
out | The output buffer where the result will be stored. | |
format | The number of bits of the complex number to print. |
Definition at line 340 of file dsp_debug_printf.c.
References print().
00341 { 00342 va_list args; 00343 int n; 00344 char *pdsp_debug_buffer; 00345 00346 // Point on the default buffer 00347 pdsp_debug_buffer = out; 00348 00349 // Compute the printf with specifics arguments 00350 va_start(args, format); 00351 n = print(32, &pdsp_debug_buffer, format, args); 00352 va_end(args); 00353 00354 return n; 00355 }
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.
fosc | The frequency of the oscillator. |
Definition at line 86 of file EVK1100/USART1/dsp_debug_setup_usart1_at32uc.c.
References dsp_debug_print_fct(), EXAMPLE_USART, EXAMPLE_USART_BAUDRATE, EXAMPLE_USART_BITSPERCHAR, EXAMPLE_USART_PARITY, EXAMPLE_USART_RX_FUNCTION, EXAMPLE_USART_RX_PIN, EXAMPLE_USART_STOPBIT, EXAMPLE_USART_TX_FUNCTION, and EXAMPLE_USART_TX_PIN.
Referenced by dsp_debug_initialization__().
00087 { 00088 static const gpio_map_t USART_GPIO_MAP = 00089 { 00090 {EXAMPLE_USART_RX_PIN, EXAMPLE_USART_RX_FUNCTION}, 00091 {EXAMPLE_USART_TX_PIN, EXAMPLE_USART_TX_FUNCTION} 00092 }; 00093 00094 // Configuration structure for the USART module 00095 static const usart_options_t USART_OPTIONS = 00096 { 00097 // Baudrate 00098 .baudrate = EXAMPLE_USART_BAUDRATE, 00099 // Number of bits per character 00100 .charlength = EXAMPLE_USART_BITSPERCHAR, 00101 // Parity 00102 .paritytype = EXAMPLE_USART_PARITY, 00103 // Stop bit 00104 .stopbits = EXAMPLE_USART_STOPBIT, 00105 // Mode normal 00106 .channelmode = USART_NORMAL_CHMODE 00107 }; 00108 00109 // Assign GPIO to USART. 00110 gpio_enable_module(USART_GPIO_MAP, 00111 sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0])); 00112 00113 // Initialize USART in RS232 mode. 00114 usart_init_rs232(EXAMPLE_USART, &USART_OPTIONS, fosc); 00115 00116 // New window 00117 dsp_debug_print_fct("\x0C\n"); 00118 }
void dsp_debug_print | ( | int | nb_bits, | |
int | q, | |||
int | n | |||
) |
Generic function to print all kind of Q formatted numbers.
nb_bits | The number of bits of the number to print. | |
q | The a parameter of a Qa.b formatted number. | |
n | The signed fixed point Q formatted number to print. |
Definition at line 330 of file dsp_debug_print.c.
References dsp_debug_buffer, dsp_debug_print_fct(), and dsp_debug_sprint().
Referenced by dsp16_debug_print(), dsp32_debug_print(), and dsp_debug_print_complex().
00331 { 00332 char *pdsp_debug_buffer; 00333 00334 // Point on the default buffer 00335 pdsp_debug_buffer = dsp_debug_buffer; 00336 // Print the number in this buffer 00337 dsp_debug_sprint(&pdsp_debug_buffer, nb_bits, q, n); 00338 // Print the buffer on the default output 00339 dsp_debug_print_fct(dsp_debug_buffer); 00340 }
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.
nb_bits | The number of bits of the complex number to print. | |
q | The a parameter of a Qa.b formatted number. | |
real | The real part of the signed fixed point Q formatted complex number to print. | |
imag | The imaginary part of the signed fixed point Q formatted complex number to print. |
Definition at line 257 of file dsp_debug_print.c.
References dsp_debug_print(), and dsp_debug_print_fct().
Referenced by dsp16_debug_print_complex(), and dsp32_debug_print_complex().
00258 { 00259 // Print the real part of the complex number 00260 dsp_debug_print(nb_bits, q, real); 00261 dsp_debug_print_fct(" + "); 00262 // Print the imaginary part of the complex number 00263 dsp_debug_print(nb_bits, q, imag); 00264 dsp_debug_print_fct("i"); 00265 }
void dsp_debug_print_fct | ( | char * | str | ) |
This function is used to print a string through the peripheral used by the debugging module.
str | The string to print. |
Definition at line 56 of file dsp_debug_print.c.
References dsp_debug_write_fct().
Referenced by dsp16_debug_print_complex_vect(), dsp16_debug_print_vect(), dsp16_debug_printf(), dsp32_debug_print_complex_vect(), dsp32_debug_print_vect(), dsp32_debug_printf(), dsp_debug_init(), dsp_debug_print(), and dsp_debug_print_complex().
00057 { 00058 while(*str) 00059 dsp_debug_write_fct(*str++); 00060 }
char dsp_debug_read_fct | ( | ) |
This function is used to get a character through the peripheral used by the debugging module.
Definition at line 80 of file EVK1100/USART1/dsp_debug_setup_usart1_at32uc.c.
References EXAMPLE_USART.
Referenced by dsp_debug_read(), dsp_debug_read_q(), and dsp_debug_read_ui().
00081 { 00082 return usart_getchar(EXAMPLE_USART); 00083 }
int dsp_debug_sprint | ( | char ** | out, | |
int | nb_bits, | |||
int | q, | |||
int | i | |||
) |
Generic function to print all kind of Q formatted numbers.
out | The buffer that recieved the printed number. | |
nb_bits | The number of bits of the number to print. | |
q | The a parameter of a Qa.b formatted number. | |
i | The signed fixed point Q formatted number to print. |
Definition at line 285 of file dsp_debug_print.c.
References dsp_debug_print_ui(), dsp_debug_sprint_after_radix(), and dsp_debug_sprint_fct().
Referenced by dsp_debug_print(), and print().
00286 { 00287 int range; 00288 int n = 0; 00289 char *pdsp_debug_buffer; 00290 // A table which contains the number of digit after the comma to print 00291 int precision[33] = { 0 /* 0 */, 2, 2, 2, 3, 3 /* 5 */, 3, 3, 4, 4, 5 /* 10 */, 5, 5, 5, 6, 6 /* 15 */, 6, 00292 7, 7, 7, 8 /* 20 */, 8, 8, 9, 9, 9 /*25 */, 10, 10, 10, 11, 11 /* 30 */, 11, 12 }; 00293 00294 // if this is a negative number 00295 if (i < 0) 00296 { 00297 // Particulary case 00298 if (i == 0x80000000) 00299 { 00300 i = 0; 00301 range = 1; 00302 } 00303 else 00304 { 00305 // Get its absolute value 00306 i = -i; 00307 // range contains the floor value of the fixed-point number 00308 range = i >> (nb_bits-q); 00309 } 00310 // Print the '-' character to specify that it is a negative number 00311 n += dsp_debug_sprint_fct(out, "-"); 00312 } 00313 else 00314 // range contains the floor value of the fixed-point number 00315 range = i >> (nb_bits-q); 00316 00317 // Print the floor value 00318 pdsp_debug_buffer = dsp_debug_print_ui(range); 00319 n += dsp_debug_sprint_fct(out, pdsp_debug_buffer); 00320 // Print the comma 00321 n += dsp_debug_sprint_fct(out, "."); 00322 // Print the number after the comma 00323 n += dsp_debug_sprint_after_radix(out, i, 1 << (nb_bits-q), precision[nb_bits-q]); 00324 00325 // Retruns the length of the string generated 00326 return n; 00327 }
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.
out | The buffer that recieved the digits after the radix. | |
num | The numerator of the division. | |
den | The denominator of the division. | |
nb_digits | The number of digits to print. |
Definition at line 212 of file dsp_debug_print.c.
References dsp_debug_sprint_fct().
Referenced by dsp_debug_sprint().
00213 { 00214 unsigned int i; 00215 char temp[2]; 00216 int n = 0; 00217 00218 temp[1] = '\0'; 00219 00220 // Go until reaching desired numbers (the one after the comma) 00221 i = num/den; 00222 num -= i*den; 00223 00224 // Then print the numbers after the radix 00225 while(nb_digits-- && num) 00226 { 00227 // This is to minimize the overflows 00228 // If the numerator is not too high, then multiply its value per 10 00229 // Else divide the value of the denominator per 10 which has the same effect 00230 if (num <= 0xFFFFFFFF/10) 00231 num *= 10; 00232 else 00233 den /= 10; 00234 00235 // Get the quotient of the division of num/den 00236 i = num/den; 00237 // Saturate i 00238 if (i > 9) 00239 i = 9; 00240 00241 // Print the number on the default output 00242 temp[0] = (char) i + '0'; 00243 n += dsp_debug_sprint_fct(out, temp); 00244 00245 num -= i*den; 00246 } 00247 00248 // Finish the string 00249 **out = '\0'; 00250 00251 return n; 00252 }
void dsp_debug_write_fct | ( | char | c | ) |
This function is used to print a character through the peripheral used by the debugging module.
c | The character to print. |
Definition at line 74 of file EVK1100/USART1/dsp_debug_setup_usart1_at32uc.c.
References EXAMPLE_USART.
Referenced by dsp_debug_print_fct().
00075 { 00076 usart_putchar(EXAMPLE_USART, c); 00077 }