‫Hello and welcome, everybody, and in this lecture, we're going to further work on the Tangela that
‫we created last lecture, you know, the new one that we've been making the better design.
‫We're essentially going to make this handler access function point to array, much like we did with
‫the ISI he commands.
‫OK, and essentially you'll be able to register interest handlers and the handler will pick the correct
‫one in the function points a table.
‫OK, so that that's what we're going to do this lecture and that will allow you to do things like similar
‫with the ISI, the commands, so you'll be able to register interrupts you.
‫Here we go.
‫ISI, the register command will have a function for registering those interrupts instead.
‫Now, this is pretty important because ideally we don't want to switch statement in the interest of
‫every possible interest.
‫Now, we could we could do that, but it's very ugly.
‫It's not a clean solution and it needs a lot of improvement.
‫OK, so by having a function pointer array like this where you can register, interrupt handlers and
‫stuff like that, that is much cleaner.
‫That's what we do with the Israeli commands.
‫And you saw how clean it is to make those you just go SCADA register command.
‫Look how simple that is.
‫Right.
‫That's why we use the function pointers.
‫That's why we have the ability to register those commands.
‫We're going to do the exact same thing with the intercepts so that you can register interest handlers
‫because remember, it can only go so far.
‫It requires an assembly handler because there's things that it doesn't do that we need done.
‫So OK, so we've abstracted it out to use the Interop handler and see and passes the interest.
‫No, that's great, but we can improve this further, which is what we're going to do in this lecture.
‫OK, so we're going to do then we're going to go to Idit Dot Hage and we're going to create another
‫type deafens of the command here.
‫We're just going to go.
‫Typedef void interrupts callback function and that's going to take no arguments.
‫Now remember, we're not returning anything here.
‫OK, this is just void, a void return type.
‫Nothing's being returned.
‫It's not a void pointer like this one.
‫So don't make that mistake.
‫OK, great.
‫So once you've done that, just go to Tazi and scroll up and we're going to make an array for those.
‫So just above ISI, the commands were going to go static interrupts, callback function, interrupt
‫callbacks and that's going to take the picture as total interrupts as a parameter.
‫So we're making an array the size of the U.S. interrupts five, 10, 12, interrupts an array of function
‫pointers.
‫OK, so it can hold five, 10, 12 of those function pointers to interrupt callback routines.
‫OK, so you set up the array correctly.
‫That's perfect.
‫Now let's make the register function that will be in charge of registering these inter callback functions.
‫OK, so just scroll down and just just by here we're going to go in.
‫It is register interrupts callback and it interrupts.
‫This is the number you wish to register the callback with team four and we're going to go into a callback
‫function.
‫Interrupts Callback.
‫OK, and now we're just going to go in and rescue us all, OK?
‫OK, we're going to return.
‫Yes, we're going to scroll up because we need to include the status of the Hajj just like that.
‫OK, let's go back down.
‫And we're just going to say, if the interrupt is below zero, all the interrupts is above Peatross.
‫Max interrupts.
‫Total trips, I mean.
‫Then there's an error and we'll actually do it, but very cool because we want to check to see if it's
‫breaching the bounds or not, right.
‫So above all, equal, that should be guys.
‫And here we're just going to go return minus EIO.
‫OK, well, no invalid dog, actually.
‫OK, and now down here, we're going to say interrupt callbacks.
‫Interrupts equals interrupt callback, and we can actually get rid of this variable and address as well,
‫guys, and just return zero by here, so that's our entire callback function.
‫So it simply just assigns the index where the index is the number, OK?
‫It assigns that index to the callback function pointer you provided.
‫OK, that's what that does.
‫Now, I just want us to scroll up.
‫So the handler.
‫So what we're going to do now is, is we're going to make it so when this handler gets invoked, it'll
‫use the number here to find the callback in the interest callbacks array and then it will invoke that
‫function pointer, essentially running the entire handler that we've registered.
‫By here online, 67, so that's that's what's going to be going on here.
‫OK, we need to implement that now, so we'll do that now.
‫So just scroll up to that intra panel function.
‫And we're just going to do Colonel Page
‫and we're going to say if the entraps callbacks.
‫Interrupt does not equal zero, then task current safe state.
‫And now we're going to call the call back by going into callbacks frame and also pass the interest number
‫in here guys as well.
‫OK, so that will call our callback, OK?
‫And we know it exists because we check here on line 30 if it's null and it hasn't been set.
‫OK, and then just by here, we're going to go back to the tax page because we're going to go back to
‫use the land in a moment.
‫And then finally here on line 37, we let the pig know that we've acknowledged there interrupt.
‫So, yeah, that that should work absolutely fine.
‫So essentially, our entire panel will come in.
‫Maybe there's 21 or something.
‫Yeah, it'll come in and it will call the callback that was registered for that interrupt.
‫If there wasn't an interim callback register for that interrupt, then no interrupts runs just ignored.
‫And we acknowledge it with knowledge, with the pick.
‫So yeah, it's a nice design.
‫It's now much cleaner.
‫Will now be it's just register callbacks as we did well when we registered commands for ISIS.
‫It's now the same type of design.
‫Before we do anything else, just scroll down.
‫And go to a function for registering in callbacks, copy and paste this prototype.
‫We you to put that in the head of file.
‫OK, because we need the ability to register callbacks in the head of file like that.
‫OK, so just put that and then that should be fine.
‫OK, so the final thing to do is to go make a clean build that S.H..
‫And we can see everything builds absolutely fine.
‫OK, so we now have the ability to command.
‫That's really good.
‫We can test this functionality now just to be on the safe side.
‫That's absolutely fine.
‫So if we just go to Colonel Godse, we'll write a little handler now for us to test this.
‫So just have to keyboard initialization.
‫We will need to register that.
‫So we're going to register a command for the callback, correct?
‫Just on the keyboard in it.
‫We're going to go it register, interrupt, callback, and we're going to use twenty, which will be
‫the timer interrupt because of the way we've mapped the pic to zero x 20.
‫Right.
‫And the first routine is the timer.
‫So because we have to see X 26, 24 timer interrupts.
‫So we're going to pass we're going to register that call back to the pick time callback just just for
‫a test to see if this works.
‫And we're going to have to create that function now.
‫OK, so just scroll up just above Colonel Main and we're just going to go void pick time a callback,
‫and that's going to accept an interim frame.
‫And we're just literally going to go print timer activated just to see if that works.
‫OK, so if you now just go make a clean bill to S.H..
‫Cribben and we run the kumu.
‫You can see timer activated, you see, and the reason the time is activated is because every few minutes,
‫seconds, the pick interrupts the process, causing interrupt handler to be called, which then calls
‫are registered peak time, a callback, which we registered here with the ADT Register callback function
‫that we just created.
‫So now that we've improved our intrepid handler, we we are now ready to go back to implement the keyboard
‫functionality further.
‫OK, so thanks so much for watching this lecture.
‫I hope you appreciate your new design.
‫This will be far easier to work with, with anything relating to interrupts.