Compare commits
No commits in common. "92e1128e5ab1873fc670c90cb76d7394111eadb1" and "15a478c9aa2ea6c87197cf5d2d6ae2bc07440922" have entirely different histories.
92e1128e5a
...
15a478c9aa
3 changed files with 58 additions and 20 deletions
54
main.c
54
main.c
|
@ -90,6 +90,20 @@ const float gVoltageScale[VOLTAGE_SCALES] = {
|
||||||
0.1, 0.2, 0.5, 1., 2.
|
0.1, 0.2, 0.5, 1., 2.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TIME_SCALES 6
|
||||||
|
const char * const gTimeScaleStr[TIME_SCALES] = {
|
||||||
|
"100 ms", "50 ms", "20 ms", " 10 ms", "50 us", "20 us"
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint64_t gTImeScale[TIME_SCALES] = {
|
||||||
|
100 * 1000 / PIXELS_PER_DIV,
|
||||||
|
50 * 1000 / PIXELS_PER_DIV,
|
||||||
|
20 * 1000 / PIXELS_PER_DIV,
|
||||||
|
10 * 1000 / PIXELS_PER_DIV,
|
||||||
|
50 / PIXELS_PER_DIV,
|
||||||
|
20 / PIXELS_PER_DIV,
|
||||||
|
};
|
||||||
|
|
||||||
int Trigger(bool rising);
|
int Trigger(bool rising);
|
||||||
|
|
||||||
// start a pwm test signal
|
// start a pwm test signal
|
||||||
|
@ -269,6 +283,14 @@ void handle_user_input() {
|
||||||
case Down: // previous scale
|
case Down: // previous scale
|
||||||
local_options.voltage_scale = (local_options.voltage_scale + VOLTAGE_SCALES - 1) % VOLTAGE_SCALES;
|
local_options.voltage_scale = (local_options.voltage_scale + VOLTAGE_SCALES - 1) % VOLTAGE_SCALES;
|
||||||
break;
|
break;
|
||||||
|
case Right: // next scale
|
||||||
|
local_options.time_scale = (local_options.time_scale + 1) % TIME_SCALES;
|
||||||
|
set_frequency(gTImeScale[local_options.time_scale]);
|
||||||
|
break;
|
||||||
|
case Left: // previous scale
|
||||||
|
local_options.time_scale = (local_options.time_scale + TIME_SCALES - 1) % TIME_SCALES;
|
||||||
|
set_frequency(gTImeScale[local_options.time_scale]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Semaphore_pend(options_sem, BIOS_WAIT_FOREVER);
|
Semaphore_pend(options_sem, BIOS_WAIT_FOREVER);
|
||||||
|
@ -313,31 +335,23 @@ void display_waveform(UArg arg1, UArg arg2)
|
||||||
|
|
||||||
// info
|
// info
|
||||||
GrContextForegroundSet(&sContext, ClrWheat);
|
GrContextForegroundSet(&sContext, ClrWheat);
|
||||||
|
GrStringDraw(&sContext, gVoltageScaleStr[local_options.voltage_scale], /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false);
|
||||||
|
GrStringDraw(&sContext, gTimeScaleStr[local_options.time_scale], /*length*/ -1, /*x*/ 60, /*y*/ 0, /*opaque*/ false);
|
||||||
snprintf(str, sizeof(str), "CPU Load %.1f%%", usage_percent);
|
snprintf(str, sizeof(str), "CPU Load %.1f%%", usage_percent);
|
||||||
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ HEIGHT - 10, /*opaque*/ false);
|
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ HEIGHT - 10, /*opaque*/ false);
|
||||||
|
|
||||||
|
switch (local_options.trigger_mode) {
|
||||||
if (local_options.fft) {
|
case 1:
|
||||||
GrStringDraw(&sContext, "20 dB" , /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false);
|
GrStringDraw(&sContext, "^", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||||
|
break;
|
||||||
} else {
|
case 0:
|
||||||
GrStringDraw(&sContext, gVoltageScaleStr[local_options.voltage_scale], /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false);
|
GrStringDraw(&sContext, "v", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||||
|
break;
|
||||||
switch (local_options.trigger_mode) {
|
case 2:
|
||||||
case 1:
|
GrStringDraw(&sContext, "-", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
||||||
GrStringDraw(&sContext, "^", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
break;
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
GrStringDraw(&sContext, "v", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
GrStringDraw(&sContext, "-", /*length*/ -1, /*x*/ WIDTH - 10, /*y*/ 0, /*opaque*/ false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// display graph
|
// display graph
|
||||||
GrContextForegroundSet(&sContext, ClrYellow);
|
GrContextForegroundSet(&sContext, ClrYellow);
|
||||||
int j;
|
int j;
|
||||||
|
|
24
sampling.c
24
sampling.c
|
@ -119,6 +119,8 @@ void start_sampler() {
|
||||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
|
||||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
|
||||||
|
|
||||||
|
// timer for low-speed
|
||||||
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
|
||||||
// ADC clock
|
// ADC clock
|
||||||
uint32_t pll_frequency = SysCtlFrequencyGet(CRYSTAL_FREQUENCY);
|
uint32_t pll_frequency = SysCtlFrequencyGet(CRYSTAL_FREQUENCY);
|
||||||
uint32_t pll_divisor =
|
uint32_t pll_divisor =
|
||||||
|
@ -143,3 +145,25 @@ void start_sampler() {
|
||||||
ADCSequenceDMAEnable(ADC1_BASE, 0); // enable DMA for ADC1 sequence 0
|
ADCSequenceDMAEnable(ADC1_BASE, 0); // enable DMA for ADC1 sequence 0
|
||||||
ADCIntEnableEx(ADC1_BASE, ADC_INT_DMA_SS0); // enable ADC1 sequence 0 DMA interrupt
|
ADCIntEnableEx(ADC1_BASE, ADC_INT_DMA_SS0); // enable ADC1 sequence 0 DMA interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_frequency(uint64_t microseconds) {
|
||||||
|
if (microseconds == 1) {
|
||||||
|
ADCSequenceDisable(ADC1_BASE, 0);
|
||||||
|
// don't use a timer for high speed
|
||||||
|
ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_ALWAYS, 0);
|
||||||
|
ADCSequenceEnable(ADC1_BASE, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// initialize timer 2 in periodic mode
|
||||||
|
TimerDisable(TIMER2_BASE, TIMER_BOTH);
|
||||||
|
TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);
|
||||||
|
#define MICROSECONDS_PER_SECOND 1000000
|
||||||
|
TimerLoadSet(TIMER2_BASE, TIMER_A, (uint32_t) ((uint64_t) gSystemClock * microseconds / MICROSECONDS_PER_SECOND) - 1);
|
||||||
|
TimerControlTrigger(TIMER2_BASE, TIMER_A, true);
|
||||||
|
TimerEnable(TIMER2_BASE, TIMER_A);
|
||||||
|
|
||||||
|
ADCSequenceDisable(ADC1_BASE, 0);
|
||||||
|
ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_TIMER, 0);
|
||||||
|
ADCSequenceEnable(ADC1_BASE, 0);
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue