Hello, welcome back.
And this we are going to test out the drivers that we've assembled, but before we do that, I'm going
to add a simple driver to our XDA that Cifas actually this driver has got nothing to do with XDA, but
it's it's the same peripheral.
It's a driver for PC 13 inputs.
But in this configuration here will let us configure PC 13 as an input but in interruptive mode.
And we'll interrupt mode in places that we need not check.
The state of the pin, whether it's been pressed or not, will be towed.
But I'm going to create a simpler driver, which would require us to pull the the state of the pin.
So to do that, this one, I'm simply going to say void.
This is an easy one.
We say GPU in it and all we have to do is we have to enable clock access to GPU Pottsy, because we're
dealing with PC 13 and because in the mode register to set up into inputs, you need to set the two
bits of that be.
You need to set it to bits of that pin to to 090, and because the default value is zero and zero in
the mode register, I need not go and explicitly set it to zero zero over here.
What we did is explicitly set it to zero and zero.
We can do the same thing here or we can skip, but.
I'll just keep and show you that it would still work.
I think they'll be a good lesson.
OK, so this over here, we just need to enable clock access and by default, the penis and input mode.
So we're not touching anything.
Now we're going to read the Penn State.
So we have this function that we created is going to return you into eight underscore T and the name
of the function is going to be read digital senseor.
So we say read digital on the school senseor like this and it takes no arguments open and close like
this.
OK, so what we have to do is go to the.
Port inputs, data register and locates the bits that corresponds to the the particular pin we are looking
for.
So let's go and see this.
It's worth showing.
I'm over here in our reference manual GPU.
Registe this I'm going to scroll down to IDR, which stands for Input's Data Register.
She'll be down here somewhere.
We have input data register here and over here when we configure the opinions as input, the state is
kept here such that I'd ask you is four point zero.
So if our button was connected to a PIN zero, we can check IDR zero for where the button is pressed
or not.
In our case, we're dealing with 13.
So IDR 13 here.
And it tells us these bits are read-only and can be accessed in a word mode only, meaning we can access
these bits in a 32 bit mode only.
They contain the input value of corresponding iReports, so we want to check the status of this 13.
So what we can do is we can run, we can write on an operator and compare it to the bits 13.
OK, so.
In this register industry, chuba to register, if we set everything to zero and we set only bits 13
to one, if we convert zero zero zero zero zero zero one zero zero zero zero zero into hexadecimal,
no, what we will get is zero six two zero zero zero three zeros after the two.
All you can, you know.
Three zeros after the two.
Let's use hexadecimal.
It will be shorter.
Let me show you what I mean.
Just pardon me this time I'm all over the place.
So what we're going to do is this time elaborate because it's a short function over here.
We're going to see if you see and input data register.
So this is the entire register that we've just seen.
We're going to take that and perform an end operation with zero X.
Two zero zero zero and what does this mean, OK, if I take this hexadecimal value?
And I it to binary.
I'll show you what we get.
But before I show you this value here that we see, we see it's got one, two, three, four digits
is the same as one, two, three, four in a zero in front of a number can be deleted and is the same.
So we can keep one zero here, keep to keep three or keep four or just have it like this is the same.
If we expand this to binary, what we get is this.
So this two here in binary becomes zero one, it becomes zero zero one zero like this, and the other
zero become four zeros.
One, two, three, four.
And then one, two, three, four, one, two, three, four.
So if we count this, we have we count from zero.
So over here, we end it.
We have zero, one, two, three, then four, five, six, seven, eight, nine, 10, 11, 12.
This is 13.
So we are comparing a bit to 13.
This constant bit 13 and a bit 13 in our ADR register, we are performing an end operation.
If our bits 13 and Idriz Sets is going to return, true, otherwise is going to return false.
So that's what we're dealing with.
OK.
Let's see, so we are seen, we take this and then we perform our end operation and then we see.
Return one for true.
Else return false.
10 zero like this.
OK.
Right.
So we're going to expose these functions as well.
DoubleClick.
And I'm going to come to the includes order, open openness and.
Drop this over here, put a semicolon and go back there, double click.
Contrary to copy, includes foda to get the dots each fall and drop this over here.
OK, we're looking good control to save over here and come back here, control to save us.
Well, now I'm going to go to the main road, see fall and test them out one by one.
So I'll come over here and I'll have.
You indeed underscore t I call this B10 state.
And then I have.
You into 30 to 40, I'll call this sense of value.
So over here in our wall, one, what we want to do is.
We want to enable our you so Cappiello, you enable.
Before our wild one, sorry about that of anybody, you how about ADC?
We want to enable our ADC, so we call ADC and it's as well.
If anybody ADC so now.
In here, we're going to get our button states.
We see button states equals.
We're going to use read digital senseor.
Function, the function we just wrote.
So the return value of this function is going to be stored in our B10 state.
Variable.
OK, and then sense of value equals.
We're going to call our read sense of value.
Read analog senator over here.
OK.
This one here like this.
OK.
So we can print we can print something.
Let's see, OK, we can read it on prints, we can just view this in the watch window.
Um, so I come over here, click over here to build.
We have three arrows.
Let's see where the anomaly is, OK?
Goodness, I'm losing my mind.
I put these here.
This is supposed to be a variable acyclic to be able to gain.
It's built successfully, it's ups looking good.
OK, so once this is done, I'm going to right click over here.
And go to debuggers, estimate that to double click.
The name some drivers.
And then I say, OK, over here.
And then I'll click the switch.
Eau Claire, what we currently have here.
Remove all of this controversy and then and then a sense of value as well currently of not connected
in a sense, or to my P one.
So we don't expect anything.
We expect the value to be random to float and then I'll connect something and then we test it.
So let's click here to run.
OK, so the reason our B10 status is one is because our push button on the nuclear board is active high
meaning by default, its values.
One when you press its sorry.
Scratch that, the push button on our nuclear on our nuclear board is active, low, active, low means
it becomes when you activate it, it becomes law.
So by default, its value is high, which is one.
So I'm going to press the button, Lissi.
You see, as I press is one I release as I press, it goes to zero.
I release just one of press again.
It becomes zero.
I release it becomes one press again.
It becomes zero release.
It becomes one.
So.
Our or Aitkin is.
Pier one, I'm going to connect a jumper wire from Pier one to ground to see if I can get it.
Uh, my microcontroller disconnected.
OK, so my microcontroller disconnected because I was trying to add a jumper wire in the OK, let's
go back to Dybbuk.
You click over here.
It's opening a click to switch.
OK.
A click to run to code.
OK, so currently I have an ADC connected to my PC, one of Connecter, the middle of the ADC to be
one, the rightmost leg to the three point three votes and the leftmost leg.
To my.
OK, so currently I have a potential meter, just bear with me, this lesson is not going as planned.
I have a potential meter connector to my P.A. one not on easy.
I wonder why I said that.
So there is a potential meter connector to peer one.
And as you know, a potential meter has three legs, the middle leg, the left leg and the right leg.
The middle leg is connected to a one.
The left leg is connected to G and D.
The right leg is connected to the three point three votes.
And as I move the potential meter, you would see that the value would change.
Currently the value is zero because I've moved it to the opposite end.
That will give me zero.
I'm going to move it to the other opposite end.
Let's see.
Just a moment, OK, so I've moved it to the opposite end and I can see the sense of value has changed.
OK, you can try this with a jumper.
Yes, well, you can just put a jumper wire into Pier one and then connect at the other end of the jumper
wire to ground zero.
And then you can pull it out of ground and connect it to three point three votes.
It should read four thousand.
And something which is the maximum ATC volume, four thousand and ninety five is the maximum, but it
should be read in something around that it doesn't have to be precisely that.
But this would be an indication that your analog sensor configuration is working.
So this is it.
So as you can see over here, yes, it's reading almost the maximum ATC value because my potential meter
is pushed to the other end.
If I'm to rotate it to the opposite end, is going to give us a value like zero one or two, which indicates
that it's an extremely, extremely low value.
OK, so I'm sure you've got this.
I know this lesson had a bit of hiccups.
If there is something you didn't understand, kindly leave it in the questions in this area and I'll
be glad to follow up on it.
So this it.
I'll see you in the next lesson of a nice day.