From 05e744a159e6c7b808b12e53b5ac231a8045bd8b Mon Sep 17 00:00:00 2001 From: travisutk Date: Sun, 25 Nov 2012 22:04:37 +0000 Subject: [PATCH] Forked donbfet to allow for Zigduino support. Not yet working. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1352 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/config.mk | 4 +- firmware/lib/atmega128rfa1.c | 171 ++++++++++++++++++++++++++++++++++ firmware/platforms/zigduino.h | 110 ++++++++++++++++++++++ 3 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 firmware/lib/atmega128rfa1.c create mode 100644 firmware/platforms/zigduino.h diff --git a/firmware/config.mk b/firmware/config.mk index f001b48..29a587a 100644 --- a/firmware/config.mk +++ b/firmware/config.mk @@ -150,8 +150,8 @@ endif ifneq (,$(findstring $(board),zigduino)) GCC := avr-gcc CC := avr-gcc -mcu ?= atmega1284p -platform = donbfet +mcu ?= atmega128rfa1 +platform = zigduino CFLAGS=$(DEBUG) -Iinclude -mmcu=$(mcu) -W -Os -mcall-prologues -Wall -Wextra -Wuninitialized -fpack-struct -fshort-enums -funsigned-bitfields config := monitor #avr spi endif diff --git a/firmware/lib/atmega128rfa1.c b/firmware/lib/atmega128rfa1.c new file mode 100644 index 0000000..81dcd2c --- /dev/null +++ b/firmware/lib/atmega128rfa1.c @@ -0,0 +1,171 @@ +#include "platform.h" + +#include +#include + +//! Receive a byte. +unsigned char serial0_rx(){ + while( !(UCSR0A & (1 << RXC0)) ); + return UDR0; +} + +//! Receive a byte. +unsigned char serial1_rx(){ + return 0; +} + +//! Transmit a byte. +void serial0_tx(unsigned char x){ + while (!(UCSR0A & (1< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* all AVR SRAM starts after I/O mapped memory and registers */ +#define RAMSTART 0x100 + +#ifndef PB0 +# define PB0 PORTB0 +#endif +#ifndef PA0 +# define PA0 PORTA0 +#endif +#ifndef PA1 +# define PA1 PORTA1 +#endif +#ifndef PA2 +# define PA2 PORTA2 +#endif +#ifndef PA3 +# define PA3 PORTA3 +#endif +#ifndef PA4 +# define PA4 PORTA4 +#endif +#ifndef PA5 +# define PA5 PORTA5 +#endif + +//LED on P1.0 +#define PLEDOUT PORTB +#define PLEDDIR DDRB +#define PLEDPIN PB0 + +//Use P3 instead of P5 for target I/O on chips without P5. +#ifdef msp430f2274 +//#warning "No P5, using P3 instead. Will break 2618 and 1612 support." +# define P5OUT P3OUT +# define P5DIR P3DIR +# define P5IN P3IN +# define P5REN P3REN + +# define SPIOUT P3OUT +# define SPIDIR P3DIR +# define SPIIN P3IN +# define SPIREN P3REN +#else + +# if (platform == zigduino) +# define SPIOUT PORTA +# define SPIDIR DDRA +# define SPIIN PINA +//# define SPIREN P5REN +# endif +#endif + +//This is how things used to work, don't do it anymore. +//#ifdef msp430x1612 +//#define P5REN somedamnedextern +//#endif + +#if (platform == zigduino) +# define SETSS PORTA|=SS; +# define CLRSS PORTA&=~SS; +# define DIRSS DDRA|=SS; +#else +//No longer works for Hope badge. +# define SETSS P5OUT|=BIT0 +# define CLRSS P5OUT&=~BIT0 +# define DIRSS P5DIR|=BIT0; +#endif + +//Used for the Nordic port, !RST pin on regular GoodFET. +#define SETCE P2OUT|=BIT6 +#define CLRCE P2OUT&=~BIT6 +#define DIRCE P2DIR|=BIT6 + +// network byte order converters +#define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \ + (((uint16_t)(x) & 0x00FF) << 8)) +#define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \ + (((uint32_t)(x) & 0x00FF0000) >> 8) | \ + (((uint32_t)(x) & 0x0000FF00) << 8) | \ + (((uint32_t)(x) & 0x000000FF) << 24)) + +#define ntohs htons +#define ntohl htonl + +extern uint8_t zigduino_get_byte(uint16_t); + -- 2.20.1