Click here to Skip to main content
15,888,290 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I'm so overwhelmed. =/ Pin
Al_Brown31-Aug-22 0:07
Al_Brown31-Aug-22 0:07 
GeneralRe: I'm so overwhelmed. =/ Pin
honey the codewitch31-Aug-22 3:41
mvahoney the codewitch31-Aug-22 3:41 
GeneralRe: I'm so overwhelmed. =/ Pin
Greg Utas31-Aug-22 4:00
professionalGreg Utas31-Aug-22 4:00 
GeneralRe: I'm so overwhelmed. =/ Pin
honey the codewitch31-Aug-22 5:00
mvahoney the codewitch31-Aug-22 5:00 
GeneralRe: I'm so overwhelmed. =/ Pin
Gerry Schmitz31-Aug-22 7:13
mveGerry Schmitz31-Aug-22 7:13 
GeneralRe: I'm so overwhelmed. =/ Pin
honey the codewitch31-Aug-22 7:26
mvahoney the codewitch31-Aug-22 7:26 
GeneralRe: I'm so overwhelmed. =/ Pin
David O'Neil31-Aug-22 7:54
professionalDavid O'Neil31-Aug-22 7:54 
GeneralRe: I'm so overwhelmed. =/ Pin
honey the codewitch31-Aug-22 8:05
mvahoney the codewitch31-Aug-22 8:05 
I can't rename the processor's SPI register constants.

Let me show you what I'm working with.

Frankly the variable names don't bother me. There aren't many variables, and I understand most of the class members like _csport and _dcport at this point. My main issue is the behavior of the registers. I have the manual but it reads like bad stereo instructions

C++
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)  // Teensy 4.x
#define TCR_MASK \
    (LPSPI_TCR_PCS(3) | LPSPI_TCR_FRAMESZ(31) | LPSPI_TCR_CONT | LPSPI_TCR_RXMSK)
    void maybeUpdateTCR(
        uint32_t requested_tcr_state) /*__attribute__((always_inline)) */ {
        if ((_spi_tcr_current & TCR_MASK) != requested_tcr_state) {
            bool dc_state_change = (_spi_tcr_current & LPSPI_TCR_PCS(3)) !=
                                   (requested_tcr_state & LPSPI_TCR_PCS(3));
            _spi_tcr_current = (_spi_tcr_current & ~TCR_MASK) | requested_tcr_state;
            // only output when Transfer queue is empty.
            if (!dc_state_change || !_dcpinmask) {
                while ((_pimxrt_spi->FSR & 0x1f))
                    ;
                _pimxrt_spi->TCR = _spi_tcr_current;  // update the TCR

            } else {
                waitTransmitComplete();
                if (requested_tcr_state & LPSPI_TCR_PCS(3))
                    DIRECT_WRITE_HIGH(_dcport, _dcpinmask);
                else
                    DIRECT_WRITE_LOW(_dcport, _dcpinmask);
                _pimxrt_spi->TCR = _spi_tcr_current &
                                   ~(LPSPI_TCR_PCS(3) |
                                     LPSPI_TCR_CONT);  // go ahead and update TCR anyway?
            }
        }
    }

    // BUGBUG:: currently assumming we only have CS_0 as valid CS
    void writecommand_cont(uint8_t c) __attribute__((always_inline)) {
        maybeUpdateTCR(_tcr_dc_assert | LPSPI_TCR_FRAMESZ(7) /*| LPSPI_TCR_CONT*/);
        _pimxrt_spi->TDR = c;
        pending_rx_count++;  //
        waitFifoNotFull();
    }
    void writedata8_cont(uint8_t c) __attribute__((always_inline)) {
        maybeUpdateTCR(_tcr_dc_not_assert | LPSPI_TCR_FRAMESZ(7) | LPSPI_TCR_CONT);
        _pimxrt_spi->TDR = c;
        pending_rx_count++;  //
        waitFifoNotFull();
    }
    void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
        maybeUpdateTCR(_tcr_dc_not_assert | LPSPI_TCR_FRAMESZ(15) | LPSPI_TCR_CONT);
        _pimxrt_spi->TDR = d;
        pending_rx_count++;  //
        waitFifoNotFull();
    }

To err is human. Fortune favors the monsters.

GeneralRe: I'm so overwhelmed. =/ Pin
David O'Neil31-Aug-22 8:38
professionalDavid O'Neil31-Aug-22 8:38 
GeneralRe: I'm so overwhelmed. =/ Pin
Randor 31-Aug-22 8:20
professional Randor 31-Aug-22 8:20 
GeneralRe: I'm so overwhelmed. =/ Pin
honey the codewitch31-Aug-22 8:31
mvahoney the codewitch31-Aug-22 8:31 
GeneralWorldle 222 Pin
Amarnath S30-Aug-22 14:58
professionalAmarnath S30-Aug-22 14:58 
GeneralRe: Worldle 222 Pin
OriginalGriff30-Aug-22 18:54
mveOriginalGriff30-Aug-22 18:54 
GeneralRe: Worldle 222 Pin
Sander Rossel30-Aug-22 21:01
professionalSander Rossel30-Aug-22 21:01 
GeneralRe: Worldle 222 Pin
ChandraRam30-Aug-22 22:07
ChandraRam30-Aug-22 22:07 
GeneralRe: Worldle 222 Pin
megaadam31-Aug-22 7:17
professionalmegaadam31-Aug-22 7:17 
GeneralReality check for all you young uns and oldrsters... Pin
charlieg30-Aug-22 13:45
charlieg30-Aug-22 13:45 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
d_c_allison30-Aug-22 13:58
d_c_allison30-Aug-22 13:58 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
Amarnath S30-Aug-22 16:29
professionalAmarnath S30-Aug-22 16:29 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
Sander Rossel30-Aug-22 21:05
professionalSander Rossel30-Aug-22 21:05 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
Eddy Vluggen30-Aug-22 22:36
professionalEddy Vluggen30-Aug-22 22:36 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
theoldfool31-Aug-22 1:28
professionaltheoldfool31-Aug-22 1:28 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
DrWalter PE31-Aug-22 7:49
professionalDrWalter PE31-Aug-22 7:49 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
charlieg31-Aug-22 11:03
charlieg31-Aug-22 11:03 
GeneralRe: Reality check for all you young uns and oldrsters... Pin
rnbergren31-Aug-22 16:03
rnbergren31-Aug-22 16:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.