├── Makefile ├── README.md ├── cp2104.c ├── cp2104_3.10.c ├── cp2104_3.6.c ├── cp210x_gpio_example.c ├── cp210x_gpio_on.c ├── cp210x_toggle.c ├── images ├── IMG_6550.JPG ├── IMG_6550_small.JPG └── cp2104.jpg └── k8048_cp2104 ├── HEADER.txt ├── LICENSE ├── Makefile └── Src ├── HEADER.txt ├── INSTALL ├── Makefile ├── TODO ├── VERSION ├── config.mk ├── doc ├── HEADER.txt ├── Makefile ├── README.12 ├── README.14 ├── README.16 ├── README.24 ├── README.32 ├── README.bus-parrot ├── README.chipKITPi ├── README.gpio-bb ├── README.i2c ├── README.icspio ├── README.k8048 ├── README.mips ├── README.proton ├── README.raspi ├── README.rkp28sb ├── README.serial ├── README.tools └── README.xino ├── dotconf.c ├── dotconf.h ├── dotconf ├── HEADER.txt ├── HVP-RPI ├── K8048-RPI ├── K8048-ttyS0 ├── K8048-ttyUSB0 ├── Makefile ├── cp2102-ttyUSB0 ├── cp2104-gpio ├── gpio-RPI ├── gpio-bb └── i2c-mcp23017 ├── gpio-bb.c ├── gpio-bb.h ├── inhx32.c ├── inhx32.h ├── io.c ├── io.h ├── k8048.c ├── k8048.h ├── kio.c ├── kio.h ├── mcp23017.c ├── mcp23017.h ├── pic.c ├── pic.h ├── pic12.c ├── pic12.h ├── pic14.c ├── pic14.h ├── pic16.c ├── pic16.h ├── pic24.c ├── pic24.h ├── pic32.c ├── pic32.h ├── raspi.c ├── raspi.h ├── serial_posix.c ├── serial_posix.h ├── util.c └── util.h /Makefile: -------------------------------------------------------------------------------- 1 | obj-m = cp2104.o 2 | KVERSION = $(shell uname -r) 3 | all: 4 | make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules 5 | clean: 6 | make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Using GPIOs on CP2104 adapter 2 | ============================= 3 | This git contains module code to use the GPIOs on cp2104 adapter with Linux. 4 | 5 | ![alt text](https://raw.githubusercontent.com/GBert/CP2104_GPIO/master/images/cp2104.jpg "cp2104") 6 | 7 | It also contains code to programm PIC MCUs. 8 | 9 | Howto use the kernel module 10 | --------------------------- 11 | ``` 12 | git clone https://github.com/GBert/CP2104_GPIO 13 | cd CP2104_GPIO 14 | # decide which module to use 15 | uname -a 16 | # for kernels <= 3.6 17 | cp cp2104_3.6.c cp2104.c 18 | # for kernel > 3.6 19 | cp cp2104_3.10.c cp2104.c 20 | make 21 | # remove existing module and install modified module 22 | sudo rmmod cp210x 23 | sudo insmod ./cp2104.ko 24 | ``` 25 | 26 | Using as PIC programmer 27 | ----------------------- 28 | The original [k8048 code](http://dev.kewl.org/k8048/Doc/) is able to programm a wide range of PICs 29 | in Low Voltage Programming (aka LVP) mode. There is an inplementation using cheap USB to serial 30 | converters like the CP2102 based boards. But you run ouf of output pins if you have PICs with 31 | PGM pin. I've modified the original code to use the GPIOs on CP2104 boards which are able to do it. 32 | 33 | BTW: The slow programming speed is caused by the USB interface. The k8048 code itself is very 34 | fast if you use GPIOs on boards like RPi or OpenWrt router. 35 | 36 | Interfacing to PIC MCU 37 | ---------------------- 38 | The GPIOs are normally open-drain so pull-ups are needed. 39 | 40 | ``` 41 | Breadboard connections for LVP programming with VPP at 3V3 42 | ---------------------------------------------------------- 43 | CP2104 PICMicro 44 | ====== ======== 45 | 3V3-------------------------------VDD----------+ 46 | | 47 | GND-------------------------------VSS | 48 | | 49 | GPIO 1----------------------------VPP---4.7K---+ 50 | | 51 | GPIO 2----------------------------PGC---4.7K---+ 52 | | 53 | GPIO 3----------------------------PGD---4.7K---+ 54 | | 55 | GPIO 0----------------------------PGM---4.7K---+ (1) 56 | 57 | (1) Not used by all LVP compatible devices. 58 | (2) PIC18F14K50 needs VUSB connected to VDD 59 | ``` 60 | ### Using 61 | 62 | #### Compile and install: 63 | ``` 64 | cd k8048_cp2104 65 | make ; sudo make install 66 | # copy the config file 67 | cp dotconf/cp2104_gpio ~/.k8048 68 | ```` 69 | 70 | #### Quick Test 71 | ``` 72 | % time k16 id 73 | [000000] [PROGRAM] 2000 WORDS (0100 ROWS OF 0020 WORDS) 74 | [200000] [IDLOCATION1] FF . 75 | [200001] [IDLOCATION2] FF . 76 | [200002] [IDLOCATION3] FF . 77 | [200003] [IDLOCATION4] FF . 78 | [200004] [IDLOCATION5] FF . 79 | [200005] [IDLOCATION6] FF . 80 | [200006] [IDLOCATION7] FF . 81 | [200007] [IDLOCATION8] FF . 82 | [300000] [CONFIG1] 7500 83 | [300002] [CONFIG2] 1E23 84 | [300004] [CONFIG3] 0000 85 | [300006] [CONFIG4] 008D 86 | [300008] [CONFIG5] C003 87 | [30000A] [CONFIG6] 8003 88 | [30000C] [CONFIG7] 4003 89 | [3FFFFE] [DEVICEID] 4760 DEV:23B REV:00 PIC18F14K50 90 | [F00000] [DATA] 0100 BYTES 91 | k16 id 0,06s user 0,00s system 1% cpu 5,129 total 92 | ``` 93 | #### "Speed" Test 94 | ``` 95 | % time k16 p USBtin_bootloader_v1.0.hex 96 | Total: 3980 97 | k16 p USBtin_bootloader_v1.0.hex 0,68s user 3,90s system 0% cpu 7:47,22 total 98 | 99 | % time k16 v USBtin_bootloader_v1.0.hex 100 | Total: 3966 Pass: 3966 Fail: 0 101 | k16 v USBtin_bootloader_v1.0.hex 1,10s user 5,71s system 1% cpu 11:13,08 total 102 | ``` 103 | 104 | -------------------------------------------------------------------------------- /cp210x_gpio_example.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | int fd; 12 | cout << "CP210x Serial Test\n"; 13 | fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); 14 | if (fd == -1) 15 | { 16 | cout << "Error opening port /dev/ttyUSB0\n"; 17 | return -1; 18 | } 19 | 20 | unsigned long gpio; 21 | gpio=0; 22 | 23 | ioctl(fd, 0x8000, &gpio); 24 | cout << "original gpio = "; 25 | cout << hex << gpio << endl; 26 | gpio = ~gpio; 27 | gpio = gpio << 8; 28 | gpio |= 0x00FF; 29 | cout << "gpio = "; 30 | cout << hex << gpio << endl; 31 | ioctl(fd, 0x8001, &gpio); 32 | ioctl(fd, 0x8000, &gpio); 33 | cout << "new gpio = "; 34 | cout << hex << gpio << endl; 35 | 36 | close(fd); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /cp210x_gpio_on.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define IOCTL_GPIOGET 0x8000 8 | #define IOCTL_GPIOSET 0x8001 9 | #define GPIO_0_ON 0x00010001 10 | #define GPIO_0_OFF 0x00000001 11 | #define GPIO_1_ON GPIO_0_ON << 1 12 | #define GPIO_1_OFF GPIO_0_OFF << 1 13 | #define GPIO_2_ON GPIO_0_ON << 2 14 | #define GPIO_2_OFF GPIO_0_OFF << 2 15 | #define GPIO_3_ON GPIO_0_ON << 3 16 | #define GPIO_3_OFF GPIO_0_OFF << 3 17 | 18 | int main() { 19 | int fd; 20 | unsigned int gpio, i; 21 | printf("CP2104 GPIO Test on ttyUSB0\n"); 22 | fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); 23 | if (fd == -1) { 24 | fprintf(stderr,"Error opening port /dev/ttyUSB0\n"); 25 | return -1; 26 | } 27 | gpio = 0; 28 | 29 | ioctl(fd, IOCTL_GPIOGET, &gpio); 30 | printf("original gpio = 0x%08X\n",gpio); 31 | 32 | for (i = 0; i<= 10000; i++) { 33 | /* switch on the GPIOs */ 34 | gpio = GPIO_0_ON; 35 | ioctl(fd, IOCTL_GPIOSET, &gpio); 36 | gpio = GPIO_1_ON; 37 | ioctl(fd, IOCTL_GPIOSET, &gpio); 38 | gpio = GPIO_2_ON; 39 | ioctl(fd, IOCTL_GPIOSET, &gpio); 40 | gpio = GPIO_3_ON; 41 | ioctl(fd, IOCTL_GPIOSET, &gpio); 42 | /* switch off the GPIOs - reverse */ 43 | gpio = GPIO_3_OFF; 44 | ioctl(fd, IOCTL_GPIOSET, &gpio); 45 | gpio = GPIO_2_OFF; 46 | ioctl(fd, IOCTL_GPIOSET, &gpio); 47 | gpio = GPIO_1_OFF; 48 | ioctl(fd, IOCTL_GPIOSET, &gpio); 49 | gpio = GPIO_0_OFF; 50 | ioctl(fd, IOCTL_GPIOSET, &gpio); 51 | } 52 | close(fd); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /cp210x_toggle.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define IOCTL_GPIOGET 0x8000 8 | #define IOCTL_GPIOSET 0x8001 9 | 10 | int main() 11 | { 12 | int fd; 13 | printf("CP2104 GPIO Test\n"); 14 | fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); 15 | if (fd == -1) 16 | { 17 | fprintf(stderr,"Error opening port /dev/ttyUSB0\n"); 18 | return -1; 19 | } 20 | 21 | unsigned gpio, i; 22 | gpio = 0; 23 | 24 | ioctl(fd, IOCTL_GPIOGET, &gpio); 25 | printf("original gpio = 0x%08X\n",gpio); 26 | 27 | for (i = 0; i<= 50000; i++) { 28 | gpio = 0x0005000f; 29 | ioctl(fd, IOCTL_GPIOSET, &gpio); 30 | gpio = 0x000a000f; 31 | ioctl(fd, IOCTL_GPIOSET, &gpio); 32 | } 33 | 34 | close(fd); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /images/IMG_6550.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GBert/CP2104_GPIO/3ef94890b15ff2015623727165d58c56dbdf1d2a/images/IMG_6550.JPG -------------------------------------------------------------------------------- /images/IMG_6550_small.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GBert/CP2104_GPIO/3ef94890b15ff2015623727165d58c56dbdf1d2a/images/IMG_6550_small.JPG -------------------------------------------------------------------------------- /images/cp2104.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GBert/CP2104_GPIO/3ef94890b15ff2015623727165d58c56dbdf1d2a/images/cp2104.jpg -------------------------------------------------------------------------------- /k8048_cp2104/HEADER.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | -------------------------------------------------------------------------------- /k8048_cp2104/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (C) 2005-2014 Darron Broad 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name `Darron Broad' nor the names of any contributors 17 | may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /k8048_cp2104/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # COMMAND LINE TOOL ONLY 35 | # 36 | # DEBIAN: 37 | # sudo apt-get install mercurial 38 | # hg clone http://hg.kewl.org/pub/k8048/ 39 | # cd k8048 40 | # make build 41 | # sudo make install 42 | # 43 | build: 44 | cd Src && $(MAKE) 45 | 46 | install: 47 | cd Src && $(MAKE) install 48 | 49 | uninstall: 50 | cd Src && $(MAKE) uninstall 51 | 52 | clean: 53 | rm -f *~ 54 | cd Doc && $(MAKE) clean 55 | cd Src && $(MAKE) clean 56 | # 57 | # COMMAND LINE TOOL & ASSEMBLER DEMOS 58 | # 59 | # REQUIRES: gpasm gEDA gEDA-utils 60 | # 61 | # DEBIAN: 62 | # sudo apt-get install gputils 63 | # sudo apt-get install geda 64 | # sudo apt-get install geda-utils 65 | # sudo apt-get install libreadline-dev 66 | # sudo apt-get install libncurses-dev 67 | # make build-all 68 | # sudo make install-all 69 | # 70 | build-all: 71 | cd Doc && $(MAKE) 72 | cd Src && $(MAKE) build-all 73 | 74 | install-all: 75 | cd Src && $(MAKE) install-all 76 | 77 | uninstall-all: 78 | cd Src && $(MAKE) uninstall-all 79 | 80 | clean-all: 81 | rm -f *~ 82 | cd Doc && $(MAKE) clean 83 | cd Src && $(MAKE) clean-all 84 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/HEADER.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/INSTALL: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | Program install (gnu make) 36 | -------------------------- 37 | 38 | make build 39 | sudo make install 40 | 41 | Program uninstall (gnu make) 42 | ---------------------------- 43 | 44 | sudo make uninstall 45 | 46 | Compiled and tested on 47 | ---------------------- 48 | 49 | FreeBSD 5.3-release (duron 700/SiS) 50 | FreeBSD 5.4-stable (athlon 850/VIA 266) 51 | FreeBSD 6.0-current (celeron 750/Toshiba) 52 | FreeBSD 9.0-release (i5-2500K/Intel) 53 | FreeBSD 10-0-BETA2 (i5-2500K/Intel) 54 | GNU/Linux 2.6.5 (athlon 1G/VIA 133) 55 | MacOS X 10.4.3 (iBook G4 limited success using a Prolific PL-2303 USB to SERIAL adapter) 56 | Redhat Fedora Core 4 57 | NetBSD 3.0 (i386) 58 | Windows XP (SP2) CYGWIN 1.5.21-1 (athlon-64 3000+/nForce4) 59 | Windows XP (SP2) CYGWIN 1.5.21-1 (athlon-64 3800+/nForce4) 60 | Debian Wheezy (i5-2500K/Intel) 61 | Debian Wheezy 'Raspbian' (armv6l/Broadcom) 62 | 63 | Compiled but not tested on 64 | -------------------------- 65 | 66 | GNU/Linux 2.4.18 67 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # build targets and backend configuration 34 | include config.mk 35 | 36 | #FreeBSD IBMPC: FreeBSD 9.0-RELEASE amd64 37 | #Debian IBMPC: Linux 3.2.0-4-amd64 x86_64 38 | #Debian R-PI: Linux 3.2.27+ armv6l 39 | SYSTEM:=$(shell uname -s) 40 | RELEASE:=$(shell uname -r) 41 | PLATFORM:=$(shell uname -m) 42 | 43 | ifeq "$(SYSTEM)" "FreeBSD" 44 | ifneq (,$(findstring 10.,$(RELEASE))) 45 | CC=cc 46 | else 47 | CC=gcc 48 | endif 49 | else 50 | CC=gcc 51 | endif 52 | 53 | CFLAGS=-Os -std=gnu99 -pedantic-errors -I. -Wall -fverbose-asm -save-temps 54 | ifeq "$(GDB)" "1" 55 | CFLAGS+=-ggdb 56 | endif 57 | 58 | ifeq "$(VERBOSE)" "1" 59 | CFLAGS+=-DVERBOSE 60 | endif 61 | ifneq (,$(findstring CYGWIN,$(SYSTEM))) 62 | CFLAGS+=-D__USE_LINUX_IOCTL_DEFS 63 | endif 64 | 65 | BINDIR=/usr/local/bin 66 | 67 | CLIB1=$(CLIB) 68 | TARGET1=k8048 69 | SOURCE1=k8048.c dotconf.c inhx32.c io.c pic.c util.c 70 | 71 | CLIB2=$(CLIB) 72 | TARGET2=kio 73 | SOURCE2=kio.c dotconf.c io.c util.c 74 | 75 | ifeq "$(K12)" "1" 76 | CFLAGS+=-DK12 77 | SOURCE1+=pic12.c 78 | endif 79 | ifeq "$(K14)" "1" 80 | CFLAGS+=-DK14 81 | SOURCE1+=pic14.c 82 | endif 83 | ifeq "$(K16)" "1" 84 | CFLAGS+=-DK16 85 | SOURCE1+=pic16.c 86 | endif 87 | ifeq "$(K24)" "1" 88 | CFLAGS+=-DK24 89 | SOURCE1+=pic24.c 90 | endif 91 | ifeq "$(K32)" "1" 92 | CFLAGS+=-DK32 93 | SOURCE1+=pic32.c 94 | endif 95 | ifeq "$(KCTRL)" "1" 96 | CFLAGS+=-DKCTRL 97 | endif 98 | ifeq "$(KTEST)" "1" 99 | CFLAGS+=-DKTEST 100 | endif 101 | ifeq "$(KIO)" "1" 102 | CFLAGS+=-DKIO 103 | endif 104 | 105 | ifeq "$(TTY)" "1" 106 | CFLAGS+=-DTTY 107 | SOURCE1+=serial_posix.c 108 | SOURCE2+=serial_posix.c 109 | endif 110 | 111 | ifeq "$(CP2104)" "1" 112 | CFLAGS+=-DCP2104 113 | endif 114 | 115 | ifeq "$(RPI)" "1" 116 | ifeq "$(PLATFORM)" "armv6l" 117 | CFLAGS+=-DRPI 118 | SOURCE1+=raspi.c 119 | SOURCE2+=raspi.c 120 | endif 121 | endif 122 | 123 | ifeq "$(SYSTEM)" "Linux" 124 | ifeq "$(MCP23017)" "1" 125 | CFLAGS+=-DMCP23017 126 | SOURCE1+=mcp23017.c 127 | SOURCE2+=mcp23017.c 128 | endif 129 | 130 | ifeq "$(BITBANG)" "1" 131 | CFLAGS+=-DBITBANG 132 | SOURCE1+=gpio-bb.c 133 | SOURCE2+=gpio-bb.c 134 | endif 135 | endif 136 | 137 | OBJECT1=$(SOURCE1:.c=.o) 138 | HEADER1=$(SOURCE1:.c=.h) 139 | 140 | OBJECT2=$(SOURCE2:.c=.o) 141 | HEADER2=$(SOURCE2:.c=.h) 142 | 143 | # 144 | # COMMAND LINE TOOL 145 | # 146 | # DEBIAN: 147 | # sudo apt-get install mercurial 148 | # hg clone http://hg.kewl.org/pub/k8048/ 149 | # cd k8048 150 | # make build 151 | # sudo make install 152 | # 153 | ifeq "$(KIO)" "1" 154 | build: $(TARGET1) $(TARGET2) 155 | else 156 | build: $(TARGET1) 157 | endif 158 | 159 | $(TARGET1):$(OBJECT1) 160 | @echo -n "[LINK] " 161 | $(CC) $(CFLAGS) $(OBJECT1) -o $(TARGET1) $(CLIB1) -Wl,-Map=$(TARGET1).map 162 | ifneq "$(GDB)" "1" 163 | @echo -n "[STRIP] " 164 | strip $(TARGET1) 165 | endif 166 | 167 | $(OBJECT1):$(HEADER1) Makefile config.mk VERSION 168 | 169 | $(TARGET2):$(OBJECT2) 170 | @echo -n "[LINK] " 171 | $(CC) $(CFLAGS) $(OBJECT2) -o $(TARGET2) $(CLIB2) -Wl,-Map=$(TARGET2).map 172 | ifneq "$(GDB)" "1" 173 | @echo -n "[STRIP] " 174 | strip $(TARGET2) 175 | endif 176 | 177 | $(OBJECT2):$(HEADER2) Makefile config.mk VERSION 178 | 179 | %.o:%.c 180 | @echo -n "[CC] " 181 | $(CC) $(CFLAGS) -c $< -o $@ 182 | 183 | install:build 184 | mkdir -p $(BINDIR) 185 | cp $(TARGET1) $(BINDIR)/$(TARGET1) 186 | ifeq "$(K12)" "1" 187 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/k12 188 | endif 189 | ifeq "$(K14)" "1" 190 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/k14 191 | endif 192 | ifeq "$(K16)" "1" 193 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/k16 194 | endif 195 | ifeq "$(K24)" "1" 196 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/k24 197 | endif 198 | ifeq "$(K32)" "1" 199 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/k32 200 | endif 201 | ifeq "$(KCTRL)" "1" 202 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/kctrl 203 | endif 204 | ifeq "$(KTEST)" "1" 205 | ln -sf $(BINDIR)/$(TARGET1) $(BINDIR)/ktest 206 | endif 207 | ifeq "$(KIO)" "1" 208 | cp $(TARGET2) $(BINDIR)/$(TARGET2) 209 | endif 210 | ifeq (,$(findstring CYGWIN,$(SYSTEM))) 211 | chown 0:0 $(BINDIR)/$(TARGET1) 212 | chmod u+s $(BINDIR)/$(TARGET1) 213 | ifeq "$(KIO)" "1" 214 | chown 0:0 $(BINDIR)/$(TARGET2) 215 | chmod u+s $(BINDIR)/$(TARGET2) 216 | endif 217 | endif 218 | 219 | uninstall: 220 | rm -f $(BINDIR)/$(TARGET1) 221 | rm -f $(BINDIR)/k12 222 | rm -f $(BINDIR)/k14 223 | rm -f $(BINDIR)/k16 224 | rm -f $(BINDIR)/k24 225 | rm -f $(BINDIR)/k32 226 | rm -f $(BINDIR)/kctrl 227 | rm -f $(BINDIR)/ktest 228 | rm -f $(BINDIR)/$(TARGET2) 229 | 230 | clean: 231 | cd dotconf && $(MAKE) clean 232 | rm -f $(TARGET1) $(TARGET2) *.o *~ .*~ *.err *.log *.map *.s *.i 233 | # 234 | # ASSEMBLER DEMOS 235 | # 236 | # REQUIRES: gpasm gEDA gEDA-utils 237 | # 238 | # DEBIAN: 239 | # sudo apt-get install gputils 240 | # sudo apt-get install geda 241 | # sudo apt-get install geda-utils 242 | # sudo apt-get install libreadline-dev 243 | # sudo apt-get install libncurses-dev 244 | # make build-asm 245 | # 246 | build-asm: 247 | cd asm && $(MAKE) 248 | 249 | install-asm:build-asm 250 | cd asm && $(MAKE) install 251 | 252 | uninstall-asm: 253 | cd asm && $(MAKE) uninstall 254 | 255 | clean-asm: 256 | cd asm && $(MAKE) clean 257 | # 258 | # COMMAND LINE TOOL, AND DEMOS 259 | # 260 | # REQUIRES: gpasm sdcc pic30-tools gEDA gEDA-utils 261 | # 262 | # DEBIAN: 263 | # view README.tools 264 | # sudo apt-get install geda 265 | # sudo apt-get install geda-utils 266 | # sudo apt-get install libreadline-dev 267 | # sudo apt-get install libncurses-dev 268 | # make build-all 269 | # sudo make install-all 270 | # 271 | build-all:build build-asm 272 | 273 | install-all:install install-asm 274 | 275 | uninstall-all:uninstall uninstall-asm 276 | 277 | clean-all:clean clean-asm 278 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/TODO: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | KNOWN UNSUPPORTED DEVICES (PDIP/SPDIP ONLY) 36 | =========================================== 37 | 38 | TO ACQUIRE (C=CPC, F=FARNELL, M=MICROCHP) 39 | ----------------------------------------- 40 | 41 | BASELINE 42 | N/A 43 | MIDRANGE 44 | N/A 45 | ENHANCED 46 | PIC16F18313/23/24/25/44/45 Future Product 47 | PIC16LF1554/9 Future Product Related to the PIC12LF1552 48 | PIC16F1614/5/8/9 Future Product Related to the PIC12F1612 49 | PIC16F1717/8/9 Future Product Related to the PIC16F1713/6 50 | PIC18 51 | N/A 52 | PIC24 53 | N/A 54 | dsPIC 55 | dsPIC33EV256GM002 Future Product 5V 56 | PIC32 57 | N/A 58 | 59 | ON ORDER 60 | -------- 61 | 62 | BASELINE 63 | N/A 64 | MIDRANGE 65 | N/A 66 | ENHANCED 67 | N/A 68 | PIC18 69 | N/A 70 | PIC24 71 | N/A 72 | dsPIC 73 | N/A 74 | PIC32 75 | N/A 76 | 77 | AVAILABLE 78 | --------- 79 | 80 | BASELINE 81 | N/A 82 | MIDRANGE 83 | N/A 84 | ENHANCED 85 | PIC12LF1572 86 | PIC16LF1716 87 | PIC18 88 | N/A 89 | PIC24 90 | N/A 91 | dsPIC 92 | N/A 93 | PIC32 94 | PIC32MX150F128B 95 | PIC32MX250F128B 96 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/VERSION: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | const char VERSION[] = "2.18-dev"; 34 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/config.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # build targets (enable:1 disable:0) 34 | K12=1 35 | K14=1 36 | K16=1 37 | K24=1 38 | K32=0 39 | KCTRL=1 40 | KTEST=1 41 | KIO=1 42 | 43 | # backends (where available) (enable:1 disable:0) 44 | TTY=1 45 | CP2104=1 46 | RPI=0 47 | MCP23017=0 48 | BITBANG=0 49 | 50 | # gdb else strip (gdb:1 strip:0) 51 | GDB=0 52 | 53 | # output verbose config (enable:1 disable:0) 54 | VERBOSE=0 55 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/HEADER.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | clean: 34 | rm -f *~ 35 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.12: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | 12-bit word PIC10F/12F/16F architecture. 36 | 37 | Sample data: 38 | 39 | PIC16F505: 40 | [0400] [USERID0] 0FFF 41 | [0401] [USERID1] 0FFF 42 | [0402] [USERID2] 0FFF 43 | [0403] [USERID3] 0FFF 44 | [DEVICEID] PIC16F505 45 | [03FF] [RESET] 0C1A 46 | [0404] [OSCCAL] 0C1A 47 | [07FF] [CONFIG] 0FFF 48 | 49 | asm/test/d_pic16f505.asm: 50 | [0000] 0025 0CE0 0007 0067 0907 02A7 0A04 0C80 51 | [0008] 0028 0069 02E9 0A0A 02E8 0A09 0800 0FFF 52 | [03F8] 0FFF 0FFF 0FFF 0FFF 0FFF 0FFF 0FFF 0C1A 53 | [0400] [USERID0] 0050 P 54 | [0401] [USERID1] 0049 I 55 | [0402] [USERID2] 0043 C 56 | [0403] [USERID3] 0021 ! 57 | [DEVICEID] PIC16F505 58 | [03FF] [OSCCAL RESET] 0C1A 59 | [0404] [OSCCAL BACKUP] 0C1A 60 | [07FF] [CONFIG] 0FF1 61 | 62 | PIC10F200: 63 | [0100] [USERID0] 0FFF . 64 | [0101] [USERID1] 0FFF . 65 | [0102] [USERID2] 0FFF . 66 | [0103] [USERID3] 0FFF . 67 | [DEVICEID] PIC10F200 68 | [00FF] [OSCCAL RESET] 0C1C 69 | [0104] [OSCCAL BACKUP] 0C1C 70 | [01FF] [CONFIG] 0FFF 71 | 72 | PIC10F202: 73 | [0200] [USERID0] 0FFF . 74 | [0201] [USERID1] 0FFF . 75 | [0202] [USERID2] 0FFF . 76 | [0203] [USERID3] 0FFF . 77 | [DEVICEID] PIC10F202 78 | [01FF] [OSCCAL RESET] 0C16 79 | [0204] [OSCCAL BACKUP] 0C16 80 | [03FF] [CONFIG] 0FFF 81 | 82 | PIC12F508: 83 | [0200] [USERID0] 0FFF . 84 | [0201] [USERID1] 0FFF . 85 | [0202] [USERID2] 0FFF . 86 | [0203] [USERID3] 0FFF . 87 | [DEVICEID] PIC12F508 88 | [01FF] [OSCCAL RESET] 0C1A 89 | [0204] [OSCCAL BACKUP] 0C1A 90 | [03FF] [CONFIG] 0FFF 91 | 92 | PIC16F57: 93 | [0800] [USERID0] 0050 P 94 | [0801] [USERID1] 0049 I 95 | [0802] [USERID2] 0043 C 96 | [0803] [USERID3] 0021 ! 97 | [DEVICEID] PIC16F57 98 | [0FFF] [CONFIG] 0FF9 99 | 100 | PIC16F506: 101 | [0400] [USERID0] 0FFF . 102 | [0401] [USERID1] 0FFF . 103 | [0402] [USERID2] 0FFF . 104 | [0403] [USERID3] 0FFF . 105 | [DEVICEID] PIC16F506 106 | [03FF] [OSCCAL RESET] 0C16 107 | [0404] [OSCCAL BACKUP] 0C16 108 | [07FF] [CONFIG] 0FFF 109 | 110 | PIC10F220: 111 | [0100] [USERID0] 0FFF . 112 | [0101] [USERID1] 0FFF . 113 | [0102] [USERID2] 0FFF . 114 | [0103] [USERID3] 0FFF . 115 | [DEVICEID] PIC10F220 116 | [00FF] [OSCCAL RESET] 0C1E 117 | [0104] [OSCCAL BACKUP] 0C1E 118 | [01FF] [CONFIG] 07FF 119 | 120 | PIC12F519: 121 | [0440] [USERID0] 0FFF . 122 | [0441] [USERID1] 0FFF . 123 | [0442] [USERID2] 0FFF . 124 | [0443] [USERID3] 0FFF . 125 | [DEVICEID] PIC12F519 126 | [03FF] [OSCCAL RESET] 0C0E 127 | [0444] [OSCCAL BACKUP0] 0C0E 128 | [0445] [OSCCAL BACKUP1] 0FFF 129 | [0446] [OSCCAL BACKUP2] 0FFF 130 | [0447] [OSCCAL BACKUP3] 0FFF 131 | [07FF] [CONFIG] 0FFF 132 | 133 | PIC12F510: 134 | [0000] [PROGRAM] 0400 WORDS 135 | [03FF] [OSCCAL] 0C18 136 | [0400] [USERID0] 0FFF . 137 | [0401] [USERID1] 0FFF . 138 | [0402] [USERID2] 0FFF . 139 | [0403] [USERID3] 0FFF . 140 | [0404] [BACKUP] 0C18 141 | [0FFF] [CONFIG] 0FFF 142 | [DEVICEID] PIC12F510 143 | 144 | PIC16F570: 145 | [0000] [PROGRAM] 0800 WORDS 146 | [07FF] [OSCCAL] 0C2C 147 | [0800] [DATA] 0040 BYTES 148 | [0840] [USERID0] 0FFF . 149 | [0841] [USERID1] 0FFF . 150 | [0842] [USERID2] 0FFF . 151 | [0843] [USERID3] 0FFF . 152 | [0844] [BACKUP] 0C2C 153 | [0FFF] [CONFIG] 0FFF 154 | [DEVICEID] PIC16F570 155 | 156 | PIC16F527: 157 | [0000] [PROGRAM] 0400 WORDS 158 | [03FF] [OSCCAL] 0C10 159 | [0400] [DATA] 0040 BYTES 160 | [0440] [USERID0] 0FFF . 161 | [0441] [USERID1] 0FFF . 162 | [0442] [USERID2] 0FFF . 163 | [0443] [USERID3] 0FFF . 164 | [0444] [BACKUP] 0C10 165 | [0FFF] [CONFIG] 0FFF 166 | [DEVICEID] PIC16F527 167 | 168 | PIC16F526: 169 | [0000] [PROGRAM] 0400 WORDS 170 | [03FF] [OSCCAL] 0C12 171 | [0400] [DATA] 0040 BYTES 172 | [0440] [USERID0] 0FFF . 173 | [0441] [USERID1] 0FFF . 174 | [0442] [USERID2] 0FFF . 175 | [0443] [USERID3] 0FFF . 176 | [0444] [BACKUP] 0C12 177 | [0FFF] [CONFIG] 0FFF 178 | [DEVICEID] PIC16F526 179 | 180 | DS41226E 181 | PIC12F508 T PIC12F509 U PIC16F505 T 182 | 183 | DS41257B 184 | PIC12F510 T 185 | 186 | DS41258C 187 | PIC16F506 T 188 | 189 | DS41228D (1) 190 | PIC10F200 T PIC10F202 T PIC10F204 U PIC10F206 U 191 | 192 | DS41266C (1) 193 | PIC10F220 T PIC10F222 U 194 | 195 | DS41207D 196 | PIC16F54 T 197 | 198 | DS41208C (1) 199 | PIC16F57 T 200 | 201 | DS41243B 202 | PIC16F59 T 203 | 204 | DS41316C 205 | PIC12F519 T 206 | 207 | DS41670A 208 | PIC16F570 T 209 | 210 | DS41640A 211 | PIC16F527 T 212 | 213 | DS41317B 214 | PIC16F526 T 215 | 216 | T=TESTED 217 | U=UNTESTED 218 | 219 | (1) These devices are not pin compatible with the Velleman K8048 and must 220 | be programmed via the ICSP header. 221 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.32: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | 32-bit word PIC32 architecture. 36 | 37 | Sample data: 38 | 39 | PIC32MX150F128B: 40 | 41 | PIC32MX250F128B: 42 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.bus-parrot: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | Bus Parrot Bus Pirate Setup 36 | =========================== 37 | 38 | The Circuit 39 | ----------- 40 | 41 | http://dev.kewl.org/k8048/Src/asm/PIC24FJ64GA002/gEDA/busparrot.png 42 | 43 | This layout is a work-in-progress and is almost functionally 44 | the same as the original the difference being the the power section. 45 | 46 | This can be solved later but adequate parts are not available for 47 | testing at this time. 48 | 49 | All parts should be available from CPC in the UK including the PICMicro. 50 | 51 | k8048 config 52 | ------------ 53 | 54 | ~/.k8048: 55 | DEVICE=RPI 56 | SLEEP=1 57 | BITRULES=0x1700 58 | VPP=9 59 | PGM=255 60 | PGC=10 61 | PGD=11 62 | 63 | These are the configuration options for the k8048 application which 64 | is used to program the PICMicro. 65 | 66 | Detect the PIC24FJ64GA002 67 | ------------------------- 68 | 69 | > k24 lvp id 70 | [000000] [PROGRAM] 5600 WORDS 71 | [00ABFC] [CONFIG2] F9DF 72 | [00ABFE] [CONFIG1] 3F7F 73 | [8007F0] [APPID] D3 74 | [8007F4] [CALIB1] E97B34 75 | [8007F6] [CALIB2] 0F0081 76 | [8007F8] [CALIB3] FF006F 77 | [8007FA] [CALIB4] FF0001 78 | [8007FC] [CALIB5] FFFF21 79 | [8007FE] [CALIB6] FFF97D 80 | [FF0000] [DEVID] 0447 FAM:11 DEV:07 PIC24FJ64GA002 81 | [FF0002] [DEVREV] 3046 MAJOR:1 DOT:6 82 | Time: 0:00.07s 83 | 84 | Program the PIC24FJ64GA002 85 | -------------------------- 86 | 87 | > k24 lvp program BPv3-Firmware_v6.3-beta1_r2151__Bootloader_v4.4.hex 88 | Total: 18436 89 | Time: 0:03.97s 90 | 91 | Verify the PIC24FJ64GA002 92 | ------------------------- 93 | 94 | > k24 lvp verify BPv3-Firmware_v6.3-beta1_r2151__Bootloader_v4.4.hex 95 | Total: 18436 Pass: 18436 Fail: 0 96 | Time: 0:04.58s 97 | 98 | Install and setup kermit 99 | ------------------------ 100 | 101 | > apt-get install ckermit 102 | 103 | ~/.kermrc: 104 | set modem type none 105 | set line /dev/ttyAMA0 106 | set carrier-watch off 107 | set speed 115200 108 | set flow none 109 | connect 110 | 111 | Test the Bus Parrot Bus Pirate 112 | ------------------------------ 113 | 114 | > kermit 115 | # 116 | RE 117 | Bus Pirate v3.a 118 | Firmware v6.3-beta1 r2151 Bootloader v4.4 119 | DEVID:0x0447 REVID:0x3046 (24FJ64GA002 B8) 120 | http://dangerousprototypes.com 121 | HiZ> 122 | \Q 123 | 124 | \ is the CONTROL key pressed and then backslash entered without releasing control. 125 | Enter this and afterward enter upper case Q. This will quit kermit and return to the UNIX 126 | shell. 127 | 128 | Bus Parrot Bus Pirate Demo 129 | ========================== 130 | 131 | http://dangerousprototypes.com/docs/Bus_Pirate 132 | 133 | I2C EEPROM 134 | ---------- 135 | 136 | http://dev.kewl.org/k8048/Images/busparrot.jpg 137 | 138 | http://dangerousprototypes.com/docs/3EEPROM_explorer_board#24AA_I2C_EEPROM 139 | 140 | > kermit 141 | # 142 | RE 143 | Bus Pirate v3.a 144 | Firmware v6.3-beta1 r2151 Bootloader v4.4 145 | DEVID:0x0447 REVID:0x3046 (24FJ64GA002 B8) 146 | http://dangerousprototypes.com 147 | HiZ>m 148 | 1. HiZ 149 | 2. 1-WIRE 150 | 3. UART 151 | 4. I2C 152 | 5. SPI 153 | 6. 2WIRE 154 | 7. 3WIRE 155 | 8. LCD 156 | x. exit(without change) 157 | 158 | (1)>4 159 | Set speed: 160 | 1. ~5KHz 161 | 2. ~50KHz 162 | 3. ~100KHz 163 | 4. ~400KHz 164 | 165 | (1)> 166 | Clutch disengaged!!! 167 | To finish setup, start up the power supplies with command 'W' 168 | 169 | Ready 170 | I2C>P 171 | Pull-up resistors ON 172 | I2C>W 173 | POWER SUPPLIES ON 174 | Clutch engaged!!! 175 | I2C>(0) 176 | 0.Macro menu 177 | 1.7bit address search 178 | 2.I2C sniffer 179 | I2C>(1) 180 | Searching I2C address space. Found devices at: 181 | 0xA0(0x50 W) 0xA1(0x50 R) 182 | 183 | I2C>[0b10100000 0 0 3 2 1] 184 | I2C START BIT 185 | WRITE: 0xA0 ACK 186 | WRITE: 0x00 ACK 187 | WRITE: 0x00 ACK 188 | WRITE: 0x03 ACK 189 | WRITE: 0x02 ACK 190 | WRITE: 0x01 ACK 191 | I2C STOP BIT 192 | I2C>[0b10100000 0 0] 193 | I2C START BIT 194 | WRITE: 0xA0 ACK 195 | WRITE: 0x00 ACK 196 | WRITE: 0x00 ACK 197 | I2C STOP BIT 198 | I2C>[0b10100001 r:3] 199 | I2C START BIT 200 | WRITE: 0xA1 ACK 201 | READ: 0x03 ACK 0x02 ACK 0x01 202 | NACK 203 | I2C STOP BIT 204 | I2C> 205 | \Q 206 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.chipKITPi: -------------------------------------------------------------------------------- 1 | chipKITPi R-PI GPIO header (RPi-Connect) 2 | ------------------------------------------------------------------------------- 3 | 4 | JP5 5 | +---J4---+ 6 | NC 01 02 GPIO0/GPIO2 7 | GPIO1/GPIO3 03 04 NC 8 | GPIO4 05 06 GND 9 | GPIO18 07 08 GPIO17 10 | GND 09 10 GPIO21/GPIO27 11 | GPIO23 11 12 GPIO22 12 | GPIO24 13 14 3V3 13 | GND 15 16 GPIO10 14 | GPIO25 17 18 GPIO9 15 | GPIO8 19 20 GPIO11 16 | GPIO7 21 22 GND 17 | +--------+ 18 | 19 | chipKITPi I/O headers (Arduino 3V3 compatible) 20 | ------------------------------------------------------------------------------- 21 | 22 | JA1 23 | === 24 | JA4 POWER NC NC 25 | ========= G GND 26 | RESET 13 D13 SCK 27 | 3V3 12 D12 MISO 28 | 5V0 11 D11 MOSI PWM 29 | GND 10 D10 SS 30 | GND 9 D9 PWM 31 | VIN 8 D8 32 | 33 | JA2 34 | === 35 | JA3 ANALOG 7 D7 AIN1 36 | ========== 6 D6 AIN0 PWM 37 | A0 5 D5 T1 PWM 38 | A1 4 D4 T0 39 | NC 3 D3 INT1 PWM 40 | NC 2 D2 INT2 41 | SDA 1 D1 TXD 42 | SCL 0 D0 RXD 43 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.gpio-bb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | Breadboard connections for LVP programming with VPP at 3V3 36 | ---------------------------------------------------------- 37 | 38 | R-PI PICMicro GPIO header 39 | ==== ======== =========== 40 | 41 | 3V3-------------------------------VDD----+ PIN 1 (P1-01) 42 | | 43 | GND-------------------------------VSS | PIN 6 44 | 1 45 | GPIO04-----------470R-------------VPP 0 PIN 7 46 | K 47 | GPIO25-----------470R-------------PGC | PIN 22 48 | | 49 | GPIO24-----------470R-------------PGD----+ PIN 18 50 | 51 | GPIO22-----------470R-------------PGM (1) PIN 15 52 | 53 | (1) Not used by all LVP compatible devices. 54 | 55 | How to build gpio bit-bang kernel module for raspbian on the R-PI 56 | ================================================================= 57 | 58 | Determine the running kernel and it's config on the Raspberry Pi target machine. 59 | 60 | $ uname -a 61 | Linux pi3 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux 62 | $ zgrep "* firmware as of" /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1 | awk '{ print $5 }' 63 | 030082b403b 64 | $ zcat /proc/config.gz > 030082b403b.config 65 | 66 | Linux pi3 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux d4f5315cfac4e 67 | Linux pi3 3.10.23+ #608 PREEMPT Mon Dec 9 21:11:23 GMT 2013 armv6l GNU/Linux 9d34d0475f9 68 | Linux pi3 3.10.24+ #614 PREEMPT Thu Dec 19 20:38:42 GMT 2013 armv6l GNU/Linux c32bc633039cd9 69 | Linux pi3 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux 030082b403b 70 | 71 | Determine the kernel hash for this firmware. 72 | 73 | $ wget -q https://raw.github.com/raspberrypi/firmware/030082b403b/extra/git_hash -O /tmp/hash 74 | $ cat /tmp/hash 75 | 16eb921a96db3dc3555a65b53b99c15753e6b770 76 | 77 | 3.6.11+ d4f5315cfac4e 1587f775d0a3c437485262ba951afc5e30be69fa 78 | 3.10.23+ 9d34d0475f9 c15430e6a01e1332032d83f6484a866504e8ee97 79 | 3.10.24+ c32bc633039cd9 4bbea92eae6c0792e85a4ba079d367ac6aa77fb5 80 | 3.10.25+ 030082b403b 16eb921a96db3dc3555a65b53b99c15753e6b770 81 | 82 | On the build host fetch the kernel build tools. 83 | 84 | $ mkdir -p /embedded/raspbian/build/ 85 | $ cd /embedded/raspbian/build/ 86 | $ git clone git://github.com/raspberrypi/tools.git 87 | 88 | Then fetch the kernel source for the previously determined hash. 89 | 90 | $ cd /embedded/raspbian/build/ 91 | $ rm -Rf /embedded/raspbian/build/linux 92 | $ git clone https://github.com/raspberrypi/linux.git 93 | $ cd /embedded/raspbian/build/linux/ 94 | $ git checkout 16eb921a96db3dc3555a65b53b99c15753e6b770 95 | $ git reset --hard 96 | 97 | Prepare to build kernel and copy over configuration. 98 | 99 | $ make ARCH=arm mrproper 100 | $ scp pi@pi:030082b403b.config .config 101 | 102 | Build the kernel using the cross compiler tools. 103 | 104 | $ make ARCH=arm oldconfig 105 | $ make ARCH=arm CROSS_COMPILE=/embedded/raspbian/build/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- -j 8 106 | 107 | Build the gpio bit-bang module from the k8048 build directory and copy to target machine. 108 | 109 | $ cd $HOME/k8048/Src/gpio-bb/ 110 | $ make 111 | $ find . -name "*.ko" -exec scp {} pi@pi: \; 112 | 113 | Install the module on the Raspberry Pi target machine (Eg. 3.6.11+). 114 | 115 | $ mkdir -p /lib/modules/3.6.11+/kernel/local/ 116 | $ cp gpio-bb.ko /lib/modules/3.6.11+/kernel/local/ 117 | $ chown -R 0:0 /lib/modules/3.6.11+/kernel/local/ 118 | $ depmod -a 119 | 120 | Load modules on target machine. 121 | 122 | /etc/modprobe.d/modprobe.conf: 123 | install gpio-bb modprobe --ignore-install gpio-bb && modprobe gpio-bb && mknod /dev/gpio-bb c 180 0 124 | 125 | $ modprobe gpio-bb 126 | 127 | How to build gpio bit-bang kernel modules for OpenWRT 128 | ===================================================== 129 | 130 | This example builds the firmware for a TP-LINK TL-WR941ND V3.2 (UNTESTED) 131 | 132 | $ mkdir -p /embedded/openwrt/ 133 | $ cd /embedded/openwrt/ 134 | $ git clone git://git.openwrt.org/openwrt.git openwrt.git 135 | $ chown -R nobody:nogroup /embedded/openwrt/openwrt.git 136 | $ cd /embedded/openwrt/openwrt.git 137 | $ /bin/su nobody 138 | $ cp feeds.conf.default feeds.conf.default.orig 139 | $ echo "src-git openwrtfiles git://github.com/GBert/openwrt-files" >> feeds.conf.default 140 | $ ./scripts/feeds update -a 141 | $ ./scripts/feeds install kmod-bit-bang-gpio picprog-new 142 | $ make menuconfig 143 | [Target System = Atheros AR7xxx/AR9xxx] 144 | [Target Profile = TP-LINK TL-WR941N/ND] 145 | [Kernel Modules] [Other Modules] [kmod-bit-bang-gpio] 146 | [Utilities] [picprog-new] 147 | [Exit] [Yes] 148 | $ make V=s 149 | [WAIT FOR A LONG TIME...] 150 | $ ls -1 bin/ar71xx/openwrt-ar71xx-generic-tl-wr941nd-v*factory.bin 151 | bin/ar71xx/openwrt-ar71xx-generic-tl-wr941nd-v2-squashfs-factory.bin 152 | bin/ar71xx/openwrt-ar71xx-generic-tl-wr941nd-v3-squashfs-factory.bin 153 | bin/ar71xx/openwrt-ar71xx-generic-tl-wr941nd-v4-squashfs-factory.bin 154 | bin/ar71xx/openwrt-ar71xx-generic-tl-wr941nd-v6-squashfs-factory.bin 155 | [UPGRADE FIRMWARE] 156 | $ telnet 192.168.1.1 157 | Trying 192.168.1.1... 158 | Connected to 192.168.1.1. 159 | Escape character is '^]'. 160 | === IMPORTANT ============================ 161 | Use 'passwd' to set your login password 162 | this will disable telnet and enable SSH 163 | ------------------------------------------ 164 | 165 | 166 | BusyBox v1.19.4 (2014-03-17 16:43:34 GMT) built-in shell (ash) 167 | Enter 'help' for a list of built-in commands. 168 | 169 | _______ ________ __ 170 | | |.-----.-----.-----.| | | |.----.| |_ 171 | | - || _ | -__| || | | || _|| _| 172 | |_______|| __|_____|__|__||________||__| |____| 173 | |__| W I R E L E S S F R E E D O M 174 | ----------------------------------------------------- 175 | BARRIER BREAKER (Bleeding Edge, r39935) 176 | ----------------------------------------------------- 177 | * 1/2 oz Galliano Pour all ingredients into 178 | * 4 oz cold Coffee an irish coffee mug filled 179 | * 1 1/2 oz Dark Rum with crushed ice. Stir. 180 | * 2 tsp. Creme de Cacao 181 | ----------------------------------------------------- 182 | root@OpenWrt:/# 183 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.i2c: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | Linux (R-PI) I2C (MCP23017) 36 | --------------------------- 37 | 38 | R-PI I2C 39 | -------- 40 | 41 | Enable I2C on the R-PI as root. 42 | 43 | $ sed -i 's/^blacklist/#blacklist/g' /etc/modprobe.d/raspi-blacklist.conf 44 | $ echo 'SUBSYSTEM=="i2c-dev", MODE="0666"' >> /etc/udev/rules.d/10-local.rules 45 | $ echo "options i2c_bcm2708 baudrate=400000" >> /etc/modprobe.d/modprobe.conf 46 | $ echo 'i2c-dev' >> /etc/modules 47 | $ reboot 48 | 49 | For the MCP23017 a baudrate of 900000 has been tested and appears to work 50 | satisfactorily. You should experiment with this value. 51 | 52 | Slice of PI/O on Raspberry Pi 53 | ----------------------------- 54 | 55 | RPI version I2C device Default MCP Address 56 | ----------- ---------- ------------------- 57 | 1 /dev/i2c-0 0x20 58 | 2 /dev/i2c-1 0x20 59 | 60 | The slice of PI/O may be configured in 3V3 or 5V modes of operation 61 | by a jumper. 62 | 63 | Power may be taken from the board on PWR and GND if a suitable 4-pin 64 | header is connected. 65 | 66 | Breadboard connections for LVP programming with VPP at 3V3 or 5V 67 | ---------------------------------------------------------------- 68 | 69 | SLICE OF PI/O PICMicro 70 | ============= ======== 71 | 72 | PWR-------------------------------VDD 73 | 74 | GND-------------------------------VSS 75 | 76 | A0--------------------------------VPP 77 | 78 | A1--------------------------------PGC 79 | 80 | A2--------------1000R--------+----PGD 81 | | 82 | A3---------------------------+ 83 | 84 | A4--------------------------------PGM (1) 85 | 86 | (1) Not used by all LVP compatible devices. 87 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.icspio: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | VELLEMAN K8048 ICSP I/O 36 | ----------------------- 37 | Performs serial I/O over the Velleman K8048 ICSP PGC clock and PGD data lines. 38 | PGC and PGD port and bits are determined by the number of pins else they may 39 | be user defined. 40 | 41 | Usage 42 | ----- 43 | #INCLUDE "device.inc" ;DEVICE CONFIG 44 | #INCLUDE "const.inc" ;CONSTANTS 45 | #INCLUDE "macro.inc" ;MACROS 46 | #INCLUDE "delay.inc" ;DELAY COUNTERS 47 | #INCLUDE "shadow.inc" ;SHADOW I/O (ONLY USE IF DEVICE HAS NO LATCH) 48 | NPINS SET .18 ;18-PIN PDIP 49 | #INCLUDE "icspio.inc" ;ICSP I/O 50 | 51 | Internal variables are assigned at the current CBLOCK address. It is up to 52 | the main source file to ensure that this address is both valid and that 53 | there is enough space for allocation. 54 | 55 | Demo 56 | ---- 57 | Set LEDs and read switches in a loop. 58 | ktest 5 ARG 59 | 60 | Set LEDs and read switches from the command line. 61 | kio CMD ARG 62 | Src/etc/led.sh 63 | Src/etc/switch.sh 64 | 65 | Functions 66 | --------- 67 | GETBYTE 68 | Fetches a byte from the master (host) and stores it in BUFFER. 69 | Sets W and also sets the carry bit on error (time-out, protocol or 70 | parity error). 71 | 72 | SENDBYTE 73 | Sends a byte in W to the master (host). 74 | Sets W and also sets the carry bit on a time-out error. 75 | 76 | SENDACK 77 | Calls SENDBYTE with W=ACK (acknowledge) 78 | 79 | SENDNAK 80 | Calls SENDBYTE with W=NAK (negative acknowledge) 81 | 82 | 2 levels of stack are used when calling the routines GETBYTE, SENDBYTE or 83 | SENDTERM. On 12-bit word architecture devices do not call any of these 84 | routines from within a sub-routine since it will overflow the stack. 85 | 86 | Protocol 87 | -------- 88 | PGD is used for data I/O with even parity and PGC for clock synchronisation. 89 | PGC is unidirectional and is only controlled by the master (host), this is the 90 | slave. The interface may or not be inverted but this is catered for by the 91 | BITRULES inversion logic. 92 | 93 | Data is setup on the master prior to a clock low to high transition and setup 94 | on the slave after a clock low to high transition. Data is read after a clock 95 | high to low transition on both master and slave. 96 | 97 | Start and stop bits have data held low and high respectively and if invalid 98 | then a protocol error is flagged and the transaction terminated without further 99 | communication on either end. Parity error causes a similar closure of the 100 | session. 101 | 102 | PGC +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ 103 | | | | | | | | | | | | | | | | | | | | | | | 104 | ------+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +--+ +------- 105 | PGD START DATA DATA DATA DATA DATA DATA DATA DATA EVEN STOP 106 | XXXXXXLLLLLL000000111111222222333333444444555555666666777777PPPPPPHHHHHHHHHHH 107 | BIT BIT0 BIT1 BIT2 BIT3 BIT4 BIT5 BIT6 BIT7 PAR. BIT 108 | 109 | 1 start bit, 8 data bits, even parity and one stop bit. The data line is 110 | normally held high since in order to operate bi-directionally data output must 111 | be held high in order for data input to operate. 112 | 113 | Notes 114 | ----- 115 | Arch. Stack level 116 | ---- ----------- 117 | 12 2 118 | 14 8 119 | 16 31 120 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.k8048: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | SOCKET CROSS REFERENCE 36 | ------------------------------------------------------------------------------- 37 | 38 | Socket 8-pin 14-pin 18-pin 28-pin 39 | --------- --------- --------- --------- --------- 40 | Function Pin 41 | --------- --- 42 | LD1 GP2 (5) RC0 (10) RB0 (6) RA0 (2) 43 | LD2 GP4 (3) RC1 (9) RB1 (7) RA1 (3) 44 | LD3 RC2 (8) RB2 (8) RA2 (4) 45 | LD4 RC3 (7) RB3 (9) RA3 (5) 46 | LD5 RC4 (6) RB4 (10) RA4 (6) 47 | LD6 RB5 (11) RA5 (7) 48 | 49 | SW1 GP5 (2) RC5 (5) RA0 (17) RB0 (21) 50 | SW2 RA2 (11) RA1 (18) RB1 (22) 51 | SW3 RA2 (1) RB2 (23) 52 | SW4 RA3 (2) RB4 (25) 53 | 54 | PGD GP0 (7) RA0 (13) RB7 (13) RB7 (28) 55 | PGC GP1 (6) RA1 (12) RB6 (12) RB6 (27) 56 | VPP GP3 (4) RA3 (4) RA5 (4) VPP (1) 57 | PGM/24 RB3 (24) 58 | PGM/26 RB5 (26) 59 | 60 | OSC1 RA5 (2) RA7 (16) RA7 (9) 61 | OSC2 RA4 (3) RA6 (15) RA6 (10) 62 | 63 | VDD/VCC VDD (1) VDD (1) VDD (14) VDD (20) 64 | VSS/GND VSS (8) VSS (14) VSS (5) VSS (8, 19) 65 | 66 | NC RA4 (3) 67 | NC RC0 (11) 68 | NC RC1 (12) 69 | NC RC2 (13) 70 | NC RC3 (14) 71 | NC RC4 (15) 72 | NC RC5 (16) 73 | NC RC6 (17) 74 | NC RC7 (18) 75 | 76 | ICSP (In-Circuit Serial Programming) 77 | ------------------------------------------------------------------------------- 78 | 79 | SK3 is an ICSP port, the pins are arranged as follows: 80 | 81 | ICSP 82 | --------- 83 | 5 4 3 2 1 84 | 85 | 1:VPP 12V 86 | 2:VDD 5V 87 | 3:VSS/GND 88 | 4:PGD 89 | 5:PGC 90 | 91 | ICSP voltage levels (No chip installed, no D-SUB-9 connection) 92 | -------------------------------------------------------------- 93 | 94 | Switch set to RUN. 95 | 96 | 1:VPP 5V 97 | 2:VDD 5V 98 | 3:VSS/GND 0V 99 | 4:PGD 5V 100 | 5:PGC 5V 101 | 102 | Switch set to STANDBY. 103 | 104 | 1:VPP 0V 105 | 2:VDD 0V 106 | 3:VSS/GND 0V 107 | 4:PGD 5V 108 | 5:PGC 5V 109 | 110 | Switch set to PROG. 111 | 112 | 1:VPP 12V 113 | 2:VDD 5V 114 | 3:VSS/GND 0V 115 | 4:PGD 5V 116 | 5:PGC 5V 117 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.mips: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | MIPS32 REGISTERS 36 | ================ 37 | 38 | NUMBER REGISTER NAME USAGE 39 | ------ ------------- ----- 40 | 0x00 ZERO ZERO 41 | 0x01 AT ASSEMBLER TEMP 42 | 0x02 V0 VALUE 0 43 | 0x03 V1 VALUE 1 44 | 0x04 A0 ARG 0 45 | 0x05 A1 ARG 1 46 | 0x06 A2 ARG 2 47 | 0x07 A3 ARG 3 48 | 0x08 T0 TEMP 0 49 | 0x09 T1 TEMP 1 50 | 0x0A T2 TEMP 2 51 | 0x0B T3 TEMP 3 52 | 0x0C T4 TEMP 4 53 | 0x0D T5 TEMP 5 54 | 0x0E T6 TEMP 6 55 | 0x0F T7 TEMP 7 56 | 0x10 S0 SAVED TEMP 0 57 | 0x11 S1 SAVED TEMP 1 58 | 0x12 S2 SAVED TEMP 2 59 | 0x13 S3 SAVED TEMP 3 60 | 0x14 S4 SAVED TEMP 4 61 | 0x15 S5 SAVED TEMP 5 62 | 0x16 S6 SAVED TEMP 6 63 | 0x17 S7 SAVED TEMP 7 64 | 0x18 T8 TEMP 8 65 | 0x19 T9 TEMP 9 66 | 0x1A K0 KERNEL 0 67 | 0x1B K1 KERNEL 1 68 | 0x1C GP GLOBAL POINTER 69 | 0x1D SP STACK POINTER 70 | 0x1E FP FRAME POINTER 71 | 0x1F RA RETURN ADDRESS 72 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.proton: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | RS-232 SERIAL 36 | ------------- 37 | RX TX GND 38 | 1 2 3 4 5 39 | x x x x x 40 | x x x x 41 | 6 7 8 9 42 | 43 | PROTON ICSP VELLEMAN K8048 ICSP 44 | ----------- ------------------- 45 | NC x x VPP 5 4 3 2 1 46 | NC x x NC x x x x x 47 | GND x x PGD P P V V V 48 | GND x x PGC G G S D P 49 | GND x x NC C D S D P 50 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.rkp28sb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | PIC18F2550 36 | ========== 37 | 38 | PINOUT 39 | ------ 40 | !MCLR VPP RE3 1-----28 RB7 KBI3 PGD 41 | RA0 AN0 2 27 RB6 KBI2 PGC 42 | RA1 AN1 3 26 RB5 KBI1 PGM 43 | RA2 AN2 VREF- CVREF 4 25 RB4 KBI0 AN11 44 | RA3 AN3 VREF+ 5 24 RB3 AN9 CCP2 VPO 45 | RA4 T0CKI C1OUT RCV 6 23 RB2 AN8 INT2 VMO 46 | RA5 AN4 !SS HLVDIN C2OUT 7 22 RB1 AN10 INT1 SCK SCL 47 | VSS GND 8 21 RB0 AN12 INT0 FLT0 SDI SDA 48 | OSC1 CLKI 9 20 VDD VCC 49 | OSC2 CLKO RA6 10 19 VSS GND 50 | RC0 T1OSO T13CKI 11 18 RC7 RX DT SDO 51 | RC1 T1OSI CCP2 !UOE 12 17 RC6 TX CK 52 | RC2 CCP1 13 16 RC5 D+ VP 53 | VUSB 14----15 RC4 D- VM 54 | 55 | J9 ICSP PIC18F2550 J6 PIC18F2550 56 | ------- ---------- --- ---------- 57 | 1:VPP !MCLR VPP RE3 10:RB1/SCL/SCK RB1 AN10 INT1 SCK SCL 58 | 2:VDD 5V VPIC 9:RB0/SDA/SDI RB0 AN12 INT0 FLT0 SDI SDA 59 | 3:VSS/GND GND 8:RA3/VREF RA3 AN3 VREF+ 60 | 4:PGD RB7 KBI3 PGD 7:GND GND 61 | 5:PGC RB6 KDI2 PGC 6:RB1/SCL/SCK RB1 AN10 INT1 SCK SCL 62 | 6:NC 5:RC7/RXD/SDO RC7 RX DT SDO 63 | 4:RB0/SDA/SDI RB0 AN12 INT0 FLT0 SDI SDA 64 | J5 POWER 3:RA5/TXD/SS RA5 AN4 !SS HLVDIN C2OUT 65 | -------- 2:RC1 RC1 T1OSI CCP2 !UOE 66 | 1:RST !MCLR VPP RE3 1:RC0 RC0 T1OSO T13CKI 67 | 2:3V3 +3V3 68 | 3:5V +5V J4 69 | 4:GND GND --- 70 | 5:GND GND 8:RB7 RB7 KBI3 PGD 71 | 6:VIN VIN 7:RB6 RB6 KBI2 PGC 72 | 6:RB5 RB5 KBI1 PGM 73 | J3 ANALOGUE 5:RC2 RC2 CCP1 74 | ----------- 4:RC4/D- RC4 D- VM 75 | 1:RA0/AN0 RA0 AN0 3:RC5/D+ RC5 D+ VP 76 | 2:RA1/AN1 RA1 AN1 2:RC6/TXD RC6 TX CK 77 | 3:RA2/AN2 RA2 AN2 VREF- CVREF 1:RC7/RXD/SDO RC7 RX DT SDO 78 | 4:RB2/AN3 RB2 AN8 INT2 VMO 79 | 5:RB3/AN4 RB3 AN9 CCP2 VPO 80 | 6:RB4/AN5 RB4 KBI0 AN11 81 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.serial: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | The Velleman programmer board has the following serial interface 36 | characteristics (D-SUB-9): 37 | 38 | D-SUB-9 ICSP 39 | ------- ---- 40 | OUTPUT 41 | 7 RTS -> PGC 5 42 | 4 DTR -> PGD 4 43 | 3 TX -> !MCLR/VPP 1 44 | INPUT 45 | 8 CTS <- PGD 4 46 | OTHER 47 | 9 <- 3 RI <- TX 48 | 49 | Although the interface connects to the serial port, it doesn't utilise 50 | the RS-232 serial protocol and instead I/O is performed with bit banging. 51 | 52 | Data output bits are sent through the DTR line and clocked on the falling 53 | edge of RTS. 54 | 55 | The Tx line is utilised to enable the application of the high programming 56 | voltage on !MCLR/VPP and not for sending data bits. 57 | 58 | Data input bits are read from the CTS line using the same clock as for 59 | output with the data output line taken high for correct circuit operation. 60 | 61 | D-SUB-9 62 | --------- 63 | 1 2 3 4 5 64 | 6 7 8 9 65 | 66 | 1:CD 67 | 2:Rx 68 | 3:Tx 69 | 4:DTR 70 | 5:GND 71 | 6:DSR 72 | 7:RTS 73 | 8:CTS 74 | 9:RI 75 | 76 | Flash dump test 77 | --------------- 78 | 79 | ttyS (SLEEP=0) 80 | -------------- 81 | 82 | > time k14 flash 2048 83 | ... 84 | 0.000u 0.704s 0:01.10 63.6% 0+0k 0+0io 0pf+0w 85 | 86 | > time k16 flash 16384 87 | ... 88 | 0.016u 7.816s 0:08.44 92.6% 0+0k 0+0io 0pf+0w 89 | 90 | D-SUB-9 voltage levels (PL-2303 USB SERIAL Adapter) 91 | --------------------------------------------------- 92 | 93 | > ktest 1 10 94 | 95 | TEST MODE 1 [D-SUB-9] D-SUB-9 96 | ------- 97 | Tx SET (+VE) (D-SUB-9 3) [10 seconds] CTS IN: 0 +6.91V 98 | Tx CLR (-VE) (D-SUB-9 3) [10 seconds] CTS IN: 0 -6.45V 99 | 100 | DTR SET (+VE) (D-SUB-9 4) [10 seconds] CTS IN: 0 +6.91V 101 | DTR CLR (-VE) (D-SUB-9 4) [10 seconds] CTS IN: 0 -6.45V 102 | 103 | RTS SET (+VE) (D-SUB-9 7) [10 seconds] CTS IN: 0 +6.91V 104 | RTS CLR (-VE) (D-SUB-9 7) [10 seconds] CTS IN: 0 -6.45V 105 | 106 | TEST DONE 107 | 108 | D-SUB-9 RTS 7 (PGC) mark time (Linux AMD64 3800+) 109 | ------------------------------------------------- 110 | 111 | ttyS 112 | ---- 113 | 114 | There was a 1.5us rise time. 115 | 116 | > ktest 3 0 117 | 118 | Sleep : none 119 | Time : 2.39us 120 | Reliable : no 121 | 122 | > ktest 3 1 123 | 124 | Sleep : io_usleep(1) 125 | Time : 5.56us 126 | Reliable : yes 127 | 128 | ttyUSB 129 | ------ 130 | 131 | Time was dependant upon usb_control_msg() which always took a minimum of 3ms. 132 | 133 | For reliable operation a sleep time of 500us is required. 134 | 135 | > ktest 3 0 136 | 137 | Sleep : none 138 | Time : 3ms 139 | Reliable : no 140 | 141 | > ktest 3 1 142 | 143 | Sleep : io_usleep(1) 144 | Time : 3ms 145 | Reliable : no 146 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.tools: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | gputils 36 | ======= 37 | 38 | $ apt-get install build-essential 39 | $ cd /usr/src 40 | $ wget http://downloads.sourceforge.net/project/gputils/gputils/1.2.0/gputils-1.2.0.tar.gz 41 | $ tar zxvf gputils-1.2.0.tar.gz 42 | $ cd gputils-1.2.0 43 | $ ./configure --prefix=/usr/local --disable-html-doc 44 | $ make 45 | $ make install 46 | 47 | gputils SVN 48 | =========== 49 | 50 | $ apt-get install build-essential subversion 51 | $ cd /usr/src 52 | $ svn checkout svn://svn.code.sf.net/p/gputils/code/trunk gputils-svn 53 | $ cd gputils-svn/gputils 54 | $ ./configure --prefix=/usr/local --disable-html-doc 55 | $ make 56 | $ make install 57 | $ gpasm -v 58 | gpasm-1.2.0 #1000 (Feb 26 2014) 59 | 60 | gputils for Windows 61 | =================== 62 | 63 | Install http://sf.net/projects/gputils/files/gputils-win32/1.2.0/gputils-1.2.0.exe/download 64 | 65 | When installation ends add gputils to the PATH in the dialog box (default). 66 | 67 | sdcc 68 | ==== 69 | 70 | $ apt-get install bison flex stx-btree-dev libgc-dev libboost-all-dev 71 | $ cd /usr/src 72 | $ wget http://downloads.sourceforge.net/project/sdcc/sdcc/3.3.0/sdcc-src-3.3.0.tar.bz2 73 | $ tar jxvf sdcc-src-3.3.0.tar.bz2 74 | $ cd sdcc-3.3.0 75 | $ ./configure --prefix=/usr/local --enable-libgc 76 | $ make 77 | $ make install 78 | 79 | sdcc SVN 80 | ======== 81 | 82 | $ apt-get install bison flex stx-btree-dev libgc-dev libboost-all-dev 83 | $ cd /usr/src 84 | $ svn checkout svn://svn.code.sf.net/p/sdcc/code/trunk sdcc-svn 85 | $ cd sdcc-svn/sdcc 86 | $ ./configure --prefix=/usr/local --enable-libgc 87 | $ make 88 | $ make install 89 | $ sdcc -v 90 | SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.3.2 #8953 (Feb 26 2014) (Linux) 91 | published under GNU General Public License (GPL) 92 | 93 | sdcc for Windows 94 | ================ 95 | 96 | Install http://sf.net/projects/sdcc/files/sdcc-win32/3.3.0/sdcc-3.3.0-setup.exe/download 97 | 98 | When installation ends add sdcc to the PATH in the dialog box (default). 99 | 100 | sdcc for the R-PI using a raspbian emulator 101 | =========================================== 102 | 103 | It is not possible to build sdcc natively on a raspberry pi model A due to 104 | memory contraints but we may build it on a high powered machine using an 105 | emulator. 106 | 107 | See: http://superpiadventures.com/2012/07/development-environment/ 108 | 109 | Install emulator on emulator host machine. 110 | 111 | $ apt-get install qemu-user-static 112 | $ apt-get install debootstrap 113 | $ mkdir -p /embedded/raspbian/dev 114 | $ mkdir -p /embedded/raspbian/proc 115 | $ mkdir -p /embedded/raspbian/sys 116 | $ qemu-debootstrap --no-check-gpg --arch armhf wheezy /embedded/raspbian http://archive.raspbian.org/raspbian 117 | 118 | Enter emulator and initialise. 119 | 120 | $ mount -o bind /dev /embedded/raspbian/dev 121 | $ mount -t proc proc /embedded/raspbian/proc 122 | $ mount -t sysfs sysfs /embedded/raspbian/sys 123 | $ setenv QEMU_CPU arm1176 124 | $ chroot /embedded/raspbian /bin/bash 125 | $ echo "deb http://archive.raspbian.org/raspbian/ wheezy main contrib non-free rpi" > /etc/apt/sources.list 126 | $ wget http://archive.raspbian.org/raspbian.public.key -O - | apt-key add - 127 | $ apt-get update 128 | $ apt-get install locales 129 | $ dpkg-reconfigure locales 130 | 131 | First compile gputils and then afterward sdcc without installing. 132 | 133 | Now archive the source directories on the emulator and copy them to the 134 | R-PI target machine. 135 | 136 | $ cd /embedded/raspbian/usr/src 137 | $ tar -zcf gputils-svn.tgz gputils-svn/gputils 138 | $ tar -zcf sdcc-svn.tgz sdcc-svn/sdcc 139 | $ scp *-svn.tgz pi@pi: 140 | 141 | On the R-PI target machine install gputils and sddc into /usr/local 142 | 143 | $ ssh pi@pi 144 | $ tar zxf gputils-svn.tgz 145 | $ tar zxf sdcc-svn.tgz 146 | $ cd ~/gputils-svn/gputils 147 | $ sudo make install 148 | $ cd ~/sdcc-svn/sdcc 149 | $ sudo make install 150 | 151 | XC16 C30/ASM30 for the R-PI using the raspbian emulator 152 | ======================================================= 153 | 154 | Fetch microchip X16 C30/ASM30 v1.21 for Linux. 155 | 156 | $ wget http://ww1.microchip.com/downloads/en/DeviceDoc/xc16-v1.21-linux-installer.run.tar 157 | 158 | Install microchip C30/ASM30 for Linux in /opt/microchip/xc16/v1.21 159 | 160 | $ tar xvf xc16-v1.21-linux-installer.run.tar 161 | $ chmod +x xc16-v1.21-linux-installer.run 162 | $ ./xc16-v1.21-linux-installer.run 163 | 164 | Copy microchip C30/ASM30 for Linux to emulator. 165 | 166 | $ mkdir -p /embedded/raspbian/opt/microchip/xc16/v1.21/ 167 | $ cd /embedded/raspbian/opt/microchip/xc16/v1.21/ 168 | $ cp -Rp /opt/microchip/xc16/v1.21/* . 169 | $ rm -Rf ./rollbackBackupDirectory 170 | 171 | Copy build scripts for microchip C30/ASM30 for Linux to emulator. 172 | 173 | $ rm -Rf /embedded/raspbian/opt/pic30* 174 | $ rm -Rf /embedded/raspbian/var/tmp/pic30* 175 | $ cp -Rp $HOME/k8048/Src/tools/pic30 /embedded/raspbian/var/tmp 176 | 177 | Fetch source for microchip C30/ASM30 for Linux. 178 | 179 | $ cd /embedded/raspbian/var/tmp/pic30 180 | $ wget http://ww1.microchip.com/downloads/en/DeviceDoc/XC16_v1_21_src.zip 181 | 182 | Enter emulator and build C30/ASM30 for raspbian. 183 | 184 | $ mount -o bind /dev /embedded/raspbian/dev 185 | $ mount -t proc proc /embedded/raspbian/proc 186 | $ mount -t sysfs sysfs /embedded/raspbian/sys 187 | $ setenv QEMU_CPU arm1176 188 | $ chroot /embedded/raspbian /bin/bash 189 | $ cd /var/tmp/pic30 190 | $ apt-get install unzip libelf-dev libgmp-dev libppl-dev libcloog-ppl-dev libz-dev 191 | $ ./install 192 | $ exit 193 | 194 | Create C30/ASM30 archive on the build host and copy to the R-PI target machine. 195 | 196 | $ cd /embedded/raspbian/opt 197 | $ tar zcf pic30-tools.tgz pic30-tools 198 | $ scp pic30-tools.tgz pi@pi: 199 | 200 | On the R-PI target machine extract the archive into /opt 201 | 202 | $ ssh pi@pi 203 | $ sudo -s 204 | $ cd /opt 205 | $ rm -Rf pic30-tools 206 | $ tar zxf ~/pic30-tools.tgz 207 | $ rm -f ~/pic30-tools.tgz 208 | 209 | PIC32 for the R-PI using CHIPKIT 210 | ================================ 211 | 212 | $ cd /opt/ 213 | $ wget http://chipkit.s3.amazonaws.com/compilers/pic32-tools-chipKIT-cxx-master-arm-linux-image.zip 214 | $ unzip pic32-tools-chipKIT-cxx-master-arm-linux-image.zip 215 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/doc/README.xino: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | The XINO Basic for PIC/PICAXE is compatible with any 18-pin device which has a 36 | UART with RX on pin 8 and TX on pin 11 (Eg. 16F88 but not 16F627) and has an 37 | internal oscillator. The on-board XTAL is not connected to the 18-pin socket. 38 | 39 | All 28-pin devices should be compatible which have a UART on pins 17 and 18. 40 | 41 | ------------------------------------------------------------------------------- 42 | 43 | PIC16F88 (REPLACING PICAXE 18M2 = PIC16F1847) 44 | ============================================= 45 | 46 | PINOUT 47 | ------ 48 | RA2 AN2 VREF- CVREF 1----18 RA1 AN1 49 | RA3 AN3 VREF+ C1OUT 2 17 RA0 AN0 50 | RA4 AN4 T0CKI C2OUT 3 16 RA7 OSC1 CLKI 51 | RA5 !MCLR VPP 4 15 RA6 OSC2 CLKO 52 | VSS/GND 5 14 VDD/VCC 53 | RB0 INT CCP1 6 13 RB7 AN6 PGD T1OSI 54 | RB1 SDI SDA 7 12 RB6 AN5 PGC T1OSO T1CKI 55 | RB2 SDO RX DT 8 11 RB5 !SS TX CK 56 | RB3 PGM CCP1 9----10 RB4 SCK SCL 57 | 58 | HEADER 59 | ------ 60 | P0 NC 15 NC 61 | P1 NC 14 5 VSS GND 62 | RST NC 13 10 RB4 SCK SCL 63 | 3V3 14 VDD/VCC JUMPER=3V3 12 7 RB1 SDI SDA 64 | 5V 14 VDD/VCC JUMPER=5V 11 15 RA6 OSC2 CLKO 65 | GND 5 VSS/GND 10 2 RA3 AN3 VREF+ C1OUT 66 | GND 5 VSS/GND 09 NC 67 | VIN NC 08 16 RA7 OSC1 CLKI 68 | 69 | A0 1 RA2 AN2 VREF- CVREF 07 NC 70 | A1 13 RB7 AN6 PGD T1OSI 06 NC 71 | A2 17 RA0 AN0 05 NC 72 | A3 18 RA1 AN1 04 9 RB3 PGM CCP1 73 | A4 3 RA4 AN4 T0CKI C2OUT 03 12 RB6 AN5 PGC T1OSO T1CKI 74 | A5 4 RA5 !MCLR VPP 02 6 RB0 INT CCP1 75 | 01 11 RB5 !SS TX CK 76 | SERIAL 00 8 RB2 SDO RX DT 77 | ------ 78 | RST NC JACK 79 | GND 5 VSS/GND ---- 80 | MCUPWR 14 VDD/VCC SLEEVE 2 RA3 81 | TX 11 RB5 !SS TX CK RING 3 RA4 82 | RX 8 RB2 SDO RX DT TIP GROUND 83 | 84 | ICSP 85 | ---- 86 | 1:VPP 12V A5 TIE WITH 9V1 ZENER FOR 9V HVP 87 | 2:VDD 5V 5V 88 | 3:VSS/GND GND 89 | 4:PGD A1 90 | 5:PGC 03 91 | PGM 04 TIE WITH 100K TO GND FOR HVP 92 | 93 | PIC18F2320 (REPLACING PICAXE 28X2 = PIC18F25K22) 94 | ================================================ 95 | 96 | PINOUT 97 | ------ 98 | !MCLR VPP 1----28 RB7 KBI3 PGD 99 | RA0 AN0 2 27 RB6 KBI2 PGC 100 | RA1 AN1 3 26 RB5 KBI1 PGM 101 | RA2 AN2 VREF- CVREF 4 25 RB4 KBI0 AN11 102 | RA3 AN3 VREF+ 5 24 RB3 AN9 CCP2 103 | RA4 T0CKI C1OUT 6 23 RB2 AN8 INT2 104 | RA5 AN4 !SS LVDIN C2OUT 7 22 RB1 AN10 INT1 105 | VSS GND 8 21 RB0 AN12 INT0 106 | OSC1 CLKI RA7 9 20 VDD VCC 107 | OSC2 CLKO RA6 10 19 VSS GND 108 | RC0 T1OSO T1CKI 11 18 RC7 RX DT 109 | RC1 T1OSI CCP2 12 17 RC6 TX CK 110 | RC2 CCP1 P1A 13 16 RC5 SDO 111 | RC3 SCK SCL 14---15 RC4 SDI SDA 112 | 113 | HEADER 114 | ------ 115 | P0 12 RC1 T1OSI CCP2 15 NC 116 | P1 13 RC2 CCP1 P1A 14 8/19 VSS GND 117 | RST 1 !MCLR VPP 13 14 RC3 SCK SCL 118 | 3V3 20 VDD/VCC JUMPER=3V3 12 15 RC4 SDI SDA 119 | 5V 20 VDD/VCC JUMPER=5V 11 16 RC5 SDO 120 | GND 8/19 VSS/GND 10 7 RA5 AN4 !SS LVDIN C2OUT 121 | GND 8/19 VSS/GND 09 28 RB7 KBI3 PGD 122 | VIN NC 08 27 RB6 KBI2 PGC 123 | 124 | A0 2 RA0 AN0 07 26 RB5 KBI1 PGM 125 | A1 3 RA1 AN1 06 25 RB4 KBI0 AN11 126 | A2 4 RA2 AN2 VREF- CVREF 05 24 RB3 AN9 CCP2 127 | A3 5 RA3 AN3 VREF+ 04 23 RB2 AN8 INT2 128 | A4 6 RA4 T0CKI C1OUT 03 22 RB1 AN10 INT1 129 | A5 11 RC0 T1OSO T1CKI 02 21 RB0 AN12 INT0 130 | 01 17 RC6 TX CK 131 | SERIAL 00 18 RC7 RX DT 132 | ------ 133 | RST 1 !MCLR VPP JACK XTAL 134 | GND 8 VSS/GND ---- ---- 135 | MCUPWR 20 VDD/VCC SLEEVE 7 RA5 9 OSC1 CLKI RA7 136 | TX 17 RC6 TX CK RING 6 RA4 10 OSC2 CLKO RA6 137 | RX 18 RC7 RX DT TIP GROUND 138 | 139 | ICSP 140 | ---- 141 | 1:VPP 12V RST TIE WITH 9V1 ZENER FOR 9V HVP 142 | 2:VDD 5V 5V 143 | 3:VSS/GND GND 144 | 4:PGD 09 145 | 5:PGC 08 146 | PGM 07 TIE WITH 100K TO GND FOR HVP 147 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "k8048.h" 34 | 35 | /* 36 | * Dot file 37 | */ 38 | void 39 | getdotfile(struct k8048 *k) 40 | { 41 | char dir[STRLEN], *filename, *homedir, *username; 42 | 43 | filename = getenv("K8048"); 44 | if (filename != NULL && access(filename, R_OK) == 0) { 45 | snprintf(k->dotfile, STRLEN, "%s", filename); 46 | return; 47 | } 48 | 49 | if (getcwd(dir, STRLEN) == NULL) { 50 | printf("%s: fatal error: getcwd failed\n", __func__); 51 | io_exit(k, EX_OSERR); /* Panic */ 52 | } 53 | 54 | snprintf(k->dotfile, STRLEN, "%s/%s", dir, DOTFILENAME); 55 | if (access(k->dotfile, R_OK) == 0) { 56 | return; 57 | } 58 | 59 | homedir = getenv("HOME"); 60 | if (homedir != NULL) { 61 | snprintf(k->dotfile, STRLEN, "%s/%s", homedir, DOTFILENAME); 62 | if (access(k->dotfile, R_OK) == 0) { 63 | return; 64 | } 65 | } 66 | 67 | username = getenv("USER"); 68 | if (username != NULL) { 69 | snprintf(k->dotfile, STRLEN, "/home/%s/%s", username, DOTFILENAME); 70 | if (access(k->dotfile, R_OK) == 0) { 71 | return; 72 | } 73 | } 74 | 75 | /* No dot file available */ 76 | k->dotfile[0] = '\0'; 77 | } 78 | 79 | /* 80 | * Configuration 81 | */ 82 | void 83 | getconf(struct k8048 *k, char *e) 84 | { 85 | FILE *f1; 86 | char line[STRLEN]; 87 | 88 | /* Configure defaults */ 89 | bzero(k, sizeof(struct k8048)); 90 | k->bitrules = (PGD_IN_PULLUP | PGD_OUT_FLIP | PGC_OUT_FLIP | VPP_OUT_FLIP | PGD_IN_FLIP); 91 | k->sleep_low = 1; 92 | k->sleep_high = 1; 93 | k->fwsleep = 30; 94 | 95 | /* Configure I/O defaults */ 96 | io_config(k); 97 | 98 | /* Load dot file if available */ 99 | getdotfile(k); 100 | #ifdef DEBUG 101 | printf("%s: DOTFILE=%s\n", __func__, k->dotfile); 102 | #endif 103 | if (k->dotfile[0] && (f1 = fopen(k->dotfile, "rb")) != NULL) { 104 | 105 | while (fgets(line, STRLEN, f1) != NULL) { 106 | line[strlen(line) - 1] = '\0'; /* Remove LF */ 107 | 108 | if (mystrcasestr(line, "DEVICE=") == line) { 109 | #ifdef DEBUG 110 | printf("%s: DEVICE=%s\n", __func__, &line[7]); 111 | #endif 112 | strncpy(k->device, &line[7], STRLEN); 113 | } 114 | else if (mystrcasestr(line, "SLEEP=") == line) { 115 | #ifdef DEBUG 116 | printf("%s: SLEEP=%s\n", __func__, &line[6]); 117 | #endif 118 | k->sleep_low = strtoul(&line[6], NULL, 0); 119 | k->sleep_high = k->sleep_low; 120 | } 121 | else if (mystrcasestr(line, "SLEEP_LOW=") == line) { 122 | #ifdef DEBUG 123 | printf("%s: SLEEP_LOW=%s\n", __func__, &line[10]); 124 | #endif 125 | k->sleep_low = strtoul(&line[10], NULL, 0); 126 | } 127 | else if (mystrcasestr(line, "SLEEP_HIGH=") == line) { 128 | #ifdef DEBUG 129 | printf("%s: SLEEP_HIGH=%s\n", __func__, &line[11]); 130 | #endif 131 | k->sleep_high = strtoul(&line[11], NULL, 0); 132 | } 133 | else if (mystrcasestr(line, "BITRULES=") == line) { 134 | #ifdef DEBUG 135 | printf("%s: BITRULES=%s\n", __func__, &line[9]); 136 | #endif 137 | k->bitrules = strtoul(&line[9], NULL, 0); 138 | } 139 | else if (mystrcasestr(line, "BUSY=") == line) { 140 | #ifdef DEBUG 141 | printf("%s: BUSY=%s\n", __func__, &line[5]); 142 | #endif 143 | k->busy = strtoul(&line[5], NULL, 0); 144 | } 145 | #if defined(RPI) || defined(BITBANG) 146 | else if (mystrcasestr(line, "VPP=") == line) { 147 | #ifdef DEBUG 148 | printf("%s: VPP=%s\n", __func__, &line[4]); 149 | #endif 150 | k->vpp = strtoul(&line[4], NULL, 0); 151 | } 152 | else if (mystrcasestr(line, "PGM=") == line) { 153 | #ifdef DEBUG 154 | printf("%s: PGM=%s\n", __func__, &line[4]); 155 | #endif 156 | k->pgm = strtoul(&line[4], NULL, 0); 157 | } 158 | else if (mystrcasestr(line, "PGC=") == line) { 159 | #ifdef DEBUG 160 | printf("%s: PGC=%s\n", __func__, &line[4]); 161 | #endif 162 | k->pgc = strtoul(&line[4], NULL, 0); 163 | } 164 | else if (mystrcasestr(line, "PGD=") == line) { 165 | #ifdef DEBUG 166 | printf("%s: PGD=%s\n", __func__, &line[4]); 167 | #endif 168 | k->pgdi = strtoul(&line[4], NULL, 0); 169 | k->pgdo = k->pgdi; 170 | } 171 | else if (mystrcasestr(line, "PGDO=") == line) { 172 | #ifdef DEBUG 173 | printf("%s: PGDO=%s\n", __func__, &line[5]); 174 | #endif 175 | k->pgdo = strtoul(&line[5], NULL, 0); 176 | } 177 | else if (mystrcasestr(line, "PGDI=") == line) { 178 | #ifdef DEBUG 179 | printf("%s: PGDI=%s\n", __func__, &line[5]); 180 | #endif 181 | k->pgdi = strtoul(&line[5], NULL, 0); 182 | } 183 | #endif /* RPI || BITBANG */ 184 | #ifdef MCP23017 185 | else if (mystrcasestr(line, "MCP=") == line) { 186 | #ifdef DEBUG 187 | printf("%s: MCP=%s\n", __func__, &line[4]); 188 | #endif 189 | k->mcp = strtoul(&line[4], NULL, 0); 190 | } 191 | #endif /* MCP23017 */ 192 | else if (mystrcasestr(line, "FWSLEEP=") == line) { 193 | #ifdef DEBUG 194 | printf("%s: FWSLEEP=%s\n", __func__, &line[8]); 195 | #endif 196 | k->fwsleep = strtoul(&line[8], NULL, 0); 197 | } 198 | else if (mystrcasestr(line, "DEBUG=") == line) { 199 | #ifdef DEBUG 200 | printf("%s: DEBUG=%s\n", __func__, &line[6]); 201 | #endif 202 | k->debug = strtoul(&line[6], NULL, 0); 203 | } 204 | } 205 | fclose(f1); 206 | } else { /* We are using the defaults */ 207 | snprintf(k->dotfile, STRLEN, "Using defaults (override in %s)", DOTFILENAME); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _DOTCONF_H 34 | #define _DOTCONF_H 35 | 36 | #define DOTFILENAME ".k8048" 37 | 38 | void getdotfile(struct k8048 *); 39 | void getconf(struct k8048 *, char *); 40 | 41 | #endif /* !_DOTCONF_H */ 42 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/HEADER.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | 3 | Copyright (C) 2005-2014 Darron Broad 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name `Darron Broad' nor the names of any contributors 18 | may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/HVP-RPI: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | #DEVICE=/dev/ttyUSB0 42 | DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | #SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | #BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | #BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | BITRULES=0x001B 99 | # MCP23017 I2C 100 | #BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | #BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | #VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | #PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | #PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | #PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | #PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | #VPP=9 162 | # PGM - RPi-Connect 12 163 | #PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | #PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | #PGD=11 168 | 169 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 170 | # = R-Pi HIGH VOLTAGE PROGRAMMER = 171 | # !MCLR/VPP 172 | VPP=9 173 | # PGM 174 | PGM=22 175 | # PGC CLOCK 176 | PGC=10 177 | # PGD DATA_OUT 178 | PGDO=11 179 | # PGD DATA_IN 180 | PGDI=7 181 | 182 | # MCP23017 I2C ADDRESS (README.i2c) 183 | # 184 | MCP=0x20 185 | 186 | # ICSP I/O per half-bit sleep time for `kio'. 187 | FWSLEEP=30 188 | 189 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 190 | DEBUG=1 191 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/K8048-RPI: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | #DEVICE=/dev/ttyUSB0 42 | DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | #SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | SLEEP=10 62 | # RASPBERRY PI GPIO 63 | #SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | #BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | #BITRULES=0x1000 99 | # MCP23017 I2C 100 | #BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | #BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | #VPP=9 162 | # PGM - RPi-Connect 12 163 | #PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | #PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | #PGD=11 168 | 169 | # MCP23017 I2C ADDRESS (README.i2c) 170 | # 171 | MCP=0x20 172 | 173 | # ICSP I/O per half-bit sleep time for `kio'. 174 | FWSLEEP=30 175 | 176 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 177 | DEBUG=1 178 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/K8048-ttyS0: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | DEVICE=/dev/ttyS0 41 | #DEVICE=/dev/ttyUSB0 42 | #DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | SLEEP=1 58 | # ttyUSB 59 | #SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | #SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # 85 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 86 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 87 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 88 | # 89 | # TTY VELLEMAN K8048 90 | BITRULES=0x001F 91 | # TTY VELLEMAN K8076 92 | #BITRULES=0x0010 93 | # RASPBERRY PI VELLEMAN K8048 94 | #BITRULES=0x0010 95 | # RASPBERRY PI GPIO 96 | #BITRULES=0x1000 97 | # MCP23017 I2C 98 | #BITRULES=0x1010 99 | # GPIO BIT-BANG 100 | #BITRULES=0x1000 101 | 102 | # I/O busy cursor (0=DISABLED) 103 | # 104 | BUSY=0 105 | 106 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 107 | # 108 | # TX/!MCLR/VPP - DSUB9(3) 109 | #VPP=14 110 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 111 | #PGM=22 112 | # RTS/PGC CLOCK - DSUB9(7) 113 | #PGC=15 114 | # DTR/PGD DATA_OUT - DSUB9(4) 115 | #PGDO=23 116 | # CTS/PGD DATA_IN - DSUB9(8) 117 | #PGDI=24 118 | 119 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 120 | # 121 | # TX/!MCLR/VPP - DSUB9(3) 122 | #VPP=14 123 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 124 | #PGM=22 125 | # RTS/PGC CLOCK - DSUB9(7) 126 | #PGC=18 127 | # DTR/PGD DATA_OUT - DSUB9(4) 128 | #PGDO=24 129 | # CTS/PGD DATA_IN - DSUB9(8) 130 | #PGDI=25 131 | 132 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 133 | # = SLICE OF PI/O = 134 | # !MCLR/VPP - PI/O G04 135 | #VPP=4 136 | # PGM - PI/O G22 137 | #PGM=22 138 | # PGC CLOCK - PI/O G25 139 | #PGC=25 140 | # PGD DATA_OUT - PI/O G24 141 | #PGDO=24 142 | # PGD DATA_IN - PI/O G23 143 | #PGDI=23 144 | 145 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 146 | # = SLICE OF PI/O = 147 | # !MCLR/VPP - PI/O G04 148 | #VPP=4 149 | # PGM - PI/O G22 150 | #PGM=22 151 | # PGC CLOCK - PI/O G25 152 | #PGC=25 153 | # PGD DATA_I/O - PI/O G24 154 | #PGD=24 155 | 156 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 157 | # = CHIPKIT PI = 158 | # !MCLR/VPP - RPi-Connect 18 159 | VPP=9 160 | # PGM - RPi-Connect 12 161 | PGM=22 162 | # PGC CLOCK - RPi-Connect 16 163 | PGC=10 164 | # PGD DATA_I/O - RPi-Connect 20 165 | PGD=11 166 | 167 | # MCP23017 I2C ADDRESS (README.i2c) 168 | # 169 | MCP=0x20 170 | 171 | # ICSP I/O per half-bit sleep time for `kio'. 172 | FWSLEEP=30 173 | 174 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 175 | DEBUG=1 176 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/K8048-ttyUSB0: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | DEVICE=/dev/ttyUSB0 42 | #DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | #SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | #BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | #BITRULES=0x1000 99 | # MCP23017 I2C 100 | #BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | #BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | #VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | #PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | #PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | #PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | #PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | VPP=9 162 | # PGM - RPi-Connect 12 163 | PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | PGD=11 168 | 169 | # MCP23017 I2C ADDRESS (README.i2c) 170 | # 171 | MCP=0x20 172 | 173 | # ICSP I/O per half-bit sleep time for `kio'. 174 | FWSLEEP=30 175 | 176 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 177 | DEBUG=1 178 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | clean: 34 | rm -f *~ 35 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/cp2102-ttyUSB0: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | DEVICE=/dev/ttyUSB0 42 | #DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | SLEEP=0 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | #SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | #BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | #BITRULES=0x1000 99 | # MCP23017 I2C 100 | #BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | #BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | #VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | #PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | #PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | #PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | #PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | VPP=9 162 | # PGM - RPi-Connect 12 163 | PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | PGD=11 168 | 169 | # MCP23017 I2C ADDRESS (README.i2c) 170 | # 171 | MCP=0x20 172 | 173 | # ICSP I/O per half-bit sleep time for `kio'. 174 | FWSLEEP=30 175 | 176 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 177 | DEBUG=1 178 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/cp2104-gpio: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty 38 | # 39 | DEVICE=/dev/ttyUSB0 40 | 41 | # For ttyS 1us is fine 42 | # For ttyUSB try 600us 43 | # 44 | # When SLEEP is set to zero no delay is taken 45 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 46 | # When SLEEP is less than 100 a busy loop is utilised 47 | # When SLEEP is >=100 then system usleep is used. 48 | # 49 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 50 | # 51 | # cuau0/ttyS 52 | #SLEEP=1 53 | # ttyUSB 54 | SLEEP=0 55 | 56 | # I/O bit rules. 57 | # These rules determine the polarity of the control lines and whether 58 | # data input requires data output pulled high. 59 | # 0x0001 PGD_OUT_FLIP 60 | # 0x0002 PGC_OUT_FLIP 61 | # 0x0004 VPP_OUT_FLIP 62 | # 0x0008 PGD_IN_FLIP 63 | # 0x0010 PGD_IN_PULLUP 64 | # 0x0020 PGM_OUT_FLIP 65 | # These rules are for GPIOs on program exit. 66 | # 0x0100 PGD_RELEASE 67 | # 0x0200 PGC_RELEASE 68 | # 0x0400 PGM_RELEASE 69 | # 0x0800 VPP_RELEASE 70 | # 0x1000 VPP_RUN 71 | # This rule enables shift with irq lock for GPIO BIT-BANG 72 | # 0x2000 BB_LOCK 73 | # 74 | BITRULES=0x0010 75 | 76 | # I/O busy cursor (0=DISABLED) 77 | # 78 | BUSY=1 79 | 80 | # CP2104 GPOI Ports are fixed - only for record here 81 | # !MCLR/VPP 82 | VPP=1 83 | # PGM Programming 84 | PGM=0 85 | # PGC CLOCK 86 | PGC=2 87 | # PGD Data 88 | PGD=3 89 | 90 | # ICSP I/O per half-bit sleep time for `kio'. 91 | FWSLEEP=30 92 | 93 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 94 | DEBUG=1 95 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/gpio-RPI: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | #DEVICE=/dev/ttyUSB0 42 | DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | #SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | #BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | #BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | BITRULES=0x1000 99 | # MCP23017 I2C 100 | #BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | #BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | #VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | #PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | #PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | #PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | #PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | VPP=9 162 | # PGM - RPi-Connect 12 163 | PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | PGD=11 168 | 169 | # MCP23017 I2C ADDRESS (README.i2c) 170 | # 171 | MCP=0x20 172 | 173 | # ICSP I/O per half-bit sleep time for `kio'. 174 | FWSLEEP=30 175 | 176 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 177 | DEBUG=1 178 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/gpio-bb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | #DEVICE=/dev/ttyUSB0 42 | #DEVICE=RPI 43 | #DEVICE=/dev/i2c-1 44 | DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | #SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | #SLEEP=1 64 | # MCP23017 I2C 65 | #SLEEP=0 66 | # GPIO BIT-BANG 67 | SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | #BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | #BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | #BITRULES=0x1000 99 | # MCP23017 I2C 100 | #BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | #VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | #PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | #PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | #PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | #PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | VPP=9 162 | # PGM - RPi-Connect 12 163 | PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | PGD=11 168 | 169 | # MCP23017 I2C ADDRESS (README.i2c) 170 | # 171 | MCP=0x20 172 | 173 | # ICSP I/O per half-bit sleep time for `kio'. 174 | FWSLEEP=30 175 | 176 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 177 | DEBUG=1 178 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/dotconf/i2c-mcp23017: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005-2014 Darron Broad 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # 3. Neither the name `Darron Broad' nor the names of any contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | # 34 | # Copy this file to ~/.k8048 35 | # 36 | 37 | # I/O device: tty, ttyUSB, RPI, I2C (MCP23017) or GPIO BIT-BANG 38 | # 39 | #DEVICE=/dev/cuau0 40 | #DEVICE=/dev/ttyS0 41 | #DEVICE=/dev/ttyUSB0 42 | #DEVICE=RPI 43 | DEVICE=/dev/i2c-1 44 | #DEVICE=/dev/gpio-bb 45 | 46 | # For ttyS 1us is fine 47 | # For ttyUSB try 600us 48 | # 49 | # When SLEEP is set to zero no delay is taken 50 | # When SLEEP is less than 10, then SLEEP x I/O bit time is taken for R-PI and tty 51 | # When SLEEP is less than 100 a busy loop is utilised 52 | # When SLEEP is >=100 then system usleep is used. 53 | # 54 | # For GPIO BIT-BANG SLEEP configures the low and high clock durations in the driver 55 | # 56 | # cuau0/ttyS 57 | #SLEEP=1 58 | # ttyUSB 59 | #SLEEP=600 60 | # RASPBERRY PI VELLEMAN K8048 61 | #SLEEP=10 62 | # RASPBERRY PI GPIO 63 | #SLEEP=1 64 | # MCP23017 I2C 65 | SLEEP=0 66 | # GPIO BIT-BANG 67 | #SLEEP=1 68 | 69 | # I/O bit rules. 70 | # These rules determine the polarity of the control lines and whether 71 | # data input requires data output pulled high. 72 | # 0x0001 PGD_OUT_FLIP 73 | # 0x0002 PGC_OUT_FLIP 74 | # 0x0004 VPP_OUT_FLIP 75 | # 0x0008 PGD_IN_FLIP 76 | # 0x0010 PGD_IN_PULLUP 77 | # 0x0020 PGM_OUT_FLIP 78 | # These rules are for GPIOs on program exit. 79 | # 0x0100 PGD_RELEASE 80 | # 0x0200 PGC_RELEASE 81 | # 0x0400 PGM_RELEASE 82 | # 0x0800 VPP_RELEASE 83 | # 0x1000 VPP_RUN 84 | # This rule enables shift with irq lock for GPIO BIT-BANG 85 | # 0x2000 BB_LOCK 86 | # 87 | # TTY VELLEMAN K8048 = PGD_IN_PULLUP + PGD_OUT_FLIP + PGC_OUT_FLIP + VPP_OUT_FLIP + PGD_IN_FLIP 88 | # TTY VELLEMAN K8076 = PGD_IN_PULLUP 89 | # RPI VELLEMAN K8048 = PGD_IN_PULLUP 90 | # 91 | # TTY VELLEMAN K8048 92 | #BITRULES=0x001F 93 | # TTY VELLEMAN K8076 94 | #BITRULES=0x0010 95 | # RASPBERRY PI VELLEMAN K8048 96 | #BITRULES=0x0010 97 | # RASPBERRY PI GPIO 98 | #BITRULES=0x1000 99 | # MCP23017 I2C 100 | BITRULES=0x1010 101 | # GPIO BIT-BANG 102 | #BITRULES=0x1000 103 | 104 | # I/O busy cursor (0=DISABLED) 105 | # 106 | BUSY=0 107 | 108 | # RASPBERRY PI VELLEMAN K8048 (README.raspi) 109 | # 110 | # TX/!MCLR/VPP - DSUB9(3) 111 | #VPP=14 112 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 113 | #PGM=22 114 | # RTS/PGC CLOCK - DSUB9(7) 115 | #PGC=15 116 | # DTR/PGD DATA_OUT - DSUB9(4) 117 | #PGDO=23 118 | # CTS/PGD DATA_IN - DSUB9(8) 119 | #PGDI=24 120 | 121 | # RASPBERRY PI VELLEMAN K8048 (http://dev.kewl.org/k8048/Images/K8048-RPI/) 122 | # 123 | # TX/!MCLR/VPP - DSUB9(3) 124 | #VPP=14 125 | # PGM - NOT SUPPORTED ON VELLEMAN K8048 126 | #PGM=22 127 | # RTS/PGC CLOCK - DSUB9(7) 128 | #PGC=18 129 | # DTR/PGD DATA_OUT - DSUB9(4) 130 | #PGDO=24 131 | # CTS/PGD DATA_IN - DSUB9(8) 132 | #PGDI=25 133 | 134 | # RASPBERRY PI GPIO (separate PGD DATA I/O) 135 | # = SLICE OF PI/O = 136 | # !MCLR/VPP - PI/O G04 137 | #VPP=4 138 | # PGM - PI/O G22 139 | #PGM=22 140 | # PGC CLOCK - PI/O G25 141 | #PGC=25 142 | # PGD DATA_OUT - PI/O G24 143 | #PGDO=24 144 | # PGD DATA_IN - PI/O G23 145 | #PGDI=23 146 | 147 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 148 | # = SLICE OF PI/O = 149 | # !MCLR/VPP - PI/O G04 150 | #VPP=4 151 | # PGM - PI/O G22 152 | #PGM=22 153 | # PGC CLOCK - PI/O G25 154 | #PGC=25 155 | # PGD DATA_I/O - PI/O G24 156 | #PGD=24 157 | 158 | # R-PI OR GPIO BIT-BANG (single PGD DATA I/O) 159 | # = CHIPKIT PI = 160 | # !MCLR/VPP - RPi-Connect 18 161 | VPP=9 162 | # PGM - RPi-Connect 12 163 | PGM=22 164 | # PGC CLOCK - RPi-Connect 16 165 | PGC=10 166 | # PGD DATA_I/O - RPi-Connect 20 167 | PGD=11 168 | 169 | # MCP23017 I2C ADDRESS (README.i2c) 170 | # 171 | MCP=0x20 172 | 173 | # ICSP I/O per half-bit sleep time for `kio'. 174 | FWSLEEP=30 175 | 176 | # Debug level (0=NONE, 1=ERROR, 10=INFO) 177 | DEBUG=1 178 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/gpio-bb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "gpio-bb.h" 42 | 43 | /* 44 | * File descriptor 45 | */ 46 | int gpio_bb_fd = -1; 47 | 48 | int 49 | gpio_bb_open(const char *device) 50 | { 51 | #ifdef __linux 52 | gpio_bb_fd = open(device, O_RDWR); 53 | if (gpio_bb_fd < 0) { 54 | printf("%s: warning: open failed [%s]\n", __func__, strerror(errno)); 55 | gpio_bb_fd = -1; 56 | return -1; 57 | } 58 | return gpio_bb_fd; 59 | #else 60 | return -1; 61 | #endif 62 | } 63 | 64 | void 65 | gpio_bb_close(void) 66 | { 67 | #ifdef __linux 68 | close(gpio_bb_fd); 69 | gpio_bb_fd = -1; 70 | #endif 71 | } 72 | 73 | int 74 | gpio_bb_io(struct gpio_bb_io *io) 75 | { 76 | #ifdef __linux 77 | return ioctl(gpio_bb_fd, GPIO_BB_IO, io); 78 | #else 79 | return -1 80 | #endif 81 | } 82 | 83 | int 84 | gpio_bb_configure(struct gpio_bb_config *config) 85 | { 86 | #ifdef __linux 87 | return ioctl(gpio_bb_fd, GPIO_BB_CONFIGURE, config); 88 | #else 89 | return -1 90 | #endif 91 | } 92 | 93 | int 94 | gpio_bb_shift(struct gpio_bb_shift *shift) 95 | { 96 | #ifdef __linux 97 | return ioctl(gpio_bb_fd, GPIO_BB_SHIFT, shift); 98 | #else 99 | return -1; 100 | #endif 101 | } 102 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/gpio-bb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _GPIO_BB_H 34 | #define _GPIO_BB_H 35 | 36 | struct gpio_bb_io { 37 | uint8_t dir; 38 | uint8_t pin; 39 | uint8_t bit; 40 | }; 41 | 42 | struct gpio_bb_config { 43 | uint8_t clock_pin; 44 | uint8_t clock_falling; 45 | uint8_t data_pin_input; 46 | uint8_t data_pin_output; 47 | uint8_t clock_delay_low; 48 | uint8_t clock_delay_high; 49 | uint8_t lock; 50 | }; 51 | 52 | struct gpio_bb_shift { 53 | uint8_t dir; 54 | uint8_t nbits; 55 | uint64_t bits; 56 | }; 57 | 58 | #define GPIO_BB_MAX (256) 59 | 60 | #define GPIO_BB_MAJOR (180) 61 | #define GPIO_BB_IO _IOWR(GPIO_BB_MAJOR, 100, struct gpio_bb_io *) 62 | #define GPIO_BB_CONFIGURE _IOW(GPIO_BB_MAJOR, 101, struct gpio_bb_config *) 63 | #define GPIO_BB_SHIFT _IOWR(GPIO_BB_MAJOR, 102, struct gpio_bb_shift *) 64 | 65 | #ifndef __KERNEL__ 66 | int gpio_bb_open(const char *); 67 | void gpio_bb_close(void); 68 | int gpio_bb_io(struct gpio_bb_io *); 69 | int gpio_bb_configure(struct gpio_bb_config *); 70 | int gpio_bb_shift(struct gpio_bb_shift *); 71 | #endif 72 | 73 | #endif /* _GPIO_BB_H */ 74 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/inhx32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _INHX32_H 34 | #define _INHX32_H 35 | 36 | /* intel hex format 32 definitions */ 37 | #define BB (1) 38 | #define AAAA (3) 39 | #define TT (7) 40 | #define HHHH (9) 41 | #define TT_DATA (0) 42 | #define TT_EOF (1) 43 | #define TT_EXTENDED_SEGMENT_ADDRESS (2) 44 | #define TT_START_SEGMENT_ADDRESS (3) 45 | #define TT_EXTENDED_LINEAR_ADDRESS (4) 46 | #define TT_START_LINEAR_ADDRESS (5) 47 | 48 | /* 49 | * a program data line 50 | */ 51 | #define BYTESMAX (256) 52 | typedef struct { 53 | uint32_t address; 54 | uint16_t bytes[BYTESMAX]; 55 | uint16_t nbytes; 56 | } inhx32_data; 57 | 58 | /* prototypes */ 59 | uint8_t inhx32_gethexn(char); 60 | uint8_t inhx32_gethexb(char *); 61 | int inhx32_compare(const void *, const void *); 62 | void inhx32_order(const void *, VISIT, int); 63 | uint32_t inhx32(struct k8048 *, const char *, uint32_t); 64 | void inhx32_free(struct k8048 *); 65 | 66 | #endif /* !_INHX32_H */ 67 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/k8048.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _K8048_H 34 | #define _K8048_H 35 | 36 | #undef DEBUG 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #ifndef O_NDELAY 59 | #define O_NDELAY O_NONBLOCK 60 | #endif 61 | 62 | #define LOW (0) 63 | #define HIGH (1) 64 | 65 | #ifndef FALSE 66 | #define FALSE (LOW) 67 | #endif 68 | 69 | #ifndef TRUE 70 | #define TRUE (HIGH) 71 | #endif 72 | 73 | #define STRLEN (1024) 74 | #define STRMAX (STRLEN - 1) 75 | 76 | #define UL_ON ("\033[4m") 77 | #define UL_OFF ("\033[0m") 78 | 79 | #define ARCH12BIT (0x00000FFF) 80 | #define ARCH14BIT (0x00003FFF) 81 | #define ARCH16BIT (0x0000FFFF) 82 | #define ARCH24BIT (0x00FFFFFF) 83 | #define ARCH32BIT (0xFFFFFFFF) /* UNIMPLEMENTED */ 84 | 85 | #define NOKEY (0) /* NO KEY IN OPERATION */ 86 | #define HVPKEY (1) /* HVP KEY IN OPERATION */ 87 | #define LVPKEY (2) /* LVP KEY IN OPERATION */ 88 | 89 | struct k8048; 90 | 91 | /* I/O backends */ 92 | #ifdef TTY 93 | #include "serial_posix.h" 94 | #endif 95 | #ifdef RPI 96 | #include "raspi.h" 97 | #endif 98 | #ifdef MCP23017 99 | #include "mcp23017.h" 100 | #endif 101 | #ifdef BITBANG 102 | #include "gpio-bb.h" 103 | #endif 104 | 105 | #include "util.h" 106 | #include "dotconf.h" 107 | #include "inhx32.h" 108 | #include "io.h" 109 | #include "pic.h" 110 | #include "pic12.h" 111 | #include "pic14.h" 112 | #include "pic16.h" 113 | #include "pic24.h" 114 | #include "pic32.h" 115 | 116 | struct k8048 { 117 | char dotfile[STRLEN]; /* configuration file name */ 118 | char device[STRLEN]; /* I/O device name: tty or rpi */ 119 | char devicename[STRLEN];/* overridden PICMicro device name */ 120 | uint16_t bitrules; /* I/O bit rules */ 121 | uint32_t key; /* MCHP LVP key */ 122 | uint32_t busy; /* I/O busy cursor speed */ 123 | uint32_t sleep_low; /* I/O clock low duration */ 124 | uint32_t sleep_high; /* I/O clock high duration */ 125 | uint32_t fwsleep; /* ICSPIO bit time */ 126 | uint32_t debug; /* default 0 (no debugging) */ 127 | uint8_t clock_falling; /* Clock falling edge for shifting in bits */ 128 | 129 | inhx32_data **pdata; /* hex32 data lines */ 130 | uint32_t count; /* hex32 data line count */ 131 | 132 | /* I/O backends */ 133 | uint8_t iot; /* I/O type (tty, rpi or i2c) */ 134 | #ifdef MCP23017 135 | int mcp; /* MCP23017 I2C address */ 136 | #endif 137 | #if defined(RPI) || defined(BITBANG) || defined(TTY) 138 | uint8_t vpp; /* TX/!MCLR/VPP */ 139 | uint8_t pgc; /* RTS/PGC CLOCK */ 140 | uint8_t pgdo; /* DTR/PGD DATA_OUT */ 141 | uint8_t pgdi; /* CTS/PGD DATA_IN */ 142 | uint8_t pgm; /* PGM OUT */ 143 | #endif 144 | /* Hardware operations */ 145 | struct pic_ops *pic; 146 | }; 147 | 148 | /* prototypes */ 149 | void usage_k8048(struct k8048 *); 150 | void usage_ktest(struct k8048 *, char *); 151 | void usage_k12(struct k8048 *, char *); 152 | void usage_k14(struct k8048 *, char *); 153 | void usage_k16(struct k8048 *, char *); 154 | void usage_k24(struct k8048 *, char *); 155 | void usage_k32(struct k8048 *, char *); 156 | void usage(struct k8048 *, char *, char *); 157 | int main(int, char **); 158 | 159 | #endif /* !_K8048_H */ 160 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/kio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _KIO_H 34 | #define _KIO_H 35 | 36 | #include "k8048.h" 37 | 38 | /* prototypes */ 39 | void usage(struct k8048 *, char *, char *); 40 | uint8_t getbytearg(struct k8048 *, char *, char *); 41 | uint16_t getshortarg(struct k8048 *, char *, char *); 42 | uint32_t get24arg(struct k8048 *, char *, char *); 43 | uint32_t getintarg(struct k8048 *, char *, char *); 44 | uint8_t getportarg(struct k8048 *, char *, char *); 45 | int main(int, char **); 46 | 47 | #endif /* !_KIO_H */ 48 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/mcp23017.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "k8048.h" 34 | 35 | /* 36 | * File descriptor 37 | */ 38 | static int mcp_fd = -1; 39 | 40 | /* 41 | * Shadow output 42 | */ 43 | static uint8_t mcp_latch; 44 | 45 | int 46 | mcp_open(const char *i2c_device, int address) 47 | { 48 | #ifdef __linux 49 | mcp_fd = open(i2c_device, O_RDWR); 50 | if (mcp_fd < 0) { 51 | mcp_fd = -1; 52 | return -1; /* Error */ 53 | } 54 | if (ioctl(mcp_fd, I2C_SLAVE, address) < 0) { 55 | close(mcp_fd); 56 | mcp_fd = -1; 57 | return -1; /* Error */ 58 | } 59 | 60 | /* Initialise mcp23017 */ 61 | mcp_set(MCP_IOCON, 0x00); 62 | 63 | /* All O/P except PGDI I/P */ 64 | mcp_set(MCP_IODIR, MCP_PGDI); 65 | 66 | /* All O/P low */ 67 | mcp_latch = 0; 68 | mcp_set(MCP_OUT, mcp_latch); 69 | 70 | return mcp_fd; /* Okay */ 71 | #else 72 | return -1; /* Unsupported */ 73 | #endif 74 | } 75 | 76 | void 77 | mcp_close(void) 78 | { 79 | close(mcp_fd); 80 | mcp_fd = -1; 81 | } 82 | 83 | void 84 | mcp_set(uint8_t reg, uint8_t val) 85 | { 86 | uint8_t buf[2]; 87 | 88 | buf[0] = reg; 89 | buf[1] = val; 90 | int rc = write(mcp_fd, buf, 2); 91 | if (rc != 2) { 92 | printf("%s: warning: unhandled error\n", __func__); 93 | } 94 | } 95 | 96 | void 97 | mcp_get(uint8_t reg, uint8_t *val) 98 | { 99 | uint8_t buf[1]; 100 | 101 | buf[0] = reg; 102 | int rc = write(mcp_fd, buf, 1); 103 | if (rc != 1) { 104 | printf("%s: warning: unhandled error\n", __func__); 105 | } 106 | rc = read(mcp_fd, buf, 1); 107 | if (rc != 1) { 108 | printf("%s: warning: unhandled error\n", __func__); 109 | } 110 | *val = buf[0]; 111 | } 112 | 113 | void 114 | mcp_set_pgd(int pgd) 115 | { 116 | if (pgd) 117 | mcp_latch |= MCP_PGDO; 118 | else 119 | mcp_latch &= ~MCP_PGDO; 120 | mcp_set(MCP_OUT, mcp_latch); 121 | } 122 | 123 | void 124 | mcp_set_pgc(int pgc) 125 | { 126 | if (pgc) 127 | mcp_latch |= MCP_PGC; 128 | else 129 | mcp_latch &= ~MCP_PGC; 130 | mcp_set(MCP_OUT, mcp_latch); 131 | } 132 | 133 | void 134 | mcp_set_pgm(int pgm) 135 | { 136 | if (pgm) 137 | mcp_latch |= MCP_PGM; 138 | else 139 | mcp_latch &= ~MCP_PGM; 140 | mcp_set(MCP_OUT, mcp_latch); 141 | } 142 | 143 | void 144 | mcp_set_vpp(int vpp) 145 | { 146 | if (vpp) 147 | mcp_latch |= MCP_VPP; 148 | else 149 | mcp_latch &= ~MCP_VPP; 150 | mcp_set(MCP_OUT, mcp_latch); 151 | } 152 | 153 | int 154 | mcp_get_pgd(void) 155 | { 156 | uint8_t pgd; 157 | 158 | mcp_get(MCP_IN, &pgd); 159 | 160 | return (pgd & MCP_PGDI) ? HIGH : LOW; 161 | } 162 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/mcp23017.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _MCP23017_H 34 | #define _MCP23017_H 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #ifdef __linux 44 | #include 45 | #endif 46 | 47 | #if 1 48 | /* 49 | * IOCON_BANK = 0 50 | */ 51 | #define IODIRA (0x00) 52 | #define IODIRB (0x01) 53 | #define IPOLA (0x02) 54 | #define IPOLB (0x03) 55 | #define GPINTENA (0x04) 56 | #define GPINTENB (0x05) 57 | #define DEFVALA (0x06) 58 | #define DEFVALB (0x07) 59 | #define INTCONA (0x08) 60 | #define INTCONB (0x09) 61 | #define IOCONA (0x0A) 62 | #define IOCONB (0x0B) 63 | #define GPPUA (0x0C) 64 | #define GPPUB (0x0D) 65 | #define INTFA (0x0E) 66 | #define INTFB (0x0F) 67 | #define INTCAPA (0x10) 68 | #define INTCAPB (0x11) 69 | #define GPIOA (0x12) 70 | #define GPIOB (0x13) 71 | #define OLATA (0x14) 72 | #define OLATB (0x15) 73 | #else 74 | /* 75 | * IOCON_BANK = 1 76 | */ 77 | #define IODIRA (0x00) 78 | #define IPOLA (0x01) 79 | #define GPINTENA (0x02) 80 | #define DEFVALA (0x03) 81 | #define INTCONA (0x04) 82 | #define IOCONA (0x05) 83 | #define GPPUA (0x06) 84 | #define INTFA (0x07) 85 | #define INTCAPA (0x08) 86 | #define GPIOA (0x09) 87 | #define OLATA (0x0A) 88 | #define IODIRB (0x10) 89 | #define IPOLB (0x11) 90 | #define GPINTENB (0x12) 91 | #define DEFVALB (0x13) 92 | #define INTCONB (0x14) 93 | #define IOCONB (0x15) 94 | #define GPPUB (0x16) 95 | #define INTFB (0x17) 96 | #define INTCAPB (0x18) 97 | #define GPIOB (0x19) 98 | #define OLATB (0x1A) 99 | #endif 100 | 101 | #define IOCONX_BANK (0x80) 102 | #define IOCONX_MIRROR (0x40) 103 | #define IOCONX_SEQOP (0x20) 104 | #define IOCONX_DISSLW (0x10) 105 | #define IOCONX_HAEN (0x08) 106 | #define IOCONX_ODR (0x04) 107 | #define IOCONX_INTPOL (0x02) 108 | #define IOCONX_U (0x01) 109 | 110 | /* 111 | * MCP23016 112 | */ 113 | #define GP0 (0x00) 114 | #define GP1 (0x01) 115 | #define OLAT0 (0x02) 116 | #define OLAT1 (0x03) 117 | #define IPOL0 (0x04) 118 | #define IPOL1 (0x05) 119 | #define IODIR0 (0x06) 120 | #define IODIR1 (0x07) 121 | #define INTCAP0 (0x08) 122 | #define INTCAP1 (0x09) 123 | #define IOCON0 (0x0A) 124 | #define IOCON1 (0x0B) 125 | 126 | /* mcp23017 i2c address (default) */ 127 | #define MCP_ADDR (0x020) 128 | 129 | /* I/O ports */ 130 | #define MCP_IOCON (IOCONA) 131 | #define MCP_IODIR (IODIRA) 132 | #define MCP_OUT (OLATA) 133 | #define MCP_IN (GPIOA) 134 | 135 | /* I/O bits */ 136 | #define MCP_VPP (0x01) 137 | #define MCP_PGC (0x02) 138 | #define MCP_PGDO (0x04) 139 | #define MCP_PGDI (0x08) 140 | #define MCP_PGM (0x10) 141 | 142 | int mcp_open(const char *, int); 143 | void mcp_close(void); 144 | void mcp_set(uint8_t, uint8_t); 145 | void mcp_get(uint8_t, uint8_t *); 146 | void mcp_set_pgm(int); 147 | void mcp_set_vpp(int); 148 | void mcp_set_pgd(int); 149 | void mcp_set_pgc(int); 150 | int mcp_get_pgd(void); 151 | 152 | #endif /* !_MCP23017_H */ 153 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/pic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _PIC_H 34 | #define _PIC_H 35 | 36 | /* ISCP OPERATIONS */ 37 | struct pic_ops { 38 | uint32_t arch; 39 | void (*selector)(void); 40 | void (*read_config_memory)(struct k8048 *, int); 41 | uint32_t (*get_program_size)(uint32_t *); 42 | uint32_t (*get_data_size)(uint32_t *); 43 | uint32_t (*get_executive_size)(uint32_t *); 44 | uint32_t (*read_program_memory_block)(struct k8048 *, uint32_t *, uint32_t, uint32_t); 45 | uint32_t (*read_data_memory_block)(struct k8048 *, uint16_t *, uint32_t, uint16_t); 46 | void (*program)(struct k8048 *, char *, int); 47 | uint32_t (*verify)(struct k8048 *, char *); 48 | void (*bulk_erase)(struct k8048 *k, uint16_t, uint16_t); 49 | void (*row_erase)(struct k8048 *, uint32_t, uint32_t); 50 | void (*dumpdeviceid)(struct k8048 *); 51 | void (*dumpconfig)(struct k8048 *, int); 52 | void (*dumposccal)(struct k8048 *); 53 | void (*dumpdevice)(struct k8048 *); 54 | void (*dumphexcode)(struct k8048 *, uint32_t, uint32_t, uint32_t *); 55 | void (*dumpinhxcode)(struct k8048 *, uint32_t, uint32_t, uint32_t *); 56 | void (*dumphexdata)(struct k8048 *, uint32_t, uint32_t, uint16_t *); 57 | void (*dumpinhxdata)(struct k8048 *, uint32_t, uint32_t, uint16_t *); 58 | }; 59 | 60 | /* ENHANCED MID-RANGE ICSP = MCHP (0x4D434850) */ 61 | #define MCHPKEY (0x4D434850) 62 | 63 | /* PIC18/dsPIC33/PIC24 EXECUTIVE = MCHP (0x4D434850) REVERSED */ 64 | #define PHCMKEY (0x0A12C2B2) 65 | 66 | /* PIC24 ICSP = MCHQ (0x4D434851) REVERSED */ 67 | #define QHCMKEY (0x8A12C2B2) 68 | 69 | /* dsPIC33F DS70152B-page 37 ICSP/STDP = ???? (0x5B982073) REVERSED */ 70 | #define P30FKEY (0xCE0419DA) 71 | 72 | void pic_x(struct k8048 *); /* DEBUGGING */ 73 | 74 | uint32_t pic_arch(struct k8048 *, const char *); 75 | 76 | int pic_cmp(const void *, const void *); 77 | #define PIC_NCOLS (5) 78 | void pic_selector(struct k8048 *); 79 | 80 | #define PIC_CONFIG_ONLY (0) 81 | #define PIC_CONFIG_ALL (1) 82 | void pic_read_config(struct k8048 *, int); 83 | 84 | uint32_t pic_get_program_size(struct k8048 *, uint32_t *); 85 | uint32_t pic_get_data_size(struct k8048 *, uint32_t *); 86 | uint32_t pic_get_executive_size(struct k8048 *, uint32_t *); 87 | 88 | uint32_t pic_read_program_memory_block(struct k8048 *, uint32_t *, uint32_t, uint32_t); 89 | uint32_t pic_read_data_memory_block(struct k8048 *, uint16_t *, uint32_t, uint16_t); 90 | 91 | #define PIC_VOID (0xFFFF) 92 | void pic_program(struct k8048 *, char *, int); 93 | uint32_t pic_verify(struct k8048 *, char *); 94 | 95 | #define PIC_INTERNAL (0xFFFF) 96 | #define PIC_NOINTERNAL (0xFFFE) 97 | void pic_writebandgap(struct k8048 *k, uint16_t); 98 | void pic_writeosccal(struct k8048 *, uint16_t); 99 | void pic_blank(struct k8048 *); 100 | 101 | #define PIC_ERASE_ID (UINT32_MAX) 102 | #define PIC_ERASE_CONFIG (PIC_ERASE_ID - 1) 103 | #define PIC_ERASE_EEPROM (PIC_ERASE_ID - 2) 104 | void pic_erase(struct k8048 *, uint32_t, uint32_t); 105 | 106 | void pic_dumpdeviceid(struct k8048 *); 107 | 108 | #define PIC_BRIEF (0) 109 | #define PIC_VERBOSE (1) 110 | void pic_dumpconfig(struct k8048 *); 111 | void pic_dumposccal(struct k8048 *); 112 | 113 | void pic_dumpaddr(uint32_t, int); 114 | void pic_dumpbyte(uint32_t, uint8_t); 115 | void pic_dumpword16(uint32_t, uint16_t); 116 | void pic_dumpword32(uint32_t, uint32_t); 117 | 118 | void pic_dumpdevice(struct k8048 *); 119 | 120 | void pic_dumpprogram(struct k8048 *, uint32_t); 121 | void pic_dumpdata(struct k8048 *); 122 | void pic_dumpexec(struct k8048 *); 123 | 124 | #define PIC_HEXDEC (1) 125 | #define PIC_INHX32 (2) 126 | #define PIC_CHAR(X) ((((X) >= ' ' && (X) < 127) ? (X) : ('.'))) 127 | void pic_dump_program(struct k8048 *, uint32_t, uint32_t, int); 128 | int pic_mtcode(uint32_t, uint32_t, uint32_t *); 129 | void pic_dumphexcode(struct k8048 *, uint32_t, uint32_t, uint32_t *); 130 | void pic_dumpinhxcode(struct k8048 *, uint32_t, uint32_t, uint32_t *); 131 | void pic_dump_data(struct k8048 *, uint32_t, uint32_t, int); 132 | int pic_mtdata(uint16_t, uint32_t, uint16_t *); 133 | void pic_dumphexdata(struct k8048 *, uint32_t, uint32_t, uint16_t *); 134 | void pic_dumpinhxdata(struct k8048 *, uint32_t, uint32_t, uint16_t *); 135 | 136 | #endif /* !_PIC_H */ 137 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/pic12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _PIC12_H 34 | #define _PIC12_H 35 | 36 | /****************************************************************************** 37 | * 12-bit CONFIGURATION 38 | *****************************************************************************/ 39 | 40 | #define PIC12_MASK (0x0FFF) 41 | 42 | struct pic12_config { 43 | uint16_t userid[4]; /* PIC16F505: 0x0400 */ 44 | uint16_t osccal_backup; /* PIC16F505: 0x0404 PIC12F519: 0x0444 */ 45 | uint16_t osccal_reset; /* PIC16F505: 0x03FF */ 46 | uint16_t config; /* PIC16F505: 0x07FF */ 47 | }; 48 | 49 | struct pic12_dsmap { 50 | char devicename[STRLEN]; 51 | uint32_t deviceid; /* derived from part number */ 52 | uint16_t flash; /* program flash size in words */ 53 | uint16_t dataflash; /* data flash size in bytes 0=none */ 54 | uint32_t datasheet; 55 | uint16_t backupaddr; /* osccal backup address (0=unsupported) */ 56 | uint16_t configaddr; 57 | uint8_t nlatches; 58 | }; 59 | 60 | #define PIC12_WORD(X) (((X) * 8192.0) / 12) /* KB to words */ 61 | 62 | /* 63 | * MEMORY MAP 64 | */ 65 | #if 0 66 | #define PIC12_CODE_LOW (0x0000) 67 | #endif 68 | #define PIC12_CODE_HIGH (0x07FF) /* 2K words (3KB) is the largest flash size available */ 69 | #define PIC12_CONFIG (0x0FFF) /* default config address */ 70 | 71 | /* 72 | * MEMORY REGIONS 73 | */ 74 | #define PIC12_REGIONNOTSUP (0) /* ? */ 75 | #define PIC12_REGIONCODE (1) /* 0 .. FLASH SIZE */ 76 | #define PIC12_REGIONCONFIG (2) /* 0xFFF */ 77 | 78 | /* 79 | * PROGRAM / ERASE 80 | */ 81 | #define PIC12_TPROG_DEFAULT (2000) /* 2ms DS41226G-page 18 */ 82 | #define PIC12_TERASE_DEFAULT (10000) /* 10ms DS41226G-page 18 */ 83 | #define PIC12_TDISCHARGE_DEFAULT (100) /* 100us DS41226G-page 18 */ 84 | #define PIC12_TDISCHARGE_300US (300) /* 300us DS41670A-page 20 */ 85 | 86 | /****************************************************************************** 87 | * PICMicro devices (12-bit word devices have no embedded device id) 88 | *****************************************************************************/ 89 | 90 | /* DS41228F PIC10F200/202/204/206 */ 91 | #define DS41228F (41228) 92 | #define PIC10F200 (10200) 93 | #define PIC10F202 (10202) 94 | #define PIC10F204 (10204) 95 | #define PIC10F206 (10206) 96 | 97 | /* DS41227E PIC12F508/509 */ 98 | #define DS41227E (41227) 99 | #define PIC12F508 (12508) 100 | #define PIC12F509 (12509) 101 | 102 | /* DS41207D PIC16F54 */ 103 | #define DS41207D (41207) 104 | #define PIC16F54 (1654) 105 | 106 | /* DS41208C PIC16F57 */ 107 | #define DS41208C (41208) 108 | #define PIC16F57 (1657) 109 | 110 | /* DS41243B PIC16F59 */ 111 | #define DS41243B (41243) 112 | #define PIC16F59 (1659) 113 | 114 | /* DS41226G PIC16F505 */ 115 | #define DS41226G (41226) 116 | #define PIC16F505 (16505) 117 | 118 | /* DS41258C PIC16F506 */ 119 | #define DS41258C (41258) 120 | #define PIC16F506 (16506) 121 | 122 | /* DS41257B PIC12F510 */ 123 | #define DS41257B (41257) 124 | #define PIC12F510 (12510) 125 | 126 | /* DS41266C PIC12F220/222 */ 127 | #define DS41266C (41266) 128 | #define PIC10F220 (10220) 129 | #define PIC10F222 (10222) 130 | 131 | /* DS41316C PIC12F519 */ 132 | #define DS41316C (41316) 133 | #define PIC12F519 (12519) 134 | 135 | /* DS41670A PIC16F570 */ 136 | #define DS41670A (41670) 137 | #define PIC16F570 (16570) 138 | 139 | /* DS41640A PIC16F527 */ 140 | #define DS41640A (41640) 141 | #define PIC16F527 (16527) 142 | 143 | /* DS41317B PIC16F526 */ 144 | #define DS41317B (41317) 145 | #define PIC16F526 (16526) 146 | 147 | /****************************************************************************** 148 | * PROTOTYPES 149 | *****************************************************************************/ 150 | 151 | uint32_t pic12_arch(struct k8048 *); 152 | void pic12_selector(void); 153 | void pic12_program_verify(struct k8048 *); 154 | void pic12_standby(struct k8048 *); 155 | uint16_t pic12_read_program_memory_increment(struct k8048 *); 156 | void pic12_read_config_memory(struct k8048 *, int); 157 | void pic12_bulk_erase(struct k8048 *, uint16_t, uint16_t); 158 | uint32_t pic12_get_program_size(uint32_t *); 159 | uint32_t pic12_get_data_size(uint32_t *); 160 | uint32_t pic12_read_program_memory_block(struct k8048 *, uint32_t *, uint32_t, uint32_t); 161 | uint32_t pic12_read_data_memory_block(struct k8048 *, uint16_t *, uint32_t, uint16_t); 162 | uint16_t pic12_read_osccal(struct k8048 *); 163 | uint32_t pic12_write_osccal(struct k8048 *, uint16_t); 164 | uint32_t pic12_write_config(struct k8048 *, uint16_t); 165 | void pic12_programregion(struct k8048 *, uint16_t, uint16_t, uint16_t); 166 | uint32_t pic12_verifyregion(struct k8048 *, uint16_t, uint16_t, uint16_t); 167 | void pic12_program(struct k8048 *, char*, int); 168 | uint32_t pic12_verify(struct k8048 *, char *); 169 | void pic12_dumpdeviceid(struct k8048 *); 170 | void pic12_dumposccal(struct k8048 *); 171 | void pic12_dumpconfig(struct k8048 *, int); 172 | void pic12_dumpconfig_verbose(struct k8048 *); 173 | void pic12_dumphexcode(struct k8048 *, uint32_t, uint32_t, uint32_t *); 174 | void pic12_dumpinhxcode(struct k8048 *, uint32_t, uint32_t, uint32_t *); 175 | void pic12_dumphexdata(struct k8048 *, uint32_t, uint32_t, uint16_t *); 176 | void pic12_dumpinhxdata(struct k8048 *, uint32_t, uint32_t, uint16_t *); 177 | void pic12_dumpdevice(struct k8048 *); 178 | #endif /* !_PIC12_H */ 179 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/raspi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "k8048.h" 34 | 35 | extern int io_stop; 36 | 37 | /* 38 | * Memory handle 39 | */ 40 | static int gpio_mem = -1; 41 | 42 | /* 43 | * Memory mapped I/O pointer 44 | */ 45 | static void *gpio_map = NULL; 46 | 47 | /* 48 | * I/O Pins 0..31 on headers P1 & P5 49 | */ 50 | static uint8_t gpio_pins[32], gpio_dirs[32]; 51 | 52 | /* 53 | * Map Raspberry-Pi GPIO memory 54 | */ 55 | int 56 | gpio_open(const char *device) 57 | { 58 | #ifdef RPI 59 | /* Open /dev/mem */ 60 | gpio_mem = open(device, O_RDWR | O_SYNC); 61 | if (gpio_mem < 0) { 62 | printf("%s: warning: open failed [%s]\n", __func__, strerror(errno)); 63 | gpio_mem = -1; 64 | return -1; 65 | } 66 | 67 | /* Memory map GPIO */ 68 | gpio_map = mmap(NULL, GPIO_MAP_LEN, PROT_READ | PROT_WRITE, MAP_SHARED, gpio_mem, GPIO_BASE_ADDR); 69 | if (gpio_map == MAP_FAILED) { 70 | printf("%s: warning: mmap failed [%s]\n", __func__, strerror(errno)); 71 | close(gpio_mem); 72 | gpio_mem = -1; 73 | return -1; 74 | } 75 | 76 | /* Reset used pin flags */ 77 | memset(&gpio_pins, 0, 32); 78 | 79 | return gpio_mem; 80 | #else 81 | return -1; /* Unsupported */ 82 | #endif 83 | } 84 | 85 | /* 86 | * Un-map Raspberry-Pi GPIO memory 87 | */ 88 | void 89 | gpio_close(void) 90 | { 91 | if (gpio_map) { 92 | if (munmap(gpio_map, GPIO_MAP_LEN)) { 93 | printf("%s: warning: munmap failed\n", __func__); 94 | } 95 | gpio_map = NULL; 96 | } 97 | if (gpio_mem >= 0) { 98 | if (close(gpio_mem)) { 99 | printf("%s: warning: close failed\n", __func__); 100 | } 101 | gpio_mem = -1; 102 | } 103 | } 104 | 105 | static inline void 106 | gpio_read(uint8_t gpio_reg, uint32_t *val) 107 | { 108 | GPIO_ADDR reg = (GPIO_ADDR)(gpio_map) + gpio_reg; 109 | 110 | *val = *reg; 111 | } 112 | 113 | void 114 | gpio_delay(void) 115 | { 116 | uint32_t val; 117 | 118 | gpio_read(GPLEV0, &val); 119 | } 120 | 121 | static inline void 122 | gpio_write(uint8_t gpio_reg, uint32_t val) 123 | { 124 | GPIO_ADDR reg = (GPIO_ADDR)(gpio_map) + gpio_reg; 125 | 126 | *reg = val; 127 | } 128 | 129 | static inline void 130 | gpio_pud(uint8_t pin, uint8_t pud) 131 | { 132 | gpio_write(GPPUD, pud); 133 | usleep(1); /* ? */ 134 | gpio_write(GPPUDCLK0, (1 << pin)); 135 | usleep(1); /* ? */ 136 | gpio_write(GPPUD, 0); 137 | gpio_write(GPPUDCLK0, 0); 138 | } 139 | 140 | static inline uint32_t 141 | gpio_gpfsel(uint8_t pin) 142 | { 143 | return /* GPFSEL0 + */(pin / 10); 144 | } 145 | 146 | static inline void 147 | gpio_select_input(uint8_t pin) 148 | { 149 | GPIO_ADDR reg = (GPIO_ADDR)(gpio_map) + gpio_gpfsel(pin); 150 | 151 | uint32_t val = ~(7 << ((pin % 10) * 3)); 152 | *reg &= val; /* 000 = Input */ 153 | 154 | gpio_dirs[pin] = 1; 155 | } 156 | 157 | static inline void 158 | gpio_select_output(uint8_t pin) 159 | { 160 | GPIO_ADDR reg = (GPIO_ADDR)(gpio_map) + gpio_gpfsel(pin); 161 | 162 | uint32_t val = 1 << ((pin % 10) * 3); 163 | *reg |= val; /* 001 = Output */ 164 | 165 | gpio_dirs[pin] = 0; 166 | } 167 | 168 | int 169 | gpio_get(uint8_t pin, uint8_t *level) 170 | { 171 | if (pin > 31) 172 | return -1; 173 | 174 | if (gpio_pins[pin] == 0) { 175 | gpio_pins[pin] = 1; 176 | gpio_pud(pin, GPPUD_UP); 177 | gpio_select_input(pin); 178 | } 179 | else if (gpio_dirs[pin] == 0) { 180 | gpio_select_input(pin); 181 | } 182 | 183 | uint32_t val; 184 | 185 | gpio_read(GPLEV0, &val); 186 | 187 | *level = (val & (1 << pin)) ? (HIGH) : (LOW); 188 | 189 | return 0; 190 | } 191 | 192 | int 193 | gpio_set(uint8_t pin, uint8_t level) 194 | { 195 | if (pin > 31) 196 | return -1; 197 | 198 | if (gpio_pins[pin] == 0) { 199 | gpio_pins[pin] = 1; 200 | gpio_pud(pin, GPPUD_UP); 201 | gpio_select_input(pin); 202 | gpio_select_output(pin); 203 | } 204 | else if (gpio_dirs[pin] == 1) { 205 | gpio_select_output(pin); 206 | } 207 | 208 | gpio_write((level) ? (GPSET0) : (GPCLR0), (1 << pin)); 209 | 210 | return 0; 211 | } 212 | 213 | int 214 | gpio_release(uint8_t pin) 215 | { 216 | if (pin > 31) 217 | return -1; 218 | 219 | gpio_pud(pin, GPPUD_OFF); 220 | if (gpio_dirs[pin] == 0) 221 | gpio_select_input(pin); 222 | 223 | return 0; 224 | } 225 | 226 | /* 227 | * Test GPIO pins 228 | */ 229 | void 230 | gpio_test(struct k8048 *k, int seconds) 231 | { 232 | uint8_t output_level = 0, input_level; 233 | 234 | printf("\nTEST MODE 4 [RPI GPIO] CTRL-C TO STOP\n"); 235 | 236 | while (!io_stop) { 237 | printf("\n"); 238 | 239 | gpio_set(k->vpp, output_level); 240 | printf("GPIO %-3d (VPP) (TX) = %d\n", k->vpp, output_level); 241 | 242 | if (k->pgm != GPIO_PGM_DISABLED) { 243 | gpio_set(k->pgm, output_level); 244 | printf("GPIO %-3d (PGM) = %d\n", k->pgm, output_level); 245 | } 246 | 247 | gpio_set(k->pgc, output_level); 248 | printf("GPIO %-3d (PGC) (RTS) = %d\n", k->pgc, output_level); 249 | 250 | gpio_set(k->pgdo, output_level); 251 | printf("GPIO %-3d (PGD) (DTR) = %d\n", k->pgdo,output_level); 252 | 253 | if (k->pgdi != k->pgdo) { 254 | gpio_get(k->pgdi, &input_level); 255 | printf("GPIO %02d (PGD) (CTS) = %d\n", k->pgdi, input_level); 256 | } 257 | 258 | fflush(stdout); 259 | 260 | sleep(seconds); 261 | output_level = 1 - output_level; 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/raspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _RASPI_H 34 | #define _RASPI_H 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | /* Access from ARM Running Linux */ 51 | #define BCM2708_PERI_BASE_ADDR (0x20000000) 52 | #define GPIO_BASE_ADDR (BCM2708_PERI_BASE_ADDR + 0x200000) 53 | #define GPIO_MAP_LEN (0x201000 - 0x200000) 54 | 55 | /* I/O access */ 56 | typedef volatile uint32_t *GPIO_ADDR; 57 | 58 | /* GPIO registers (32-bit) */ 59 | #define GPFSEL0 (0x00) 60 | #define GPFSEL1 (0x01) 61 | #define GPFSEL2 (0x02) 62 | #define GPFSEL3 (0x03) 63 | #define GPFSEL4 (0x04) 64 | #define GPFSEL5 (0x05) 65 | /* RESERVED 0x06 */ 66 | #define GPSET0 (0x07) 67 | #define GPSET1 (0x08) 68 | /* RESERVED 0x09 */ 69 | #define GPCLR0 (0x0A) 70 | #define GPCLR1 (0x0B) 71 | /* RESERVED 0x0C */ 72 | #define GPLEV0 (0x0D) 73 | #define GPLEV1 (0x0E) 74 | /* RESERVED 0x0F */ 75 | #define GPEDS0 (0x10) 76 | #define GPEDS1 (0x11) 77 | /* RESERVED 0x12 */ 78 | #define GPREN0 (0x13) 79 | #define GPREN1 (0x14) 80 | /* RESERVED 0x15 */ 81 | #define GPFEN0 (0x16) 82 | #define GPFEN1 (0x17) 83 | /* RESERVED 0x18 */ 84 | #define GPHEN0 (0x19) 85 | #define GPHEN1 (0x1A) 86 | /* RESERVED 0x1B */ 87 | #define GPLEN0 (0x1C) 88 | #define GPLEN1 (0x1D) 89 | /* RESERVED 0x1E */ 90 | #define GPAREN0 (0x1F) 91 | #define GPAREN1 (0x20) 92 | /* RESERVED 0x21 */ 93 | #define GPAFEN0 (0x22) 94 | #define GPAFEN1 (0x23) 95 | /* RESERVED 0x24 */ 96 | #define GPPUD (0x25) 97 | #define GPPUDCLK0 (0x26) 98 | #define GPPUDCLK1 (0x27) 99 | /* RESERVED 0x28 */ 100 | /* RESERVED 0x29 */ 101 | /* RESERVED 0x2A */ 102 | /* RESERVED 0x2B */ 103 | /* TEST 0x2C */ 104 | 105 | #define GPPUD_OFF (0) 106 | #define GPPUD_DOWN (1) 107 | #define GPPUD_UP (2) 108 | #define GPPUD_RESERVED (3) 109 | #define GPPUD_DELAY (150) 110 | 111 | int gpio_open(const char *); 112 | void gpio_close(void); 113 | 114 | void gpio_delay(void); 115 | int gpio_get(uint8_t, uint8_t *); 116 | int gpio_set(uint8_t, uint8_t); 117 | int gpio_release(uint8_t); 118 | void gpio_test(struct k8048 *k, int); 119 | 120 | #endif /* !_RASPI_H */ 121 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/serial_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "k8048.h" 34 | 35 | /* 36 | * File descriptor 37 | */ 38 | static int serial_port = -1; 39 | 40 | /* 41 | * 'open_serial_port()' - Open serial serial_port 1. 42 | * 43 | * Returns the file descriptor on success or -1 on error. 44 | */ 45 | int 46 | serial_open(const char *device) 47 | { 48 | struct termios options; 49 | 50 | serial_port = open(device, O_RDWR | O_NOCTTY | O_NDELAY); 51 | if (serial_port < 0) { 52 | serial_port = -1; 53 | return -1; 54 | } 55 | 56 | fcntl(serial_port, F_SETFL, O_NONBLOCK); 57 | 58 | /* 59 | * Get the current options for the serial_port... 60 | */ 61 | tcgetattr(serial_port, &options); 62 | 63 | /* 64 | * Enable the receiver 65 | */ 66 | options.c_cflag = IGNBRK | IGNPAR | CS8 | CREAD | CLOCAL; 67 | 68 | /* 69 | * Reset other options 70 | */ 71 | options.c_oflag = 0; 72 | options.c_lflag = 0; 73 | 74 | /* 75 | * Set the new options for the serial_port... 76 | */ 77 | tcsetattr(serial_port, TCSANOW, &options); 78 | 79 | return serial_port; 80 | } 81 | 82 | /* 83 | * Close serial serial_port 84 | */ 85 | void 86 | serial_close(void) 87 | { 88 | close(serial_port); 89 | serial_port = -1; 90 | } 91 | 92 | /* 93 | * Get CTS (input set when +ve) (DATA_IN) 94 | */ 95 | int 96 | get_cts(void) 97 | { 98 | #ifdef CP2104 99 | unsigned gpio; 100 | ioctl(serial_port, IOCTL_GPIOGET, &gpio); 101 | return (gpio & 0x00000008 ) ? (HIGH) : (LOW); 102 | #else 103 | int status; 104 | ioctl(serial_port, TIOCMGET, &status); 105 | 106 | return (status & TIOCM_CTS) ? (HIGH) : (LOW); 107 | #endif 108 | } 109 | 110 | #ifdef CP2104 111 | void 112 | reset_gpios(void) 113 | { 114 | 115 | unsigned gpio; 116 | /* reset all GPIOs */ 117 | gpio = 0x0000000F; 118 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); 119 | } 120 | #endif 121 | 122 | /* 123 | * Set DTR (output +ve on set) (DATA_OUT) 124 | */ 125 | void 126 | set_dtr(int dtr) 127 | { 128 | #ifdef CP2104 129 | unsigned gpio; 130 | if (dtr) { 131 | gpio = GPIO_3_ON; 132 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); 133 | } 134 | else { 135 | gpio = GPIO_3_OFF; 136 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); 137 | } 138 | #else 139 | int status; 140 | 141 | ioctl(serial_port, TIOCMGET, &status); 142 | 143 | if (dtr) 144 | status |= TIOCM_DTR; 145 | else 146 | status &= ~TIOCM_DTR; 147 | 148 | ioctl(serial_port, TIOCMSET, &status); 149 | #endif 150 | } 151 | 152 | /* 153 | * Set RTS (output +ve on set) (CLOCK) 154 | */ 155 | void 156 | set_rts(int rts) 157 | { 158 | #ifdef CP2104 159 | unsigned gpio; 160 | if (rts) { 161 | gpio = GPIO_2_ON; 162 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); /* -ve */ 163 | } 164 | else { 165 | gpio = GPIO_2_OFF; 166 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); /* +ve */ 167 | } 168 | #else 169 | int status; 170 | ioctl(serial_port, TIOCMGET, &status); 171 | 172 | if (rts) 173 | status |= TIOCM_RTS; 174 | else 175 | status &= ~TIOCM_RTS; 176 | 177 | ioctl(serial_port, TIOCMSET, &status); 178 | #endif 179 | } 180 | 181 | /* 182 | * Set Tx (output +ve on set) (VPP) 183 | */ 184 | void 185 | set_tx(int tx) 186 | { 187 | #ifdef CP2104 188 | unsigned gpio; 189 | if (tx) { 190 | gpio = GPIO_1_ON; 191 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); /* -ve */ 192 | } 193 | else { 194 | gpio = GPIO_1_OFF; 195 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); /* +ve */ 196 | } 197 | #else 198 | if (tx) 199 | ioctl(serial_port, TIOCSBRK, 0); /* +ve */ 200 | else 201 | ioctl(serial_port, TIOCCBRK, 0); /* -ve */ 202 | #endif 203 | } 204 | 205 | /* 206 | * Set GPIO0 (putput +ve on set) (PGM) 207 | */ 208 | 209 | #ifdef CP2104 210 | void 211 | set_gpio0(int gpio0) 212 | { 213 | unsigned gpio; 214 | 215 | if (gpio0) { 216 | gpio = GPIO_0_ON; 217 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); /* -ve */ 218 | } 219 | else { 220 | gpio = GPIO_0_OFF; 221 | ioctl(serial_port, IOCTL_GPIOSET, &gpio); /* +ve */ 222 | } 223 | } 224 | #endif 225 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/serial_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _SERIAL_POSIX_H 34 | #define _SERIAL_POSIX_H 35 | 36 | #include /* Standard input/output definitions */ 37 | #include /* String function definitions */ 38 | #include /* UNIX standard function definitions */ 39 | #include /* File control definitions */ 40 | #include /* Error number definitions */ 41 | #include /* POSIX terminal control definitions */ 42 | 43 | 44 | /* CP2104 IOCTLs */ 45 | #define IOCTL_GPIOGET 0x8000 46 | #define IOCTL_GPIOSET 0x8001 47 | /* CP2104 GPIO */ 48 | #define GPIO_0_ON 0x00010001 49 | #define GPIO_0_OFF 0x00000001 50 | #define GPIO_1_ON GPIO_0_ON << 1 51 | #define GPIO_1_OFF GPIO_0_OFF << 1 52 | #define GPIO_2_ON GPIO_0_ON << 2 53 | #define GPIO_2_OFF GPIO_0_OFF << 2 54 | #define GPIO_3_ON GPIO_0_ON << 3 55 | #define GPIO_3_OFF GPIO_0_OFF << 3 56 | 57 | /* 58 | * linux/cygwin 59 | */ 60 | #define SERIAL_DEVICE "/dev/ttyS0" 61 | 62 | int serial_open(const char *); 63 | void serial_close(void); 64 | 65 | int get_cts(void); 66 | void set_dtr(int); 67 | void set_rts(int); 68 | void set_tx(int); 69 | #ifdef CP2104 70 | void reset_gpios(void); 71 | void set_gpio0(int); 72 | #endif 73 | #endif 74 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "k8048.h" 34 | 35 | /****************************************************************************** 36 | * UTILITY FUNCTIONS 37 | *****************************************************************************/ 38 | 39 | /* 40 | * Are you sure? 41 | */ 42 | int 43 | areyousure(const char *s) 44 | { 45 | int c; 46 | 47 | printf("%s: are you sure [y/N]? ", s); 48 | c = fgetc(stdin); 49 | if (c == 'y' || c == 'Y') 50 | return 1; 51 | 52 | return 0; 53 | } 54 | 55 | /* 56 | * strcasestr implementation for cygwin 57 | */ 58 | const char * 59 | mystrcasestr(const char *haystack, const char *needle) 60 | { 61 | int i, j; 62 | int nlen = strlen(needle); 63 | int hlen = strlen(haystack) - nlen; 64 | 65 | for (i = 0; i <= hlen; i++) { 66 | for (j = 0; j < nlen; j++) { 67 | if (tolower((int)haystack[i + j]) != tolower((int)needle[j])) 68 | break; 69 | } 70 | if (j == nlen) { 71 | return &haystack[i]; 72 | } 73 | } 74 | return NULL; 75 | } 76 | -------------------------------------------------------------------------------- /k8048_cp2104/Src/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2014 Darron Broad 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name `Darron Broad' nor the names of any contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _UTIL_H 34 | #define _UTIL_H 35 | 36 | int areyousure(const char *s); 37 | const char *mystrcasestr(const char *, const char *); 38 | 39 | #endif /* !_UTIL_H */ 40 | --------------------------------------------------------------------------------