Files
@ 84e25f7efd5a
Branch filter:
Location: seniordesign-firmware/slave/slave/lib/geiger.c - annotation
84e25f7efd5a
1.6 KiB
text/plain
Fixed issue where get_latitudeTrimmed() and get_latitudeLSBs() and associated longitude function returned the same results due to buffer sharing and compiler optimization.
51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 29db24a20666 51c8e8809a90 51c8e8809a90 51c8e8809a90 29db24a20666 29db24a20666 381ec8b85cb2 29db24a20666 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 29db24a20666 381ec8b85cb2 51c8e8809a90 381ec8b85cb2 51c8e8809a90 51c8e8809a90 51c8e8809a90 29db24a20666 29db24a20666 29db24a20666 29db24a20666 381ec8b85cb2 381ec8b85cb2 381ec8b85cb2 381ec8b85cb2 381ec8b85cb2 381ec8b85cb2 381ec8b85cb2 381ec8b85cb2 51c8e8809a90 51c8e8809a90 51c8e8809a90 51c8e8809a90 88a84e3b4dd9 88a84e3b4dd9 88a84e3b4dd9 88a84e3b4dd9 29db24a20666 29db24a20666 29db24a20666 381ec8b85cb2 29db24a20666 29db24a20666 88a84e3b4dd9 88a84e3b4dd9 51c8e8809a90 51c8e8809a90 b23f284b2449 51c8e8809a90 29db24a20666 b23f284b2449 b23f284b2449 b23f284b2449 b23f284b2449 1614c3d5e9cd b23f284b2449 b23f284b2449 29db24a20666 29db24a20666 29db24a20666 29db24a20666 29db24a20666 0df60b3e84ea bff9c47f83da bff9c47f83da bff9c47f83da 0df60b3e84ea bff9c47f83da bff9c47f83da 0df60b3e84ea bff9c47f83da bff9c47f83da bff9c47f83da bff9c47f83da bff9c47f83da bff9c47f83da bff9c47f83da bff9c47f83da | /*
* geiger.c
*
* Created: 11/19/2012 9:24:05 PM
* Author: kripperger
*/
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "../config.h"
#include <util/delay.h>
#include "geiger.h"
#include "loopTimer.h"
volatile uint8_t seconds; // Counts Seconds from Timer2 interrupt
volatile uint16_t counts; // Counts the pulses
volatile uint16_t CPM; // Counts per Minuite
volatile uint32_t countStart = 0;
volatile uint8_t CPS[60]; // Counts per Second
volatile uint8_t i;
ISR(TIMER2_OVF_vect) // Timer 2 overflow interrupt handler
{
// This executes every second. Update real-time clocks.
// Used only in Geiger module
// The following is a 60 second moving average of the CPS
seconds++;
if (seconds>=60)
{
seconds = 0;
}
CPS[seconds] = counts;
counts = 0;
CPM = 0;
for (i=0;i<60;i++)
{
CPM = CPM + CPS[i];
}
//CPM = CPM * 2; // For a 30 second moving average
}
ISR(PCINT0_vect) // Interrupt on PA0
{
if(((PINA & 0b00000001))==1)
{
// Interrupts when pulse received from Geiger tube
counts++; // Increment counter.
countStart = time_millis();
led_on(1);
io_piezoOff();
_delay_us(50);
}
}
uint16_t geiger_getCpm()
{
return CPM;
}
uint8_t geiger_getCount() //DEBUG
{
return counts;
}
uint32_t geiger_getCountStart()
{
return countStart;
}
void geiger_on()
{
// Turn the Flyback Transformer on
PORTA |= (1 << PA1); //ON
}
void geiger_refresh()
{
// Turn the Flyback Transformer off
PORTA &= ~(1 << PA1); //OFF
_delay_ms(1);
// Turn the Flyback Transformer on
PORTA |= (1 << PA1); //ON
}
|