tux-droid-svn Mailing List for Tux Droid CE (Page 188)
Status: Beta
Brought to you by:
ks156
You can subscribe to this list here.
2007 |
Jan
|
Feb
(32) |
Mar
(108) |
Apr
(71) |
May
(38) |
Jun
(128) |
Jul
(1) |
Aug
(14) |
Sep
(77) |
Oct
(104) |
Nov
(90) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(81) |
Feb
(18) |
Mar
(40) |
Apr
(102) |
May
(151) |
Jun
(74) |
Jul
(151) |
Aug
(257) |
Sep
(447) |
Oct
(379) |
Nov
(404) |
Dec
(430) |
2009 |
Jan
(173) |
Feb
(236) |
Mar
(519) |
Apr
(300) |
May
(112) |
Jun
(232) |
Jul
(314) |
Aug
(58) |
Sep
(203) |
Oct
(293) |
Nov
(26) |
Dec
(109) |
2010 |
Jan
(19) |
Feb
(25) |
Mar
(33) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Paul_R <c2m...@c2...> - 2008-07-16 10:56:10
|
Author: Paul_R Date: 2008-07-16 12:56:13 +0200 (Wed, 16 Jul 2008) New Revision: 1332 Removed: sounds/ Log: * Removed the sound directory. The sounds can be found on tuxgi directory (http://svn.tuxisalive.com/software_suite_v1/software/tuxgi/trunk) |
From: Paul_R <c2m...@c2...> - 2008-07-16 10:52:18
|
Author: Paul_R Date: 2008-07-16 12:52:27 +0200 (Wed, 16 Jul 2008) New Revision: 1331 Modified: software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile Log: * Reverted to rev 1330 Modified: software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile 2008-07-16 10:46:15 UTC (rev 1330) +++ software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile 2008-07-16 10:52:27 UTC (rev 1331) @@ -10,7 +10,7 @@ TARGET = libtuxdriver.so C_INCLUDE_DIRS = -I"../../../../../../../usr/local/include" C_PREPROC = -CFLAGS = -pipe -std=gnu99 -DUSE_MUTEX -Wall -g0 -O2 -fPIC -DUSB_IDFRAME -DUSB_DEBUG +CFLAGS = -pipe -std=gnu99 -DUSE_MUTEX -Wall -g0 -O2 -fPIC LIB_DIRS = LIBS = -lpthread -lm LDFLAGS = -pipe -shared |
Author: Paul_R Date: 2008-07-16 12:46:15 +0200 (Wed, 16 Jul 2008) New Revision: 1330 Added: software_suite_v1/ software_suite_v1/api/ software_suite_v1/api/python/ software_suite_v1/daemon/ software_suite_v1/software/ Removed: api/ daemon/ software/ software_suite_v1/api/python/ Modified: firmware/fuxusb/branches/usb_cleanup/bootloader/twi.h firmware/fuxusb/trunk/fuxusb.Opt firmware/fuxusb/trunk/src/usb_commands.c firmware/fuxusb/trunk/src/version.h software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile Log: * Moved daemon, api and software into a new directory 'software_suite_v1' Modified: firmware/fuxusb/branches/usb_cleanup/bootloader/twi.h =================================================================== --- firmware/fuxusb/branches/usb_cleanup/bootloader/twi.h 2008-07-16 08:26:54 UTC (rev 1329) +++ firmware/fuxusb/branches/usb_cleanup/bootloader/twi.h 2008-07-16 10:46:15 UTC (rev 1330) @@ -1,4 +1,4 @@ -/* $Id:$ */ +/* $Id$ */ #ifndef _LIBMCU_TWI_H_ #define _LIBMCU_TWI_H_ 1 Modified: firmware/fuxusb/trunk/fuxusb.Opt =================================================================== (Binary files differ) Modified: firmware/fuxusb/trunk/src/usb_commands.c =================================================================== --- firmware/fuxusb/trunk/src/usb_commands.c 2008-07-16 08:26:54 UTC (rev 1329) +++ firmware/fuxusb/trunk/src/usb_commands.c 2008-07-16 10:46:15 UTC (rev 1330) @@ -97,13 +97,20 @@ void prepare_status(void) { uint8_t data i; + /* XXX + * This counter is only used for debug. + * With the new driver, sometimes, the RF status is online but no statuses + * are present on the frame. + * This counter is incremented each time a status frame is sent, to + * determine if the commands are correclty executed. */ + static uint8_t debug_counter = 0; if((status_requested) && (CMD_IN_Bank_Nb < 2)) { Usb_select_ep(EP_CMD_IN); /* Write header */ - Usb_write_byte(0); + Usb_write_byte(debug_counter++); Usb_write_byte(RF_OFFLINE ? 0 : 1); Usb_write_byte(RF_Status); Usb_write_byte(FifoIn_STT_Idx ? (FifoIn_STT_Idx / 4) : 0); Modified: firmware/fuxusb/trunk/src/version.h =================================================================== --- firmware/fuxusb/trunk/src/version.h 2008-07-16 08:26:54 UTC (rev 1329) +++ firmware/fuxusb/trunk/src/version.h 2008-07-16 10:46:15 UTC (rev 1330) @@ -19,7 +19,7 @@ * KySoH iTux agent created on 2005/10/20 by David Bourgeois */ -/* $Id:$ */ +/* $Id$ */ #ifndef _VERSION_H_ #define _VERSION_H_ Copied: software_suite_v1/api (from rev 1328, api) Copied: software_suite_v1/api/python (from rev 1329, api/python) Copied: software_suite_v1/daemon (from rev 1329, daemon) Copied: software_suite_v1/software (from rev 1329, software) Modified: software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile 2008-07-16 08:26:54 UTC (rev 1329) +++ software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile 2008-07-16 10:46:15 UTC (rev 1330) @@ -10,7 +10,7 @@ TARGET = libtuxdriver.so C_INCLUDE_DIRS = -I"../../../../../../../usr/local/include" C_PREPROC = -CFLAGS = -pipe -std=gnu99 -DUSE_MUTEX -Wall -g0 -O2 -fPIC +CFLAGS = -pipe -std=gnu99 -DUSE_MUTEX -Wall -g0 -O2 -fPIC -DUSB_IDFRAME -DUSB_DEBUG LIB_DIRS = LIBS = -lpthread -lm LDFLAGS = -pipe -shared |
From: jaguarondi <c2m...@c2...> - 2008-07-16 08:26:45
|
Author: jaguarondi Date: 2008-07-16 10:26:54 +0200 (Wed, 16 Jul 2008) New Revision: 1329 Modified: firmware/tuxaudio/trunk/PC_communication.c Log: * Dirty hack when an ACK is never received, resend the command. This problem doesn't seem to appear with the new RF so this is just a temporary solution. Modified: firmware/tuxaudio/trunk/PC_communication.c =================================================================== --- firmware/tuxaudio/trunk/PC_communication.c 2008-07-16 08:14:37 UTC (rev 1328) +++ firmware/tuxaudio/trunk/PC_communication.c 2008-07-16 08:26:54 UTC (rev 1329) @@ -54,6 +54,7 @@ spi_ready = 0; if (spi_slave == HEADERS) { + uint8_t static force_resend = 0; /* Sound */ if (FifoLength(ADCFifo) >= 17) spi_headerb = 0x02; /* frame will contain sound */ @@ -67,8 +68,18 @@ spi_headerb |= 0x08; /* resend the previous status if nacked */ } else if (rf_data_sent_ack != RF_DATA_SENT_BUSY) /* wait the end of transmission */ + { if (!popStatus(spi_commandTX)) /* fetch the next status */ spi_headerb |= 0x08; /* indicate that the frame contains status */ + } + else + { + if (++force_resend == 20) + { + force_resend = 0; + spi_headerb |= 0x08; /* resend the previous status if nacked */ + } + } SPDR = spi_headerb; // Header byte spi_slave = GET_SOUND_FIFO; // Next state |
From: jaguarondi <c2m...@c2...> - 2008-07-16 08:14:28
|
Author: jaguarondi Date: 2008-07-16 10:14:37 +0200 (Wed, 16 Jul 2008) New Revision: 1328 Modified: firmware/rf/trunk/interface.c firmware/rf/trunk/interface.h firmware/rf/trunk/rf_ctrl.c firmware/rf/trunk/varis.c firmware/rf/trunk/varis.h Log: * Added redundancy for the audio data, seems correct and will benefit from some cleanup later. The SPI and RF frames aren't in sync anymore as the redundancy is onle dealt with in the RF frame. Data and audio sent in the same SPI frame end up in different SPI frames at the other side as the audio frame is buffered. Modified: firmware/rf/trunk/interface.c =================================================================== --- firmware/rf/trunk/interface.c 2008-07-16 08:08:10 UTC (rev 1327) +++ firmware/rf/trunk/interface.c 2008-07-16 08:14:37 UTC (rev 1328) @@ -25,6 +25,7 @@ #include "interface.h" #include "varis.h" +uint8_t second_buffer; /** * Initialize the SPI interface. */ @@ -39,44 +40,81 @@ static uint8_t * const spi_in = (uint8_t *)rf_buffer_tx+12; static uint8_t * spi_out; -static uint8_t spi_idx; +static uint8_t spi_in_idx; +static uint8_t spi_out_idx; ISR(SIG_SPI) { /* Get byte n and prepare byte n+1 to send. */ - spi_in[spi_idx] = SPDR; + spi_in[spi_in_idx] = SPDR; set_spiack(); - spi_idx++; - SPDR = spi_out[spi_idx]; + spi_in_idx++; + spi_out_idx++; + if (spi_in_idx == SPI_AUDIO_OFFSET) + { + /* Select the second part of the buffer if the spi frame index is even */ + if (spi_in[SPI_IDX_OFFSET] & 0x01) + spi_in_idx += AUDIO_SPK_SIZE; + /* second_buffer is for upcoming data, so we invert for the data + * received. */ + if (!second_buffer) + spi_out_idx += AUDIO_SPK_SIZE; + } + SPDR = spi_out[spi_out_idx]; clr_spiack(); } void spi_request(void) { + uint8_t tmp; + static uint8_t prev_audio = 0; + static uint8_t frame_dropped = 0; /* XXX should we disable/enable SPIE? */ - spi_idx = 0; - /* XXX size is at [0] -> +1 for the start of the frame */ + spi_in_idx = 0; + spi_out_idx = 0; + /* Select the lastest received data */ spi_out = (uint8_t *)rf_buffer_rx_full; - SPDR = spi_out[spi_idx]; - set_txe(); -} -int8_t spi_complete(void) - /* XXX guess this isn't truly necessary */ -{ - clr_txe(); - if (spi_idx == 63) + /* As we send the previous audio frame, we have to reconfigure the audio + * bit in the config byte. */ + if (checksum1 == 0) { - return 1; + prev_audio = spi_out[SPI_CONFIG_OFFSET] & CFG_SECBUF_MK; + frame_dropped = 0; } - else if (spi_idx > 63) - /* Error */ + else { - return -1; + if (frame_dropped) + prev_audio = 0; + else + frame_dropped = 1; } + tmp = spi_out[SPI_CONFIG_OFFSET] & CFG_AUDIO_MK; + if (prev_audio) + spi_out[SPI_CONFIG_OFFSET] |= CFG_AUDIO_MK; else - /* Not finished */ - /* XXX what to do here? */ - { - return 0; - } + spi_out[SPI_CONFIG_OFFSET] &= ~CFG_AUDIO_MK; + /* We store the information here in case the next frame is dropped. */ + prev_audio = tmp; + + /* The frame idx indicates in which buffer the audio is, but if we don't + * get a frame, just use the alternate buffer of the previous frame. */ + if (checksum1 == 0) + second_buffer = spi_out[SPI_IDX_OFFSET] & 0x01; + else + second_buffer = !second_buffer; + + SPDR = spi_out[spi_out_idx]; + set_txe(); } + +void spi_complete(void) + /* XXX guess this isn't truly necessary */ +{ + static uint8_t second_buffer_included = 0; + clr_txe(); + /* Store whether the current frame will contain the previous audio in the + * second buffer */ + if (second_buffer_included) + spi_in[SPI_CONFIG_OFFSET] |= CFG_SECBUF_MK; + second_buffer_included = spi_in[SPI_CONFIG_OFFSET] & CFG_AUDIO_MK; +} Modified: firmware/rf/trunk/interface.h =================================================================== --- firmware/rf/trunk/interface.h 2008-07-16 08:08:10 UTC (rev 1327) +++ firmware/rf/trunk/interface.h 2008-07-16 08:14:37 UTC (rev 1328) @@ -22,6 +22,8 @@ #ifndef INTERFACE_H #define INTERFACE_H +#include "common/defines.h" + #define LINK_PORT PORTD #define LINK_DDR DDRD #define LINK_OUT PD7 @@ -40,7 +42,7 @@ #define clr_spiack() (SPIACK_PORT &= ~_BV(SPIACK_OUT)) void interface_init(void); -int8_t spi_complete(void); +void spi_complete(void); void spi_request(void); #endif /* INTERFACE_H */ Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-16 08:08:10 UTC (rev 1327) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-16 08:14:37 UTC (rev 1328) @@ -27,7 +27,6 @@ #include "prot.h" #include "interface.h" -volatile int8_t spi_tmp; /* XXX debug */ uint8_t checksum_tx; static void reset_atr2406(void); @@ -50,7 +49,7 @@ ISR (SIG_OUTPUT_COMPARE1A) { - PORTD ^= 0x08; // XXX DEBUG + //PORTD ^= 0x08; // XXX DEBUG switch(rf_state) { /* @@ -81,8 +80,12 @@ uint8_t volatile *p = rf_buffer_rx; rf_buffer_rx = rf_buffer_rx_full; rf_buffer_rx_full = p; + PORTD ^= 0x08; // XXX DEBUG } + checksum1 = checksum; } + else + checksum1 = 10; /* Configure in TX. */ #ifdef NOHOPP channel = TRX_CHANNEL; @@ -107,9 +110,12 @@ OCR1A = OCR1A + T_LOOP; //calculate new RF-Packet! SOF depending wether connected or not!! rf_buffer_tx[8] = channel; + /* What should we do if it's not complete? + * 2 ways, either continue the SPI until all data is gotten, but then + * that doesn't work if there's a problem, or drop the data, in which + * case it's possible to extend slightly the com period. */ + spi_complete(); - //PACKET CALCULATIONS - break; case 0x02: /* Start transmission. */ @@ -137,12 +143,6 @@ //} //} - /* What should we do if it's not complete? - * 2 ways, either continue the SPI until all data is gotten, but then - * that doesn't work if there's a problem, or drop the data, in which - * case it's possible to extend slightly the com period. */ - spi_tmp = spi_complete(); - rf_state = 3; // XXX skip PU break; @@ -155,11 +155,7 @@ /* Request a SPI communication. */ /* XXX Should check here whether we're connected or not */ - if (rf_status) - /* XXX I think we don't need this 'if' anymore */ - { - spi_request(); - } + spi_request(); //pwr_up_atr2406(); break; @@ -249,7 +245,7 @@ break; } rf_state = (rf_state + 1) & 7; - PORTD ^= 0x08; // XXX DEBUG + //PORTD ^= 0x08; // XXX DEBUG } volatile uint16_t testt = T_HEADER; Modified: firmware/rf/trunk/varis.c =================================================================== --- firmware/rf/trunk/varis.c 2008-07-16 08:08:10 UTC (rev 1327) +++ firmware/rf/trunk/varis.c 2008-07-16 08:14:37 UTC (rev 1328) @@ -99,6 +99,7 @@ volatile uint8_t rf_rx_state; //State of the RX interrupt volatile uint8_t checksum; +volatile uint8_t checksum1; //Checksum => 0x00 => okay Modified: firmware/rf/trunk/varis.h =================================================================== --- firmware/rf/trunk/varis.h 2008-07-16 08:08:10 UTC (rev 1327) +++ firmware/rf/trunk/varis.h 2008-07-16 08:14:37 UTC (rev 1328) @@ -61,6 +61,7 @@ extern volatile uint8_t rf_rx_counter; extern volatile uint8_t rf_rx_state; extern volatile uint8_t checksum; +extern volatile uint8_t checksum1; extern volatile uint8_t trial_cnt; extern volatile uint16_t ts; |
From: jaguarondi <c2m...@c2...> - 2008-07-16 08:08:14
|
Author: jaguarondi Date: 2008-07-16 10:08:10 +0200 (Wed, 16 Jul 2008) New Revision: 1327 Modified: firmware/rf/trunk/defines.h Log: * Updated some parameters and comments. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-16 08:00:29 UTC (rev 1326) +++ firmware/rf/trunk/defines.h 2008-07-16 08:08:10 UTC (rev 1327) @@ -30,7 +30,7 @@ //**Define the used HOPPING SCHEME**// //#define HOPPING #define NOHOPP -#define TRX_CHANNEL 4 +#define TRX_CHANNEL 0 //#define CYCHOPP //**Define the used HOPPING SCHEME**// @@ -113,7 +113,7 @@ /* Part of the HEADER which is stored in the buffer. 2 bytes of the PREAMBLE * aren't stored but sent directly. */ #define STORED_HEADER (HEADER - 2) -#define PAYLOAD 75 /* Payload in bytes */ +#define PAYLOAD 73 /* Payload in bytes */ #define RF_BUFFER_SIZE (PAYLOAD + STORED_HEADER) /* USART bit to tick ratio: sys_clk / (8 * 1152e3) */ @@ -130,7 +130,7 @@ #define T_PWR_UP 0//69 /* 40us */ /* Programming (~20us) and PLL loop (>200us) */ #define T_LOOP 380 -/* Sending the HEAER and PAYLOAD */ +/* Sending the HEDAER and PAYLOAD */ //#define T_ACTIVE 1124 /* 650us */ #define T_MARGIN 20 #define T_ACTIVE (T_HEADER + T_PAYLOAD + T_MARGIN) @@ -151,9 +151,12 @@ /* There's a latency between the time the master sends the first byte of the * payload and the time the slave captures the last byte of the header. This - * value is better checked with an oscilloscope: the first byte of the preamble - * should be received 50us (T_RX_ON) after RX_ON is set. */ -#define T_LATENCY 10 + * value is can be checked with an oscilloscope: the first byte of the preamble + * should be received 50us (T_RX_ON) after RX_ON is set. This should be true + * for both master and slave. + * Another way is to check the minimum and maximum values that still work + * (checksum OK) and get the value in the middle. */ +#define T_LATENCY 25 //#define T_1ms 1728 [> Exactly -> 1000us <] //#define T_PWR_UP_TX 69 [> 40us <] |
From: jaguarondi <c2m...@c2...> - 2008-07-16 08:00:26
|
Author: jaguarondi Date: 2008-07-16 10:00:29 +0200 (Wed, 16 Jul 2008) New Revision: 1326 Modified: firmware/tuxaudio/branches/new_rf/communication.c firmware/tuxaudio/branches/new_rf/main.c Log: * The redundancy in the RF makes it possible to have 2 frames with the same ID but with different valid audio samples. Modified: firmware/tuxaudio/branches/new_rf/communication.c =================================================================== --- firmware/tuxaudio/branches/new_rf/communication.c 2008-07-11 09:57:07 UTC (rev 1325) +++ firmware/tuxaudio/branches/new_rf/communication.c 2008-07-16 08:00:29 UTC (rev 1326) @@ -21,6 +21,7 @@ #include <avr/io.h> #include <avr/interrupt.h> +#include <stdio.h> #include "communication.h" #include "fifo.h" @@ -356,25 +357,49 @@ /* Ack the data by toggling the bit */ config_out ^= CFG_ACK_MK; } - if (config_in & CFG_AUDIO_MK) - { - adapt_audio_rate(); - - for (i=0; i<AUDIO_SPK_SIZE; i++) - { - FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]); - //XXX DEBUG: used to show when the stack overflows. - //if (FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]) != FIFO_OK) - //PORTB |= 0x80; // XXX DEBUG - //else - //PORTB &= ~0x80; // XXX DEBUG - } - } - //PORTB &= ~0x80; // XXX DEBUG } //else //PORTB |= 0x80; // XXX DEBUG + if (config_in & CFG_AUDIO_MK) + { + adapt_audio_rate(); + for (i=0; i<AUDIO_SPK_SIZE; i++) + { + FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]); + } + } + else + PORTB ^= 0x80; // XXX DEBUG + + /* DEBUG VERSION + * The first part checks a saw wave, the second part can check for + * stack overflow. */ + //{ + //uint8_t static tmp2; + //adapt_audio_rate(); + + //for (i=0; i<AUDIO_SPK_SIZE; i++) + //{ + //uint8_t tmp1; + //tmp1 = spi_in[i+SPI_AUDIO_OFFSET]; + //FifoPut(PWMFifo, tmp1); + //if (tmp1 != (uint8_t)(tmp2 + 1)) + //{ + //PORTB ^= 0x80; // XXX DEBUG + //queue_rf_cmd_p(0xFE, tmp1, tmp2, frame_in_idx); + //} + //tmp2 = tmp1; + //XXX DEBUG: used to show when the stack overflows. + //if (FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]) != FIFO_OK) + //PORTB |= 0x80; // XXX DEBUG + //else + //PORTB &= ~0x80; // XXX DEBUG + //} + //} + /*else*/ + /*PORTB ^= 0x80; // XXX DEBUG*/ + /* Outgoing data, add commands and/or audio. */ spi_out[SPI_IDX_OFFSET] = frame_out_idx++; if ((!(config_out & CFG_DATA_MK)) == (!(config_in & CFG_ACK_MK)) && @@ -417,7 +442,7 @@ { if (!parse_cmd(received_cmd)) queue_rf_cmd(received_cmd); - received_cmd = 0; + received_cmd = NULL; } /* Send otherwise get commands. */ Modified: firmware/tuxaudio/branches/new_rf/main.c =================================================================== --- firmware/tuxaudio/branches/new_rf/main.c 2008-07-11 09:57:07 UTC (rev 1325) +++ firmware/tuxaudio/branches/new_rf/main.c 2008-07-16 08:00:29 UTC (rev 1326) @@ -252,13 +252,13 @@ DDRD &= ~0x03; } /* XXX debug of the audio stack */ - queue_rf_cmd_p(0xFE, FifoLength(PWMFifo), OCR0A, 0); + //queue_rf_cmd_p(0xFE, FifoLength(PWMFifo), OCR0A, 0); } /* Sleep mode */ if (pre_sleep_delay == 1) sleep(); - } + } } //static inline void audio_sampling(void) __attribute__ ( ( always_inline ) ); |
From: jaguarondi <c2m...@c2...> - 2008-07-11 09:57:02
|
Author: jaguarondi Date: 2008-07-11 11:57:07 +0200 (Fri, 11 Jul 2008) New Revision: 1325 Modified: firmware/tuxdefs/defines.h Log: * I can save one byte in the audio as sending 33 bytes is good enough to have at least 16kHz. Modified: firmware/tuxdefs/defines.h =================================================================== --- firmware/tuxdefs/defines.h 2008-07-10 13:02:52 UTC (rev 1324) +++ firmware/tuxdefs/defines.h 2008-07-11 09:57:07 UTC (rev 1325) @@ -264,21 +264,21 @@ * @{ */ /* SPI frame structure */ -#define SPI_SIZE 40 +#define SPI_SIZE 39 #define SPI_IDX_OFFSET 0 #define SPI_CONFIG_OFFSET 1 #define SPI_DATA_OFFSET 2 #define SPI_AUDIO_OFFSET (SPI_DATA_OFFSET + CMD_SIZE) /** Size of the audio data in the SPI frame */ -#define AUDIO_SPK_SIZE 34 +#define AUDIO_SPK_SIZE 33 #define AUDIO_MIC_SIZE 17 /* Bits of the config byte */ #define CFG_CRCOK_MK _BV(0) #define CFG_DATA_MK _BV(1) #define CFG_AUDIO_MK _BV(2) -#define CFG_PREVAUDIO_MK _BV(3) +#define CFG_SECBUF_MK _BV(3) #define CFG_ACK_MK _BV(4) /*! @} */ |
From: jaguarondi <c2m...@c2...> - 2008-07-10 13:02:43
|
Author: jaguarondi Date: 2008-07-10 15:02:52 +0200 (Thu, 10 Jul 2008) New Revision: 1324 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/init.c firmware/rf/trunk/varis.c Log: * Now using 75 bytes of payload. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-10 12:42:25 UTC (rev 1323) +++ firmware/rf/trunk/defines.h 2008-07-10 13:02:52 UTC (rev 1324) @@ -113,7 +113,7 @@ /* Part of the HEADER which is stored in the buffer. 2 bytes of the PREAMBLE * aren't stored but sent directly. */ #define STORED_HEADER (HEADER - 2) -#define PAYLOAD 52 /* Payload in bytes */ +#define PAYLOAD 75 /* Payload in bytes */ #define RF_BUFFER_SIZE (PAYLOAD + STORED_HEADER) /* USART bit to tick ratio: sys_clk / (8 * 1152e3) */ Modified: firmware/rf/trunk/init.c =================================================================== --- firmware/rf/trunk/init.c 2008-07-10 12:42:25 UTC (rev 1323) +++ firmware/rf/trunk/init.c 2008-07-10 13:02:52 UTC (rev 1324) @@ -126,57 +126,4 @@ rf_buffer_tx[9]=sof_ary[1]; rf_buffer_tx[10]=sof_ary[2]; rf_buffer_tx[11]=sof_ary[3]; - - rf_buffer_tx[12]=52; - rf_buffer_tx[13]=0x55; - rf_buffer_tx[14]=0x55; - rf_buffer_tx[15]=0x55; - rf_buffer_tx[16]=0x55; - rf_buffer_tx[17]=0x55; - rf_buffer_tx[18]=0x55; - rf_buffer_tx[19]=0x55; - rf_buffer_tx[20]=0x55; - rf_buffer_tx[21]=0x55; - rf_buffer_tx[22]=0x55; - rf_buffer_tx[23]=0x55; - rf_buffer_tx[24]=0x55; - rf_buffer_tx[25]=0x55; - rf_buffer_tx[26]=0x55; - rf_buffer_tx[27]=0x55; - rf_buffer_tx[28]=0x55; - rf_buffer_tx[29]=0x55; - rf_buffer_tx[30]=0x55; - rf_buffer_tx[31]=0x55; - rf_buffer_tx[32]=0x55; - rf_buffer_tx[33]=0x55; - rf_buffer_tx[34]=0x55; - rf_buffer_tx[35]=0x55; - rf_buffer_tx[36]=0x55; - rf_buffer_tx[37]=0x55; - rf_buffer_tx[38]=0x55; - rf_buffer_tx[39]=0x55; - rf_buffer_tx[40]=0x55; - rf_buffer_tx[41]=0x55; - rf_buffer_tx[42]=0x55; - rf_buffer_tx[43]=0x55; - rf_buffer_tx[44]=0x55; - rf_buffer_tx[45]=0x55; - rf_buffer_tx[46]=0x55; - rf_buffer_tx[47]=0x55; - rf_buffer_tx[48]=0x55; - rf_buffer_tx[49]=0x55; - rf_buffer_tx[50]=0x55; - rf_buffer_tx[51]=0x55; - rf_buffer_tx[52]=0x55; - rf_buffer_tx[53]=0x55; - rf_buffer_tx[54]=0x55; - rf_buffer_tx[55]=0x55; - rf_buffer_tx[56]=0x55; - rf_buffer_tx[57]=0x55; - rf_buffer_tx[58]=0x55; - rf_buffer_tx[59]=0x55; - rf_buffer_tx[60]=0x55; - rf_buffer_tx[61]=0x55; - rf_buffer_tx[62]=0x55; - rf_buffer_tx[63]=0x34; /* Parity checksum manually calculated */ } Modified: firmware/rf/trunk/varis.c =================================================================== --- firmware/rf/trunk/varis.c 2008-07-10 12:42:25 UTC (rev 1323) +++ firmware/rf/trunk/varis.c 2008-07-10 13:02:52 UTC (rev 1324) @@ -60,10 +60,10 @@ -volatile uint8_t rf_buffer_tx[64]; +volatile uint8_t rf_buffer_tx[RF_BUFFER_SIZE]; //buffer for storing the RF TX data -volatile uint8_t rf_buffer_rx1[64]; -volatile uint8_t rf_buffer_rx2[64]; +volatile uint8_t rf_buffer_rx1[PAYLOAD]; +volatile uint8_t rf_buffer_rx2[PAYLOAD]; uint8_t volatile *rf_buffer_rx = rf_buffer_rx1; uint8_t volatile *rf_buffer_rx_full = rf_buffer_rx2; //buffer for storing the RF RX data |
From: jaguarondi <c2m...@c2...> - 2008-07-10 12:42:17
|
Author: jaguarondi Date: 2008-07-10 14:42:25 +0200 (Thu, 10 Jul 2008) New Revision: 1323 Modified: firmware/tuxdefs/defines.h Log: * Define missing for the USB. Modified: firmware/tuxdefs/defines.h =================================================================== --- firmware/tuxdefs/defines.h 2008-07-10 12:36:56 UTC (rev 1322) +++ firmware/tuxdefs/defines.h 2008-07-10 12:42:25 UTC (rev 1323) @@ -32,6 +32,10 @@ #ifndef _DEFINES_H_ #define _DEFINES_H_ +#ifndef _BV +#define _BV(x) (1<<x) +#endif + #include <stdint.h> /** * \name Identifiers and addresses. |
From: jaguarondi <c2m...@c2...> - 2008-07-10 12:36:48
|
Author: jaguarondi Date: 2008-07-10 14:36:56 +0200 (Thu, 10 Jul 2008) New Revision: 1322 Modified: firmware/tuxdefs/defines.h Log: * Updated the SPI frame structure for one command and 16kHz audio. Modified: firmware/tuxdefs/defines.h =================================================================== --- firmware/tuxdefs/defines.h 2008-07-10 12:25:01 UTC (rev 1321) +++ firmware/tuxdefs/defines.h 2008-07-10 12:36:56 UTC (rev 1322) @@ -260,11 +260,10 @@ * @{ */ /* SPI frame structure */ -#define SPI_SIZE 51 +#define SPI_SIZE 40 #define SPI_IDX_OFFSET 0 #define SPI_CONFIG_OFFSET 1 -#define SPI_DATAIDX_OFFSET 2 -#define SPI_DATA_OFFSET 3 +#define SPI_DATA_OFFSET 2 #define SPI_AUDIO_OFFSET (SPI_DATA_OFFSET + CMD_SIZE) /** Size of the audio data in the SPI frame */ |
From: jaguarondi <c2m...@c2...> - 2008-07-10 12:24:54
|
Author: jaguarondi Date: 2008-07-10 14:25:01 +0200 (Thu, 10 Jul 2008) New Revision: 1321 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/init.c firmware/rf/trunk/interface.c firmware/rf/trunk/misc.c firmware/rf/trunk/prot.c firmware/rf/trunk/rf_ctrl.c Log: * Fixed the size of the RF frame with a define which is used throughout the code. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-10 11:10:13 UTC (rev 1320) +++ firmware/rf/trunk/defines.h 2008-07-10 12:25:01 UTC (rev 1321) @@ -109,7 +109,12 @@ #define PREAMBLE 8 /* Preamble in bytes */ #define SYNC 2 /* Sync data in bytes */ #define SOF 4 /* Start Of Frame in bytes */ -#define PAYLOAD 75 /* Payload in bytes */ +#define HEADER (PREAMBLE + SYNC + SOF) +/* Part of the HEADER which is stored in the buffer. 2 bytes of the PREAMBLE + * aren't stored but sent directly. */ +#define STORED_HEADER (HEADER - 2) +#define PAYLOAD 52 /* Payload in bytes */ +#define RF_BUFFER_SIZE (PAYLOAD + STORED_HEADER) /* USART bit to tick ratio: sys_clk / (8 * 1152e3) */ #define TICKS_PER_BIT (F_CPU/(8.*1152000)) Modified: firmware/rf/trunk/init.c =================================================================== --- firmware/rf/trunk/init.c 2008-07-10 11:10:13 UTC (rev 1320) +++ firmware/rf/trunk/init.c 2008-07-10 12:25:01 UTC (rev 1321) @@ -127,8 +127,7 @@ rf_buffer_tx[10]=sof_ary[2]; rf_buffer_tx[11]=sof_ary[3]; - /* TODO increase the frame size to add the previosu audio data */ - rf_buffer_tx[12]=52; /* Number of bytes from here */ + rf_buffer_tx[12]=52; rf_buffer_tx[13]=0x55; rf_buffer_tx[14]=0x55; rf_buffer_tx[15]=0x55; Modified: firmware/rf/trunk/interface.c =================================================================== --- firmware/rf/trunk/interface.c 2008-07-10 11:10:13 UTC (rev 1320) +++ firmware/rf/trunk/interface.c 2008-07-10 12:25:01 UTC (rev 1321) @@ -36,7 +36,7 @@ clr_spiack(); } -static uint8_t * const spi_in = (uint8_t *)rf_buffer_tx+13; +static uint8_t * const spi_in = (uint8_t *)rf_buffer_tx+12; static uint8_t * spi_out; static uint8_t spi_idx; @@ -55,7 +55,7 @@ /* XXX should we disable/enable SPIE? */ spi_idx = 0; /* XXX size is at [0] -> +1 for the start of the frame */ - spi_out = (uint8_t *)rf_buffer_rx_full+1; + spi_out = (uint8_t *)rf_buffer_rx_full; SPDR = spi_out[spi_idx]; set_txe(); } Modified: firmware/rf/trunk/misc.c =================================================================== --- firmware/rf/trunk/misc.c 2008-07-10 11:10:13 UTC (rev 1320) +++ firmware/rf/trunk/misc.c 2008-07-10 12:25:01 UTC (rev 1321) @@ -129,9 +129,10 @@ uint8_t *ptr; ptr = (uint8_t *)&rf_buffer_tx[12]; tmp = 0x00; - for(i=rf_buffer_tx[12]; i>0x01; i--) + for(i=PAYLOAD; i>0x01; i--) { tmp += *ptr++; } + /* Store the checksum at the last byte */ *ptr = (tmp ^ 0xFF) + 1; } Modified: firmware/rf/trunk/prot.c =================================================================== --- firmware/rf/trunk/prot.c 2008-07-10 11:10:13 UTC (rev 1320) +++ firmware/rf/trunk/prot.c 2008-07-10 12:25:01 UTC (rev 1321) @@ -117,7 +117,6 @@ do{ if(rf_rx_state==0xFF){//something received if(checksum==0x00){//correct received - if(rf_buffer_rx[0]==52){//packet received //pwr_dwn_atr2406(); rf_rx_state = 0x00; @@ -132,9 +131,10 @@ start_rf_timer(); return; - } } } + /* XXX use the overflow interrupt and the same timer + * settings as in normal mode. */ } while (TCNT1 < 43201); /* 200ms */ } } Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-10 11:10:13 UTC (rev 1320) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-10 12:25:01 UTC (rev 1321) @@ -432,19 +432,18 @@ //***************************************************************************** ISR (SIG_USART_DATA) { - uint8_t tmp = rf_tx_counter; + uint8_t cnt = rf_tx_counter; /* Set nOLE to low when preamble is sent. */ - if(tmp == 0x07) + if(cnt == 0x07) { clr_nole(); } - /* XXX frame size would better be fixed, no? */ /* Last data buffered. */ - if(tmp == rf_buffer_tx[12] + 11) + if(cnt == RF_BUFFER_SIZE - 1) { /* TODO this can be moved out of the if/else */ - UDR0 = rf_buffer_tx[tmp] ^ SCRAMBLE_BYTE; + UDR0 = rf_buffer_tx[cnt] ^ SCRAMBLE_BYTE; //UDR0 = (0-checksum_tx) ^ SCRAMBLE_BYTE; /* Enable USART Transmit complete interrupt (SIG_USART_TRANS) and * disable DRE (SIG_USART_DATA) */ @@ -452,18 +451,11 @@ } else { - UDR0 = rf_buffer_tx[tmp] ^ SCRAMBLE_BYTE; - //checksum_tx += rf_buffer_tx[tmp]; + UDR0 = rf_buffer_tx[cnt] ^ SCRAMBLE_BYTE; + //checksum_tx += rf_buffer_tx[cnt]; } - rf_tx_counter = ++tmp; + rf_tx_counter = ++cnt; } -//worsest case duration 46 cycles -//@13.824MHz ==> 38% (1N8) -//@ 6.912MHz ==> 77% (1N8) -//@13.824MHz ==> 35% (2N8)(1N8 + Parity) -//@ 6.912MHz ==> 70% (2N8)(1N8 + Parity) -//@13.824MHz ==> 32% (2N9) -//@ 6.912MHz ==> 64% (2N9) //***************************************************************************** //* Project: RF-Firmware for ISM * @@ -516,14 +508,12 @@ /* Frame detected, receive data */ { rf_buffer_rx[rf_rx_counter++] = data; - /* Wrap around buffer */ - rf_rx_counter &= 0x3F; /* checksum is computed from buf[4] to buf[-1] and should be 0 at the * end as buf[-1] contains the checksum of buf[4..-2] */ checksum += data; - if(rf_rx_counter==rf_buffer_rx[0]) /* XXX better have a define here unless we want dynamic length of frames */ + if(rf_rx_counter == PAYLOAD) { state = 0xFF; UCSR0A = 0x00; @@ -542,7 +532,7 @@ { #ifdef _SLAVE ts = TCNT1; - OCR1A = ts + T_SYNC - T_LATENCY - T_PWR_DWN; + OCR1A = ts + T_SYNC - T_LATENCY; #endif } } |
From: jaguarondi <c2m...@c2...> - 2008-07-10 11:10:17
|
Author: jaguarondi Date: 2008-07-10 13:10:13 +0200 (Thu, 10 Jul 2008) New Revision: 1320 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/prot.c firmware/rf/trunk/rf_ctrl.c firmware/rf/trunk/varis.h Log: * Changed the timing so that I should now be able to have a payload of 75 byes. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-09 14:27:46 UTC (rev 1319) +++ firmware/rf/trunk/defines.h 2008-07-10 11:10:13 UTC (rev 1320) @@ -109,7 +109,7 @@ #define PREAMBLE 8 /* Preamble in bytes */ #define SYNC 2 /* Sync data in bytes */ #define SOF 4 /* Start Of Frame in bytes */ -#define PAYLOAD 48 /* Payload in bytes */ +#define PAYLOAD 75 /* Payload in bytes */ /* USART bit to tick ratio: sys_clk / (8 * 1152e3) */ #define TICKS_PER_BIT (F_CPU/(8.*1152000)) @@ -117,16 +117,18 @@ * (8bits + start + stop) */ #define BITS_PER_BYTE 10 /* HEADER duration */ -#define T_HEADER ((PREAMBLE + SYNC + SOF) * BITS_PER_BYTE * TICKS_PER_BIT) // 210 +#define T_HEADER (uint16_t)((PREAMBLE + SYNC + SOF) * BITS_PER_BYTE * TICKS_PER_BIT) // 210 /* PAYLOAD duration */ -#define T_PAYLOAD (PAYLOAD * BITS_PER_BYTE * TICKS_PER_BIT) // 720 +#define T_PAYLOAD (uint16_t)(PAYLOAD * BITS_PER_BYTE * TICKS_PER_BIT) // 720 /* Power-up (> 40us) */ -#define T_PWR_UP 69 /* 40us */ +#define T_PWR_UP 0//69 /* 40us */ /* Programming (~20us) and PLL loop (>200us) */ -#define T_LOOP 363 /* 210us */ /*XXX should be 220us */ +#define T_LOOP 380 /* Sending the HEAER and PAYLOAD */ -#define T_ACTIVE 1124 /* 650us */ +//#define T_ACTIVE 1124 /* 650us */ +#define T_MARGIN 20 +#define T_ACTIVE (T_HEADER + T_PAYLOAD + T_MARGIN) #define T_PWR_DWN (T_1ms - T_PWR_UP - T_LOOP - T_ACTIVE) #define T_TX2RX (T_ACTIVE + T_PWR_DWN) @@ -137,16 +139,16 @@ #define T_LOOP_RX (T_LOOP - T_RX_ON) /* 2->3 (T_TX2RX) should be equal to 6->0 - * 6->0 is (T_MAX_PAC_RX + T_RX2TX) for master - * ts->0 is (-T_HEADER + T_MAX_PAC_RX + T_RX2TX) for slave */ -#define T_SYNC 1086 + * 6->0 is (T_MAX_PAC_RX + T_PWR_DWN) for master + * ts->0 is (-T_HEADER + T_ACTIVE + T_PWR_DWN) for slave */ +#define T_SYNC (-T_HEADER + T_ACTIVE + T_PWR_DWN) // ==> 48KB/second (384.000bps) /* There's a latency between the time the master sends the first byte of the - * pauload and the time the slave captures the last byte of the header. This - * value could be calculated by looking at the assembly or using an - * oscilloscope. */ -#define T_LATENCY 26 + * payload and the time the slave captures the last byte of the header. This + * value is better checked with an oscilloscope: the first byte of the preamble + * should be received 50us (T_RX_ON) after RX_ON is set. */ +#define T_LATENCY 10 //#define T_1ms 1728 [> Exactly -> 1000us <] //#define T_PWR_UP_TX 69 [> 40us <] Modified: firmware/rf/trunk/prot.c =================================================================== --- firmware/rf/trunk/prot.c 2008-07-09 14:27:46 UTC (rev 1319) +++ firmware/rf/trunk/prot.c 2008-07-10 11:10:13 UTC (rev 1320) @@ -118,12 +118,13 @@ if(rf_rx_state==0xFF){//something received if(checksum==0x00){//correct received if(rf_buffer_rx[0]==52){//packet received - pwr_dwn_atr2406(); + //pwr_dwn_atr2406(); rf_rx_state = 0x00; rf_status |= SLAVE; j = TCNT1; + /* XXX have to change this so ts isn't global anymore */ j = j - ts; /* Changing prescaler!! */ j = j << 3; @@ -142,6 +143,7 @@ /* MASTER mode. */ rf_status |= MASTER; pwr_dwn_atr2406(); + pwr_up_atr2406(); start_rf_timer(); UCSR0A = 0x00; UCSR0B = 0x00; Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-09 14:27:46 UTC (rev 1319) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-10 11:10:13 UTC (rev 1320) @@ -30,6 +30,8 @@ volatile int8_t spi_tmp; /* XXX debug */ uint8_t checksum_tx; +static void reset_atr2406(void); + //***************************************************************************** //* Project: RF-Firmware for ISM * //* Function: TIM1_COMPA_IRQ * @@ -56,10 +58,31 @@ */ case 0x00: /* Power up for TX. */ - pwr_up_atr2406(); - OCR1A = OCR1A + T_PWR_UP; - break; + //OCR1A = OCR1A + T_PWR_UP; + //pwr_up_atr2406(); + //break; + rf_state = 1; case 0x01: + /* RX complete, check what we got. */ + UCSR0A = 0x00; + UCSR0B = 0x00; + UCSR0C = 0x00; + reset_atr2406(); + + /* XXX thought we shouldn't power down at full rate */ + //pwr_dwn_atr2406(); + + if (rf_rx_state==0xFF) + /* Good frame received. */ + { + if (checksum==0x00) + { + /* Switch rx buffer */ + uint8_t volatile *p = rf_buffer_rx; + rf_buffer_rx = rf_buffer_rx_full; + rf_buffer_rx_full = p; + } + } /* Configure in TX. */ #ifdef NOHOPP channel = TRX_CHANNEL; @@ -120,6 +143,7 @@ * case it's possible to extend slightly the com period. */ spi_tmp = spi_complete(); + rf_state = 3; // XXX skip PU break; /* @@ -127,6 +151,7 @@ */ case 0x03: /* End of TX, power up for RX. */ + OCR1A = OCR1A + T_PWR_UP; /* Request a SPI communication. */ /* XXX Should check here whether we're connected or not */ @@ -136,11 +161,12 @@ spi_request(); } - pwr_up_atr2406(); - OCR1A = OCR1A + T_PWR_UP; + //pwr_up_atr2406(); break; case 0x04: /* Configure in RX mode. */ + reset_atr2406(); + spi_request(); #ifdef NOHOPP channel = TRX_CHANNEL; #endif @@ -179,29 +205,34 @@ UCSR0A = 0x00; UCSR0B = 0x90; UCSR0C = 0x46; - OCR1A = OCR1A + T_ACTIVE; + OCR1A = OCR1A + T_ACTIVE + T_PWR_DWN; + rf_state = 0; // XXX skip PU break; case 0x07: /* RX complete, check what we got. */ UCSR0A = 0x00; UCSR0B = 0x00; UCSR0C = 0x00; + reset_atr2406(); /* XXX thought we shouldn't power down at full rate */ //pwr_dwn_atr2406(); - if ((rf_rx_state==0xFF) && (checksum==0x00)) + if (rf_rx_state==0xFF) /* Good frame received. */ { - /* Switch rx buffer */ - uint8_t volatile *p = rf_buffer_rx; - rf_buffer_rx = rf_buffer_rx_full; - rf_buffer_rx_full = p; + if (checksum==0x00) + { + /* Switch rx buffer */ + uint8_t volatile *p = rf_buffer_rx; + rf_buffer_rx = rf_buffer_rx_full; + rf_buffer_rx_full = p; + } if (rf_status & SLAVE) - /* SLAVE, resynchronize. */ + /* SLAVE, resynchronized already. */ { - OCR1A = ts + T_SYNC - T_LATENCY; + //OCR1A = ts + T_SYNC - T_LATENCY; } else /* MASTER */ @@ -214,6 +245,7 @@ { OCR1A = OCR1A + T_PWR_DWN; } + rf_state = 0; // XXX skip PU break; } rf_state = (rf_state + 1) & 7; @@ -227,6 +259,7 @@ */ void start_rf_timer(void) { + testt = T_PWR_DWN; TCNT1H = 0x00; TCNT1L = 0x00; TCCR1A = 0x00; @@ -353,6 +386,17 @@ DDRD = DDRD|0x10;//XCK PIN set to output!! } +void reset_atr2406(void) +{ + set_nole(); //close loop + set_enable(); + clr_rxon(); //switch off RX + clr_txon(); //switch off TX + clr_clock(); + clr_data(); + DDRD = DDRD|0x10;//XCK PIN set to output!! +} + //***************************************************************************** //* Project: RF-Firmware for ISM * //* Function: pwr_dwn_atr2406 * @@ -436,7 +480,7 @@ UCSR0A = 0x00; UCSR0B = 0x00; UCSR0C = 0x00; - clr_pupwr(); + //clr_pupwr(); clr_txon(); clr_enable(); set_nole(); @@ -485,7 +529,7 @@ UCSR0A = 0x00; UCSR0B = 0x00; UCSR0C = 0x00; - clr_pupwr(); + //clr_pupwr(); clr_rxon(); } } @@ -496,7 +540,10 @@ { if(++state==0x04) { +#ifdef _SLAVE ts = TCNT1; + OCR1A = ts + T_SYNC - T_LATENCY - T_PWR_DWN; +#endif } } else Modified: firmware/rf/trunk/varis.h =================================================================== --- firmware/rf/trunk/varis.h 2008-07-09 14:27:46 UTC (rev 1319) +++ firmware/rf/trunk/varis.h 2008-07-10 11:10:13 UTC (rev 1320) @@ -46,29 +46,17 @@ #include "defines.h" -uint8_t GFCS; +extern uint8_t GFCS; extern volatile uint8_t rf_buffer_tx[]; extern uint8_t volatile *rf_buffer_rx; extern uint8_t volatile *rf_buffer_rx_full; - extern uint8_t sof_ary[]; - - - extern volatile uint8_t rf_status; extern volatile uint8_t channel; extern uint8_t channel_width; - - - extern volatile uint8_t tx_pac_len; - - - extern volatile uint8_t protocol_flags; - - extern volatile uint8_t rf_tx_counter; extern volatile uint8_t rf_rx_counter; extern volatile uint8_t rf_rx_state; @@ -76,8 +64,4 @@ extern volatile uint8_t trial_cnt; extern volatile uint16_t ts; - - - - #endif |
From: jaguarondi <c2m...@c2...> - 2008-07-09 14:27:37
|
Author: jaguarondi Date: 2008-07-09 16:27:46 +0200 (Wed, 09 Jul 2008) New Revision: 1319 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/prot.c firmware/rf/trunk/rf_ctrl.c Log: * Some more re-arranging of the defines. I go step by step. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-09 13:49:53 UTC (rev 1318) +++ firmware/rf/trunk/defines.h 2008-07-09 14:27:46 UTC (rev 1319) @@ -124,25 +124,30 @@ /* Power-up (> 40us) */ #define T_PWR_UP 69 /* 40us */ /* Programming (~20us) and PLL loop (>200us) */ -#define T_LOOP_TX 363 /* 210us */ /*XXX should be 220us */ -#define T_TX2RX 1296 /* 750us */ +#define T_LOOP 363 /* 210us */ /*XXX should be 220us */ +/* Sending the HEAER and PAYLOAD */ +#define T_ACTIVE 1124 /* 650us */ +#define T_PWR_DWN (T_1ms - T_PWR_UP - T_LOOP - T_ACTIVE) + +#define T_TX2RX (T_ACTIVE + T_PWR_DWN) + /* RX on (>50us) before active RX-slot */ #define T_RX_ON 87 /* 50us */ /* Programming (~30us) and PLL loop (>200us) but next IRQ is at RX_ON */ -#define T_LOOP_RX (T_LOOP_TX - T_RX_ON) +#define T_LOOP_RX (T_LOOP - T_RX_ON) -#define T_MAX_PAC_RX 1124 /* 650us */ -#define T_RX2TX (2*T_1ms - T_PWR_UP - T_LOOP_TX - T_TX2RX - T_PWR_UP - \ - T_LOOP_RX - T_RX_ON - T_MAX_PAC_RX) /* Remaining up to 2ms */// 172 - -#define T_START_SYNC 1086 - /* 2->3 (T_TX2RX) should be equal to 6->0 * 6->0 is (T_MAX_PAC_RX + T_RX2TX) for master * ts->0 is (-T_HEADER + T_MAX_PAC_RX + T_RX2TX) for slave */ #define T_SYNC 1086 // ==> 48KB/second (384.000bps) +/* There's a latency between the time the master sends the first byte of the + * pauload and the time the slave captures the last byte of the header. This + * value could be calculated by looking at the assembly or using an + * oscilloscope. */ +#define T_LATENCY 26 + //#define T_1ms 1728 [> Exactly -> 1000us <] //#define T_PWR_UP_TX 69 [> 40us <] //#define T_LOOP_TX 363 [> 210us <] Modified: firmware/rf/trunk/prot.c =================================================================== --- firmware/rf/trunk/prot.c 2008-07-09 13:49:53 UTC (rev 1318) +++ firmware/rf/trunk/prot.c 2008-07-09 14:27:46 UTC (rev 1319) @@ -127,7 +127,7 @@ j = j - ts; /* Changing prescaler!! */ j = j << 3; - OCR1A = T_START_SYNC - j; + OCR1A = T_SYNC - j; start_rf_timer(); return; Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-09 13:49:53 UTC (rev 1318) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-09 14:27:46 UTC (rev 1319) @@ -81,7 +81,7 @@ init_atr2406(channel,TXEN);//configure ATR2406 to desired channel UCSR0A = 0x40; UCSR0B = 0x08; - OCR1A = OCR1A+T_LOOP_TX; + OCR1A = OCR1A + T_LOOP; //calculate new RF-Packet! SOF depending wether connected or not!! rf_buffer_tx[8] = channel; @@ -179,7 +179,7 @@ UCSR0A = 0x00; UCSR0B = 0x90; UCSR0C = 0x46; - OCR1A = OCR1A+T_MAX_PAC_RX; + OCR1A = OCR1A + T_ACTIVE; break; case 0x07: /* RX complete, check what we got. */ @@ -201,18 +201,18 @@ if (rf_status & SLAVE) /* SLAVE, resynchronize. */ { - OCR1A = ts + T_SYNC; + OCR1A = ts + T_SYNC - T_LATENCY; } else /* MASTER */ { - OCR1A = OCR1A+T_RX2TX; + OCR1A = OCR1A + T_PWR_DWN; } } else /* Wrong frame, just continue. */ { - OCR1A = OCR1A+T_RX2TX; + OCR1A = OCR1A + T_PWR_DWN; } break; } @@ -227,7 +227,6 @@ */ void start_rf_timer(void) { - testt = T_RX2TX; TCNT1H = 0x00; TCNT1L = 0x00; TCCR1A = 0x00; @@ -460,11 +459,6 @@ //* Size: tbd * //* Date: * //***************************************************************************** -/* There's a latency between the time the master sends the first byte of the - * pauload and the time the slave captures the last byte of the header. This - * value could be calculated by looking at the assembly or using an - * oscilloscope. */ -#define T_LATENCY 30 ISR(SIG_USART_RECV) { uint8_t data, state; @@ -502,7 +496,7 @@ { if(++state==0x04) { - ts = TCNT1 - T_LATENCY; + ts = TCNT1; } } else |
From: jaguarondi <c2m...@c2...> - 2008-07-09 13:49:47
|
Author: jaguarondi Date: 2008-07-09 15:49:53 +0200 (Wed, 09 Jul 2008) New Revision: 1318 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/rf_ctrl.c Log: * I didn't changed the timings yet but started to redefine them all. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-09 09:47:18 UTC (rev 1317) +++ firmware/rf/trunk/defines.h 2008-07-09 13:49:53 UTC (rev 1318) @@ -98,22 +98,68 @@ /* S[SC] of channel 0 in RX mode, p. 10 of datasheet */ #define CH00RX 28 +#define POLL_LOOPS 4 + /* * T_SLOT == 1ms ==> every 1000us 48 Bytes of payload are exchanged + * 1 tick = 578,704ns */ -#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) +#define T_1ms 1728 /* Exactly -> 1000us */ + +#define PREAMBLE 8 /* Preamble in bytes */ +#define SYNC 2 /* Sync data in bytes */ +#define SOF 4 /* Start Of Frame in bytes */ +#define PAYLOAD 48 /* Payload in bytes */ + +/* USART bit to tick ratio: sys_clk / (8 * 1152e3) */ +#define TICKS_PER_BIT (F_CPU/(8.*1152000)) +/* USART bits per byte + * (8bits + start + stop) */ +#define BITS_PER_BYTE 10 +/* HEADER duration */ +#define T_HEADER ((PREAMBLE + SYNC + SOF) * BITS_PER_BYTE * TICKS_PER_BIT) // 210 +/* PAYLOAD duration */ +#define T_PAYLOAD (PAYLOAD * BITS_PER_BYTE * TICKS_PER_BIT) // 720 + +/* Power-up (> 40us) */ +#define T_PWR_UP 69 /* 40us */ +/* Programming (~20us) and PLL loop (>200us) */ +#define T_LOOP_TX 363 /* 210us */ /*XXX should be 220us */ +#define T_TX2RX 1296 /* 750us */ +/* RX on (>50us) before active RX-slot */ +#define T_RX_ON 87 /* 50us */ +/* Programming (~30us) and PLL loop (>200us) but next IRQ is at RX_ON */ +#define T_LOOP_RX (T_LOOP_TX - T_RX_ON) + +#define T_MAX_PAC_RX 1124 /* 650us */ +#define T_RX2TX (2*T_1ms - T_PWR_UP - T_LOOP_TX - T_TX2RX - T_PWR_UP - \ + T_LOOP_RX - T_RX_ON - T_MAX_PAC_RX) /* Remaining up to 2ms */// 172 + +#define T_START_SYNC 1086 + +/* 2->3 (T_TX2RX) should be equal to 6->0 + * 6->0 is (T_MAX_PAC_RX + T_RX2TX) for master + * ts->0 is (-T_HEADER + T_MAX_PAC_RX + T_RX2TX) for slave */ +#define T_SYNC 1086 // ==> 48KB/second (384.000bps) +//#define T_1ms 1728 [> Exactly -> 1000us <] +//#define T_PWR_UP_TX 69 [> 40us <] +//#define T_LOOP_TX 363 [> 210us <] +//#define T_TX2RX 1296 [> 750us <] +//#define T_PWR_UP_RX 69 [> 40us <] +//#define T_LOOP_RX 276 [> 160us <] +//#define T_RX_ON 87 [> 50us <] +//#define T_MAX_PAC_RX 1124 [> 650us <] +//#define T_RX2TX (2*T_1ms - T_PWR_UP_TX - T_LOOP_TX - T_TX2RX - T_PWR_UP_RX - + //T_LOOP_RX - T_RX_ON - T_MAX_PAC_RX) [> Remaining up to 2ms <] + +//#define T_START_SYNC 1086 + +/* 2->3 (T_TX2RX) should be equal to 6->0 + * 6->0 is (T_MAX_PAC_RX + T_RX2TX) for master + * 6->0 is (ts - T_PREAMBLE + T_MAX_PAC_RX + T_RX2TX) for slave */ +//#define T_SYNC 1086 +//// ==> 48KB/second (384.000bps) + #endif /* DEFINES_H */ Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-09 09:47:18 UTC (rev 1317) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-09 13:49:53 UTC (rev 1318) @@ -48,6 +48,7 @@ ISR (SIG_OUTPUT_COMPARE1A) { + PORTD ^= 0x08; // XXX DEBUG switch(rf_state) { /* @@ -56,7 +57,7 @@ case 0x00: /* Power up for TX. */ pwr_up_atr2406(); - OCR1A = OCR1A+T_PWR_UP_TX; + OCR1A = OCR1A + T_PWR_UP; break; case 0x01: /* Configure in TX. */ @@ -136,7 +137,7 @@ } pwr_up_atr2406(); - OCR1A = OCR1A+T_PWR_UP_RX; + OCR1A = OCR1A + T_PWR_UP; break; case 0x04: /* Configure in RX mode. */ @@ -200,7 +201,7 @@ if (rf_status & SLAVE) /* SLAVE, resynchronize. */ { - OCR1A = ts+T_SYNC-26; + OCR1A = ts + T_SYNC; } else /* MASTER */ @@ -216,14 +217,17 @@ break; } rf_state = (rf_state + 1) & 7; + PORTD ^= 0x08; // XXX DEBUG } +volatile uint16_t testt = T_HEADER; /* * Setup 16 bit timer1 which is used to generate all RF related timings. * We're using a crystal @ sys_clk = 13.824 MHz */ void start_rf_timer(void) { + testt = T_RX2TX; TCNT1H = 0x00; TCNT1L = 0x00; TCCR1A = 0x00; @@ -456,6 +460,11 @@ //* Size: tbd * //* Date: * //***************************************************************************** +/* There's a latency between the time the master sends the first byte of the + * pauload and the time the slave captures the last byte of the header. This + * value could be calculated by looking at the assembly or using an + * oscilloscope. */ +#define T_LATENCY 30 ISR(SIG_USART_RECV) { uint8_t data, state; @@ -493,7 +502,7 @@ { if(++state==0x04) { - ts = TCNT1; + ts = TCNT1 - T_LATENCY; } } else @@ -503,6 +512,7 @@ } rf_rx_state = state; } + //worsest case duration 70 cycles = but as this is the case only with the //last byte it is no problem!! //meaningfull worsest case is 54 |
From: jaguarondi <c2m...@c2...> - 2008-07-09 09:47:12
|
Author: jaguarondi Date: 2008-07-09 11:47:18 +0200 (Wed, 09 Jul 2008) New Revision: 1317 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/rf_ctrl.c Log: * Some more minor stuff before changing the timings of the RF frame. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-09 09:04:09 UTC (rev 1316) +++ firmware/rf/trunk/defines.h 2008-07-09 09:47:18 UTC (rev 1317) @@ -50,6 +50,9 @@ #define MASTER 0x40 #define SLAVE 0x80 +/* + * RF-Specifc-Defines + */ /* I/O ports for the ATR2406 */ #define CLOCK_PORT PORTD #define CLOCK_DDR DDRD @@ -90,28 +93,27 @@ #define in_rxd (PIND & 0x01) -//Hardware Definitions - -//----->RF-Specifc-Defines<-----// /* S[SC] of channel 0 in TX mode, p. 10 of datasheet */ #define CH00TX 27 /* S[SC] of channel 0 in RX mode, p. 10 of datasheet */ #define CH00RX 28 -//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) +/* + * T_SLOT == 1ms ==> every 1000us 48 Bytes 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) +#define T_SYNC 1086//1065 //1065 == 616.32(616.32) // ==> 48KB/second (384.000bps) #endif /* DEFINES_H */ Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-09 09:04:09 UTC (rev 1316) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-09 09:47:18 UTC (rev 1317) @@ -48,18 +48,17 @@ ISR (SIG_OUTPUT_COMPARE1A) { - rf_state = (rf_state + 1) & 7; switch(rf_state) { /* * TX */ - case 0x01: + case 0x00: /* Power up for TX. */ pwr_up_atr2406(); OCR1A = OCR1A+T_PWR_UP_TX; break; - case 0x02: + case 0x01: /* Configure in TX. */ #ifdef NOHOPP channel = TRX_CHANNEL; @@ -88,7 +87,7 @@ //PACKET CALCULATIONS break; - case 0x03: + case 0x02: /* Start transmission. */ OCR1A = OCR1A + T_TX2RX; rf_tx_counter = 0x00; @@ -125,7 +124,7 @@ /* * RX */ - case 0x04: + case 0x03: /* End of TX, power up for RX. */ /* Request a SPI communication. */ @@ -139,7 +138,7 @@ pwr_up_atr2406(); OCR1A = OCR1A+T_PWR_UP_RX; break; - case 0x05: + case 0x04: /* Configure in RX mode. */ #ifdef NOHOPP channel = TRX_CHANNEL; @@ -166,14 +165,14 @@ //PIN configuration for input or output DDRD = DDRD&0xEF;//XCK PIN set to input!! break; - case 0x06: + case 0x05: /* Start receiving. */ OCR1A = OCR1A+T_RX_ON; set_rxon();//power up RF-Chip in receive mode //Setup SOFs!! sof_ary[0] = channel; break; - case 0x07: + case 0x06: /* Used to resync probably. */ checksum = 0x00; UCSR0A = 0x00; @@ -181,7 +180,7 @@ UCSR0C = 0x46; OCR1A = OCR1A+T_MAX_PAC_RX; break; - case 0x00: + case 0x07: /* RX complete, check what we got. */ UCSR0A = 0x00; UCSR0B = 0x00; @@ -216,28 +215,21 @@ } break; } + rf_state = (rf_state + 1) & 7; } -//***************************************************************************** -//* Project: RF-Firmware for ISM * -//* Function: pwr_up_atr2406 * -//* Parameters: None * -//* Returns: None * -//* Action: init Timer1 * -//* Duration: tbd * -//* Size: tbd * -//* Date: 31.01.06 * -//* Description: Basic setup and start of the RF - Timer (Timer1) * -//***************************************************************************** +/* + * Setup 16 bit timer1 which is used to generate all RF related timings. + * We're using a crystal @ sys_clk = 13.824 MHz + */ void start_rf_timer(void) { - //setup 16 bit timer1 to generate all rf related timings TCNT1H = 0x00; TCNT1L = 0x00; TCCR1A = 0x00; - TCCR1B = 0x02;//clocksource enabled @ sys_clk/8 ==> 1 click == 578,704ns - TIMSK1 = 0x02;//enable compare A irq - TIFR1 = 0x02; //clear all flags + TCCR1B = 0x02; /* sys_clk/8 ==> 1 click = 578,704ns */ + TIMSK1 = 0x02; /* Enable compare A IRQ */ + TIFR1 = 0x02; /* Clear all flags */ } //***************************************************************************** |
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; |
From: jaguarondi <c2m...@c2...> - 2008-07-08 14:51:34
|
Author: jaguarondi Date: 2008-07-08 16:51:42 +0200 (Tue, 08 Jul 2008) New Revision: 1315 Modified: firmware/rf/trunk/init.c Log: * Cleanup. Modified: firmware/rf/trunk/init.c =================================================================== --- firmware/rf/trunk/init.c 2008-07-08 14:26:00 UTC (rev 1314) +++ firmware/rf/trunk/init.c 2008-07-08 14:51:42 UTC (rev 1315) @@ -1,109 +1,80 @@ -//***************************************************************************** -//* Project: RF-Firmware Point to Multipoint for ISM - Transceiver ATR2406 * -//* Version: V1.0 * -//* File: init.c * -//* 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$ */ + #include "defines.h" #include "init.h" #include "varis.h" -//***************************************************************************** -//* Project: RF-Firmware for ISM * -//* Function: init_avr * -//* Parameters: NONE * -//* Returns: NONE * -//* Action: Basic setup of AVR * -//* Duration: tbd * -//* Size: tbd * -//* Date: 31.01.06 * -//* Description: Basic setup of the AVR I/O and for the RF-USART * -//***************************************************************************** +/* + * Initialization of the AVR I/O and peripherals. + */ void init_avr(void) { - //init of AVR ports - //*************PORTB*************// - //PORTB.0 -> OUT TXON - //PORTB.1 -> OUT nOLE - //PORTB.2 -> IN SS - //PORTB.3 -> IN MOSI - //PORTB.4 -> OUT MISO - //PORTB.5 -> IN SCK - //PORTB.6 -> XTAL1 - //PORTB.7 -> XTAL2 (output to RF - Chip) - PORTB = 0x20; - DDRB = 0x13; - //*************PORTB*************// - //*************PORTC*************// - //PORTC.0 -> SPIACK - //PORTC.1 -> OUT Enable - //PORTC.2 -> TXE (TX [register] empty) - //PORTC.3 -> NOT USED, PULLED UP - //PORTC.4 -> NOT USED, PULLED UP - //PORTC.5 -> NOT USED, PULLED UP - //PORTC.6 -> RESET - PORTC = 0x38; - DDRC = 0x07; - //*************PORTC*************// - //*************PORTD*************// - //PORTD.0 -> IN RX_DATA - //PORTD.1 -> OUT TX_DATA/Data - //PORTD.2 -> OUT PU_TRX/PU_REG - //PORTD.3 -> PASCAL SAID NOT TO TOUCH THIS ONE - //PORTD.4 -> I/O CLK_REC/Clock - //PORTD.5 -> OUT RXON - //PORTD.6 -> NOT USED, PULLED UP - //PORTD.7 -> LINK - PORTD = 0x40; - DDRD = 0xA6; - //*************PORTD*************// - //***********init-needed-peripherals***************// - UBRR0L = 0x05; - //***********init-needed-peripherals***************// - /* Disable UART */ + /* + PORTB.0 -> OUT TXON + PORTB.1 -> OUT nOLE + PORTB.2 -> IN SS + PORTB.3 -> IN MOSI + PORTB.4 -> OUT MISO + PORTB.5 -> IN SCK + PORTB.6 -> XTAL1 + PORTB.7 -> XTAL2 (output to RF - Chip) + */ + PORTB = 0x20; + DDRB = 0x13; + + /* + PORTC.0 -> SPIACK + PORTC.1 -> OUT Enable + PORTC.2 -> TXE (TX [register] empty) + PORTC.3 -> NOT USED, PULLED UP + PORTC.4 -> NOT USED, PULLED UP + PORTC.5 -> NOT USED, PULLED UP + PORTC.6 -> RESET + */ + PORTC = 0x38; + DDRC = 0x07; + + /* + PORTD.0 -> IN RX_DATA + PORTD.1 -> OUT TX_DATA/Data + PORTD.2 -> OUT PU_TRX/PU_REG + PORTD.3 -> PASCAL SAID NOT TO TOUCH THIS ONE + PORTD.4 -> I/O CLK_REC/Clock + PORTD.5 -> OUT RXON + PORTD.6 -> NOT USED, PULLED UP + PORTD.7 -> LINK + */ + PORTD = 0x40; + DDRD = 0xA6; + + /* USART baud rate */ + UBRR0L = 0x05; + + /* Disable the USART for now */ UCSR0A = 0x00; UCSR0B = 0x00; UCSR0C = 0x00; - /* Disable interrupts. */ + /* Disable timer interrupt. */ TIMSK1 = 0x00; /* Read the gaussian filter setting */ @@ -113,8 +84,8 @@ { GFCS = 4; } - } + //***************************************************************************** //* Project: RF-Firmware for ISM * //* Function: init_varis * @@ -208,5 +179,3 @@ rf_buffer_tx[62]=0x55; rf_buffer_tx[63]=0x34; /* Parity checksum manually calculated */ } - - |
From: jaguarondi <c2m...@c2...> - 2008-07-08 14:25:59
|
Author: jaguarondi Date: 2008-07-08 16:26:00 +0200 (Tue, 08 Jul 2008) New Revision: 1314 Modified: firmware/rf/trunk/defines.h firmware/rf/trunk/init.c firmware/rf/trunk/rf_ctrl.c firmware/rf/trunk/varis.c firmware/rf/trunk/varis.h Log: * The gaussian filter setting is now read from EEPROM. Modified: firmware/rf/trunk/defines.h =================================================================== --- firmware/rf/trunk/defines.h 2008-07-08 10:57:20 UTC (rev 1313) +++ firmware/rf/trunk/defines.h 2008-07-08 14:26:00 UTC (rev 1314) @@ -58,6 +58,13 @@ //#define CYCHOPP //**Define the used HOPPING SCHEME**// +/* Address in EEPROM of GFCS */ +#define EE_GFCS (uint8_t*)0 + +/* Scrambled byte used to code the values sent through the USART to the ATR2406 + */ +#define SCRAMBLE_BYTE 0x0F + #define TXEN 0x01 #define RXEN 0x00 #define CONNECTED 0x80 Modified: firmware/rf/trunk/init.c =================================================================== --- firmware/rf/trunk/init.c 2008-07-08 10:57:20 UTC (rev 1313) +++ firmware/rf/trunk/init.c 2008-07-08 14:26:00 UTC (rev 1314) @@ -46,8 +46,6 @@ #include "init.h" #include "varis.h" - - //***************************************************************************** //* Project: RF-Firmware for ISM * //* Function: init_avr * @@ -107,6 +105,15 @@ /* Disable interrupts. */ TIMSK1 = 0x00; + + /* Read the gaussian filter setting */ + GFCS = eeprom_read_byte(EE_GFCS); + /* If the eeprom is unprogrammed or out of range, use a default value */ + if (GFCS > 7) + { + GFCS = 4; + } + } //***************************************************************************** //* Project: RF-Firmware for ISM * Modified: firmware/rf/trunk/rf_ctrl.c =================================================================== --- firmware/rf/trunk/rf_ctrl.c 2008-07-08 10:57:20 UTC (rev 1313) +++ firmware/rf/trunk/rf_ctrl.c 2008-07-08 14:26:00 UTC (rev 1314) @@ -1,54 +1,30 @@ -//***************************************************************************** -//* Project: RF-Firmware Point to Multipoint for ISM - Transceiver ATR2406 * -//* Version: V1.0 * -//* File: rf_ctrl.c * -//* 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$ */ + #include "defines.h" #include "init.h" #include "varis.h" #include "misc.h" #include "rf_ctrl.h" #include "prot.h" - #include "interface.h" volatile int8_t spi_tmp; /* XXX debug */ @@ -297,7 +273,6 @@ //* Description: Programms the ATR2406 to the desired channel and to the * //* desired mode. * //***************************************************************************** -#define GFCS 7 void init_atr2406(uint8_t channel,uint8_t mode) { uint8_t i, dat_l, dat_h, tmp; Modified: firmware/rf/trunk/varis.c =================================================================== --- firmware/rf/trunk/varis.c 2008-07-08 10:57:20 UTC (rev 1313) +++ firmware/rf/trunk/varis.c 2008-07-08 14:26:00 UTC (rev 1314) @@ -44,6 +44,8 @@ #include "defines.h" +/* GFCS parameter of the ATR2406 (gaussian filter) */ +uint8_t GFCS; //***************************************************************************** // SETUP of RF_BUFFER_TX: * Modified: firmware/rf/trunk/varis.h =================================================================== --- firmware/rf/trunk/varis.h 2008-07-08 10:57:20 UTC (rev 1313) +++ firmware/rf/trunk/varis.h 2008-07-08 14:26:00 UTC (rev 1314) @@ -44,11 +44,9 @@ #ifndef VARIS_H #define VARIS_H - - #include "defines.h" -#define SCRAMBLE_BYTE 0x0F +uint8_t GFCS; extern volatile uint8_t rf_buffer_tx[]; extern uint8_t volatile *rf_buffer_rx; |
From: jaguarondi <c2m...@c2...> - 2008-07-08 10:57:16
|
Author: jaguarondi Date: 2008-07-08 12:57:20 +0200 (Tue, 08 Jul 2008) New Revision: 1313 Modified: firmware/fuxusb/branches/new_rf/src/spi_task.c firmware/tuxaudio/branches/new_rf/communication.c Log: * Added an ACK on commands bewteen tuxaudio and tuxcore. This slows down the data rate but we don't need much for data anyway. I'd leave like this until there's a real need to do otherwise. Modified: firmware/fuxusb/branches/new_rf/src/spi_task.c =================================================================== --- firmware/fuxusb/branches/new_rf/src/spi_task.c 2008-07-08 08:30:39 UTC (rev 1312) +++ firmware/fuxusb/branches/new_rf/src/spi_task.c 2008-07-08 10:57:20 UTC (rev 1313) @@ -31,6 +31,7 @@ #include "fifo_spk.h" #include "fifo_mic.h" #include "fifo_stt.h" +#include "common/defines.h" /** * \brief spi_slave enum define the steps of the SPI frame. @@ -72,30 +73,8 @@ static bit spi_ready = 0; static bit spi_Start_Flag = 0; -/** \name SPI frame constants - * @{ */ -/** Size of the audio data in the SPI frame */ -// XXX Double frame -#define AUDIO_SPK_SIZE 34 -#define AUDIO_MIC_SIZE 17 - -/* Bits of the config byte */ -#define _BV(x) (1<<x) -#define CFG_CRCOK_MK _BV(0) -#define CFG_DATA_MK _BV(1) -#define CFG_AUDIO_MK _BV(2) -#define CFG_PREVAUDIO_MK _BV(3) - -/* SPI frame organization */ -#define SPI_SIZE 50 -#define SPI_IDX_OFFSET 0 -#define SPI_CONFIG_OFFSET 1 -#define SPI_DATA_OFFSET 3 -#define SPI_AUDIO_OFFSET (SPI_DATA_OFFSET + CMD_SIZE) -/*! @} */ - static uint8_t spi_in[SPI_SIZE], spi_out[SPI_SIZE], spi_idx; -static uint8_t idx_in, idx_out; +static uint8_t frame_in_idx, frame_out_idx; /** * \brief Reset the SPI task to the defaults states. @@ -196,7 +175,6 @@ */ void spi_task(void) { - uint8_t config; uint8_t i; static bit prev_spi_start = False; @@ -228,13 +206,38 @@ } else if (spi_idx >= SPI_SIZE) { + uint8_t config_in = 0; + static uint8_t config_out = 0; + spi_idx = 0; - /* Prepare next SPI frame to be sent to the RF */ - config = 0; - if (new_command_received) + config_in = spi_in[SPI_CONFIG_OFFSET]; + + /* Incoming data */ + if (frame_in_idx != spi_in[SPI_IDX_OFFSET]) { + frame_in_idx = spi_in[SPI_IDX_OFFSET]; + if ((!(config_in & CFG_DATA_MK)) != (!(config_out & CFG_ACK_MK))) + { + for (i=0; i<CMD_SIZE; i++) + { + FIFO_STT_put(spi_in[i+SPI_DATA_OFFSET]); + } + /* Ack the data */ + config_out ^= CFG_ACK_MK; + } + if (config_in & CFG_AUDIO_MK) + { + FIFO_MIC_put_n(&spi_in[SPI_AUDIO_OFFSET], AUDIO_MIC_SIZE); + } + } + + /* Outgoing data, add commands and/or audio. */ + spi_out[SPI_IDX_OFFSET] = frame_out_idx++; + if ((!(config_out & CFG_DATA_MK)) == (!(config_in & CFG_ACK_MK)) && + new_command_received) + { new_command_received = False; - config |= CFG_DATA_MK; + config_out ^= CFG_DATA_MK; for (i=0; i<CMD_SIZE; i++) { spi_out[i+SPI_DATA_OFFSET] = command_received[i]; @@ -242,44 +245,14 @@ } if (FIFO_SPK_length() >= AUDIO_SPK_SIZE) { - config |= CFG_AUDIO_MK; + config_out |= CFG_AUDIO_MK; FIFO_SPK_get_n(&spi_out[SPI_AUDIO_OFFSET], AUDIO_SPK_SIZE); } - - - /* Store the frame index and the config byte. */ - spi_out[SPI_IDX_OFFSET] = idx_out++; - spi_out[SPI_CONFIG_OFFSET] = config; - - /* XXX debug */ - /*for (i=0; i<SPI_SIZE; i++)*/ - /*spi_out[i] = 0x00;//1<<(i&7);*/ - /*for (i=23; i<45; i++)*/ - /*spi_out[i] = 0x00;//1<<(i&7);*/ - /*for (i=45; i<SPI_SIZE; i+=1)*/ - /*spi_out[i] = 0x01;*/ - /*for (i=40; i<50; i++)*/ - /*spi_out[i] = 0x55;*/ - - /* Store and increment the index of the frame. */ - - /* Process last SPI frame received from the RF */ - if (idx_in != spi_in[SPI_IDX_OFFSET]) + else { - idx_in = spi_in[SPI_IDX_OFFSET]; - config = spi_in[SPI_CONFIG_OFFSET]; - if (config & CFG_DATA_MK) - { - for (i=0; i<CMD_SIZE; i++) - { - FIFO_STT_put(spi_in[i+SPI_DATA_OFFSET]); - } - } - if (config & CFG_AUDIO_MK) - { - FIFO_MIC_put_n(&spi_in[SPI_AUDIO_OFFSET], AUDIO_MIC_SIZE); - } + config_out &= ~CFG_AUDIO_MK; } + spi_out[SPI_CONFIG_OFFSET] = config_out; } P3_6 = 0; /* XXX debug */ } Modified: firmware/tuxaudio/branches/new_rf/communication.c =================================================================== --- firmware/tuxaudio/branches/new_rf/communication.c 2008-07-08 08:30:39 UTC (rev 1312) +++ firmware/tuxaudio/branches/new_rf/communication.c 2008-07-08 10:57:20 UTC (rev 1313) @@ -242,26 +242,6 @@ * SPI communication */ -/** \name SPI frame constants - * @{ */ -/** Size of the audio data in the SPI frame */ -#define AUDIO_SPK_SIZE 34 -#define AUDIO_MIC_SIZE 17 - -/* Bits of the config byte */ -#define CFG_CRCOK_MK _BV(0) -#define CFG_DATA_MK _BV(1) -#define CFG_AUDIO_MK _BV(2) -#define CFG_PREVAUDIO_MK _BV(3) - -/* SPI frame organization */ -#define SPI_SIZE 51 -#define SPI_IDX_OFFSET 0 -#define SPI_CONFIG_OFFSET 1 -#define SPI_DATA_OFFSET 3 -#define SPI_AUDIO_OFFSET (SPI_DATA_OFFSET + CMD_SIZE) -/*! @} */ - static uint8_t frame_in_idx, frame_out_idx; static uint8_t spi_in[52], spi_out[52], spi_idx; @@ -280,8 +260,6 @@ //PORTB &= ~0x80; // XXX DEBUG } - -/* XXX add an spi_config byte as register that could be checked by bits */ /* INT0 (PD0) Interrupt on SPIACK signal. */ ISR(SIG_INTERRUPT0) { @@ -341,8 +319,8 @@ } /** - * \brief Service routine that handles the regular communication tasks like sending - * and fetching commands. + * \brief Service routine that handles the regular communication tasks like + * sending and fetching commands. */ void communication_task(void) { @@ -356,47 +334,29 @@ /* Fill and process RF data. */ if (spi_idx >= SPI_SIZE) { - uint8_t config; + uint8_t config_in; + static uint8_t config_out; uint8_t i; spi_idx = 0; + config_in = spi_in[SPI_CONFIG_OFFSET]; - /* Add data and/or audio if necessary. */ - config = 0; - if (FifoLength(rf_cmdout_buf) >= CMD_SIZE) - { - config |= CFG_DATA_MK; - for (i=0; i<CMD_SIZE; i++) - { - FifoGet(rf_cmdout_buf, &spi_out[i+SPI_DATA_OFFSET]); - } - } - if (FifoLength(ADCFifo) >= AUDIO_MIC_SIZE) - { - config |= CFG_AUDIO_MK; - for (i=0; i<AUDIO_MIC_SIZE; i++) - { - FifoGet(ADCFifo, &spi_out[i+SPI_AUDIO_OFFSET]); - } - } - spi_out[SPI_IDX_OFFSET] = frame_out_idx++; - spi_out[SPI_CONFIG_OFFSET] = config; - /* Incoming data */ if (frame_in_idx != spi_in[SPI_IDX_OFFSET]) { //PORTB |= 0x80; // XXX DEBUG frame_in_idx = spi_in[SPI_IDX_OFFSET]; - config = spi_in[SPI_CONFIG_OFFSET]; - if (config & CFG_DATA_MK) + if ((!(config_in & CFG_DATA_MK)) != (!(config_out & CFG_ACK_MK))) { /* Parse the command and forward to tuxcore if it isn't * dropped. */ uint8_t *cmd = &spi_in[SPI_DATA_OFFSET]; if (!parse_cmd(cmd)) queue_core_cmd(cmd); + /* Ack the data by toggling the bit */ + config_out ^= CFG_ACK_MK; } - if (config & CFG_AUDIO_MK) + if (config_in & CFG_AUDIO_MK) { adapt_audio_rate(); @@ -414,6 +374,31 @@ } //else //PORTB |= 0x80; // XXX DEBUG + + /* Outgoing data, add commands and/or audio. */ + spi_out[SPI_IDX_OFFSET] = frame_out_idx++; + if ((!(config_out & CFG_DATA_MK)) == (!(config_in & CFG_ACK_MK)) && + FifoLength(rf_cmdout_buf) >= CMD_SIZE) + { + config_out ^= CFG_DATA_MK; + for (i=0; i<CMD_SIZE; i++) + { + FifoGet(rf_cmdout_buf, &spi_out[i+SPI_DATA_OFFSET]); + } + } + if (FifoLength(ADCFifo) >= AUDIO_MIC_SIZE) + { + config_out |= CFG_AUDIO_MK; + for (i=0; i<AUDIO_MIC_SIZE; i++) + { + FifoGet(ADCFifo, &spi_out[i+SPI_AUDIO_OFFSET]); + } + } + else + { + config_out &= ~CFG_AUDIO_MK; + } + spi_out[SPI_CONFIG_OFFSET] = config_out; } /* If busy, pass. */ |
From: jaguarondi <c2m...@c2...> - 2008-07-08 08:30:32
|
Author: jaguarondi Date: 2008-07-08 10:30:39 +0200 (Tue, 08 Jul 2008) New Revision: 1312 Modified: firmware/rf/trunk/Makefile Log: * 'make prog' now compiles and programs both firmware. Modified: firmware/rf/trunk/Makefile =================================================================== --- firmware/rf/trunk/Makefile 2008-07-08 08:29:16 UTC (rev 1311) +++ firmware/rf/trunk/Makefile 2008-07-08 08:30:39 UTC (rev 1312) @@ -112,7 +112,7 @@ ## Clean target .PHONY: clean clean: - -rm -rf $(OBJECTS) main.elf dep/* $(PROJECT).* svnrev.h + -rm -rf $(OBJECTS) main.elf dep/* $(PROJECT).{elf,lss} svnrev.h ## Other dependencies @@ -120,7 +120,11 @@ # Programming prog: $(PROJECT).hex - tuxup $(PROJECT).hex $(PROJECT).eep + make TYPE=master clean + make TYPE=master + make TYPE=slave clean + make TYPE=slave + tuxup fuxrf.hex tuxrf.hex dwen: $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -U hfuse:w:0x95:m |
From: jaguarondi <c2m...@c2...> - 2008-07-08 08:29:13
|
Author: jaguarondi Date: 2008-07-08 10:29:16 +0200 (Tue, 08 Jul 2008) New Revision: 1311 Modified: firmware/tuxdefs/defines.h Log: * Moved the SPI frame definitions to the common files. Modified: firmware/tuxdefs/defines.h =================================================================== --- firmware/tuxdefs/defines.h 2008-07-04 07:12:49 UTC (rev 1310) +++ firmware/tuxdefs/defines.h 2008-07-08 08:29:16 UTC (rev 1311) @@ -256,7 +256,31 @@ #define FW_MAIN_LOOP_DELAY 0.004 /*! @} */ +/** \name RF SPI frame structure + * @{ */ + +/* SPI frame structure */ +#define SPI_SIZE 51 +#define SPI_IDX_OFFSET 0 +#define SPI_CONFIG_OFFSET 1 +#define SPI_DATAIDX_OFFSET 2 +#define SPI_DATA_OFFSET 3 +#define SPI_AUDIO_OFFSET (SPI_DATA_OFFSET + CMD_SIZE) + +/** Size of the audio data in the SPI frame */ +#define AUDIO_SPK_SIZE 34 +#define AUDIO_MIC_SIZE 17 + +/* Bits of the config byte */ +#define CFG_CRCOK_MK _BV(0) +#define CFG_DATA_MK _BV(1) +#define CFG_AUDIO_MK _BV(2) +#define CFG_PREVAUDIO_MK _BV(3) +#define CFG_ACK_MK _BV(4) + /*! @} */ +/*! @} */ + #endif /* _DEFINES_H_ */ |
From: remi <c2m...@c2...> - 2008-07-04 07:12:54
|
Author: remi Date: 2008-07-04 09:12:49 +0200 (Fri, 04 Jul 2008) New Revision: 1310 Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_driver.c software_suite_v2/middleware/tuxdriver/trunk/src/version.h Log: * updated some version messages with the revision number (from svncwrev tool) * removed the build information from "version.h" Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_driver.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_driver.c 2008-07-03 14:58:41 UTC (rev 1309) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_driver.c 2008-07-04 07:12:49 UTC (rev 1310) @@ -440,14 +440,14 @@ tux_desc->driver.version_major = VER_MAJOR; tux_desc->driver.version_minor = VER_MINOR; tux_desc->driver.version_update = VER_UPDATE; - tux_desc->driver.version_build = VER_BUILD; + tux_desc->driver.version_build = VER_REVISION; strcpy(tux_desc->driver.version_state, VER_STATE); sprintf(tux_desc->driver.version_string, - "Tux_driver_%d.%d.%d - b%.3d (%s)", + "libtuxdriver_%d.%d.%d-r%d(%s)", VER_MAJOR, VER_MINOR, VER_UPDATE, - VER_BUILD, + VER_REVISION, VER_STATE); } @@ -466,11 +466,11 @@ LIBEXPORT void TuxDrv_Start(void) { - printf("Tux driver v%d.%d.%d-b%.3d(%s)\n\n", + printf("libtuxdriver_%d.%d.%d-r%d(%s)\n\n", VER_MAJOR, VER_MINOR, VER_UPDATE, - VER_BUILD, + VER_REVISION, VER_STATE); tux_usb_init_module(); Modified: software_suite_v2/middleware/tuxdriver/trunk/src/version.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/version.h 2008-07-03 14:58:41 UTC (rev 1309) +++ software_suite_v2/middleware/tuxdriver/trunk/src/version.h 2008-07-04 07:12:49 UTC (rev 1310) @@ -27,7 +27,6 @@ #define VER_MAJOR 0 #define VER_MINOR 0 #define VER_UPDATE 1 -#define VER_BUILD 11 #define VER_REVISION SVN_REV #define VER_DATE SVN_REVDATE #define VER_STATE "BETA" |
From: remi <c2m...@c2...> - 2008-07-03 14:58:36
|
Author: remi Date: 2008-07-03 16:58:41 +0200 (Thu, 03 Jul 2008) New Revision: 1309 Added: software_suite_v2/middleware/tuxdriver/trunk/src/svnrev.tmpl.h Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c software_suite_v2/middleware/tuxdriver/trunk/src/version.h software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile software_suite_v2/middleware/tuxdriver/trunk/win32/Makefile Log: * updated version.h with the directory revision requested by the tool : svnwcrev on linux SubWCRev on windows Added: software_suite_v2/middleware/tuxdriver/trunk/src/svnrev.tmpl.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/svnrev.tmpl.h (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/svnrev.tmpl.h 2008-07-03 14:58:41 UTC (rev 1309) @@ -0,0 +1,37 @@ +/* + * Tux Droid - svnrev template + * Copyright (C) 2008 C2ME Sa + * + * 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, 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. + */ +/* SVN : $Id$ */ +/* This file is a template to generate svnrev.h automatically. + * SubWCRev performs keyword susbstitution whith SVN information. + */ + +#ifndef _SVNREV_H_ +#define _SVNREV_H_ + +#define SVN_REV $WCREV$ +#define SVN_REVSTR "$WCREV$" +#define SVN_REVDATE "$WCDATE$" +#define SVN_MOD $WCMODS?1:0$ +#define SVN_MIX $WCMIXED?1:0$ +#define SVN_STATUS (SVN_MOD + (SVN_MIX<<1)) +#define SVN_RANGE "$WCRANGE$" +#define SVN_URL "$WCURL$" + +#endif /* _SVNREV_H_ */ Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c 2008-07-03 13:13:11 UTC (rev 1308) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c 2008-07-03 14:58:41 UTC (rev 1309) @@ -213,19 +213,16 @@ tux_sw_status_init(void) { static char driver_symbolic_version[128] = ""; - char tmp_str[14] = VER_REVISION; - char my_rev[6] = "00000"; #ifdef USE_MUTEX mutex_init(__status_mutex); #endif - memcpy(&my_rev[0], &tmp_str[7], 5); - sprintf(driver_symbolic_version, "libtuxdriver-%d.%d.%d-r%s(%s)", + sprintf(driver_symbolic_version, "libtuxdriver_%d.%d.%d-r%d(%s)", VER_MAJOR, VER_MINOR, VER_UPDATE, - my_rev, + VER_REVISION, VER_STATE); tux_sw_status_set_strvalue(SW_ID_DRIVER_SYMBOLIC_VERSION, Modified: software_suite_v2/middleware/tuxdriver/trunk/src/version.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/version.h 2008-07-03 13:13:11 UTC (rev 1308) +++ software_suite_v2/middleware/tuxdriver/trunk/src/version.h 2008-07-03 14:58:41 UTC (rev 1309) @@ -22,11 +22,14 @@ #ifndef _VERSION_H_ #define _VERSION_H_ +#include "svnrev.h" + #define VER_MAJOR 0 #define VER_MINOR 0 #define VER_UPDATE 1 #define VER_BUILD 11 -#define VER_REVISION "$Rev:: $" +#define VER_REVISION SVN_REV +#define VER_DATE SVN_REVDATE #define VER_STATE "BETA" #ifdef WIN32 # define VER_ARCH "WIN32" Modified: software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile 2008-07-03 13:13:11 UTC (rev 1308) +++ software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile 2008-07-03 14:58:41 UTC (rev 1309) @@ -76,6 +76,7 @@ directories: -@if [ ! -d "$(OUTPUT_DIR)" ]; then mkdir "$(OUTPUT_DIR)"; fi -@if [ ! -d "$(OBJ_DIR)" ]; then mkdir "$(OBJ_DIR)"; fi + -@svnwcrev ../src ../src/svnrev.tmpl.h ../src/svnrev.h $(OBJ_DIR)/tux_battery.o: ../src/tux_battery.c \ ../src/tux_hw_status.h \ Modified: software_suite_v2/middleware/tuxdriver/trunk/win32/Makefile =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/win32/Makefile 2008-07-03 13:13:11 UTC (rev 1308) +++ software_suite_v2/middleware/tuxdriver/trunk/win32/Makefile 2008-07-03 14:58:41 UTC (rev 1309) @@ -71,6 +71,7 @@ directories: -@if [ ! -d "$(OUTPUT_DIR)" ]; then mkdir "$(OUTPUT_DIR)"; fi -@if [ ! -d "$(OBJ_DIR)" ]; then mkdir "$(OBJ_DIR)"; fi + -@SubWCRev ../src ../src/svnrev.tmpl.h ../src/svnrev.h $(OBJ_DIR)/tux_battery.o: ../src/tux_battery.c \ ../src/tux_hw_status.h \ |
From: remi <c2m...@c2...> - 2008-07-03 13:13:09
|
Author: remi Date: 2008-07-03 15:13:11 +0200 (Thu, 03 Jul 2008) New Revision: 1308 Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c Log: * updated the version status Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c 2008-07-03 12:29:50 UTC (rev 1307) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c 2008-07-03 13:13:11 UTC (rev 1308) @@ -212,19 +212,21 @@ LIBLOCAL void tux_sw_status_init(void) { - static char driver_symbolic_version[128] = ""; + static char driver_symbolic_version[128] = ""; + char tmp_str[14] = VER_REVISION; + char my_rev[6] = "00000"; #ifdef USE_MUTEX mutex_init(__status_mutex); #endif - sprintf(driver_symbolic_version, "libtuxdriver-%d.%d.%d-b%.3d(%s)(%s)", + memcpy(&my_rev[0], &tmp_str[7], 5); + sprintf(driver_symbolic_version, "libtuxdriver-%d.%d.%d-r%s(%s)", VER_MAJOR, VER_MINOR, VER_UPDATE, - VER_BUILD, - VER_STATE, - VER_ARCH); + my_rev, + VER_STATE); tux_sw_status_set_strvalue(SW_ID_DRIVER_SYMBOLIC_VERSION, driver_symbolic_version, false); |