Hello, welcome back.
And this lesson, we going to see how to work with task notifications, what I'm going to do is make
a copy of our drivers project.
Some drivers, this one here, I'll make a copy of it.
I'll say copy over here and paste over here.
And this becomes 31 who call this task notifications.
Like this.
OK, I'm going to expand.
Open the main door, see, fall over here, OK, this is what we have.
This is our driver's fuda, our some driver's projects over here.
We're going to use our external interrupts driver that we created yesterday.
And what that is, is basically set in our PC 13 as an input interrupt such that when we press the PC
13, we uninterrupted is generated and we can, you know, implement or run a piece of code in the interrupt
request handler.
OK, so this project, we don't need this.
I'm going to clean this bit from it.
So a project currently has no ARTUS.
We don't need this as well, so I'll clean this.
All we have is our inclusions and then we've initialized our UTX.
OK, so to use notifications we need to enable notifications in our Simms's.
The CMC is always the each file over here.
Right click go to open declarations and you come down here.
Over here.
Currently we have just Tosk dot h included.
Um not here.
Sorry about that.
Goodness.
I'm losing my mind.
We have to include notification by going to our free ARTUS configured HFA.
Sorry, um, look at that.
I was on a roll just talking about something else.
OK, this fall here, free artist configurator.
So just like we included the other artist component.
We can search for notification or do control over here and such notification, it's not here, so I'm
going to include it.
So what we want to do is type.
Define config task notifications, and then we said this to one, this will allow us to be able to use
notifications controls to save come back to me not see.
OK, we're going to have one task.
This is the handler task.
And then we're going to have our interrupted request handler.
So what are we going to do?
Is we going to initialize PC 13 for interruptive?
So I copy this function and then I'll come over here.
And then I call this function here, so P.S. 13 is enabled in its interrupt mode, and because it's
interrupt, we've got to define the interrupt request handler or the interrupted service routine.
The interrupt request handler for P.S. 13 is called XDA 15 dash 10 I.Q. It has to be written like this.
This is its name in the vector table.
And the reason it's a 15 dash 10 is because interrupts request external interrupts 10 through 15.
Share the same interrupt.
Request a line.
That is why we're doing an extra 10 dash 15 over here.
If we had if we were using less European such as 10, 11, 12, 13, then in here we would have an if
close or we'd be using it to check whether the interrupt is from 10, 11, 12, 13, 14 or 15.
But because we have just one, which is from 13, we need not check the source of it.
In a way.
Like I said, this is bare metal stuff, so I wouldn't go deeper into this.
So what we have so far with initialize our P.S. 13 as an input interrupts and then we have the empty
interrupt request handler here.
OK, we going to create a task, a single task known as the handler task.
And we can give it any priority because it is the only task in our system.
So currently the name of this task function is going to be on the task.
The task is called handler task and we given it a stack size of 128, which is equal to five one two
bytes.
OK, so this stack size volume is what we have here and we're given a priority of three.
You can give a priority of whatever you want because it's the only task here and we're going to store
the handle of this task.
In a variable here, so we have this variable Hondo task.
So once the task is created, the handle of the task will be stored in this variable here.
OK, looking good so far.
Next, we going to start our scheduler using our V task search that starts function once that is done.
We going to come over here and implement the task function of our handler task.
So we say, well, one in here.
Open and close, OK?
And over here, we're going to define a delay amount, you're going to define a hundred times delay.
So I'm going to say Purdum's to takes one hundred and I'm going to store the value in this variable
known as X marks expected block time.
OK, so this is our interrupt request handler, when we press our push button, whatever we please in
this function is going to be executed.
OK, what we want to do is whenever the push button is pressed, we want to send a notification to our
handler task over here.
OK, so I'm going to start by defining X higher priority task to be walking or define this variable
and we can set it to false.
We don't have any higher priority tasks.
We want to wake up.
We have a single task and I'll leave it up to you to run these experiments with multiple tasks and CD
effect of setting higher priority task, walking to true or false in a mortarboard or in a multi task
system with different priorities.
OK, so then what we do is what we want to happen here, we want to send a notification to our to ask,
so we use the V task, notify give from Isar function to send a notification.
So this function takes the task.
The task you want to send a notification to takes the handle of that task as the first argument.
And a second argument is the higher priority task.
Wolken.
And once that is done for our interruptive, we need to clear the interruptive flag right to recommit.
So to clear the flag, we simply write this hexadecimal value in the P r register.
Okay.
Once that's done, we're going to request a context switch.
So the interrupt request handler will tell the process.
Okay, I'm done during the process or so we use the port from ESADE, just like we saw in our other
examples where we have where we are entraps request handles.
So party from ESR and then we pass X higher priority task walking us arguments here.
So this will send a notification.
OK.
So once that is done, we would go to our handler to ask to see if a notification.
Was received in our handler task over here, come and call the take notification function and dysfunction
here.
Come over here.
We see this the name of the function you task, notify, take.
This function takes two arguments, the first argument here is the is the Xolair count on exit.
As you can see over here, it's called a clear count on exit and of course, the next argument is that
block time.
So this one here, clear count on exit.
If we set it to false, then these are the Arktos notification value is decrements it before we exit
this function.
So you can think of this.
This is like account in semaphore being decrements it whenever we take the SEMAFO, if we said is to
force thus the effect we have if we said is to true, it's like a binary semaphore being set to zero
because a binary semaphore can either be one or zero.
OK, so over here we settled into force.
OK.
Right.
So we're going to see if this is not equal to zero, then we want to see want to print something essentially.
When I come over here and print this, we see handler task in event, meaning we've received it.
Essentially what we use this for is to be able if this handler task had an important piece of information,
then it would notify it that it's done its job and then we process further.
Yeah, over here we can see do something and do something we are doing is basically printing this to
the US.
OK, so once this is done, we can have an LST condition here if we want.
Do something as well.
OK, so that is it, we can take our task prototype to the top over here.
And then.
We build and see what we have a click over here to build.
It's built successfully.
All right, click over here.
And then.
Go to debark us ystem thirty two, thirty one, and then OK over here.
And then click the switch over here.
I'll clear what we have here.
We don't need this, actually, so I'll leave it.
I'll bring real time.
I'm going to select this new line mode port over here, I'm going to select the portrait, then I'm
going to select the port.
And then I'm going to open it, then I'm going to minimize this.
And I'm going to click to play over here, OK?
Awkward is running, so I'm going to press the push button.
And as you can see, I press the push button.
It says, let us process an event.
So when I press the interrupt, a case of press again.
I've pressed again, so basically and notification is sent to our handler to ask whenever the push button
is pressed, when a push button is pressed in our interrupts request handler, we say notify the handler
task.
OK, and over here, we just using the push button as an example, this could be you configuring your
ADC to work in interrupt mode such that when there is a new piece of analog data, you can just notify
a function that has your digital signal processing algorithm to process that new piece of data.
Over here, we are using simple examples to explain these complex, powerful features that we have in
the ARTUS.
So this order is for this lesson, and I'll see you later.
Have a nice day.