Add comments, bugfixes, merge avr-atmega128rfa1 platform changes to avr-raven

This commit is contained in:
dak664 2011-02-07 14:06:53 -05:00
parent f1f32c8e6a
commit 519cce0019
3 changed files with 82 additions and 17 deletions

View file

@ -291,6 +291,7 @@ raven_gui_loop(process_event_t ev, process_data_t data)
} else switch (ev) {
case SERIAL_CMD:
/* Check for command from serial port, execute it. */
/* Note cmd frame is written in an interrupt - delays here can cause overwriting by next command */
PRINTF("\nCommand %d length %d done %d",cmd.cmd,cmd.len,cmd.done);
if (cmd.done){
/* Execute the waiting command */

View file

@ -30,8 +30,7 @@
*
* @(#)$$
*/
/* Test github commit from windows 7 TortoiseGit */
/* Test github commit from Vista TortoiseGit */
/**
* \file
* Configuration for Atmel Raven
@ -40,7 +39,7 @@
* Simon Barner <barner@in.tum.de>
* David Kopf <dak664@embarqmail.com>
*/
/* Test git commit */
#ifndef __CONTIKI_CONF_H__
#define __CONTIKI_CONF_H__
@ -75,6 +74,10 @@ unsigned long clock_seconds(void);
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
/* The 1284p can use TIMER2 with the external 32768Hz crystal to keep time. Else TIMER0 is used. */
/* The sleep timer in raven-lcd.c also uses the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
#define AVR_CONF_USE32KCRYSTAL 0
/* COM port to be used for SLIP connection. Not tested on Raven */
#define SLIP_PORT RS232_PORT_0
@ -168,15 +171,17 @@ unsigned long clock_seconds(void);
#define CHANNEL_802_15_4 26
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
#define RF230_CONF_AUTOACK 1
/* Request 802.15.4 ACK on all packets sent (else autoretry) */
/* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
#define SICSLOWPAN_CONF_ACK_ALL 0
/* Number of auto retry attempts 0-15 (0 implies don't use extended TX_ARET_ON mode with CCA) */
#define RF230_CONF_AUTORETRIES 2
#define SICSLOWPAN_CONF_FRAG 1
//Most browsers reissue GETs after 3 seconds which stops frag reassembly, longer MAXAGE does no good
/* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
#define SICSLOWPAN_CONF_MAXAGE 3
/* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
#define UIP_CONF_WAIT_TIMEOUT 5
#elif 0 /* Contiki-mac radio cycling */
#elif 1 /* Contiki-mac radio cycling */
//#define NETSTACK_CONF_MAC nullmac_driver
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC contikimac_driver
@ -190,17 +195,21 @@ unsigned long clock_seconds(void);
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
#elif 1 /* cx-mac radio cycling */
/* RF230 does clear-channel assessment in extended mode (autoretries>0) */
#define RF230_CONF_AUTORETRIES 1
#if RF230_CONF_AUTORETRIES
#define NETSTACK_CONF_MAC nullmac_driver
//#define NETSTACK_CONF_MAC csma_driver
#else
#define NETSTACK_CONF_MAC csma_driver
#endif
#define NETSTACK_CONF_RDC cxmac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#define NETSTACK_CONF_RADIO rf230_driver
#define CHANNEL_802_15_4 26
#define RF230_CONF_AUTOACK 1
#define RF230_CONF_AUTORETRIES 1
#define SICSLOWPAN_CONF_FRAG 1
#define SICSLOWPAN_CONF_MAXAGE 3
#define CXMAC_CONF_ANNOUNCEMENTS 0
#define CXMAC_CONF_ANNOUNCEMENTS 0
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
//Below gives 10% duty cycle, undef for default 5%

View file

@ -107,22 +107,30 @@ SIGNATURE = {
};
FUSES ={.low = 0xe2, .high = 0x99, .extended = 0xff,};
/*----------------------Configuration of EEPROM---------------------------*/
/* Use existing EEPROM if it passes the integrity test, else reinitialize with build values */
/* Put default MAC address in EEPROM */
#if WEBSERVER
extern uint8_t mac_address[8]; //These are defined in httpd-fsdata.c via makefsdata.h
extern uint8_t mac_address[8]; //These are defined in httpd-fsdata.c via makefsdata.h
extern uint8_t server_name[16];
extern uint8_t domain_name[30];
#else
uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
uint8_t mac_address[8] PROGMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
#endif
#ifdef CHANNEL_802_15_4
uint8_t rf_channel[2] EEMEM = {CHANNEL_802_15_4, ~CHANNEL_802_15_4};
#else
uint8_t rf_channel[2] EEMEM = {22, ~22};
#endif
volatile uint8_t eeprom_channel;
static uint8_t get_channel_from_eeprom() {
uint8_t eeprom_channel;
// volatile uint8_t eeprom_channel;
uint8_t eeprom_check;
eeprom_channel = eeprom_read_byte((uint8_t *)9);
eeprom_check = eeprom_read_byte((uint8_t *)10);
eeprom_channel = eeprom_read_byte(&rf_channel[0]);
eeprom_check = eeprom_read_byte(&rf_channel[1]);
if(eeprom_channel==~eeprom_check)
return eeprom_channel;
@ -149,15 +157,22 @@ static uint16_t get_panaddr_from_eeprom(void) {
return 0;
}
void calibrate_rc_osc_32k();
/*-------------------------Low level initialization------------------------*/
/*------Done in a subroutine to keep main routine stack usage small--------*/
void initialize(void)
{
//calibrate_rc_osc_32k(); //CO: Had to comment this out
watchdog_init();
watchdog_start();
#define CONFIG_STACK_MONITOR 1
#if CONFIG_STACK_MONITOR
extern uint16_t __bss_end;
__bss_end = 0x4242;
*(uint16_t *)(&__bss_end+100) = 0x4242;
#endif
#ifdef RAVEN_LCD_INTERFACE
/* First rs232 port for Raven 3290 port */
rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
@ -170,6 +185,24 @@ void initialize(void)
/* Redirect stdout to second port */
rs232_redirect_stdout(RS232_PORT_1);
clock_init();
#define CONF_CALIBRATE_OSCCAL 0
#if CONF_CALIBRATE_OSCCAL
{
extern uint8_t osccal_calibrated;
uint8_t i;
printf_P(PSTR("\nBefore calibration OSCCAL=%x\n"),OSCCAL);
for (i=0;i<10;i++) {
calibrate_rc_osc_32k();
printf_P(PSTR("Calibrated=%x\n"),osccal_calibrated);
//#include <util/delay_basic.h>
//#define delay_us( us ) ( _delay_loop_2(1+(us*F_CPU)/4000000UL) )
// delay_us(50000);
}
clock_init();
}
#endif
#if ANNOUNCE_BOOT
printf_P(PSTR("\n*******Booting %s*******\n"),CONTIKI_VERSION_STRING);
#endif
@ -346,6 +379,28 @@ main(void)
while(1) {
process_run();
#if CONFIG_STACK_MONITOR
extern uint16_t __bss_end;
if (*(uint16_t *)(&__bss_end+100) != 0x4242) {
printf_P(PSTR("\nStack Warning, overflow within 100 bytes!\n"));
if (__bss_end != 0x4242) {
__bss_end = 0x4242;
printf_P(PSTR("\n!!!!!!!Stack Overflow!!!!!!!!\n"));
}
*(uint16_t *)(&__bss_end+100) = 0x4242;
}
#endif
#if 0
/* Clock.c can trigger a periodic RF PLL calibration */
extern uint8_t rf230_calibrated;
if (rf230_calibrated) {
printf_P(PSTR("\nRF230 calibrated!"));
rf230_calibrated=0;
}
#endif
//Various entry points for debugging in AVR simulator
// NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
// process_poll(&rf230_process);