Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rk119 committed Jul 12, 2022
0 parents commit f85535e
Show file tree
Hide file tree
Showing 11 changed files with 3,198 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.gitlab-ci.yml
/Coursework_F28HS_2022.pdf
Binary file added F28HS_CW2_Report.pdf
Binary file not shown.
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# simple Makefile to build and test the MasterMind implementation

prg=master-mind
fnc = masterFunc
lib=lcdBinary
matches=mm-matchesC
tester=testm

CC=gcc
AS=as
OPTS=-W

all: $(prg) cw2 $(tester)

cw2: $(prg)
@if [ ! -L cw2 ] ; then ln -s $(prg) cw2 ; fi

$(prg): $(prg).o $(lib).o $(matches).o
$(CC) -o $@ $^

$(tester): $(tester).o $(fnc).o $(lib).o $(matches).o
$(CC) -o $@ $^

%.o: %.c
$(CC) $(OPTS) -c -o $@ $<



# run the program with debug option to show secret sequence
run:
sudo ./$(prg) -d

# do unit testing on the matching function
unit: cw2
sh ./test.sh

# testing the C vs the Assembler version of the matching fct
test: $(tester)
./$(tester)

clean:
-rm $(prg) $(tester) cw2 *.o

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Mastermind Game
Binary file added fritz_CW2_2020_bb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions lcdBinary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* ***************************************************************************** */
/* You can use this file to define the low-level hardware control fcts for */
/* LED, button and LCD devices. */
/* Note that these need to be implemented in Assembler. */
/* You can use inline Assembler code, or use a stand-alone Assembler file. */
/* Alternatively, you can implement all fcts directly in master-mind.c, */
/* using inline Assembler code there. */
/* The Makefile assumes you define the functions here. */
/* ***************************************************************************** */


#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#endif

#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)

#define INPUT 0
#define OUTPUT 1

#define LOW 0
#define HIGH 1


// APP constants ---------------------------------

// Wiring (see call to lcdInit in main, using BCM numbering)
// NB: this needs to match the wiring as defined in master-mind.c

#define STRB_PIN 24
#define RS_PIN 25
#define DATA0_PIN 23
#define DATA1_PIN 10
#define DATA2_PIN 27
#define DATA3_PIN 22

// -----------------------------------------------------------------------------
// includes
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h>

// -----------------------------------------------------------------------------
// prototypes

int failure (int fatal, const char *message, ...);

// -----------------------------------------------------------------------------
// Functions to implement here (or directly in master-mind.c)

/* this version needs gpio as argument, because it is in a separate file */
void digitalWrite (uint32_t *gpio, int pin, int value);

// adapted from setPinMode
void pinMode(uint32_t *gpio, int pin, int mode /*, int fSel, int shift */);

void writeLED(uint32_t *gpio, int led, int value);

int readButton(uint32_t *gpio, int button);

void waitForButton(uint32_t *gpio, int button);
Loading

0 comments on commit f85535e

Please sign in to comment.