Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit 237152f

Browse files
committed
First commit
0 parents  commit 237152f

File tree

15 files changed

+1179
-0
lines changed

15 files changed

+1179
-0
lines changed

LICENSE

+700
Large diffs are not rendered by default.

Makefile

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
PRJ = main
3+
MCU = atmega88p
4+
CLK = 8000000UL
5+
6+
# Libraries
7+
LIBSRC = $(wildcard *.c)
8+
LIBOBJ = $(LIBSRC:.c=.o)
9+
LIBHDR = $(LIBSRC:.c=.h)
10+
11+
# Compiler and linker settings
12+
CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(CLK) -I. -I$(LIBDIR) -Wall
13+
CFLAGS = -Os -g -std=gnu11 -Wall
14+
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
15+
CFLAGS += -ffunction-sections -fdata-sections
16+
LDFLAGS = -Wl,-Map,$(PRJ).map -mmcu=$(MCU)
17+
LDFLAGS += -Wl,--gc-sections
18+
19+
OBJCOPY = avr-objcopy
20+
OBJDUMP = avr-objdump
21+
SIZE = avr-size --format=avr --mcu=$(MCU)
22+
CC = avr-gcc
23+
24+
# Programmer settings
25+
PRG = apu2 -P ft0
26+
AVRDUDE = taskset -c 1 avrdude -c $(PRG) -p $(MCU) -C ~/.avrduderc -C /etc/avrdude.conf
27+
LFU = 0xE2
28+
HFU = 0xDF
29+
EFU = 0xFF
30+
31+
all: $(PRJ).hex
32+
33+
clean:
34+
rm -f *.hex *.elf *.o *.map $(LIBOBJ)
35+
36+
test:
37+
$(AVRDUDE) -v
38+
39+
flash: all
40+
$(AVRDUDE) -U flash:w:$(PRJ).hex:i
41+
42+
fuse:
43+
$(AVRDUDE) -U lfuse:w:$(LFU):m -B 1200 -U hfuse:w:$(HFU):m -U efuse:w:$(EFU):m
44+
45+
disasm: $(PRJ).elf
46+
$(OBJDUMP) -d $(PRJ).elf
47+
48+
%.o: %.c $(LIBHDR) Makefile
49+
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<;
50+
51+
$(PRJ).elf: $(LIBOBJ)
52+
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
53+
54+
$(PRJ).hex: $(PRJ).elf
55+
rm -f $(PRJ).hex
56+
$(OBJCOPY) -j .text -j .data -O ihex $(PRJ).elf $(PRJ).hex
57+
$(SIZE) $(PRJ).elf

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 4-port HDMI Switch
2+
3+
A pretty basic 4-port HDMI Switch design based on three Texas Instruments HD3SS215 2:1/1:2 Differential Switch ICs and ATmega88PA-AU microcontroller.
4+
5+
# Notes
6+
7+
Some kind of hot-air rework station is strongly recommended for soldering HD3SS215.
8+
9+
# Images
10+
11+
You can find more pictures in *extra/pictures*
12+
13+
![Switch](extra/pictures/Front.jpg)

common.h

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
Main definitions file for HDMI Switcher
3+
Copyright (C) 2018 pcm720 <[email protected]>
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see
17+
<http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef COMMON_H_
21+
#define COMMON_H_
22+
23+
#include <avr/io.h>
24+
#include <avr/interrupt.h>
25+
#include <util/delay.h>
26+
27+
/* switch states (used for outputState/selectedState)
28+
outputState/selectedState map:
29+
bits: 76543210
30+
76543: not used
31+
2: output (enabled — 1, disabled — 0)
32+
1: selected switch (SW1 — 1, SW2 — 0)
33+
0: selected port (A — 0, B — 1)
34+
*/
35+
#define OFF 0x0
36+
#define HDMI1 0x6 // 0b110
37+
#define HDMI2 0x7 // 0b111
38+
#define HDMI3 0x4 // 0b100
39+
#define HDMI4 0x5 // 0b101
40+
41+
// inputs (PORT D)
42+
#define B_OFF 0x1B
43+
#define B_HDMI1 0x1E
44+
#define B_HDMI2 0x1D
45+
#define B_HDMI3 0x17
46+
#define B_HDMI4 0x0F
47+
48+
// LEDs (PORT B)
49+
#define LED_HDMI1 0x0
50+
#define LED_HDMI2 0x1
51+
#define LED_HDMI3 0x6
52+
#define LED_HDMI4 0x7
53+
54+
// switch control pins configuration (PORT C)
55+
#define SW1_SW2_OE 0x28 // 0b101000
56+
#define SW3_OE 0x2 // 0b10
57+
#define Dx_SEL_MASK 0x15 // 0b010101
58+
#define PC_HDMI1 0x23 // 0b100011
59+
#define PC_HDMI2 0x33 // 0b110011
60+
#define PC_HDMI3 0xA // 0b001010
61+
#define PC_HDMI4 0xE // 0b001110
62+
63+
/*
64+
PC0 = SW3_Dx_SEL
65+
PC1 = SW3_OE
66+
PC2 = SW2_Dx_SEL
67+
PC3 = SW2_OE
68+
PC4 = SW1_Dx_SEL
69+
PC5 = SW1_OE
70+
71+
OFF HDMI1 HDMI2 HDMI3 HDMI4
72+
OE DxSEL OE DxSEL OE DxSEL OE DxSEL OE DxSEL
73+
SW1 LOW — HIGH LOW HIGH HIGH LOW — LOW —
74+
SW2 LOW — LOW — LOW — HIGH LOW HIGH HIGH
75+
SW3 LOW — HIGH HIGH HIGH HIGH HIGH LOW HIGH LOW
76+
*/
77+
78+
#endif

eeprom.c

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
EEPROM operations
3+
Copyright (C) 2018 pcm720 <[email protected]>
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see
17+
<http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include "eeprom.h"
21+
#include <avr/eeprom.h>
22+
#include <util/atomic.h>
23+
24+
static inline uint8_t calculate_parity(uint8_t* state);
25+
26+
uint8_t eeprom_read(uint8_t* state) {
27+
uint8_t parity_bit;
28+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
29+
eeprom_read_block((void*)state, (void*)0, sizeof(*state));
30+
parity_bit = ((*state >> 0x7) & 1); // get parity bit read from EEPROM
31+
*state &= ~0x80; // clear parity bit from state
32+
}
33+
if (calculate_parity(state) != parity_bit) return 1; // read failed
34+
else return 0;
35+
}
36+
37+
uint8_t eeprom_write(uint8_t state) {
38+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
39+
state = state + (calculate_parity(&state) << 0x7); // 8th bit of state is a parity bit
40+
eeprom_update_block((const void*)&state, (void*)0, sizeof(state));
41+
}
42+
return eeprom_read(&state); // if write failed, returns 1
43+
}
44+
45+
static inline uint8_t calculate_parity(uint8_t* state) {
46+
return ((*state >> 1) ^ (*state >> 2) ^ (*state >> 3)) & 1;
47+
}

eeprom.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Header file for EEPROM operations
3+
Copyright (C) 2018 pcm720 <[email protected]>
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see
17+
<http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef EEPROM_H_
21+
#define EEPROM_H_
22+
23+
#include "common.h"
24+
25+
uint8_t eeprom_read(uint8_t* state);
26+
uint8_t eeprom_write(uint8_t state);
27+
28+
#endif

extra/pcb_design/BOM.txt

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Reference | Value | Size | Count
2+
3+
Buttons:
4+
B1-B5 | 1243SHIM | 5
5+
6+
Diodes:
7+
D1 | BAT54 | SOT-23 | 1
8+
D2-D6 | KP-2012SGD | 5
9+
10+
Fuses:
11+
F1 | MF-MSMF050-2 | 1
12+
13+
HDMI Sockets:
14+
HDMI1-HDMI4 | DS1114-BN0 | 4
15+
HDMI5 | LOTES, Model # Unknown | 1
16+
17+
Headers:
18+
ISP1 | IDC-06MS/2.54 pin header | 1
19+
20+
USB Sockets:
21+
J1 | Molex_47346-0001 | 1
22+
23+
Resistors:
24+
R1-R4, R18 | 1M | 0805 | 5
25+
R5-R8 | 100k | 0805 | 4
26+
R10-R11 | 47k | 0805 | 2
27+
R14-R17, R19-R21, R27 | 10k | 0805 | 8
28+
R22-R25 | 200 | 0805 | 4
29+
R26 | 1k | 0805 | 1
30+
31+
32+
ICs:
33+
U1-U3 | HD3SS215RTQT | 3
34+
U4 | ATMEGA88PA-AU
35+
U5 | AMS1117-3.3
36+
37+
Capacitors:
38+
С1-C10, C12 | 0.1 uF | 0805 | 11
39+
С11, C13, C15, C17 | 100 nF | 0603 | 4
40+
С14, C16 | 47 uF 10V | Tantalum B | 2

extra/pcb_design/gerber.zip

192 KB
Binary file not shown.

extra/pcb_design/kicad.zip

151 KB
Binary file not shown.

extra/pictures/Back.jpg

7.96 MB
Loading

extra/pictures/Front.jpg

7.22 MB
Loading

extra/pictures/PCBs.jpg

7.39 MB
Loading

0 commit comments

Comments
 (0)