Changeset 565 for trunk/modules/vci_spi/caba/source/src
- Timestamp:
- Oct 26, 2013, 5:34:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_spi/caba/source/src/vci_spi.cpp
r564 r565 55 55 r_ctrl_cpha = false; 56 56 r_ctrl_go_bsy = false; 57 r_ clk_counter = 0xffff;57 r_spi_clk_counter = 0xffff; 58 58 r_spi_clk = 0; 59 r_spi_done = false; 59 60 60 61 r_irq = false; … … 68 69 // r_target_fsm, r_irq_enable, r_nblocks, r_buf adress, r_lba, r_go, r_read 69 70 ////////////////////////////////////////////////////////////////////////////// 71 72 if (r_spi_done) 73 r_ctrl_go_bsy = false; 70 74 71 75 switch(r_target_fsm) { … … 210 214 // the SPI FSM controls SPI signals 211 215 ////////////////////////////////////////////////////////////////////////////// 216 if (r_ctrl_go_bsy == false) 217 r_spi_done = false; 212 218 switch (r_spi_fsm) { 213 219 case S_IDLE: 214 r_ clk_counter = r_divider.read();220 r_spi_clk_counter = r_divider.read(); 215 221 r_spi_clk = 0; 216 222 r_spi_clk_previous = r_ctrl_cpha; 217 223 r_spi_clk_ignore = r_ctrl_cpha; 218 r_ bit_count = r_ctrl_char_len;224 r_spi_bit_count = r_ctrl_char_len; 219 225 r_spi_out = (r_txrx[(r_ctrl_char_len -1)/ 64] >> ((r_ctrl_char_len - 1) % 64)) & (uint64_t)0x0000000000000001ULL; 220 if (r_ctrl_go_bsy.read() )226 if (r_ctrl_go_bsy.read() && !r_spi_done.read()) 221 227 r_spi_fsm = S_XMIT; 222 228 break; … … 231 237 r_txrx[1] = (r_txrx[1] << 1) | (r_txrx[0] >> 63); 232 238 r_txrx[0] = (r_txrx[0] << 1) | p_spi_miso; 233 r_ bit_count = r_bit_count - 1;239 r_spi_bit_count = r_spi_bit_count - 1; 234 240 } else if (r_spi_clk_previous == 1 && s_clk_sample == 0) { 235 241 // high to low transition: change output, or stop 236 if (r_ bit_count == 0) {242 if (r_spi_bit_count == 0) { 237 243 r_spi_fsm = S_IDLE; 238 244 r_irq = r_ctrl_ie; 239 r_ ctrl_go_bsy = false;245 r_spi_done = true; 240 246 #ifdef SOCLIB_MODULE_DEBUG0 241 247 std::cout << name() << " end xfer " << std::dec << (int)r_ctrl_char_len.read() << " data " << std::hex << r_txrx[1] << " " << r_txrx[0] << std::endl; … … 248 254 r_spi_clk_previous = s_clk_sample; 249 255 // generate the SPI clock 250 if (r_ clk_counter.read() == 0) {251 r_ clk_counter = r_divider.read();256 if (r_spi_clk_counter.read() == 0) { 257 r_spi_clk_counter = r_divider.read(); 252 258 r_spi_clk = !r_spi_clk.read(); 253 259 r_spi_clk_ignore = false; 254 260 } else { 255 r_ clk_counter = r_clk_counter.read() - 1;261 r_spi_clk_counter = r_spi_clk_counter.read() - 1; 256 262 } 257 263 break; … … 766 772 << std::endl; 767 773 std::cout << name() << " _SPI : " << spi_str[r_spi_fsm.read()] 768 << " clk_counter " << r_ clk_counter.read()769 << " r_ bit_count " << r_bit_count.read()774 << " clk_counter " << r_spi_clk_counter.read() 775 << " r_spi_bit_count " << r_spi_bit_count.read() 770 776 << " r_ctrl_go_bsy " << (int)r_ctrl_go_bsy.read() << std::endl; 771 777 std::cout << name() << " _SPI : "
Note: See TracChangeset
for help on using the changeset viewer.