A library for observing RAM utilization with an oscilloscope.
scope_RAM.cpp@1:b6905730f836, 2013-11-12 (annotated)
- Committer:
- altasoul
- Date:
- Tue Nov 12 07:35:11 2013 +0000
- Revision:
- 1:b6905730f836
- Parent:
- 0:e996e4a4c783
for publication (no docs yet)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altasoul | 1:b6905730f836 | 1 | /* |
altasoul | 1:b6905730f836 | 2 | * Copyright (c) 2013 Tom Soulanille |
altasoul | 1:b6905730f836 | 3 | * |
altasoul | 1:b6905730f836 | 4 | * |
altasoul | 1:b6905730f836 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
altasoul | 1:b6905730f836 | 6 | * you may not use this file except in compliance with the License. |
altasoul | 1:b6905730f836 | 7 | * You may obtain a copy of the License at |
altasoul | 1:b6905730f836 | 8 | * |
altasoul | 1:b6905730f836 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
altasoul | 1:b6905730f836 | 10 | * |
altasoul | 1:b6905730f836 | 11 | * Unless required by applicable law or agreed to in writing, software |
altasoul | 1:b6905730f836 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
altasoul | 1:b6905730f836 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
altasoul | 1:b6905730f836 | 14 | * See the License for the specific language governing permissions and |
altasoul | 1:b6905730f836 | 15 | * limitations under the License. |
altasoul | 1:b6905730f836 | 16 | */ |
altasoul | 1:b6905730f836 | 17 | |
altasoul | 0:e996e4a4c783 | 18 | #include "mbed.h" |
altasoul | 0:e996e4a4c783 | 19 | #include "scope_RAM.h" |
altasoul | 0:e996e4a4c783 | 20 | |
altasoul | 0:e996e4a4c783 | 21 | RAMscope::RAMscope( |
altasoul | 0:e996e4a4c783 | 22 | PinName trigger_pin, |
altasoul | 0:e996e4a4c783 | 23 | PinName value_pin |
altasoul | 0:e996e4a4c783 | 24 | ) : |
altasoul | 0:e996e4a4c783 | 25 | trigger_output(trigger_pin), |
altasoul | 0:e996e4a4c783 | 26 | value_output(value_pin), |
altasoul | 0:e996e4a4c783 | 27 | scope_ram_timer(&RAMscope::scope_ram, osTimerPeriodic, (void *)this) |
altasoul | 0:e996e4a4c783 | 28 | { |
altasoul | 0:e996e4a4c783 | 29 | |
altasoul | 0:e996e4a4c783 | 30 | } |
altasoul | 0:e996e4a4c783 | 31 | |
altasoul | 0:e996e4a4c783 | 32 | void RAMscope::scope_ram(const void *arg) { |
altasoul | 0:e996e4a4c783 | 33 | RAMscope *instance = (RAMscope*)arg; |
altasoul | 0:e996e4a4c783 | 34 | instance->output_to_scope(); |
altasoul | 0:e996e4a4c783 | 35 | } |
altasoul | 0:e996e4a4c783 | 36 | |
altasoul | 0:e996e4a4c783 | 37 | void RAMscope::output_to_scope(void) { |
altasoul | 0:e996e4a4c783 | 38 | int i; |
altasoul | 0:e996e4a4c783 | 39 | unsigned char *p = start; |
altasoul | 0:e996e4a4c783 | 40 | trigger_output = true; trigger_output = false; |
altasoul | 0:e996e4a4c783 | 41 | for (i=0; i<length; i++) { |
altasoul | 0:e996e4a4c783 | 42 | value_output = *p++ == WATERMARK; |
altasoul | 0:e996e4a4c783 | 43 | } |
altasoul | 0:e996e4a4c783 | 44 | value_output = false; |
altasoul | 0:e996e4a4c783 | 45 | } |
altasoul | 0:e996e4a4c783 | 46 | |
altasoul | 0:e996e4a4c783 | 47 | void RAMscope::watermark(unsigned char *st, int len) { |
altasoul | 0:e996e4a4c783 | 48 | while (len--) *st++ = WATERMARK; |
altasoul | 0:e996e4a4c783 | 49 | } |
altasoul | 0:e996e4a4c783 | 50 | |
altasoul | 0:e996e4a4c783 | 51 | void RAMscope::scope(unsigned char *st, int len, int period) { |
altasoul | 0:e996e4a4c783 | 52 | start = st; |
altasoul | 0:e996e4a4c783 | 53 | length = len; |
altasoul | 0:e996e4a4c783 | 54 | scope_ram_timer.start(period); |
altasoul | 0:e996e4a4c783 | 55 | } |
altasoul | 0:e996e4a4c783 | 56 | |
altasoul | 0:e996e4a4c783 | 57 | void RAMscope::stop() { |
altasoul | 0:e996e4a4c783 | 58 | scope_ram_timer.stop(); |
altasoul | 0:e996e4a4c783 | 59 | } |