//
//
//
// Arduino Uno (atmega328p)
//
//
// PC -> Commodore Plus/4 Service Idler
//
// Source for a first test
//
// License: GPL
//
//
#include <avr/io.h>
/* Debug Display */
#include "lcd-routines.h"
#include <uart.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/delay.h>
/* Define UART buad rate here */
#define UART_BAUD_RATE 57600
#define ACK_PIN PINC
#define ACK_BIT PC5
int main(void)
{
unsigned int c;
uint8_t msb,lsb;
// data directions
// LSB , st0, st1
DDRB |= (1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3) | (1 << DDB4) | (1 << DDB5);
// MSB, dav, ack
DDRC |= (1 << DDC0) | (1 << DDC1) | (1 << DDC2) | (1 << DDC3) | (1 << DDC4) | (0 << DDC5);
// uart init
uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
sei();
// activate debug-display
// lcd init
// lcd_init();
// set status-bits
PORTB = PORTB | (1<<PB4) | (1<<PB5); // #%11
// Idler
for(;;)
{
c = uart_getc();
if ( c & UART_NO_DATA )
{
/*
* no data available from UART
*/
}
else
{
msb = c & 0xf0;
lsb = c & 0x0f;
msb = msb >>4;
PORTB = msb;
PORTC = lsb |= (1<<PC4);
loop_until_bit_is_set(ACK_PIN, ACK_BIT);
PORTC &= ~(1<<PC4);
}
}
}Letzte Änderung: 2019-01-06 09:51:35