SPI "wrong parameter"


#1

Hello All. I am sorry, maybe is is dummy, nevertheless…
I am heading to some problem. I cant subscribe to SPI bus. This is code i use. Nothing else in program, just this SPI test. The handle returned is -2, ADL_RET_ERR_PARAM. Neither SPI1, not SPI2 doesnt work. What am i doing wrong???

adl_busSPISettings_t MySPISettings;
    MySPISettings.Clk_Speed = 0; //13MHz
    MySPISettings.Clk_Mode = ADL_BUS_SPI_CLK_MODE_0;
    MySPISettings.ChipSelect = ADL_BUS_SPI_ADDR_CS_HARD;
    MySPISettings.ChipSelectPolarity = ADL_BUS_SPI_CS_POL_LOW;
    MySPISettings.LsbFirst = ADL_BUS_SPI_MSB_FIRST;
    MySPISettings.GpioChipSelect = 0;
    MySPISettings.WriteHandling = ADL_BUS_SPI_FRAME_HANDLING;
    MySPISettings.DataLinesConf = ADL_BUS_SPI_DATA_UNIDIR;

    s32 MySPIHandle;
    ascii * My_Message = adl_memGet ( 100 );
    MySPIHandle = adl_busSubscribe (ADL_BUS_SPI1, (adl_busSettings_u *)(&MySPISettings));
    
    wm_sprintf(My_Message, "\r\nMySPIHandle: %d\r\n", MySPIHandle);
    adl_atSendResponse ( ADL_AT_UNS, My_Message);

    ReturnValue = adl_busUnsubscribe (MySPIHandle);

#2

P.S. I forgot to mention that i use Q2686H CPU, firmware is 6.63. OS 4.21.01.


#3

Quickly reviewing your code, I don’t see anything wrong. Here’s my code, which works on the Q2687, firmware 6.63b10, OS 4.22.00. I don’t use chip select, so there’s a chance you have a problem there and I wouldn’t notice it.

s32 SPI_Handle = -1;
const adl_busSPISettings_t SPI_Settings = {
  0,
  ADL_BUS_SPI_CLK_MODE_0,
  ADL_BUS_SPI_ADDR_CS_NONE,
  ADL_BUS_SPI_CS_POL_LOW,
  ADL_BUS_SPI_MSB_FIRST,
  0,
  0,
  ADL_BUS_SPI_DATA_UNIDIR
};
SPI_Handle = adl_busSubscribe(ADL_BUS_SPI1, (adl_busSettings_u *)&SPI_Settings);
if (MMCSPI_Handle < 0) {
  // ERROR
}

#4

Dear Matt
Yes, you are right. Removing CS settings makes no error, subscription is OK.
But i really need CS, because i have two memory chips.

Is this a known problem with this firmware, and will upgrade solve it??
Another way, can i use in GPIO CS settings the same pins as in HARD_CS??

Great thanks in advance.
Regards
Sergey


#5

Reading the documentation for ADL_BUS_SPI_FRAME_HANDLING:


#6

Dear Matt
It`s my mistake.
Solved.

Great thanks in advance.
Regards
Sergey