DOS EOL and indentation fixes (platform files)
- Removed some DOS EOLs - Changed some tabs to spaces - Removed some trailing whitespaces Closes #6
This commit is contained in:
parent
713c2e5974
commit
67bf9ec10e
|
@ -34,43 +34,43 @@
|
|||
#include "dev/adc.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
ADMUX = 0;
|
||||
/* AVCC with external capacitor at AREF pin. */
|
||||
ADMUX |= _BV(REFS0);
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
|
||||
/* Set ADC prescaler to 64 and clear interrupt flag. */
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Poll based approach. The interrupt based adc is currently not used.
|
||||
The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
ADMUX |= (channel & 0x1F);
|
||||
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~_BV(ADIE);
|
||||
/* Clear previous interrupts. */
|
||||
/* Clear previous interrupts. */
|
||||
ADCSRA |= _BV(ADIF);
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
reading = ADCL;
|
||||
/* Get last two bits. */
|
||||
/* Get last two bits. */
|
||||
reading |= (ADCH & 3) << 8;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "contiki-conf.h"
|
||||
#include "dev/leds.h"
|
||||
#include <avr/io.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -39,180 +39,180 @@
|
|||
*/
|
||||
|
||||
#include "mts300.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sounder_on()
|
||||
sounder_on()
|
||||
{
SOUNDER_DDR |= SOUNDER_MASK;
|
||||
SOUNDER_PORT &= ~SOUNDER_MASK;
|
||||
SOUNDER_PORT |= SOUNDER_MASK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sounder_off()
|
||||
{
|
||||
SOUNDER_PORT &= ~(SOUNDER_MASK);
|
||||
SOUNDER_DDR &= ~(SOUNDER_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
void
|
||||
sounder_off()
|
||||
{
|
||||
SOUNDER_PORT &= ~(SOUNDER_MASK);
|
||||
SOUNDER_DDR &= ~(SOUNDER_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
ADMUX = 0;
|
||||
/* AVCC with external capacitor at AREF pin. */
|
||||
//ADMUX |= _BV(REFS0)
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
|
||||
/* Set ADC prescaler to 64 and clear interrupt flag. */
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Poll based approach. The interrupt based adc is currently not used.
|
||||
The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
ADMUX |= (channel & 0x1F);
|
||||
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~_BV(ADIE);
|
||||
/* Clear previous interrupts. */
|
||||
/* Clear previous interrupts. */
|
||||
ADCSRA |= _BV(ADIF);
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
reading = ADCL;
|
||||
/* Get last two bits. */
|
||||
/* Get last two bits. */
|
||||
reading |= (ADCH & 3) << 8;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_light()
|
||||
{
|
||||
uint16_t reading;
|
||||
uint16_t
|
||||
get_light()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable light sensor. */
|
||||
LIGHT_PORT |= LIGHT_PIN_MASK;
|
||||
LIGHT_PORT |= LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR |= LIGHT_PIN_MASK;
|
||||
/* Disable temperature sensor. */
|
||||
TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
|
||||
TEMP_PORT &= ~TEMP_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
reading = get_adc(LIGHT_ADC_CHANNEL);
|
||||
/* Read ADC. */
|
||||
reading = get_adc(LIGHT_ADC_CHANNEL);
|
||||
/* Disable light sensor. */
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
|
||||
return reading;
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_temp()
|
||||
{
|
||||
uint16_t reading;
|
||||
uint16_t
|
||||
get_temp()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Disable light sensor. */
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
|
||||
/* Enable temperature sensor. */
|
||||
TEMP_PORT_DDR |= TEMP_PIN_MASK;
|
||||
TEMP_PORT |= TEMP_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(TEMP_ADC_CHANNEL);
|
||||
/* Disable temperature sensor. */
|
||||
/* Disable temperature sensor. */
|
||||
TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
|
||||
TEMP_PORT &= ~TEMP_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_accx()
|
||||
{
|
||||
uint16_t reading;
|
||||
uint16_t
|
||||
get_accx()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
ACCEL_PORT |= ACCEL_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(ACCELX_ADC_CHANNEL);
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
ACCEL_PORT &= ~ACCEL_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_accy()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
ACCEL_PORT |= ACCEL_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
reading = get_adc(ACCELY_ADC_CHANNEL);
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
ACCEL_PORT &= ~ACCEL_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uint16_t
|
||||
get_accy()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
ACCEL_PORT |= ACCEL_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
reading = get_adc(ACCELY_ADC_CHANNEL);
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
ACCEL_PORT &= ~ACCEL_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_magx()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
MAGNET_PORT |= MAGNET_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(MAGNETX_ADC_CHANNEL);
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
MAGNET_PORT &= ~MAGNET_PIN_MASK;
|
||||
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uint16_t
|
||||
get_magy()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
MAGNET_PORT |= MAGNET_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(MAGNETY_ADC_CHANNEL);
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
MAGNET_PORT &= ~MAGNET_PIN_MASK;
|
||||
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uint16_t
|
||||
get_mic()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR |= MIC_PIN_MASK;
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR |= MIC_PIN_MASK;
|
||||
MIC_PORT |= MIC_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(MIC_ADC_CHANNEL);
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR &= ~MIC_PIN_MASK;
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR &= ~MIC_PIN_MASK;
|
||||
MIC_PORT &= ~MIC_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#define SOUNDER_MASK _BV(2)
|
||||
#define SOUNDER_DDR DDRC
|
||||
|
||||
/* MTS300CA and MTS310CA, the light sensor power is controlled
|
||||
/* MTS300CA and MTS310CA, the light sensor power is controlled
|
||||
* by setting signal INT1(PORTE pin 5).
|
||||
* Both light and thermistor use the same ADC channel.
|
||||
*/
|
||||
|
@ -57,7 +57,7 @@
|
|||
#define LIGHT_PIN_MASK _BV(5)
|
||||
#define LIGHT_ADC_CHANNEL 1
|
||||
|
||||
/* MTS300CA and MTS310CA, the thermistor power is controlled
|
||||
/* MTS300CA and MTS310CA, the thermistor power is controlled
|
||||
* by setting signal INT2(PORTE pin 6).
|
||||
* Both light and thermistor use the same ADC channel.
|
||||
*/
|
||||
|
@ -89,8 +89,8 @@
|
|||
#define MIC_PORT PORTC
|
||||
#define MIC_PIN_MASK _BV(3)
|
||||
#define MIC_ADC_CHANNEL 2
|
||||
|
||||
void sounder_on();
|
||||
|
||||
void sounder_on();
|
||||
void sounder_off();
|
||||
|
||||
uint16_t get_light();
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -106,7 +106,7 @@
|
|||
#define RPL_CONF_MAX_DAG_PER_INSTANCE 1
|
||||
#define PROCESS_CONF_NUMEVENTS 16
|
||||
|
||||
#if WITH_UIP6
|
||||
#if WITH_UIP6
|
||||
|
||||
/* Network setup for IPv6 */
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
* Contiki main file.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -105,7 +105,7 @@ set_rime_addr(void)
|
|||
union {
|
||||
uint8_t u8[8];
|
||||
} eui64;
|
||||
|
||||
|
||||
int8u *stm32w_eui64 = ST_RadioGetEui64();
|
||||
{
|
||||
int8u c;
|
||||
|
@ -136,30 +136,30 @@ set_rime_addr(void)
|
|||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* Initalize hardware.
|
||||
*/
|
||||
halInit();
|
||||
clock_init();
|
||||
|
||||
|
||||
uart1_init(115200);
|
||||
|
||||
|
||||
/* Led initialization */
|
||||
leds_init();
|
||||
|
||||
INTERRUPTS_ON();
|
||||
|
||||
INTERRUPTS_ON();
|
||||
|
||||
PRINTF("\r\nStarting ");
|
||||
PRINTF(CONTIKI_VERSION_STRING);
|
||||
PRINTF(" on MB851\r\n");
|
||||
PRINTF(" on MB851\r\n");
|
||||
|
||||
/*
|
||||
* Initialize Contiki and our processes.
|
||||
*/
|
||||
|
||||
|
||||
process_init();
|
||||
|
||||
|
||||
#if WITH_SERIAL_LINE_INPUT
|
||||
uart1_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
|
@ -168,7 +168,7 @@ main(void)
|
|||
layers */
|
||||
rtimer_init();
|
||||
/* etimer_process should be initialized before ctimer */
|
||||
process_start(&etimer_process, NULL);
|
||||
process_start(&etimer_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
netstack_init();
|
||||
|
@ -197,7 +197,7 @@ main(void)
|
|||
and no packets will be sent. DEFAULT_RADIO_CCA_THRESHOLD is
|
||||
defined in this file. */
|
||||
ST_RadioSetEdCcaThreshold(DEFAULT_RADIO_CCA_THRESHOLD);
|
||||
|
||||
|
||||
autostart_start(autostart_processes);
|
||||
#if UIP_CONF_IPV6
|
||||
printf("Tentative link-local IPv6 address ");
|
||||
|
@ -228,21 +228,21 @@ main(void)
|
|||
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
watchdog_start();
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
int r;
|
||||
|
||||
|
||||
int r;
|
||||
|
||||
do {
|
||||
/* Reset watchdog. */
|
||||
watchdog_periodic();
|
||||
r = process_run();
|
||||
} while(r > 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
||||
/* watchdog_stop(); */
|
||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
||||
|
@ -251,10 +251,10 @@ main(void)
|
|||
/* We are awake. */
|
||||
/* watchdog_start(); */
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -262,53 +262,53 @@ main(void)
|
|||
/*int8u errcode __attribute__(( section(".noinit") ));
|
||||
|
||||
void halBaseBandIsr(){
|
||||
|
||||
|
||||
errcode = 1;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void BusFault_Handler(){
|
||||
|
||||
errcode = 2;
|
||||
|
||||
errcode = 2;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void halDebugIsr(){
|
||||
|
||||
|
||||
errcode = 3;
|
||||
leds_on(LEDS_RED);
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void DebugMon_Handler(){
|
||||
|
||||
|
||||
errcode = 4;
|
||||
//leds_on(LEDS_RED);
|
||||
//leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void HardFault_Handler(){
|
||||
|
||||
errcode = 5;
|
||||
|
||||
errcode = 5;
|
||||
//leds_on(LEDS_RED);
|
||||
//halReboot();
|
||||
}
|
||||
|
||||
void MemManage_Handler(){
|
||||
|
||||
errcode = 6;
|
||||
|
||||
errcode = 6;
|
||||
//leds_on(LEDS_RED);
|
||||
//halReboot();
|
||||
}
|
||||
|
||||
void UsageFault_Handler(){
|
||||
|
||||
errcode = 7;
|
||||
|
||||
errcode = 7;
|
||||
//leds_on(LEDS_RED);
|
||||
//halReboot();
|
||||
}
|
||||
|
||||
void Default_Handler()
|
||||
{
|
||||
//errcode = 8;
|
||||
void Default_Handler()
|
||||
{
|
||||
//errcode = 8;
|
||||
leds_on(LEDS_RED);
|
||||
halReboot();
|
||||
}*/
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* platform-conf.h for MB851.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __PLATFORM_CONF_H__
|
||||
#define __PLATFORM_CONF_H__
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h> // For memcpm().
|
||||
|
||||
/* Platform-dependent definitions */
|
||||
#define CC_CONF_REGISTER_ARGS 0
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
#define CC_CONF_FASTCALL
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
||||
#define WITH_SERIAL_LINE_INPUT 1
|
||||
|
||||
/* rtimer_second = 11719 */
|
||||
#define RT_CONF_RESOLUTION 2
|
||||
|
||||
/* A trick to resolve a compilation error with IAR. */
|
||||
#ifdef __ICCARM__
|
||||
#define UIP_CONF_DS6_AADDR_NBU 1
|
||||
#endif
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
typedef unsigned long rtimer_clock_t;
|
||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
||||
|
||||
/* LEDs ports MB851 */
|
||||
#define LEDS_CONF_RED_PIN 5
|
||||
#define LEDS_CONF_GREEN_PIN 6
|
||||
#define LEDS_CONF_PORT PORTB
|
||||
#define LEDS_CONF_RED (1<<LEDS_CONF_RED_PIN)
|
||||
#define LEDS_CONF_GREEN (1<<LEDS_CONF_GREEN_PIN)
|
||||
|
||||
#define UIP_ARCH_ADD32 1
|
||||
#define UIP_ARCH_CHKSUM 0
|
||||
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
|
||||
#endif /* __PLATFORM_CONF_H__ */
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* platform-conf.h for MB851.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __PLATFORM_CONF_H__
|
||||
#define __PLATFORM_CONF_H__
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h> // For memcpm().
|
||||
|
||||
/* Platform-dependent definitions */
|
||||
#define CC_CONF_REGISTER_ARGS 0
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
#define CC_CONF_FASTCALL
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
||||
#define WITH_SERIAL_LINE_INPUT 1
|
||||
|
||||
/* rtimer_second = 11719 */
|
||||
#define RT_CONF_RESOLUTION 2
|
||||
|
||||
/* A trick to resolve a compilation error with IAR. */
|
||||
#ifdef __ICCARM__
|
||||
#define UIP_CONF_DS6_AADDR_NBU 1
|
||||
#endif
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
typedef unsigned long rtimer_clock_t;
|
||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
||||
|
||||
/* LEDs ports MB851 */
|
||||
#define LEDS_CONF_RED_PIN 5
|
||||
#define LEDS_CONF_GREEN_PIN 6
|
||||
#define LEDS_CONF_PORT PORTB
|
||||
#define LEDS_CONF_RED (1<<LEDS_CONF_RED_PIN)
|
||||
#define LEDS_CONF_GREEN (1<<LEDS_CONF_GREEN_PIN)
|
||||
|
||||
#define UIP_ARCH_ADD32 1
|
||||
#define UIP_ARCH_CHKSUM 0
|
||||
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
|
||||
#endif /* __PLATFORM_CONF_H__ */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
* Contiki main file.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -80,9 +80,9 @@
|
|||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
PROCINIT(&tcpip_process, &sensors_process);
|
||||
PROCINIT(&tcpip_process, &sensors_process);
|
||||
#else
|
||||
PROCINIT(&sensors_process);
|
||||
PROCINIT(&sensors_process);
|
||||
#warning "No TCP/IP process!"
|
||||
#endif
|
||||
|
||||
|
@ -96,9 +96,9 @@ set_rime_addr(void)
|
|||
union {
|
||||
uint8_t u8[8];
|
||||
}eui64;
|
||||
|
||||
|
||||
//rimeaddr_t lladdr;
|
||||
|
||||
|
||||
int8u *stm32w_eui64 = ST_RadioGetEui64();
|
||||
{
|
||||
int8u c;
|
||||
|
@ -106,14 +106,14 @@ set_rime_addr(void)
|
|||
eui64.u8[c] = stm32w_eui64[7 - c];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr));
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64);
|
||||
#else
|
||||
#else
|
||||
rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8-RIMEADDR_SIZE]);
|
||||
#endif
|
||||
|
||||
|
@ -122,25 +122,25 @@ set_rime_addr(void)
|
|||
printf("%d.", rimeaddr_node_addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", rimeaddr_node_addr.u8[i]);
|
||||
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* Initialize hardware.
|
||||
*/
|
||||
halInit();
|
||||
clock_init();
|
||||
|
||||
|
||||
uart1_init(115200);
|
||||
|
||||
|
||||
// Led initialization
|
||||
leds_init();
|
||||
|
||||
INTERRUPTS_ON();
|
||||
|
||||
INTERRUPTS_ON();
|
||||
|
||||
PRINTF("\r\nStarting ");
|
||||
PRINTF(CONTIKI_VERSION_STRING);
|
||||
|
@ -149,21 +149,21 @@ main(void)
|
|||
/*
|
||||
* Initialize Contiki and our processes.
|
||||
*/
|
||||
|
||||
|
||||
process_init();
|
||||
|
||||
|
||||
#if WITH_SERIAL_LINE_INPUT
|
||||
uart1_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
#endif
|
||||
/* rtimer and ctimer should be initialized before radio duty cycling layers*/
|
||||
rtimer_init();
|
||||
/* etimer_process should be initialized before ctimer */
|
||||
process_start(&etimer_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
/* rtimer and ctimer should be initialized before radio duty cycling layers*/
|
||||
rtimer_init();
|
||||
netstack_init();
|
||||
/* etimer_process should be initialized before ctimer */
|
||||
process_start(&etimer_process, NULL);
|
||||
ctimer_init();
|
||||
|
||||
rtimer_init();
|
||||
netstack_init();
|
||||
set_rime_addr();
|
||||
|
||||
printf("%s %s, channel check rate %lu Hz\n",
|
||||
|
@ -173,41 +173,41 @@ main(void)
|
|||
printf("802.15.4 PAN ID 0x%x, EUI-%d:",
|
||||
IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16);
|
||||
uip_debug_lladdr_print(&rimeaddr_node_addr);
|
||||
printf(", radio channel %u\n", RF_CHANNEL);
|
||||
|
||||
procinit_init();
|
||||
printf(", radio channel %u\n", RF_CHANNEL);
|
||||
|
||||
procinit_init();
|
||||
|
||||
energest_init();
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
|
||||
watchdog_start();
|
||||
|
||||
|
||||
while(1){
|
||||
|
||||
int r;
|
||||
|
||||
|
||||
int r;
|
||||
|
||||
do {
|
||||
/* Reset watchdog. */
|
||||
watchdog_periodic();
|
||||
r = process_run();
|
||||
} while(r > 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
||||
//watchdog_stop();
|
||||
//watchdog_stop();
|
||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
||||
/* Go to idle mode. */
|
||||
halSleepWithOptions(SLEEPMODE_IDLE,0);
|
||||
/* We are awake. */
|
||||
//watchdog_start();
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,53 +215,53 @@ main(void)
|
|||
/*int8u errcode __attribute__(( section(".noinit") ));
|
||||
|
||||
void halBaseBandIsr(){
|
||||
|
||||
|
||||
errcode = 1;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void BusFault_Handler(){
|
||||
|
||||
errcode = 2;
|
||||
|
||||
errcode = 2;
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void halDebugIsr(){
|
||||
|
||||
|
||||
errcode = 3;
|
||||
leds_on(LEDS_RED);
|
||||
leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void DebugMon_Handler(){
|
||||
|
||||
|
||||
errcode = 4;
|
||||
//leds_on(LEDS_RED);
|
||||
//leds_on(LEDS_RED);
|
||||
}
|
||||
|
||||
void HardFault_Handler(){
|
||||
|
||||
errcode = 5;
|
||||
|
||||
errcode = 5;
|
||||
//leds_on(LEDS_RED);
|
||||
//halReboot();
|
||||
}
|
||||
|
||||
void MemManage_Handler(){
|
||||
|
||||
errcode = 6;
|
||||
|
||||
errcode = 6;
|
||||
//leds_on(LEDS_RED);
|
||||
//halReboot();
|
||||
}
|
||||
|
||||
void UsageFault_Handler(){
|
||||
|
||||
errcode = 7;
|
||||
|
||||
errcode = 7;
|
||||
//leds_on(LEDS_RED);
|
||||
//halReboot();
|
||||
}*/
|
||||
|
||||
void Default_Handler()
|
||||
{
|
||||
//errcode = 8;
|
||||
void Default_Handler()
|
||||
{
|
||||
//errcode = 8;
|
||||
leds_on(LEDS_RED);
|
||||
halReboot();
|
||||
}
|
||||
|
|
|
@ -1,92 +1,92 @@
|
|||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* platform-conf.h for MBXXX.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __PLATFORM_CONF_H__
|
||||
#define __PLATFORM_CONF_H__
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h> // For memcpm().
|
||||
|
||||
/* Platform-dependent definitions */
|
||||
#define CC_CONF_REGISTER_ARGS 0
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
#define CC_CONF_FASTCALL
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
||||
#define WITH_SERIAL_LINE_INPUT 1
|
||||
|
||||
/* rtimer_second = 11719 */
|
||||
#define RT_CONF_RESOLUTION 2
|
||||
|
||||
/* A trick to resolve a compilation error with IAR. */
|
||||
#ifdef __ICCARM__
|
||||
#define UIP_CONF_DS6_AADDR_NBU 1
|
||||
#endif
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
typedef unsigned long rtimer_clock_t;
|
||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
||||
|
||||
/* LEDs ports MB8xxx */
|
||||
#define LEDS_CONF_GREEN LED_D1
|
||||
#define LEDS_CONF_YELLOW LED_D3
|
||||
#define LEDS_CONF_RED LED_D3
|
||||
|
||||
#define UIP_ARCH_ADD32 1
|
||||
#define UIP_ARCH_CHKSUM 0
|
||||
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
|
||||
#endif /* __PLATFORM_CONF_H__ */
|
||||
/*
|
||||
* Copyright (c) 2010, STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* platform-conf.h for MBXXX.
|
||||
* \author
|
||||
* Salvatore Pitrulli <salvopitru@users.sourceforge.net>
|
||||
* Chi-Anh La <la@imag.fr>
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __PLATFORM_CONF_H__
|
||||
#define __PLATFORM_CONF_H__
|
||||
|
||||
#include PLATFORM_HEADER
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h> // For memcpm().
|
||||
|
||||
/* Platform-dependent definitions */
|
||||
#define CC_CONF_REGISTER_ARGS 0
|
||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||
#define CC_CONF_FASTCALL
|
||||
#define CC_CONF_VA_ARGS 1
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
||||
#define WITH_SERIAL_LINE_INPUT 1
|
||||
|
||||
/* rtimer_second = 11719 */
|
||||
#define RT_CONF_RESOLUTION 2
|
||||
|
||||
/* A trick to resolve a compilation error with IAR. */
|
||||
#ifdef __ICCARM__
|
||||
#define UIP_CONF_DS6_AADDR_NBU 1
|
||||
#endif
|
||||
|
||||
typedef unsigned long clock_time_t;
|
||||
|
||||
#define CLOCK_CONF_SECOND 1000
|
||||
|
||||
typedef unsigned long rtimer_clock_t;
|
||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
||||
|
||||
/* LEDs ports MB8xxx */
|
||||
#define LEDS_CONF_GREEN LED_D1
|
||||
#define LEDS_CONF_YELLOW LED_D3
|
||||
#define LEDS_CONF_RED LED_D3
|
||||
|
||||
#define UIP_ARCH_ADD32 1
|
||||
#define UIP_ARCH_CHKSUM 0
|
||||
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
|
||||
#endif /* __PLATFORM_CONF_H__ */
|
||||
|
|
|
@ -34,43 +34,43 @@
|
|||
#include "dev/adc.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
ADMUX = 0;
|
||||
/* AVCC with external capacitor at AREF pin. */
|
||||
ADMUX |= _BV(REFS0);
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
|
||||
/* Set ADC prescaler to 64 and clear interrupt flag. */
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Poll based approach. The interrupt based adc is currently not used.
|
||||
The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
ADMUX |= (channel & 0x1F);
|
||||
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~_BV(ADIE);
|
||||
/* Clear previous interrupts. */
|
||||
/* Clear previous interrupts. */
|
||||
ADCSRA |= _BV(ADIF);
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
reading = ADCL;
|
||||
/* Get last two bits. */
|
||||
/* Get last two bits. */
|
||||
reading |= (ADCH & 3) << 8;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -65,7 +65,7 @@ unsigned char ds2401_id[8];
|
|||
#define SET_PIN_OUTPUT() (SERIAL_ID_PxDIR |= SERIAL_ID_PIN_MASK)
|
||||
|
||||
#define OUTP_0() (SERIAL_ID_PxOUT &= ~SERIAL_ID_PIN_MASK)
|
||||
#define OUTP_1() (SERIAL_ID_PxOUT |= SERIAL_ID_PIN_MASK)
|
||||
#define OUTP_1() (SERIAL_ID_PxOUT |= SERIAL_ID_PIN_MASK)
|
||||
|
||||
#define PIN_INIT() do{ \
|
||||
SET_PIN_INPUT(); \
|
||||
|
@ -91,9 +91,9 @@ unsigned char ds2401_id[8];
|
|||
/*
|
||||
* Delay times in us.
|
||||
*/
|
||||
#define tA 6 /* min-5, recommended-6, max-15 */
|
||||
#define tA 6 /* min-5, recommended-6, max-15 */
|
||||
#define tB 64 /* min-59, recommended-64, max-N/A */
|
||||
#define tC 60 /* min-60, recommended-60, max-120 */
|
||||
#define tC 60 /* min-60, recommended-60, max-120 */
|
||||
#define tD 10 /* min-5.3, recommended-10, max-N/A */
|
||||
#define tE 9 /* min-0.3, recommended-9, max-9.3 */
|
||||
#define tF 55 /* min-50, recommended-55, max-N/A */
|
||||
|
@ -106,17 +106,17 @@ unsigned char ds2401_id[8];
|
|||
* The delay caused by calling the delay_loop is given by the following
|
||||
* formula.
|
||||
* delay(us) = (4n + 1)/XTAL
|
||||
* where n is the number of iterations and XTAL is the clock frequency(in MHz).
|
||||
* where n is the number of iterations and XTAL is the clock frequency(in MHz).
|
||||
* TODO: Moving the delay_loop to dev/clock.c
|
||||
*/
|
||||
static void
|
||||
delay_loop(uint16_t __count)
|
||||
{
|
||||
asm volatile ("1: sbiw %0,1" "\n\t"
|
||||
"brne 1b"
|
||||
: "=w" (__count)
|
||||
: "0" (__count)
|
||||
);
|
||||
static void
|
||||
delay_loop(uint16_t __count)
|
||||
{
|
||||
asm volatile ("1: sbiw %0,1" "\n\t"
|
||||
"brne 1b"
|
||||
: "=w" (__count)
|
||||
: "0" (__count)
|
||||
);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
|
@ -210,7 +210,7 @@ ds2401_init()
|
|||
cli(); /* Disable interrupts. */
|
||||
|
||||
if (reset() == 0) {
|
||||
write_byte(0x33); /* Read ROM command. */
|
||||
write_byte(0x33); /* Read ROM command. */
|
||||
family = read_byte();
|
||||
for (i = 7; i >= 2; i--) {
|
||||
ds2401_id[i] = read_byte();
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "contiki-conf.h"
|
||||
#include "dev/leds.h"
|
||||
#include <avr/io.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -39,180 +39,180 @@
|
|||
*/
|
||||
|
||||
#include "mts300.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sounder_on()
|
||||
sounder_on()
|
||||
{
SOUNDER_DDR |= SOUNDER_MASK;
|
||||
SOUNDER_PORT &= ~SOUNDER_MASK;
|
||||
SOUNDER_PORT |= SOUNDER_MASK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sounder_off()
|
||||
{
|
||||
SOUNDER_PORT &= ~(SOUNDER_MASK);
|
||||
SOUNDER_DDR &= ~(SOUNDER_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
void
|
||||
sounder_off()
|
||||
{
|
||||
SOUNDER_PORT &= ~(SOUNDER_MASK);
|
||||
SOUNDER_DDR &= ~(SOUNDER_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
adc_init()
|
||||
{
|
||||
ADMUX = 0;
|
||||
/* AVCC with external capacitor at AREF pin. */
|
||||
//ADMUX |= _BV(REFS0)
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
|
||||
/* Set ADC prescaler to 64 and clear interrupt flag. */
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Poll based approach. The interrupt based adc is currently not used.
|
||||
The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
other two bits are in ADCH. See Atmega128 datasheet page 228. */
|
||||
uint16_t
|
||||
get_adc(int channel)
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
ADMUX |= (channel & 0x1F);
|
||||
|
||||
/* Disable ADC interrupts. */
|
||||
/* Disable ADC interrupts. */
|
||||
ADCSRA &= ~_BV(ADIE);
|
||||
/* Clear previous interrupts. */
|
||||
/* Clear previous interrupts. */
|
||||
ADCSRA |= _BV(ADIF);
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
/* Enable ADC and start conversion. */
|
||||
ADCSRA |= _BV(ADEN) | _BV(ADSC);
|
||||
/* Wait until conversion is completed. */
|
||||
while ( ADCSRA & _BV(ADSC) );
|
||||
/* Get first 8 bits. */
|
||||
reading = ADCL;
|
||||
/* Get last two bits. */
|
||||
/* Get last two bits. */
|
||||
reading |= (ADCH & 3) << 8;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
/* Disable ADC. */
|
||||
ADCSRA &= ~_BV(ADEN);
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_light()
|
||||
{
|
||||
uint16_t reading;
|
||||
uint16_t
|
||||
get_light()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable light sensor. */
|
||||
LIGHT_PORT |= LIGHT_PIN_MASK;
|
||||
LIGHT_PORT |= LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR |= LIGHT_PIN_MASK;
|
||||
/* Disable temperature sensor. */
|
||||
TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
|
||||
TEMP_PORT &= ~TEMP_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
reading = get_adc(LIGHT_ADC_CHANNEL);
|
||||
/* Read ADC. */
|
||||
reading = get_adc(LIGHT_ADC_CHANNEL);
|
||||
/* Disable light sensor. */
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
|
||||
return reading;
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_temp()
|
||||
{
|
||||
uint16_t reading;
|
||||
uint16_t
|
||||
get_temp()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Disable light sensor. */
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT &= ~LIGHT_PIN_MASK;
|
||||
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
|
||||
/* Enable temperature sensor. */
|
||||
TEMP_PORT_DDR |= TEMP_PIN_MASK;
|
||||
TEMP_PORT |= TEMP_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(TEMP_ADC_CHANNEL);
|
||||
/* Disable temperature sensor. */
|
||||
/* Disable temperature sensor. */
|
||||
TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
|
||||
TEMP_PORT &= ~TEMP_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_accx()
|
||||
{
|
||||
uint16_t reading;
|
||||
uint16_t
|
||||
get_accx()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
ACCEL_PORT |= ACCEL_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(ACCELX_ADC_CHANNEL);
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
ACCEL_PORT &= ~ACCEL_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_accy()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
ACCEL_PORT |= ACCEL_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
reading = get_adc(ACCELY_ADC_CHANNEL);
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
ACCEL_PORT &= ~ACCEL_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uint16_t
|
||||
get_accy()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
|
||||
ACCEL_PORT |= ACCEL_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
reading = get_adc(ACCELY_ADC_CHANNEL);
|
||||
/* Enable accelerometer. */
|
||||
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
|
||||
ACCEL_PORT &= ~ACCEL_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
get_magx()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
MAGNET_PORT |= MAGNET_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(MAGNETX_ADC_CHANNEL);
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
MAGNET_PORT &= ~MAGNET_PIN_MASK;
|
||||
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uint16_t
|
||||
get_magy()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
|
||||
MAGNET_PORT |= MAGNET_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(MAGNETY_ADC_CHANNEL);
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
/* Enable magnetometer. */
|
||||
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
|
||||
MAGNET_PORT &= ~MAGNET_PIN_MASK;
|
||||
|
||||
|
||||
return reading;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uint16_t
|
||||
get_mic()
|
||||
{
|
||||
uint16_t reading;
|
||||
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR |= MIC_PIN_MASK;
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR |= MIC_PIN_MASK;
|
||||
MIC_PORT |= MIC_PIN_MASK;
|
||||
/* Read ADC. */
|
||||
/* Read ADC. */
|
||||
reading = get_adc(MIC_ADC_CHANNEL);
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR &= ~MIC_PIN_MASK;
|
||||
/* Enable mic. */
|
||||
MIC_PORT_DDR &= ~MIC_PIN_MASK;
|
||||
MIC_PORT &= ~MIC_PIN_MASK;
|
||||
|
||||
return reading;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#define SOUNDER_MASK _BV(2)
|
||||
#define SOUNDER_DDR DDRC
|
||||
|
||||
/* MTS300CA and MTS310CA, the light sensor power is controlled
|
||||
/* MTS300CA and MTS310CA, the light sensor power is controlled
|
||||
* by setting signal INT1(PORTE pin 5).
|
||||
* Both light and thermistor use the same ADC channel.
|
||||
*/
|
||||
|
@ -57,7 +57,7 @@
|
|||
#define LIGHT_PIN_MASK _BV(5)
|
||||
#define LIGHT_ADC_CHANNEL 1
|
||||
|
||||
/* MTS300CA and MTS310CA, the thermistor power is controlled
|
||||
/* MTS300CA and MTS310CA, the thermistor power is controlled
|
||||
* by setting signal INT2(PORTE pin 6).
|
||||
* Both light and thermistor use the same ADC channel.
|
||||
*/
|
||||
|
@ -89,8 +89,8 @@
|
|||
#define MIC_PORT PORTC
|
||||
#define MIC_PIN_MASK _BV(3)
|
||||
#define MIC_ADC_CHANNEL 2
|
||||
|
||||
void sounder_on();
|
||||
|
||||
void sounder_on();
|
||||
void sounder_off();
|
||||
|
||||
uint16_t get_light();
|
||||
|
|
Loading…
Reference in a new issue