Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 /* mbed Microcontroller Library
thedo 166:3a9487d57a5c 2 * Copyright (c) 2006-2012 ARM Limited
thedo 166:3a9487d57a5c 3 *
thedo 166:3a9487d57a5c 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
thedo 166:3a9487d57a5c 5 * of this software and associated documentation files (the "Software"), to deal
thedo 166:3a9487d57a5c 6 * in the Software without restriction, including without limitation the rights
thedo 166:3a9487d57a5c 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
thedo 166:3a9487d57a5c 8 * copies of the Software, and to permit persons to whom the Software is
thedo 166:3a9487d57a5c 9 * furnished to do so, subject to the following conditions:
thedo 166:3a9487d57a5c 10 *
thedo 166:3a9487d57a5c 11 * The above copyright notice and this permission notice shall be included in
thedo 166:3a9487d57a5c 12 * all copies or substantial portions of the Software.
thedo 166:3a9487d57a5c 13 *
thedo 166:3a9487d57a5c 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
thedo 166:3a9487d57a5c 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
thedo 166:3a9487d57a5c 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
thedo 166:3a9487d57a5c 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
thedo 166:3a9487d57a5c 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
thedo 166:3a9487d57a5c 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
thedo 166:3a9487d57a5c 20 * SOFTWARE.
thedo 166:3a9487d57a5c 21 */
thedo 166:3a9487d57a5c 22 #ifndef QUEUE_H
thedo 166:3a9487d57a5c 23 #define QUEUE_H
thedo 166:3a9487d57a5c 24
thedo 166:3a9487d57a5c 25 #include <stdint.h>
thedo 166:3a9487d57a5c 26 #include <string.h>
thedo 166:3a9487d57a5c 27
thedo 166:3a9487d57a5c 28 #include "cmsis_os.h"
thedo 166:3a9487d57a5c 29 #include "platform/mbed_error.h"
thedo 166:3a9487d57a5c 30
thedo 166:3a9487d57a5c 31 namespace rtos {
thedo 166:3a9487d57a5c 32 /** \addtogroup rtos */
thedo 166:3a9487d57a5c 33 /** @{*/
thedo 166:3a9487d57a5c 34
thedo 166:3a9487d57a5c 35 /** The Queue class allow to control, send, receive, or wait for messages.
thedo 166:3a9487d57a5c 36 A message can be a integer or pointer value to a certain type T that is send
thedo 166:3a9487d57a5c 37 to a thread or interrupt service routine.
thedo 166:3a9487d57a5c 38 @tparam T data type of a single message element.
thedo 166:3a9487d57a5c 39 @tparam queue_sz maximum number of messages in queue.
thedo 166:3a9487d57a5c 40 */
thedo 166:3a9487d57a5c 41 template<typename T, uint32_t queue_sz>
thedo 166:3a9487d57a5c 42 class Queue {
thedo 166:3a9487d57a5c 43 public:
thedo 166:3a9487d57a5c 44 /** Create and initialise a message Queue. */
thedo 166:3a9487d57a5c 45 Queue() {
thedo 166:3a9487d57a5c 46 #ifdef CMSIS_OS_RTX
thedo 166:3a9487d57a5c 47 memset(_queue_q, 0, sizeof(_queue_q));
thedo 166:3a9487d57a5c 48 _queue_def.pool = _queue_q;
thedo 166:3a9487d57a5c 49 _queue_def.queue_sz = queue_sz;
thedo 166:3a9487d57a5c 50 #endif
thedo 166:3a9487d57a5c 51 _queue_id = osMessageCreate(&_queue_def, NULL);
thedo 166:3a9487d57a5c 52 if (_queue_id == NULL) {
thedo 166:3a9487d57a5c 53 error("Error initialising the queue object\n");
thedo 166:3a9487d57a5c 54 }
thedo 166:3a9487d57a5c 55 }
thedo 166:3a9487d57a5c 56
thedo 166:3a9487d57a5c 57 /** Put a message in a Queue.
thedo 166:3a9487d57a5c 58 @param data message pointer.
thedo 166:3a9487d57a5c 59 @param millisec timeout value or 0 in case of no time-out. (default: 0)
thedo 166:3a9487d57a5c 60 @return status code that indicates the execution status of the function.
thedo 166:3a9487d57a5c 61 */
thedo 166:3a9487d57a5c 62 osStatus put(T* data, uint32_t millisec=0) {
thedo 166:3a9487d57a5c 63 return osMessagePut(_queue_id, (uint32_t)data, millisec);
thedo 166:3a9487d57a5c 64 }
thedo 166:3a9487d57a5c 65
thedo 166:3a9487d57a5c 66 /** Get a message or Wait for a message from a Queue.
thedo 166:3a9487d57a5c 67 @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
thedo 166:3a9487d57a5c 68 @return event information that includes the message and the status code.
thedo 166:3a9487d57a5c 69 */
thedo 166:3a9487d57a5c 70 osEvent get(uint32_t millisec=osWaitForever) {
thedo 166:3a9487d57a5c 71 return osMessageGet(_queue_id, millisec);
thedo 166:3a9487d57a5c 72 }
thedo 166:3a9487d57a5c 73
thedo 166:3a9487d57a5c 74 private:
thedo 166:3a9487d57a5c 75 osMessageQId _queue_id;
thedo 166:3a9487d57a5c 76 osMessageQDef_t _queue_def;
thedo 166:3a9487d57a5c 77 #ifdef CMSIS_OS_RTX
thedo 166:3a9487d57a5c 78 uint32_t _queue_q[4+(queue_sz)];
thedo 166:3a9487d57a5c 79 #endif
thedo 166:3a9487d57a5c 80 };
thedo 166:3a9487d57a5c 81
thedo 166:3a9487d57a5c 82 }
thedo 166:3a9487d57a5c 83 #endif
thedo 166:3a9487d57a5c 84
thedo 166:3a9487d57a5c 85 /** @}*/