signal spi_sdo : std_logic;
signal spi_sdi : std_logic;
- signal word_count : integer range 0 to BITS-1;
+ signal word_count : integer range 0 to 31 := 1;
signal bit_count : integer range 0 to BITS-1;
signal time_count : integer range 0 to 1023;
signal readback : std_logic_vector(31 downto 0);
signal blocked : std_logic;
signal sudolock : std_logic;
-
+ signal reset_fsm : std_logic;
type fsm_t is (IDLE, WAIT_STATE, SET, TOGGLE_CS, TOGGLE_CS_0, TOGGLE_CS_1, TOGGLE_CS_2, FINISH);
signal fsm_state : fsm_t;
signal word_length : integer range 0 to BITS := BITS;
BUS_ACK_OUT <= '0';
BUS_BUSY_OUT <= '0';
start <= '0';
+ reset_fsm <= '0';
if BUS_WRITE_IN = '1' then
if fsm_state = IDLE and blocked = '0' then
wait_cycles <= to_integer(unsigned(BUS_DATA_IN(9 downto 0)));
elsif BUS_ADDR_IN(3 downto 0) = x"1" then --0x11
ctrl_reg <= BUS_DATA_IN;
- blocked <= BUS_DATA_IN(16);
- start <= not sudolock or BUS_DATA_IN(17) ;
+ blocked <= BUS_DATA_IN(16) and or_all(BUS_DATA_IN(4 downto 0));
+ start <= (not sudolock or BUS_DATA_IN(17)) and or_all(BUS_DATA_IN(4 downto 0));
elsif BUS_ADDR_IN(3 downto 0) = x"0" then --0x10
chipselect_reg <= BUS_DATA_IN(15 downto 0);
end if;
elsif BUS_ADDR_IN = "10011" then --Reg. 0x13
sudolock <= BUS_DATA_IN(17);
+ reset_fsm <= BUS_DATA_IN(31);
BUS_ACK_OUT <= '1';
else
BUS_BUSY_OUT <= '1';
time_count <= time_count - 1;
end if;
end case;
- if RESET_IN = '1' then
+ if RESET_IN = '1' or reset_fsm = '1' then
fsm_state <= IDLE;
end if;
end process;