Changes to I/O access

This commit is contained in:
Wayne Parham
2021-06-09 10:23:42 -05:00
parent 2a25921515
commit 7d6541274d
8 changed files with 219 additions and 583 deletions

View File

@@ -25,9 +25,8 @@ void main (void) {
puts( "\nType a message (40 chars max) and press ENTER, please:\n" );
while( (c != '\r') && (i < 41) ) {
while( (c != '\n') && (i < 40) ) {
c = getchar();
putchar( c );
buffer[i] = c;
i++;
if( i == 40 ) {
@@ -40,7 +39,6 @@ void main (void) {
while( z == 0 ) {
puts( "\n\nHow many times (0 for forever) to repeat?" );
c = getchar();
putchar( c );
if( (c >= '0') && (c <= '9') ) { // between 1 and 9 loops allowed
z = 1; // a number was pressed
t = c - '0'; // convert char to int
@@ -59,14 +57,13 @@ void main (void) {
putchar( '\r' ); // Send CR to console
set_D0( DISP_SPACE ); // Clear the display
set_D1( DISP_SPACE );
set_D2( DISP_SPACE );
set_D3( DISP_SPACE );
set_D4( DISP_SPACE );
set_D5( DISP_SPACE );
set_D6( DISP_SPACE );
DISPLAY.d0 = DISP_SPACE; // Clear the display
DISPLAY.d1 = DISP_SPACE;
DISPLAY.d2 = DISP_SPACE;
DISPLAY.d3 = DISP_SPACE;
DISPLAY.d4 = DISP_SPACE;
DISPLAY.d5 = DISP_SPACE;
DISPLAY.d6 = DISP_SPACE;
for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
@@ -78,247 +75,247 @@ void main (void) {
switch( buffer[l] ) { // Put the typed charaters
case '1': // into the display buffer
set_D6( DISP_1 ); // one at a time
DISPLAY.d6 = DISP_1; // one at a time
break;
case '2':
set_D6( DISP_2 );
DISPLAY.d6 = DISP_2;
break;
case '3':
set_D6( DISP_3 );
DISPLAY.d6 = DISP_3;
break;
case '4':
set_D6( DISP_4 );
DISPLAY.d6 = DISP_4;
break;
case '5':
set_D6( DISP_5 );
DISPLAY.d6 = DISP_5;
break;
case '6':
set_D6( DISP_6 );
DISPLAY.d6 = DISP_6;
break;
case '7':
set_D6( DISP_7 );
DISPLAY.d6 = DISP_7;
break;
case '8':
set_D6( DISP_8 );
DISPLAY.d6 = DISP_8;
break;
case '9':
set_D6( DISP_9 );
DISPLAY.d6 = DISP_9;
break;
case '0':
set_D6( DISP_0 );
DISPLAY.d6 = DISP_0;
break;
case 'A':
set_D6( DISP_A );
DISPLAY.d6 = DISP_A;
break;
case 'a':
set_D6( DISP_A );
DISPLAY.d6 = DISP_A;
break;
case 'B':
set_D6( DISP_b );
DISPLAY.d6 = DISP_b;
break;
case 'b':
set_D6( DISP_b );
DISPLAY.d6 = DISP_b;
break;
case 'C':
set_D6( DISP_C );
DISPLAY.d6 = DISP_C;
break;
case 'c':
set_D6( DISP_c );
DISPLAY.d6 = DISP_c;
break;
case 'D':
set_D6( DISP_d );
DISPLAY.d6 = DISP_d;
break;
case 'd':
set_D6( DISP_d );
DISPLAY.d6 = DISP_d;
break;
case 'E':
set_D6( DISP_E );
DISPLAY.d6 = DISP_E;
break;
case 'e':
set_D6( DISP_e );
DISPLAY.d6 = DISP_e;
break;
case 'F':
set_D6( DISP_F );
DISPLAY.d6 = DISP_F;
break;
case 'f':
set_D6( DISP_F );
DISPLAY.d6 = DISP_F;
break;
case 'G':
set_D6( DISP_G );
DISPLAY.d6 = DISP_G;
break;
case 'g':
set_D6( DISP_g );
DISPLAY.d6 = DISP_g;
break;
case 'H':
set_D6( DISP_H );
DISPLAY.d6 = DISP_H;
break;
case 'h':
set_D6( DISP_h );
DISPLAY.d6 = DISP_h;
break;
case 'I':
set_D6( DISP_I );
DISPLAY.d6 = DISP_I;
break;
case 'i':
set_D6( DISP_i );
DISPLAY.d6 = DISP_i;
break;
case 'J':
set_D6( DISP_J );
DISPLAY.d6 = DISP_J;
break;
case 'j':
set_D6( DISP_J );
DISPLAY.d6 = DISP_J;
break;
case 'K':
set_D6( DISP_K );
DISPLAY.d6 = DISP_K;
break;
case 'k':
set_D6( DISP_K );
DISPLAY.d6 = DISP_K;
break;
case 'L':
set_D6( DISP_L );
DISPLAY.d6 = DISP_L;
break;
case 'l':
set_D6( DISP_L );
DISPLAY.d6 = DISP_L;
break;
case 'M':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_M_1 );
set_D6( DISP_M_2 );
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_M_1;
DISPLAY.d6 = DISP_M_2;
break;
case 'm':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_M_1 );
set_D6( DISP_M_2 );
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_M_1;
DISPLAY.d6 = DISP_M_2;
break;
case 'N':
set_D6( DISP_n );
DISPLAY.d6 = DISP_n;
break;
case 'n':
set_D6( DISP_n );
DISPLAY.d6 = DISP_n;
break;
case 'O':
set_D6( DISP_O );
DISPLAY.d6 = DISP_O;
break;
case 'o':
set_D6( DISP_o );
DISPLAY.d6 = DISP_o;
break;
case 'P':
set_D6( DISP_P );
DISPLAY.d6 = DISP_P;
break;
case 'p':
set_D6( DISP_P );
DISPLAY.d6 = DISP_P;
break;
case 'Q':
set_D6( DISP_q );
DISPLAY.d6 = DISP_q;
break;
case 'q':
set_D6( DISP_q );
DISPLAY.d6 = DISP_q;
break;
case 'R':
set_D6( DISP_r );
DISPLAY.d6 = DISP_r;
break;
case 'r':
set_D6( DISP_r );
DISPLAY.d6 = DISP_r;
break;
case 'S':
set_D6( DISP_S );
DISPLAY.d6 = DISP_S;
break;
case 's':
set_D6( DISP_S );
DISPLAY.d6 = DISP_S;
break;
case 'T':
set_D6( DISP_t );
DISPLAY.d6 = DISP_t;
break;
case 't':
set_D6( DISP_t );
DISPLAY.d6 = DISP_t;
break;
case 'U':
set_D6( DISP_U );
DISPLAY.d6 = DISP_U;
break;
case 'u':
set_D6( DISP_u );
DISPLAY.d6 = DISP_u;
break;
case 'V':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_V_1 );
set_D6( DISP_V_2 );
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_V_1;
DISPLAY.d6 = DISP_V_2;
break;
case 'v':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_V_1 );
set_D6( DISP_V_2 );
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_V_1;
DISPLAY.d6 = DISP_V_2;
break;
case 'W':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_W_1 );
set_D6( DISP_W_2 );
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_W_1;
DISPLAY.d6 = DISP_W_2;
break;
case 'w':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_W_1 );
set_D6( DISP_W_2 );
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_W_1;
DISPLAY.d6 = DISP_W_2;
break;
case 'Y':
set_D6( DISP_Y );
DISPLAY.d6 = DISP_Y;
break;
case 'y':
set_D6( DISP_Y );
DISPLAY.d6 = DISP_Y;
break;
case 'Z':
set_D6( DISP_Z );
DISPLAY.d6 = DISP_Z;
break;
case 'z':
set_D6( DISP_Z );
DISPLAY.d6 = DISP_Z;
break;
case ' ':
set_D6( DISP_SPACE );
DISPLAY.d6 = DISP_SPACE;
break;
case '.':
set_D6( DISP_PERIOD );
DISPLAY.d6 = DISP_PERIOD;
break;
case '-':
set_D6( DISP_HYPHEN );
DISPLAY.d6 = DISP_HYPHEN;
break;
case '\'':
set_D6( DISP_APOSTR );
DISPLAY.d6 = DISP_APOSTR;
break;
case '"':
set_D6( DISP_APOSTR );
DISPLAY.d6 = DISP_APOSTR;
break;
case '=':
set_D6( DISP_EQUAL );
DISPLAY.d6 = DISP_EQUAL;
break;
case '_':
set_D6( DISP_BOTTOM );
DISPLAY.d6 = DISP_BOTTOM;
break;
case '/':
set_D6( DISP_SLASH );
DISPLAY.d6 = DISP_SLASH;
break;
case '\\':
set_D6( DISP_BACKSLASH );
DISPLAY.d6 = DISP_BACKSLASH;
break;
default:
displayable = 0; // Character not mapped
@@ -328,12 +325,12 @@ void main (void) {
putchar( buffer[l] ); // Send it to the console
set_D0( get_D1() ); // Scroll to the left
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( get_D6() );
DISPLAY.d0 = DISPLAY.d1; // Scroll to the left
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISPLAY.d6;
for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
@@ -342,13 +339,13 @@ void main (void) {
}
for( e = 0; e < 6; e++ ) { // Gradually fill the
set_D0( get_D1() ); // display with spaces
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_SPACE );
set_D6( DISP_SPACE );
DISPLAY.d0 = DISPLAY.d1; // display with spaces
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_SPACE;
DISPLAY.d6 = DISP_SPACE;
for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}

View File

@@ -23,9 +23,8 @@ void main(void) {
}
printf( "Type a line and press ENTER, please.\n\n" );
while( c != '\r' ) {
while( c != '\n' ) {
c = getchar();
putchar( c );
}
printf( "\n\nThanks!\n\n" );

View File

@@ -12,24 +12,24 @@
#include <string.h>
void main(void) {
int ddr1a = 0x00;
int ior1a = 0x00;
int ddr1b = 0x00;
int ior1b = 0x00;
int ddr2a = 0x00;
int ior2a = 0x00;
int ddr2b = 0x00;
int ior2b = 0x00;
int ddr3a = 0x00;
int ior3a = 0x00;
int ddr3b = 0x00;
int ior3b = 0x00;
int l = 0x00;
int val = 0x00;
int going = 0x01;
int instr = 0x01;
char* vp = 0x00;
char cmd[20] = { 0x00 };
unsigned char ddr1a = 0x00;
unsigned char ior1a = 0x00;
unsigned char ddr1b = 0x00;
unsigned char ior1b = 0x00;
unsigned char ddr2a = 0x00;
unsigned char ior2a = 0x00;
unsigned char ddr2b = 0x00;
unsigned char ior2b = 0x00;
unsigned char ddr3a = 0x00;
unsigned char ior3a = 0x00;
unsigned char ddr3b = 0x00;
unsigned char ior3b = 0x00;
unsigned char val = 0x00;
int going = 0x01;
int instr = 0x01;
int l = 0x00;
char* vp = 0x00;
char cmd[20] = { 0x00 };
while( going ) {
@@ -38,18 +38,18 @@ void main(void) {
putchar( '\n' );
}
ddr1a = get_DDR1A();
ior1a = get_IOR1A();
ddr1b = get_DDR1B();
ior1b = get_IOR1B();
ddr2a = get_DDR2A();
ior2a = get_IOR2A();
ddr2b = get_DDR2B();
ior2b = get_IOR2B();
ddr3a = get_DDR3A();
ior3a = get_IOR3A();
ddr3b = get_DDR3B();
ior3b = get_IOR3B();
ddr1a = VIA1.ddra;
ior1a = VIA1.pra;
ddr1b = VIA1.ddrb;
ior1b = VIA1.prb;
ddr2a = VIA2.ddra;
ior2a = VIA2.pra;
ddr2b = VIA2.ddrb;
ior2b = VIA2.prb;
ddr3a = VIA3.ddra;
ior3a = VIA3.pra;
ddr3b = VIA3.ddrb;
ior3b = VIA3.prb;
puts( "================== Digital I/O Status ==================" );
puts( " Port1A Port1B Port2A Port2B Port3A Port3B" );
@@ -63,7 +63,7 @@ void main(void) {
puts( "bits off and the bottom three on, type 'IOR2A 07'." );
puts( "Press ENTER without any command to see register values" );
puts( "without changing any of them. Type 'help' to see these" );
puts( "instructions again and type 'stop' to end the program.\n");
puts( "instructions again and type 'quit' to end the program.\n");
puts( "Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A" );
puts( "IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B." );
instr = 0;
@@ -74,7 +74,7 @@ void main(void) {
fgets(cmd, sizeof(cmd)-1, stdin);
cmd[strlen(cmd)-1] = '\0';
if( strncasecmp(cmd, "stop", 4) == 0) {
if( strncasecmp(cmd, "quit", 4) == 0) {
going = 0;
}
else if( strncasecmp(cmd, "help", 4) == 0) {
@@ -83,85 +83,85 @@ void main(void) {
else if( strncasecmp(cmd, "ddr1a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR1A( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.ddra = val;
}
}
else if( strncasecmp(cmd, "ior1a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR1A( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.pra = val;
}
}
else if( strncasecmp(cmd, "ddr1b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR1B( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.ddrb = val;
}
}
else if( strncasecmp(cmd, "ior1b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR1B( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA1.prb = val;
}
}
else if( strncasecmp(cmd, "ddr2a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR2A( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.ddra = val;
}
}
else if( strncasecmp(cmd, "ior2a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR2A( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.pra = val;
}
}
else if( strncasecmp(cmd, "ddr2b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR2B( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.ddrb = val;
}
}
else if( strncasecmp(cmd, "ior2b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR2B( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA2.prb = val;
}
}
else if( strncasecmp(cmd, "ddr3a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR3A( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.ddra = val;
}
}
else if( strncasecmp(cmd, "ior3a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR3A( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.pra = val;
}
}
else if( strncasecmp(cmd, "ddr3b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR3B( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.ddrb = val;
}
}
else if( strncasecmp(cmd, "ior3b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR3B( val );
val = (unsigned char) strtol( vp, NULL, 0 );
VIA3.prb = val;
}
}
}

View File

@@ -26,9 +26,8 @@ void main(void) {
}
}
while( c != '\r' ) {
while( c != '\n' ) {
c = getchar();
putchar( c );
}
puts( "\n\nThanks!\n" );