From 9416d720e118e4b5508ad17d64af0c9b69ff3a2f Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Fri, 28 Feb 2020 11:20:34 -0600 Subject: Redo numpad --- Lab3.X/Makefile | 113 +++++ Lab3.X/display.c | 12 +- Lab3.X/display.h | 17 +- Lab3.X/dist/default/production/memoryfile.xml | 18 + Lab3.X/lab3_main_MAYA_C.c | 245 ++++++++++ Lab3.X/lab3_main_c.c | 24 +- Lab3.X/nbproject/Makefile-default.mk | 189 ++++++++ Lab3.X/nbproject/Makefile-genesis.properties | 10 + Lab3.X/nbproject/Makefile-impl.mk | 69 +++ Lab3.X/nbproject/Makefile-local-default.mk | 38 ++ Lab3.X/nbproject/Makefile-variables.mk | 13 + Lab3.X/nbproject/Package-default.bash | 73 +++ Lab3.X/nbproject/configurations.xml | 654 ++++++++++++++++++++++++++ Lab3.X/nbproject/private/configurations.xml | 25 + Lab3.X/nbproject/private/private.xml | 10 +- Lab3.X/nbproject/project.xml | 29 ++ Lab3.X/numpad.c | 150 +++--- Lab3.X/numpad.h | 4 +- 18 files changed, 1566 insertions(+), 127 deletions(-) create mode 100644 Lab3.X/Makefile create mode 100644 Lab3.X/dist/default/production/memoryfile.xml create mode 100644 Lab3.X/lab3_main_MAYA_C.c create mode 100644 Lab3.X/nbproject/Makefile-default.mk create mode 100644 Lab3.X/nbproject/Makefile-genesis.properties create mode 100644 Lab3.X/nbproject/Makefile-impl.mk create mode 100644 Lab3.X/nbproject/Makefile-local-default.mk create mode 100644 Lab3.X/nbproject/Makefile-variables.mk create mode 100644 Lab3.X/nbproject/Package-default.bash create mode 100644 Lab3.X/nbproject/configurations.xml create mode 100644 Lab3.X/nbproject/private/configurations.xml create mode 100644 Lab3.X/nbproject/project.xml diff --git a/Lab3.X/Makefile b/Lab3.X/Makefile new file mode 100644 index 0000000..fca8e2c --- /dev/null +++ b/Lab3.X/Makefile @@ -0,0 +1,113 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin +RANLIB=ranlib + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... +# WARNING: the IDE does not call this target since it takes a long time to +# simply run make. Instead, the IDE removes the configuration directories +# under build and dist directly without calling make. +# This target is left here so people can do a clean when running a clean +# outside the IDE. + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/Lab3.X/display.c b/Lab3.X/display.c index 5ad9c4f..d456b49 100644 --- a/Lab3.X/display.c +++ b/Lab3.X/display.c @@ -2,9 +2,13 @@ #include "display.h" //Functions used for Display -void init7seg(void) { - TRISB = 0b0000000000000011; //and port B to outputs - LATB = 0x0000; //and all of port B to LOW +void init7seg(void) { + CLKDIVbits.RCDIV = 0; //Set RCDIV=1:1 (default 2:1) 32MHz or FCY/2=16M + AD1PCFG = 0x9fff; //sets all pins to digital I/O + TRISA = 0b0000000000011111; //set port A to inputs, + TRISB = 0b0000000000000011; //and port B to outputs + LATA = 0x0000; //Set all of port A to LOW + LATB = 0x0000; //and all of port B to LOW } void showChar7seg(char myChar, enum DIGIT myDigit) { @@ -61,6 +65,6 @@ void showChar7seg(char myChar, enum DIGIT myDigit) { default: LATB ^= (0b11111111 << 2); break; - } //END OF SWITCH + } //END OF SWITCH LATB |= myDigit; } \ No newline at end of file diff --git a/Lab3.X/display.h b/Lab3.X/display.h index fa2dfa1..893eea1 100644 --- a/Lab3.X/display.h +++ b/Lab3.X/display.h @@ -7,14 +7,15 @@ extern "C" { #endif /* __cplusplus */ - // Insert declarations -enum DIGIT { - MSB = (0b1 << 11), - LSB = (0b1 << 10) -}; -void init7seg(void); -void showChar7seg(char myChar, enum DIGIT myDigit); -void delay(long num); + // Insert declarations + + enum DIGIT { + MSB = (0b1 << 11), + LSB = (0b1 << 10) + }; + void init7seg(void); + void showChar7seg(char myChar, enum DIGIT myDigit); + void delay(long num); #ifdef __cplusplus } diff --git a/Lab3.X/dist/default/production/memoryfile.xml b/Lab3.X/dist/default/production/memoryfile.xml new file mode 100644 index 0000000..508df7f --- /dev/null +++ b/Lab3.X/dist/default/production/memoryfile.xml @@ -0,0 +1,18 @@ + + + + + + bytes + 8192 + 0 + 8192 + + + bytes + 65274 + 2034 + 63240 + + + diff --git a/Lab3.X/lab3_main_MAYA_C.c b/Lab3.X/lab3_main_MAYA_C.c new file mode 100644 index 0000000..bd12cf7 --- /dev/null +++ b/Lab3.X/lab3_main_MAYA_C.c @@ -0,0 +1,245 @@ +#include "xc.h" +#include "numpad.h" +#include "display.h" + +// CW1: FLASH CONFIGURATION WORD 1 (see PIC24 Family Reference Manual 24.1) +#pragma config ICS = PGx1 // Comm Channel Select (Emulator EMUC1/EMUD1 pins are shared with PGC1/PGD1) +#pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog Timer is disabled) +#pragma config GWRP = OFF // General Code Segment Write Protect (Writes to program memory are allowed) +#pragma config GCP = OFF // General Code Segment Code Protect (Code protection is disabled) +#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG port is disabled) + + +// CW2: FLASH CONFIGURATION WORD 2 (see PIC24 Family Reference Manual 24.1) +#pragma config I2C1SEL = PRI // I2C1 Pin Location Select (Use default SCL1/SDA1 pins) +#pragma config IOL1WAY = OFF // IOLOCK Protection (IOLOCK may be changed via unlocking seq) +#pragma config OSCIOFNC = ON // Primary Oscillator I/O Function (CLKO/RC15 functions as I/O pin) +#pragma config FCKSM = CSECME // Clock Switching and Monitor (Clock switching is enabled, +// Fail-Safe Clock Monitor is enabled) +#pragma config FNOSC = FRCPLL // Oscillator Select (Fast RC Oscillator with PLL module (FRCPLL)) + +#define NOKEY 255 + +void delay(long d) { + for (d=d; d > 0; d--) { + asm("nop"); + } +} +char cycle(); + + +//============================================================================// + +int main(void) { + init7seg(); + initKeyPad(); + char key = 'N'; + char right, left; + int debounce = 250; + //RB<9:2> will drive the cathodes of the seven-segment display + //RB<11:10> will drive the right and left anodes respectively + //RA<3:0> will drive inputs of keypad + //RB<15:12> will cycle to sense RA inputs + while (1) { + if (debounce == 0) { + key = cycle(); + if (key != 'N') { + left = right; + right = key; + } + debounce = 250; + } + + showChar7seg(right, MSB); + delay(500); + showChar7seg(left, LSB); + delay(200); + + debounce--; +// while (!IFS0bits.T1IF); +// IFS0bits.T1IF = 0; + } +} + +//============================================================================// + + +//void test7seg(void) { +// long int wait = 500000; +// showChar7seg('1', 0); +// delay(wait); +// showChar7seg('1', 1); +// delay(wait); +// showChar7seg('2', 0); +// delay(wait); +// showChar7seg('2', 1); +// delay(wait); +// showChar7seg('3', 0); +// delay(wait); +// showChar7seg('3', 1); +// delay(wait); +// showChar7seg('4', 0); +// delay(wait); +// showChar7seg('4', 1); +// delay(wait); +// showChar7seg('5', 0); +// delay(wait); +// showChar7seg('5', 1); +// delay(wait); +// showChar7seg('6', 0); +// delay(wait); +// showChar7seg('6', 1); +// delay(wait); +// showChar7seg('7', 0); +// delay(wait); +// showChar7seg('7', 1); +// delay(wait); +// showChar7seg('8', 0); +// delay(wait); +// showChar7seg('8', 1); +// delay(wait); +// showChar7seg('9', 0); +// delay(wait); +// showChar7seg('9', 1); +// delay(wait); +// showChar7seg('0', 0); +// delay(wait); +// showChar7seg('0', 1); +// delay(wait); +// showChar7seg('A', 0); +// delay(wait); +// showChar7seg('A', 1); +// delay(wait); +// showChar7seg('b', 0); +// delay(wait); +// showChar7seg('b', 1); +// delay(wait); +// showChar7seg('C', 0); +// delay(wait); +// showChar7seg('C', 1); +// delay(wait); +// showChar7seg('d', 0); +// delay(wait); +// showChar7seg('d', 1); +// delay(wait); +// showChar7seg('E', 0); +// delay(wait); +// showChar7seg('E', 1); +// delay(wait); +// showChar7seg('F', 0); +// delay(wait); +// showChar7seg('F', 1); +// delay(wait); +// return; +//} + +//void showChar7seg(char myChar, int myDigit) { +// //1,2,3,4,5,6,7,8,9,0,A,b,C,d,E, and F +// LATB &= 0xF000; +// if (myDigit == 1) { +// if (myChar == '1') { +// LATB |= 0x067F; +// } else if (myChar == '2') { +// LATB |= 0x0497; +// } else if (myChar == '3') { +// LATB |= 0x0437; +// } else if (myChar == '4') { +// LATB |= 0x0667; +// } else if (myChar == '5') { +// LATB |= 0x0527; +// } else if (myChar == '6') { +// LATB |= 0x0507; +// } else if (myChar == '7') { +// LATB |= 0x047F; +// } else if (myChar == '8') { +// LATB |= 0x0407; +// } else if (myChar == '9') { +// LATB |= 0x0427; +// } else if (myChar == '0') { +// LATB |= 0x040F; +// } else if (myChar == 'A') { +// LATB |= 0x0447; +// } else if (myChar == 'b') { +// LATB |= 0x0707; +// } else if (myChar == 'C') { +// LATB |= 0x058F; +// } else if (myChar == 'd') { +// LATB |= 0x0617; +// } else if (myChar == 'E') { +// LATB |= 0x0587; +// } else if (myChar == 'F') { +// LATB |= 0x05C7; +// } +// } else if (myDigit == 0) { +// if (myChar == '1') { +// LATB |= 0x0A7F; +// } else if (myChar == '2') { +// LATB |= 0x0897; +// } else if (myChar == '3') { +// LATB |= 0x0837; +// } else if (myChar == '4') { +// LATB |= 0x0A67; +// } else if (myChar == '5') { +// LATB |= 0x0927; +// } else if (myChar == '6') { +// LATB |= 0x0907; +// } else if (myChar == '7') { +// LATB |= 0x087F; +// } else if (myChar == '8') { +// LATB |= 0x0807; +// } else if (myChar == '9') { +// LATB |= 0x0827; +// } else if (myChar == '0') { +// LATB |= 0x080F; +// } else if (myChar == 'A') { +// LATB |= 0x0847; +// } else if (myChar == 'b') { +// LATB |= 0x0B07; +// } else if (myChar == 'C') { +// LATB |= 0x098F; +// } else if (myChar == 'd') { +// LATB |= 0x0A17; +// } else if (myChar == 'E') { +// LATB |= 0x0987; +// } else if (myChar == 'F') { +// LATB |= 0x09C7; +// } +// } +// return; +//} + + + +char cycle() { + int i = 0; + char key = 'N'; + while (i < 4) { + if (i == 0) { + LATBbits.LATB12 = 0; + LATBbits.LATB13 = 1; + LATBbits.LATB14 = 1; + LATBbits.LATB15 = 1; + } else if (i == 1) { + LATBbits.LATB12 = 1; + LATBbits.LATB13 = 0; + LATBbits.LATB14 = 1; + LATBbits.LATB15 = 1; + } else if (i == 2) { + LATBbits.LATB12 = 1; + LATBbits.LATB13 = 1; + LATBbits.LATB14 = 0; + LATBbits.LATB15 = 1; + } else if (i == 3) { + LATBbits.LATB12 = 1; + LATBbits.LATB13 = 1; + LATBbits.LATB14 = 1; + LATBbits.LATB15 = 0; + } + key = readKeyPadRAW(); + if (key != 'N') { + return key; + } + i++; + } + return key; +} \ No newline at end of file diff --git a/Lab3.X/lab3_main_c.c b/Lab3.X/lab3_main_c.c index f917f4c..bf99269 100644 --- a/Lab3.X/lab3_main_c.c +++ b/Lab3.X/lab3_main_c.c @@ -14,23 +14,23 @@ #pragma config IOL1WAY = OFF // IOLOCK Protection (IOLOCK may be changed via unlocking seq) #pragma config OSCIOFNC = ON // Primary Oscillator I/O Function (CLKO/RC15 functions as I/O pin) #pragma config FCKSM = CSECME // Clock Switching and Monitor (Clock switching is enabled, - // Fail-Safe Clock Monitor is enabled) +// Fail-Safe Clock Monitor is enabled) #pragma config FNOSC = FRCPLL // Oscillator Select (Fast RC Oscillator with PLL module (FRCPLL)) void delay(long n) { - for (n=n; n>0; n--) { - asm("nop"); - } + for (n = n; n > 0; n--) { + asm("nop"); + } } void setup(void) { - CLKDIVbits.RCDIV = 0; //Set RCDIV=1:1 (default 2:1) 32MHz or FCY/2=16M - AD1PCFG = 0x9fff; //sets all pins to digital I/O -// T1CON = 0; -// PR1 = 15999; -// TMR1 = 0; -// IFS0bits.T1IF = 0; -// T1CONbits.TON = 1; + CLKDIVbits.RCDIV = 0; //Set RCDIV=1:1 (default 2:1) 32MHz or FCY/2=16M + AD1PCFG = 0x9fff; //sets all pins to digital I/O + // T1CON = 0; + // PR1 = 15999; + // TMR1 = 0; + // IFS0bits.T1IF = 0; + // T1CONbits.TON = 1; init7seg(); initKeyPad(); } @@ -49,7 +49,7 @@ int main(void) { right = temp; } showChar7seg(right, MSB); - delay(200); + delay(200); showChar7seg(left, LSB); delay(200); debounce++; diff --git a/Lab3.X/nbproject/Makefile-default.mk b/Lab3.X/nbproject/Makefile-default.mk new file mode 100644 index 0000000..7c32e70 --- /dev/null +++ b/Lab3.X/nbproject/Makefile-default.mk @@ -0,0 +1,189 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Include project Makefile +ifeq "${IGNORE_LOCAL}" "TRUE" +# do not include local makefile. User is passing all local related variables already +else +include Makefile +# Include makefile containing local settings +ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk" +include nbproject/Makefile-local-default.mk +endif +endif + +# Environment +MKDIR=gnumkdir -p +RM=rm -f +MV=mv +CP=cp + +# Macros +CND_CONF=default +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +IMAGE_TYPE=debug +OUTPUT_SUFFIX=elf +DEBUGGABLE_SUFFIX=elf +FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +else +IMAGE_TYPE=production +OUTPUT_SUFFIX=hex +DEBUGGABLE_SUFFIX=elf +FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +endif + +ifeq ($(COMPARE_BUILD), true) +COMPARISON_BUILD=-mafrlcsj +else +COMPARISON_BUILD= +endif + +ifdef SUB_IMAGE_ADDRESS +SUB_IMAGE_ADDRESS_COMMAND=--image-address $(SUB_IMAGE_ADDRESS) +else +SUB_IMAGE_ADDRESS_COMMAND= +endif + +# Object Directory +OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE} + +# Distribution Directory +DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE} + +# Source Files Quoted if spaced +SOURCEFILES_QUOTED_IF_SPACED=display.c numpad.c lab3_main_MAYA_C.c + +# Object Files Quoted if spaced +OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/display.o ${OBJECTDIR}/numpad.o ${OBJECTDIR}/lab3_main_MAYA_C.o +POSSIBLE_DEPFILES=${OBJECTDIR}/display.o.d ${OBJECTDIR}/numpad.o.d ${OBJECTDIR}/lab3_main_MAYA_C.o.d + +# Object Files +OBJECTFILES=${OBJECTDIR}/display.o ${OBJECTDIR}/numpad.o ${OBJECTDIR}/lab3_main_MAYA_C.o + +# Source Files +SOURCEFILES=display.c numpad.c lab3_main_MAYA_C.c + + + +CFLAGS= +ASFLAGS= +LDLIBSOPTIONS= + +############# Tool locations ########################################## +# If you copy a project from one host to another, the path where the # +# compiler is installed may be different. # +# If you open this project with MPLAB X in the new host, this # +# makefile will be regenerated and the paths will be corrected. # +####################################################################### +# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build +FIXDEPS=fixDeps + +.build-conf: ${BUILD_SUBPROJECTS} +ifneq ($(INFORMATION_MESSAGE), ) + @echo $(INFORMATION_MESSAGE) +endif + ${MAKE} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} + +MP_PROCESSOR_OPTION=24FJ64GA002 +MP_LINKER_FILE_OPTION=,--script=p24FJ64GA002.gld +# ------------------------------------------------------------------------------------ +# Rules for buildStep: compile +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +${OBJECTDIR}/display.o: display.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/display.o.d + @${RM} ${OBJECTDIR}/display.o + ${MP_CC} $(MP_EXTRA_CC_PRE) display.c -o ${OBJECTDIR}/display.o -c -mcpu=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/display.o.d" -g -D__DEBUG -D__MPLAB_DEBUGGER_SIMULATOR=1 -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -O0 -msmart-io=1 -Wall -msfr-warn=off -mdfp=${DFP_DIR}/xc16 + @${FIXDEPS} "${OBJECTDIR}/display.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/numpad.o: numpad.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/numpad.o.d + @${RM} ${OBJECTDIR}/numpad.o + ${MP_CC} $(MP_EXTRA_CC_PRE) numpad.c -o ${OBJECTDIR}/numpad.o -c -mcpu=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/numpad.o.d" -g -D__DEBUG -D__MPLAB_DEBUGGER_SIMULATOR=1 -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -O0 -msmart-io=1 -Wall -msfr-warn=off -mdfp=${DFP_DIR}/xc16 + @${FIXDEPS} "${OBJECTDIR}/numpad.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/lab3_main_MAYA_C.o: lab3_main_MAYA_C.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/lab3_main_MAYA_C.o.d + @${RM} ${OBJECTDIR}/lab3_main_MAYA_C.o + ${MP_CC} $(MP_EXTRA_CC_PRE) lab3_main_MAYA_C.c -o ${OBJECTDIR}/lab3_main_MAYA_C.o -c -mcpu=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/lab3_main_MAYA_C.o.d" -g -D__DEBUG -D__MPLAB_DEBUGGER_SIMULATOR=1 -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -O0 -msmart-io=1 -Wall -msfr-warn=off -mdfp=${DFP_DIR}/xc16 + @${FIXDEPS} "${OBJECTDIR}/lab3_main_MAYA_C.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ + +else +${OBJECTDIR}/display.o: display.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/display.o.d + @${RM} ${OBJECTDIR}/display.o + ${MP_CC} $(MP_EXTRA_CC_PRE) display.c -o ${OBJECTDIR}/display.o -c -mcpu=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/display.o.d" -g -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -O0 -msmart-io=1 -Wall -msfr-warn=off -mdfp=${DFP_DIR}/xc16 + @${FIXDEPS} "${OBJECTDIR}/display.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/numpad.o: numpad.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/numpad.o.d + @${RM} ${OBJECTDIR}/numpad.o + ${MP_CC} $(MP_EXTRA_CC_PRE) numpad.c -o ${OBJECTDIR}/numpad.o -c -mcpu=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/numpad.o.d" -g -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -O0 -msmart-io=1 -Wall -msfr-warn=off -mdfp=${DFP_DIR}/xc16 + @${FIXDEPS} "${OBJECTDIR}/numpad.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/lab3_main_MAYA_C.o: lab3_main_MAYA_C.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/lab3_main_MAYA_C.o.d + @${RM} ${OBJECTDIR}/lab3_main_MAYA_C.o + ${MP_CC} $(MP_EXTRA_CC_PRE) lab3_main_MAYA_C.c -o ${OBJECTDIR}/lab3_main_MAYA_C.o -c -mcpu=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/lab3_main_MAYA_C.o.d" -g -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -O0 -msmart-io=1 -Wall -msfr-warn=off -mdfp=${DFP_DIR}/xc16 + @${FIXDEPS} "${OBJECTDIR}/lab3_main_MAYA_C.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ + +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: assemble +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +else +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: assemblePreproc +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +else +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: link +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE} + ${MP_CC} $(MP_EXTRA_LD_PRE) -o dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -mcpu=$(MP_PROCESSOR_OPTION) -D__DEBUG=__DEBUG -D__MPLAB_DEBUGGER_SIMULATOR=1 -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -Wl,,,--defsym=__MPLAB_BUILD=1,--defsym=__MPLAB_DEBUG=1,--defsym=__DEBUG=1,-D__DEBUG=__DEBUG,--defsym=__MPLAB_DEBUGGER_SIMULATOR=1,$(MP_LINKER_FILE_OPTION),--stack=16,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map="${DISTDIR}/${PROJECTNAME}.${IMAGE_TYPE}.map",--report-mem,--memorysummary,dist/${CND_CONF}/${IMAGE_TYPE}/memoryfile.xml$(MP_EXTRA_LD_POST) -mdfp=${DFP_DIR}/xc16 + +else +dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE} + ${MP_CC} $(MP_EXTRA_LD_PRE) -o dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -mcpu=$(MP_PROCESSOR_OPTION) -omf=elf -DXPRJ_default=$(CND_CONF) -legacy-libc $(COMPARISON_BUILD) -Wl,,,--defsym=__MPLAB_BUILD=1,$(MP_LINKER_FILE_OPTION),--stack=16,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map="${DISTDIR}/${PROJECTNAME}.${IMAGE_TYPE}.map",--report-mem,--memorysummary,dist/${CND_CONF}/${IMAGE_TYPE}/memoryfile.xml$(MP_EXTRA_LD_POST) -mdfp=${DFP_DIR}/xc16 + ${MP_CC_DIR}\\xc16-bin2hex dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} -a -omf=elf -mdfp=${DFP_DIR}/xc16 + +endif + + +# Subprojects +.build-subprojects: + + +# Subprojects +.clean-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r build/default + ${RM} -r dist/default + +# Enable dependency checking +.dep.inc: .depcheck-impl + +DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES}) +ifneq (${DEPFILES},) +include ${DEPFILES} +endif diff --git a/Lab3.X/nbproject/Makefile-genesis.properties b/Lab3.X/nbproject/Makefile-genesis.properties new file mode 100644 index 0000000..babf995 --- /dev/null +++ b/Lab3.X/nbproject/Makefile-genesis.properties @@ -0,0 +1,10 @@ +# +#Fri Feb 28 11:09:32 CST 2020 +default.Pack.dfplocation=C\:\\Program Files (x86)\\Microchip\\MPLABX\\v5.30\\packs\\Microchip\\PIC24F-GA-GB_DFP\\1.1.74 +default.com-microchip-mplab-nbide-toolchainXC16-XC16LanguageToolchain.md5=3de759bc6af06f5ee7453ec146192402 +default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc16\\v1.41\\bin +configurations-xml=a484db181b70bf7bdb9ff81073d3f011 +com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=7cd2eead2ea6964989cbf02efe721a76 +default.languagetoolchain.version=1.41 +host.platform=windows +conf.ids=default diff --git a/Lab3.X/nbproject/Makefile-impl.mk b/Lab3.X/nbproject/Makefile-impl.mk new file mode 100644 index 0000000..5ac92a5 --- /dev/null +++ b/Lab3.X/nbproject/Makefile-impl.mk @@ -0,0 +1,69 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a pre- and a post- target defined where you can add customization code. +# +# This makefile implements macros and targets common to all configurations. +# +# NOCDDL + + +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf +# and .clean-reqprojects-conf unless SUB has the value 'no' +SUB_no=NO +SUBPROJECTS=${SUB_${SUB}} +BUILD_SUBPROJECTS_=.build-subprojects +BUILD_SUBPROJECTS_NO= +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} +CLEAN_SUBPROJECTS_=.clean-subprojects +CLEAN_SUBPROJECTS_NO= +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} + + +# Project Name +PROJECTNAME=Lab3.X + +# Active Configuration +DEFAULTCONF=default +CONF=${DEFAULTCONF} + +# All Configurations +ALLCONFS=default + + +# build +.build-impl: .build-pre + ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf + + +# clean +.clean-impl: .clean-pre + ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf + +# clobber +.clobber-impl: .clobber-pre .depcheck-impl + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean + + + +# all +.all-impl: .all-pre .depcheck-impl + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build + + + +# dependency checking support +.depcheck-impl: +# @echo "# This code depends on make tool being used" >.dep.inc +# @if [ -n "${MAKE_VERSION}" ]; then \ +# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ +# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ +# echo "include \$${DEPFILES}" >>.dep.inc; \ +# echo "endif" >>.dep.inc; \ +# else \ +# echo ".KEEP_STATE:" >>.dep.inc; \ +# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ +# fi diff --git a/Lab3.X/nbproject/Makefile-local-default.mk b/Lab3.X/nbproject/Makefile-local-default.mk new file mode 100644 index 0000000..214e7fa --- /dev/null +++ b/Lab3.X/nbproject/Makefile-local-default.mk @@ -0,0 +1,38 @@ +# +# Generated Makefile - do not edit! +# +# +# This file contains information about the location of compilers and other tools. +# If you commmit this file into your revision control server, you will be able to +# to checkout the project and build it from the command line with make. However, +# if more than one person works on the same project, then this file might show +# conflicts since different users are bound to have compilers in different places. +# In that case you might choose to not commit this file and let MPLAB X recreate this file +# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at +# least once so the file gets created and the project can be built. Finally, you can also +# avoid using this file at all if you are only building from the command line with make. +# You can invoke make with the values of the macros: +# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ... +# +SHELL=cmd.exe +PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/v5.30/mplab_platform/platform/../mplab_ide/modules/../../bin/ +# Adding MPLAB X bin directory to path. +PATH:=C:/Program Files (x86)/Microchip/MPLABX/v5.30/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH) +# Path to java used to run MPLAB X when this makefile was created +MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\v5.30\sys\java\jre1.8.0_181/bin/" +OS_CURRENT="$(shell uname -s)" +MP_CC="C:\Program Files (x86)\Microchip\xc16\v1.41\bin\xc16-gcc.exe" +# MP_CPPC is not defined +# MP_BC is not defined +MP_AS="C:\Program Files (x86)\Microchip\xc16\v1.41\bin\xc16-as.exe" +MP_LD="C:\Program Files (x86)\Microchip\xc16\v1.41\bin\xc16-ld.exe" +MP_AR="C:\Program Files (x86)\Microchip\xc16\v1.41\bin\xc16-ar.exe" +DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/v5.30/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar" +MP_CC_DIR="C:\Program Files (x86)\Microchip\xc16\v1.41\bin" +# MP_CPPC_DIR is not defined +# MP_BC_DIR is not defined +MP_AS_DIR="C:\Program Files (x86)\Microchip\xc16\v1.41\bin" +MP_LD_DIR="C:\Program Files (x86)\Microchip\xc16\v1.41\bin" +MP_AR_DIR="C:\Program Files (x86)\Microchip\xc16\v1.41\bin" +# MP_BC_DIR is not defined +DFP_DIR="C:/Program Files (x86)/Microchip/MPLABX/v5.30/packs/Microchip/PIC24F-GA-GB_DFP/1.1.74" diff --git a/Lab3.X/nbproject/Makefile-variables.mk b/Lab3.X/nbproject/Makefile-variables.mk new file mode 100644 index 0000000..6d2747c --- /dev/null +++ b/Lab3.X/nbproject/Makefile-variables.mk @@ -0,0 +1,13 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +CND_BASEDIR=`pwd` +# default configuration +CND_ARTIFACT_DIR_default=dist/default/production +CND_ARTIFACT_NAME_default=Lab3.X.production.hex +CND_ARTIFACT_PATH_default=dist/default/production/Lab3.X.production.hex +CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package +CND_PACKAGE_NAME_default=lab3.x.tar +CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/lab3.x.tar diff --git a/Lab3.X/nbproject/Package-default.bash b/Lab3.X/nbproject/Package-default.bash new file mode 100644 index 0000000..dbb0551 --- /dev/null +++ b/Lab3.X/nbproject/Package-default.bash @@ -0,0 +1,73 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_CONF=default +CND_DISTDIR=dist +TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +OUTPUT_BASENAME=Lab3.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +PACKAGE_TOP_DIR=lab3.x/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/package +rm -rf ${TMPDIR} +mkdir -p ${TMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory ${TMPDIR}/lab3.x/bin +copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/package/lab3.x.tar +cd ${TMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/lab3.x.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${TMPDIR} diff --git a/Lab3.X/nbproject/configurations.xml b/Lab3.X/nbproject/configurations.xml new file mode 100644 index 0000000..fa82250 --- /dev/null +++ b/Lab3.X/nbproject/configurations.xml @@ -0,0 +1,654 @@ + + + + + display.h + numpad.h + + + + + lab3_main_c.c + display.c + numpad.c + lab3_main_MAYA_C.c + + + Makefile + + + + . + + Makefile + + + + localhost + PIC24FJ64GA002 + + + Simulator + XC16 + 1.41 + 3 + + + + + + + + + + + + + false + false + + + + + + + false + + false + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Lab3.X/nbproject/private/configurations.xml b/Lab3.X/nbproject/private/configurations.xml new file mode 100644 index 0000000..74e2a26 --- /dev/null +++ b/Lab3.X/nbproject/private/configurations.xml @@ -0,0 +1,25 @@ + + + Makefile + 0 + + + + C:\Program Files (x86)\Microchip\xc16\v1.41\bin + + place holder 1 + place holder 2 + + + + + true + 0 + 0 + 0 + + + + + + diff --git a/Lab3.X/nbproject/private/private.xml b/Lab3.X/nbproject/private/private.xml index c10361e..d82f0d3 100644 --- a/Lab3.X/nbproject/private/private.xml +++ b/Lab3.X/nbproject/private/private.xml @@ -3,11 +3,11 @@ - file:/C:/Users/Ross/MPLABXProjects/EE2361Projects/Lab3.X/display.h - file:/C:/Users/Ross/MPLABXProjects/EE2361Projects/Lab3.X/numpad.h - file:/C:/Users/Ross/MPLABXProjects/EE2361Projects/Lab3.X/display.c - file:/C:/Users/Ross/MPLABXProjects/EE2361Projects/Lab3.X/numpad.c - file:/C:/Users/Ross/MPLABXProjects/EE2361Projects/Lab3.X/lab3_main_c.c + file:/C:/Users/MSatt/MPLABXProjects/EE2361Projects/Lab3.X/numpad.h + file:/C:/Users/MSatt/MPLABXProjects/EE2361Projects/Lab3.X/lab3_main_c.c + file:/C:/Users/MSatt/MPLABXProjects/EE2361Projects/Lab3.X/display.c + file:/C:/Users/MSatt/MPLABXProjects/EE2361Projects/Lab3.X/numpad.c + file:/C:/Users/MSatt/MPLABXProjects/EE2361Projects/Lab3.X/display.h diff --git a/Lab3.X/nbproject/project.xml b/Lab3.X/nbproject/project.xml new file mode 100644 index 0000000..8f58032 --- /dev/null +++ b/Lab3.X/nbproject/project.xml @@ -0,0 +1,29 @@ + + + com.microchip.mplab.nbide.embedded.makeproject + + + Lab3 + 87ceaaaa-2d11-4659-ab7c-7b12fe00629e + 0 + c + + h + + ISO-8859-1 + + + . + + + + default + 2 + + + + false + + + + diff --git a/Lab3.X/numpad.c b/Lab3.X/numpad.c index 455ef19..5c2c924 100644 --- a/Lab3.X/numpad.c +++ b/Lab3.X/numpad.c @@ -1,106 +1,64 @@ #include "xc.h" + void initKeyPad(void) { - TRISA = 0b0000000000011111; //set port A to inputs, - LATA = 0x0000; //Set all of port A to LOW - CNPU1bits.CN11PUE = 1; - CNPU1bits.CN12PUE = 1; - CNPU1bits.CN13PUE = 1; - CNPU1bits.CN14PUE = 1; + AD1PCFG = 0x9fff; //sets all pins to digital I/O + TRISA = 0b0000000000011111; //set port A to inputs, + TRISB = 0b0000000000000011; //and port B to outputs + LATA = 0xFFFF; //Set all of port A to HIGH + LATB = 0xF000; //Set RB12-15 to high, no touch rest of RB + CNPU1bits.CN2PUE = 1; //RA0 + CNPU1bits.CN3PUE = 1; //RA1 + CNPU2bits.CN30PUE = 1; //RA2 + CNPU2bits.CN29PUE = 1; //RA3 + T1CON = 0; + PR1 = 15999; + TMR1 = 0; + IFS0bits.T1IF = 0; + T1CONbits.TON = 1; } + void padDelay(long n) { - for (n=n; n>0; n--) { - asm("nop"); - } + for (n = n; n > 0; n--) { + asm("nop"); + } } // 1 2 3 4 5 6 7 8 // RA0 RA1 RA2 RA3 RB15 RB14 RB13 RB12 + char readKeyPadRAW(void) { - int i; - char num; -//0 - num = (_RA0 << 3) | (_RA1 << 2) | (_RA2 << 1) | _RA3; - LATB |= (0b1111 << 12); - padDelay(5); - for (i = 0; i < 4; i++) { - LATB ^= 0b1 << (15 - i); - padDelay(10); - switch (i) { - case 0: - switch (num) { - case 0b1110: - return 'A'; - break; - case 0b1101: - return '3'; - break; - case 0b1011: - return '2'; - break; - case 0b0111: - return '1'; - break; - } break; - case 1: - switch (num) { - case 0b1110: - return 'b'; - break; - case 0b1101: - return '6'; - break; - case 0b1011: - return '5'; - break; - case 0b0111: - return '4'; - break; - } break; - case 2: - switch (num) { - case 0b1110: - return 'C'; - break; - case 0b1101: - return '9'; - break; - case 0b1011: - return '8'; - break; - case 0b0111: - return '7'; - break; - } break; - case 3: - switch (num) { - case 0b1110: - return 'd'; - break; - case 0b1101: - return 'E'; - break; - case 0b1011: - return '0'; - break; - case 0b0111: - return 'F'; - break; - } break; - } //END switch(i); - LATB |= (0b1111 << 12); + if ((PORTAbits.RA0 || LATBbits.LATB12) == 0) { + return 'A'; + } else if ((PORTAbits.RA1 || LATBbits.LATB12) == 0) { + return '3'; + } else if ((PORTAbits.RA2 || LATBbits.LATB12) == 0) { + return '2'; + } else if ((PORTAbits.RA3 || LATBbits.LATB12) == 0) { + return '1'; + } else if ((PORTAbits.RA0 || LATBbits.LATB13) == 0) { + return 'b'; + } else if ((PORTAbits.RA1 || LATBbits.LATB13) == 0) { + return '6'; + } else if ((PORTAbits.RA2 || LATBbits.LATB13) == 0) { + return '5'; + } else if ((PORTAbits.RA3 || LATBbits.LATB13) == 0) { + return '4'; + } else if ((PORTAbits.RA0 || LATBbits.LATB14) == 0) { + return 'C'; + } else if ((PORTAbits.RA1 || LATBbits.LATB14) == 0) { + return '9'; + } else if ((PORTAbits.RA2 || LATBbits.LATB14) == 0) { + return '8'; + } else if ((PORTAbits.RA3 || LATBbits.LATB14) == 0) { + return '7'; + } else if ((PORTAbits.RA0 || LATBbits.LATB15) == 0) { + return 'd'; + } else if ((PORTAbits.RA1 || LATBbits.LATB15) == 0) { + return 'F'; + } else if ((PORTAbits.RA2 || LATBbits.LATB15) == 0) { + return '0'; + } else if ((PORTAbits.RA3 || LATBbits.LATB15) == 0) { + return 'E'; + } else { + return 'N'; } - return '\0'; } -/* -Outputs<8:5> = 0b0111; // Set Row 1 output Low -delay(1us); // this delay could be lower, probably 2-3 cycles -RowOne = Inputs<4:1>; // returns 0b1111 (no buttons pressed in row 1) - -Outputs<8:5> = 0b1011; // Set Row 2 output Low -delay(1us); -RowTwo = Inputs<4:1>; // returns 0b1101 (the ?6? key was pressed!) -... -Outputs<8:5> = 0b1110; // Set Row 4 output Low -delay(1us); -RowFour = Inputs<4:1>; // returns 0b1111 (no buttons pressed in row 4) - - */ diff --git a/Lab3.X/numpad.h b/Lab3.X/numpad.h index d94bf42..057ee69 100644 --- a/Lab3.X/numpad.h +++ b/Lab3.X/numpad.h @@ -7,9 +7,9 @@ extern "C" { #endif /* __cplusplus */ - // Insert declarations + // Insert declarations void initKeyPad(void); - unsigned int readKeyPadRAW(void); + char readKeyPadRAW(void); #ifdef __cplusplus } -- cgit v1.2.3