![](/media/cache/profiles/20200518_163046.jpg.50x50_q85.jpg)
PSoC 6 pioneer kit multi library code for emwin driven tft display, capsense and mechanical button input.
emwin_config/GUI_X_Mbed.cpp@3:1edcda6af8df, 2019-10-18 (annotated)
- Committer:
- reedas
- Date:
- Fri Oct 18 21:14:25 2019 +0000
- Revision:
- 3:1edcda6af8df
- Parent:
- 0:4ad2c16b6e43
Example of using different libraries to build a program. (emwin graphics, Pindetect key debouncing, capsense switch input.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
reedas | 0:4ad2c16b6e43 | 1 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 2 | * SEGGER Microcontroller GmbH * |
reedas | 0:4ad2c16b6e43 | 3 | * Solutions for real time microcontroller applications * |
reedas | 0:4ad2c16b6e43 | 4 | ********************************************************************** |
reedas | 0:4ad2c16b6e43 | 5 | * * |
reedas | 0:4ad2c16b6e43 | 6 | * (c) 1996 - 2018 SEGGER Microcontroller GmbH * |
reedas | 0:4ad2c16b6e43 | 7 | * * |
reedas | 0:4ad2c16b6e43 | 8 | * Internet: www.segger.com Support: support@segger.com * |
reedas | 0:4ad2c16b6e43 | 9 | * * |
reedas | 0:4ad2c16b6e43 | 10 | ********************************************************************** |
reedas | 0:4ad2c16b6e43 | 11 | |
reedas | 0:4ad2c16b6e43 | 12 | ** emWin V5.48 - Graphical user interface for embedded applications ** |
reedas | 0:4ad2c16b6e43 | 13 | All Intellectual Property rights in the Software belongs to SEGGER. |
reedas | 0:4ad2c16b6e43 | 14 | emWin is protected by international copyright laws. Knowledge of the |
reedas | 0:4ad2c16b6e43 | 15 | source code may not be used to write a similar product. This file may |
reedas | 0:4ad2c16b6e43 | 16 | only be used in accordance with the following terms: |
reedas | 0:4ad2c16b6e43 | 17 | |
reedas | 0:4ad2c16b6e43 | 18 | The software has been licensed to Cypress Semiconductor Corporation, |
reedas | 0:4ad2c16b6e43 | 19 | whose registered office is situated at 198 Champion Ct. San Jose, CA |
reedas | 0:4ad2c16b6e43 | 20 | 95134 USA solely for the purposes of creating libraries for Cypress |
reedas | 0:4ad2c16b6e43 | 21 | PSoC3 and PSoC5 processor-based devices, sublicensed and distributed |
reedas | 0:4ad2c16b6e43 | 22 | under the terms and conditions of the Cypress End User License |
reedas | 0:4ad2c16b6e43 | 23 | Agreement. |
reedas | 0:4ad2c16b6e43 | 24 | Full source code is available at: www.segger.com |
reedas | 0:4ad2c16b6e43 | 25 | |
reedas | 0:4ad2c16b6e43 | 26 | We appreciate your understanding and fairness. |
reedas | 0:4ad2c16b6e43 | 27 | ---------------------------------------------------------------------- |
reedas | 0:4ad2c16b6e43 | 28 | Licensing information |
reedas | 0:4ad2c16b6e43 | 29 | Licensor: SEGGER Microcontroller Systems LLC |
reedas | 0:4ad2c16b6e43 | 30 | Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA |
reedas | 0:4ad2c16b6e43 | 31 | Licensed SEGGER software: emWin |
reedas | 0:4ad2c16b6e43 | 32 | License number: GUI-00319 |
reedas | 0:4ad2c16b6e43 | 33 | License model: Services and License Agreement, signed June 10th, 2009 |
reedas | 0:4ad2c16b6e43 | 34 | Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) |
reedas | 0:4ad2c16b6e43 | 35 | ---------------------------------------------------------------------- |
reedas | 0:4ad2c16b6e43 | 36 | Support and Update Agreement (SUA) |
reedas | 0:4ad2c16b6e43 | 37 | SUA period: 2009-06-12 - 2022-07-27 |
reedas | 0:4ad2c16b6e43 | 38 | Contact to extend SUA: sales@segger.com |
reedas | 0:4ad2c16b6e43 | 39 | ---------------------------------------------------------------------- |
reedas | 0:4ad2c16b6e43 | 40 | File : GUI_X_Mbed.c |
reedas | 0:4ad2c16b6e43 | 41 | Purpose : Config / System dependent externals for GUI |
reedas | 0:4ad2c16b6e43 | 42 | ---------------------------END-OF-HEADER------------------------------ |
reedas | 0:4ad2c16b6e43 | 43 | */ |
reedas | 0:4ad2c16b6e43 | 44 | |
reedas | 0:4ad2c16b6e43 | 45 | #include <stdio.h> |
reedas | 0:4ad2c16b6e43 | 46 | #include "mbed.h" |
reedas | 0:4ad2c16b6e43 | 47 | |
reedas | 0:4ad2c16b6e43 | 48 | extern "C" { |
reedas | 0:4ad2c16b6e43 | 49 | #include "GUI.h" |
reedas | 0:4ad2c16b6e43 | 50 | } |
reedas | 0:4ad2c16b6e43 | 51 | |
reedas | 0:4ad2c16b6e43 | 52 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 53 | * |
reedas | 0:4ad2c16b6e43 | 54 | * Global data |
reedas | 0:4ad2c16b6e43 | 55 | */ |
reedas | 0:4ad2c16b6e43 | 56 | |
reedas | 0:4ad2c16b6e43 | 57 | Ticker emwin_ticker; |
reedas | 0:4ad2c16b6e43 | 58 | Mutex emwin_mutex; |
reedas | 0:4ad2c16b6e43 | 59 | volatile GUI_TIMER_TIME timeMS = 0; |
reedas | 0:4ad2c16b6e43 | 60 | |
reedas | 0:4ad2c16b6e43 | 61 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 62 | * |
reedas | 0:4ad2c16b6e43 | 63 | * Public code |
reedas | 0:4ad2c16b6e43 | 64 | * |
reedas | 0:4ad2c16b6e43 | 65 | ********************************************************************** |
reedas | 0:4ad2c16b6e43 | 66 | */ |
reedas | 0:4ad2c16b6e43 | 67 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 68 | * |
reedas | 0:4ad2c16b6e43 | 69 | * Timing: |
reedas | 0:4ad2c16b6e43 | 70 | * GUI_X_GetTime() |
reedas | 0:4ad2c16b6e43 | 71 | * GUI_X_Delay(int) |
reedas | 0:4ad2c16b6e43 | 72 | |
reedas | 0:4ad2c16b6e43 | 73 | Some timing dependent routines require a GetTime |
reedas | 0:4ad2c16b6e43 | 74 | and delay function. Default time unit (tick), normally is |
reedas | 0:4ad2c16b6e43 | 75 | 1 ms. |
reedas | 0:4ad2c16b6e43 | 76 | */ |
reedas | 0:4ad2c16b6e43 | 77 | |
reedas | 0:4ad2c16b6e43 | 78 | GUI_TIMER_TIME GUI_X_GetTime(void) |
reedas | 0:4ad2c16b6e43 | 79 | { |
reedas | 0:4ad2c16b6e43 | 80 | return timeMS; |
reedas | 0:4ad2c16b6e43 | 81 | } |
reedas | 0:4ad2c16b6e43 | 82 | |
reedas | 0:4ad2c16b6e43 | 83 | void GUI_X_Delay(int ms) |
reedas | 0:4ad2c16b6e43 | 84 | { |
reedas | 0:4ad2c16b6e43 | 85 | wait_ms(ms); |
reedas | 0:4ad2c16b6e43 | 86 | } |
reedas | 0:4ad2c16b6e43 | 87 | |
reedas | 0:4ad2c16b6e43 | 88 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 89 | * |
reedas | 0:4ad2c16b6e43 | 90 | * GUI_X_ExecIdle() |
reedas | 0:4ad2c16b6e43 | 91 | * |
reedas | 0:4ad2c16b6e43 | 92 | */ |
reedas | 0:4ad2c16b6e43 | 93 | void GUI_X_ExecIdle(void) |
reedas | 0:4ad2c16b6e43 | 94 | { |
reedas | 0:4ad2c16b6e43 | 95 | wait_ms(1); |
reedas | 0:4ad2c16b6e43 | 96 | } |
reedas | 0:4ad2c16b6e43 | 97 | |
reedas | 0:4ad2c16b6e43 | 98 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 99 | * |
reedas | 0:4ad2c16b6e43 | 100 | * Multitasking: |
reedas | 0:4ad2c16b6e43 | 101 | * |
reedas | 0:4ad2c16b6e43 | 102 | * GUI_X_InitOS() |
reedas | 0:4ad2c16b6e43 | 103 | * GUI_X_GetTaskId() |
reedas | 0:4ad2c16b6e43 | 104 | * GUI_X_Lock() |
reedas | 0:4ad2c16b6e43 | 105 | * GUI_X_Unlock() |
reedas | 0:4ad2c16b6e43 | 106 | * |
reedas | 0:4ad2c16b6e43 | 107 | * Note: |
reedas | 0:4ad2c16b6e43 | 108 | * The following routines are required only if emWin is used in a |
reedas | 0:4ad2c16b6e43 | 109 | * true multi task environment, which means you have more than one |
reedas | 0:4ad2c16b6e43 | 110 | * thread using the emWin API. |
reedas | 0:4ad2c16b6e43 | 111 | * In this case the |
reedas | 0:4ad2c16b6e43 | 112 | * #define GUI_OS 1 |
reedas | 0:4ad2c16b6e43 | 113 | * needs to be in GUIConf.h |
reedas | 0:4ad2c16b6e43 | 114 | */ |
reedas | 0:4ad2c16b6e43 | 115 | void GUI_X_InitOS(void) {} |
reedas | 0:4ad2c16b6e43 | 116 | void GUI_X_Unlock(void) { emwin_mutex.unlock(); } |
reedas | 0:4ad2c16b6e43 | 117 | void GUI_X_Lock(void) { emwin_mutex.lock(); } |
reedas | 0:4ad2c16b6e43 | 118 | U32 GUI_X_GetTaskId(void) { return 0; } |
reedas | 0:4ad2c16b6e43 | 119 | |
reedas | 0:4ad2c16b6e43 | 120 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 121 | * |
reedas | 0:4ad2c16b6e43 | 122 | * Logging: OS dependent |
reedas | 0:4ad2c16b6e43 | 123 | |
reedas | 0:4ad2c16b6e43 | 124 | Note: |
reedas | 0:4ad2c16b6e43 | 125 | Logging is used in higher debug levels only. The typical target |
reedas | 0:4ad2c16b6e43 | 126 | build does not use logging and does therefor not require any of |
reedas | 0:4ad2c16b6e43 | 127 | the logging routines below. For a release build without logging |
reedas | 0:4ad2c16b6e43 | 128 | the routines below may be eliminated to save some space. |
reedas | 0:4ad2c16b6e43 | 129 | (If the linker is not function aware and eliminates unreferenced |
reedas | 0:4ad2c16b6e43 | 130 | functions automatically) |
reedas | 0:4ad2c16b6e43 | 131 | |
reedas | 0:4ad2c16b6e43 | 132 | */ |
reedas | 0:4ad2c16b6e43 | 133 | |
reedas | 0:4ad2c16b6e43 | 134 | void GUI_X_Log (const char *s) { GUI_USE_PARA(s); } |
reedas | 0:4ad2c16b6e43 | 135 | void GUI_X_Warn (const char *s) { GUI_USE_PARA(s); } |
reedas | 0:4ad2c16b6e43 | 136 | void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); } |
reedas | 0:4ad2c16b6e43 | 137 | |
reedas | 0:4ad2c16b6e43 | 138 | void ticker_handler(void) |
reedas | 0:4ad2c16b6e43 | 139 | { |
reedas | 0:4ad2c16b6e43 | 140 | timeMS++; |
reedas | 0:4ad2c16b6e43 | 141 | } |
reedas | 0:4ad2c16b6e43 | 142 | |
reedas | 0:4ad2c16b6e43 | 143 | /********************************************************************* |
reedas | 0:4ad2c16b6e43 | 144 | * |
reedas | 0:4ad2c16b6e43 | 145 | * GUI_X_Init() |
reedas | 0:4ad2c16b6e43 | 146 | * |
reedas | 0:4ad2c16b6e43 | 147 | * Note: |
reedas | 0:4ad2c16b6e43 | 148 | * This routine is called from GUI_Init() in any case whether there |
reedas | 0:4ad2c16b6e43 | 149 | * is an RTOS or not. You can use it for additional initializations |
reedas | 0:4ad2c16b6e43 | 150 | * needed. |
reedas | 0:4ad2c16b6e43 | 151 | */ |
reedas | 0:4ad2c16b6e43 | 152 | |
reedas | 0:4ad2c16b6e43 | 153 | void GUI_X_Init(void) |
reedas | 0:4ad2c16b6e43 | 154 | { |
reedas | 0:4ad2c16b6e43 | 155 | emwin_ticker.attach(&ticker_handler, 0.001); |
reedas | 0:4ad2c16b6e43 | 156 | } |
reedas | 0:4ad2c16b6e43 | 157 | |
reedas | 0:4ad2c16b6e43 | 158 | /*************************** End of file ****************************/ |