Skip to content

Commit

Permalink
Changed terminal code to work bidirectional and added it to the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jacgoudsmit committed Nov 10, 2018
1 parent 7ce6d8a commit e74f9f5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 18 deletions.
22 changes: 17 additions & 5 deletions firmware/badge-supercon18.X/nbproject/Makefile-default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}

# Source Files Quoted if spaced
SOURCEFILES_QUOTED_IF_SPACED=src/basic/tokenizer.c src/basic/ubasic.c src/basic/tokenizer_fast.c src/basic/tokenizer_slow.c src/Z80/sim2.c src/Z80/sim4.c src/Z80/sim1.c src/Z80/sim3.c src/Z80/iosim.c src/Z80/sim5.c src/Z80/sim7.c src/Z80/simfun.c src/Z80/hwz.c src/Z80/simglb.c src/Z80/sim6.c src/badge.c src/box_game.c src/disp.c src/hw.c src/images.c src/main.c src/post.c src/snake.c src/splash.c src/tetrapuzz.c src/tune_player.c src/vt100.c src/nyancat.c src/user_program.c src/puzzle.c
SOURCEFILES_QUOTED_IF_SPACED=src/basic/tokenizer.c src/basic/ubasic.c src/basic/tokenizer_fast.c src/basic/tokenizer_slow.c src/Z80/sim2.c src/Z80/sim4.c src/Z80/sim1.c src/Z80/sim3.c src/Z80/iosim.c src/Z80/sim5.c src/Z80/sim7.c src/Z80/simfun.c src/Z80/hwz.c src/Z80/simglb.c src/Z80/sim6.c src/badge.c src/box_game.c src/disp.c src/hw.c src/images.c src/main.c src/post.c src/snake.c src/splash.c src/tetrapuzz.c src/tune_player.c src/vt100.c src/nyancat.c src/user_program.c src/puzzle.c src/user_program_term.c

# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/src/basic/tokenizer.o ${OBJECTDIR}/src/basic/ubasic.o ${OBJECTDIR}/src/basic/tokenizer_fast.o ${OBJECTDIR}/src/basic/tokenizer_slow.o ${OBJECTDIR}/src/Z80/sim2.o ${OBJECTDIR}/src/Z80/sim4.o ${OBJECTDIR}/src/Z80/sim1.o ${OBJECTDIR}/src/Z80/sim3.o ${OBJECTDIR}/src/Z80/iosim.o ${OBJECTDIR}/src/Z80/sim5.o ${OBJECTDIR}/src/Z80/sim7.o ${OBJECTDIR}/src/Z80/simfun.o ${OBJECTDIR}/src/Z80/hwz.o ${OBJECTDIR}/src/Z80/simglb.o ${OBJECTDIR}/src/Z80/sim6.o ${OBJECTDIR}/src/badge.o ${OBJECTDIR}/src/box_game.o ${OBJECTDIR}/src/disp.o ${OBJECTDIR}/src/hw.o ${OBJECTDIR}/src/images.o ${OBJECTDIR}/src/main.o ${OBJECTDIR}/src/post.o ${OBJECTDIR}/src/snake.o ${OBJECTDIR}/src/splash.o ${OBJECTDIR}/src/tetrapuzz.o ${OBJECTDIR}/src/tune_player.o ${OBJECTDIR}/src/vt100.o ${OBJECTDIR}/src/nyancat.o ${OBJECTDIR}/src/user_program.o ${OBJECTDIR}/src/puzzle.o
POSSIBLE_DEPFILES=${OBJECTDIR}/src/basic/tokenizer.o.d ${OBJECTDIR}/src/basic/ubasic.o.d ${OBJECTDIR}/src/basic/tokenizer_fast.o.d ${OBJECTDIR}/src/basic/tokenizer_slow.o.d ${OBJECTDIR}/src/Z80/sim2.o.d ${OBJECTDIR}/src/Z80/sim4.o.d ${OBJECTDIR}/src/Z80/sim1.o.d ${OBJECTDIR}/src/Z80/sim3.o.d ${OBJECTDIR}/src/Z80/iosim.o.d ${OBJECTDIR}/src/Z80/sim5.o.d ${OBJECTDIR}/src/Z80/sim7.o.d ${OBJECTDIR}/src/Z80/simfun.o.d ${OBJECTDIR}/src/Z80/hwz.o.d ${OBJECTDIR}/src/Z80/simglb.o.d ${OBJECTDIR}/src/Z80/sim6.o.d ${OBJECTDIR}/src/badge.o.d ${OBJECTDIR}/src/box_game.o.d ${OBJECTDIR}/src/disp.o.d ${OBJECTDIR}/src/hw.o.d ${OBJECTDIR}/src/images.o.d ${OBJECTDIR}/src/main.o.d ${OBJECTDIR}/src/post.o.d ${OBJECTDIR}/src/snake.o.d ${OBJECTDIR}/src/splash.o.d ${OBJECTDIR}/src/tetrapuzz.o.d ${OBJECTDIR}/src/tune_player.o.d ${OBJECTDIR}/src/vt100.o.d ${OBJECTDIR}/src/nyancat.o.d ${OBJECTDIR}/src/user_program.o.d ${OBJECTDIR}/src/puzzle.o.d
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/src/basic/tokenizer.o ${OBJECTDIR}/src/basic/ubasic.o ${OBJECTDIR}/src/basic/tokenizer_fast.o ${OBJECTDIR}/src/basic/tokenizer_slow.o ${OBJECTDIR}/src/Z80/sim2.o ${OBJECTDIR}/src/Z80/sim4.o ${OBJECTDIR}/src/Z80/sim1.o ${OBJECTDIR}/src/Z80/sim3.o ${OBJECTDIR}/src/Z80/iosim.o ${OBJECTDIR}/src/Z80/sim5.o ${OBJECTDIR}/src/Z80/sim7.o ${OBJECTDIR}/src/Z80/simfun.o ${OBJECTDIR}/src/Z80/hwz.o ${OBJECTDIR}/src/Z80/simglb.o ${OBJECTDIR}/src/Z80/sim6.o ${OBJECTDIR}/src/badge.o ${OBJECTDIR}/src/box_game.o ${OBJECTDIR}/src/disp.o ${OBJECTDIR}/src/hw.o ${OBJECTDIR}/src/images.o ${OBJECTDIR}/src/main.o ${OBJECTDIR}/src/post.o ${OBJECTDIR}/src/snake.o ${OBJECTDIR}/src/splash.o ${OBJECTDIR}/src/tetrapuzz.o ${OBJECTDIR}/src/tune_player.o ${OBJECTDIR}/src/vt100.o ${OBJECTDIR}/src/nyancat.o ${OBJECTDIR}/src/user_program.o ${OBJECTDIR}/src/puzzle.o ${OBJECTDIR}/src/user_program_term.o
POSSIBLE_DEPFILES=${OBJECTDIR}/src/basic/tokenizer.o.d ${OBJECTDIR}/src/basic/ubasic.o.d ${OBJECTDIR}/src/basic/tokenizer_fast.o.d ${OBJECTDIR}/src/basic/tokenizer_slow.o.d ${OBJECTDIR}/src/Z80/sim2.o.d ${OBJECTDIR}/src/Z80/sim4.o.d ${OBJECTDIR}/src/Z80/sim1.o.d ${OBJECTDIR}/src/Z80/sim3.o.d ${OBJECTDIR}/src/Z80/iosim.o.d ${OBJECTDIR}/src/Z80/sim5.o.d ${OBJECTDIR}/src/Z80/sim7.o.d ${OBJECTDIR}/src/Z80/simfun.o.d ${OBJECTDIR}/src/Z80/hwz.o.d ${OBJECTDIR}/src/Z80/simglb.o.d ${OBJECTDIR}/src/Z80/sim6.o.d ${OBJECTDIR}/src/badge.o.d ${OBJECTDIR}/src/box_game.o.d ${OBJECTDIR}/src/disp.o.d ${OBJECTDIR}/src/hw.o.d ${OBJECTDIR}/src/images.o.d ${OBJECTDIR}/src/main.o.d ${OBJECTDIR}/src/post.o.d ${OBJECTDIR}/src/snake.o.d ${OBJECTDIR}/src/splash.o.d ${OBJECTDIR}/src/tetrapuzz.o.d ${OBJECTDIR}/src/tune_player.o.d ${OBJECTDIR}/src/vt100.o.d ${OBJECTDIR}/src/nyancat.o.d ${OBJECTDIR}/src/user_program.o.d ${OBJECTDIR}/src/puzzle.o.d ${OBJECTDIR}/src/user_program_term.o.d

# Object Files
OBJECTFILES=${OBJECTDIR}/src/basic/tokenizer.o ${OBJECTDIR}/src/basic/ubasic.o ${OBJECTDIR}/src/basic/tokenizer_fast.o ${OBJECTDIR}/src/basic/tokenizer_slow.o ${OBJECTDIR}/src/Z80/sim2.o ${OBJECTDIR}/src/Z80/sim4.o ${OBJECTDIR}/src/Z80/sim1.o ${OBJECTDIR}/src/Z80/sim3.o ${OBJECTDIR}/src/Z80/iosim.o ${OBJECTDIR}/src/Z80/sim5.o ${OBJECTDIR}/src/Z80/sim7.o ${OBJECTDIR}/src/Z80/simfun.o ${OBJECTDIR}/src/Z80/hwz.o ${OBJECTDIR}/src/Z80/simglb.o ${OBJECTDIR}/src/Z80/sim6.o ${OBJECTDIR}/src/badge.o ${OBJECTDIR}/src/box_game.o ${OBJECTDIR}/src/disp.o ${OBJECTDIR}/src/hw.o ${OBJECTDIR}/src/images.o ${OBJECTDIR}/src/main.o ${OBJECTDIR}/src/post.o ${OBJECTDIR}/src/snake.o ${OBJECTDIR}/src/splash.o ${OBJECTDIR}/src/tetrapuzz.o ${OBJECTDIR}/src/tune_player.o ${OBJECTDIR}/src/vt100.o ${OBJECTDIR}/src/nyancat.o ${OBJECTDIR}/src/user_program.o ${OBJECTDIR}/src/puzzle.o
OBJECTFILES=${OBJECTDIR}/src/basic/tokenizer.o ${OBJECTDIR}/src/basic/ubasic.o ${OBJECTDIR}/src/basic/tokenizer_fast.o ${OBJECTDIR}/src/basic/tokenizer_slow.o ${OBJECTDIR}/src/Z80/sim2.o ${OBJECTDIR}/src/Z80/sim4.o ${OBJECTDIR}/src/Z80/sim1.o ${OBJECTDIR}/src/Z80/sim3.o ${OBJECTDIR}/src/Z80/iosim.o ${OBJECTDIR}/src/Z80/sim5.o ${OBJECTDIR}/src/Z80/sim7.o ${OBJECTDIR}/src/Z80/simfun.o ${OBJECTDIR}/src/Z80/hwz.o ${OBJECTDIR}/src/Z80/simglb.o ${OBJECTDIR}/src/Z80/sim6.o ${OBJECTDIR}/src/badge.o ${OBJECTDIR}/src/box_game.o ${OBJECTDIR}/src/disp.o ${OBJECTDIR}/src/hw.o ${OBJECTDIR}/src/images.o ${OBJECTDIR}/src/main.o ${OBJECTDIR}/src/post.o ${OBJECTDIR}/src/snake.o ${OBJECTDIR}/src/splash.o ${OBJECTDIR}/src/tetrapuzz.o ${OBJECTDIR}/src/tune_player.o ${OBJECTDIR}/src/vt100.o ${OBJECTDIR}/src/nyancat.o ${OBJECTDIR}/src/user_program.o ${OBJECTDIR}/src/puzzle.o ${OBJECTDIR}/src/user_program_term.o

# Source Files
SOURCEFILES=src/basic/tokenizer.c src/basic/ubasic.c src/basic/tokenizer_fast.c src/basic/tokenizer_slow.c src/Z80/sim2.c src/Z80/sim4.c src/Z80/sim1.c src/Z80/sim3.c src/Z80/iosim.c src/Z80/sim5.c src/Z80/sim7.c src/Z80/simfun.c src/Z80/hwz.c src/Z80/simglb.c src/Z80/sim6.c src/badge.c src/box_game.c src/disp.c src/hw.c src/images.c src/main.c src/post.c src/snake.c src/splash.c src/tetrapuzz.c src/tune_player.c src/vt100.c src/nyancat.c src/user_program.c src/puzzle.c
SOURCEFILES=src/basic/tokenizer.c src/basic/ubasic.c src/basic/tokenizer_fast.c src/basic/tokenizer_slow.c src/Z80/sim2.c src/Z80/sim4.c src/Z80/sim1.c src/Z80/sim3.c src/Z80/iosim.c src/Z80/sim5.c src/Z80/sim7.c src/Z80/simfun.c src/Z80/hwz.c src/Z80/simglb.c src/Z80/sim6.c src/badge.c src/box_game.c src/disp.c src/hw.c src/images.c src/main.c src/post.c src/snake.c src/splash.c src/tetrapuzz.c src/tune_player.c src/vt100.c src/nyancat.c src/user_program.c src/puzzle.c src/user_program_term.c


CFLAGS=
Expand Down Expand Up @@ -285,6 +285,12 @@ ${OBJECTDIR}/src/puzzle.o: src/puzzle.c nbproject/Makefile-${CND_CONF}.mk
@${RM} ${OBJECTDIR}/src/puzzle.o.d
@${RM} ${OBJECTDIR}/src/puzzle.o
@${FIXDEPS} "${OBJECTDIR}/src/puzzle.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -O1 -funroll-loops -D_SUPPRESS_PLIB_WARNING -MMD -MF "${OBJECTDIR}/src/puzzle.o.d" -o ${OBJECTDIR}/src/puzzle.o src/puzzle.c -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD)

${OBJECTDIR}/src/user_program_term.o: src/user_program_term.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/src"
@${RM} ${OBJECTDIR}/src/user_program_term.o.d
@${RM} ${OBJECTDIR}/src/user_program_term.o
@${FIXDEPS} "${OBJECTDIR}/src/user_program_term.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -O1 -funroll-loops -D_SUPPRESS_PLIB_WARNING -MMD -MF "${OBJECTDIR}/src/user_program_term.o.d" -o ${OBJECTDIR}/src/user_program_term.o src/user_program_term.c -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD)

else
${OBJECTDIR}/src/basic/tokenizer.o: src/basic/tokenizer.c nbproject/Makefile-${CND_CONF}.mk
Expand Down Expand Up @@ -467,6 +473,12 @@ ${OBJECTDIR}/src/puzzle.o: src/puzzle.c nbproject/Makefile-${CND_CONF}.mk
@${RM} ${OBJECTDIR}/src/puzzle.o
@${FIXDEPS} "${OBJECTDIR}/src/puzzle.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -O1 -funroll-loops -D_SUPPRESS_PLIB_WARNING -MMD -MF "${OBJECTDIR}/src/puzzle.o.d" -o ${OBJECTDIR}/src/puzzle.o src/puzzle.c -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD)

${OBJECTDIR}/src/user_program_term.o: src/user_program_term.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/src"
@${RM} ${OBJECTDIR}/src/user_program_term.o.d
@${RM} ${OBJECTDIR}/src/user_program_term.o
@${FIXDEPS} "${OBJECTDIR}/src/user_program_term.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -O1 -funroll-loops -D_SUPPRESS_PLIB_WARNING -MMD -MF "${OBJECTDIR}/src/user_program_term.o.d" -o ${OBJECTDIR}/src/user_program_term.o src/user_program_term.c -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD)

endif

# ------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions firmware/badge-supercon18.X/nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<itemPath>src/vt100.h</itemPath>
<itemPath>src/puzzle.h</itemPath>
<itemPath>src/nyancat.h</itemPath>
<itemPath>src/user_program_term.h</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
Expand Down Expand Up @@ -71,6 +72,7 @@
<itemPath>src/nyancat.c</itemPath>
<itemPath>src/user_program.c</itemPath>
<itemPath>src/puzzle.c</itemPath>
<itemPath>src/user_program_term.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
Expand Down
11 changes: 9 additions & 2 deletions firmware/badge-supercon18.X/src/badge.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdint.h>
#include "Z80/sim.h"
#include "Z80/simglb.h"

#include "user_program_term.h"


uint16_t basic_loads (int8_t * data, uint16_t maxlen);
Expand Down Expand Up @@ -379,6 +379,11 @@ void badge_menu(void)
while (1) loop_puzzle();
}
else if (strcmp(menu_buff,"7")==0)
{
user_term_init();
for (;;) user_term_loop();
}
else if (strcmp(menu_buff,"8")==0)
{
init_userprog();
while (1) loop_userprog();
Expand Down Expand Up @@ -563,7 +568,9 @@ void showmenu(void)
video_gotoxy(TEXT_LEFT,11);
stdio_write("6 - Puzzle");
video_gotoxy(TEXT_LEFT,12);
stdio_write("7 - User Program");
stdio_write("7 - Serial Terminal");
video_gotoxy(TEXT_LEFT,13);
stdio_write("8 - User Program");

show_version();
clear_prompt();
Expand Down
2 changes: 1 addition & 1 deletion firmware/badge-supercon18.X/src/user_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Take a look at user_program_temp.c (not included in project, but
* available in src directory) to see how to use IIC routines
*
* see user_program_term.c to see simple one way serial terminal
* see user_program_term.c to see a simple serial terminal
************************************/


Expand Down
36 changes: 26 additions & 10 deletions firmware/badge-supercon18.X/src/user_program_term.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
#include "badge_user.h"

//simple one way terminal - characters from serial are directed to stdio
// Simple terminal program:
// Characters from the serial port are printed on the screen, and characters
// from the keyboard are sent to the serial port
//
// NOTE: Just like with a real terminal, characters from the keyboard don't get
// printed on the screen; the host computer (to which you connect the serial
// port) should take care of echoing the characters (or not, e.g. when you're
// typing a password).
//
// NOTE: this is a simple program that basically loops at full speed. It works
// fine but of course it's not very efficient with energy. It would be better
// to put the CPU to sleep and let the UART or the keyboard wake it up. This
// is left as an excercise for the reader :-)

void user_program_init(void)
void user_term_init(void)
{
clr_buffer();
video_gotoxy(0,0);
serial_flush();
}

void user_program_loop(void)
void user_term_loop(void)
{
uint8_t temp;
if (rx_sta())
{
temp = rx_read();
stdio_c(temp);
}
}
if (rx_sta())
{
stdio_c(rx_read());
}

uint8_t c;
if (stdio_get(&c))
{
tx_write(c);
}
}
5 changes: 5 additions & 0 deletions firmware/badge-supercon18.X/src/user_program_term.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/************************************
* Module that can be used as a serial terminal
************************************/
void user_term_init(void);
void user_term_loop(void);

0 comments on commit e74f9f5

Please sign in to comment.