Example using the support package for LPC4088 DisplayModule
Dependencies: DMBasicGUI DMSupport
Example using a lot of the features in the software package for the LPC4088 Display Module.
This project can be selected as a template when creating a new project based on the LPC4088 Display Module.
Information
This project works on the 4.3" display modules.
Some of the apps works on the 5" display modules. The ImageViewer and Slideshow app will show the images distorted as it does not take the resolution into consideration.
Information
The USB Status app is disabled. The Image viewer looks for images in the root of SD cards, USB memory sticks or the file system on the QSPI flash. The Slideshow app expects to find a slideshow script in /mci/elec14/ea_logo.txt.
This is what it looks like on the 4.3" display:
main.cpp@30:e1cded731965, 2019-11-04 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Nov 04 14:33:29 2019 +0000
- Revision:
- 30:e1cded731965
- Parent:
- 27:4fe24decabf9
More updates related to mbed OS 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:dfad71908d59 | 1 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 2 | * Includes |
embeddedartists | 0:dfad71908d59 | 3 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 4 | |
embeddedartists | 0:dfad71908d59 | 5 | #include "mbed.h" |
embeddedartists | 0:dfad71908d59 | 6 | #include "mbed_interface.h" |
embeddedartists | 0:dfad71908d59 | 7 | #include "rtos.h" |
embeddedartists | 26:f07df116f3c9 | 8 | |
embeddedartists | 26:f07df116f3c9 | 9 | #include "dm_board_config.h" |
embeddedartists | 0:dfad71908d59 | 10 | |
embeddedartists | 26:f07df116f3c9 | 11 | #if defined(DM_BOARD_USE_ETHERNET) |
embeddedartists | 26:f07df116f3c9 | 12 | #include "EthernetInterface.h" |
embeddedartists | 26:f07df116f3c9 | 13 | #include "HTTPServer.h" |
embeddedartists | 26:f07df116f3c9 | 14 | #endif |
embeddedartists | 26:f07df116f3c9 | 15 | #if defined(DM_BOARD_USE_USB_DEVICE) |
embeddedartists | 26:f07df116f3c9 | 16 | #include "USBMSD_RAMFS.h" |
embeddedartists | 26:f07df116f3c9 | 17 | #include "USBSerial.h" |
embeddedartists | 26:f07df116f3c9 | 18 | #include "USBKeyboard.h" |
embeddedartists | 26:f07df116f3c9 | 19 | #include "AppUSBMouse.h" |
embeddedartists | 26:f07df116f3c9 | 20 | #endif |
embeddedartists | 26:f07df116f3c9 | 21 | #if defined(DM_BOARD_USE_USB_HOST) |
embeddedartists | 26:f07df116f3c9 | 22 | #include "USBHostMSD.h" |
embeddedartists | 26:f07df116f3c9 | 23 | #include "USBHostMouse.h" |
embeddedartists | 26:f07df116f3c9 | 24 | #include "USBHostKeyboard.h" |
embeddedartists | 26:f07df116f3c9 | 25 | #endif |
embeddedartists | 0:dfad71908d59 | 26 | #include "DMBoard.h" |
embeddedartists | 0:dfad71908d59 | 27 | |
embeddedartists | 2:070e9c054796 | 28 | #include "AppLauncher.h" |
embeddedartists | 2:070e9c054796 | 29 | #include "meas.h" |
embeddedartists | 2:070e9c054796 | 30 | |
embeddedartists | 13:57e65aba9802 | 31 | #include "AppNetworkSettings.h" |
embeddedartists | 13:57e65aba9802 | 32 | #include "AppStatus.h" |
embeddedartists | 7:c8bef6a4b019 | 33 | #include "AppTouchCalibration.h" |
embeddedartists | 7:c8bef6a4b019 | 34 | #include "AppColorPicker.h" |
embeddedartists | 7:c8bef6a4b019 | 35 | #include "AppImageViewer.h" |
embeddedartists | 7:c8bef6a4b019 | 36 | #include "AppSlideShow.h" |
embeddedartists | 18:715f542538b3 | 37 | #include "AppRTCSettings.h" |
embeddedartists | 24:768f5958c308 | 38 | //#include "AppUSBStatus.h" |
embeddedartists | 24:768f5958c308 | 39 | #include "AppDraw.h" |
embeddedartists | 7:c8bef6a4b019 | 40 | #include "image_data.h" |
alindvall | 27:4fe24decabf9 | 41 | #include "Resource.h" |
embeddedartists | 7:c8bef6a4b019 | 42 | |
embeddedartists | 2:070e9c054796 | 43 | |
embeddedartists | 0:dfad71908d59 | 44 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 45 | * Typedefs and defines |
embeddedartists | 0:dfad71908d59 | 46 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 47 | |
embeddedartists | 26:f07df116f3c9 | 48 | /* Size of RAM file system exposed to PC as USB MassStorage */ |
embeddedartists | 26:f07df116f3c9 | 49 | #define RAM_FS_SIZE (20*1024*1024) |
embeddedartists | 0:dfad71908d59 | 50 | |
embeddedartists | 0:dfad71908d59 | 51 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 52 | * Local variables |
embeddedartists | 0:dfad71908d59 | 53 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 54 | |
alindvall | 27:4fe24decabf9 | 55 | static Resource resOkButton(img_ok, img_size_ok, 40, 40); |
alindvall | 27:4fe24decabf9 | 56 | static Resource resRepeatButton(img_repeat, img_size_repeat, 40, 40); |
alindvall | 27:4fe24decabf9 | 57 | |
embeddedartists | 0:dfad71908d59 | 58 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 59 | * Global variables |
embeddedartists | 0:dfad71908d59 | 60 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 61 | |
embeddedartists | 26:f07df116f3c9 | 62 | #if defined(DM_BOARD_USE_ETHERNET) |
embeddedartists | 26:f07df116f3c9 | 63 | EthernetInterface eth; |
embeddedartists | 26:f07df116f3c9 | 64 | bool ethInitialized = false; |
embeddedartists | 26:f07df116f3c9 | 65 | bool ethUsingDHCP = true; |
embeddedartists | 26:f07df116f3c9 | 66 | #endif |
embeddedartists | 26:f07df116f3c9 | 67 | #if defined(DM_BOARD_USE_USB_HOST) |
embeddedartists | 26:f07df116f3c9 | 68 | bool haveUSBMSD = false; |
embeddedartists | 26:f07df116f3c9 | 69 | #endif |
embeddedartists | 26:f07df116f3c9 | 70 | |
embeddedartists | 26:f07df116f3c9 | 71 | #if defined(DM_BOARD_USE_USB_DEVICE) |
embeddedartists | 26:f07df116f3c9 | 72 | //#define DEMO_USB_DEVICE_MOUSE |
embeddedartists | 26:f07df116f3c9 | 73 | //#define DEMO_USB_DEVICE_SERIAL |
embeddedartists | 26:f07df116f3c9 | 74 | #define DEMO_USB_DEVICE_MSD |
embeddedartists | 26:f07df116f3c9 | 75 | #endif |
embeddedartists | 2:070e9c054796 | 76 | |
embeddedartists | 0:dfad71908d59 | 77 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 78 | * Local functions |
embeddedartists | 0:dfad71908d59 | 79 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 80 | |
embeddedartists | 30:e1cded731965 | 81 | void aliveTask(void) |
embeddedartists | 0:dfad71908d59 | 82 | { |
embeddedartists | 0:dfad71908d59 | 83 | DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:dfad71908d59 | 84 | |
embeddedartists | 0:dfad71908d59 | 85 | while(true) |
embeddedartists | 0:dfad71908d59 | 86 | { |
embeddedartists | 0:dfad71908d59 | 87 | board->setLED(DMBoard::Led4, false); |
embeddedartists | 0:dfad71908d59 | 88 | board->setLED(DMBoard::Led1, true); |
embeddedartists | 30:e1cded731965 | 89 | ThisThread::sleep_for(300); |
embeddedartists | 0:dfad71908d59 | 90 | board->setLED(DMBoard::Led1, false); |
embeddedartists | 0:dfad71908d59 | 91 | board->setLED(DMBoard::Led2, true); |
embeddedartists | 30:e1cded731965 | 92 | ThisThread::sleep_for(300); |
embeddedartists | 0:dfad71908d59 | 93 | board->setLED(DMBoard::Led2, false); |
embeddedartists | 0:dfad71908d59 | 94 | board->setLED(DMBoard::Led3, true); |
embeddedartists | 30:e1cded731965 | 95 | ThisThread::sleep_for(300); |
embeddedartists | 0:dfad71908d59 | 96 | board->setLED(DMBoard::Led3, false); |
embeddedartists | 0:dfad71908d59 | 97 | board->setLED(DMBoard::Led4, true); |
embeddedartists | 30:e1cded731965 | 98 | ThisThread::sleep_for(300); |
embeddedartists | 0:dfad71908d59 | 99 | } |
embeddedartists | 0:dfad71908d59 | 100 | } |
embeddedartists | 0:dfad71908d59 | 101 | |
embeddedartists | 0:dfad71908d59 | 102 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 2:070e9c054796 | 103 | |
embeddedartists | 7:c8bef6a4b019 | 104 | typedef enum { |
embeddedartists | 7:c8bef6a4b019 | 105 | ColorPickerApp, |
embeddedartists | 7:c8bef6a4b019 | 106 | ImageViewerApp, |
embeddedartists | 7:c8bef6a4b019 | 107 | SlideshowApp, |
embeddedartists | 7:c8bef6a4b019 | 108 | SettingsApp, |
embeddedartists | 13:57e65aba9802 | 109 | StatusApp, |
embeddedartists | 7:c8bef6a4b019 | 110 | TouchTestApp, |
embeddedartists | 18:715f542538b3 | 111 | RtcApp, |
embeddedartists | 24:768f5958c308 | 112 | USBStatusApp, |
embeddedartists | 24:768f5958c308 | 113 | DrawingApp, |
embeddedartists | 26:f07df116f3c9 | 114 | USBMouseApp, |
embeddedartists | 7:c8bef6a4b019 | 115 | CalibrationApp = AppLauncher::CalibrationApp, |
embeddedartists | 7:c8bef6a4b019 | 116 | Placeholder, |
embeddedartists | 7:c8bef6a4b019 | 117 | } myapps_t; |
embeddedartists | 7:c8bef6a4b019 | 118 | |
embeddedartists | 7:c8bef6a4b019 | 119 | static App* launchApp(uint32_t id) |
embeddedartists | 7:c8bef6a4b019 | 120 | { |
embeddedartists | 7:c8bef6a4b019 | 121 | App* a = NULL; |
embeddedartists | 7:c8bef6a4b019 | 122 | switch ((myapps_t)id) { |
embeddedartists | 7:c8bef6a4b019 | 123 | case CalibrationApp: |
embeddedartists | 7:c8bef6a4b019 | 124 | a = new AppTouchCalibration(); |
alindvall | 27:4fe24decabf9 | 125 | ((AppTouchCalibration*)a)->addResource(AppTouchCalibration::Resource_Ok_button, &resOkButton); |
embeddedartists | 7:c8bef6a4b019 | 126 | break; |
embeddedartists | 7:c8bef6a4b019 | 127 | case SettingsApp: |
embeddedartists | 13:57e65aba9802 | 128 | a = new AppNetworkSettings(); |
embeddedartists | 7:c8bef6a4b019 | 129 | break; |
embeddedartists | 7:c8bef6a4b019 | 130 | case ColorPickerApp: |
embeddedartists | 7:c8bef6a4b019 | 131 | a = new AppColorPicker(); |
alindvall | 27:4fe24decabf9 | 132 | ((AppColorPicker*)a)->addResource(AppColorPicker::Resource_Ok_button, &resOkButton); |
embeddedartists | 7:c8bef6a4b019 | 133 | break; |
embeddedartists | 7:c8bef6a4b019 | 134 | case ImageViewerApp: |
embeddedartists | 7:c8bef6a4b019 | 135 | a = new AppImageViewer(); |
embeddedartists | 7:c8bef6a4b019 | 136 | break; |
embeddedartists | 7:c8bef6a4b019 | 137 | case SlideshowApp: |
embeddedartists | 24:768f5958c308 | 138 | a = new AppSlideShow("/mci/elec14/ea_logo.txt", "/mci/elec14", 0, 0); |
alindvall | 27:4fe24decabf9 | 139 | ((AppSlideShow*)a)->addResource(AppSlideShow::Resource_Ok_button, &resOkButton); |
alindvall | 27:4fe24decabf9 | 140 | ((AppSlideShow*)a)->addResource(AppSlideShow::Resource_Repeat_button, &resRepeatButton); |
embeddedartists | 7:c8bef6a4b019 | 141 | break; |
embeddedartists | 13:57e65aba9802 | 142 | case StatusApp: |
embeddedartists | 13:57e65aba9802 | 143 | a = new AppStatus(); |
embeddedartists | 13:57e65aba9802 | 144 | break; |
embeddedartists | 18:715f542538b3 | 145 | case RtcApp: |
embeddedartists | 18:715f542538b3 | 146 | a = new AppRTCSettings(); |
embeddedartists | 18:715f542538b3 | 147 | break; |
embeddedartists | 24:768f5958c308 | 148 | case USBStatusApp: |
embeddedartists | 24:768f5958c308 | 149 | //a = new AppUSBStatus(); |
embeddedartists | 24:768f5958c308 | 150 | break; |
embeddedartists | 24:768f5958c308 | 151 | case DrawingApp: |
embeddedartists | 24:768f5958c308 | 152 | a = new AppDraw(); |
embeddedartists | 24:768f5958c308 | 153 | break; |
embeddedartists | 26:f07df116f3c9 | 154 | #if defined(DM_BOARD_USE_USB_DEVICE) && defined(DEMO_USB_DEVICE_MOUSE) |
embeddedartists | 26:f07df116f3c9 | 155 | case USBMouseApp: |
embeddedartists | 26:f07df116f3c9 | 156 | a = new AppUSBMouse(); |
embeddedartists | 26:f07df116f3c9 | 157 | break; |
embeddedartists | 26:f07df116f3c9 | 158 | #endif |
embeddedartists | 7:c8bef6a4b019 | 159 | default: |
embeddedartists | 7:c8bef6a4b019 | 160 | break; |
embeddedartists | 7:c8bef6a4b019 | 161 | } |
embeddedartists | 7:c8bef6a4b019 | 162 | return a; |
embeddedartists | 7:c8bef6a4b019 | 163 | } |
embeddedartists | 7:c8bef6a4b019 | 164 | |
embeddedartists | 2:070e9c054796 | 165 | #define SWIM_TASK_PREFIX "[SWIM] " |
embeddedartists | 30:e1cded731965 | 166 | void swimTask(void) |
embeddedartists | 2:070e9c054796 | 167 | { |
embeddedartists | 2:070e9c054796 | 168 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 2:070e9c054796 | 169 | |
embeddedartists | 2:070e9c054796 | 170 | log->printf(SWIM_TASK_PREFIX"swimTask started\n"); |
embeddedartists | 4:37a60b9bdb99 | 171 | |
embeddedartists | 2:070e9c054796 | 172 | AppLauncher launcher; |
embeddedartists | 7:c8bef6a4b019 | 173 | |
embeddedartists | 7:c8bef6a4b019 | 174 | |
embeddedartists | 2:070e9c054796 | 175 | if (launcher.setup()) { |
embeddedartists | 24:768f5958c308 | 176 | launcher.addImageButton(SettingsApp, "Network", WHITE, img_preferences_system_network, img_size_preferences_system_network); |
embeddedartists | 24:768f5958c308 | 177 | launcher.addImageButton(DrawingApp, "Drawing", WHITE, img_bijiben, img_size_bijiben); |
embeddedartists | 24:768f5958c308 | 178 | launcher.addImageButton(SlideshowApp, "Slideshow", WHITE, img_multimedia_photo_manager, img_size_multimedia_photo_manager); |
embeddedartists | 7:c8bef6a4b019 | 179 | //launcher.addImageButton(TouchGFXApp, "TouchGFX"); |
embeddedartists | 7:c8bef6a4b019 | 180 | //launcher.addImageButton(EmWinApp, "emWin"); |
embeddedartists | 24:768f5958c308 | 181 | launcher.addImageButton(ColorPickerApp, "Color Picker", WHITE, img_preferences_color, img_size_preferences_color); |
embeddedartists | 24:768f5958c308 | 182 | launcher.addImageButton(ImageViewerApp, "Image Viewer", WHITE, img_multimedia_photo_manager, img_size_multimedia_photo_manager); |
embeddedartists | 24:768f5958c308 | 183 | launcher.addImageButton(StatusApp, "About", WHITE, img_utilities_system_monitor, img_size_utilities_system_monitor); |
embeddedartists | 26:f07df116f3c9 | 184 | #if defined(DM_BOARD_USE_USB_DEVICE) && defined(DEMO_USB_DEVICE_MOUSE) |
embeddedartists | 26:f07df116f3c9 | 185 | launcher.addImageButton(USBMouseApp, "USB Mouse", WHITE, img_unetbootin, img_size_unetbootin); |
embeddedartists | 26:f07df116f3c9 | 186 | #else |
embeddedartists | 24:768f5958c308 | 187 | launcher.addImageButton(Placeholder, "USB Status", WHITE, img_unetbootin, img_size_unetbootin); |
embeddedartists | 26:f07df116f3c9 | 188 | #endif |
embeddedartists | 24:768f5958c308 | 189 | launcher.addImageButton(RtcApp, "Clock", WHITE, img_preferences_system_time, img_size_preferences_system_time); |
embeddedartists | 4:37a60b9bdb99 | 190 | |
embeddedartists | 7:c8bef6a4b019 | 191 | launcher.setAppCreatorFunc(launchApp); |
embeddedartists | 2:070e9c054796 | 192 | log->printf(SWIM_TASK_PREFIX"Starting menu system\n"); |
embeddedartists | 2:070e9c054796 | 193 | launcher.runToCompletion(); |
embeddedartists | 2:070e9c054796 | 194 | launcher.teardown(); |
embeddedartists | 2:070e9c054796 | 195 | } else { |
embeddedartists | 4:37a60b9bdb99 | 196 | log->printf(SWIM_TASK_PREFIX"Failed to prepare menu system\n"); |
embeddedartists | 2:070e9c054796 | 197 | } |
embeddedartists | 2:070e9c054796 | 198 | |
embeddedartists | 2:070e9c054796 | 199 | // Should never end up here |
embeddedartists | 2:070e9c054796 | 200 | mbed_die(); |
embeddedartists | 2:070e9c054796 | 201 | } |
embeddedartists | 2:070e9c054796 | 202 | |
embeddedartists | 0:dfad71908d59 | 203 | #endif //DM_BOARD_USE_DISPLAY |
embeddedartists | 0:dfad71908d59 | 204 | |
embeddedartists | 26:f07df116f3c9 | 205 | #if defined(DM_BOARD_USE_ETHERNET) |
embeddedartists | 0:dfad71908d59 | 206 | |
embeddedartists | 26:f07df116f3c9 | 207 | #define NET_TASK_PREFIX "[NET] " |
embeddedartists | 30:e1cded731965 | 208 | void netTask(void) |
embeddedartists | 26:f07df116f3c9 | 209 | { |
embeddedartists | 26:f07df116f3c9 | 210 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 30:e1cded731965 | 211 | log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n"); |
embeddedartists | 30:e1cded731965 | 212 | |
embeddedartists | 30:e1cded731965 | 213 | nsapi_error_t net_err = eth.connect(); |
embeddedartists | 30:e1cded731965 | 214 | |
embeddedartists | 30:e1cded731965 | 215 | if (net_err != NSAPI_ERROR_OK) { |
embeddedartists | 30:e1cded731965 | 216 | log->printf(NET_TASK_PREFIX"EthernetInterface connect Error %d\r\n", net_err); |
embeddedartists | 30:e1cded731965 | 217 | } |
embeddedartists | 30:e1cded731965 | 218 | else { |
embeddedartists | 30:e1cded731965 | 219 | |
embeddedartists | 30:e1cded731965 | 220 | ethInitialized = true; |
embeddedartists | 30:e1cded731965 | 221 | ethUsingDHCP = true; |
embeddedartists | 26:f07df116f3c9 | 222 | |
embeddedartists | 30:e1cded731965 | 223 | log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.get_ip_address()); |
embeddedartists | 30:e1cded731965 | 224 | log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.get_netmask()); |
embeddedartists | 30:e1cded731965 | 225 | log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.get_gateway()); |
embeddedartists | 30:e1cded731965 | 226 | log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n"); |
embeddedartists | 0:dfad71908d59 | 227 | |
embeddedartists | 30:e1cded731965 | 228 | HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler |
embeddedartists | 30:e1cded731965 | 229 | FSHandler::mount("/mci", "/"); |
embeddedartists | 30:e1cded731965 | 230 | HTTPServerAddHandler<FSHandler>("/"); |
embeddedartists | 30:e1cded731965 | 231 | //lcd.locate(0,0); |
embeddedartists | 30:e1cded731965 | 232 | //lcd.printf("%s",eth.getIPAddress()); |
embeddedartists | 30:e1cded731965 | 233 | HTTPServerStart(80); |
embeddedartists | 30:e1cded731965 | 234 | |
embeddedartists | 30:e1cded731965 | 235 | } |
embeddedartists | 30:e1cded731965 | 236 | |
embeddedartists | 30:e1cded731965 | 237 | |
embeddedartists | 26:f07df116f3c9 | 238 | } |
embeddedartists | 26:f07df116f3c9 | 239 | #endif //DM_BOARD_USE_ETHERNET |
embeddedartists | 0:dfad71908d59 | 240 | |
embeddedartists | 26:f07df116f3c9 | 241 | #if defined(DM_BOARD_USE_USB_HOST) |
embeddedartists | 26:f07df116f3c9 | 242 | static volatile int mouse_button, mouse_x, mouse_y, mouse_z; |
embeddedartists | 13:57e65aba9802 | 243 | static uint16_t cursor_x=0, cursor_y=0; |
embeddedartists | 1:15ea03d72dd7 | 244 | void mouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) |
embeddedartists | 1:15ea03d72dd7 | 245 | { |
embeddedartists | 1:15ea03d72dd7 | 246 | mouse_button = buttons; |
embeddedartists | 1:15ea03d72dd7 | 247 | mouse_x = x; |
embeddedartists | 1:15ea03d72dd7 | 248 | mouse_y = y; |
embeddedartists | 1:15ea03d72dd7 | 249 | mouse_z = z; |
embeddedartists | 13:57e65aba9802 | 250 | |
embeddedartists | 13:57e65aba9802 | 251 | if (x < 0) { |
embeddedartists | 13:57e65aba9802 | 252 | if (cursor_x > -x) { |
embeddedartists | 13:57e65aba9802 | 253 | cursor_x += x; |
embeddedartists | 13:57e65aba9802 | 254 | } else { |
embeddedartists | 13:57e65aba9802 | 255 | cursor_x = 0; |
embeddedartists | 13:57e65aba9802 | 256 | } |
embeddedartists | 13:57e65aba9802 | 257 | } else { |
embeddedartists | 13:57e65aba9802 | 258 | if ((cursor_x + x) >= 480) { |
embeddedartists | 13:57e65aba9802 | 259 | cursor_x = 479; |
embeddedartists | 13:57e65aba9802 | 260 | } else { |
embeddedartists | 13:57e65aba9802 | 261 | cursor_x += x; |
embeddedartists | 13:57e65aba9802 | 262 | } |
embeddedartists | 13:57e65aba9802 | 263 | } |
embeddedartists | 26:f07df116f3c9 | 264 | |
embeddedartists | 13:57e65aba9802 | 265 | if (y < 0) { |
embeddedartists | 13:57e65aba9802 | 266 | if (cursor_y > -y) { |
embeddedartists | 13:57e65aba9802 | 267 | cursor_y += y; |
embeddedartists | 13:57e65aba9802 | 268 | } else { |
embeddedartists | 13:57e65aba9802 | 269 | cursor_y = 0; |
embeddedartists | 13:57e65aba9802 | 270 | } |
embeddedartists | 13:57e65aba9802 | 271 | } else { |
embeddedartists | 13:57e65aba9802 | 272 | if ((cursor_y + y) >= 272) { |
embeddedartists | 13:57e65aba9802 | 273 | cursor_y = 271; |
embeddedartists | 13:57e65aba9802 | 274 | } else { |
embeddedartists | 13:57e65aba9802 | 275 | cursor_y += y; |
embeddedartists | 13:57e65aba9802 | 276 | } |
embeddedartists | 13:57e65aba9802 | 277 | } |
embeddedartists | 13:57e65aba9802 | 278 | |
embeddedartists | 13:57e65aba9802 | 279 | //Chip_LCD_Cursor_SetPos(LPC_LCD, cursor_x, cursor_y); |
embeddedartists | 13:57e65aba9802 | 280 | LPC_LCD->CRSR_XY = (cursor_x & 0x3FF) | ((cursor_y & 0x3FF) << 16); |
embeddedartists | 13:57e65aba9802 | 281 | } |
embeddedartists | 13:57e65aba9802 | 282 | |
embeddedartists | 13:57e65aba9802 | 283 | #define LCD_CURSOR_32x32 0 |
embeddedartists | 13:57e65aba9802 | 284 | #define LCD_CURSOR_64x64 1 |
embeddedartists | 13:57e65aba9802 | 285 | #define CURSOR_SIZE LCD_CURSOR_32x32 |
embeddedartists | 13:57e65aba9802 | 286 | #define CURSOR_H_SIZE 32 |
embeddedartists | 13:57e65aba9802 | 287 | #define CURSOR_V_SIZE 32 |
embeddedartists | 13:57e65aba9802 | 288 | #define CURSOR_NUM 0 |
embeddedartists | 13:57e65aba9802 | 289 | #define CURSOR_H_OFS (10) |
embeddedartists | 13:57e65aba9802 | 290 | #define CURSOR_V_OFS (6) |
embeddedartists | 13:57e65aba9802 | 291 | |
embeddedartists | 13:57e65aba9802 | 292 | const unsigned char __attribute__ ((aligned(4))) Cursor[(CURSOR_H_SIZE / 4) * CURSOR_V_SIZE] = |
embeddedartists | 13:57e65aba9802 | 293 | { |
embeddedartists | 13:57e65aba9802 | 294 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 295 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 296 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 297 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 298 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 299 | 0xAA, 0xAA, 0xAA, 0xFA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 300 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 301 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 302 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 303 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 304 | 0xAA, 0xAA, 0xAB, 0xFF, 0xEA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 305 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 306 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 307 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 308 | 0xAA, 0xAB, 0xFB, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 309 | 0xAA, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 310 | 0xAA, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 311 | 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 312 | 0xAA, 0xAA, 0xBF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 313 | 0xAA, 0xAA, 0xBF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 314 | 0xAA, 0xAA, 0xAF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 315 | 0xAA, 0xAA, 0xAF, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 316 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 317 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 318 | 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 319 | 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 320 | 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 321 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 322 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 323 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 324 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 325 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA |
embeddedartists | 13:57e65aba9802 | 326 | }; |
embeddedartists | 13:57e65aba9802 | 327 | |
embeddedartists | 13:57e65aba9802 | 328 | void prepareCursor(bool enable) { |
embeddedartists | 26:f07df116f3c9 | 329 | //Chip_LCD_Cursor_Disable(LPC_LCD, 0); |
embeddedartists | 13:57e65aba9802 | 330 | LPC_LCD->CRSR_CTRL = (CURSOR_NUM << 4); |
embeddedartists | 13:57e65aba9802 | 331 | |
embeddedartists | 13:57e65aba9802 | 332 | if (enable) { |
embeddedartists | 13:57e65aba9802 | 333 | //Chip_LCD_Cursor_Config(LPC_LCD, LCD_CURSOR_32x32, true); |
embeddedartists | 13:57e65aba9802 | 334 | LPC_LCD->CRSR_CFG = ((true ? 1 : 0) << 1) | CURSOR_SIZE; |
embeddedartists | 13:57e65aba9802 | 335 | |
embeddedartists | 13:57e65aba9802 | 336 | //Chip_LCD_Cursor_WriteImage(LPC_LCD, 0, (void *) Cursor); |
embeddedartists | 13:57e65aba9802 | 337 | { |
embeddedartists | 13:57e65aba9802 | 338 | int i, j; |
embeddedartists | 13:57e65aba9802 | 339 | uint32_t *fifoptr, *crsr_ptr = (uint32_t *) Cursor; |
embeddedartists | 13:57e65aba9802 | 340 | |
embeddedartists | 13:57e65aba9802 | 341 | /* Check if Cursor Size was configured as 32x32 or 64x64*/ |
embeddedartists | 13:57e65aba9802 | 342 | if (CURSOR_SIZE == LCD_CURSOR_32x32) { |
embeddedartists | 13:57e65aba9802 | 343 | i = CURSOR_NUM * 64; |
embeddedartists | 13:57e65aba9802 | 344 | j = i + 64; |
embeddedartists | 13:57e65aba9802 | 345 | } |
embeddedartists | 13:57e65aba9802 | 346 | else { |
embeddedartists | 13:57e65aba9802 | 347 | i = 0; |
embeddedartists | 13:57e65aba9802 | 348 | j = 256; |
embeddedartists | 13:57e65aba9802 | 349 | } |
embeddedartists | 13:57e65aba9802 | 350 | fifoptr = (uint32_t *) &(LPC_LCD->CRSR_IMG[0]); |
embeddedartists | 13:57e65aba9802 | 351 | |
embeddedartists | 13:57e65aba9802 | 352 | /* Copy Cursor Image content to FIFO */ |
embeddedartists | 13:57e65aba9802 | 353 | for (; i < j; i++) { |
embeddedartists | 13:57e65aba9802 | 354 | |
embeddedartists | 13:57e65aba9802 | 355 | *fifoptr = *crsr_ptr; |
embeddedartists | 13:57e65aba9802 | 356 | crsr_ptr++; |
embeddedartists | 13:57e65aba9802 | 357 | fifoptr++; |
embeddedartists | 13:57e65aba9802 | 358 | } |
embeddedartists | 13:57e65aba9802 | 359 | } |
embeddedartists | 13:57e65aba9802 | 360 | |
embeddedartists | 13:57e65aba9802 | 361 | //Chip_LCD_Cursor_SetClip(LPC_LCD, CURSOR_H_OFS, CURSOR_V_OFS); |
embeddedartists | 13:57e65aba9802 | 362 | LPC_LCD->CRSR_CLIP = (CURSOR_H_OFS & 0x3F) | ((CURSOR_V_OFS & 0x3F) << 8); |
embeddedartists | 13:57e65aba9802 | 363 | |
embeddedartists | 13:57e65aba9802 | 364 | //Chip_LCD_Cursor_SetPos(LPC_LCD, cursor_x, cursor_y); |
embeddedartists | 13:57e65aba9802 | 365 | |
embeddedartists | 13:57e65aba9802 | 366 | //Chip_LCD_Cursor_Enable(LPC_LCD, 0); |
embeddedartists | 13:57e65aba9802 | 367 | LPC_LCD->CRSR_CTRL = (CURSOR_NUM << 4) | 1; |
embeddedartists | 13:57e65aba9802 | 368 | } |
embeddedartists | 1:15ea03d72dd7 | 369 | } |
embeddedartists | 1:15ea03d72dd7 | 370 | |
embeddedartists | 1:15ea03d72dd7 | 371 | |
embeddedartists | 1:15ea03d72dd7 | 372 | #define CIRCBUFF_SIZE 256 |
embeddedartists | 24:768f5958c308 | 373 | static volatile uint8_t circbuff[CIRCBUFF_SIZE]; |
embeddedartists | 24:768f5958c308 | 374 | static volatile uint32_t circbuff_read = 0; |
embeddedartists | 1:15ea03d72dd7 | 375 | static uint32_t circbuff_write = 0; |
embeddedartists | 1:15ea03d72dd7 | 376 | void keyEvent(uint8_t key) |
embeddedartists | 1:15ea03d72dd7 | 377 | { |
embeddedartists | 1:15ea03d72dd7 | 378 | circbuff[circbuff_write%CIRCBUFF_SIZE] = key; |
embeddedartists | 1:15ea03d72dd7 | 379 | circbuff_write++; |
embeddedartists | 1:15ea03d72dd7 | 380 | } |
embeddedartists | 1:15ea03d72dd7 | 381 | |
embeddedartists | 1:15ea03d72dd7 | 382 | |
embeddedartists | 26:f07df116f3c9 | 383 | #define USBH_TASK_PREFIX "[USBH] " |
embeddedartists | 26:f07df116f3c9 | 384 | #define USBH_CONNECTION_EVENT (1<<4) |
embeddedartists | 30:e1cded731965 | 385 | void usbHostTask(void) |
embeddedartists | 18:715f542538b3 | 386 | { |
embeddedartists | 18:715f542538b3 | 387 | bool msdConnected = false; |
embeddedartists | 18:715f542538b3 | 388 | bool keyboardConnected = false; |
embeddedartists | 18:715f542538b3 | 389 | bool mouseConnected = false; |
embeddedartists | 18:715f542538b3 | 390 | |
embeddedartists | 18:715f542538b3 | 391 | USBHostMSD* msd = new USBHostMSD("usb"); |
embeddedartists | 18:715f542538b3 | 392 | USBHostKeyboard* keyboard = new USBHostKeyboard(); |
embeddedartists | 18:715f542538b3 | 393 | USBHostMouse* mouse = new USBHostMouse(); |
embeddedartists | 18:715f542538b3 | 394 | USBHost* host = USBHost::getHostInst(); |
embeddedartists | 30:e1cded731965 | 395 | EventFlags connectionEvent; |
embeddedartists | 30:e1cded731965 | 396 | host->signalOnConnections(&connectionEvent, USBH_CONNECTION_EVENT); |
embeddedartists | 18:715f542538b3 | 397 | |
embeddedartists | 18:715f542538b3 | 398 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 18:715f542538b3 | 399 | |
embeddedartists | 26:f07df116f3c9 | 400 | log->printf(USBH_TASK_PREFIX"Started\n"); |
embeddedartists | 18:715f542538b3 | 401 | |
embeddedartists | 18:715f542538b3 | 402 | prepareCursor(false); |
embeddedartists | 18:715f542538b3 | 403 | |
embeddedartists | 18:715f542538b3 | 404 | while (true) { |
embeddedartists | 30:e1cded731965 | 405 | |
embeddedartists | 18:715f542538b3 | 406 | // wait for connect/disconnect message from USBHost |
embeddedartists | 30:e1cded731965 | 407 | connectionEvent.wait_any(USBH_CONNECTION_EVENT); |
embeddedartists | 26:f07df116f3c9 | 408 | log->printf(USBH_TASK_PREFIX"got USB event\n"); |
embeddedartists | 30:e1cded731965 | 409 | |
embeddedartists | 18:715f542538b3 | 410 | if (msd->connected()) { |
embeddedartists | 18:715f542538b3 | 411 | if (!msdConnected) { |
embeddedartists | 18:715f542538b3 | 412 | msdConnected = true; |
embeddedartists | 18:715f542538b3 | 413 | haveUSBMSD = true; |
embeddedartists | 26:f07df116f3c9 | 414 | log->printf(USBH_TASK_PREFIX"USB MassStorage Device - Connected\n"); |
embeddedartists | 18:715f542538b3 | 415 | } |
embeddedartists | 18:715f542538b3 | 416 | } else { |
embeddedartists | 18:715f542538b3 | 417 | if (msdConnected) { |
embeddedartists | 18:715f542538b3 | 418 | msdConnected = false; |
embeddedartists | 18:715f542538b3 | 419 | haveUSBMSD = false; |
embeddedartists | 26:f07df116f3c9 | 420 | log->printf(USBH_TASK_PREFIX"USB MassStorage Device - Ejected\n"); |
embeddedartists | 18:715f542538b3 | 421 | } |
embeddedartists | 18:715f542538b3 | 422 | |
embeddedartists | 18:715f542538b3 | 423 | if (msd->connect()) { |
embeddedartists | 18:715f542538b3 | 424 | msdConnected = true; |
embeddedartists | 18:715f542538b3 | 425 | haveUSBMSD = true; |
embeddedartists | 26:f07df116f3c9 | 426 | log->printf(USBH_TASK_PREFIX"USB MassStorage Device - Connected\n"); |
embeddedartists | 18:715f542538b3 | 427 | } |
embeddedartists | 18:715f542538b3 | 428 | } |
embeddedartists | 18:715f542538b3 | 429 | |
embeddedartists | 18:715f542538b3 | 430 | if (keyboard->connected()) { |
embeddedartists | 18:715f542538b3 | 431 | if (!keyboardConnected) { |
embeddedartists | 18:715f542538b3 | 432 | keyboardConnected = true; |
embeddedartists | 26:f07df116f3c9 | 433 | log->printf(USBH_TASK_PREFIX"USB Keyboard - Connected\n"); |
embeddedartists | 18:715f542538b3 | 434 | keyboard->attach(keyEvent); |
embeddedartists | 18:715f542538b3 | 435 | } |
embeddedartists | 18:715f542538b3 | 436 | } else { |
embeddedartists | 18:715f542538b3 | 437 | if (keyboardConnected) { |
embeddedartists | 18:715f542538b3 | 438 | keyboardConnected = false; |
embeddedartists | 26:f07df116f3c9 | 439 | log->printf(USBH_TASK_PREFIX"USB Keyboard - Ejected\n"); |
embeddedartists | 18:715f542538b3 | 440 | } |
embeddedartists | 18:715f542538b3 | 441 | if (keyboard->connect()) { |
embeddedartists | 18:715f542538b3 | 442 | keyboardConnected = true; |
embeddedartists | 26:f07df116f3c9 | 443 | log->printf(USBH_TASK_PREFIX"USB Keyboard - Connected\n"); |
embeddedartists | 18:715f542538b3 | 444 | keyboard->attach(keyEvent); |
embeddedartists | 18:715f542538b3 | 445 | } |
embeddedartists | 18:715f542538b3 | 446 | } |
embeddedartists | 18:715f542538b3 | 447 | |
embeddedartists | 18:715f542538b3 | 448 | if (mouse->connected()) { |
embeddedartists | 18:715f542538b3 | 449 | if (!mouseConnected) { |
embeddedartists | 18:715f542538b3 | 450 | mouseConnected = true; |
embeddedartists | 26:f07df116f3c9 | 451 | log->printf(USBH_TASK_PREFIX"USB Mouse - Connected\n"); |
embeddedartists | 18:715f542538b3 | 452 | mouse->attachEvent(mouseEvent); |
embeddedartists | 18:715f542538b3 | 453 | prepareCursor(true); |
embeddedartists | 18:715f542538b3 | 454 | } |
embeddedartists | 18:715f542538b3 | 455 | } else { |
embeddedartists | 18:715f542538b3 | 456 | if (mouseConnected) { |
embeddedartists | 18:715f542538b3 | 457 | prepareCursor(false); |
embeddedartists | 18:715f542538b3 | 458 | mouseConnected = false; |
embeddedartists | 26:f07df116f3c9 | 459 | log->printf(USBH_TASK_PREFIX"USB Mouse - Ejected\n"); |
embeddedartists | 18:715f542538b3 | 460 | } |
embeddedartists | 18:715f542538b3 | 461 | if (mouse->connect()) { |
embeddedartists | 18:715f542538b3 | 462 | mouseConnected = true; |
embeddedartists | 26:f07df116f3c9 | 463 | log->printf(USBH_TASK_PREFIX"USB Mouse - Connected\n"); |
embeddedartists | 18:715f542538b3 | 464 | mouse->attachEvent(mouseEvent); |
embeddedartists | 18:715f542538b3 | 465 | prepareCursor(true); |
embeddedartists | 18:715f542538b3 | 466 | } |
embeddedartists | 18:715f542538b3 | 467 | } |
embeddedartists | 30:e1cded731965 | 468 | |
embeddedartists | 18:715f542538b3 | 469 | } |
embeddedartists | 18:715f542538b3 | 470 | } |
embeddedartists | 18:715f542538b3 | 471 | |
embeddedartists | 26:f07df116f3c9 | 472 | #endif //DM_BOARD_USE_USB_HOST |
embeddedartists | 26:f07df116f3c9 | 473 | |
embeddedartists | 26:f07df116f3c9 | 474 | #if defined(DM_BOARD_USE_USB_DEVICE) |
embeddedartists | 26:f07df116f3c9 | 475 | |
embeddedartists | 26:f07df116f3c9 | 476 | #define USBD_TASK_PREFIX "[USBD] " |
embeddedartists | 26:f07df116f3c9 | 477 | //#define USBD_CONNECTION_EVENT (1<<4) |
embeddedartists | 30:e1cded731965 | 478 | void usbDeviceTask(void) |
embeddedartists | 26:f07df116f3c9 | 479 | { |
embeddedartists | 26:f07df116f3c9 | 480 | DMBoard* board = &DMBoard::instance(); |
embeddedartists | 26:f07df116f3c9 | 481 | RtosLog* log = board->logger(); |
embeddedartists | 26:f07df116f3c9 | 482 | |
embeddedartists | 26:f07df116f3c9 | 483 | log->printf(USBD_TASK_PREFIX"Started\n"); |
embeddedartists | 26:f07df116f3c9 | 484 | |
embeddedartists | 26:f07df116f3c9 | 485 | // Possibilities: |
embeddedartists | 26:f07df116f3c9 | 486 | // - MassStorage |
embeddedartists | 26:f07df116f3c9 | 487 | // * RAM file system |
embeddedartists | 26:f07df116f3c9 | 488 | // a) For editing of settings or registry |
embeddedartists | 26:f07df116f3c9 | 489 | // b) To give user an html file with information |
embeddedartists | 26:f07df116f3c9 | 490 | // c) For BIOS updating |
embeddedartists | 26:f07df116f3c9 | 491 | // * Expose MCI file system |
embeddedartists | 26:f07df116f3c9 | 492 | // - Serial |
embeddedartists | 26:f07df116f3c9 | 493 | // * Let RtosLogger use the USBDevice serial port instead to |
embeddedartists | 26:f07df116f3c9 | 494 | // allow prints during debugging |
embeddedartists | 26:f07df116f3c9 | 495 | // - Mouse |
embeddedartists | 26:f07df116f3c9 | 496 | // * Use the display as a "trackpad" |
embeddedartists | 26:f07df116f3c9 | 497 | // - Keyboard |
embeddedartists | 26:f07df116f3c9 | 498 | // * Could be used by the RtosLogger (for fun) |
embeddedartists | 26:f07df116f3c9 | 499 | // * Write our logo in ASCII art (for fun) |
embeddedartists | 26:f07df116f3c9 | 500 | // - Audio? |
embeddedartists | 26:f07df116f3c9 | 501 | // - CDC? |
embeddedartists | 26:f07df116f3c9 | 502 | |
embeddedartists | 26:f07df116f3c9 | 503 | #if defined(DEMO_USB_DEVICE_MSD) |
embeddedartists | 26:f07df116f3c9 | 504 | // USBDevice: MassStorage - Expose a 5MB RAM file system |
embeddedartists | 26:f07df116f3c9 | 505 | // |
embeddedartists | 26:f07df116f3c9 | 506 | // Notes: |
embeddedartists | 26:f07df116f3c9 | 507 | // * Copying the large file to the PC at ca 512Kbyte per second |
embeddedartists | 26:f07df116f3c9 | 508 | // * Copying a large file to the board at ca 800Kbyte per second |
embeddedartists | 26:f07df116f3c9 | 509 | void* fsmem = malloc(RAM_FS_SIZE); |
embeddedartists | 26:f07df116f3c9 | 510 | if (fsmem == NULL) { |
embeddedartists | 26:f07df116f3c9 | 511 | log->printf("Failed to allocate memory for RAM file system\n"); |
embeddedartists | 26:f07df116f3c9 | 512 | mbed_die(); |
embeddedartists | 26:f07df116f3c9 | 513 | } |
embeddedartists | 26:f07df116f3c9 | 514 | RAMFileSystem ramfs((uint32_t)fsmem, RAM_FS_SIZE, "ram"); |
embeddedartists | 26:f07df116f3c9 | 515 | USBMSD_RAMFS usbmsd(&ramfs); |
embeddedartists | 26:f07df116f3c9 | 516 | ramfs.format(); |
embeddedartists | 26:f07df116f3c9 | 517 | |
embeddedartists | 26:f07df116f3c9 | 518 | // Create test file that user can modify |
embeddedartists | 26:f07df116f3c9 | 519 | FILE* f = fopen("/ram/message.txt", "w"); |
embeddedartists | 26:f07df116f3c9 | 520 | if (f != NULL) { |
embeddedartists | 26:f07df116f3c9 | 521 | fwrite("Hello World!\n", 1, 13, f); |
embeddedartists | 26:f07df116f3c9 | 522 | fclose(f); |
embeddedartists | 26:f07df116f3c9 | 523 | } |
embeddedartists | 26:f07df116f3c9 | 524 | |
embeddedartists | 26:f07df116f3c9 | 525 | // Create benchmark file |
embeddedartists | 26:f07df116f3c9 | 526 | uint32_t benchSize = RAM_FS_SIZE - 1*1024*1024; |
embeddedartists | 26:f07df116f3c9 | 527 | log->printf(USBD_TASK_PREFIX"Generating %dMB benchmarking file...\n", benchSize/(1024*1024)); |
embeddedartists | 26:f07df116f3c9 | 528 | char buff[512+1] = {0}; |
embeddedartists | 26:f07df116f3c9 | 529 | for (int i = 0; i < 512; i++) { |
embeddedartists | 26:f07df116f3c9 | 530 | buff[i] = i; |
embeddedartists | 26:f07df116f3c9 | 531 | } |
embeddedartists | 26:f07df116f3c9 | 532 | f = fopen("/ram/bench.bin", "w"); |
embeddedartists | 26:f07df116f3c9 | 533 | if (f != NULL) { |
embeddedartists | 26:f07df116f3c9 | 534 | for (int i = 0; i < (benchSize/512); i++) { |
embeddedartists | 26:f07df116f3c9 | 535 | fwrite(buff, 1, 512, f); |
embeddedartists | 26:f07df116f3c9 | 536 | } |
embeddedartists | 26:f07df116f3c9 | 537 | fclose(f); |
embeddedartists | 26:f07df116f3c9 | 538 | } |
embeddedartists | 26:f07df116f3c9 | 539 | log->printf(USBD_TASK_PREFIX"Finished generating /ram/bench.bin\n"); |
embeddedartists | 26:f07df116f3c9 | 540 | |
embeddedartists | 26:f07df116f3c9 | 541 | while (true) { |
embeddedartists | 26:f07df116f3c9 | 542 | if (usbmsd.connect()) { |
embeddedartists | 26:f07df116f3c9 | 543 | log->printf(USBD_TASK_PREFIX"USB MassStorage - Connected\n"); |
embeddedartists | 26:f07df116f3c9 | 544 | log->printf(USBD_TASK_PREFIX"Press USER button to disconnect USB MassStorage!\n"); |
embeddedartists | 26:f07df116f3c9 | 545 | while (!board->buttonPressed()) { |
embeddedartists | 26:f07df116f3c9 | 546 | Thread::wait(50); |
embeddedartists | 26:f07df116f3c9 | 547 | } |
embeddedartists | 26:f07df116f3c9 | 548 | log->printf(USBD_TASK_PREFIX"User requested USB disconnect\n"); |
embeddedartists | 26:f07df116f3c9 | 549 | usbmsd.disconnect(); |
embeddedartists | 26:f07df116f3c9 | 550 | while (board->buttonPressed()) { |
embeddedartists | 26:f07df116f3c9 | 551 | Thread::wait(50); |
embeddedartists | 26:f07df116f3c9 | 552 | } |
embeddedartists | 26:f07df116f3c9 | 553 | log->printf(USBD_TASK_PREFIX"USB disconnected\n"); |
embeddedartists | 26:f07df116f3c9 | 554 | |
embeddedartists | 26:f07df116f3c9 | 555 | { |
embeddedartists | 26:f07df116f3c9 | 556 | log->printf("Reading /ram/message.txt:\n"); |
embeddedartists | 26:f07df116f3c9 | 557 | f = fopen("/ram/message.txt", "r"); |
embeddedartists | 26:f07df116f3c9 | 558 | if (f != NULL) { |
embeddedartists | 26:f07df116f3c9 | 559 | while (true) { |
embeddedartists | 26:f07df116f3c9 | 560 | size_t num = fread(buff, 1, 512, f); |
embeddedartists | 26:f07df116f3c9 | 561 | if (num > 0) { |
embeddedartists | 26:f07df116f3c9 | 562 | buff[num] = '\0'; |
embeddedartists | 26:f07df116f3c9 | 563 | log->printf(buff); |
embeddedartists | 26:f07df116f3c9 | 564 | } else { |
embeddedartists | 26:f07df116f3c9 | 565 | break; |
embeddedartists | 26:f07df116f3c9 | 566 | } |
embeddedartists | 26:f07df116f3c9 | 567 | } |
embeddedartists | 26:f07df116f3c9 | 568 | fclose(f); |
embeddedartists | 26:f07df116f3c9 | 569 | log->printf("\nEOF\n"); |
embeddedartists | 26:f07df116f3c9 | 570 | } else { |
embeddedartists | 26:f07df116f3c9 | 571 | log->printf("Failed to read /ram/message.txt\n"); |
embeddedartists | 26:f07df116f3c9 | 572 | } |
embeddedartists | 26:f07df116f3c9 | 573 | } |
embeddedartists | 26:f07df116f3c9 | 574 | |
embeddedartists | 26:f07df116f3c9 | 575 | log->printf("\n"USBD_TASK_PREFIX"Press USER button to connect USB MassStorage again!\n"); |
embeddedartists | 26:f07df116f3c9 | 576 | while (!board->buttonPressed()) { |
embeddedartists | 26:f07df116f3c9 | 577 | Thread::wait(50); |
embeddedartists | 26:f07df116f3c9 | 578 | } |
embeddedartists | 26:f07df116f3c9 | 579 | while (board->buttonPressed()) { |
embeddedartists | 26:f07df116f3c9 | 580 | Thread::wait(50); |
embeddedartists | 26:f07df116f3c9 | 581 | } |
embeddedartists | 26:f07df116f3c9 | 582 | log->printf(USBD_TASK_PREFIX"User requested to connect USB again\n"); |
embeddedartists | 26:f07df116f3c9 | 583 | } |
embeddedartists | 26:f07df116f3c9 | 584 | } |
embeddedartists | 26:f07df116f3c9 | 585 | #endif // #if defined(DEMO_USB_DEVICE_MSD) |
embeddedartists | 26:f07df116f3c9 | 586 | |
embeddedartists | 26:f07df116f3c9 | 587 | #if defined(DEMO_USB_DEVICE_SERIAL) |
embeddedartists | 26:f07df116f3c9 | 588 | // USBDevice: Serial (see http://developer.mbed.org/handbook/USBSerial) |
embeddedartists | 26:f07df116f3c9 | 589 | // http://developer.mbed.org/questions/5872/User-Friendly-Installation-of-USBSerial-/ |
embeddedartists | 26:f07df116f3c9 | 590 | // |
embeddedartists | 26:f07df116f3c9 | 591 | // Notes: |
embeddedartists | 26:f07df116f3c9 | 592 | // * Works, but a reset (e.g. Alt-B) requires the USB cable to be ejected+inserted |
embeddedartists | 26:f07df116f3c9 | 593 | // for the PC to see the COM port again. It does not help to restart the Terminal |
embeddedartists | 26:f07df116f3c9 | 594 | // program |
embeddedartists | 26:f07df116f3c9 | 595 | // * Unplugging the USB cable after the terminal program on the PC has connected |
embeddedartists | 26:f07df116f3c9 | 596 | // and then plugging it in again does not work. The terminal program will not see |
embeddedartists | 26:f07df116f3c9 | 597 | // the port until after a bord reset. |
embeddedartists | 26:f07df116f3c9 | 598 | // Update: This seems to be the Terminal Program's fault. Restarting the terminal |
embeddedartists | 26:f07df116f3c9 | 599 | // program will make the port appear again. |
embeddedartists | 26:f07df116f3c9 | 600 | // * It is possible to have the cable connected before powering up as well as connecting |
embeddedartists | 26:f07df116f3c9 | 601 | // the cable after powering up. |
embeddedartists | 26:f07df116f3c9 | 602 | #if defined(DM_BOARD_USE_USBSERIAL_IN_RTOSLOG) |
embeddedartists | 26:f07df116f3c9 | 603 | int counter = 0; |
embeddedartists | 26:f07df116f3c9 | 604 | while(true) { |
embeddedartists | 26:f07df116f3c9 | 605 | Thread::wait(1000); |
embeddedartists | 26:f07df116f3c9 | 606 | log->printf(USBD_TASK_PREFIX"Counter %3d\n", counter++); |
embeddedartists | 26:f07df116f3c9 | 607 | } |
embeddedartists | 26:f07df116f3c9 | 608 | #else |
embeddedartists | 26:f07df116f3c9 | 609 | USBSerial s; |
embeddedartists | 26:f07df116f3c9 | 610 | int counter = 0; |
embeddedartists | 26:f07df116f3c9 | 611 | while(true) { |
embeddedartists | 26:f07df116f3c9 | 612 | Thread::wait(1000); |
embeddedartists | 26:f07df116f3c9 | 613 | s.printf(USBD_TASK_PREFIX"Counter %3d\n", counter++); |
embeddedartists | 26:f07df116f3c9 | 614 | } |
embeddedartists | 26:f07df116f3c9 | 615 | #endif |
embeddedartists | 26:f07df116f3c9 | 616 | #endif // #if defined(DEMO_USB_DEVICE_SERIAL) |
embeddedartists | 26:f07df116f3c9 | 617 | |
embeddedartists | 26:f07df116f3c9 | 618 | #if defined(DEMO_USB_DEVICE_MOUSE) |
embeddedartists | 26:f07df116f3c9 | 619 | // Notes: |
embeddedartists | 26:f07df116f3c9 | 620 | // * If the USBMouse class is used after this then the USBKeyboard stops working. |
embeddedartists | 26:f07df116f3c9 | 621 | // if both are to be used then the USBMouseKeyboard class must be used instead. |
embeddedartists | 26:f07df116f3c9 | 622 | USBKeyboard keyb; |
embeddedartists | 26:f07df116f3c9 | 623 | while(true) { |
embeddedartists | 26:f07df116f3c9 | 624 | while (!board->buttonPressed()) { |
embeddedartists | 26:f07df116f3c9 | 625 | Thread::wait(50); |
embeddedartists | 26:f07df116f3c9 | 626 | } |
embeddedartists | 26:f07df116f3c9 | 627 | keyb.printf("Hello World!\n"); |
embeddedartists | 26:f07df116f3c9 | 628 | while (board->buttonPressed()) { |
embeddedartists | 26:f07df116f3c9 | 629 | Thread::wait(50); |
embeddedartists | 26:f07df116f3c9 | 630 | } |
embeddedartists | 26:f07df116f3c9 | 631 | } |
embeddedartists | 26:f07df116f3c9 | 632 | #endif // #if defined(DEMO_USB_DEVICE_MOUSE) |
embeddedartists | 26:f07df116f3c9 | 633 | } |
embeddedartists | 26:f07df116f3c9 | 634 | #endif |
embeddedartists | 26:f07df116f3c9 | 635 | |
embeddedartists | 18:715f542538b3 | 636 | |
embeddedartists | 14:73f6c425b2b5 | 637 | #define REGTEST "[REG] " |
embeddedartists | 14:73f6c425b2b5 | 638 | static void testRegistry() |
embeddedartists | 14:73f6c425b2b5 | 639 | { |
embeddedartists | 14:73f6c425b2b5 | 640 | Registry* reg = DMBoard::instance().registry(); |
embeddedartists | 14:73f6c425b2b5 | 641 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 14:73f6c425b2b5 | 642 | char* key; |
embeddedartists | 14:73f6c425b2b5 | 643 | char* val; |
embeddedartists | 14:73f6c425b2b5 | 644 | Registry::RegistryError err; |
embeddedartists | 14:73f6c425b2b5 | 645 | |
embeddedartists | 14:73f6c425b2b5 | 646 | log->printf(REGTEST"Before:\n"); |
embeddedartists | 14:73f6c425b2b5 | 647 | for (int i = 0; i < reg->numEntries(); i++) { |
embeddedartists | 14:73f6c425b2b5 | 648 | err = reg->entryAt(i, &key, &val); |
embeddedartists | 14:73f6c425b2b5 | 649 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 650 | log->printf(REGTEST" [%2d] '%s' = '%s'\n", i, key, val); |
embeddedartists | 14:73f6c425b2b5 | 651 | free(key); |
embeddedartists | 14:73f6c425b2b5 | 652 | free(val); |
embeddedartists | 14:73f6c425b2b5 | 653 | } else { |
embeddedartists | 14:73f6c425b2b5 | 654 | log->printf(REGTEST" [%2d] got error %d\n", i, err); |
embeddedartists | 14:73f6c425b2b5 | 655 | } |
embeddedartists | 14:73f6c425b2b5 | 656 | } |
embeddedartists | 14:73f6c425b2b5 | 657 | |
embeddedartists | 14:73f6c425b2b5 | 658 | log->printf(REGTEST"Getting existing value:\n"); |
embeddedartists | 14:73f6c425b2b5 | 659 | err = reg->getValue("IP Address", &val); |
embeddedartists | 14:73f6c425b2b5 | 660 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 661 | log->printf(REGTEST" Existing 'IP Address' = '%s'\n", val); |
embeddedartists | 14:73f6c425b2b5 | 662 | free(val); |
embeddedartists | 14:73f6c425b2b5 | 663 | } else { |
embeddedartists | 14:73f6c425b2b5 | 664 | log->printf(REGTEST" Existing 'IP Address' got error %d\n", err); |
embeddedartists | 14:73f6c425b2b5 | 665 | } |
embeddedartists | 14:73f6c425b2b5 | 666 | |
embeddedartists | 14:73f6c425b2b5 | 667 | log->printf(REGTEST"Getting missing value:\n"); |
embeddedartists | 14:73f6c425b2b5 | 668 | err = reg->getValue("X78g4dfwx", &val); |
embeddedartists | 14:73f6c425b2b5 | 669 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 670 | log->printf(REGTEST" Missing 'X78g4dfwx' = '%s'\n", val); |
embeddedartists | 14:73f6c425b2b5 | 671 | free(val); |
embeddedartists | 14:73f6c425b2b5 | 672 | } else if (err == Registry::NoSuchKeyError) { |
embeddedartists | 14:73f6c425b2b5 | 673 | log->printf(REGTEST" Missing 'X78g4dfwx' was missing.\n", err); |
embeddedartists | 14:73f6c425b2b5 | 674 | } else { |
embeddedartists | 14:73f6c425b2b5 | 675 | log->printf(REGTEST" Existing 'X78g4dfwx' got error %d\n", err); |
embeddedartists | 14:73f6c425b2b5 | 676 | } |
embeddedartists | 14:73f6c425b2b5 | 677 | |
embeddedartists | 14:73f6c425b2b5 | 678 | log->printf(REGTEST"Updating value:\n"); |
embeddedartists | 14:73f6c425b2b5 | 679 | err = reg->getValue("EATest", &val); |
embeddedartists | 14:73f6c425b2b5 | 680 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 681 | log->printf(REGTEST" Old value for 'EATest' = '%s'\n", val); |
embeddedartists | 14:73f6c425b2b5 | 682 | char buf[32]; |
embeddedartists | 14:73f6c425b2b5 | 683 | sprintf(buf, "%d", atoi(val)+1); |
embeddedartists | 14:73f6c425b2b5 | 684 | free(val); |
embeddedartists | 14:73f6c425b2b5 | 685 | err = reg->setValue("EATest", buf); |
embeddedartists | 14:73f6c425b2b5 | 686 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 687 | log->printf(REGTEST" Updated 'EATest' to '%s'\n", buf); |
embeddedartists | 14:73f6c425b2b5 | 688 | } else { |
embeddedartists | 14:73f6c425b2b5 | 689 | log->printf(REGTEST" Failed to update 'EATest', got error %d\n", err); |
embeddedartists | 14:73f6c425b2b5 | 690 | } |
embeddedartists | 14:73f6c425b2b5 | 691 | } else if (err == Registry::NoSuchKeyError) { |
embeddedartists | 14:73f6c425b2b5 | 692 | log->printf(REGTEST" No value for 'EATest', adding one\n", err); |
embeddedartists | 14:73f6c425b2b5 | 693 | err = reg->setValue("EATest", "-3"); |
embeddedartists | 14:73f6c425b2b5 | 694 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 695 | log->printf(REGTEST" Set 'EATest' to '0'\n"); |
embeddedartists | 14:73f6c425b2b5 | 696 | } else { |
embeddedartists | 14:73f6c425b2b5 | 697 | log->printf(REGTEST" Failed to set 'EATest', got error %d\n", err); |
embeddedartists | 14:73f6c425b2b5 | 698 | } |
embeddedartists | 14:73f6c425b2b5 | 699 | } else { |
embeddedartists | 14:73f6c425b2b5 | 700 | log->printf(REGTEST" Failed to read 'EATest' got error %d\n", err); |
embeddedartists | 14:73f6c425b2b5 | 701 | } |
embeddedartists | 14:73f6c425b2b5 | 702 | |
embeddedartists | 14:73f6c425b2b5 | 703 | log->printf(REGTEST"Storing values persistently\n"); |
embeddedartists | 14:73f6c425b2b5 | 704 | err = reg->store(); |
embeddedartists | 14:73f6c425b2b5 | 705 | if (err != Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 706 | log->printf(REGTEST" Failed to store values, got error %d\n", err); |
embeddedartists | 14:73f6c425b2b5 | 707 | } |
embeddedartists | 14:73f6c425b2b5 | 708 | |
embeddedartists | 14:73f6c425b2b5 | 709 | log->printf(REGTEST"After:\n"); |
embeddedartists | 14:73f6c425b2b5 | 710 | for (int i = 0; i < reg->numEntries(); i++) { |
embeddedartists | 14:73f6c425b2b5 | 711 | err = reg->entryAt(i, &key, &val); |
embeddedartists | 14:73f6c425b2b5 | 712 | if (err == Registry::Ok) { |
embeddedartists | 14:73f6c425b2b5 | 713 | log->printf(REGTEST" [%2d] '%s' = '%s'\n", i, key, val); |
embeddedartists | 14:73f6c425b2b5 | 714 | free(key); |
embeddedartists | 14:73f6c425b2b5 | 715 | free(val); |
embeddedartists | 14:73f6c425b2b5 | 716 | } else { |
embeddedartists | 14:73f6c425b2b5 | 717 | log->printf(REGTEST" [%2d] got error %d\n", i, err); |
embeddedartists | 14:73f6c425b2b5 | 718 | } |
embeddedartists | 14:73f6c425b2b5 | 719 | } |
embeddedartists | 14:73f6c425b2b5 | 720 | } |
embeddedartists | 14:73f6c425b2b5 | 721 | |
embeddedartists | 0:dfad71908d59 | 722 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 723 | * Main function |
embeddedartists | 0:dfad71908d59 | 724 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 725 | int main() |
embeddedartists | 0:dfad71908d59 | 726 | { |
embeddedartists | 0:dfad71908d59 | 727 | DMBoard::BoardError err; |
embeddedartists | 0:dfad71908d59 | 728 | DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:dfad71908d59 | 729 | RtosLog* log = board->logger(); |
embeddedartists | 0:dfad71908d59 | 730 | err = board->init(); |
embeddedartists | 0:dfad71908d59 | 731 | if (err != DMBoard::Ok) { |
embeddedartists | 0:dfad71908d59 | 732 | log->printf("Failed to initialize the board, got error %d\r\n", err); |
embeddedartists | 16:77f4f42eb6a7 | 733 | log->printf("\nTERMINATING\n"); |
embeddedartists | 30:e1cded731965 | 734 | ThisThread::sleep_for(2000); // allow RtosLog to flush messages |
embeddedartists | 0:dfad71908d59 | 735 | mbed_die(); |
embeddedartists | 0:dfad71908d59 | 736 | } |
embeddedartists | 30:e1cded731965 | 737 | |
embeddedartists | 11:4830c7689843 | 738 | board->buzzer(440,50); |
embeddedartists | 11:4830c7689843 | 739 | wait_ms(30); |
embeddedartists | 11:4830c7689843 | 740 | board->buzzer(660,50); |
embeddedartists | 11:4830c7689843 | 741 | wait_ms(30); |
embeddedartists | 11:4830c7689843 | 742 | board->buzzer(440,50); |
embeddedartists | 11:4830c7689843 | 743 | |
embeddedartists | 0:dfad71908d59 | 744 | log->printf("\n\n---\nMulti-threaded demo\nBuilt: " __DATE__ " at " __TIME__ "\n\n"); |
embeddedartists | 0:dfad71908d59 | 745 | |
embeddedartists | 16:77f4f42eb6a7 | 746 | //testRegistry(); |
embeddedartists | 14:73f6c425b2b5 | 747 | |
embeddedartists | 14:73f6c425b2b5 | 748 | |
embeddedartists | 30:e1cded731965 | 749 | Thread tAlive; |
embeddedartists | 30:e1cded731965 | 750 | tAlive.start(aliveTask); |
embeddedartists | 0:dfad71908d59 | 751 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 30:e1cded731965 | 752 | Thread tSwim(osPriorityNormal, 8192); |
embeddedartists | 30:e1cded731965 | 753 | tSwim.start(swimTask); |
embeddedartists | 26:f07df116f3c9 | 754 | #endif |
embeddedartists | 30:e1cded731965 | 755 | |
embeddedartists | 30:e1cded731965 | 756 | |
embeddedartists | 30:e1cded731965 | 757 | |
embeddedartists | 26:f07df116f3c9 | 758 | #if defined(DM_BOARD_USE_ETHERNET) |
embeddedartists | 30:e1cded731965 | 759 | Thread tNetwork(osPriorityNormal, 8192); |
embeddedartists | 30:e1cded731965 | 760 | tNetwork.start(netTask); |
embeddedartists | 26:f07df116f3c9 | 761 | #endif |
embeddedartists | 30:e1cded731965 | 762 | |
embeddedartists | 26:f07df116f3c9 | 763 | #if defined(DM_BOARD_USE_USB_HOST) |
embeddedartists | 30:e1cded731965 | 764 | Thread tUSBHandler(osPriorityNormal, 8192); |
embeddedartists | 30:e1cded731965 | 765 | tUSBHandler.start(usbHostTask); |
embeddedartists | 26:f07df116f3c9 | 766 | #elif defined(DM_BOARD_USE_USB_DEVICE) |
embeddedartists | 30:e1cded731965 | 767 | Thread tUSBDev(osPriorityNormal, 8192); |
embeddedartists | 30:e1cded731965 | 768 | tUSBDev.start(usbDeviceTask); |
embeddedartists | 26:f07df116f3c9 | 769 | #endif |
embeddedartists | 26:f07df116f3c9 | 770 | |
embeddedartists | 18:715f542538b3 | 771 | while(1) { |
embeddedartists | 30:e1cded731965 | 772 | ThisThread::sleep_for(5000); |
embeddedartists | 18:715f542538b3 | 773 | time_t seconds = time(NULL); |
embeddedartists | 30:e1cded731965 | 774 | |
embeddedartists | 18:715f542538b3 | 775 | log->printf("Time: %s\n", ctime(&seconds)); |
embeddedartists | 18:715f542538b3 | 776 | } |
embeddedartists | 0:dfad71908d59 | 777 | } |