summaryrefslogtreecommitdiffstats
path: root/sw/programmer
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-11-23 14:34:55 +0100
committerNao Pross <naopross@thearcway.org>2017-11-23 14:34:55 +0100
commit141137dfe5bdc7400d5cc1ad388b670f9f2e9446 (patch)
treebef58de3c44787dadb22ec9cf452a3606ddd6708 /sw/programmer
parentImprovements in PIO driver, pio test rewritten in inline asm (diff)
downloadz80uPC-141137dfe5bdc7400d5cc1ad388b670f9f2e9446.tar.gz
z80uPC-141137dfe5bdc7400d5cc1ad388b670f9f2e9446.zip
update cpld files from VHDL dev machine and delete programmer code (unused)
Diffstat (limited to 'sw/programmer')
-rw-r--r--sw/programmer/avr/main.c140
-rw-r--r--sw/programmer/avr/makefile31
-rw-r--r--sw/programmer/avr/usart.c107
-rw-r--r--sw/programmer/avr/usart.h96
-rw-r--r--sw/programmer/linux/config.h26
-rw-r--r--sw/programmer/linux/configure.ac23
-rw-r--r--sw/programmer/linux/makefile.am2
-rw-r--r--sw/programmer/linux/reading_links.txt4
-rw-r--r--sw/programmer/linux/src/flash.c70
-rw-r--r--sw/programmer/linux/src/flash.h22
-rw-r--r--sw/programmer/linux/src/main.c67
-rw-r--r--sw/programmer/linux/src/makefile.am7
-rw-r--r--sw/programmer/linux/src/serial.c90
-rw-r--r--sw/programmer/linux/src/serial.h17
-rw-r--r--sw/programmer/linux/src/ui.c143
-rw-r--r--sw/programmer/linux/src/ui.h24
-rwxr-xr-xsw/programmer/linux/src/z80progbin52072 -> 0 bytes
-rw-r--r--sw/programmer/linux/src/z80prog.ui223
18 files changed, 0 insertions, 1092 deletions
diff --git a/sw/programmer/avr/main.c b/sw/programmer/avr/main.c
deleted file mode 100644
index e9fec62..0000000
--- a/sw/programmer/avr/main.c
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "usart.h"
-
-#include <stdio.h>
-#include <util/delay.h>
-
-#define EEPROM_TICK_MS 10
-
-#define ADDRCR PORTB
-#define EEPROMCR PORTC
-#define EEPROMDR PORTD
-
-#define ADDR_BIT 0
-#define ADDR_EL 3
-#define ADDR_EH 4
-#define ADDR_DL 5
-#define ADDR_DH 6
-
-#define EEPROM_WR 0
-#define EEPROM_RD 1
-#define EEPROM_CLK 2
-
-
-struct file_blk
-{
- uint16_t addr;
- uint16_t size;
-};
-
-void eeprom_set_addr(uint16_t addr);
-void eeprom_write(uint16_t addr, uint8_t byte);
-uint8_t eeprom_read(uint16_t addr);
-
-int main(void)
-{
- uint8_t *buffer, i;
- size_t read;
-
- struct file_blk *blk = malloc(sizeof(struct file_blk));
-
- DDRB = 0x7F;
- DDRC = 0x1F;
- DDRD = 0xFD;
-
- /* get configuration */
- usart_init(1200);
-
- while (usart_read((uint8_t *) blk, sizeof(struct file_blk))) {
- buffer = malloc(blk->size);
- read = usart_read(buffer, blk->size);
-
- for (i = 0; i < read; i++) {
- eeprom_write(blk->addr +i, buffer[i]);
- _delay_ms(5);
- eeprom_read(blk->addr +i); // != buffer[i];
- }
-
- free(buffer);
- usart_send_byte(0x06);
- usart_send_byte(0x06);
- usart_send_byte(0x06);
- }
-
- free(blk);
- return 0;
-}
-
-void eeprom_set_addr(uint16_t addr)
-{
- int bit;
-
- for (bit = 0; bit < 8; bit++) {
- // clear bits
- ADDRCR &= ~0x07;
- // select the bit
- ADDRCR |= bit;
-
- // write bit for lower byte
- if (addr & _BV(bit))
- ADDRCR |= _BV(ADDR_DL);
- else
- ADDRCR &= ~_BV(ADDR_DL);
-
- // write bit for higher byte
- if ((addr>>8) & _BV(bit))
- ADDRCR |= _BV(ADDR_DH);
- else
- ADDRCR &= ~_BV(ADDR_DH);
-
- _delay_ms(5);
- }
-}
-
-void eeprom_write(uint16_t addr, uint8_t byte)
-{
- eeprom_set_addr(addr);
-
- DDRC |= 0x18; // ED1 ED0
- DDRD |= 0xFC; // ED7-ED2
-
- /* set data */
- EEPROMDR = byte & 0xFC;
-
- // because EEPROMDR0 and EEPROMDR1 are used by Tx and Rx
- EEPROMCR = (PINC & 0xE7) | (byte & 0x03)<<3;
-
- /* enable address output */
- EEPROMCR &= ~(_BV(ADDR_EH) | _BV(ADDR_EL));
-
- /* write eeprom */
- EEPROMCR &= ~_BV(EEPROM_WR);
- _delay_ms(5);
-
- /* reset */
- EEPROMCR |= _BV(EEPROM_WR);
- EEPROMCR |= _BV(ADDR_EH) | _BV(ADDR_EL);
-}
-
-uint8_t eeprom_read(uint16_t addr)
-{
- uint8_t data;
-
- eeprom_set_addr(addr);
-
- DDRC &= ~0x18;
- DDRD &= ~0xFC;
-
- /* enable address output */
- EEPROMCR &= ~(_BV(ADDR_EH) | _BV(ADDR_EL));
-
- /* enable read eeprom */
- EEPROMCR &= ~_BV(EEPROM_RD);
- data = (PINC & 0x18) | (PIND & 0xFB);
- _delay_ms(5);
-
- /* reset */
- EEPROMCR |= _BV(EEPROM_RD);
- EEPROMCR |= _BV(ADDR_EH) | _BV(ADDR_EL);
-
- return data;
-}
diff --git a/sw/programmer/avr/makefile b/sw/programmer/avr/makefile
deleted file mode 100644
index ba2a709..0000000
--- a/sw/programmer/avr/makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-###
-# Project settings
-#
-TARGET := programmer
-SOURCES := $(wildcard *.c)
-
-###
-# Compiler settings
-#
-CC := avr-gcc
-PORT := /dev/ttyUSB0
-MCU := atmega328p
-
-CFLAGS := -g -Wall -mcall-prologues -mmcu=$(MCU) -Os -I . \
- -DF_CPU=1000000UL -DDEBUG
-LDFLAGS := -Wl,-gc-sections -Wl,-relax
-
-.PHONY: all clean program
-all: $(TARGET).hex
-
-clean:
- rm -f *.o *.hex *.obj *.bin
-
-$(TARGET).hex: $(TARGET).bin
- avr-objcopy -R .eeprom -O ihex $(TARGET).bin $@
-
-$(TARGET).bin: $(SOURCES)
- $(CC) $(CFLAGS) $(SOURCES) -o $@ $(LDFLAGS)
-
-program: $(TARGET).hex
- avrdude -p $(MCU) -c usbasp -P usb -U flash:w:$(TARGET).hex
diff --git a/sw/programmer/avr/usart.c b/sw/programmer/avr/usart.c
deleted file mode 100644
index 3d5faf6..0000000
--- a/sw/programmer/avr/usart.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "usart.h"
-
-static uint16_t usart_baudrate;
-static uint16_t usart_baud_prescale;
-
-void usart_init(uint16_t baudrate)
-{
- // enable RX and TX
- UCSR0B |= _BV(RXEN0) | _BV(TXEN0);
-
- // set 8 bit size char
- UCSR0C |= _BV(UCSZ01) | _BV(UCSZ00);
-
- // set baudrate
- usart_baudrate = baudrate;
- usart_baud_prescale = (F_CPU / (usart_baudrate * 16)) -1;
-
- UBRR0L = usart_baud_prescale;
- UBRR0H = usart_baud_prescale >> 8;
-}
-
-void usart_send_byte(uint8_t data)
-{
- while (!(UCSR0A & _BV(UDRE0)));
- UDR0 = data;
-}
-
-void usart_send(uint8_t *data, size_t len)
-{
- uint8_t *p = data;
-
- while (len--) {
- usart_send_byte(*(p++));
- }
-}
-
-void usart_print(char *str)
-{
- char *p = str;
- size_t len = 0;
-
- while (*p++ != '\0') {
- len++;
- }
-
- usart_send((uint8_t *) str, len);
-}
-
-int usart_read_byte(uint8_t *byte)
-{
- uint16_t timeout = USART_TIMEOUT;
-
- do {
- if (UCSR0A & _BV(RXC0)) {
- *byte = UDR0;
- return 0;
- }
- } while (timeout--);
-
- return -1;
-}
-
-uint8_t usart_read_byte_nt(void)
-{
- while ((UCSR0A & _BV(RXC0)) == 0);
- return UDR0;
-}
-
-
-size_t usart_read(uint8_t *buffer, size_t len)
-{
- size_t read = 0;
- uint8_t *p = buffer;
-
- while (len--) {
- if (usart_read_byte(p) == 0) {
- p++;
- read++;
- }
- }
-
- return read;
-}
-
-int usart_read_line(uint8_t *buffer, size_t len)
-{
- uint8_t ch;
- uint8_t *p = buffer;
- size_t read = 0;
-
- while (len--) {
- if (usart_read_byte(&ch) != 0)
- continue;
- else
- read++;
-
- if (ch == '\n')
- break;
- else
- *(p++) = ch;
- }
-
- if (ch != '\n')
- return -1;
-
- return 0;
-}
diff --git a/sw/programmer/avr/usart.h b/sw/programmer/avr/usart.h
deleted file mode 100644
index 0cf85f2..0000000
--- a/sw/programmer/avr/usart.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef __USART_H__
-#define __USART_H__
-/***
- * USART REGISTERS {{{
- *
- * UCSR: control and status regisers, composed from 3 registers:
- * +------------------------------------------------------------------------+
- * | UCSRA :| RXC | TXC | UDRE | FE | DOR | PE | U2X | MPCM |
- * +------------------------------------------------------------------------+
- * UCSRA is a status register (read only)
- * Relevant bits:
- * - RXC : set to 1 if data is present on the receive buffer
- * - TXC : set to 1 when data is transferred to the transfer register
- * - UDRE: set to 1 when trasmit buffer is empty (data sent)
- * +------------------------------------------------------------------------+
- * | UCSRB :| RXCIE | TXCIE | UDRIE | RXEN | TXEN | UCSZ2 | RXB8 | TXB8 |
- * +------------------------------------------------------------------------+
- * UCSRB is used to setup hardware configuration
- * Relevant bits:
- * - RXCIE: RX complete interrupt enabled when set to 1
- * - TXCIE: TX complete interrupt enabled when set to 1
- * - UDRIE: data register empty interrupt enabled when set to 1
- * - RXEN : uart receiver enabled when set to 1
- * - TXEN : uart transmitter enabled when set to 1
- * +------------------------------------------------------------------------+
- * | UCSRC :| URSEL | UMSEL | UPM1 | UPM0 | USBS | UCSZ1 | UCSZ0 | UCPOL |
- * +------------------------------------------------------------------------+
- * UCSRB is used to setup protocol configuration
- * Relevant bits:
- * - URSEL: register select (location is shared with UBRRH and UCSRC)
- * - UMSEL: mode select
- * 1 -> synchronous
- * 0 -> asynchronous
- * - UMP1 + UPM0: set parity
- * 00 -> no parity
- * 01 -> reserved
- * 10 -> even
- * 11 -> odd
- * - UCSZ2 + UCSZ1 + UCSZ0: set data frame (char size)
- * 000 -> 5 bit
- * 001 -> 6 bit
- * 010 -> 7 bit
- * 011 -> 8 bit
- * 100 to 110 -> reserved
- * 111 -> 9 bit
- *
- * UBRR: baudrate register
- * +------------------------------------------------------------------------+
- * | UBRRH :| URSEL | | | | UBRR11| UBRR10| UBRR9 | UBRR8 |
- * +------------------------------------------------------------------------+
- * | UBRRL :| UBRR7 | UBRR6 | UBRR5 | UBRR4 | UBRR3 | UBRR2 | UBRR1 | UBRR0 |
- * +------------------------------------------------------------------------+
- * UBRR is composed of 2 8 bit registers to store a 12 bit baudrate value.
- * The value to be stored in this register is calculated with the following
- * formula (approximate to integer):
- * UBRR = ( XTAL_frequency ) / ( 16 * BAUDRATE ) -1
- *
- * in C code corresponds to:
- * #define USART_BAUDRATE 9600
- * #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
- *
- * Relevant bits:
- * - URSEL: register select (location is share with UCSRC)
- *
- * UDR : data register
- * This register is shared between RX and TX
- *
- * }}}
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <avr/io.h>
-
-#define USART_TIMEOUT 50000
-
-// struct usart_conf
-// {
-// uint16_t baudrate;
-// };
-
-void usart_init(uint16_t baudrate);
-// void usart_init_conf(struct usart_conf *conf);
-
-void usart_send_byte(uint8_t data);
-void usart_send(uint8_t *data, size_t len);
-
-void usart_print(char *str);
-
-int usart_read_byte(uint8_t *byte);
-uint8_t usart_read_byte_nt(void);
-size_t usart_read(uint8_t *buffer, size_t len);
-int uart_read_line(uint8_t *buffer, size_t len);
-
-#endif
diff --git a/sw/programmer/linux/config.h b/sw/programmer/linux/config.h
deleted file mode 100644
index d319f43..0000000
--- a/sw/programmer/linux/config.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Name of package */
-#define PACKAGE "z80prog"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "naopross@tharcway.org"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "z80prog"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "z80prog 0.1"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "z80prog"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.1"
-
-/* Version number of package */
-#define VERSION "0.1"
diff --git a/sw/programmer/linux/configure.ac b/sw/programmer/linux/configure.ac
deleted file mode 100644
index a5c4b3b..0000000
--- a/sw/programmer/linux/configure.ac
+++ /dev/null
@@ -1,23 +0,0 @@
-AC_CONFIG_SRCDIR([src])
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_AUX_DIR([build-aux])
-
-AC_INIT([z80prog], [0.1], [naopross@tharcway.org])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign])
-
-AC_PROG_CC
-
-####
-# Check for required packages / libraries
-#
-LIBGTK_REQUIRED=2.91
-
-PKG_CHECK_MODULES(gtk3, [gtk+-3.0 >= $LIBGTK_REQUIRED])
-
-AC_CONFIG_FILES([
- makefile
- src/makefile
-])
-
-AC_OUTPUT
diff --git a/sw/programmer/linux/makefile.am b/sw/programmer/linux/makefile.am
deleted file mode 100644
index 4d27cea..0000000
--- a/sw/programmer/linux/makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-SUBDIRS = src
-CLEANFILES = *~
diff --git a/sw/programmer/linux/reading_links.txt b/sw/programmer/linux/reading_links.txt
deleted file mode 100644
index 83c62f4..0000000
--- a/sw/programmer/linux/reading_links.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.5
-https://developer.gnome.org/gio/unstable/GApplication.html
-https://git.gnome.org/browse/gnome-hello/tree/src/app.c
-
diff --git a/sw/programmer/linux/src/flash.c b/sw/programmer/linux/src/flash.c
deleted file mode 100644
index 3527de8..0000000
--- a/sw/programmer/linux/src/flash.c
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "flash.h"
-
-static int flash_serial_fd = -1;
-
-int flash_open(const char *path, unsigned long baudrate)
-{
- flash_serial_fd = serial_open(path, baudrate);
-
- if (flash_serial_fd < 0)
- return -1;
-
- return 0;
-}
-
-int flash_write(const char *romfile, void (*log)(const char *))
-{
- int romfd;
- int v;
- ssize_t written;
-
- struct stat romst;
- struct flash_blk head;
-
- uint8_t *buffer = malloc(FLASH_BLOCK_SIZE);
-
- romfd = open(romfile, O_RDONLY);
-
- if (fstat(romfd, &romst) != 0)
- goto exit_romfd;
-
- while ((head.size = read(romfd, buffer, FLASH_BLOCK_SIZE))) {
- if (head.size < 0) {
- log("[!] Error while reading from file\n");
- break;
- }
-
- head.addr = (uint16_t) lseek(romfd, 0, SEEK_CUR) - head.size;
-
- char logbuf[64];
- sprintf(logbuf, "[@] Writing a block of size %d at addr %d\n", head.size, head.addr);
- log(logbuf);
-
- written = write(flash_serial_fd, &head, sizeof(struct flash_blk));
- if (written != sizeof(struct flash_blk)) {
- log("[!] Some bytes of flash_blk haven't been written\n");
- }
-
- written = write(flash_serial_fd, buffer, head.size);
- if (written != head.size) {
- log("[#] Some bytes might not have been written\n");
- }
-
- while (!read(flash_serial_fd, &v, 1));
-
- sprintf(logbuf, "[@] Written %d bytes at address %d\n", head.size, head.addr);
- log(logbuf);
- }
-
-exit_romfd:
- close(romfd);
-
- free(buffer);
- return 0;
-}
-
-void flash_close(void)
-{
- if (flash_serial_fd >= 0)
- close(flash_serial_fd);
-} \ No newline at end of file
diff --git a/sw/programmer/linux/src/flash.h b/sw/programmer/linux/src/flash.h
deleted file mode 100644
index 373ebf3..0000000
--- a/sw/programmer/linux/src/flash.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __FLASH_H__
-#define __FLASH_H__
-
-#include "serial.h"
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#define FLASH_BLOCK_SIZE 512
-
-struct flash_blk
-{
- uint16_t addr;
- uint16_t size;
-};
-
-int flash_open(const char *devpath, unsigned long baudrate);
-int flash_write(const char *romfile, void (*log)(const char *));
-void flash_close(void);
-
-#endif
diff --git a/sw/programmer/linux/src/main.c b/sw/programmer/linux/src/main.c
deleted file mode 100644
index 1bfd359..0000000
--- a/sw/programmer/linux/src/main.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "config.h"
-#include "ui.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <errno.h>
-
-void out(const char *msg)
-{
- printf("%s", msg);
-}
-
-int main(int argc, char *argv[])
-{
- int opt;
- int use_ui = 0;
-
- unsigned long baudrate;
- char *file, *device, *baud;
-
- file = device = baud = NULL;
-
- while ((opt = getopt(argc, argv, "gf:d:b:")) != -1) {
- switch (opt) {
- case 'g':
- use_ui = 1;
- break;
- case 'f':
- file = optarg;
- break;
- case 'd':
- device = optarg;
- break;
- case 'b':
- baud = optarg;
- break;
- }
- }
-
- if (use_ui) {
- ui_init(&argc, &argv);
- return 0;
- }
-
- if (file == NULL || device == NULL || baud == NULL) {
- perror("Missing argument\n");
- return -1;
- }
-
- baudrate = strtoul(baud, NULL, 0);
- if (errno == ERANGE) {
- perror("Invalid baudrate\n");
- return -1;
- }
-
- if (flash_open(device, baudrate) < 0) {
- perror("Failed to open device\n");
- return -2;
- }
-
- flash_write(file, out);
- flash_close();
-
- return 0;
-}
diff --git a/sw/programmer/linux/src/makefile.am b/sw/programmer/linux/src/makefile.am
deleted file mode 100644
index 33ae438..0000000
--- a/sw/programmer/linux/src/makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-bin_PROGRAMS = z80prog
-z80prog_SOURCES = main.c ui.c serial.c flash.c
-
-z80prog_CFLAGS = -Wall -g $(gtk3_CFLAGS) -pthread
-z80prog_LDADD = $(gtk3_LIBS)
-
-CLEANFILES = *~
diff --git a/sw/programmer/linux/src/serial.c b/sw/programmer/linux/src/serial.c
deleted file mode 100644
index 42f021e..0000000
--- a/sw/programmer/linux/src/serial.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#include "serial.h"
-
-static int rate_to_constant(int baudrate) {
-#define B(x) case x: return B##x
- switch(baudrate) {
- B(50); B(75); B(110); B(134); B(150);
- B(200); B(300); B(600); B(1200); B(1800);
- B(2400); B(4800); B(9600); B(19200); B(38400);
- B(57600); B(115200); B(230400); B(460800); B(500000);
- B(576000); B(921600); B(1000000);B(1152000);B(1500000);
- default: return 0;
- }
-#undef B
-}
-
-int serial_open(const char *devpath, unsigned long baudrate)
-{
- int fd, speed;
- struct termios tty;
- struct serial_struct serinfo;
- // struct termios tty_old;
-
- // open device
- if ((fd = open(devpath, O_RDWR | O_NOCTTY)) < 0) {
- return -1;
- }
-
- speed = rate_to_constant(baudrate);
- if (speed == 0) {
- /* custom divisor */
- serinfo.reserved_char[0] = 0;
- if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
- return -1;
- serinfo.flags &= ~ASYNC_SPD_MASK;
- serinfo.flags |= ASYNC_SPD_CUST;
- serinfo.custom_divisor = (serinfo.baud_base + (baudrate / 2)) / baudrate;
-
- if (serinfo.custom_divisor < 1)
- serinfo.custom_divisor = 1;
- if (ioctl(fd, TIOCSSERIAL, &serinfo) < 0)
- return -1;
- if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
- return -1;
- if (serinfo.custom_divisor * baudrate != serinfo.baud_base) {
- warnx("actual baudrate is %d / %d = %f",
- serinfo.baud_base, serinfo.custom_divisor,
- (float)serinfo.baud_base / serinfo.custom_divisor);
- }
- }
-
- // set custom baudrate
- ioctl(fd, TIOCGSERIAL, &serinfo);
- serinfo.flags = ASYNC_SPD_CUST | ASYNC_LOW_LATENCY;
- serinfo.custom_divisor = serinfo.baud_base / baudrate;
- ioctl(fd, TIOCSSERIAL, &serinfo);
-
- // set parameters
- if (tcgetattr(fd, &tty) != 0) {
- // perror("failed tcgetattr");
- return -1;
- }
-
- cfsetispeed(&tty, speed ?: B38400);
- cfsetospeed(&tty, speed ?: B38400);
- cfmakeraw(&tty);
-
- tty.c_cflag &= ~PARENB; // no parity
- tty.c_cflag &= ~CSTOPB; // no stop bit
- tty.c_cflag |= CS8; // 8 bit data
- tty.c_cflag &= ~CRTSCTS; // no flow control
-
- tty.c_lflag = 0; // no signaling chars, no echo, no canonical processing
- tty.c_oflag = 0; // no remapping, no delays
- tty.c_cc[VMIN] = 0; // no block read
- tty.c_cc[VTIME] = 5; // .5 seconds read timeout
-
- tty.c_cflag |= CREAD | CLOCAL; // turn on read and ignore ctrl lines
- tty.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off s/w flow ctrl
- tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // make raw
- tty.c_oflag &= ~OPOST; // make raw
-
- tcflush(fd , TCIFLUSH); // ?
-
- if (tcsetattr (fd, TCSANOW, &tty) != 0) {
- // perror("failed tcsetattr to set serial port.\n");
- return -1;
- }
-
- return fd;
-}
diff --git a/sw/programmer/linux/src/serial.h b/sw/programmer/linux/src/serial.h
deleted file mode 100644
index dd70756..0000000
--- a/sw/programmer/linux/src/serial.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __Z80PROG_SERIAL_H__
-#define __Z80PROG_SERIAL_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <termio.h>
-#include <err.h>
-#include <linux/serial.h>
-
-int serial_open(const char *devpath, unsigned long baudrate);
-
-#endif
diff --git a/sw/programmer/linux/src/ui.c b/sw/programmer/linux/src/ui.c
deleted file mode 100644
index b53ff0b..0000000
--- a/sw/programmer/linux/src/ui.c
+++ /dev/null
@@ -1,143 +0,0 @@
-#include "ui.h"
-
-static bool ui_connected, ui_fileset;
-static GtkBuilder *ui_builder;
-
-void ui_init(int *argc, char **argv[])
-{
- GtkWindow *window;
- GtkFileChooserButton *filechoosebtn;
- GtkButton *connectbtn, *flashbtn;
-
- ui_connected = ui_fileset = false;
-
- gtk_init(argc, argv);
-
- ui_builder = gtk_builder_new();
- gtk_builder_add_from_file(ui_builder, "z80prog.ui", NULL);
-
- /* connect objects to callbacks */
- window = GTK_WINDOW(gtk_builder_get_object(ui_builder, "window"));
- g_signal_connect(window, "delete_event", G_CALLBACK(flash_close), NULL);
- g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
-
- connectbtn = GTK_BUTTON(gtk_builder_get_object(ui_builder, "connectbtn"));
- g_signal_connect(connectbtn, "clicked", G_CALLBACK(ui_connect_clicked), NULL);
-
- flashbtn = GTK_BUTTON(gtk_builder_get_object(ui_builder, "flashbtn"));
- g_signal_connect(flashbtn, "clicked", G_CALLBACK(ui_flash_clicked), NULL);
-
- filechoosebtn = GTK_FILE_CHOOSER_BUTTON(gtk_builder_get_object(ui_builder, "filechoosebtn"));
- g_signal_connect(filechoosebtn, "file-set", G_CALLBACK(ui_file_set), NULL);
-
- /* start gtk window */
- gtk_main();
-}
-
-void ui_log(const char *msg)
-{
- GtkTextIter end;
- GtkTextView *ui_log;
-
- static GtkTextBuffer *ui_logbuf = NULL;
-
- ui_log = GTK_TEXT_VIEW(gtk_builder_get_object(ui_builder, "logview"));
-
- if (ui_logbuf == NULL) {
- ui_logbuf = gtk_text_buffer_new(NULL);
- gtk_text_view_set_buffer(ui_log, ui_logbuf);
- }
-
- gtk_text_buffer_get_end_iter(ui_logbuf, &end);
- gtk_text_buffer_insert(ui_logbuf, &end, msg, -1);
- gtk_text_view_scroll_to_iter(ui_log, &end, .0, TRUE, .0, .1);
-}
-
-void ui_check_enable_flashbtn(void)
-{
- GtkWidget *ui_flashbtn = GTK_WIDGET(gtk_builder_get_object(ui_builder, "flashbtn"));
-
- if (ui_connected && ui_fileset)
- gtk_widget_set_sensitive(ui_flashbtn, TRUE);
- else
- gtk_widget_set_sensitive(ui_flashbtn, FALSE);
-}
-
-void ui_file_set(GtkFileChooserButton *btn, gpointer user_data)
-{
- GtkEntry *filepath = GTK_ENTRY(gtk_builder_get_object(ui_builder, "filepath"));
-
- gtk_entry_set_text(filepath, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(btn)));
- ui_log(UI_LOG_MSG "file set\n");
- ui_fileset = true;
-
- ui_check_enable_flashbtn();
-}
-
-void ui_connect_clicked(void)
-{
- GtkEntry *ui_devpath = GTK_ENTRY(gtk_builder_get_object(ui_builder, "devpath"));
- GtkSpinButton *ui_baudrate = GTK_SPIN_BUTTON(gtk_builder_get_object(ui_builder, "devbaudrate"));
- GtkButton *ui_connectbtn = GTK_BUTTON(gtk_builder_get_object(ui_builder, "connectbtn"));
-
- unsigned long baudrate = gtk_spin_button_get_value_as_int(ui_baudrate);
- const char *devpath = gtk_entry_get_text(ui_devpath);
-
- if (flash_open(devpath, baudrate) != 0) {
- ui_log(UI_LOG_ERR "failed to open serial device\n");
- } else {
- ui_connected = true;
- ui_log(UI_LOG_MSG "connected to serial device ");
- ui_log(devpath);
- ui_log("\n");
-
- g_signal_handlers_disconnect_by_func(ui_connectbtn, G_CALLBACK(ui_connect_clicked), NULL);
- g_signal_connect(ui_connectbtn, "clicked", G_CALLBACK(ui_disconnect_clicked), NULL);
-
- gtk_button_set_label(ui_connectbtn, "gtk-disconnect");
- ui_check_enable_flashbtn();
- }
-}
-
-void ui_disconnect_clicked(void)
-{
- GtkButton *ui_connectbtn = GTK_BUTTON(gtk_builder_get_object(ui_builder, "connectbtn"));
-
- flash_close();
-
- ui_connected = false;
- ui_log(UI_LOG_MSG "disconnected\n");
-
- g_signal_handlers_disconnect_by_func(ui_connectbtn, G_CALLBACK(ui_disconnect_clicked), NULL);
- g_signal_connect(ui_connectbtn, "clicked", G_CALLBACK(ui_connect_clicked), NULL);
-
- gtk_button_set_label(ui_connectbtn, "gtk-connect");
- ui_check_enable_flashbtn();
-}
-
-int ui_flash_write_start(void *ptr)
-{
- const char *filepath = (const char *) ptr;
-
- flash_write(filepath, ui_log);
- ui_check_enable_flashbtn();
-
- return 0;
-}
-
-void ui_flash_clicked(void)
-{
- GtkWidget *ui_flashbtn = GTK_WIDGET(gtk_builder_get_object(ui_builder, "flashbtn"));
- GtkEntry *ui_filepath = GTK_ENTRY(gtk_builder_get_object(ui_builder, "filepath"));
-
- const char *filepath = gtk_entry_get_text(ui_filepath);
-
- gdk_threads_add_idle_full(
- G_PRIORITY_HIGH_IDLE,
- ui_flash_write_start,
- (void *) filepath,
- NULL
- );
-
- gtk_widget_set_sensitive(ui_flashbtn, FALSE);
-}
diff --git a/sw/programmer/linux/src/ui.h b/sw/programmer/linux/src/ui.h
deleted file mode 100644
index 510537a..0000000
--- a/sw/programmer/linux/src/ui.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __Z80PROG_UI_H__
-#define __Z80PROG_UI_H_
-
-#include "flash.h"
-
-#include <stdbool.h>
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#define UI_LOG_ERR "[!] "
-#define UI_LOG_WARN "[#] "
-#define UI_LOG_MSG "[@] "
-
-void ui_init(int *argc, char **argv[]);
-void ui_log(const char *msg);
-void ui_check_enable_flashbtn(void);
-
-void ui_file_set(GtkFileChooserButton *btn, gpointer user_data);
-void ui_connect_clicked(void);
-void ui_disconnect_clicked(void);
-void ui_flash_clicked(void);
-
-#endif
diff --git a/sw/programmer/linux/src/z80prog b/sw/programmer/linux/src/z80prog
deleted file mode 100755
index e2876ee..0000000
--- a/sw/programmer/linux/src/z80prog
+++ /dev/null
Binary files differ
diff --git a/sw/programmer/linux/src/z80prog.ui b/sw/programmer/linux/src/z80prog.ui
deleted file mode 100644
index 6c652ec..0000000
--- a/sw/programmer/linux/src/z80prog.ui
+++ /dev/null
@@ -1,223 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
-<interface>
- <requires lib="gtk+" version="3.12"/>
- <object class="GtkAdjustment" id="baudrateadjust">
- <property name="upper">1000000</property>
- <property name="value">9600</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkFileFilter" id="gbbinfilter">
- <patterns>
- <pattern>*.bin</pattern>
- <pattern>*.gb</pattern>
- <pattern>*.gba</pattern>
- <pattern>*.gbc</pattern>
- <pattern>*.hex</pattern>
- </patterns>
- </object>
- <object class="GtkWindow" id="window">
- <property name="width_request">450</property>
- <property name="height_request">250</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">Z80 ROM Programmer</property>
- <property name="default_width">450</property>
- <property name="default_height">200</property>
- <child>
- <object class="GtkBox" id="mainbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">10</property>
- <property name="margin_right">10</property>
- <property name="margin_top">10</property>
- <property name="margin_bottom">10</property>
- <property name="orientation">vertical</property>
- <property name="spacing">10</property>
- <child>
- <object class="GtkBox" id="devbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">10</property>
- <child>
- <object class="GtkEntry" id="devpath">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="text" translatable="yes">/dev/tty</property>
- <property name="placeholder_text" translatable="yes">Enter device path</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="devbaudrate">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="width_chars">0</property>
- <property name="max_width_chars">7</property>
- <property name="overwrite_mode">True</property>
- <property name="placeholder_text" translatable="yes">1200</property>
- <property name="input_purpose">number</property>
- <property name="adjustment">baudrateadjust</property>
- <property name="climb_rate">10</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <property name="update_policy">if-valid</property>
- <property name="value">1200</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="connectbtn">
- <property name="label">gtk-connect</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="filebox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">10</property>
- <child>
- <object class="GtkEntry" id="filepath">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="placeholder_text" translatable="yes">Enter binary path</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFileChooserButton" id="filechoosebtn">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="filter">gbbinfilter</property>
- <property name="title" translatable="yes"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="flashbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">10</property>
- <child>
- <object class="GtkProgressBar" id="flashbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_text">True</property>
- <property name="ellipsize">start</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="flashbtn">
- <property name="label" translatable="yes">Flash</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkViewport" id="logviewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkExpander" id="logexpander">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="expanded">True</property>
- <property name="label_fill">True</property>
- <property name="resize_toplevel">True</property>
- <child>
- <object class="GtkScrolledWindow" id="logscroller">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTextView" id="logview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="editable">False</property>
- <property name="monospace">True</property>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="loglabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Logs</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
-</interface>