clear;
close all;

%Import scope trace
filein = 'V:\Electrical Engr\Scope Traces\WASC0001.CSV'; %SPI
raw_data = csvread(filein,0,0,[21 0 2020 1]);

% filein = 'V:\Electrical Engr\Scope Traces\WASC0003.CSV';  %I2C
% raw_data = csvread(filein,0,0,[21 0 20020 1]);

ch1 = raw_data(:,2);
ch2 = raw_data(:,3);
dt = 1e-9;
t = (0:length(ch1)-1) .* dt;

plot(t,ch1,'r');
hold on;
plot(t,ch2,'b');
xlabel('Time (s)');
ylabel('Volts (V)');
title('SPI induced noise FEZ Raptor, 100MHz scope BW, 6/2/15, 09:34');
legend('CH1: X1-P9 (SCK)','CH2: X1-P2 (3.3V)');

[pxx,f] = pwelch(ch1);
figure;
plot(f,10*log10(pxx));