Changeset 574 for trunk/modules/sdmmc


Ignore:
Timestamp:
Nov 17, 2013, 3:47:26 PM (11 years ago)
Author:
bouyer
Message:

Try to be closer to a real sdmmc device: on rising edge really use the value
we had while the clock was low, not the value at the rising edge time.
This is to make the transfer fail if the MOSI line changes at rising clock
instead of falling clock as it should.

Location:
trunk/modules/sdmmc/caba/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/sdmmc/caba/source/include/sdmmc.h

    r557 r574  
    5959    int               spi_bitcount;
    6060    int               spi_clk;
     61    int               spi_mosi_previous; // sampled MOSI value
    6162
    6263    uint8_t           command;
  • trunk/modules/sdmmc/caba/source/src/sdmmc.cpp

    r557 r574  
    6060        spi_fsm  = S_IDLE;
    6161        spi_clk = p_spi_clk;
     62        spi_mosi_previous = p_spi_mosi;
    6263        return;
    6364    }
     
    6768        if (p_spi_clk.read() == 1 && spi_clk == 0) {
    6869                // rising edge
    69                 command = (command << 1) | p_spi_mosi;
     70                command = (command << 1) | spi_mosi_previous;
    7071                spi_bitcount = 6;
    7172                spi_fsm = S_RECEIVE_CMD;
     
    7576        if (p_spi_clk.read() == 1 && spi_clk == 0) {
    7677                // rising edge
    77                 command = (command << 1) | p_spi_mosi;
     78                command = (command << 1) | spi_mosi_previous;
    7879                if (spi_bitcount == 0) {
    7980                        if ((command & 0x80) == 0) {
     
    9394        if (p_spi_clk.read() == 1 && spi_clk == 0) {
    9495                // rising edge
    95                 args = (args << 1) | p_spi_mosi;
     96                args = (args << 1) | spi_mosi_previous;
    9697                spi_bitcount = 30;
    9798                spi_fsm = S_RECEIVE_ARGS;
     
    101102        if (p_spi_clk.read() == 1 && spi_clk == 0) {
    102103                // rising edge
    103                 args = (args << 1) | p_spi_mosi;
     104                args = (args << 1) | spi_mosi_previous;
    104105                if (spi_bitcount == 0) {
    105106                        spi_bitcount = 7;
     
    113114        if (p_spi_clk.read() == 1 && spi_clk == 0) {
    114115                // rising edge
    115                 cmdcrc = (cmdcrc << 1) | p_spi_mosi;
     116                cmdcrc = (cmdcrc << 1) | spi_mosi_previous;
    116117                if (spi_bitcount == 0) {
    117118                        handle_sdmmc_cmd(command, args);
     
    154155            // rising edge
    155156            uint8_t s_data;
    156             s_data = (m_databuf[0] << 1) | p_spi_mosi;
     157            s_data = (m_databuf[0] << 1) | spi_mosi_previous;
    157158            m_databuf[0] = s_data;
    158159            if (spi_bitcount == 0) {
     
    178179            if (p_spi_clk.read() == 1 && spi_clk == 0) {
    179180                // rising edge
    180                 m_databuf[m_data_idx] = (m_databuf[m_data_idx] << 1) | p_spi_mosi;
     181                m_databuf[m_data_idx] = (m_databuf[m_data_idx] << 1) | spi_mosi_previous;
    181182                if (spi_bitcount == 0) {
    182183                    m_data_idx++;
     
    215216    }
    216217    spi_clk = p_spi_clk.read();
     218    spi_mosi_previous = p_spi_mosi;
    217219} // end GenMealy()
    218220
Note: See TracChangeset for help on using the changeset viewer.