-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlueTooth.v
58 lines (57 loc) · 1.22 KB
/
BlueTooth.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module BlueTooth_command(
input clk,
input rst,
input RXD,
output reg [15: 0] volume,
output reg [2: 0] current
);
parameter DELAY_TIME = 5000000;
integer cnt = 0;
wire flag;
wire [7: 0] data;
uart_deal ud(.clk(clk), .rst(rst), .RXD(RXD), .uart_state(flag), .DATA(data));
// the phone actually send message like B100 to let data keep 00 after change the sign.
always @ (posedge clk) begin
if(cnt==DELAY_TIME)
case(data)
8'hB1: begin
current <= (current==0) ? 2: current-1;
cnt <= 0;
end
8'hB2: begin
current <= (current==3) ? 0: current+1;
cnt <= 0;
end
8'hB3: begin
volume <= (volume==0) ? 0: (volume - 16'h1010);
cnt <= 0;
end
8'hB4: begin
volume <= (volume==16'hF0F0) ? 16'hF0F0 : (volume + 16'h1010);
cnt <= 0;
end
8'h0: begin
current<= 0;
cnt <= 0;
end
8'h1: begin
current <= 1;
cnt <= 0;
end
8'h2: begin
current <= 2;
cnt <= 0;
end
8'h3: begin
current <= 3;
cnt <= 0;
end
8'h4: begin
current <= 4;
cnt <= 0;
end
default: ;
endcase
else cnt <= cnt+1;
end
endmodule