1 /** 2 ********************************************************************************************************* 3 * Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved. 4 ********************************************************************************************************** 5 * @file app_msg.h 6 * @brief Message definition for user application task. 7 * @note If new message types/sub types are to be added, add to the end of enumeration. 8 * The orders are NOT to changed. 9 * @author Lory 10 * @date 2017.2.9 11 * @version v1.0 12 ********************************************************************************************************* 13 */ 14 /*============================================================================* 15 * Define to prevent recursive inclusion 16 *============================================================================*/ 17 18 #ifndef _APP_MSG_H_ 19 #define _APP_MSG_H_ 20 21 /*============================================================================* 22 * Header Files 23 *============================================================================*/ 24 #include <stdint.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 31 /** 32 * @defgroup APP_MSG APP Message 33 * @brief message definition for user application task. 34 * @{ 35 */ 36 37 /** 38 * @defgroup APP_MSG_Exported_Types APP Message Exported Types 39 * @{ 40 */ 41 42 /** 43 * @brief Event group definitions. 44 * @details event code is 1 byte code to define messages type exchanging from/to different layers. 45 * first half byte is for group define, and second harf byte is for code define 46 * group code: 47 * 0: from stack layer 48 * 0x1: from peripheral layer 49 * 0x2: from audio lib 50 * 0xA: from instructment 51 */ 52 typedef enum 53 { 54 EVENT_GROUP_STACK = 0, /**< message group from BT layer */ 55 EVENT_GROUP_IO = 1, /**< message group from IO layer */ 56 EVENT_GROUP_AUDIOLIB = 2, /**< message group from Audio lib layer */ 57 EVENT_GROUP_INSTRUMENT = 0xa, /**< message group from instructment layer */ 58 } T_EVENT_GROUP; 59 60 /** @brief Event type definitions. 61 */ 62 typedef enum 63 { 64 EVENT_GAP_MSG = 0x01, /**< message from gap layer for stack */ 65 EVENT_GAP_TIMER = 0x02, /**< message from gap layer for timer */ 66 67 EVENT_IO_TO_APP = 0x11, /**< message from IO to user application */ 68 69 EVENT_RWS_TIMER = 0x21, /**< message from RWS timer to user application */ 70 EVENT_DSP_MSG = 0x22, /**< message from DSP to user application */ 71 72 EVENT_CMD_FROM_8852B = 0xa1, /**< message from 8852B to user application */ 73 74 EVENT_USER_HTTP_SERVER = 0xa2, /**< message from user http server */ 75 } T_EVENT_TYPE; 76 77 /** @brief get event code group definition */ 78 #define EVENT_GROUP(event_code) (event_code >> 4) 79 80 /** @brief IO type definitions for IO message, may extend as requested */ 81 typedef enum 82 { 83 IO_MSG_TYPE_BT_STATUS, /**< BT status change with subtype @ref GAP_MSG_TYPE */ 84 IO_MSG_TYPE_KEYSCAN, /**< Key scan message with subtype @ref T_IO_MSG_KEYSCAN */ 85 IO_MSG_TYPE_QDECODE, /**< subtype to be defined */ 86 IO_MSG_TYPE_UART, /**< Uart message with subtype @ref T_IO_MSG_UART */ 87 IO_MSG_TYPE_KEYPAD, /**< subtype to be defined */ 88 IO_MSG_TYPE_IR, /**< subtype to be defined */ 89 IO_MSG_TYPE_GDMA, /**< subtype to be defined */ 90 IO_MSG_TYPE_ADC, /**< subtype to be defined */ 91 IO_MSG_TYPE_D3DG, /**< subtype to be defined */ 92 IO_MSG_TYPE_SPI, /**< subtype to be defined */ 93 IO_MSG_TYPE_MOUSE_BUTTON, /**< subtype to be defined */ 94 IO_MSG_TYPE_GPIO, /**< Gpio message with subtype @ref T_IO_MSG_GPIO*/ 95 IO_MSG_TYPE_MOUSE_SENSOR, /**< subtype to be defined */ 96 IO_MSG_TYPE_TIMER, /**< App timer message with subtype @ref T_IO_MSG_TIMER */ 97 IO_MSG_TYPE_WRISTBNAD, /**< wristband message with subtype @ref T_IO_MSG_WRISTBAND */ 98 IO_MSG_TYPE_MESH_STATUS, /**< subtype to be defined */ 99 IO_MSG_TYPE_KEYBOARD_BUTTON, /**< subtype to be defined */ 100 IO_MSG_TYPE_ANCS, /**< ANCS message*/ 101 } T_IO_MSG_TYPE; 102 103 /** @brief IO subtype definitions for @ref IO_MSG_TYPE_KEYSCAN type */ 104 typedef enum 105 { 106 IO_MSG_KEYSCAN_RX_PKT = 1, /**< Keyscan RX data event */ 107 IO_MSG_KEYSCAN_MAX = 2, /**< */ 108 IO_MSG_KEYSCAN_ALLKEYRELEASE = 3, /**< All keys are released event */ 109 IO_MSG_KEYSCAN_STUCK = 4, /**< key stuck message */ 110 } T_IO_MSG_KEYSCAN; 111 112 /** @brief IO subtype definitions for @ref IO_MSG_TYPE_UART type */ 113 typedef enum 114 { 115 IO_MSG_UART_RX = 0x10, /**< UART RX event */ 116 117 IO_MSG_UART_TX = 0x20, /**< UART TX event */ 118 } T_IO_MSG_UART; 119 120 /** @brief IO subtype definitions for @ref IO_MSG_TYPE_GPIO type */ 121 typedef enum 122 { 123 IO_MSG_GPIO_KEY, /**< KEY GPIO event */ 124 IO_MSG_GPIO_LINE_IN, /**< LINE IN event */ 125 IO_MSG_GPIO_NFC, /**< NFC event */ 126 IO_MSG_GPIO_UART_WAKE_UP, /**< UART WAKE UP event */ 127 IO_MSG_GPIO_CHARGER, /**< CHARGER event */ 128 IO_MSG_GPIO_USB_AUDIO_PLUG, /**< USB PLUG IN event */ 129 IO_MSG_GPIO_USB_AUDIO_UNPLUG /**< USB PLUG OUT event */ 130 } T_IO_MSG_GPIO; 131 132 /** @brief IO subtype definitions for @ref IO_MSG_TYPE_TIMER type */ 133 typedef enum 134 { 135 IO_MSG_TIMER_ALARM, 136 IO_MSG_TIMER_RWS 137 } T_IO_MSG_TIMER; 138 139 /** @brief IO subtype definitions for @ref IO_MSG_TYPE_WRISTBNAD type */ 140 typedef enum 141 { 142 IO_MSG_BWPS_TX_VALUE = 1, 143 IO_MSG_OS_TIMEROUT_SEND_DATA = 2, 144 IO_MSG_OS_TIMEROUT_SEND_DELAY = 3, 145 IO_MSG_OS_TIMEROUT_SENSOR = 4, 146 IO_MSG_RTC_TIMEROUT_WALL_CLOCK = 5, 147 IO_MSG_SENSOR_DOUBLE_CLICK = 6, 148 IO_MSG_ADC_INT = 7, 149 IO_MSG_SENSOR_INT = 8, 150 IO_MSG_SENSOR_WAKE_UP = 9, 151 IO_MSG_LED_TWINKLE = 10, 152 IO_MSG_MOTOR_VIBRATE = 11, 153 IO_MSG_CHARGER_STATE = 12, 154 IO_MSG_RTC_LOW_BATTERY_RESTORE = 13, 155 IO_MSG_RTC_ALARM = 14, 156 IO_MSG_ADC_SAMPLE_READY = 15, 157 IO_MSG_GDMA_RECV = 16, 158 IO_MSG_SENSOR_LEN = 17, 159 IO_MSG_BUTTON_EVENT = 18, 160 IO_MSG_POWER_OFF = 19, 161 IO_MSG_POWER_ON = 20, 162 IO_MSG_HRS_EVENT = 21, 163 IO_MSG_SENSOR_MOTION_INTERRUPT = 22, 164 IO_MSG_UART_CMD_DEBUG = 23, 165 IO_MSG_OTA_GDMA_READ = 24, 166 IO_MSG_OTA_GDMA_WRITE = 25, 167 IO_MSG_HRS_TIMEOUT_HANDLE = 26, 168 IO_MSG_UPDATE_CONPARA = 27, 169 } T_IO_MSG_WRISTBAND; 170 171 /** @brief IO message definition for communications between tasks*/ 172 typedef struct 173 { 174 uint16_t type; 175 uint16_t subtype; 176 union 177 { 178 uint32_t param; 179 void *buf; 180 } u; 181 } T_IO_MSG; 182 183 /** @} */ /* End of group APP_MSG_Exported_Types */ 184 185 /** @} */ /* End of group APP_MSG */ 186 187 #ifdef __cplusplus 188 } 189 #endif 190 191 #endif /* _APP_MSG_H_ */ 192