2 - Lab. 2 using Services

advertisement
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.
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
2/14/2015
2 / 28
2/14/2015
3 / 28
All true, the third time
you try using it
However, that’s what you do in
an industrial environment
2/14/2015
4 / 28
All the non-hardware
stuff from Lab. 1, 2 and
3 stays the same
VDK
All the hardware
stuff from Lab. 1, 2 and
3 – “better?”
2/14/2015
5 / 28
Shopping list
?????
2/14/2015
6 / 28
Something related to Lab. 2
2/14/2015
7 / 28
2/14/2015
8 / 28
Sounds like Lab. 2
2/14/2015
9 / 28
2/14/2015
10 / 28
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
2/14/2015
11 / 28
Next step – look for an example
This VDSP directory looks promising for GPIO
and LED control
2/14/2015
12 / 28
File LEDButtonCallback.c
This is a .c file
What happens if
want to use an
.cpp and asm
compatible to C++?
WAIL
2/14/2015
13 / 28
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
2/14/2015
This is NOT an ISR –
this is a function called
from the ISR activated
on PF interrupts
14 / 28
We can guess functionality
Whats “ezErrorCheck( )?
Same as Lab. 1 InitGPIOFlags( )
but 1 button at a time
2/14/2015
15 / 28
We can guess functionality
Guess – interrupts on PF8 and PF9
Guess – ADI_FLAG_TRIGGER_BOTH_EDGES
Guess – ADI_FLAG_POLARITY?????
Look in service.h files
2/14/2015
16 / 28
More complicated than
InitLEDPort( )
Uses “memory variable
to remember “LED stat
Improved WriteLEDASM( ) ?
2/14/2015
17 / 28
Improved WriteLEDASM( )
This is ReadGPIO( ) &
SW3Pressed == true
2/14/2015
Terminate services needed
18 / 28
fopen( )
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
2/14/2015
19 / 28
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
2/14/2015
20 / 28
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
2/14/2015
21 / 28
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
2/14/2015
22 / 28
I recognize this stuff
2/14/2015
23 / 28
I can guess about this stuff
2/14/2015
24 / 28
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
2/14/2015
25 / 28
4 ISR
equivalents
here
2/14/2015
26 / 28
We know enough to “fake” calling CPP ASM code
from C code without rewriting the code
2/14/2015
27 / 28
2/14/2015
28 / 28
Don’t know what we did
But that’s Lab. 1, 2 and 3
2/14/2015
29 / 28
Download