1
00:00:00,700 --> 00:00:01,920
Hello, welcome back.

2
00:00:02,320 --> 00:00:10,270
And this lesson, we going to see how to work with task notifications, what I'm going to do is make

3
00:00:10,270 --> 00:00:12,580
a copy of our drivers project.

4
00:00:12,580 --> 00:00:15,760
Some drivers, this one here, I'll make a copy of it.

5
00:00:16,390 --> 00:00:19,630
I'll say copy over here and paste over here.

6
00:00:21,840 --> 00:00:27,270
And this becomes 31 who call this task notifications.

7
00:00:32,420 --> 00:00:33,080
Like this.

8
00:00:35,680 --> 00:00:37,390
OK, I'm going to expand.

9
00:00:41,780 --> 00:00:46,830
Open the main door, see, fall over here, OK, this is what we have.

10
00:00:46,850 --> 00:00:51,500
This is our driver's fuda, our some driver's projects over here.

11
00:00:51,510 --> 00:00:55,520
We're going to use our external interrupts driver that we created yesterday.

12
00:00:55,850 --> 00:01:02,390
And what that is, is basically set in our PC 13 as an input interrupt such that when we press the PC

13
00:01:02,390 --> 00:01:10,040
13, we uninterrupted is generated and we can, you know, implement or run a piece of code in the interrupt

14
00:01:10,040 --> 00:01:10,980
request handler.

15
00:01:11,620 --> 00:01:14,920
OK, so this project, we don't need this.

16
00:01:14,950 --> 00:01:16,630
I'm going to clean this bit from it.

17
00:01:17,450 --> 00:01:19,970
So a project currently has no ARTUS.

18
00:01:21,590 --> 00:01:24,230
We don't need this as well, so I'll clean this.

19
00:01:24,350 --> 00:01:32,990
All we have is our inclusions and then we've initialized our UTX.

20
00:01:33,740 --> 00:01:41,130
OK, so to use notifications we need to enable notifications in our Simms's.

21
00:01:43,040 --> 00:01:45,050
The CMC is always the each file over here.

22
00:01:45,050 --> 00:01:49,940
Right click go to open declarations and you come down here.

23
00:01:50,360 --> 00:01:50,890
Over here.

24
00:01:50,900 --> 00:01:54,110
Currently we have just Tosk dot h included.

25
00:01:55,130 --> 00:01:56,360
Um not here.

26
00:01:56,360 --> 00:01:57,110
Sorry about that.

27
00:01:57,110 --> 00:01:57,740
Goodness.

28
00:01:57,740 --> 00:01:58,880
I'm losing my mind.

29
00:02:00,700 --> 00:02:07,160
We have to include notification by going to our free ARTUS configured HFA.

30
00:02:07,450 --> 00:02:09,960
Sorry, um, look at that.

31
00:02:09,970 --> 00:02:13,120
I was on a roll just talking about something else.

32
00:02:13,600 --> 00:02:16,410
OK, this fall here, free artist configurator.

33
00:02:16,810 --> 00:02:20,290
So just like we included the other artist component.

34
00:02:21,210 --> 00:02:31,470
We can search for notification or do control over here and such notification, it's not here, so I'm

35
00:02:31,470 --> 00:02:32,590
going to include it.

36
00:02:33,690 --> 00:02:36,750
So what we want to do is type.

37
00:02:39,440 --> 00:02:45,950
Define config task notifications, and then we said this to one, this will allow us to be able to use

38
00:02:45,950 --> 00:02:49,610
notifications controls to save come back to me not see.

39
00:02:51,020 --> 00:02:53,070
OK, we're going to have one task.

40
00:02:53,120 --> 00:02:54,500
This is the handler task.

41
00:02:54,710 --> 00:02:58,800
And then we're going to have our interrupted request handler.

42
00:02:59,720 --> 00:03:01,070
So what are we going to do?

43
00:03:01,190 --> 00:03:05,690
Is we going to initialize PC 13 for interruptive?

44
00:03:05,690 --> 00:03:09,290
So I copy this function and then I'll come over here.

45
00:03:11,400 --> 00:03:20,820
And then I call this function here, so P.S. 13 is enabled in its interrupt mode, and because it's

46
00:03:20,820 --> 00:03:26,190
interrupt, we've got to define the interrupt request handler or the interrupted service routine.

47
00:03:26,670 --> 00:03:36,030
The interrupt request handler for P.S. 13 is called XDA 15 dash 10 I.Q. It has to be written like this.

48
00:03:36,030 --> 00:03:38,000
This is its name in the vector table.

49
00:03:38,220 --> 00:03:46,320
And the reason it's a 15 dash 10 is because interrupts request external interrupts 10 through 15.

50
00:03:46,320 --> 00:03:47,640
Share the same interrupt.

51
00:03:47,970 --> 00:03:49,020
Request a line.

52
00:03:49,050 --> 00:03:52,610
That is why we're doing an extra 10 dash 15 over here.

53
00:03:52,770 --> 00:04:00,150
If we had if we were using less European such as 10, 11, 12, 13, then in here we would have an if

54
00:04:00,150 --> 00:04:07,350
close or we'd be using it to check whether the interrupt is from 10, 11, 12, 13, 14 or 15.

55
00:04:07,650 --> 00:04:13,590
But because we have just one, which is from 13, we need not check the source of it.

56
00:04:14,010 --> 00:04:14,520
In a way.

57
00:04:14,730 --> 00:04:18,380
Like I said, this is bare metal stuff, so I wouldn't go deeper into this.

58
00:04:18,690 --> 00:04:26,670
So what we have so far with initialize our P.S. 13 as an input interrupts and then we have the empty

59
00:04:26,670 --> 00:04:28,290
interrupt request handler here.

60
00:04:28,860 --> 00:04:34,890
OK, we going to create a task, a single task known as the handler task.

61
00:04:34,890 --> 00:04:39,180
And we can give it any priority because it is the only task in our system.

62
00:04:39,670 --> 00:04:44,730
So currently the name of this task function is going to be on the task.

63
00:04:45,000 --> 00:04:53,130
The task is called handler task and we given it a stack size of 128, which is equal to five one two

64
00:04:53,130 --> 00:04:53,550
bytes.

65
00:04:54,300 --> 00:05:00,210
OK, so this stack size volume is what we have here and we're given a priority of three.

66
00:05:00,210 --> 00:05:05,880
You can give a priority of whatever you want because it's the only task here and we're going to store

67
00:05:05,880 --> 00:05:07,680
the handle of this task.

68
00:05:09,610 --> 00:05:14,380
In a variable here, so we have this variable Hondo task.

69
00:05:16,650 --> 00:05:22,410
So once the task is created, the handle of the task will be stored in this variable here.

70
00:05:22,620 --> 00:05:24,240
OK, looking good so far.

71
00:05:25,260 --> 00:05:33,510
Next, we going to start our scheduler using our V task search that starts function once that is done.

72
00:05:33,540 --> 00:05:40,420
We going to come over here and implement the task function of our handler task.

73
00:05:41,010 --> 00:05:44,010
So we say, well, one in here.

74
00:05:46,690 --> 00:05:48,790
Open and close, OK?

75
00:05:49,270 --> 00:05:56,670
And over here, we're going to define a delay amount, you're going to define a hundred times delay.

76
00:05:56,890 --> 00:06:03,670
So I'm going to say Purdum's to takes one hundred and I'm going to store the value in this variable

77
00:06:03,670 --> 00:06:05,920
known as X marks expected block time.

78
00:06:06,980 --> 00:06:14,690
OK, so this is our interrupt request handler, when we press our push button, whatever we please in

79
00:06:14,690 --> 00:06:17,990
this function is going to be executed.

80
00:06:18,740 --> 00:06:24,590
OK, what we want to do is whenever the push button is pressed, we want to send a notification to our

81
00:06:24,590 --> 00:06:25,880
handler task over here.

82
00:06:27,380 --> 00:06:35,750
OK, so I'm going to start by defining X higher priority task to be walking or define this variable

83
00:06:35,760 --> 00:06:37,480
and we can set it to false.

84
00:06:38,210 --> 00:06:40,040
We don't have any higher priority tasks.

85
00:06:40,040 --> 00:06:41,060
We want to wake up.

86
00:06:41,060 --> 00:06:47,480
We have a single task and I'll leave it up to you to run these experiments with multiple tasks and CD

87
00:06:47,510 --> 00:06:55,250
effect of setting higher priority task, walking to true or false in a mortarboard or in a multi task

88
00:06:56,270 --> 00:06:58,370
system with different priorities.

89
00:07:00,450 --> 00:07:09,810
OK, so then what we do is what we want to happen here, we want to send a notification to our to ask,

90
00:07:10,110 --> 00:07:16,280
so we use the V task, notify give from Isar function to send a notification.

91
00:07:16,830 --> 00:07:20,910
So this function takes the task.

92
00:07:21,780 --> 00:07:26,550
The task you want to send a notification to takes the handle of that task as the first argument.

93
00:07:26,760 --> 00:07:29,790
And a second argument is the higher priority task.

94
00:07:29,790 --> 00:07:30,210
Wolken.

95
00:07:31,770 --> 00:07:38,370
And once that is done for our interruptive, we need to clear the interruptive flag right to recommit.

96
00:07:38,880 --> 00:07:44,110
So to clear the flag, we simply write this hexadecimal value in the P r register.

97
00:07:44,640 --> 00:07:45,120
Okay.

98
00:07:45,990 --> 00:07:49,280
Once that's done, we're going to request a context switch.

99
00:07:49,770 --> 00:07:53,150
So the interrupt request handler will tell the process.

100
00:07:53,220 --> 00:08:00,390
Okay, I'm done during the process or so we use the port from ESADE, just like we saw in our other

101
00:08:00,390 --> 00:08:03,900
examples where we have where we are entraps request handles.

102
00:08:04,140 --> 00:08:09,960
So party from ESR and then we pass X higher priority task walking us arguments here.

103
00:08:11,470 --> 00:08:13,080
So this will send a notification.

104
00:08:13,920 --> 00:08:14,450
OK.

105
00:08:17,030 --> 00:08:23,780
So once that is done, we would go to our handler to ask to see if a notification.

106
00:08:25,180 --> 00:08:35,920
Was received in our handler task over here, come and call the take notification function and dysfunction

107
00:08:35,920 --> 00:08:36,330
here.

108
00:08:37,870 --> 00:08:38,790
Come over here.

109
00:08:38,950 --> 00:08:44,200
We see this the name of the function you task, notify, take.

110
00:08:48,900 --> 00:08:57,330
This function takes two arguments, the first argument here is the is the Xolair count on exit.

111
00:08:58,750 --> 00:09:02,980
As you can see over here, it's called a clear count on exit and of course, the next argument is that

112
00:09:02,980 --> 00:09:03,520
block time.

113
00:09:03,700 --> 00:09:06,590
So this one here, clear count on exit.

114
00:09:06,670 --> 00:09:15,340
If we set it to false, then these are the Arktos notification value is decrements it before we exit

115
00:09:15,340 --> 00:09:16,050
this function.

116
00:09:16,420 --> 00:09:17,620
So you can think of this.

117
00:09:17,620 --> 00:09:24,010
This is like account in semaphore being decrements it whenever we take the SEMAFO, if we said is to

118
00:09:24,010 --> 00:09:30,910
force thus the effect we have if we said is to true, it's like a binary semaphore being set to zero

119
00:09:31,210 --> 00:09:34,150
because a binary semaphore can either be one or zero.

120
00:09:34,990 --> 00:09:37,480
OK, so over here we settled into force.

121
00:09:37,760 --> 00:09:38,200
OK.

122
00:09:40,030 --> 00:09:40,440
Right.

123
00:09:41,940 --> 00:09:48,510
So we're going to see if this is not equal to zero, then we want to see want to print something essentially.

124
00:09:50,340 --> 00:09:58,350
When I come over here and print this, we see handler task in event, meaning we've received it.

125
00:09:58,470 --> 00:10:05,520
Essentially what we use this for is to be able if this handler task had an important piece of information,

126
00:10:05,880 --> 00:10:11,150
then it would notify it that it's done its job and then we process further.

127
00:10:11,280 --> 00:10:20,050
Yeah, over here we can see do something and do something we are doing is basically printing this to

128
00:10:20,050 --> 00:10:20,750
the US.

129
00:10:21,840 --> 00:10:29,340
OK, so once this is done, we can have an LST condition here if we want.

130
00:10:34,760 --> 00:10:35,830
Do something as well.

131
00:10:40,350 --> 00:10:49,320
OK, so that is it, we can take our task prototype to the top over here.

132
00:10:51,660 --> 00:10:52,200
And then.

133
00:10:54,360 --> 00:10:57,150
We build and see what we have a click over here to build.

134
00:11:01,220 --> 00:11:02,690
It's built successfully.

135
00:11:05,550 --> 00:11:07,020
All right, click over here.

136
00:11:08,990 --> 00:11:09,590
And then.

137
00:11:11,430 --> 00:11:18,300
Go to debark us ystem thirty two, thirty one, and then OK over here.

138
00:11:22,200 --> 00:11:23,880
And then click the switch over here.

139
00:11:26,880 --> 00:11:28,270
I'll clear what we have here.

140
00:11:28,380 --> 00:11:30,340
We don't need this, actually, so I'll leave it.

141
00:11:31,080 --> 00:11:32,430
I'll bring real time.

142
00:11:35,400 --> 00:11:41,790
I'm going to select this new line mode port over here, I'm going to select the portrait, then I'm

143
00:11:41,790 --> 00:11:43,230
going to select the port.

144
00:11:45,740 --> 00:11:50,360
And then I'm going to open it, then I'm going to minimize this.

145
00:11:55,430 --> 00:12:00,040
And I'm going to click to play over here, OK?

146
00:12:00,110 --> 00:12:03,110
Awkward is running, so I'm going to press the push button.

147
00:12:04,040 --> 00:12:06,070
And as you can see, I press the push button.

148
00:12:06,080 --> 00:12:08,070
It says, let us process an event.

149
00:12:08,300 --> 00:12:11,830
So when I press the interrupt, a case of press again.

150
00:12:12,680 --> 00:12:20,660
I've pressed again, so basically and notification is sent to our handler to ask whenever the push button

151
00:12:20,660 --> 00:12:27,380
is pressed, when a push button is pressed in our interrupts request handler, we say notify the handler

152
00:12:27,380 --> 00:12:27,800
task.

153
00:12:28,850 --> 00:12:34,310
OK, and over here, we just using the push button as an example, this could be you configuring your

154
00:12:34,310 --> 00:12:42,110
ADC to work in interrupt mode such that when there is a new piece of analog data, you can just notify

155
00:12:42,350 --> 00:12:49,700
a function that has your digital signal processing algorithm to process that new piece of data.

156
00:12:49,970 --> 00:12:56,720
Over here, we are using simple examples to explain these complex, powerful features that we have in

157
00:12:56,720 --> 00:12:57,500
the ARTUS.

158
00:12:58,190 --> 00:13:01,340
So this order is for this lesson, and I'll see you later.

159
00:13:01,350 --> 00:13:01,930
Have a nice day.
