Sensor sampling library
Diff: Sensors.h
- Revision:
- 1:f9f0b92a9d7c
- Parent:
- 0:eea8d19a7f6b
--- a/Sensors.h Mon Feb 23 18:03:29 2015 +0000 +++ b/Sensors.h Mon Feb 23 23:10:36 2015 +0000 @@ -1,32 +1,23 @@ #ifndef SENSORS_H #define SENSORS_H -#define CHANNEL_0 0x00 #define CHANNEL_1 0x01 #define CHANNEL_2 0x02 -#define CHANNEL_3 0x03 #define CPU_CLOCK 48000000 /** -* Pulses sets how many edges to detect before returning a time, max of 2^16, affectively refers to sample time -* Glitch filter recognizes change on input pin after 2^n rising clock edges -* Setting glitch filter to zero disables glitch filter -* TODO: DETERMINE EXACT FUNCTIONALITY AND USAFULNESS OF FUNCTION +* Start SysTick */ -extern "C" void setup_counter(int glitch_filter); +extern "C" void start_systick(); /** * Measure the period observed on the sensor indicated by "sensor" -* TO VERIFY (KL25Z): -* PTC1 -> Pulse Counter Input 0 (00) -* PTC2 -> Pulse Counter Input 1 (01) -* PTC3 -> Pulse Counter Input 2 (10) -* PTC4 -> Pulse Counter Input 3 (11) +* TODO: Pin Routing */ -extern "C" int measure_clock_cycles(char sensor, int samples); +extern "C" int measure_clock_cycles(int sensor, int samples); -float measure_frequency(char sensor, int samples) +float measure_frequency(int sensor, int samples) { // Divide the number of cpu clock cycles by the number of measured periods of the measured waveform to // get the number of clock cycles per period