[tuxdroid-svn] r1316 - firmware/rf/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2008-07-09 09:04:08
|
Author: jaguarondi Date: 2008-07-09 11:04:09 +0200 (Wed, 09 Jul 2008) New Revision: 1316 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/init.c firmware/rf/trunk/misc.c firmware/rf/trunk/prot.c Log: * Some more cleanup. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-08 14:51:42 UTC (rev 1315) +++ firmware/rf/trunk/defines.h 2008-07-09 09:04:09 UTC (rev 1316) @@ -1,55 +1,31 @@ -//***************************************************************************** -//* Project: RF-Firmware Point to Multipoint for ISM - Transceiver ATR2406 * -//* Version: V1.0 * -//* File: defines.h * -//* Target MCU: ATMega88 * -//* Compiler: GCC * -//* Simulator: AVRStudio 4.08 * -//* Emulator: JTAG ICE * -//* Author: Christian Bechter * -//* Date: 31.01.06 * -//* Used Hardware: DEV-KIT-III * -//***************************************************************************** -//***************************************************************************** -//* Copyright 2006, Atmel Germany GmbH * -//* * -//* This software is owned by the Atmel Germany GmbH * -//* and is protected by and subject to worldwide patent protection. * -//* Atmel hereby grants to licensee a personal, * -//* non-exclusive, non-transferable license to copy, use, modify, create * -//* derivative works of, and compile the Atmel Source Code and derivative * -//* works for the sole purpose of creating custom software in support of * -//* licensee product to be used only in conjunction with a Atmel integrated * -//* circuit as specified in the applicable agreement. Any reproduction, * -//* modification, translation, compilation, or representation of this * -//* software except as specified above is prohibited without the express * -//* written permission of Atmel. * -//* * -//* Disclaimer: ATMEL MAKES NO WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, * -//* WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * -//* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -//* Atmel reserves the right to make changes without further notice to the * -//* materials described herein. Atmel does not assume any liability arising * -//* out of the application or use of any product or circuit described herein. * -//* Atmel does not authorize its products for use as critical components in * -//* life-support systems where a malfunction or failure may reasonably be * -//* expected to result in significant injury to the user. The inclusion of * -//* Atmel products in a life-support systems application implies that the * -//* manufacturer assumes all risk of such use and in doing so indemnifies * -//* Atmel against all charges. * -//* * -//* Use may be limited by and subject to the applicable Atmel software * -//* license agreement. * -//***************************************************************************** +/* + * [TF]UXRF - Firmware for the 2 RF CPU of tuxdroid (TUXRF and FUXRF) + * Copyright (C) 2007 KySoH S.A. <in...@ky...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id$ */ + #ifndef DEFINES_H #define DEFINES_H -//include defines for target MCU #include <avr/io.h> -#include <compat/ina90.h> +//#include <compat/ina90.h> #include <avr/interrupt.h> #include <avr/pgmspace.h> -#include <avr/eeprom.h> //**Define the used HOPPING SCHEME**// //#define HOPPING @@ -65,25 +41,16 @@ */ #define SCRAMBLE_BYTE 0x0F -#define TXEN 0x01 -#define RXEN 0x00 -#define CONNECTED 0x80 +#define TXEN 0x01 +#define RXEN 0x00 +#define CONNECTED 0x80 -#define TXING 0x08 -#define RXING 0x04 -#define MASTER 0x40 -#define SLAVE 0x80 +#define TXING 0x08 +#define RXING 0x04 +#define MASTER 0x40 +#define SLAVE 0x80 -//returns the address owned by the given label in registers R31:R30 -/* XXX ? delete? */ -#define GET_LABEL_ADDRESS(addr)\ -{\ - __asm__ __volatile__ ("\n"::"z"(addr));\ -} - -#define _NIX __asm__ __volatile__ ("nop") -//Hardware Definitions - +/* I/O ports for the ATR2406 */ #define CLOCK_PORT PORTD #define CLOCK_DDR DDRD #define CLOCK_OUT PD4 @@ -121,7 +88,8 @@ #define set_nole() (nOLE_PORT |= _BV(nOLE_OUT)) #define clr_nole() (nOLE_PORT &= ~_BV(nOLE_OUT)) -#define in_rxd input(PIND)&0x01 //# RXD PIND.0 +#define in_rxd (PIND & 0x01) + //Hardware Definitions //----->RF-Specifc-Defines<-----// @@ -129,107 +97,21 @@ #define CH00TX 27 /* S[SC] of channel 0 in RX mode, p. 10 of datasheet */ #define CH00RX 28 -//----->RF-Specifc-Defines<-----// - //T_SLOT == 1ms ==> every 1000us 48Bytes of payload are exchanged - #define POLL_LOOPS 4 - #define T_1ms 1728 //exact -> 1000us - #define T_PWR_UP_TX 69 //69 == 40us(39.93) - #define T_LOOP_TX 363 //363 == 210us(210.07) - #define T_TX2RX 1296 //1296 == 750us(749.99) - #define T_PWR_UP_RX 69 //69 == 40us(39.93) - #define T_LOOP_RX 276 //276 == 160us(159.72) - #define T_RX_ON 87 //87 == 50us(50.35) - #define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) - #define T_RX2TX 172 //172 == 100us(99.54) - #define T_TS_SOLL 979 //979 == 566.32us(566.55) - #define T_START_SYNC 1086//1065 - 31 //(1065 - 31) == 616.32us(616.09) [31 == calc time!!(17.94us)] - #define T_SYNC 1086//1065 //1065 == 616.32(616.32) - // ==> 48KB/second (384.000bps) +//T_SLOT == 1ms ==> every 1000us 48Bytes of payload are exchanged +#define POLL_LOOPS 4 +#define T_1ms 1728 //exact -> 1000us +#define T_PWR_UP_TX 69 //69 == 40us(39.93) +#define T_LOOP_TX 363 //363 == 210us(210.07) +#define T_TX2RX 1296 //1296 == 750us(749.99) +#define T_PWR_UP_RX 69 //69 == 40us(39.93) +#define T_LOOP_RX 276 //276 == 160us(159.72) +#define T_RX_ON 87 //87 == 50us(50.35) +#define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) +#define T_RX2TX 172 //172 == 100us(99.54) +#define T_TS_SOLL 979 //979 == 566.32us(566.55) +#define T_START_SYNC 1086//1065 - 31 //(1065 - 31) == 616.32us(616.09) [31 == calc time!!(17.94us)] +#define T_SYNC 1086//1065 //1065 == 616.32(616.32) +// ==> 48KB/second (384.000bps) -/* - //T_SLOT == 1.1ms ==> every 1100us 48Bytes of payload are exchanged - #define POLL_LOOPS 2 - #define T_1100us 1901 // -> 1100us(1100.11574) - #define T_PWR_UP_TX 70 //70 == 40us(40.51) - #define T_LOOP_TX 535 //535 == 310us(309.61) - #define T_TX2RX 1296 //1296 == 750us(749.99) - #define T_PWR_UP_RX 70 //70 == 40us(40.51) - #define T_LOOP_RX 448 //448 == 260us(259.26) - #define T_RX_ON 87 //87 == 50us(50.35) - #define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) - #define T_RX2TX 172 //172 == 100us(99.54) - #define T_TS_SOLL 979 //979 == 566.32us(566.55) - #define T_START_SYNC 1065 - 31 //(1065 - 31) == 598.38us [31 == calc time!!(17.94us)] - #define T_SYNC 1065 //1065 == 616.32(616.32) - // ==> 43.6KB/second (349.090bps) -*/ -/* - //T_SLOT == 2ms ==> every 2000us 48Bytes of payload are exchanged - #define POLL_LOOPS 2 - #define T_2ms 3456 //exact -> 2000us - #define T_PWR_UP_TX 70 //70 == 40us(40.51) - #define T_LOOP_TX 605 //605 == 350us(350.11) - #define T_TX2RX 2781 //2781 == 1610us(1609.37) - #define T_PWR_UP_RX 70 //70 == 40us(40.51) - #define T_LOOP_RX 518 //518 == 300us(299.77) - #define T_RX_ON 87 //87 == 50us(50.35) - #define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) - #define T_RX2TX 1657 //1657 == 960us(958.91) - #define T_START_SYNC 2550 - 31 //(2550 - 31) == 1475.69us [31 == calc time!!(17.94us)] - #define T_SYNC 2550 //2550 == 1475.69us - // ==> 24KB/second (192.000bps) -*/ -/* - //T_SLOT == 4ms ==> every 4000us 48Bytes of payload are exchanged - #define POLL_LOOPS 4 - #define T_4ms 6912 //exact -> 4000us - #define T_PWR_UP_TX 70 //70 == 40us(40.51) - #define T_LOOP_TX 605 //605 == 350us(350.11) - #define T_TX2RX 6237 //6237 == 3610us(3609.37) - #define T_PWR_UP_RX 70 //70 == 40us(40.51) - #define T_LOOP_RX 518 //518 == 300us(299.77) - #define T_RX_ON 87 //87 == 50us(50.35) - #define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) - #define T_RX2TX 5113 //5113 == 2960us(2958.91) - #define T_START_SYNC 6006 - 31 //(6006 - 31) == 3475.69us [31 == calc time!!(17.94us)] - #define T_SYNC 6006 //6006 == 3475.69us - // ==> 12KB/second (96.000bps) -*/ -/* - //T_SLOT == 8ms ==> every 8000us 48Bytes of payload are exchanged - #define POLL_LOOPS 8 - #define T_8ms 13824 //exact -> 8000us - #define T_PWR_UP_TX 70 //70 == 40us(40.51) - #define T_LOOP_TX 605 //605 == 350us(350.11) - #define T_TX2RX 13149 //13149 == 7610us(7609.37) - #define T_PWR_UP_RX 70 //70 == 40us(40.51) - #define T_LOOP_RX 518 //518 == 300us(299.77) - #define T_RX_ON 87 //87 == 50us(50.35) - #define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) - #define T_RX2TX 12025 //12025 == 6960us(6958.91) - #define T_START_SYNC 12918 - 31 //(12918 - 31) == 7475.69us [31 == calc time!!(17.94us)] - #define T_SYNC 12918 //12918 == 7475.69us - // ==> 6KB/second (48.000bps) -*/ -/* - //T_SLOT == 16ms ==> every 16000us 48Bytes of payload are exchanged - #define POLL_LOOPS 16 - #define T_16ms 27648 //exact -> 16000us - #define T_PWR_UP_TX 70 //70 == 40us(40.51) - #define T_LOOP_TX 605 //605 == 350us(350.11) - #define T_TX2RX 26973 //26973 == 15610us(15609.37) - #define T_PWR_UP_RX 70 //70 == 40us(40.51) - #define T_LOOP_RX 518 //518 == 300us(299.77) - #define T_RX_ON 87 //87 == 50us(50.35) - #define T_MAX_PAC_RX 1124 //1124 == 650us(650.46) - #define T_RX2TX 25849 //25849 == 14960us(14958.91) - #define T_START_SYNC 26742 - 31 //(26742 - 31) == 15475.69us [31 == calc time!!(17.94us)] - #define T_SYNC 26742 //26742 == 15475.69us - // ==> 3KB/second (24.000bps) -*/ -#define LED_ON __asm__ __volatile__ ("sbi 0x05,2") //B.2 -#define LED_OFF __asm__ __volatile__ ("cbi 0x05,2") //B.2 - -#endif - +#endif /* DEFINES_H */ Modified: firmware/rf/trunk/init.c =================================================================== --- firmware/rf/trunk/init.c 2008-07-08 14:51:42 UTC (rev 1315) +++ firmware/rf/trunk/init.c 2008-07-09 09:04:09 UTC (rev 1316) @@ -19,6 +19,8 @@ /* $Id$ */ +#include <avr/eeprom.h> + #include "defines.h" #include "init.h" #include "varis.h" Modified: firmware/rf/trunk/misc.c =================================================================== --- firmware/rf/trunk/misc.c 2008-07-08 14:51:42 UTC (rev 1315) +++ firmware/rf/trunk/misc.c 2008-07-09 09:04:09 UTC (rev 1316) @@ -61,18 +61,21 @@ //* Date: 31.01.06 * //* Description: Generates a delay. T(delay) = val * 10us * //***************************************************************************** +/* XXX replace with the delay.h functions */ void wait_n_10us(uint8_t val) { - uint8_t i,j; - i = val; - for(i=0;i<val;i++){ - for(j=0;j<16;j++){ - _NIX; - _NIX; - _NIX; - _NIX; - } - } + uint8_t i,j; + i = val; + for(i=0;i<val;i++){ + for(j=0;j<16;j++){ + asm volatile ( + "nop" "\n\t" + "nop" "\n\t" + "nop" "\n\t" + "nop" "\n\t" + ::); + } + } } //***************************************************************************** //* Project: RF-Firmware for ISM * @@ -96,7 +99,7 @@ set_rxon(); for(i=0;i<0xFF;i++){ random = 0x00; - _NIX; + asm volatile ("nop" "\n\t"::); } for(i=0;i<0x41;i++){ if((i&0x07)==0x00){ Modified: firmware/rf/trunk/prot.c =================================================================== --- firmware/rf/trunk/prot.c 2008-07-08 14:51:42 UTC (rev 1315) +++ firmware/rf/trunk/prot.c 2008-07-09 09:04:09 UTC (rev 1316) @@ -123,7 +123,7 @@ rf_rx_state = 0x00; rf_status |= SLAVE; - j = input(TCNT1); + j = TCNT1; j = j - ts; /* Changing prescaler!! */ j = j << 3; |