This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc3200 spi comunication as gpio cs

Other Parts Discussed in Thread: CC3200

Hi 

I want to use the as GPIO SPI CS pin from cc3200.(i must use multi slave spi.)

So I saw all document and other people code about cc3200 spi communication

But i understand it.

Please give me the example code about using as GPIO CS pin from cc3200.

Then i will thank you. 

  • Why can't you use the SPIEN pin? Are you considering to control multiple SPI slaves from CC3200?

  • yes i will control multi slave to spi
  • Hi,

    This is not a problem control multiple SPI slaves (=CS) by GPIO. In my application I use this "code":

    // macro(s) for SPI transfers
    #define SPIWrite(len, txBuff) MAP_SPITransfer(GSPI_BASE, txBuff, 0, len, 0)
    #define SPIRead(len, rxBuff)  MAP_SPITransfer(GSPI_BASE, 0, rxBuff, len, 0)
    #define SPIReadWrite(len, txBuff, rxBuff)  MAP_SPITransfer(GSPI_BASE, txBuff, rxBuff, len, 0)
    
    // 5MHz
    #define SPI_BIT_RATE 5000000
    
    // OS lock object for synchronisation
    static OsiLockObj_t spiLock;
    
    // *** SPI init function 
    void SPIlibInit(void) {
    
      osi_LockObjCreate(&spiLock);
    
      // enable SPI clock
      MAP_PRCMPeripheralClkEnable(PRCM_GSPI, PRCM_RUN_MODE_CLK);
      // SPI_CLK
      MAP_PinTypeSPI(PIN_05, PIN_MODE_7);
      // SPI_MISO
      MAP_PinTypeSPI(PIN_06, PIN_MODE_7);
      // GSPI_MOSI
      MAP_PinTypeSPI(PIN_07, PIN_MODE_7);
      // SPI reset
      MAP_SPIReset(GSPI_BASE);
    
      // set SPI config
      MAP_SPIConfigSetExpClk(GSPI_BASE,
                             MAP_PRCMPeripheralClockGet(PRCM_GSPI),
                             SPI_BIT_RATE,
                             SPI_MODE_MASTER,
                             SPI_SUB_MODE_3,
                            (SPI_3PIN_MODE |
                             SPI_TURBO_OFF |
                             SPI_WL_8));
    }
    
    
    // *** CS enable (CS PIN need to be configured to GPIO and output)
    void SPILockCSWait(unsigned long port, unsigned char mask) {
    
      osi_LockObjLock(&spiLock, OSI_WAIT_FOREVER);
    
      HWREG(port + (GPIO_O_GPIO_DATA + (mask << 2))) = 0x00;
      MAP_SPIEnable(GSPI_BASE);
    }
    
    
    // *** CS disable (CS PIN need to be configured to GPIO and output)
    void SPIUnlockCS(unsigned long port, unsigned char mask) {
    
      MAP_SPIDisable(GSPI_BASE);
      HWREG(port + (GPIO_O_GPIO_DATA + (mask << 2))) = 0xFF;
    
      osi_LockObjUnlock(&spiLock);
    }

    Jan

  • thank you for help