Hello, welcome back and a lesson we go going to see uninterrupted version of our interaction with drivers
project.
So I'm going to make a copy of this last project.
We created number twenty five over here.
I'm going to copy this and paste it over here.
And I'll call this number twenty six.
So what I'm going to do is I'm just going to add the word enwrapped, because I hear.
It's copying and it's done copying expand this.
We have sauce over here, whereas may not see over here.
OK, so this is our old project.
We had two tasks.
We have we have the task that pulls the you out for new data and a one to one Condorcet.
And we said I was a bit inefficient since we have to pull.
Pull means checking, checking, always checking whether there's something new and requires spending
processor cycles to do that.
And we said a better a better architecture would be not to check just to go on and do your stuff.
When there is new data, you'll be told.
So you can think of this as having a mobile phone and you're always looking at a mobile phone.
Because you think if you take your eyes off it and someone texts you, you wouldn't see the text, but
then someone comes along and says, just go ahead, live your life and leave the mobile phone.
When there is a new text message, you receive a tone that you would receive a sound and a vibration.
So when there's a new text message that's like an interrupt, you can check a text message now rather
than you keep your eyes on the phone, always looking, because what if someone sends a text and you
don't see it uninterrupted the same way?
So you can you can go ahead.
You need not keep your eyes on the phone, OK?
Anyway, I hope that's a fair analogy.
OK, or in our previous projects we kept this here in our while in our main function while loop.
This is not required.
We forgot to clean this, but of course it has no effect here because the code doesn't reach whatever's
in a while.
Loop is not executed because once the Sketchley started, all of this is unreachable.
But to keep it clean and tidy, I'm going to clean this and I'm going to go to the previous project
as well and clean it.
This one here interacting with you are two drivers.
I'm going to open the immediate C4 and clean it.
OK, I'll clean it from here.
Control as.
Close this.
So this are new project.
OK, so we said we wouldn't need polling, so I'm going to delete that task for polling.
I'll delete this task.
So we have just one task handle handle the handle the task, because I've deleted a polling task.
I'm going to delete its task function from here as well and.
The polling task, I'm going to delete it.
From here as well.
OK, so before we proceed, we have to initialise interrupt you currently our Ewart's IREX is not configured
for interrupt.
So we're going to write a piece of code that would configure it for interrupt.
So.
Or bring this block of code here, this code is called Starts, IREX interrupts, OK, and we're going
to have a global variable that we call IREX interrupts in progress.
Which I shall keep over here, I'll keep at the top over here, we have this global variable called
IREX in progress.
OK.
Right, but what from a hardware perspective or were you at hardware perspective, we start Erich's
by writing, by setting a particular bit in the control register, one too high, and this hexadecimal
value corresponds to setting that bit.
And again, if you want to learn how to write bedmate or drivers, there's a and have at least three
courses just for that.
So we just add this.
This line here would enable interrupts mode for us.
And once we've been able to interrupt mode, we have to set the interrupt priority.
So this is different from our top priority, so we said it priority to priority of six in the Novik
and then we are unable to interrupt to request.
So the name of the incorrupt is used that to I arguin.
OK, so that's it.
That's the short explanation for this.
So once we have this, we go ahead.
And also I should point out that the interrupt, just like our.
Just like our software time is interrupts how the callback function and what this means is.
It has a function, though, to execute when that particular interrupts occurs.
We saw in our software time is that we had to create Kobuk functions for them such that when there is
a timeout, the content of the particular function will be executed.
Is the same for interrupt interrupt require callback functions.
In fact, that is the only way you make use of the interrupt.
The point of the interrupt is that when something occurs, you want something, an action to be taken.
That action that you want to be taken is placed in what we call the callback function.
So we going to have a callback function and the callback function here.
We don't just give it a name.
The name is defined in something known as the vector or table, and you can find the vector table in
the dots for the start up dots file of the project of every project.
So the callback function of our user to as written as use out to underscore our cue handler.
The callback function is also known as the IQ handler, and the reason for that is as the entraps request
handler.
So it's called either the interrupts callback function, the interrupt request handler or the interrupt
service routine.
You can also call it the guess are right.
These are bedmate or.
Concepts.
OK, so there'll be a callback function here and what we place in this function is what we do is what
we execute when uninterrupted chaos, OK?
OK, so over here, this lesson is unique in that this the first time we are going to show you how to
how we are going to show interaction between how to interrupt.
And our our scheduler right over here, we have to declare a variable newnes higher priority task to
be walking in free ARTUS whenever you enter and interrupt service routine or an interrupt request handler
and you exit.
You have the option to indicate whether you want a higher priority task to be woken up, so if we had
multiple tasks in our system currently coming out of the incorrupt service routine, we can see that
when you come out, wake up the highest priority task in the secular.
This means don't go and continue where you left off.
It could be that you were running a lower priority task before you entered the interrupt service routine.
But we can see when you come out of the interrupt service routine, don't continue running your lower
priority task, just wake up the highest priority task you have.
Right.
And the reason I'm saying come out is that you have to remember our process, all this one.
So although we said we have a real time system and we're running in parallel, we run in multiple tasks
in parallel.
That is not quite true.
What is happening is that each each task is given some time on the Processo and then after the time
is exhausted, the task is taken off and a new one is brought very quickly, is so quick that we think
it's all happening in parallel.
So Wendy interrupts your case, the interrupt service routine, when the interrupt service routine is
being executed, what would happen is that the process or will be given to the interrupt service routine.
So the tasks in our scheduler wouldn't have any process or time.
So it will be after our interrupt service routine has finished in the process so that you go back to
our checklist tasks and then to continue so we would see how that would go.
So we said, OK, we set in this to force.
We start by declaring it and set it to force and then we go into.
Check our status register.
We're not Poulan, we simply checking our status register.
OK, over here, you wouldn't find a while loop to wait for a character to.
OK, so we say we simply say if status register sets, meaning if there is new data, then we want to
take this story in a in a temporary variable like this.
And then we would see if irex in progress over here, our ARITZ.
If we see if IREX in progress, then we want to send this to the queue.
The new data and this is the key part you see over here.
I'm using the version of the function excuse and from ESR in Free Artus, you'd never use a function
that hasn't got Isar at the end in the Isar.
You have to keep this in mind.
All functions, functions that we can function so we can use in Iosava, which means interrupt service
routine.
Daris, this is our version so we know we have our excuse function, our standard excuse in function.
This is that the one that we are allowed to use and interrupt service routine.
So is quote from ESR at the end.
So over here, this is the handler of the Q we want to send to this is the value we want to send.
And then over here we are indicating whether we want to we want to wake up a higher priority task or
not.
So over here, we are passing this very.
We said it's a higher priority task walking we passing this year, we have to indicate that if we want
to use this, we've started to focus, OK, once we are done over here after this, the data is going
to be in our queue.
Right.
We have to use the process or we call the function.
Porti yield from ISO Yudin means letting go.
The process yield is like give up.
Right?
So we use the process or from Isar and we pass X higher priority task walking here as argument.
OK.
So I don't know if I explain this bit properly.
The only confusing bit to be here.
Over here we are saying don't wake up a higher priority task.
Basically, that is why we have police force here.
If we want to wake up a higher priority task, we can simply sit through here.
But this the reason, uh, this is not quite relevant here is we have a single task here and it's got
one priority.
So over here we are saying, OK, when you come out of the interrupt service routine, if we had multiple
tasks and one of them, one of them is blocked Wigdor one up and continue from the higher priority task.
But over here, we are seeing force.
Right, OK, so I think I may have spelt it differently, preforms is capital letters.
OK, so we setting this to force.
So actually I can simply pass false here and pass false here.
So we have to indicate what form is or do we want to wake up a high priority task.
We still say in force.
OK, right.
If you don't get this.
Leave it in the question and answer this.
We do not want to wake up from a higher priority task, although it makes no difference in this project
because there's a single task.
So we're looking good.
No, we have to start to interrupt this function here.
We have to call it somewhere.
And also our you at our function, remember, in our previous project, we called it in our previous
task, the pool Ewart's task.
Because that task is no longer here, we will call that in our hands task, so our task first initialize
the U at our X and then it would start the IREX interrupt.
So overseeing our handler task will call these to you in initialised to you or use.
And the reason why it is called USA is because the model is actually universal Synchronoss asynchronous
receiver transmitter, but because we are using just the asynchronous bits we say you are not without.
Yes.
So I'm using the two words interchangeably.
So we initialize the what's our X?
And then we start IREX interrupt, OK, and there's nothing more to do here.
We can just we need not put a function prototype out at all because this function is defined above this
one that requires it.
OK.
So let's build and see what we've got.
I'll click over here to build.
We've got no notario.
And.
OK, I'm building the wrong one, it appears we're going to minimize this, this is our new one.
Twenty six click to build.
OK, we have a number of errors.
OK, there's a difference in the spelling.
I'm going to go to.
Oh, are you to see fall over here and grab the function?
This is how we split it here, I reckon it used to.
You are in it.
Okay.
So this the spelling of the function, OK, let's click to build.
No error, no warning, right, click.
We're going to see debug us estimate 30 to double click number twenty six over here, I say, OK, over
here.
And then click to switch.
And I'm going to open this.
This is our realtor going to click to run and then going to press a key.
I just pressed it on my keyboard with a cop's look on going to press capital D, capital B.
Capital G.
Capital T.
And I'm going to press the number eight and then the number five and number six, OK, so it's working
as expected, right?
So this is how we can use enwrapped.
Remember, the take away from this lesson is that if you want to use any function in the interrupt service
routine, the particular free Arktos function has to end with from ESR.
OK, and this here is used to indicate whether we want to wake up a higher priority task when the processor
is given back to our scheduler, because when we are executing this hour hour to stretch, that hasn't
got a process.
So I will interrupt service fruitiness using it.
When it's done.
It would have to say, OK.
We would have to decide whether we want to go to a higher priority task or we want to continue where
we left off, even if that task had a lower priority.
So that's what this parameter is for, is all there is for this lesson.
And I'll see you later.
Have a nice day.