Этот вариант работает стабильно. Таймаут перенесли в конец любой передачи, чтобы вывести периферийное устройство в начальное состояние. Линия занята SB_CONTROL_LOWER(1) = '1' - появится в начале передачи и закончится после таймаута.
This commit is contained in:
parent
92fd7969bc
commit
2b055193af
@ -111,6 +111,7 @@ begin
|
|||||||
process(clk) is
|
process(clk) is
|
||||||
variable count : integer range 0 to 255 := 0;
|
variable count : integer range 0 to 255 := 0;
|
||||||
variable halfPeriod : integer range 0 to 255 := 50;
|
variable halfPeriod : integer range 0 to 255 := 50;
|
||||||
|
variable countPause : integer range 0 to 255 := 0;
|
||||||
variable pause : integer range 0 to 255 := 200;
|
variable pause : integer range 0 to 255 := 200;
|
||||||
variable state : integer range 0 to 1 := 1;
|
variable state : integer range 0 to 1 := 1;
|
||||||
variable bitCnt : integer range -1 to 31 := 0;
|
variable bitCnt : integer range -1 to 31 := 0;
|
||||||
@ -123,6 +124,7 @@ begin
|
|||||||
bitCnt := 8;
|
bitCnt := 8;
|
||||||
latch := 0;
|
latch := 0;
|
||||||
resetCRC <= '1';
|
resetCRC <= '1';
|
||||||
|
count := 0;
|
||||||
sbdataout <= '0';
|
sbdataout <= '0';
|
||||||
state := 1;
|
state := 1;
|
||||||
if start = '1' and startPrev = '0' then
|
if start = '1' and startPrev = '0' then
|
||||||
@ -132,30 +134,16 @@ begin
|
|||||||
dataCRC(23 downto 16) <= cmdBuf(7 downto 0);
|
dataCRC(23 downto 16) <= cmdBuf(7 downto 0);
|
||||||
dataToTransmit <= dataBufIn;
|
dataToTransmit <= dataBufIn;
|
||||||
dataCRC(15 downto 0) <= dataBufIn;
|
dataCRC(15 downto 0) <= dataBufIn;
|
||||||
controlBuf(15 downto 2) <= (others => '0');
|
controlBuf(15 downto 0) <= (others => '0');
|
||||||
controlBuf(1) <= '1';
|
|
||||||
controlBuf(0) <= '0';
|
|
||||||
if count < pause then
|
|
||||||
CommunicationState <= Timeout;
|
|
||||||
count := count + 1;
|
|
||||||
else
|
|
||||||
CommunicationState <= TransmitAddress;
|
CommunicationState <= TransmitAddress;
|
||||||
count:= 0;
|
|
||||||
end if;
|
|
||||||
else
|
|
||||||
if count < pause then
|
|
||||||
count := count + 1;
|
|
||||||
controlBuf(1) <= '1';
|
|
||||||
else
|
|
||||||
controlBuf(1) <= '0';
|
|
||||||
end if;
|
|
||||||
end if;
|
end if;
|
||||||
when Timeout =>
|
when Timeout =>
|
||||||
if count < pause then
|
if count < pause then
|
||||||
|
sbclk <= '0';
|
||||||
count := count + 1;
|
count := count + 1;
|
||||||
else
|
else
|
||||||
CommunicationState <= TransmitAddress;
|
controlBuf(1) <= '0';
|
||||||
count:= 0;
|
CommunicationState <= Waiting;
|
||||||
end if;
|
end if;
|
||||||
when TransmitAddress =>
|
when TransmitAddress =>
|
||||||
if bitCnt = -1 then
|
if bitCnt = -1 then
|
||||||
@ -171,6 +159,7 @@ begin
|
|||||||
if count = 0 then
|
if count = 0 then
|
||||||
if latch = 0 then
|
if latch = 0 then
|
||||||
sbdataout <= direction;
|
sbdataout <= direction;
|
||||||
|
controlBuf(1) <= '1';
|
||||||
else
|
else
|
||||||
sbdataout <= addressToTransmit(bitCnt);
|
sbdataout <= addressToTransmit(bitCnt);
|
||||||
end if;
|
end if;
|
||||||
@ -243,8 +232,9 @@ begin
|
|||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
else
|
else
|
||||||
|
--CommunicationState <= Waiting;
|
||||||
count := 0;
|
count := 0;
|
||||||
CommunicationState <= Waiting;
|
CommunicationState <= Timeout;
|
||||||
controlBuf(15) <= '1';
|
controlBuf(15) <= '1';
|
||||||
end if;
|
end if;
|
||||||
when TransmitCheck =>
|
when TransmitCheck =>
|
||||||
@ -255,13 +245,14 @@ begin
|
|||||||
count := count + 1;
|
count := count + 1;
|
||||||
else
|
else
|
||||||
count := 0;
|
count := 0;
|
||||||
state := 0;
|
|
||||||
if sbdatain = '0' then
|
if sbdatain = '0' then
|
||||||
controlBuf(0) <= '1';
|
controlBuf(0) <= '1';
|
||||||
else
|
else
|
||||||
controlBuf(14) <= '1';
|
controlBuf(14) <= '1';
|
||||||
end if;
|
end if;
|
||||||
CommunicationState <= Waiting;
|
--CommunicationState <= Waiting;
|
||||||
|
count := 0;
|
||||||
|
CommunicationState <= Timeout;
|
||||||
end if;
|
end if;
|
||||||
when ReceiveData =>
|
when ReceiveData =>
|
||||||
if bitCnt = -1 then
|
if bitCnt = -1 then
|
||||||
@ -329,11 +320,10 @@ begin
|
|||||||
else
|
else
|
||||||
controlBuf(12) <= '1';
|
controlBuf(12) <= '1';
|
||||||
end if;
|
end if;
|
||||||
|
--CommunicationState <= Waiting;
|
||||||
count := 0;
|
count := 0;
|
||||||
CommunicationState <= Waiting;
|
CommunicationState <= Timeout;
|
||||||
when others =>
|
when others =>
|
||||||
count := 0;
|
|
||||||
CommunicationState <= Waiting;
|
|
||||||
end case;
|
end case;
|
||||||
startPrev <= start;
|
startPrev <= start;
|
||||||
end if;
|
end if;
|
||||||
|
Loading…
Reference in New Issue
Block a user