Originally authored by Bruce McKenny
Definition in file icp.c.
#include <stdio.h>
#include <inavr.h>
#include <iom64.h>
#include "icp.h"
Include dependency graph for icp.c:
Go to the source code of this file.
Defines | |
#define | ENABLE_BIT_DEFINITIONS |
#define | ICP_BIT PD4 |
#define | ICP_CTL TCCR1B |
#define | ICP_CTL_A TCCR1A |
#define | ICP_DDR DDRD |
#define | ICP_IE TICIE1 |
#define | ICP_IF ICF1 |
#define | ICP_OC_IE OCIE1A |
#define | ICP_OC_IF OCF1A |
#define | ICP_OCR OCR1A |
#define | ICP_PIN PIND |
#define | ICP_PORT PORTD |
#define | ICP_PRESCALE ((0 << CS12) | (0 << CS11) | (1 << CS10)) |
#define | ICP_SENSE ICES1 |
#define | ICP_START_SENSE (1 << ICP_SENSE) |
Typedefs | |
typedef unsigned int | icp_timer_t |
Functions | |
void | icp_init (void) |
icp_sample_t | icp_rx (void) |
__interrupt void | TIMER1_CAPT (void) |
__interrupt void | TIMER1_COMPA (void) |
Variables | |
icp_timer_t | icp_period |
icp_sample_t | icp_rx_q [ICP_RX_QSIZE] |
unsigned char | icp_rx_tail |
icp_timer_t | icp_start_time |
icp_timer_t | icp_stop_time |
icp_total_t | icp_total |
|
|
|
Definition at line 40 of file icp.c. Referenced by TIMER1_CAPT(). |
|
Definition at line 51 of file icp.c. Referenced by icp_init(), TIMER1_CAPT(), and TIMER1_COMPA(). |
|
Definition at line 50 of file icp.c. Referenced by icp_init(). |
|
|
|
Definition at line 48 of file icp.c. Referenced by icp_init(). |
|
Definition at line 49 of file icp.c. Referenced by TIMER1_CAPT(). |
|
Definition at line 46 of file icp.c. Referenced by icp_init(). |
|
Definition at line 47 of file icp.c. Referenced by TIMER1_CAPT(). |
|
Definition at line 45 of file icp.c. Referenced by icp_init(), TIMER1_CAPT(), and TIMER1_COMPA(). |
|
Definition at line 37 of file icp.c. Referenced by TIMER1_CAPT(). |
|
|
|
Definition at line 53 of file icp.c. Referenced by icp_init(). |
|
Definition at line 52 of file icp.c. Referenced by TIMER1_CAPT(), and TIMER1_COMPA(). |
|
Definition at line 55 of file icp.c. Referenced by icp_init(), TIMER1_CAPT(), and TIMER1_COMPA(). |
|
icp_start_time, icp_stop_time, icp_period State variables for the Demodulator. start_time, stop_time and period all have the same type as the respective TCNT register. |
|
Set up the ICP timer. Definition at line 328 of file icp.c. References ICP_CTL, ICP_CTL_A, ICP_IE, ICP_OC_IE, ICP_OCR, ICP_PRESCALE, and ICP_START_SENSE. Referenced by main(). |
|
Fetch a sample from the queue. For analog mode, this is a moving average of the last QSIZE readings. For digital, it is the oldest reading. Definition at line 298 of file icp.c. References ICP_RX_QSIZE, icp_rx_tail, and icp_total. Referenced by main(). |
|
ICP capture interrupt. Definition at line 206 of file icp.c. References ICP_BIT, ICP_CTL, ICP_IF, ICP_OC_IF, ICP_OCR, icp_period, ICP_PIN, ICP_SENSE, ICP_START_SENSE, icp_start_time, and icp_stop_time. |
|
ICP timer Output Compare ISR. The OC interrupt indicates that some edge didn't arrive as expected. This happens when the duty cycle is either 0% (no pulse at all) or 100% (pulse encompasses the entire period). Definition at line 182 of file icp.c. References ICP_CTL, ICP_OCR, icp_period, ICP_SCALE, ICP_SENSE, and ICP_START_SENSE. |
|
Definition at line 67 of file icp.c. Referenced by TIMER1_CAPT(), and TIMER1_COMPA(). |
|
icp_rx_q[] Stores demodulated samples. The rx_q elements have the same type as the duty-cycle result. |
|
icp_rx_tail, icp_rx_head Queue state variables for icp_rx_q. The rx_head and rx_tail indices need to be wide enough to accomodate [0:ICP_RX_QSIZE). Since QSIZE should generally not be very large, these are hard-coded as single bytes, which gets around certain atomicity concerns. Definition at line 88 of file icp.c. Referenced by icp_rx(). |
|
Definition at line 66 of file icp.c. Referenced by TIMER1_CAPT(). |
|
Definition at line 66 of file icp.c. Referenced by TIMER1_CAPT(). |
|
icp_total Used in computing a moving average for ICP_ANALOG samples. icp_total needs to be wide enough to acommodate the sum of RX_QSIZE icp_sample_t's. Definition at line 102 of file icp.c. Referenced by icp_rx(). |