Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
Child:
1:e396a61d2631
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 #include "mbed.h"
kadonotakashi 0:8fdf9a60065b 2
kadonotakashi 0:8fdf9a60065b 3 Thread thread;
kadonotakashi 0:8fdf9a60065b 4
kadonotakashi 0:8fdf9a60065b 5
kadonotakashi 0:8fdf9a60065b 6 class SPI_LIB
kadonotakashi 0:8fdf9a60065b 7 {
kadonotakashi 0:8fdf9a60065b 8 public:
kadonotakashi 0:8fdf9a60065b 9 SPI_LIB(PinName mosi,PinName miso,PinName sclk,PinName cs):_spi(mosi,miso,sclk),_cs(cs) {
kadonotakashi 0:8fdf9a60065b 10 _spi.format(8,3);
kadonotakashi 0:8fdf9a60065b 11 _spi.frequency(500000);
kadonotakashi 0:8fdf9a60065b 12 }
kadonotakashi 0:8fdf9a60065b 13
kadonotakashi 0:8fdf9a60065b 14 void SendData(uint8_t data) {
kadonotakashi 0:8fdf9a60065b 15 _cs=0;
kadonotakashi 0:8fdf9a60065b 16 _spi.write(data);
kadonotakashi 0:8fdf9a60065b 17 _cs=1;
kadonotakashi 0:8fdf9a60065b 18 }
kadonotakashi 0:8fdf9a60065b 19
kadonotakashi 0:8fdf9a60065b 20
kadonotakashi 0:8fdf9a60065b 21 private:
kadonotakashi 0:8fdf9a60065b 22 SPI _spi;
kadonotakashi 0:8fdf9a60065b 23 DigitalOut _cs;
kadonotakashi 0:8fdf9a60065b 24 };
kadonotakashi 0:8fdf9a60065b 25
kadonotakashi 0:8fdf9a60065b 26
kadonotakashi 0:8fdf9a60065b 27 void print_char(char c = '*')
kadonotakashi 0:8fdf9a60065b 28 {
kadonotakashi 0:8fdf9a60065b 29 printf("%c", c);
kadonotakashi 0:8fdf9a60065b 30 fflush(stdout);
kadonotakashi 0:8fdf9a60065b 31 }
kadonotakashi 0:8fdf9a60065b 32
kadonotakashi 0:8fdf9a60065b 33 void print_thread()
kadonotakashi 0:8fdf9a60065b 34 {
kadonotakashi 0:8fdf9a60065b 35 while (true) {
kadonotakashi 0:8fdf9a60065b 36 wait(1);
kadonotakashi 0:8fdf9a60065b 37 print_char();
kadonotakashi 0:8fdf9a60065b 38 }
kadonotakashi 0:8fdf9a60065b 39 }
kadonotakashi 0:8fdf9a60065b 40
kadonotakashi 0:8fdf9a60065b 41 SPI_LIB SPIx(D11,D12,D13,D10);
kadonotakashi 0:8fdf9a60065b 42
kadonotakashi 0:8fdf9a60065b 43 int main()
kadonotakashi 0:8fdf9a60065b 44 {
kadonotakashi 0:8fdf9a60065b 45 printf("\n\n*** RTOS basic example ***\n");
kadonotakashi 0:8fdf9a60065b 46 thread.start(print_thread);
kadonotakashi 0:8fdf9a60065b 47
kadonotakashi 0:8fdf9a60065b 48 while (true) {
kadonotakashi 0:8fdf9a60065b 49 for(uint8_t i=0; i<10; i++) {
kadonotakashi 0:8fdf9a60065b 50 SPIx.SendData(i);
kadonotakashi 0:8fdf9a60065b 51 wait(1);
kadonotakashi 0:8fdf9a60065b 52 }
kadonotakashi 0:8fdf9a60065b 53 }
kadonotakashi 0:8fdf9a60065b 54 }