Mercurial > hg > beaglert
changeset 75:8bd351ca8b46
Fixed direction in setPinMode functions, updated and fixed basic_blink
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 17 Jul 2015 20:59:43 +0100 |
parents | 0598731d3bef |
children | ff0f776415e4 |
files | core/Utilities.cpp projects/basic_blink/render.cpp |
diffstat | 2 files changed, 9 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/core/Utilities.cpp Fri Jul 17 20:23:38 2015 +0100 +++ b/core/Utilities.cpp Fri Jul 17 20:59:43 2015 +0100 @@ -68,7 +68,7 @@ // Sets the direction of a digital pin for the current frame and all subsequent frames void pinModeFrame(BeagleRTContext *context, int frame, int channel, int mode) { for(unsigned int f = frame; f < context->digitalFrames; f++) { - if(mode == OUTPUT) + if(mode == INPUT) context->digital[f] |= (1 << channel); else context->digital[f] &= ~(1 << channel); @@ -79,7 +79,7 @@ // // Sets the direction of a digital pin for the current frame only void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode) { - if(mode == OUTPUT) + if(mode == INPUT) context->digital[frame] |= (1 << channel); else context->digital[frame] &= ~(1 << channel);
--- a/projects/basic_blink/render.cpp Fri Jul 17 20:23:38 2015 +0100 +++ b/projects/basic_blink/render.cpp Fri Jul 17 20:59:43 2015 +0100 @@ -1,9 +1,3 @@ - /* - * - * Andrew McPherson and Victor Zappi - * Queen Mary, University of London - */ - #include <BeagleRT.h> #include <Utilities.h> #include <cmath> @@ -28,9 +22,13 @@ // ADCs and DACs (if available). If only audio is available, numAnalogFrames // will be 0. +/* basic_blink +* Connect an LED in series with a 470ohm resistor between P8_07 and ground. +* The LED will blink every @interval seconds. +*/ + void render(BeagleRTContext *context, void *userData) { - //connect an LED in series with a 470ohm resistor between P8_07 and ground static int count=0; //counts elapsed samples float interval=0.5; //how often to toggle the LED (in seconds) static int status=GPIO_LOW; @@ -42,11 +40,9 @@ status=GPIO_HIGH; else status=GPIO_LOW; - pinModeFrame(context, 0, P8_07, OUTPUT); - digitalWriteFrame(context, n, P8_07, status); //write the status to the LED - // rt_printf("there %d\n", context->digital[n]); + pinModeFrame(context, n, P8_07, OUTPUT); + digitalWriteFrameOnce(context, n, P8_07, status); //write the status to the LED } - context->digital[n]=status*0x00010000; count++; } }