Skip to content

Commit

Permalink
[config] - create trivial pb_print_config.c, as a better interface to…
Browse files Browse the repository at this point in the history
… pb_parse.php than

having a separately distributed program reading the same header file, pulseblaster.h
  • Loading branch information
Richard Neill committed Sep 17, 2013
1 parent 4cbec9c commit a20a73a
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ pb_utils/src/pb_arm
pb_utils/src/pb_asm
pb_utils/src/pb_cont
pb_utils/src/pb_init
pb_utils/src/pb_print_config
pb_utils/src/pb_prog
pb_utils/src/pb_serial_trigger
pb_utils/src/pb_start
Expand Down
7 changes: 7 additions & 0 deletions pb_utils/Makefile
Expand Up @@ -23,6 +23,7 @@ pbutils:
$(CC) $(CFLAGS) -o src/pb_asm src/pb_asm.c
$(CC) $(CFLAGS) -o src/pb_vliw src/pb_vliw.c
$(CC) $(CFLAGS) -o src/pb_stop-arm src/pb_stop-arm.c
$(CC) $(CFLAGS) -o src/pb_print_config src/pb_print_config.c
$(CC) $(CFLAGS) -o src/pb_serial_trigger src/pb_serial_trigger.c

strip src/pb_start
Expand All @@ -35,6 +36,7 @@ pbutils:
strip src/pb_asm
strip src/pb_vliw
strip src/pb_stop-arm
strip src/pb_print_config
strip src/pb_serial_trigger

@grep -Eq '#define\s*HAVE_PB\s*1' src/pulseblaster.h || echo "Warning: Built with #define HAVE_PB 0."
Expand All @@ -51,6 +53,7 @@ manpages:
ln -sf pb_utils.1.bz2 man/pb_prog.1.bz2
ln -sf pb_utils.1.bz2 man/pb_asm.1.bz2
ln -sf pb_utils.1.bz2 man/pb_vliw.1.bz2
ln -sf pb_utils.1.bz2 man/pb_print_config.1.bz2
ln -sf pb_utils.1.bz2 man/pb_check.1.bz2
bzip2 -kf man/pb_test-pbinit-counter.1
ln -sf pb_test-pbinit-counter.1.bz2 man/pb_test-vliw-walk4.1.bz2
Expand Down Expand Up @@ -83,6 +86,7 @@ clean:
rm -f src/pb_prog
rm -f src/pb_asm
rm -f src/pb_vliw
rm -f src/pb_print_config
rm -f src/pb_serial_trigger
rm -f vliw_examples/good/*.bin*
rm -f vliw_examples/invalid/*.bin*
Expand All @@ -102,6 +106,7 @@ install:
install src/pb_prog $(BINDIR)
install src/pb_asm $(BINDIR)
install src/pb_vliw $(BINDIR)
install src/pb_print_config $(BINDIR)
install src/pb_check.sh $(BINDIR)/pb_check
install src/pb_freq_gen.sh $(BINDIR)/pb_freq_gen
install src/pb_manual.sh $(BINDIR)/pb_manual
Expand Down Expand Up @@ -137,6 +142,7 @@ uninstall:
rm -f $(BINDIR)/pb_prog
rm -f $(BINDIR)/pb_asm
rm -f $(BINDIR)/pb_vliw
rm -f $(BINDIR)/pb_print_config
rm -f $(BINDIR)/pb_check
rm -f $(BINDIR)/pb_serial_trigger
rm -f $(BINDIR)/pb_serial_trigger_check
Expand All @@ -161,6 +167,7 @@ uninstall:
rm -f $(MAN1DIR)/pb_prog.1.bz2
rm -f $(MAN1DIR)/pb_asm.1.bz2
rm -f $(MAN1DIR)/pb_vliw.1.bz2
rm -f $(MAN1DIR)/pb_print_config.1.bz2
rm -f $(MAN1DIR)/pb_check.1.bz2
rm -f $(MAN1DIR)/pb_freq_gen.1.bz2
rm -f $(MAN1DIR)/pb_manual.1.bz2
Expand Down
6 changes: 6 additions & 0 deletions pb_utils/README.txt
Expand Up @@ -57,6 +57,12 @@ src/

pb_check
Check whether the PulseBlaster is physically installed. (checks `lspci`). pb_driver-load may still be needed.

pb_vliw
Print an example VLIW file. (Useful as a template)

pb_print_config
print the configuration (a simple bridge between pulseblaster.h and pb_parse.php)


Helper programs:
Expand Down
5 changes: 5 additions & 0 deletions pb_utils/man/pb_utils.1
Expand Up @@ -61,6 +61,11 @@ Note: this will terminate and overwrite any currently\-loaded program.
.IP
Print a brief summary of the VLIW instructions.

.LP
\fBpb_print_config\fR
.IP
Print configuration of pb_utils; used by pb_parse.

.LP
\fBpb_check\fR
.IP
Expand Down
65 changes: 65 additions & 0 deletions pb_utils/src/pb_print_config.c
@@ -0,0 +1,65 @@
/* This is pb_start.c It starts the pulseblaster. *
* Most of the important, shared stuff is in pb_functions.c */

#include "pb_functions.c"

void printhelp(){
fprintf(stderr,"pb_print_config prints out the configuration settings compiled into pb_utils.\n"
"It's a trivial dump of specific lines from pulseblaster.h, used by pb_parse.\n"
"The format is: \"NAME: Value\\n\".\n"
"Usage: pb_print_config (it takes no arguments).\n");
}

int main(int argc, char *argv[] __attribute__ ((unused)) ){
if (argc > 1){
printhelp();
exit (PB_ERROR_WRONGARGS);
}

/* Print config dump. Format is: NAME colon space value newline. */
printf ("DEBUG: %d\n"
"PB_VERSION: %s\n"
"PB_CLOCK_MHZ: %d\n"
"PB_TICK_NS: %d\n"
"PB_MEMORY: %d\n"
"PB_LOOP_MAXDEPTH: %d\n"
"PB_SUB_MAXDEPTH: %d\n"
"PB_MINIMUM_DELAY: %d\n"
"PB_WAIT_LATENCY: %d\n"
"PB_MINIMUM_WAIT_DELAY: %d\n"
"PB_BUG_PRESTOP_EXTRADELAY: %d\n"
"PB_BUG_WAIT_NOTFIRST: %d\n"
"PB_BUG_WAIT_MINFIRSTDELAY: %d\n"
"PB_OUTPUTS_24BIT: %u\n"
"PB_DELAY_32BIT: %u\n"
"PB_ARG_20BIT: %u\n"
"PB_LOOP_ARG_MIN: %d\n"
"PB_BUG_LOOP_OFFSET: %d\n"
"PB_LONGDELAY_ARG_MIN: %d\n"
"PB_BUG_LONGDELAY_OFFSET: %d\n"
"VLIWLINE_MAXLEN: %d\n"
,
DEBUG,
PB_VERSION,
PB_CLOCK_MHZ,
PB_TICK_NS,
PB_MEMORY,
PB_LOOP_MAXDEPTH,
PB_SUB_MAXDEPTH,
PB_MINIMUM_DELAY,
PB_WAIT_LATENCY,
PB_MINIMUM_WAIT_DELAY,
PB_BUG_PRESTOP_EXTRADELAY,
PB_BUG_WAIT_NOTFIRST,
PB_BUG_WAIT_MINFIRSTDELAY,
PB_OUTPUTS_24BIT,
PB_DELAY_32BIT,
PB_ARG_20BIT,
PB_LOOP_ARG_MIN,
PB_BUG_LOOP_OFFSET,
PB_LONGDELAY_ARG_MIN,
PB_BUG_LONGDELAY_OFFSET,
VLIWLINE_MAXLEN);

return PB_EXIT_OK; /* i.e. zero */
}
24 changes: 10 additions & 14 deletions pb_utils/src/pulseblaster.h
@@ -1,9 +1,6 @@
/* This is pulseblaster.h the definitions by pb_functions.c etc. See also the manual. *
* NOTE: this header is parsed by pb_parse (PHP) as well as by the C-preprocessor. *
* Please don't try anything too clever, such as: *
* #define PB_MINIMUM_WAIT_DELAY (PB_WAIT_LATENCY+PB_MINIMUM_DELAY-PB_INTERNAL_LATENCY) *
* or it will fail. *
* Copright by Richard Neill <pulseblaster at REMOVEME.richardneill.org> 2004-2011. *
* It is used indirectly, via pb_print_config, by pb_parse.php *
* Copright by Richard Neill <pulseblaster at REMOVEME.richardneill.org> 2004-2013. *
* This is Free Software, released under the GNU GPL, version 3 or later: http://gnu.org/ */

/* Important, global definitions */
Expand Down Expand Up @@ -51,7 +48,6 @@
#define PB_MINIMUM_WAIT_DELAY 12 /* PB_MINIMUM_WAIT_DELAY is shortest possible wait instruction. I *think* this is correct. See
* http://www.pulseblaster.com/CD/PulseBlaster/ISA/WAIT_Op_Code_rev1.pdf
* Calculation: PB_MINIMUM_WAIT_DELAY = PB_WAIT_LATENCY+PB_MINIMUM_DELAY-PB_INTERNAL_LATENCY
* NB add these together manually; don't use the preprocessor. See above for why.
*/

#define PB_BUG_PRESTOP_EXTRADELAY 2 /* This is a hardware bug/misfeature: the instruction which precedes a STOP has a minimum length requirement 1 or sometimes 2 ticks
Expand Down Expand Up @@ -90,15 +86,15 @@
#define PB_ARG_20BIT 0xFFFFF /* Argument max size. Hardcoded in VLIW format */
#define PB_BPW_VLIW 10 /* Bytes per word = 10 for VLIW */

#define PB_OPCODE_CONT 0 /* Definition of Opcode CONT = 0 */
#define PB_OPCODE_STOP 1 /* Definition of Opcode STOP = 1 */
#define PB_OPCODE_LOOP 2 /* Definition of Opcode LOOP = 2 */
#define PB_OPCODE_ENDLOOP 3 /* Definition of Opcode ENDLOOP = 3 */
#define PB_OPCODE_CALL 4 /* Definition of Opcode CALL = 4 */
#define PB_OPCODE_RETURN 5 /* Definition of Opcode RETURN = 5 */
#define PB_OPCODE_GOTO 6 /* Definition of Opcode GOTO = 6 */
#define PB_OPCODE_CONT 0 /* Definition of Opcode CONT = 0 */
#define PB_OPCODE_STOP 1 /* Definition of Opcode STOP = 1 */
#define PB_OPCODE_LOOP 2 /* Definition of Opcode LOOP = 2 */
#define PB_OPCODE_ENDLOOP 3 /* Definition of Opcode ENDLOOP = 3 */
#define PB_OPCODE_CALL 4 /* Definition of Opcode CALL = 4 */
#define PB_OPCODE_RETURN 5 /* Definition of Opcode RETURN = 5 */
#define PB_OPCODE_GOTO 6 /* Definition of Opcode GOTO = 6 */
#define PB_OPCODE_LONGDELAY 7 /* Definition of Opcode LONGDELAY = 7 */
#define PB_OPCODE_WAIT 8 /* Definition of Opcode WAIT = 8 */
#define PB_OPCODE_WAIT 8 /* Definition of Opcode WAIT = 8 */

/* Exit codes */
#define PB_EXIT_OK 0 /* Exit with success */
Expand Down

0 comments on commit a20a73a

Please sign in to comment.