From 8169cdc6bfaab98925b08b1a1ec42aaf2a18acfe Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sun, 25 Dec 2016 21:39:33 +0100 Subject: [PATCH] Untested Arduino code for mega328 --- software/Arduino/.clang_complete | 2 +- software/Arduino/Makefile | 2 +- software/Arduino/ardusss7.cpp | 34 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/software/Arduino/.clang_complete b/software/Arduino/.clang_complete index d4055d8..d5f7eb5 100644 --- a/software/Arduino/.clang_complete +++ b/software/Arduino/.clang_complete @@ -1,5 +1,5 @@ -I../sss7core -I/usr/avr/include -I./arduino-1.6.13/hardware/arduino/avr/cores/arduino/ --D__AVR_ATmega2560__ +-D__AVR_ATmega328__ -DF_CPU=16000000 diff --git a/software/Arduino/Makefile b/software/Arduino/Makefile index bfd1165..9777ba2 100644 --- a/software/Arduino/Makefile +++ b/software/Arduino/Makefile @@ -1,4 +1,4 @@ -AVRMCU ?= atmega2560 +AVRMCU ?= atmega328 F_CPU ?= 16000000 ISPPORT ?= /dev/ttyUSB0 diff --git a/software/Arduino/ardusss7.cpp b/software/Arduino/ardusss7.cpp index 2fe4b56..ea2978d 100644 --- a/software/Arduino/ardusss7.cpp +++ b/software/Arduino/ardusss7.cpp @@ -33,31 +33,31 @@ void SSS7Wrapper::getReceived(uint8_t msg[SSS7_PAYLOAD_SIZE]) { void SSS7Wrapper::setupUart() { - UBRR2H = UBRR_VAL >> 8; // Setting baudrate - UBRR2L = UBRR_VAL & 0xFF; + UBRR0H = UBRR_VAL >> 8; // Setting baudrate + UBRR0L = UBRR_VAL & 0xFF; - UCSR2B = (1 << TXEN2) | (1 << RXEN2); // Enable TX and RX - UCSR2C = (1 << UCSZ21) | (1 << UCSZ20); // Asynchronous 8N1 + UCSR0B = (1 << TXEN0) | (1 << RXEN0); // Enable TX and RX + UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); // Asynchronous 8N1 // flush UDR do { - UDR2; + UDR0; } - while (UCSR2A & (1 << RXC2)); + while (UCSR0A & (1 << RXC0)); // reset tx and rx complete flags - UCSR2A = (1 << RXC2) | (1 << TXC2); + UCSR0A = (1 << RXC0) | (1 << TXC0); - UCSR2B |= (1 << TXCIE2) | (1 << RXCIE2); // enable tx and rx interrupts + UCSR0B |= (1 << TXCIE0) | (1 << RXCIE0); // enable tx and rx interrupts } void uart_put_byte(uint8_t byte) { - UDR2 = byte; + UDR0 = byte; } uint8_t uart_get_byte() { - return UDR2; + return UDR0; } ISR(USART2_RX_vect) { @@ -70,19 +70,19 @@ ISR(USART2_TX_vect) { void SSS7Wrapper::setupTimer() { - TCCR4B = 0; - TCNT4 = 65535 - 16000; //Preload for 16000 ticks to overflow + TCCR1B = 0; + TCNT1 = 65535 - 16000; //Preload for 16000 ticks to overflow // Take the Timer by force ... - TCCR4A = 0; - TCCR4B = (1 << CS40); // Prescaler 1 - TCCR4C = 0; + TCCR1A = 0; + TCCR1B = (1 << CS10); // Prescaler 1 + TCCR1C = 0; - TIMSK4 = (1 << TOIE4); + TIMSK1 = (1 << TOIE1); } ISR(TIMER4_OVF_vect) { - TCNT4 = 65535 - 16000; //Preload for 16000 ticks to overflow + TCNT1 = 65535 - 16000; //Preload for 16000 ticks to overflow sss7_process_ticks(sss7_timeout_increment); }