1
1
#! /bin/bash
2
- set -e
2
+ set -e
3
3
4
4
# ####################################################################
5
5
# SIGMADSP PARAMETER FILE GENERATOR SCRIPT #
60
60
FILE_ERROR=false
61
61
fi
62
62
63
- # DSP parameter file (*_IC_1 _PARAM.h)
63
+ # DSP parameter file (*_IC_1 _PARAM.h)
64
64
DSP_PARAM_FILE=$(find $(dirname "$0 ") -name "*${SIGMA_STUDIO_PROJECT_NAME%% .* } _IC_1 _PARAM.h")
65
65
if [ "$DSP_PARAM_FILE " = "" ]
66
66
then
@@ -97,10 +97,10 @@ BEGIN {
97
97
# Add guards
98
98
printf("#ifndef SIGMADSP_PARAMETERS_H\n")
99
99
printf("#define SIGMADSP_PARAMETERS_H\n\n")
100
-
100
+
101
101
# Include SigmaDSP library
102
102
printf("#include <SigmaDSP.h>\n\n")
103
-
103
+
104
104
# Print header
105
105
printf("/****************************************************************************\n")
106
106
printf("| Filename: SigmaDSP_parameters.h |\n")
@@ -144,16 +144,16 @@ BEGIN {
144
144
printf(" | EEPROM, you can simply run loadProgram() (located at the bottom of this |\n" )
145
145
printf(" | file) where you pass the SigmaDSP object as the only parameter. |\n" )
146
146
printf(" ****************************************************************************/\n\n\n" )
147
-
147
+
148
148
printf(" /* 7-bit i2c addresses */\n" )
149
149
}
150
150
151
151
{
152
152
# Track down the DSP and EEPROM i2c addresses and convert them into 7-bit
153
153
if ($1 ~ " #define" && $2 ~ " DEVICE_ADDR_IC_1" )
154
154
printf(" %s DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n" , $1 , $3 )
155
-
156
- if ($1 ~ " #define" && $2 ~ " DEVICE_ADDR_IC_2" )
155
+
156
+ if ($1 ~ " #define" && $2 ~ " DEVICE_ADDR_IC_2" )
157
157
printf(" %s EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n" , $1 , $3 )
158
158
} ' "$DSP_PROGRAM_FILE" "$EEPROM_PROGRAM_FILE" > "$(dirname "$0")/SigmaDSP_parameters.h"
159
159
@@ -166,48 +166,48 @@ echo -e "\x1B[31m"
166
166
awk '
167
167
{
168
168
sub(" \r" ," " ) # Get rid of all CR characters from the input file
169
-
169
+
170
170
# Print out each module comment
171
- if ($0 ~ " /* Module." )
171
+ if ($0 ~ " /* Module." )
172
172
printf(" \n%s\n" , $0 )
173
173
174
174
# Print every line where column two ends with _COUNT
175
175
if ($2 ~ " ._COUNT$" )
176
176
printf(" %s %s %s\n\n" , $1 , $2 , $3 )
177
177
178
178
# Print every line where column two ends with _ADDR
179
- if ($2 ~ " ._ADDR$" )
179
+ if ($2 ~ " ._ADDR$" )
180
180
printf(" %s\n" , $0 )
181
181
182
182
# Print column 1, 2 and only the number between the parenthesis on the line where column two ends with _VALUES
183
183
if ($2 ~ " ._VALUES$" )
184
184
printf(" %s %s %s\n" , $1 , $2 , substr($3 , match($3 , /\( /) + 1, match($3 , /\) /) - (match($3 , /\( /)) - 1))
185
185
186
186
# Print every line where column two ends with _FIXPT
187
- if ($2 ~ " ._FIXPT$" )
187
+ if ($2 ~ " ._FIXPT$" )
188
188
printf(" %s\n\n" , $0 )
189
189
} ' "$DSP_PARAM_FILE" >> "$(dirname "$0")/SigmaDSP_parameters.h"
190
190
191
191
192
192
193
193
# Skip EEPROM array if file is not present
194
194
if [ "$EEPROM_HEXFILE" != "" ]
195
- then
195
+ then
196
196
# Generate C style array out from passed hex file
197
197
echo -e "\x1B[0mExtract and format EEPROM array from"
198
198
echo -e "\x1B[1m$EEPROM_HEXFILE"
199
199
echo -e "\x1B[31m"
200
200
awk '
201
201
BEGIN {
202
202
FS=" * , *"
203
- RS=" ^$"
203
+ RS=" ^$"
204
204
printf(" \n\n/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n" )
205
205
}
206
-
206
+
207
207
{
208
- printf(" #define EEPROM_SIZE " NF-1 " \n\n" )
209
- printf(" const uint8_t PROGMEM DSP_eeprom_firmware[EEPROM_SIZE ] =\n{\n" )
210
- for(i = 1; i < NF; i++)
208
+ printf(" #define EE_SIZE " NF-1 " \n\n" )
209
+ printf(" const uint8_t PROGMEM DSP_eeprom_firmware[EE_SIZE ] =\n{\n" )
210
+ for(i = 1; i < NF; i++)
211
211
{
212
212
sub(" \r" ," " ) # Get rid of all CR characters from the input file
213
213
printf(" %s" , $i " , " )
@@ -233,75 +233,75 @@ BEGIN {
233
233
234
234
{
235
235
sub(" \r" ," \n" ) # Get rid of all CR characters from the input file
236
-
236
+
237
237
if (NR > = 28) # Start from line 28
238
238
{
239
239
# Print out relevant comments
240
240
if ($0 ~ " /* DSP." || $0 ~ " /* Register." )
241
- printf(" \n%s\n" , $0 )
242
-
241
+ printf(" \n%s\n" , $0 )
242
+
243
243
if ($2 == " PROGRAM_SIZE_IC_1" )
244
244
printf(" #define PROGRAM_SIZE %s\n" , $3 )
245
-
245
+
246
246
if ($2 == " PROGRAM_ADDR_IC_1" )
247
247
{
248
248
printf(" #define PROGRAM_ADDR %s\n" , $3 )
249
249
printf(" #define PROGRAM_REGSIZE 5\n\n" )
250
250
}
251
-
251
+
252
252
if ($1 == " ADI_REG_TYPE" && $2 ~ " Program_Data." )
253
- printf(" const uint8_t PROGMEM DSP_program_data[PROGRAM_SIZE] = \n{\n" )
254
-
253
+ printf(" const uint8_t PROGMEM DSP_program_data[PROGRAM_SIZE] = \n{\n" )
254
+
255
255
if ($2 == " PARAM_SIZE_IC_1" )
256
256
printf(" #define PARAMETER_SIZE %s\n" , $3 )
257
-
257
+
258
258
if ($2 == " PARAM_ADDR_IC_1" )
259
259
{
260
260
printf(" #define PARAMETER_ADDR %s\n" , $3 )
261
261
printf(" #define PARAMETER_REGSIZE 4\n\n" )
262
262
}
263
-
263
+
264
264
if ($1 == " ADI_REG_TYPE" && $2 ~ " Param_Data." )
265
265
printf(" const uint8_t PROGMEM DSP_parameter_data[PARAMETER_SIZE] = \n{\n" )
266
-
266
+
267
267
if ($1 == " ADI_REG_TYPE" && $2 ~ " R0_COREREGISTER." )
268
268
{
269
269
printf(" #define CORE_REGISTER_R0_SIZE 2\n" )
270
270
printf(" #define CORE_REGISTER_R0_ADDR 0x081C\n" )
271
271
printf(" #define CORE_REGISTER_R0_REGSIZE 2\n\n" )
272
272
printf(" const uint8_t PROGMEM DSP_core_register_R0_data[CORE_REGISTER_R0_SIZE] = \n{\n" )
273
273
}
274
-
274
+
275
275
if ($2 == " R3_HWCONFIGURATION_IC_1_SIZE" )
276
276
{
277
277
printf(" #define HARDWARE_CONF_SIZE %s\n" , $3 )
278
278
printf(" #define HARDWARE_CONF_ADDR 0x081C\n" )
279
279
printf(" #define HARDWARE_CONF_REGSIZE 1\n\n" )
280
280
}
281
-
281
+
282
282
if ($1 == " ADI_REG_TYPE" && $2 ~ " R3_HWCONFIGURATION." )
283
283
printf(" const uint8_t PROGMEM DSP_hardware_conf_data[HARDWARE_CONF_SIZE] = \n{\n" )
284
-
284
+
285
285
if ($1 == " ADI_REG_TYPE" && $2 ~ " R4_COREREGISTER." )
286
286
{
287
287
printf(" #define CORE_REGISTER_R4_SIZE 2\n" )
288
288
printf(" #define CORE_REGISTER_R4_ADDR 0x081C\n" )
289
289
printf(" #define CORE_REGISTER_R4_REGSIZE 2\n\n" )
290
290
printf(" const uint8_t PROGMEM DSP_core_register_R4_data[CORE_REGISTER_R4_SIZE] = \n{\n" )
291
291
}
292
-
292
+
293
293
# Print out all lines that thats with 0x
294
294
if ($1 ~ " 0x." )
295
295
printf($0 )
296
-
296
+
297
297
# Print out all end brackets
298
298
if ($1 ~ " }." )
299
299
printf(" %s\n\n" , $0 )
300
-
301
- # Escape
300
+
301
+ # Escape
302
302
if ($1 == " *" )
303
303
{exit}
304
- }
304
+ }
305
305
}
306
306
307
307
END {
0 commit comments