Several examples run on only mbed-os5.13.0 (not 5.14.0)
Dependencies: BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI
Diff: Nioi_main_copy3.cpp
- Revision:
- 4:0f4affc00183
- Parent:
- 3:35ac9ee7d2d6
--- a/Nioi_main_copy3.cpp Wed Aug 07 05:39:01 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/* - * Mbed Application program / Nioi Sensor - * - * Created: July 28th, 2019 - * Revised: August 6th, 2019 - */ - -//#include "select_program.h" -#ifdef NIOI_SENSOR - -// Include -------------------------------------------------------------------- -#include <stdlib.h> -#include <stdlib.h> -#include <stdio.h> -#include <string> -#include <errno.h> -#include "mbed.h" -#include "stm32f769i_discovery.h" -#include "stm32f769i_discovery_audio.h" -#include "EthernetInterface.h" -#include "TCPServer.h" -#include "TCPSocket.h" -#include "TS_DISCO_F769NI.h" -#include "LCD_DISCO_F769NI.h" -#include "USBHostSerial.h" -//#include "USBHostMSD.h" -#include "FATFileSystem.h" -#include "SDBlockDeviceDISCOF769NI.h" -#include "mon.h" -#include "button_group.hpp" - -// Definition ----------------------------------------------------------------- -using namespace Mikami; - -#define LEDON 1 -#define LEDOFF 0 - -#define FOREVER 0x7fffffff - -#define DEBUG 0 - -#if DEBUG -#define DBG(...) pc.printf(__VA_ARGS__) -#else -#define DBG(...) {;} -#endif - -struct PointF { - PointF() {} - PointF(float x0, float y0) : x(x0), y(y0) {} - float x, y; -}; - -// Constructor ---------------------------------------------------------------- -LCD_DISCO_F769NI lcd; -TS_DISCO_F769NI ts; -Serial pc(SERIAL_TX, SERIAL_RX, 115200); -DigitalIn userSW(BUTTON1); -DigitalOut led_red(LED1); -DigitalOut led_green0(LED2); -DigitalOut led_green1(LED3); -SDBlockDeviceDISCOF769NI bd; -FATFileSystem fs("fs"); -//USBHostMSD msd; -//USBHostSerial usb_ser; - -// RAM ------------------------------------------------------------------------ -bool flag_opening_done = false; - -// ROM / Constant data -------------------------------------------------------- -const int X0 = 0; // origin of x axis -const int Y0 = 0; // origin of y axis - -const int NX = 670; // number of pixels for horizon -const int NY = 542; // number of pixels for vertical - -// Function prototypes -------------------------------------------------------- -//static void tsk_0(void const *args); -static void task_usb_serial(void const *args); -static void tsk_2(void const *args); -static void tsk_3(void const *args); - -//extern void time_enter_mode(void); -static void goto_standby(void); - -//extern void drawImage(const char * name, uint16_t x, uint16_t y); -extern void draw_bitmap(uint8_t *Name_BMP, uint32_t Xpos, uint32_t Ypos); -extern void task_opening_action(void const *args); - -//------------------------------------------------------------------------------ -// Control Program -//------------------------------------------------------------------------------ -osThreadDef(task_opening_action, osPriorityNormal,4096); -osThreadDef(task_usb_serial, osPriorityNormal,4096); -osThreadDef(tsk_2, osPriorityNormal,4096); -osThreadDef(tsk_3, osPriorityNormal,4096); - -int main() -{ - flag_opening_done = false; - osThreadId id0, id1, id2, id3; - DBG("line:%d\r\n", __LINE__); - id0 = osThreadCreate(osThread(task_opening_action), NULL); - while (flag_opening_done == false) { - DBG("line:%d\r\n", __LINE__); - ThisThread::sleep_for(100); - } - osThreadTerminate(id0); - wait_ms(100); - // - id1 = osThreadCreate(osThread(task_usb_serial), NULL); - id2 = osThreadCreate(osThread(tsk_2), NULL); - id3 = osThreadCreate(osThread(tsk_3), NULL); - pc.printf("id0=0x%x, id1=0x%x, id2=0x%x, id3=0x%x\r\n", - (uint32_t)id0, (uint32_t)id1, (uint32_t)id2, (uint32_t)id3); - while(true) { - ThisThread::sleep_for(FOREVER); - } -} - -void task_usb_serial(void const *args) -{ - DBG("line:%d\r\n", __LINE__); - USBHostSerial usb_ser; - DBG("line:%d\r\n", __LINE__); - wait_ms(500); - while(true) { - DBG("line:%d\r\n", __LINE__); - // try to connect a USB serial device - while(!usb_ser.connect()) { - DBG("line:%d\r\n", __LINE__); - wait_ms(500); - } - // in a loop, print all characters received - // if the device is disconnected, we try to connect it again - while (true) { - DBG("line:%d\r\n", __LINE__); - // if device disconnected, try to connect it again - if (!usb_ser.connected()) { - break; - } - // print characters received - while (usb_ser.available()) { - pc.printf("%c", usb_ser.getc()); - } - } - } -} - -void tsk_2(void const *args) -{ - while(true) { - led_green0 = LEDON; - ThisThread::sleep_for(1500); - led_green0 = LEDOFF; - ThisThread::sleep_for(1500); - } -} - -void tsk_3(void const *args) -{ - while(true) { - led_green1 = LEDON; - ThisThread::sleep_for(2000); - led_green1 = LEDOFF; - ThisThread::sleep_for(2000); - } -} - -void goto_standby(void) -{ - ThisThread::sleep_for(0x7fffffff); // sleep 24 days -} - -#endif