comparison projects/basic_blink/render.cpp @ 81:92145ba7aabf

Updated PRU code to allow pinModeFrame() and [untested] digitalWriteFrame() and analogWriteFrame() to be called from setup(). Updated basic_blink example accordingly.
author andrewm
date Fri, 17 Jul 2015 22:16:53 +0100
parents ff0f776415e4
children ac8eb07afcf5
comparison
equal deleted inserted replaced
79:90e0c7750df3 81:92145ba7aabf
12 // 12 //
13 // Return true on success; returning false halts the program. 13 // Return true on success; returning false halts the program.
14 14
15 bool setup(BeagleRTContext *context, void *userData) 15 bool setup(BeagleRTContext *context, void *userData)
16 { 16 {
17 pinModeFrame(context, 0, P8_07, OUTPUT);
17 return true; 18 return true;
18 } 19 }
19 20
20 // render() is called regularly at the highest priority by the audio engine. 21 // render() is called regularly at the highest priority by the audio engine.
21 // Input and output are given from the audio hardware and the other 22 // Input and output are given from the audio hardware and the other
34 static int status=GPIO_LOW; 35 static int status=GPIO_LOW;
35 for(unsigned int n=0; n<context->digitalFrames; n++){ 36 for(unsigned int n=0; n<context->digitalFrames; n++){
36 if(count==context->digitalSampleRate*interval){ //if enough samples have elapsed 37 if(count==context->digitalSampleRate*interval){ //if enough samples have elapsed
37 count=0; //reset the counter 38 count=0; //reset the counter
38 // status=digitalReadFrame(context, 0, P8_07); 39 // status=digitalReadFrame(context, 0, P8_07);
39 if(status==GPIO_LOW) //toggle the status 40 if(status==GPIO_LOW) { //toggle the status
40 status=GPIO_HIGH; 41 digitalWriteFrame(context, n, P8_07, status); //write the status to the LED
41 else 42 status=GPIO_HIGH;
42 status=GPIO_LOW; 43 }
43 pinModeFrame(context, n, P8_07, OUTPUT); 44 else {
44 digitalWriteFrame(context, n, P8_07, status); //write the status to the LED 45 digitalWriteFrame(context, n, P8_07, status); //write the status to the LED
46 status=GPIO_LOW;
47 }
45 } 48 }
46 count++; 49 count++;
47 } 50 }
48 } 51 }
49 52