9 years, 9 months ago.

Nucleo L152RE

Hello, I tried to modify this program to be compatible with Mbed nucleo L152RE (very low consumption), but I'm kind of stuck on an error. I have to recode functions BurstSPI::clearRX and BurstSPI::fastWrite but I don't understand how the original developer did it. I based on the "BurstSPI_LPC1768.cpp" and messages errors are : "Expression must have pointer type"

Do you have an idea to resolve those errors ?

include the mbed library with this snippet

#include "BurstSPI.h"

void BurstSPI::fastWrite(int data) {
    //Wait until FIFO has space
    while(((_spi.spi->SR) & 0x02) == 0);
    
    //transmit data
    _spi.spi->DR = data;
    }

void BurstSPI::clearRX( void ) {
    //Do it while either data in RX buffer, or while it is busy
    while(((_spi.spi->SR) & ((1<<4) + (1<<2))) != 0) {
        //Wait until data in RX buffer
        while(((_spi.spi->SR) & (1<<2)) == 0);
        int dummy = _spi.spi->DR;
        }
}

Question relating to:

A lib to handle a E-Paper display from Pervasive Displays. There is a interface board from Embedded Artists. The lib can handle graphic and text drawing and is using external …

2 Answers

9 years, 9 months ago.

Original developer here, so I know how to do it :P.

First of all, this question is related to the EaE paper display, if you use it for that, just remove it from the library, it doesn't really add that much due to how that display uses SPI. For regular LCD displays the difference can be huge though.

But if you do want/need to implement this, you will probably need the manual of the L152 and the mbed lib source code, since it builds upon the standard mbed source code. This is found here: http://mbed.org/users/mbed_official/code/mbed-src/file/685d5f11838f/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/spi_api.c

From this I might already be able to guess what you need. For fastWrite you can use the SSP write function (which is made static, so you cannot use the function directly but will have to copy paste it into the fastWrite function, also it uses the ssp_writable function, which wants the obj instead of the spi, we could deliver it that and also copy paste that function, or just get the relevant line from that function, which I did here):

SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_TXE) != RESET) ? 1 : 0));
SPI_I2S_SendData(spi, (uint16_t)value);

This simply sends data via SPI out. Now I don't know how much overhead those functions have (often enough I have not been exactly impressed by the efficiency of those standards functions, but maybe it isn't that bad).

Now if you make clearRX empty it should already work for transmit-only SPI.

For clearRX then you can use from that same page the functions to wait as long as it is busy (so you know it is completely done sending), and then while ssp is readable, use ssp_read to a dummy variable. I am not checking if this compiles, so I might make errors here, but in principle to not get pointer errors you should need to replace obj->spi with _spi.spi.

See if this helps you to get further. Also if you do need it (so which isn't really needed for the EaEpaper), and you do get it to work, please make a pull request and send me a PM (otherwise I don't know about the pull request), then I can add your code to the lib.

Dear Erik,

I would like to thank you so much for this great answer. I will check on the L152 lib source code and i'll try to resolve it. I use Embedded Artist E-Paper so you sugest I remove it from the lib ? What sould I delete ?

I recode a new cpp file to be compatible with my board here is the code (compile fine but might have a problem with clearRX.

how could i send it to you ?

posted by sebastien videau 24 Jun 2014

For pull requests you need to publish it (non-public is fine), then you can from the homepage make a pull request. But then it needs to be verified it works properly (and since I don't have it, I cannot do it myself).

For the e-paper simply delete the library, and replace all fastwrite functions with write. All clearRX functions can be deleted also. (And you need to delete the #include for burstSPI).

posted by Erik - 24 Jun 2014
9 years, 9 months ago.

I have remove the use of the BurstSPI lib. Erik is right - the lib is not needed for the EaPaper display. You can`t see a difference. At the time I was writing the lib, I had tried to speed up the display changes, but the display technology itself limit the speed.