Commit a4361d91 authored by Greg Davill's avatar Greg Davill

initial commit, start with iceprog as a base

parents
iceprog
*.exe
*.o
*.d
Copyright (C) 2020 Gregory Davill <greg.davill@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
PREFIX ?= /usr/local
DEBUG ?= 0
ICEPROG ?= 1
PROGRAM_PREFIX ?=
CXX ?= clang++
CC ?= clang
PKG_CONFIG ?= pkg-config
C_STD ?= c99
CXX_STD ?= c++11
ifeq ($(DEBUG),1)
OPT_LEVEL ?= 0
DBG_LEVEL ?= -ggdb
else
OPT_LEVEL ?= 2
DBG_LEVEL ?=
endif
WARN_LEVEL ?= all
LDLIBS = -lm -lstdc++
CFLAGS += -MD -O$(OPT_LEVEL) $(DBG_LEVEL) -W$(WARN_LEVEL) -std=$(C_STD) -I$(PREFIX)/include
CXXFLAGS += -MD -O$(OPT_LEVEL) $(DBG_LEVEL) -W$(WARN_LEVEL) -std=$(CXX_STD) -I$(PREFIX)/include
DESTDIR ?=
CHIPDB_SUBDIR ?= $(PROGRAM_PREFIX)icebox
ifeq ($(MXE),1)
EXE = .exe
CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc
CC = $(CXX)
PKG_CONFIG = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-pkg-config
endif
ifneq ($(shell uname -s),Darwin)
LDLIBS = -L/usr/local/lib -lm
else
LIBFTDI_NAME = $(shell $(PKG_CONFIG) --exists libftdi1 && echo ftdi1 || echo ftdi)
LDLIBS = -L/usr/local/lib -l$(LIBFTDI_NAME) -lm
endif
ifeq ($(STATIC),1)
LDFLAGS += -static
LDLIBS += $(shell for pkg in libftdi1 libftdi; do $(PKG_CONFIG) --silence-errors --static --libs $$pkg && exit; done; echo -lftdi; )
CFLAGS += $(shell for pkg in libftdi1 libftdi; do $(PKG_CONFIG) --silence-errors --static --cflags $$pkg && exit; done; )
else
LDLIBS += $(shell for pkg in libftdi1 libftdi; do $(PKG_CONFIG) --silence-errors --libs $$pkg && exit; done; echo -lftdi; )
CFLAGS += $(shell for pkg in libftdi1 libftdi; do $(PKG_CONFIG) --silence-errors --cflags $$pkg && exit; done; )
endif
all: $(PROGRAM_PREFIX)iceprog$(EXE)
$(PROGRAM_PREFIX)iceprog$(EXE): iceprog.o mpsse.o
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $(PROGRAM_PREFIX)iceprog$(EXE) $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)iceprog$(EXE)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)iceprog$(EXE)
clean:
rm -f $(PROGRAM_PREFIX)iceprog
rm -f $(PROGRAM_PREFIX)iceprog.exe
rm -f *.o *.d
-include *.d
.PHONY: all install uninstall clean
This diff is collapsed.
This diff is collapsed.
/*
* iceprog -- simple programming tool for FTDI-based Lattice iCE programmers
*
* Copyright (C) 2015 Clifford Wolf <clifford@clifford.at>
* Copyright (C) 2018 Piotr Esden-Tempski <piotr@esden.net>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MPSSE_H
#define MPSSE_H
#include <stdint.h>
void mpsse_check_rx(void);
void mpsse_error(int status);
uint8_t mpsse_recv_byte(void);
void mpsse_send_byte(uint8_t data);
void mpsse_send_spi(uint8_t *data, int n);
void mpsse_xfer_spi(uint8_t *data, int n);
uint8_t mpsse_xfer_spi_bits(uint8_t data, int n);
void mpsse_set_gpio(uint8_t gpio, uint8_t direction);
int mpsse_readb_low(void);
int mpsse_readb_high(void);
void mpsse_send_dummy_bytes(uint8_t n);
void mpsse_send_dummy_bit(void);
void mpsse_init(int ifnum, const char *devstr, bool slow_clock);
void mpsse_close(void);
#endif /* MPSSE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment