1
00:00:00,460 --> 00:00:07,390
Control, transfer, control, transfer in USB is a bit different from the other transfer types we already

2
00:00:07,390 --> 00:00:08,050
explained.

3
00:00:08,960 --> 00:00:16,730
Every one of the other TransFair types we talked about consists of only a single transaction.

4
00:00:17,680 --> 00:00:25,420
But control, transfer or every control, every every controlled TransFair consists of multiple USV

5
00:00:25,420 --> 00:00:31,270
transactions, and these transactions are divided into three stages.

6
00:00:32,080 --> 00:00:35,290
So let's now talk about these three stages.

7
00:00:35,980 --> 00:00:38,860
But before starting, let me tell you this.

8
00:00:39,280 --> 00:00:45,140
Gray packets are packets sent by the host and white packets are packets sent by the device.

9
00:00:45,610 --> 00:00:54,130
So let's start explaining the first stage in every single control transfer setup stage setup stage is

10
00:00:54,130 --> 00:01:03,460
always the first stage in all controlled transfers and set up stage consists of one single USB transaction

11
00:01:03,640 --> 00:01:09,970
and just it's a normal transaction, which consists of three packets as we see here, token packet,

12
00:01:09,970 --> 00:01:12,370
the data packet, then handshake packet.

13
00:01:13,210 --> 00:01:22,210
The token packet in this setup stage is a setup token and this is the first time we see setup token

14
00:01:22,210 --> 00:01:22,870
inus.

15
00:01:23,700 --> 00:01:30,660
And this is probably the only place where you will see a set up tour continues and as and if you remember,

16
00:01:30,660 --> 00:01:35,820
we already said that set up Tolkan is very similar to out Tolkan.

17
00:01:36,180 --> 00:01:41,270
So it just indicates that the host will be sending some data to the device.

18
00:01:41,460 --> 00:01:43,290
And this is exactly what we see here.

19
00:01:43,300 --> 00:01:49,920
And when the device receives all the data successfully, it acknowledged that by sending acknowledged

20
00:01:49,920 --> 00:01:50,590
handshake.

21
00:01:50,790 --> 00:01:57,660
So again, the first stage in every single control transfer is set up stage and set up stage consists

22
00:01:57,660 --> 00:02:00,830
of only one single USB transaction.

23
00:02:00,870 --> 00:02:09,030
It's a set up transaction because the token of this transaction is set up token and this setup token

24
00:02:09,030 --> 00:02:13,370
tells the device that the host will be sending some special data.

25
00:02:13,380 --> 00:02:15,790
And here this sentence is very important.

26
00:02:16,140 --> 00:02:17,400
Let me repeat this again.

27
00:02:17,490 --> 00:02:27,000
Set up token, unlike out token setup, Token tells the device that the host will be sending some special

28
00:02:27,000 --> 00:02:33,260
data or let's say some special pre structured data in the data packet.

29
00:02:34,530 --> 00:02:39,890
And this special pre structured data is called USPI request.

30
00:02:40,050 --> 00:02:48,140
In simple words, set up stage is responsible for sending a USB request from the host to the device.

31
00:02:48,150 --> 00:02:55,110
And this request, or let's say that the details of this request exist inside the data packet of the

32
00:02:55,110 --> 00:02:56,030
setup stage.

33
00:02:56,310 --> 00:03:04,020
And this request may be asking the device to receive some data from the host or it may be asking the

34
00:03:04,020 --> 00:03:06,890
device to send some data to the host.

35
00:03:06,900 --> 00:03:09,390
It depends on the request itself.

36
00:03:09,420 --> 00:03:17,550
So let me repeat this one last time again, set up stage is the very first stage in every single control

37
00:03:17,550 --> 00:03:18,360
TransFair.

38
00:03:19,360 --> 00:03:27,190
And it consists of one single transaction, and this transaction is a set up transaction because it

39
00:03:27,190 --> 00:03:30,660
begins when the host sends a set up token.

40
00:03:30,820 --> 00:03:37,750
This set token tells the device that in the upcoming data packet, there will be a request coming from

41
00:03:37,750 --> 00:03:38,320
the host.

42
00:03:38,320 --> 00:03:44,250
And this USB request is just let's say it's just normal data, but it's pre structured.

43
00:03:44,260 --> 00:03:48,430
So every single bit of this data means something special.

44
00:03:48,610 --> 00:03:53,230
We will see the structure and details of the important U.S. request soon.

45
00:03:53,260 --> 00:04:01,360
And finally, when the device receives that this request successfully, it acknowledged by sending an

46
00:04:01,390 --> 00:04:03,260
AK hansei packet.

47
00:04:03,370 --> 00:04:04,610
Hopefully this is clear.

48
00:04:04,630 --> 00:04:09,820
Now, just before moving to the next stage of the control transfer.

49
00:04:10,950 --> 00:04:18,580
You probably noticed that I didn't draw or mention nacke and total handshake packets here.

50
00:04:18,600 --> 00:04:26,010
This is simply because USB devices or let's say more accurately from now, add up USB functions are

51
00:04:26,010 --> 00:04:31,470
not allowed to reply to set up tokens by Mac or Stoel handshake.

52
00:04:31,680 --> 00:04:37,920
The device must do its its best to be able to always receive set up tokens.

53
00:04:37,920 --> 00:04:44,400
And if something wrong happened, the device can only ignore what it received without sending any handshake

54
00:04:44,400 --> 00:04:44,850
packet.

55
00:04:45,060 --> 00:04:48,590
This is why I didn't mention Mac and stole packets here.

56
00:04:48,720 --> 00:04:53,910
The second stage in USV Control TransFair is data stage.

57
00:04:54,120 --> 00:05:01,980
Data stage is an optional stage, which means it may present in some but not all of controlled transfers.

58
00:05:02,220 --> 00:05:12,630
And if control transfer includes data stage, this data stage may consist of one to multiple USB transactions.

59
00:05:12,900 --> 00:05:20,790
So unlike setup stage, which consists only of a single USB transaction, data stage can consist of

60
00:05:20,790 --> 00:05:22,590
multiple USB transactions.

61
00:05:22,800 --> 00:05:29,190
And if a control transfer has a data stage or not, and how many transactions data stage should have,

62
00:05:29,340 --> 00:05:34,000
that totally depends on the USB requests in the setup stage.

63
00:05:34,200 --> 00:05:42,480
So in simple words, the USB request may be asking the device to send some data to the host, or it

64
00:05:42,480 --> 00:05:45,990
may be telling the device to receive some data from the host.

65
00:05:46,440 --> 00:05:52,440
In such cases, data stage will exist and how many transactions it will include.

66
00:05:52,620 --> 00:05:59,880
This totally depends on how big the data the host when the host wants to send or receive to or from

67
00:05:59,880 --> 00:06:00,520
the device.

68
00:06:01,140 --> 00:06:09,300
So if the host in the USB request in the setup stage is asking the device to send some data to the host,

69
00:06:09,510 --> 00:06:15,240
then the transaction in the data stage will be in data transactions.

70
00:06:16,290 --> 00:06:17,370
So this here.

71
00:06:18,740 --> 00:06:21,680
Because the data will be flowing from the device to the host.

72
00:06:23,960 --> 00:06:32,270
On the other hand, if the host in the U.S. request is requesting the device or is requesting from the

73
00:06:32,270 --> 00:06:40,850
device to receive some some data from the host, then data stage will include out transactions.

74
00:06:41,970 --> 00:06:43,020
Like this here.

75
00:06:44,350 --> 00:06:52,750
So maybe single or multiple out transactions and the same year, maybe one or multiple in transactions.

76
00:06:53,930 --> 00:07:01,970
This totally depends on the U.S. request itself and on the size of data that will be sent or received,

77
00:07:02,150 --> 00:07:08,360
and here, as you can see this in transaction or this transaction or.

78
00:07:09,400 --> 00:07:16,270
Just very normal in and all transactions, just like what we already saw before in the other transfer

79
00:07:16,270 --> 00:07:16,740
types.

80
00:07:16,960 --> 00:07:23,380
So in the data stage, when the host wants to receive some data from the device, it sends an Intercon.

81
00:07:23,680 --> 00:07:31,030
Then the device starts sending the data and the host acknowledged receiving the data when everything

82
00:07:31,030 --> 00:07:33,370
is received or was received successfully.

83
00:07:34,310 --> 00:07:41,570
And here the device has again the possibility to reply by Nacke or total handshake packets, and similarly,

84
00:07:41,570 --> 00:07:49,910
if the host wants the device to receive some data, it sends in the data stage and out packet or outtalking,

85
00:07:49,920 --> 00:07:50,480
let's say.

86
00:07:51,140 --> 00:07:56,460
Then it sends the data and the device acknowledges receiving the data.

87
00:07:56,480 --> 00:08:02,750
If everything was received successfully, so very normal in or out transactions.

88
00:08:02,990 --> 00:08:04,340
Let me remind you again here.

89
00:08:04,340 --> 00:08:07,310
I'm just showing you one transaction in both cases.

90
00:08:07,310 --> 00:08:14,840
So one in transaction in case the host requests receiving some data and one transaction in case the

91
00:08:14,840 --> 00:08:18,820
host is requesting the device to receive some data.

92
00:08:19,370 --> 00:08:25,700
But the stage may include not only one transaction, but multiple transactions.

93
00:08:25,940 --> 00:08:34,250
So we can have multiple in transactions in the data stage or multiple out transactions in that data

94
00:08:34,250 --> 00:08:34,670
stage.

95
00:08:35,120 --> 00:08:42,560
This is, of course, if data packet is too small to send the whole data in only a single packet, then

96
00:08:42,560 --> 00:08:45,690
sending multiple transactions is required.

97
00:08:46,190 --> 00:08:51,800
And finally, the last stage in TransFair is status stage.

98
00:08:51,950 --> 00:08:59,960
Status stage includes only one single USB transaction, and this transaction here in the status stage

99
00:09:00,290 --> 00:09:04,100
is always the opposite of the data stage.

100
00:09:04,130 --> 00:09:05,520
What does this mean?

101
00:09:06,020 --> 00:09:11,480
This means if the data in the data stage was sent in the indirection.

102
00:09:12,750 --> 00:09:20,460
Then the stage, the stage will be an outdoor transaction and similarly, if the direction of the data

103
00:09:20,460 --> 00:09:23,040
in the data stage was out.

104
00:09:24,100 --> 00:09:32,740
Then the status stage will be and in transaction, and this makes total sense because here if the host

105
00:09:32,740 --> 00:09:36,910
in the setup stage requested some data from the device.

106
00:09:38,220 --> 00:09:43,110
Then the device will be sending some data in the data stage.

107
00:09:44,140 --> 00:09:50,400
And when the host receives the whole data, it will tell that by sending the opposite transaction,

108
00:09:50,590 --> 00:09:58,390
so the transactions in that data stage where in transactions then the host will finish the whole control

109
00:09:58,390 --> 00:10:01,780
transfer by sending an out transaction.

110
00:10:02,700 --> 00:10:09,720
And similarly, if in the setup stage, if the host requested the device to receive some data, then

111
00:10:09,720 --> 00:10:13,140
the host will be sending the data in the data stage.

112
00:10:13,830 --> 00:10:19,710
And when the host finishes sending the whole data, it will tell the device that the whole data has

113
00:10:19,710 --> 00:10:24,900
been sent by sending the opposite transaction, which is an in transaction.

114
00:10:25,740 --> 00:10:33,900
And the data packet in the state of stage has no data in it, it's a zero Leontes data packet, which

115
00:10:33,900 --> 00:10:35,700
means it has no payload.

116
00:10:35,940 --> 00:10:43,290
If the transaction in the state stage was an out transaction or in transaction, it doesn't matter.

117
00:10:43,560 --> 00:10:46,950
Data packet in status stage includes no data.

118
00:10:47,790 --> 00:10:56,280
It has no payload because it's just a signal to tell the host or the device that control transfer has

119
00:10:56,280 --> 00:10:57,150
just finished.

120
00:10:58,050 --> 00:11:05,910
Hopefully, you understand now USB control transfers, because this is a very important topic here and

121
00:11:05,910 --> 00:11:12,300
we will spend a lot of time in implementing this principle and this figure here or the information or

122
00:11:12,300 --> 00:11:14,920
the mechanism you see here in this figure.

123
00:11:15,540 --> 00:11:18,680
So please try to understand it as good as possible.

