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