This is sample program for Nucleo L152RE (and F401RE & F411RE) mbed-rtos. You need to modify mbed-src and mbed-rtos before compile it.
Dependencies: mbed-rtos mbed-src SetRTC
Fork of GR-PEACH_test_on_rtos_works_well by
Please refer below link.
/users/kenjiArai/notebook/necleo-l152re-rtos-sample-also-for-f401re--f411re-/
Diff: main.cpp
- Revision:
- 6:f14cce59e7fe
- Parent:
- 5:dccdaaa1e57b
- Child:
- 8:4006b111c0d4
diff -r dccdaaa1e57b -r f14cce59e7fe main.cpp --- a/main.cpp Thu Jan 08 13:03:16 2015 +0000 +++ b/main.cpp Sat Jan 10 04:57:33 2015 +0000 @@ -6,7 +6,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: November 29th, 2014 - * Revised: January 7th, 2015 + * Revised: January 10th, 2015 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE @@ -21,7 +21,6 @@ #include "L3GD20.h" #include "LIS3DH.h" #include "TextLCD.h" -#include "ST7565_SPI_LCD.h" // Definition ------------------------------------------------------------------------------------ #define USE_COM // use Communication with PC(UART) @@ -61,7 +60,7 @@ DigitalIn USER_SWITCH[2] = { #if defined(TARGET_RZ_A1H) DigitalIn(P6_0), DigitalIn(P6_1) -#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F401RE) +#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) DigitalIn(PC_13), DigitalIn(A0) #endif }; @@ -70,7 +69,7 @@ #if defined(TARGET_RZ_A1H) DigitalOut task0(P1_8); DigitalOut task1(P1_9); -#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F401RE) +#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) DigitalOut task0(A0); DigitalOut task1(A1); #endif @@ -88,9 +87,6 @@ // LCD TextLCD_I2C_N lcd0(&i2c, 0x7c, TextLCD::LCD16x2); // LCD(Akizuki AQM0802A) #endif -// SPI LCD -SPI spi_lcd(D11, D12, D13); // mosi, miso, sck -ST7565 lcd1(spi_lcd, D8, D9, D7, ST7565::AQM1248A); // spi,reset,a0,ncs, LCD(Akizuki AQM1248A) // Mutex Mutex i2c_mutex; @@ -188,20 +184,15 @@ void display(void const *args){ uint32_t n = 0; - lcd1.cls(); while (true) { #ifdef USE_I2C_LCD i2c_mutex.lock(); lcd0.locate(0, 0); // 1st line top - lcd0.printf("G=%7.1f ", sqrt(fa[0]*fa[0] + fa[1]*fa[1] + fa[2]*fa[2])); + lcd0.printf(" G=%4.1f ", sqrt(fa[0]*fa[0] + fa[1]*fa[1] + fa[2]*fa[2])); lcd0.locate(0, 1); // 2nd line top - lcd0.printf("%8d",n); + lcd0.printf("%8d",n++); i2c_mutex.unlock(); #endif - lcd1.locate(0,0); - lcd1.printf("G:%+6.1f,%+6.1f,%+6.1f \r\n", fg[0], fg[1], fg[2]); - lcd1.printf("A:%+6.1f,%+6.1f,%+6.1f \r\n", fa[0], fa[1], fa[2]); - lcd1.printf("%d\r\n", n++); Thread::wait(500); // debug task1 = !task1; @@ -213,7 +204,7 @@ osThreadDef(update_angle, osPriorityNormal, 2048); osThreadDef(monitor, osPriorityNormal, 2048); osThreadDef(display, osPriorityAboveNormal, 2048); -#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F401RE) +#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) osThreadDef(update_angle, osPriorityNormal, 1024); osThreadDef(monitor, osPriorityNormal, 1024); osThreadDef(display, osPriorityAboveNormal, 1024); @@ -254,18 +245,6 @@ if (osThreadCreate(osThread(update_angle), NULL) == NULL){ PRINTF("ERROR1\r\n"); } - - // SPI LCD - spi_lcd.frequency(100000); - lcd1.cls(); - lcd1.set_contrast(0x2a); - lcd1.printf("test\r\n" ); - lcd1.printf("Kenji Arai / JH1PJL\r\n" ); - lcd1.printf("ABCDEFG 1234567890\r\n" ); - lcd1.rect(5,30,120,62,1); - lcd1.circle(5,35,5,1); - lcd1.fillcircle(60,55,5,1); - lcd1.line(0,30,127,63,1); // I2C LCD #ifdef USE_I2C_LCD // ---->lock