A library for observing RAM utilization with an oscilloscope.
Diff: scope_RAM.cpp
- Revision:
- 0:e996e4a4c783
- Child:
- 1:b6905730f836
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scope_RAM.cpp Tue Nov 12 07:16:15 2013 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include "scope_RAM.h" + +RAMscope::RAMscope( + PinName trigger_pin, + PinName value_pin +) : + trigger_output(trigger_pin), + value_output(value_pin), + scope_ram_timer(&RAMscope::scope_ram, osTimerPeriodic, (void *)this) +{ + +} + +void RAMscope::scope_ram(const void *arg) { + RAMscope *instance = (RAMscope*)arg; + instance->output_to_scope(); +} + +void RAMscope::output_to_scope(void) { + int i; + unsigned char *p = start; + trigger_output = true; trigger_output = false; + for (i=0; i<length; i++) { + value_output = *p++ == WATERMARK; + } + value_output = false; +} + +void RAMscope::watermark(unsigned char *st, int len) { + while (len--) *st++ = WATERMARK; +} + +void RAMscope::scope(unsigned char *st, int len, int period) { + start = st; + length = len; + scope_ram_timer.start(period); +} + +void RAMscope::stop() { + scope_ram_timer.stop(); +}