SPI interface with Core2

Hello,
I want to use a 1.8 TFT display with ST7735 controller with Core2 board.
Are there any examples to do this with hFramework?
Can I use (with some adjustments) code for Arduino (e.g. https://github.com/adafruit/Adafruit-ST7735-Library) or are there some other libraries?

Michael

Hi Michael,

I don’t think so, but Mbed framework have a lot of examples in internet (one of them). Maybe it’s a good idea to change framework :wink:

Best regards,
Hubert

I thought about changing framework a few times, but I think I have to rewrite a lot of (working) code. This is the reason why I did not switch yet.

Michael

Hello,

I made some progress in migrating to Mded framework, but have some questions:

  • How can I “catch” printf outputs?
  • How can I use the SPI connection of Core2?

Michael

Hi Michael,

I don’t know what you mean by “catching printf outputs”. Do you mean interpreting output data on pc side? If you want to easily exchange data between the board and your pc using serial you can consider trying ros, particularly rosserial library for mbed.

SPI pins are localized on hExt port (2x10 IDC port). Here is a simple example on how to use SPI in mbed:

#include <mbed.h>

#define SPI_CS_PIN       EXT_PIN7
#define SPI_MOSI_PIN     EXT_PIN10
#define SPI_MISO_PIN     EXT_PIN9
#define SPI_SCK_PIN      EXT_PIN8

#define MCU_DESCRIPTION_SIZE 5

DigitalOut led(LED1);

Serial pc(USBTX, USBRX, 115200);

// GPIO SW slave select, active low
SPI device(SPI_MOSI_PIN, SPI_MISO_PIN, SPI_SCK_PIN, SPI_CS_PIN, use_gpio_ssel);

const char * BOARD_DESCRIPTION_STR[MCU_DESCRIPTION_SIZE] = {
    "CORE2\n",
    "STM32F407ZTG\n",
    "ARM Cortex-M4\n",
    "168Mhz\n",
    "1MB Flash/192+4KB RAM\n"
};

int main()
{
    int i = 0;

    while(1)
    {
        const char * string_ptr = BOARD_DESCRIPTION_STR[i % MCU_DESCRIPTION_SIZE]; 
        size_t string_len = strlen(string_ptr);
        
        pc.printf(string_ptr);
        device.write(string_ptr, string_len, nullptr, 0);

        led = !led;

        i++;

        ThisThread::sleep_for(1000);
    }
}

Regards,
Szymon

Hi Szymon,

thanks for your answer.
With “catching printf outputs” I meant the displaying of printf in the serial monitor for debugging purposes. In the meantime I found the trick with:
Serial pc(USBTX, USBRX, 115200);
and the same baudrate in the serial monitor of PlatformIO.

I will try the example with SPI in the next time. Hoping I’ll find a Mbed library for my display (ST7735 Display driver) :wink:
What is the meaning of the “use_gpio_ssel” parameter ?

Regards,

Michael