Building w/ SPI driver in BSP for Wi-EM

Hello,
I am using a Wi-EM w/ NetOS 7.3. I created a basic app, configured it to use port 2 for async serial IO. Verified it ran, fine, saw the debug output on port2. So I know it works w/o SPI. As I need both an SPI port and an async serial port, I then modified the BSP file bsp_serial.h to change serial port 1 to use the “BSP_SERIAL_SPI_DRIVER”. I also changed the simple serial port to BSP_SIMPLE_SERIAL_ON_PORTB to be sure this didn’t interfere w SPI driver. When I run, the Wi-EM appears to hang. debugger indicates running, but it never gets to even first line of applicationStart. No ping response. make clean same result. I even tried adding #define BSP_GPIO_MUX_SERIAL_A BSP_GPIO_MUX_SERIAL_SPI_MASTER to gpio.h. It is hanging in xk_em_serl.c, it looks like wating for serial port2 buffer to empty… but serial port2 is async and should have emptied… Is there a sample of this for the Wi-EM somewhere? thanks!

Just as suggestion, I would review some of the following documentation. There is a connector block on the Digi development board that needs to be set correctly (Pages #28-29 Wi-EM HWR Ref). There are some important register configurations discussed on page #230 of the NS7520 HWR Ref Guide.

Digi Connect EM & Wi-EM Hardware Reference:
Serial Pin Assignments Page #16
SPI Dev Bd Conn Block Pages #28-29,
GPIO Pin Settings Page #41

http://ftp1.digi.com/support/documentation/90000632_G.pdf

NS7520 Hardware Reference Guide:
GPIO Pin Settings Page #22, 23
Port Configuration Page #75-80
SPI Mode Review Page #211-219
Serial Channel 1, 2 Control Register B Page #230, 244

http://ftp1.digi.com/support/documentation/90000353_G.pdf

This is actually a known bug in 7.3 and earlier. netos_serlinit makes the assumption that the vectors for the interrupts will be setup in order from the first to last serial port. This has been corrected in 7.4 and later.

There’s a simple work around I’ve used:

Change (in netos_serlinit):

   NAInstallIsr (devParas[pChannel->serChannel].rxvector, (NA_ISR_HANDLER)onccIntRd, (void*) pChannel);

    /*  install send interrupt function */
    NAInstallIsr (devParas[pChannel->serChannel].txvector, (NA_ISR_HANDLER) onccIntWr, (void*) pChannel);

to:

   NAInstallIsr (devParas[channel].rxvector, (NA_ISR_HANDLER)onccIntRd, (void*) pChannel);

    /*  install send interrupt function */
    NAInstallIsr (devParas[channel].txvector, (NA_ISR_HANDLER) onccIntWr, (void*) pChannel);