Hi everyone, fairly new to Mbed OS.
Trying to use SPI to interface a NewHaven OLED 4x20.
I went through the user guide for setup but as soon as program gets to any of the SPI API calls the program hangs up.
I tried to step through the debugger but couldn’t make heads or tails of what was wrong.
This is the entire program. Is there some bug with the API for this board, or what am I missing?
#include "mbed.h"
SPI SPI_OLED(PA_7, PA_6, PA_5);
DigitalOut OLED_SS(PB_0);
DigitalOut OLED_RS(PC_5);
DigitalOut led(LED1);
// main() runs in its own thread in the OS
int main()
{
OLED_RS = 1;
OLED_SS = 1;
SPI_OLED.format(8, 0);
SPI_OLED.frequency(1000000);
led = 1;
thread_sleep_for(250);
led = 0;
thread_sleep_for(250);
led = 1;
thread_sleep_for(250);
led = 0;
thread_sleep_for(250);
while (true) {
led = 1;
thread_sleep_for(50);
SPI_OLED.lock();
OLED_SS = 0;
SPI_OLED.write(0x0C);
OLED_SS = 1;
SPI_OLED.unlock();
led = 0;
thread_sleep_for(500);
}
}