Set HSPI CS manually (as GPIO)

pathob
Posts: 1
Joined: Mon Oct 24, 2016 2:14 am

Set HSPI CS manually (as GPIO)

Postby pathob » Mon Oct 24, 2016 2:28 am

Hi,

is there any way to set the CS pin of the HSPI interface as an GPIO while the other HSPI pins are driven by the hardware? For the SPI interface I found the following:

Code: Select all

SET_PERI_REG_MASK(SPI_PIN(...), SPI_CS0_DIS | SPI_CS1_DIS | SPI_CS2_DIS);


But there is no HSPI_CS_DIS and as soon as I try to use CS as an GPIO, HSPI doesn't seem to work at all anymore.

Code: Select all

PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);


The problem is that I cannot change the connections anymore.

Thanks in advance for your responses!

pratik

Re: Set HSPI CS manually (as GPIO)

Postby pratik » Mon Oct 24, 2016 7:24 pm

Code: Select all

// GPIO2 as CS line
#define SD_CS_HIGH    while (READ_PERI_REG (SPI_CMD(1)) & (1<<18)); GPIO_OUTPUT_SET (2, 1)
#define SD_CS_LOW     GPIO_OUTPUT_SET (2, 0)

  // Init HSPI GPIO
  WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105);      // Clock config
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2);
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2);
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2);
  // PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2); // Do NOT use hardware CS
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); // CS signal


You could try this. This is for when you have GPIO2 as CS. Similarly, you could configure any pin you like as GPIO. Make sure you are using the correct MUX and pin names though!

Who is online

Users browsing this forum: No registered users and 59 guests