Definition in file dsp_debug_read.c.
#include "dsp_debug.h"
#include "dsp_debug_shared.h"
Go to the source code of this file.
Functions | |
static int | dsp_debug_parse_int (char *str) |
void | dsp_debug_read (char *str, int size, char end_char) |
This function is used to get a string. | |
int | dsp_debug_read_q (int a, int b) |
This function is used to get a Q formatted number. | |
int | dsp_debug_read_ui () |
This function is used to get an unsigned integer. |
static int dsp_debug_parse_int | ( | char * | str | ) | [static] |
Definition at line 48 of file dsp_debug_read.c.
Referenced by dsp_debug_read_q(), and dsp_debug_read_ui().
00049 { 00050 int i = -1, sign = 1; 00051 char c; 00052 00053 if (*str == '-') 00054 { 00055 sign = -1; 00056 str++; 00057 } 00058 00059 while(*str) 00060 { 00061 c = *str++; 00062 if (c < '0' || c > '9') 00063 break; 00064 if (i == -1) 00065 i = 0; 00066 i *= 10; 00067 i += c - '0'; 00068 } 00069 00070 return i*sign; 00071 }
void dsp_debug_read | ( | char * | str, | |
int | size, | |||
char | end_char | |||
) |
This function is used to get a string.
This function is used to get a string through the peripheral used by the debugging module.
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 get a Q formatted number.
This function is used to read a Q formatted number.
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.
This function is used to get an unsigned integer through the peripheral used by the debugging module.
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 }