Skip to content

Commit a991f52

Browse files
committed
Update generator shell script
1 parent ff158d5 commit a991f52

File tree

10 files changed

+159
-210
lines changed

10 files changed

+159
-210
lines changed

DSP_parameter_generator.sh

+17-23
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,10 @@ BEGIN {
151151
{
152152
# Track down the DSP and EEPROM i2c addresses and convert them into 7-bit
153153
if ($1 ~ "#define" && $2 ~ "DEVICE_ADDR_IC_1")
154-
printf($1 " DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $3)
154+
printf("%s DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $1, $3)
155155

156156
if ($1 ~ "#define" && $2 ~ "DEVICE_ADDR_IC_2")
157-
printf($1 " EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $3)
158-
}
159-
160-
END {
161-
printf("\n// Define readout macro as empty\n")
162-
printf("#define SIGMASTUDIOTYPE_SPECIAL(x) (x)\n\n")
157+
printf("%s EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $1, $3)
163158
} ' "$DSP_PROGRAM_FILE" "$EEPROM_PROGRAM_FILE" > "$(dirname "$0")/SigmaDSP_parameters.h"
164159
165160
@@ -174,23 +169,23 @@ awk '
174169

175170
# Print out each module comment
176171
if ($0 ~ "/* Module.")
177-
printf("\n" $0 "\n")
172+
printf("\n%s\n", $0)
178173

179174
# Print every line where column two ends with _COUNT
180175
if ($2 ~ "._COUNT$")
181-
printf($0 "\n\n")
176+
printf("%s %s %s\n\n", $1, $2, $3)
182177

183178
# Print every line where column two ends with _ADDR
184179
if ($2 ~ "._ADDR$")
185-
printf($0 "\n")
180+
printf("%s\n", $0)
186181

187-
# Print every line where column two ends with _VALUES
188-
if ($2 ~ "._VALUES$")
189-
printf($0 "\n")
182+
# Print column 1, 2 and only the number between the parenthesis on the line where column two ends with _VALUES
183+
if ($2 ~ "._VALUES$")
184+
printf("%s %s %s\n", $1, $2, substr($3, match($3, /\(/) + 1, match($3, /\)/) - (match($3, /\(/)) - 1))
190185

191186
# Print every line where column two ends with _FIXPT
192187
if ($2 ~ "._FIXPT$")
193-
printf($0 "\n\n")
188+
printf("%s\n\n", $0)
194189
} ' "$DSP_PARAM_FILE" >> "$(dirname "$0")/SigmaDSP_parameters.h"
195190
196191
@@ -206,8 +201,7 @@ then
206201
BEGIN {
207202
FS=" * , *"
208203
RS="^$"
209-
printf("\n\n")
210-
printf("/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n")
204+
printf("\n\n/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n")
211205
}
212206

213207
{
@@ -244,26 +238,26 @@ BEGIN {
244238
{
245239
# Print out relevant comments
246240
if ($0 ~ "/* DSP." || $0 ~"/* Register.")
247-
printf("\n" $0 "\n")
241+
printf("\n%s\n", $0)
248242

249243
if ($2 == "PROGRAM_SIZE_IC_1")
250-
printf("#define PROGRAM_SIZE " $3 "\n")
244+
printf("#define PROGRAM_SIZE %s\n", $3)
251245

252246
if ($2 == "PROGRAM_ADDR_IC_1")
253247
{
254-
printf("#define PROGRAM_ADDR " $3 "\n")
248+
printf("#define PROGRAM_ADDR %s\n", $3)
255249
printf("#define PROGRAM_REGSIZE 5\n\n")
256250
}
257251

258252
if ($1 == "ADI_REG_TYPE" && $2 ~ "Program_Data.")
259253
printf("const uint8_t PROGMEM DSP_program_data[PROGRAM_SIZE] = \n{\n")
260254

261255
if ($2 == "PARAM_SIZE_IC_1")
262-
printf("#define PARAMETER_SIZE " $3 "\n")
256+
printf("#define PARAMETER_SIZE %s\n", $3)
263257

264258
if ($2 == "PARAM_ADDR_IC_1")
265259
{
266-
printf("#define PARAMETER_ADDR " $3 "\n")
260+
printf("#define PARAMETER_ADDR %s\n", $3)
267261
printf("#define PARAMETER_REGSIZE 4\n\n")
268262
}
269263

@@ -280,7 +274,7 @@ BEGIN {
280274

281275
if ($2 == "R3_HWCONFIGURATION_IC_1_SIZE")
282276
{
283-
printf("#define HARDWARE_CONF_SIZE " $3 "\n")
277+
printf("#define HARDWARE_CONF_SIZE %s\n", $3)
284278
printf("#define HARDWARE_CONF_ADDR 0x081C\n")
285279
printf("#define HARDWARE_CONF_REGSIZE 1\n\n")
286280
}
@@ -302,7 +296,7 @@ BEGIN {
302296

303297
# Print out all end brackets
304298
if ($1 ~ "}.")
305-
printf($0 "\n\n")
299+
printf("%s\n\n", $0)
306300

307301
# Escape
308302
if ($1 == "*")

examples/1_Volume/DSP_parameter_generator.sh

+17-23
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,10 @@ BEGIN {
151151
{
152152
# Track down the DSP and EEPROM i2c addresses and convert them into 7-bit
153153
if ($1 ~ "#define" && $2 ~ "DEVICE_ADDR_IC_1")
154-
printf($1 " DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $3)
154+
printf("%s DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $1, $3)
155155

156156
if ($1 ~ "#define" && $2 ~ "DEVICE_ADDR_IC_2")
157-
printf($1 " EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $3)
158-
}
159-
160-
END {
161-
printf("\n// Define readout macro as empty\n")
162-
printf("#define SIGMASTUDIOTYPE_SPECIAL(x) (x)\n\n")
157+
printf("%s EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $1, $3)
163158
} ' "$DSP_PROGRAM_FILE" "$EEPROM_PROGRAM_FILE" > "$(dirname "$0")/SigmaDSP_parameters.h"
164159
165160
@@ -174,23 +169,23 @@ awk '
174169

175170
# Print out each module comment
176171
if ($0 ~ "/* Module.")
177-
printf("\n" $0 "\n")
172+
printf("\n%s\n", $0)
178173

179174
# Print every line where column two ends with _COUNT
180175
if ($2 ~ "._COUNT$")
181-
printf($0 "\n\n")
176+
printf("%s %s %s\n\n", $1, $2, $3)
182177

183178
# Print every line where column two ends with _ADDR
184179
if ($2 ~ "._ADDR$")
185-
printf($0 "\n")
180+
printf("%s\n", $0)
186181

187-
# Print every line where column two ends with _VALUES
188-
if ($2 ~ "._VALUES$")
189-
printf($0 "\n")
182+
# Print column 1, 2 and only the number between the parenthesis on the line where column two ends with _VALUES
183+
if ($2 ~ "._VALUES$")
184+
printf("%s %s %s\n", $1, $2, substr($3, match($3, /\(/) + 1, match($3, /\)/) - (match($3, /\(/)) - 1))
190185

191186
# Print every line where column two ends with _FIXPT
192187
if ($2 ~ "._FIXPT$")
193-
printf($0 "\n\n")
188+
printf("%s\n\n", $0)
194189
} ' "$DSP_PARAM_FILE" >> "$(dirname "$0")/SigmaDSP_parameters.h"
195190
196191
@@ -206,8 +201,7 @@ then
206201
BEGIN {
207202
FS=" * , *"
208203
RS="^$"
209-
printf("\n\n")
210-
printf("/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n")
204+
printf("\n\n/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n")
211205
}
212206

213207
{
@@ -244,26 +238,26 @@ BEGIN {
244238
{
245239
# Print out relevant comments
246240
if ($0 ~ "/* DSP." || $0 ~"/* Register.")
247-
printf("\n" $0 "\n")
241+
printf("\n%s\n", $0)
248242

249243
if ($2 == "PROGRAM_SIZE_IC_1")
250-
printf("#define PROGRAM_SIZE " $3 "\n")
244+
printf("#define PROGRAM_SIZE %s\n", $3)
251245

252246
if ($2 == "PROGRAM_ADDR_IC_1")
253247
{
254-
printf("#define PROGRAM_ADDR " $3 "\n")
248+
printf("#define PROGRAM_ADDR %s\n", $3)
255249
printf("#define PROGRAM_REGSIZE 5\n\n")
256250
}
257251

258252
if ($1 == "ADI_REG_TYPE" && $2 ~ "Program_Data.")
259253
printf("const uint8_t PROGMEM DSP_program_data[PROGRAM_SIZE] = \n{\n")
260254

261255
if ($2 == "PARAM_SIZE_IC_1")
262-
printf("#define PARAMETER_SIZE " $3 "\n")
256+
printf("#define PARAMETER_SIZE %s\n", $3)
263257

264258
if ($2 == "PARAM_ADDR_IC_1")
265259
{
266-
printf("#define PARAMETER_ADDR " $3 "\n")
260+
printf("#define PARAMETER_ADDR %s\n", $3)
267261
printf("#define PARAMETER_REGSIZE 4\n\n")
268262
}
269263

@@ -280,7 +274,7 @@ BEGIN {
280274

281275
if ($2 == "R3_HWCONFIGURATION_IC_1_SIZE")
282276
{
283-
printf("#define HARDWARE_CONF_SIZE " $3 "\n")
277+
printf("#define HARDWARE_CONF_SIZE %s\n", $3)
284278
printf("#define HARDWARE_CONF_ADDR 0x081C\n")
285279
printf("#define HARDWARE_CONF_REGSIZE 1\n\n")
286280
}
@@ -302,7 +296,7 @@ BEGIN {
302296

303297
# Print out all end brackets
304298
if ($1 ~ "}.")
305-
printf($0 "\n\n")
299+
printf("%s\n\n", $0)
306300

307301
# Escape
308302
if ($1 == "*")

examples/2_First_order_EQ/DSP_parameter_generator.sh

+17-23
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,10 @@ BEGIN {
151151
{
152152
# Track down the DSP and EEPROM i2c addresses and convert them into 7-bit
153153
if ($1 ~ "#define" && $2 ~ "DEVICE_ADDR_IC_1")
154-
printf($1 " DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $3)
154+
printf("%s DSP_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $1, $3)
155155

156156
if ($1 ~ "#define" && $2 ~ "DEVICE_ADDR_IC_2")
157-
printf($1 " EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $3)
158-
}
159-
160-
END {
161-
printf("\n// Define readout macro as empty\n")
162-
printf("#define SIGMASTUDIOTYPE_SPECIAL(x) (x)\n\n")
157+
printf("%s EEPROM_I2C_ADDRESS (%.4s >> 1) & 0xFE\n", $1, $3)
163158
} ' "$DSP_PROGRAM_FILE" "$EEPROM_PROGRAM_FILE" > "$(dirname "$0")/SigmaDSP_parameters.h"
164159
165160
@@ -174,23 +169,23 @@ awk '
174169

175170
# Print out each module comment
176171
if ($0 ~ "/* Module.")
177-
printf("\n" $0 "\n")
172+
printf("\n%s\n", $0)
178173

179174
# Print every line where column two ends with _COUNT
180175
if ($2 ~ "._COUNT$")
181-
printf($0 "\n\n")
176+
printf("%s %s %s\n\n", $1, $2, $3)
182177

183178
# Print every line where column two ends with _ADDR
184179
if ($2 ~ "._ADDR$")
185-
printf($0 "\n")
180+
printf("%s\n", $0)
186181

187-
# Print every line where column two ends with _VALUES
188-
if ($2 ~ "._VALUES$")
189-
printf($0 "\n")
182+
# Print column 1, 2 and only the number between the parenthesis on the line where column two ends with _VALUES
183+
if ($2 ~ "._VALUES$")
184+
printf("%s %s %s\n", $1, $2, substr($3, match($3, /\(/) + 1, match($3, /\)/) - (match($3, /\(/)) - 1))
190185

191186
# Print every line where column two ends with _FIXPT
192187
if ($2 ~ "._FIXPT$")
193-
printf($0 "\n\n")
188+
printf("%s\n\n", $0)
194189
} ' "$DSP_PARAM_FILE" >> "$(dirname "$0")/SigmaDSP_parameters.h"
195190
196191
@@ -206,8 +201,7 @@ then
206201
BEGIN {
207202
FS=" * , *"
208203
RS="^$"
209-
printf("\n\n")
210-
printf("/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n")
204+
printf("\n\n/* This array contains the entire DSP program,\nand should be loaded into the external i2c EEPROM */\n\n")
211205
}
212206

213207
{
@@ -244,26 +238,26 @@ BEGIN {
244238
{
245239
# Print out relevant comments
246240
if ($0 ~ "/* DSP." || $0 ~"/* Register.")
247-
printf("\n" $0 "\n")
241+
printf("\n%s\n", $0)
248242

249243
if ($2 == "PROGRAM_SIZE_IC_1")
250-
printf("#define PROGRAM_SIZE " $3 "\n")
244+
printf("#define PROGRAM_SIZE %s\n", $3)
251245

252246
if ($2 == "PROGRAM_ADDR_IC_1")
253247
{
254-
printf("#define PROGRAM_ADDR " $3 "\n")
248+
printf("#define PROGRAM_ADDR %s\n", $3)
255249
printf("#define PROGRAM_REGSIZE 5\n\n")
256250
}
257251

258252
if ($1 == "ADI_REG_TYPE" && $2 ~ "Program_Data.")
259253
printf("const uint8_t PROGMEM DSP_program_data[PROGRAM_SIZE] = \n{\n")
260254

261255
if ($2 == "PARAM_SIZE_IC_1")
262-
printf("#define PARAMETER_SIZE " $3 "\n")
256+
printf("#define PARAMETER_SIZE %s\n", $3)
263257

264258
if ($2 == "PARAM_ADDR_IC_1")
265259
{
266-
printf("#define PARAMETER_ADDR " $3 "\n")
260+
printf("#define PARAMETER_ADDR %s\n", $3)
267261
printf("#define PARAMETER_REGSIZE 4\n\n")
268262
}
269263

@@ -280,7 +274,7 @@ BEGIN {
280274

281275
if ($2 == "R3_HWCONFIGURATION_IC_1_SIZE")
282276
{
283-
printf("#define HARDWARE_CONF_SIZE " $3 "\n")
277+
printf("#define HARDWARE_CONF_SIZE %s\n", $3)
284278
printf("#define HARDWARE_CONF_ADDR 0x081C\n")
285279
printf("#define HARDWARE_CONF_REGSIZE 1\n\n")
286280
}
@@ -302,7 +296,7 @@ BEGIN {
302296

303297
# Print out all end brackets
304298
if ($1 ~ "}.")
305-
printf($0 "\n\n")
299+
printf("%s\n\n", $0)
306300

307301
# Escape
308302
if ($1 == "*")

0 commit comments

Comments
 (0)