2 SPI at the same time

Hi!
When I migrate my application from 3.01 (OS 6.50) to 3.10 (OS 6.55) on
my Q2501, I find out that new version do not support 2 SPI at the same time.

Follow code demonstrate this:

u32 wm_apmCustomStack [ 1024 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );

s8 HANDLE_1 = ERROR;
s8 HANDLE_2 = ERROR;


void TEST_CmdHandler ( adl_atCmdPreParser_t *paras )
{
	ascii str[100];
	s8 ret;
	u8 Value;
	adl_busAccess_t SpiBus_Access = {0,0,0,0};

	switch(atoi(ADL_GET_PARAM ( paras, 0 )))
	{
	case 10: // Subscribe to SPI 1
		HANDLE_1 = adl_busSubscribe(ADL_BUS_TYPE_SPI | ADL_BUS_SPI_ADDR_CS_SPI_EN,
						ADL_BUS_SPI_SCL_SPEED_1Mhz | ADL_BUS_SPI_CLK_MODE_0 |
						ADL_BUS_SPI_CS_POL_LOW | ADL_BUS_SPI_MSB_FIRST | ADL_BUS_SPI_BYTE_HANDLING);
		wm_sprintf(str, "\r\nHANDLE_1: %d\r\n", HANDLE_1);
		adl_atSendResponse ( ADL_AT_RSP, str);
		break;
	case 11: // Read from SPI 1
		ret = adl_busRead(HANDLE_1, &SpiBus_Access, 1, &Value);
		wm_sprintf(str, "\r\nSPI 1 read (%d): 0x%X\r\n", ret, Value);
		adl_atSendResponse ( ADL_AT_RSP, str);
		break;
	case 12: // Unsubscribe from SPI 1
		ret	= adl_busUnsubscribe( HANDLE_1 );
		HANDLE_1 = ERROR;
		wm_sprintf(str, "\r\nSPI 1 unsubscribe: %d\r\n", ret);
		adl_atSendResponse ( ADL_AT_RSP, str);
		break;
	case 20: // Subscribe to SPI 2
		HANDLE_2 = adl_busSubscribe(ADL_BUS_TYPE_SPI | ADL_BUS_SPI_ADDR_CS_SPI_AUX, 
						ADL_BUS_SPI_SCL_SPEED_1Mhz | ADL_BUS_SPI_CLK_MODE_0 |
						ADL_BUS_SPI_CS_POL_LOW | ADL_BUS_SPI_MSB_FIRST);
		wm_sprintf(str, "\r\nHANDLE_2: %d\r\n", HANDLE_2);
		adl_atSendResponse ( ADL_AT_RSP, str);
		break;
	case 21: // Read from SPI 2
		ret = adl_busRead(HANDLE_2, &SpiBus_Access, 1, &Value);
		wm_sprintf(str, "\r\nSPI 2 read (%d): 0x%X\r\n", ret, Value);
		adl_atSendResponse ( ADL_AT_RSP, str);
		break;
	case 22: // Unsubscribe from SPI 2
		ret	= adl_busUnsubscribe( HANDLE_2 );
		HANDLE_2 = ERROR;
		wm_sprintf(str, "\r\nSPI 2 unsubscribe: %d\r\n", ret);
		adl_atSendResponse ( ADL_AT_RSP, str);
		break;
	}

	adl_atSendResponse ( ADL_AT_RSP, "\r\nOK\r\n");
}


void adl_main ( adl_InitType_e InitType )
{
	adl_atCmdSubscribe ( "at+test", TEST_CmdHandler,  ADL_CMD_TYPE_PARA | 0x0011);
}

For 650a09gg.Q2501B 1949844 122204 14:53 steps:

  1. Subscribe to SPI 1 - OK (at+test=10)
  2. Subscribe to SPI 2 - OK (at+test=20)
  3. Read from SPI 1 - OK (at+test=11)
  4. Read from SPI 2 - OK (at+test=21)
  5. Unsubscribe from SPI 1 - OK (at+test=12)
  6. Unsubscribe from SPI 2 - OK (at+test=22)

For 655_09gg.Q2501B 2015268 111705 17:01 steps:

  1. Subscribe to SPI 1 - OK (at+test=10)
  2. Subscribe to SPI 2 - OK (at+test=20)
  3. Read from SPI 1 - OK (at+test=11)
  4. Read from SPI 2 - ERROR (-61) (at+test=21)
  5. Unsubscribe from SPI 1 - OK (at+test=12)
  6. Unsubscribe from SPI 2 - ERROR (-22) (at+test=22)

Only work if:

  1. Subscribe to SPI 1 - OK (at+test=10)
  2. Read from SPI 1 - OK (at+test=11)
  3. Unsubscribe from SPI 1 - OK (at+test=12)
  4. Subscribe to SPI 2 - OK (at+test=20)
  5. Read from SPI 2 - OK (at+test=21)
  6. Unsubscribe from SPI 2 - OK (at+test=22)

What happened?
Probably I do something incorrectly?
What is error -61?

Thanks!

Удалось ли побороть проблему? А то я тоже в неё упёрся…

Can you solve this problem? How?

Hi everyone,

It seems to be the same kind of problems with 6.62 OS and openat 4.20 beta 6… The error code for the second adl_busSubscribe is -4 (ADL_RET_ERR_ALREADY_SUBSCRIBED). I use different handler and busSettings…

If someone have an idea of solution other than unsubscribe to one spi and suscribe to the other one…

Tahnks in advance

BEst regards,

gdt

Resolved. I make an error :blush:

Thanks

Best regards,

gdt

Hi

I have also problem with using SPI1 and SPI2 at the same time :smiling_imp: When I try to subscribe to SPI1
(SPI2 already subscribed, and working well) -4 is been recived. Can you share with us, how did
you solved you problem?

Are you using both SPI at the same time?

\kr

(OS 6.63, OpenAT 4.22, Q2687)

Hello,

Yes, the bus API is a completely wreck, as it has also been in the previous versions.

Just an example similar to krutecki’s problem ( i just tried it , OS6.63 q2686 )

I2C works fine alone, but if i try to use the SPI bus the clock line doesn’t even brother to move ( although the functions return with OK…mostly…) ! I2C part uncommented, clock line at least started to move on SPI…

And i don’t have to mention that you can easily reboot the WCPU with the BUS api, i don’t mean with bad pointers or something like that, the API is entirely unprotected.

Does anybody know when will be this serious problem corrected?

Best Regards,
tom

Hi

Today, I have recived beta version of OS called 6.63b3 and OpenAT v4r22.b03, wich should have this
problem fixed. I have to check it, I will let you know.

BTW: Did you try Oasis 2 beta3 (OS v7.0 :confused: )? Its available to download from wavecoms developer site.

\kr

Hello,

“BTW: Did you try Oasis 2 beta3 (OS v7.0 :confused: )? Its available to download from wavecoms developer site.”

Looks like the SPI has been modified… I think i will give it a try. Please let us know your result with the new 6.63 beta.

Please somebody explain to me. Why Wavecom restarted the numbering from 4.24 so the newest package is 2.0?

Anyhow, just looking into this new package here are the names which i encountered:

Firwmare name: Open AT firmware 7.00
Package name: Open At software suite 2.0
ADL user guide: ADL user guide for Open AT OS 6.00,

Shouldn’t be “ADL user guide for Open AT OS 2.0” if we follow the naming of the previous Open AT packages.

But, i would like the most the following:

Package name: Open At software suite version whatever

Firwmare name: Open AT firmware 7.00 ( updates 7.00a,b,c,d,e or simply 7, 7a, 7b, 7c… )
ADL OS name : Open AT OS 7.01 ( updates 7.02, 03,04, 05 or 7.10 7.20 7.30 )

So you can always know that the 7.00x firmware should be compatible with Open AT OS 7.XX.

If it was an old document in the beta release and the concept is this, i didn’t say a thing. 8)

Cheers,
tom

Hi,

Sorry for a big delay, I was overworked :confused:

I would like to update you, that SPI is now working well with OpenAT 4.25
(which has new firmware 6.63c) and ADL 4.23.

I haven`t tested Oasis yet - no time for experiments, sorry :confused: But if I will,
I will let all of you know.

\kr

Hello,

I think most of the problem comes from that the BUS APIs are blocking types, but it shouldn’t freeze the WCPU so easily, i can use it painfully and with tricks but it looks like i will have to use multiple I2C devices and SPI intesivly in the future so i am going to look at the new OASIS 2.0. It has some improvements on this front, like non-blocking APIs. However, i feel that the API is a little overcomplicated. Lots of parameters, and i doubt that all counfiguration has been tested throughfully. And I always missed the clock-stretching from I2C documentation.

Has anybody tried the bus service of OASIS 2.0?

for future reference:

the current firmware (7.3) no longer freezes when something fales on the i2c bus, it reboots.
and this firmware seems to support clock-stretching (propably up to a limit.)