Add combined MCU and radio ATmega128rfa1

This commit is contained in:
dak664 2011-02-07 13:46:34 -05:00
parent ee65d0d887
commit f1f32c8e6a
9 changed files with 609 additions and 114 deletions

View file

@ -36,7 +36,43 @@
*/ \
TIMSK = _BV (OCIE0);
#elif defined (__AVR_ATmega1284P__) || (__AVR_AT90USB1287__) || (__AVR_ATmega1281__)
#elif defined (__AVR_ATmega128RFA1__) && 0
#define AVR_OUTPUT_COMPARE_INT TIMER0_COMPA_vect
#define OCRSetup() \
/* Select internal clock */ \
ASSR = 0x00; \
\
/* Set counter to zero */ \
TCNT0 = 0; \
\
/* \
* Set comparison register: \
* Crystal freq. is 8000000,\
* pre-scale factor is 1024, we want 125 ticks / sec: \
* 8000000 = 1024 * 126.01 * 62, less 1 for CTC mode \
*/ \
OCR0A = 61; \
\
/* \
* Set timer control register: \
* - prescale: 1024 (CS00 - CS02) \
* - counter reset via comparison register (WGM01) \
*/ \
TCCR0A = _BV(WGM01); \
TCCR0B = _BV(CS00) | _BV(CS02); \
\
/* Clear interrupt flag register */ \
TIFR0 = TIFR0; \
\
/* \
* Raise interrupt when value in OCR0 is reached. Note that the \
* counter value in TCNT0 is cleared automatically. \
*/ \
TIMSK0 = _BV (OCIE0A);
#elif defined (__AVR_ATmega1284P__) || (__AVR_AT90USB1287__) || (__AVR_ATmega1281__) || defined (__AVR_ATmega128RFA1__)
/*
The Raven has a 32768Hz watch crystal that can be used to clock the timer
while the 1284p is sleeping. The Jackdaw has pads for a crystal. The crystal

View file

@ -46,19 +46,42 @@ void clock_adjust_seconds(uint8_t howmany) {
#endif
}
/*---------------------------------------------------------------------------*/
/* These routines increment the second counters.
* Calling these avoids the interrupt overhead of pushing many registers on the stack.
*/
static void increment_seconds(void) __attribute__ ((noinline));
static void increment_seconds(void)
{
seconds++;
}
#if RADIOSTATS
extern volatile uint8_t rf230_calibrate;
static void increment_radioontime(void) __attribute__ ((noinline));
static void increment_radioontime(void)
{
static uint8_t calibrate_interval;
radioontime++;
if (++calibrate_interval==0) {
rf230_calibrate=1;
}
}
#endif
/*---------------------------------------------------------------------------*/
//SIGNAL(SIG_OUTPUT_COMPARE0)
ISR(AVR_OUTPUT_COMPARE_INT)
{
count++;
if(++scount == CLOCK_SECOND) {
scount = 0;
seconds++;
increment_seconds();
// seconds++;
}
#if RADIOSTATS
if (RF230_receive_on) {
if (++rcount == CLOCK_SECOND) {
rcount=0;
radioontime++;
increment_radioontime();
// radioontime++;
}
}
#endif

View file

@ -52,7 +52,7 @@
#define ADD_CARRAGE_RETURNS_TO_SERIAL_OUTPUT 1
#endif
#if defined (__AVR_ATmega128__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1281__)
#if defined (__AVR_ATmega128__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega128RFA1__)
typedef struct {
volatile uint8_t * UDR;
volatile uint8_t * UBRRH;

View file

@ -48,6 +48,8 @@
#include "dev/rs232_atmega1284.h"
#elif defined (__AVR_AT90USB1287__)
#include "dev/rs232_at90usb1287.h"
#elif defined (__AVR_ATmega128RFA1__)
#include "dev/rs232_atmega128rfa1.h"
#else
#error "Please implement a rs232 header for your MCU (or set the MCU type \
in contiki-conf.h)."