annotate projects/basic_button/render.cpp @ 223:ec9425f728bc mergingClockSync

Removed redundant calls to pinModeFrame. Closes #1623.
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 22 Feb 2016 11:28:21 +0000
parents ad130ecb2def
children db76215feb69
rev   line source
giuliomoro@77 1 /*
giuliomoro@77 2 *
giuliomoro@77 3 * Andrew McPherson and Victor Zappi
giuliomoro@77 4 * Queen Mary, University of London
giuliomoro@77 5 */
giuliomoro@77 6
giuliomoro@77 7 #include <BeagleRT.h>
giuliomoro@77 8 #include <Utilities.h>
giuliomoro@77 9 #include <cmath>
giuliomoro@77 10 #include <rtdk.h>
giuliomoro@77 11
giuliomoro@77 12 // setup() is called once before the audio rendering starts.
giuliomoro@77 13 // Use it to perform any initialisation and allocation which is dependent
giuliomoro@77 14 // on the period size or sample rate.
giuliomoro@77 15 //
giuliomoro@77 16 // userData holds an opaque pointer to a data structure that was passed
giuliomoro@77 17 // in from the call to initAudio().
giuliomoro@77 18 //
giuliomoro@77 19 // Return true on success; returning false halts the program.
giuliomoro@77 20
giuliomoro@77 21 bool setup(BeagleRTContext *context, void *userData)
giuliomoro@77 22 {
giuliomoro@223 23 for(unsigned int n=0; n<context->digitalFrames; n++){
giuliomoro@223 24 pinModeFrame(context, 0, P8_08, INPUT);
giuliomoro@223 25 pinModeFrame(context, 0, P8_07, OUTPUT);
giuliomoro@223 26 }
giuliomoro@77 27 return true;
giuliomoro@77 28 }
giuliomoro@77 29
giuliomoro@77 30 // render() is called regularly at the highest priority by the audio engine.
giuliomoro@77 31 // Input and output are given from the audio hardware and the other
giuliomoro@77 32 // ADCs and DACs (if available). If only audio is available, numAnalogFrames
giuliomoro@77 33 // will be 0.
giuliomoro@77 34
giuliomoro@77 35 /* basic_button
giuliomoro@77 36 * - connect an LED in series with a 470ohm resistor between P8_07 and ground.
giuliomoro@77 37 * - connect a 1k resistor to P9_03 (+3.3V),
giuliomoro@77 38 * - connect the other end of the resistor to both a button and P8_08
giuliomoro@77 39 * - connect the other end of the button to ground.
giuliomoro@77 40 * The program will read the button and make the LED blink when the button is pressed.
giuliomoro@77 41 */
giuliomoro@77 42
giuliomoro@77 43 void render(BeagleRTContext *context, void *userData)
giuliomoro@77 44 {
giuliomoro@77 45 for(unsigned int n=0; n<context->digitalFrames; n++){
giuliomoro@223 46 int status=digitalReadFrame(context, 0, P8_08); //read the value of the button
giuliomoro@223 47 digitalWriteFrame(context, n, P8_07, status); //write the status to the LED
giuliomoro@223 48 }
giuliomoro@77 49 }
giuliomoro@77 50
giuliomoro@77 51 // cleanup() is called once at the end, after the audio has stopped.
giuliomoro@77 52 // Release any resources that were allocated in setup().
giuliomoro@77 53
giuliomoro@77 54 void cleanup(BeagleRTContext *context, void *userData)
giuliomoro@77 55 {
giuliomoro@77 56 // Nothing to do here
giuliomoro@77 57 }