1
00:00:00,820 --> 00:00:08,950
Hello, welcome back and a lesson we go going to see uninterrupted version of our interaction with drivers

2
00:00:08,950 --> 00:00:09,460
project.

3
00:00:09,910 --> 00:00:13,510
So I'm going to make a copy of this last project.

4
00:00:13,510 --> 00:00:15,420
We created number twenty five over here.

5
00:00:15,430 --> 00:00:18,580
I'm going to copy this and paste it over here.

6
00:00:19,150 --> 00:00:21,640
And I'll call this number twenty six.

7
00:00:24,440 --> 00:00:29,510
So what I'm going to do is I'm just going to add the word enwrapped, because I hear.

8
00:00:33,620 --> 00:00:37,190
It's copying and it's done copying expand this.

9
00:00:38,960 --> 00:00:42,860
We have sauce over here, whereas may not see over here.

10
00:00:43,780 --> 00:00:45,950
OK, so this is our old project.

11
00:00:45,950 --> 00:00:47,210
We had two tasks.

12
00:00:47,870 --> 00:00:52,700
We have we have the task that pulls the you out for new data and a one to one Condorcet.

13
00:00:53,300 --> 00:00:56,630
And we said I was a bit inefficient since we have to pull.

14
00:00:56,640 --> 00:01:03,110
Pull means checking, checking, always checking whether there's something new and requires spending

15
00:01:03,110 --> 00:01:04,840
processor cycles to do that.

16
00:01:05,450 --> 00:01:12,080
And we said a better a better architecture would be not to check just to go on and do your stuff.

17
00:01:12,500 --> 00:01:14,330
When there is new data, you'll be told.

18
00:01:14,810 --> 00:01:20,300
So you can think of this as having a mobile phone and you're always looking at a mobile phone.

19
00:01:21,280 --> 00:01:27,700
Because you think if you take your eyes off it and someone texts you, you wouldn't see the text, but

20
00:01:27,700 --> 00:01:32,770
then someone comes along and says, just go ahead, live your life and leave the mobile phone.

21
00:01:32,980 --> 00:01:38,750
When there is a new text message, you receive a tone that you would receive a sound and a vibration.

22
00:01:39,250 --> 00:01:44,500
So when there's a new text message that's like an interrupt, you can check a text message now rather

23
00:01:44,500 --> 00:01:49,780
than you keep your eyes on the phone, always looking, because what if someone sends a text and you

24
00:01:49,780 --> 00:01:51,940
don't see it uninterrupted the same way?

25
00:01:52,270 --> 00:01:54,790
So you can you can go ahead.

26
00:01:54,790 --> 00:01:57,410
You need not keep your eyes on the phone, OK?

27
00:01:57,580 --> 00:01:59,530
Anyway, I hope that's a fair analogy.

28
00:02:00,280 --> 00:02:09,330
OK, or in our previous projects we kept this here in our while in our main function while loop.

29
00:02:09,350 --> 00:02:10,990
This is not required.

30
00:02:11,110 --> 00:02:16,600
We forgot to clean this, but of course it has no effect here because the code doesn't reach whatever's

31
00:02:16,630 --> 00:02:17,020
in a while.

32
00:02:17,020 --> 00:02:22,950
Loop is not executed because once the Sketchley started, all of this is unreachable.

33
00:02:23,350 --> 00:02:28,480
But to keep it clean and tidy, I'm going to clean this and I'm going to go to the previous project

34
00:02:28,480 --> 00:02:29,450
as well and clean it.

35
00:02:30,190 --> 00:02:33,040
This one here interacting with you are two drivers.

36
00:02:33,370 --> 00:02:38,410
I'm going to open the immediate C4 and clean it.

37
00:02:41,600 --> 00:02:43,260
OK, I'll clean it from here.

38
00:02:44,420 --> 00:02:45,290
Control as.

39
00:02:46,590 --> 00:02:47,310
Close this.

40
00:02:49,110 --> 00:02:50,430
So this are new project.

41
00:02:50,820 --> 00:02:56,430
OK, so we said we wouldn't need polling, so I'm going to delete that task for polling.

42
00:02:56,850 --> 00:02:58,020
I'll delete this task.

43
00:02:58,890 --> 00:03:04,770
So we have just one task handle handle the handle the task, because I've deleted a polling task.

44
00:03:04,770 --> 00:03:09,720
I'm going to delete its task function from here as well and.

45
00:03:11,220 --> 00:03:13,680
The polling task, I'm going to delete it.

46
00:03:14,810 --> 00:03:16,040
From here as well.

47
00:03:17,120 --> 00:03:26,990
OK, so before we proceed, we have to initialise interrupt you currently our Ewart's IREX is not configured

48
00:03:26,990 --> 00:03:27,720
for interrupt.

49
00:03:28,160 --> 00:03:32,510
So we're going to write a piece of code that would configure it for interrupt.

50
00:03:33,710 --> 00:03:34,160
So.

51
00:03:36,450 --> 00:03:44,940
Or bring this block of code here, this code is called Starts, IREX interrupts, OK, and we're going

52
00:03:44,940 --> 00:03:49,920
to have a global variable that we call IREX interrupts in progress.

53
00:03:51,490 --> 00:03:56,440
Which I shall keep over here, I'll keep at the top over here, we have this global variable called

54
00:03:56,830 --> 00:03:58,240
IREX in progress.

55
00:03:58,270 --> 00:03:58,660
OK.

56
00:03:59,870 --> 00:04:07,360
Right, but what from a hardware perspective or were you at hardware perspective, we start Erich's

57
00:04:08,030 --> 00:04:14,180
by writing, by setting a particular bit in the control register, one too high, and this hexadecimal

58
00:04:14,180 --> 00:04:16,230
value corresponds to setting that bit.

59
00:04:16,640 --> 00:04:21,560
And again, if you want to learn how to write bedmate or drivers, there's a and have at least three

60
00:04:21,560 --> 00:04:22,690
courses just for that.

61
00:04:23,300 --> 00:04:25,100
So we just add this.

62
00:04:25,130 --> 00:04:29,090
This line here would enable interrupts mode for us.

63
00:04:29,420 --> 00:04:33,380
And once we've been able to interrupt mode, we have to set the interrupt priority.

64
00:04:34,330 --> 00:04:41,070
So this is different from our top priority, so we said it priority to priority of six in the Novik

65
00:04:41,380 --> 00:04:43,810
and then we are unable to interrupt to request.

66
00:04:44,950 --> 00:04:48,580
So the name of the incorrupt is used that to I arguin.

67
00:04:49,060 --> 00:04:50,350
OK, so that's it.

68
00:04:50,360 --> 00:04:52,940
That's the short explanation for this.

69
00:04:54,160 --> 00:04:56,460
So once we have this, we go ahead.

70
00:04:56,800 --> 00:05:02,410
And also I should point out that the interrupt, just like our.

71
00:05:04,600 --> 00:05:10,240
Just like our software time is interrupts how the callback function and what this means is.

72
00:05:11,270 --> 00:05:15,200
It has a function, though, to execute when that particular interrupts occurs.

73
00:05:16,680 --> 00:05:22,890
We saw in our software time is that we had to create Kobuk functions for them such that when there is

74
00:05:22,890 --> 00:05:26,400
a timeout, the content of the particular function will be executed.

75
00:05:26,820 --> 00:05:30,350
Is the same for interrupt interrupt require callback functions.

76
00:05:30,570 --> 00:05:33,540
In fact, that is the only way you make use of the interrupt.

77
00:05:34,270 --> 00:05:40,470
The point of the interrupt is that when something occurs, you want something, an action to be taken.

78
00:05:40,470 --> 00:05:44,610
That action that you want to be taken is placed in what we call the callback function.

79
00:05:45,090 --> 00:05:49,970
So we going to have a callback function and the callback function here.

80
00:05:50,010 --> 00:05:51,360
We don't just give it a name.

81
00:05:51,360 --> 00:05:56,670
The name is defined in something known as the vector or table, and you can find the vector table in

82
00:05:56,670 --> 00:06:02,180
the dots for the start up dots file of the project of every project.

83
00:06:02,400 --> 00:06:09,240
So the callback function of our user to as written as use out to underscore our cue handler.

84
00:06:09,840 --> 00:06:16,380
The callback function is also known as the IQ handler, and the reason for that is as the entraps request

85
00:06:16,380 --> 00:06:16,790
handler.

86
00:06:17,310 --> 00:06:24,180
So it's called either the interrupts callback function, the interrupt request handler or the interrupt

87
00:06:24,180 --> 00:06:25,010
service routine.

88
00:06:25,020 --> 00:06:28,280
You can also call it the guess are right.

89
00:06:28,290 --> 00:06:29,400
These are bedmate or.

90
00:06:31,230 --> 00:06:31,840
Concepts.

91
00:06:32,850 --> 00:06:39,750
OK, so there'll be a callback function here and what we place in this function is what we do is what

92
00:06:39,750 --> 00:06:43,190
we execute when uninterrupted chaos, OK?

93
00:06:43,770 --> 00:06:52,200
OK, so over here, this lesson is unique in that this the first time we are going to show you how to

94
00:06:52,860 --> 00:06:57,630
how we are going to show interaction between how to interrupt.

95
00:06:58,550 --> 00:07:08,120
And our our scheduler right over here, we have to declare a variable newnes higher priority task to

96
00:07:08,120 --> 00:07:15,930
be walking in free ARTUS whenever you enter and interrupt service routine or an interrupt request handler

97
00:07:16,010 --> 00:07:16,880
and you exit.

98
00:07:17,960 --> 00:07:24,560
You have the option to indicate whether you want a higher priority task to be woken up, so if we had

99
00:07:24,560 --> 00:07:32,030
multiple tasks in our system currently coming out of the incorrupt service routine, we can see that

100
00:07:32,360 --> 00:07:37,320
when you come out, wake up the highest priority task in the secular.

101
00:07:38,550 --> 00:07:41,100
This means don't go and continue where you left off.

102
00:07:41,130 --> 00:07:46,200
It could be that you were running a lower priority task before you entered the interrupt service routine.

103
00:07:47,080 --> 00:07:52,870
But we can see when you come out of the interrupt service routine, don't continue running your lower

104
00:07:52,870 --> 00:07:56,170
priority task, just wake up the highest priority task you have.

105
00:07:57,130 --> 00:07:57,550
Right.

106
00:07:57,870 --> 00:08:03,800
And the reason I'm saying come out is that you have to remember our process, all this one.

107
00:08:04,630 --> 00:08:10,480
So although we said we have a real time system and we're running in parallel, we run in multiple tasks

108
00:08:10,480 --> 00:08:11,270
in parallel.

109
00:08:11,410 --> 00:08:12,630
That is not quite true.

110
00:08:13,210 --> 00:08:20,920
What is happening is that each each task is given some time on the Processo and then after the time

111
00:08:21,070 --> 00:08:28,000
is exhausted, the task is taken off and a new one is brought very quickly, is so quick that we think

112
00:08:28,000 --> 00:08:29,460
it's all happening in parallel.

113
00:08:29,830 --> 00:08:34,870
So Wendy interrupts your case, the interrupt service routine, when the interrupt service routine is

114
00:08:34,870 --> 00:08:40,120
being executed, what would happen is that the process or will be given to the interrupt service routine.

115
00:08:40,420 --> 00:08:43,720
So the tasks in our scheduler wouldn't have any process or time.

116
00:08:44,140 --> 00:08:49,060
So it will be after our interrupt service routine has finished in the process so that you go back to

117
00:08:49,060 --> 00:08:53,740
our checklist tasks and then to continue so we would see how that would go.

118
00:08:54,560 --> 00:08:57,150
So we said, OK, we set in this to force.

119
00:08:57,190 --> 00:09:01,750
We start by declaring it and set it to force and then we go into.

120
00:09:03,720 --> 00:09:05,290
Check our status register.

121
00:09:05,370 --> 00:09:08,380
We're not Poulan, we simply checking our status register.

122
00:09:08,730 --> 00:09:14,480
OK, over here, you wouldn't find a while loop to wait for a character to.

123
00:09:14,540 --> 00:09:22,710
OK, so we say we simply say if status register sets, meaning if there is new data, then we want to

124
00:09:22,710 --> 00:09:27,960
take this story in a in a temporary variable like this.

125
00:09:28,800 --> 00:09:35,900
And then we would see if irex in progress over here, our ARITZ.

126
00:09:35,970 --> 00:09:42,040
If we see if IREX in progress, then we want to send this to the queue.

127
00:09:43,290 --> 00:09:47,730
The new data and this is the key part you see over here.

128
00:09:47,760 --> 00:09:56,670
I'm using the version of the function excuse and from ESR in Free Artus, you'd never use a function

129
00:09:56,670 --> 00:10:01,020
that hasn't got Isar at the end in the Isar.

130
00:10:01,650 --> 00:10:02,940
You have to keep this in mind.

131
00:10:04,110 --> 00:10:10,350
All functions, functions that we can function so we can use in Iosava, which means interrupt service

132
00:10:10,350 --> 00:10:10,830
routine.

133
00:10:11,460 --> 00:10:18,680
Daris, this is our version so we know we have our excuse function, our standard excuse in function.

134
00:10:19,110 --> 00:10:23,070
This is that the one that we are allowed to use and interrupt service routine.

135
00:10:23,400 --> 00:10:25,530
So is quote from ESR at the end.

136
00:10:26,460 --> 00:10:32,370
So over here, this is the handler of the Q we want to send to this is the value we want to send.

137
00:10:32,910 --> 00:10:40,020
And then over here we are indicating whether we want to we want to wake up a higher priority task or

138
00:10:40,020 --> 00:10:40,380
not.

139
00:10:41,810 --> 00:10:43,610
So over here, we are passing this very.

140
00:10:43,970 --> 00:10:49,910
We said it's a higher priority task walking we passing this year, we have to indicate that if we want

141
00:10:49,910 --> 00:10:57,440
to use this, we've started to focus, OK, once we are done over here after this, the data is going

142
00:10:57,440 --> 00:10:58,640
to be in our queue.

143
00:10:58,910 --> 00:10:59,320
Right.

144
00:10:59,600 --> 00:11:03,040
We have to use the process or we call the function.

145
00:11:03,070 --> 00:11:06,180
Porti yield from ISO Yudin means letting go.

146
00:11:06,200 --> 00:11:08,870
The process yield is like give up.

147
00:11:09,590 --> 00:11:10,040
Right?

148
00:11:10,230 --> 00:11:16,890
So we use the process or from Isar and we pass X higher priority task walking here as argument.

149
00:11:16,940 --> 00:11:17,390
OK.

150
00:11:19,530 --> 00:11:22,520
So I don't know if I explain this bit properly.

151
00:11:23,490 --> 00:11:25,150
The only confusing bit to be here.

152
00:11:25,200 --> 00:11:28,530
Over here we are saying don't wake up a higher priority task.

153
00:11:28,800 --> 00:11:31,590
Basically, that is why we have police force here.

154
00:11:31,830 --> 00:11:36,210
If we want to wake up a higher priority task, we can simply sit through here.

155
00:11:37,140 --> 00:11:44,310
But this the reason, uh, this is not quite relevant here is we have a single task here and it's got

156
00:11:44,310 --> 00:11:45,080
one priority.

157
00:11:45,450 --> 00:11:52,080
So over here we are saying, OK, when you come out of the interrupt service routine, if we had multiple

158
00:11:52,080 --> 00:11:59,570
tasks and one of them, one of them is blocked Wigdor one up and continue from the higher priority task.

159
00:11:59,820 --> 00:12:01,590
But over here, we are seeing force.

160
00:12:03,490 --> 00:12:12,160
Right, OK, so I think I may have spelt it differently, preforms is capital letters.

161
00:12:12,700 --> 00:12:16,360
OK, so we setting this to force.

162
00:12:17,140 --> 00:12:21,580
So actually I can simply pass false here and pass false here.

163
00:12:22,180 --> 00:12:27,430
So we have to indicate what form is or do we want to wake up a high priority task.

164
00:12:27,460 --> 00:12:28,540
We still say in force.

165
00:12:28,790 --> 00:12:30,480
OK, right.

166
00:12:31,240 --> 00:12:32,290
If you don't get this.

167
00:12:34,000 --> 00:12:35,410
Leave it in the question and answer this.

168
00:12:36,580 --> 00:12:41,500
We do not want to wake up from a higher priority task, although it makes no difference in this project

169
00:12:41,500 --> 00:12:42,820
because there's a single task.

170
00:12:42,970 --> 00:12:44,080
So we're looking good.

171
00:12:44,380 --> 00:12:48,190
No, we have to start to interrupt this function here.

172
00:12:49,380 --> 00:12:51,270
We have to call it somewhere.

173
00:12:53,070 --> 00:12:58,830
And also our you at our function, remember, in our previous project, we called it in our previous

174
00:12:58,830 --> 00:13:01,170
task, the pool Ewart's task.

175
00:13:02,890 --> 00:13:10,900
Because that task is no longer here, we will call that in our hands task, so our task first initialize

176
00:13:10,900 --> 00:13:15,940
the U at our X and then it would start the IREX interrupt.

177
00:13:16,570 --> 00:13:24,600
So overseeing our handler task will call these to you in initialised to you or use.

178
00:13:25,150 --> 00:13:31,990
And the reason why it is called USA is because the model is actually universal Synchronoss asynchronous

179
00:13:31,990 --> 00:13:37,780
receiver transmitter, but because we are using just the asynchronous bits we say you are not without.

180
00:13:37,810 --> 00:13:38,200
Yes.

181
00:13:38,210 --> 00:13:41,110
So I'm using the two words interchangeably.

182
00:13:42,040 --> 00:13:45,000
So we initialize the what's our X?

183
00:13:45,010 --> 00:13:50,440
And then we start IREX interrupt, OK, and there's nothing more to do here.

184
00:13:50,440 --> 00:13:56,200
We can just we need not put a function prototype out at all because this function is defined above this

185
00:13:56,200 --> 00:13:57,280
one that requires it.

186
00:13:57,890 --> 00:13:58,330
OK.

187
00:14:00,210 --> 00:14:01,940
So let's build and see what we've got.

188
00:14:03,830 --> 00:14:05,180
I'll click over here to build.

189
00:14:08,210 --> 00:14:09,230
We've got no notario.

190
00:14:10,480 --> 00:14:11,020
And.

191
00:14:12,420 --> 00:14:17,760
OK, I'm building the wrong one, it appears we're going to minimize this, this is our new one.

192
00:14:18,210 --> 00:14:19,800
Twenty six click to build.

193
00:14:21,570 --> 00:14:23,970
OK, we have a number of errors.

194
00:14:24,410 --> 00:14:25,990
OK, there's a difference in the spelling.

195
00:14:26,490 --> 00:14:27,900
I'm going to go to.

196
00:14:30,870 --> 00:14:35,540
Oh, are you to see fall over here and grab the function?

197
00:14:36,550 --> 00:14:40,180
This is how we split it here, I reckon it used to.

198
00:14:40,180 --> 00:14:41,350
You are in it.

199
00:14:41,500 --> 00:14:41,910
Okay.

200
00:14:43,980 --> 00:14:47,520
So this the spelling of the function, OK, let's click to build.

201
00:14:49,350 --> 00:14:52,050
No error, no warning, right, click.

202
00:14:53,320 --> 00:15:00,250
We're going to see debug us estimate 30 to double click number twenty six over here, I say, OK, over

203
00:15:00,250 --> 00:15:00,550
here.

204
00:15:04,160 --> 00:15:05,450
And then click to switch.

205
00:15:07,440 --> 00:15:09,570
And I'm going to open this.

206
00:15:10,640 --> 00:15:16,700
This is our realtor going to click to run and then going to press a key.

207
00:15:16,730 --> 00:15:22,970
I just pressed it on my keyboard with a cop's look on going to press capital D, capital B.

208
00:15:22,970 --> 00:15:23,840
Capital G.

209
00:15:23,840 --> 00:15:24,680
Capital T.

210
00:15:25,650 --> 00:15:33,810
And I'm going to press the number eight and then the number five and number six, OK, so it's working

211
00:15:33,810 --> 00:15:35,630
as expected, right?

212
00:15:35,730 --> 00:15:38,750
So this is how we can use enwrapped.

213
00:15:38,760 --> 00:15:45,510
Remember, the take away from this lesson is that if you want to use any function in the interrupt service

214
00:15:45,510 --> 00:15:50,770
routine, the particular free Arktos function has to end with from ESR.

215
00:15:51,390 --> 00:15:58,160
OK, and this here is used to indicate whether we want to wake up a higher priority task when the processor

216
00:15:58,170 --> 00:16:03,900
is given back to our scheduler, because when we are executing this hour hour to stretch, that hasn't

217
00:16:03,900 --> 00:16:04,460
got a process.

218
00:16:04,460 --> 00:16:07,530
So I will interrupt service fruitiness using it.

219
00:16:07,830 --> 00:16:08,670
When it's done.

220
00:16:08,680 --> 00:16:09,960
It would have to say, OK.

221
00:16:11,250 --> 00:16:17,640
We would have to decide whether we want to go to a higher priority task or we want to continue where

222
00:16:17,640 --> 00:16:20,390
we left off, even if that task had a lower priority.

223
00:16:20,700 --> 00:16:25,800
So that's what this parameter is for, is all there is for this lesson.

224
00:16:25,800 --> 00:16:26,710
And I'll see you later.

225
00:16:26,730 --> 00:16:27,510
Have a nice day.
