diff --git a/cpu/avr/dev/clock-avr.h b/cpu/avr/dev/clock-avr.h index 97a79ee..f6ab5e5 100644 --- a/cpu/avr/dev/clock-avr.h +++ b/cpu/avr/dev/clock-avr.h @@ -73,7 +73,7 @@ TIMSK0 = _BV (OCIE0A); -#elif defined (__AVR_ATmega1284P__) || (__AVR_AT90USB1287__) || (__AVR_ATmega1281__) || defined (__AVR_ATmega128RFA1__) +#elif defined (__AVR_ATmega1284P__) || (__AVR_AT90USB1287__) || (__AVR_ATmega1281__) || defined (__AVR_ATmega128RFA1__) || defined (__AVR_ATmega256RFR2__) /* 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 diff --git a/cpu/avr/dev/rs232.c b/cpu/avr/dev/rs232.c index 94cf503..1530386 100644 --- a/cpu/avr/dev/rs232.c +++ b/cpu/avr/dev/rs232.c @@ -83,7 +83,7 @@ #define NUMPORTS RS232_CONF_NUMPORTS #endif -#if defined (__AVR_ATmega128__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega128RFA1__) +#if defined (__AVR_ATmega128__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) #ifndef NUMPORTS #define NUMPORTS 2 #elif NUMPORTS > 2 diff --git a/cpu/avr/dev/rs232.h b/cpu/avr/dev/rs232.h index 08a3d4f..b0e7a8f 100644 --- a/cpu/avr/dev/rs232.h +++ b/cpu/avr/dev/rs232.h @@ -49,6 +49,8 @@ #include "dev/rs232_at90usb1287.h" #elif defined (__AVR_ATmega128RFA1__) #include "dev/rs232_atmega128rfa1.h" +#elif defined (__AVR_ATmega256RFR2__) +#include "dev/rs232_atmega128rfa1.h" #elif defined (__AVR_ATmega644__) || defined (__AVR_ATmega328P__) #include "dev/rs232_atmega644.h" #elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8515__) \ diff --git a/cpu/avr/radio/rf230bb/hal.h b/cpu/avr/radio/rf230bb/hal.h index 737680d..f07a233 100644 --- a/cpu/avr/radio/rf230bb/hal.h +++ b/cpu/avr/radio/rf230bb/hal.h @@ -78,6 +78,7 @@ #define ZIGBIT 4 #define IRIS 5 #define ATMEGA128RFA1 6 +#define ATMEGA256RFR2 7 #if PLATFORM_TYPE == RCB_B /* 1281 rcb */ @@ -145,6 +146,11 @@ # define SLPTRPORT TRXPR # define SLPTRPIN 1 +#elif PLATFORM_TYPE == ATMEGA256RFR2 +/* ATmega1281 with internal AT86RF231 radio */ +# define SLPTRPORT TRXPR +# define SLPTRPIN 1 + #elif CONTIKI_TARGET_MULLE /* mulle 5.2 (TODO: move to platform specific) */ # define SSPORT 3 @@ -233,7 +239,7 @@ * that the source code can directly use. * \{ */ -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) #define hal_set_rst_low( ) ( TRXPR &= ~( 1 << TRXRST ) ) /**< This macro pulls the RST pin low. */ #define hal_set_rst_high( ) ( TRXPR |= ( 1 << TRXRST ) ) /**< This macro pulls the RST pin high. */ @@ -274,7 +280,7 @@ #define HAL_DD_SCK SCKPIN /**< Data Direction bit for SCK. */ #define HAL_DD_MOSI MOSIPIN /**< Data Direction bit for MOSI. */ #define HAL_DD_MISO MISOPIN /**< Data Direction bit for MISO. */ -#endif /* defined(__AVR_ATmega128RFA1__) */ +#endif /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ /** \} */ @@ -367,7 +373,7 @@ typedef struct{ void hal_init( void ); /* Hack for atmega128rfa1 with integrated radio. Access registers directly, not through SPI */ -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) //#define hal_register_read(address) _SFR_MEM8((uint16_t)address) #define hal_register_read(address) address uint8_t hal_subregister_read( uint16_t address, uint8_t mask, uint8_t position ); diff --git a/cpu/avr/radio/rf230bb/halbb.c b/cpu/avr/radio/rf230bb/halbb.c index 14ff572..00b390b 100644 --- a/cpu/avr/radio/rf230bb/halbb.c +++ b/cpu/avr/radio/rf230bb/halbb.c @@ -74,8 +74,9 @@ extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE]; #include "hal.h" #if defined(__AVR_ATmega128RFA1__) -#include #include "atmega128rfa1_registermap.h" +#elif defined(__AVR_ATmega256RFR2__) +#include "atmega256rfr2_registermap.h" #else #include "at86rf230_registermap.h" #endif @@ -88,7 +89,7 @@ volatile extern signed char rf230_last_rssi; /*============================ IMPLEMENTATION ================================*/ -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) /* AVR1281 with internal RF231 radio */ #include @@ -158,7 +159,7 @@ inline uint8_t spiWrite(uint8_t byte) /** \brief This function initializes the Hardware Abstraction Layer. */ -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) void hal_init(void) @@ -242,7 +243,7 @@ hal_init(void) #endif /* !__AVR__ */ -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) /* Hack for internal radio registers. hal_register_read and hal_register_write are handled through defines, but the preprocesser can't parse a macro containing another #define with multiple arguments, e.g. using @@ -279,7 +280,7 @@ hal_subregister_write(uint16_t address, uint8_t mask, uint8_t position, HAL_LEAVE_CRITICAL_REGION(); } -#else /* defined(__AVR_ATmega128RFA1__) */ +#else /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ /*----------------------------------------------------------------------------*/ /** \brief This function reads data from one of the radio transceiver's registers. * @@ -383,7 +384,7 @@ hal_subregister_write(uint8_t address, uint8_t mask, uint8_t position, /* Write the modified register value. */ hal_register_write(address, value); } -#endif /* defined(__AVR_ATmega128RFA1__) */ +#endif /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ /*----------------------------------------------------------------------------*/ /** \brief Transfer a frame from the radio transceiver to a RAM buffer * @@ -399,7 +400,7 @@ hal_subregister_write(uint8_t address, uint8_t mask, uint8_t position, void hal_frame_read(hal_rx_frame_t *rx_frame) { -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) uint8_t frame_length,*rx_data,*rx_buffer; @@ -432,7 +433,7 @@ hal_frame_read(hal_rx_frame_t *rx_frame) */ rx_frame->crc = true; -#else /* defined(__AVR_ATmega128RFA1__) */ +#else /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ uint8_t frame_length, *rx_data; @@ -487,7 +488,7 @@ hal_frame_read(hal_rx_frame_t *rx_frame) HAL_SPI_TRANSFER_CLOSE(); -#endif /* defined(__AVR_ATmega128RFA1__) */ +#endif /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ } /*----------------------------------------------------------------------------*/ @@ -500,7 +501,7 @@ hal_frame_read(hal_rx_frame_t *rx_frame) void hal_frame_write(uint8_t *write_buffer, uint8_t length) { -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) uint8_t *tx_buffer; tx_buffer=(uint8_t *)0x180; //start of fifo in i/o space /* Write frame length, including the two byte checksum */ @@ -518,7 +519,7 @@ hal_frame_write(uint8_t *write_buffer, uint8_t length) #endif do _SFR_MEM8(tx_buffer++)= *write_buffer++; while (--length); -#else /* defined(__AVR_ATmega128RFA1__) */ +#else /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ /* Optionally truncate length to maximum frame length. * Not doing this is a fast way to know when the application needs fixing! */ @@ -540,7 +541,7 @@ hal_frame_write(uint8_t *write_buffer, uint8_t length) do HAL_SPI_TRANSFER(*write_buffer++); while (--length); HAL_SPI_TRANSFER_CLOSE(); -#endif /* defined(__AVR_ATmega128RFA1__) */ +#endif /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ } /*----------------------------------------------------------------------------*/ @@ -632,7 +633,7 @@ volatile char rf230interruptflag; #define INTERRUPTDEBUG(arg) #endif -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) /* The atmega128rfa1 has individual interrupts for the integrated radio' * Whichever are enabled by the RF230 driver must be present even if not used! */ @@ -713,7 +714,7 @@ ISR(TRX24_CCA_ED_DONE_vect) rf230_ccawait=0; } -#else /* defined(__AVR_ATmega128RFA1__) */ +#else /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ /* Separate RF230 has a single radio interrupt and the source must be read from the IRQ_STATUS register */ HAL_RF230_ISR() { @@ -803,7 +804,7 @@ HAL_RF230_ISR() ; } } -#endif /* defined(__AVR_ATmega128RFA1__) */ +#endif /* defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) */ # endif /* defined(DOXYGEN) */ /** @} */ diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index c85608e..5b4de8f 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -212,7 +212,7 @@ static unsigned long total_time_for_transmission, total_transmission_len; static int num_transmissions; #endif -#if defined(__AVR_ATmega128RFA1__) +#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) volatile uint8_t rf230_wakewait, rf230_txendwait, rf230_ccawait; #endif @@ -583,7 +583,7 @@ radio_on(void) #if RF230BB_CONF_LEDONPORTE1 PORTE|=(1<