290 likes | 364 Views
The System Services way of doing Lab. 2 Task 8. What was Lab. 2. Activate EBIU, Flash memory, Flash LED, GPIO flags Connect light sensor to PF11 Each time an interrupt occurs on PF11, record the CYCLES counter.
E N D
What was Lab. 2 • Activate EBIU, Flash memory, Flash LED, GPIO flags • Connect light sensor to PF11 • Each time an interrupt occurs on PF11, record the CYCLES counter. • Every second time an interrupt occurs, calculate the frequency of the light sensor voltage, and calculate light level • Display the light level on the LED lights
All true, the third timeyou try using it However, that’s what you do inan industrial environment
VDK All the non-hardwarestuff from Lab. 1, 2 and3 stays the same All the hardwarestuff from Lab. 1, 2 and3 – “better?”
Shopping list ?????
Where to start? • Make sure we understand the following • Lab. 1 – Setting up the EBIU • Lab. 1 – Activating the LED • Lab. 1 – Activating the GPIO switches • Lab. 2 – software interrupts on GPIO • Lab. 2 – hardware interrupts on GPIO • Lab. 2 – ISR for measuring light sensor output • Assignment 3 – Activating CYCLES
Next step – look for an example This VDSP directory looks promising for GPIO and LED control
File LEDButtonCallback.c This is a .c fileWhat happens ifwant to use an.cpp and asmcompatible to C++? WAIL
Callback function What is a “client handle”? What’s a “u32Event”? What’s a “void *pArg”? Why is function “static”?The rest we can guess This is NOT an ISR – this is a function calledfrom the ISR activated on PF interrupts
We can guess functionality Whats “ezErrorCheck( )? Same as Lab. 1 InitGPIOFlags( ) but 1 button at a time
We can guess functionality Guess – interrupts on PF8 and PF9 Guess – ADI_FLAG_TRIGGER_BOTH_EDGESGuess – ADI_FLAG_POLARITY????? Look in service.h files
More complicated thanInitLEDPort( ) Uses “memory variables”to remember “LED state” Improved WriteLEDASM( ) ?
Improved WriteLEDASM( ) This is ReadGPIO( ) & SW3Pressed == true Terminate services neededfopen( )fclose( ) equivalent
Still a lot more to understand • Many questions still unanswered • In principle we could fix this code to handle Lab. 2 and 3 since we know what Lab. 2 and 3 are supposed to do • We could re-use most of the code • Switch 4 for light sensor • Switch 3 and 2 for thermal sensors • Switch 1 for “stop” • Cut and paste that code
Call back function • Using this “*pArg” thing I could fix it so • If button 4 interrupt then read CYCLES and store in light sensor array • If button 3 interrupt store CYCLES in temp 1 array • If button 2 interrupt store CYCLES in temp 2 array • Once 4 values stored in array, leave “message” for main( ) to do necessary calculation
Main( ) • Do all the same init manager stuff • Make all three buttons call Callback • While loop • If light sensor values ready, calculate light level and display • If temp1 values ready, calculate temperature and print • If temp2 values ready, calculate emperature and print
Quote from Arthur C Clarke • The technology of any sufficiently advanced civilization is indistinguishable from magic. • It may be magic, but based on how I got Labs 1, 2 and 3, I reckon I could hack main( ) to get something to happen. • How I would test it, debug it or customize it – I have not got a clue – meaning I could not extend the ideas to use SDMA or SPI service
Next Stage • Not entirely sure what is happening • But I believe that if I do good code review, frequently check my syntax, and am lucky, I could do Lab. 1, Lab. 2 and Lab 3 tasks using Services • Debugging things – especially if services are not written as expected, or I have misunderstood something – may be problematic • My code follows
We know enough to “fake” calling CPP ASM codefrom C code without rewriting the code