/* Copyright © 2020 tyrolyean
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#define F_CPU 16000000UL
#include
#include
#include
#include
#include
#include
#define BUS_HOLD_US 1
/* Shift values inside the PORTK Register */
#define WR_SHIFT 1
#define RD_SHIFT 2
#define MR_SHIFT 0
#define CS_SHIFT 3
#define CS_ADC_SHIFT 4
/* Registers in the 16550 UART */
#define UART_REG_DLLS 0
#define UART_REG_DLMS 1
#define UART_REG_TXRX 0
#define UART_REG_IER 1
#define UART_REG_IIR 2
#define UART_REG_LCR 3
#define UART_REG_MCR 4
#define UART_REG_LSR 5
#define UART_REG_MSR 6
#define UART_REG_SCR 7
uint8_t mcusr_mirror __attribute__ ((section (".noinit")));
void get_mcusr(void) \
__attribute__((naked)) \
__attribute__((section(".init3")));
void get_mcusr(void)
{
mcusr_mirror = MCUSR;
MCUSR = 0;
wdt_disable();
}
int routine();
void set_addr(uint8_t addr){
PORTK = addr;
return;
}
void write_to_16550(uint8_t addr, uint8_t data){
set_addr(addr);
DDRF = 0xFF;
PORTL &= ~(1<