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 /* Copyright (c) 2010-2012 mbed.org, MIT License
thedo 166:3a9487d57a5c 2 *
thedo 166:3a9487d57a5c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
thedo 166:3a9487d57a5c 4 * and associated documentation files (the "Software"), to deal in the Software without
thedo 166:3a9487d57a5c 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
thedo 166:3a9487d57a5c 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
thedo 166:3a9487d57a5c 7 * Software is furnished to do so, subject to the following conditions:
thedo 166:3a9487d57a5c 8 *
thedo 166:3a9487d57a5c 9 * The above copyright notice and this permission notice shall be included in all copies or
thedo 166:3a9487d57a5c 10 * substantial portions of the Software.
thedo 166:3a9487d57a5c 11 *
thedo 166:3a9487d57a5c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
thedo 166:3a9487d57a5c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
thedo 166:3a9487d57a5c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
thedo 166:3a9487d57a5c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
thedo 166:3a9487d57a5c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
thedo 166:3a9487d57a5c 17 */
thedo 166:3a9487d57a5c 18
thedo 166:3a9487d57a5c 19 #ifndef WANDONGLESERIALPORT_H
thedo 166:3a9487d57a5c 20 #define WANDONGLESERIALPORT_H
thedo 166:3a9487d57a5c 21
thedo 166:3a9487d57a5c 22 #include "USBHostConf.h"
thedo 166:3a9487d57a5c 23
thedo 166:3a9487d57a5c 24 #ifdef USBHOST_3GMODULE
thedo 166:3a9487d57a5c 25
thedo 166:3a9487d57a5c 26 #include "USBHost.h"
thedo 166:3a9487d57a5c 27 #include "IUSBHostSerial.h"
thedo 166:3a9487d57a5c 28
thedo 166:3a9487d57a5c 29 #include "rtos.h"
thedo 166:3a9487d57a5c 30
thedo 166:3a9487d57a5c 31
thedo 166:3a9487d57a5c 32 #define WANDONGLE_MAX_OUTEP_SIZE 64
thedo 166:3a9487d57a5c 33 #define WANDONGLE_MAX_INEP_SIZE 64
thedo 166:3a9487d57a5c 34
thedo 166:3a9487d57a5c 35 /** A class to use a WAN (3G/LTE) access dongle
thedo 166:3a9487d57a5c 36 *
thedo 166:3a9487d57a5c 37 */
thedo 166:3a9487d57a5c 38 class WANDongleSerialPort : public IUSBHostSerial {
thedo 166:3a9487d57a5c 39 public:
thedo 166:3a9487d57a5c 40 /*
thedo 166:3a9487d57a5c 41 * Constructor
thedo 166:3a9487d57a5c 42 *
thedo 166:3a9487d57a5c 43 */
thedo 166:3a9487d57a5c 44 WANDongleSerialPort();
thedo 166:3a9487d57a5c 45
thedo 166:3a9487d57a5c 46 void init( USBHost* pHost );
thedo 166:3a9487d57a5c 47
thedo 166:3a9487d57a5c 48 void connect( USBDeviceConnected* pDev, USBEndpoint* pInEp, USBEndpoint* pOutEp );
thedo 166:3a9487d57a5c 49
thedo 166:3a9487d57a5c 50 void disconnect( );
thedo 166:3a9487d57a5c 51
thedo 166:3a9487d57a5c 52 /*
thedo 166:3a9487d57a5c 53 * Get a char from the dongle's serial interface
thedo 166:3a9487d57a5c 54 */
thedo 166:3a9487d57a5c 55 virtual int getc();
thedo 166:3a9487d57a5c 56
thedo 166:3a9487d57a5c 57 /*
thedo 166:3a9487d57a5c 58 * Put a char to the dongle's serial interface
thedo 166:3a9487d57a5c 59 */
thedo 166:3a9487d57a5c 60 virtual int putc(int c);
thedo 166:3a9487d57a5c 61
thedo 166:3a9487d57a5c 62 /*
thedo 166:3a9487d57a5c 63 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls
thedo 166:3a9487d57a5c 64 */
thedo 166:3a9487d57a5c 65 virtual int readPacket();
thedo 166:3a9487d57a5c 66
thedo 166:3a9487d57a5c 67 /*
thedo 166:3a9487d57a5c 68 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls
thedo 166:3a9487d57a5c 69 */
thedo 166:3a9487d57a5c 70 virtual int writePacket();
thedo 166:3a9487d57a5c 71
thedo 166:3a9487d57a5c 72 /**
thedo 166:3a9487d57a5c 73 * Check the number of bytes available.
thedo 166:3a9487d57a5c 74 *
thedo 166:3a9487d57a5c 75 * @returns the number of bytes available
thedo 166:3a9487d57a5c 76 */
thedo 166:3a9487d57a5c 77 virtual int readable();
thedo 166:3a9487d57a5c 78
thedo 166:3a9487d57a5c 79 /**
thedo 166:3a9487d57a5c 80 * Check the free space in output.
thedo 166:3a9487d57a5c 81 *
thedo 166:3a9487d57a5c 82 * @returns the number of bytes available
thedo 166:3a9487d57a5c 83 */
thedo 166:3a9487d57a5c 84 virtual int writeable();
thedo 166:3a9487d57a5c 85
thedo 166:3a9487d57a5c 86 /**
thedo 166:3a9487d57a5c 87 * Attach a handler to call when a packet is received / when a packet has been transmitted.
thedo 166:3a9487d57a5c 88 *
thedo 166:3a9487d57a5c 89 * @param pListener instance of the listener deriving from the IUSBHostSerialListener
thedo 166:3a9487d57a5c 90 */
thedo 166:3a9487d57a5c 91 virtual void attach(IUSBHostSerialListener* pListener);
thedo 166:3a9487d57a5c 92
thedo 166:3a9487d57a5c 93 /**
thedo 166:3a9487d57a5c 94 * Enable or disable readable/writeable callbacks
thedo 166:3a9487d57a5c 95 */
thedo 166:3a9487d57a5c 96 virtual void setupIrq(bool en, IrqType irq = RxIrq);
thedo 166:3a9487d57a5c 97
thedo 166:3a9487d57a5c 98
thedo 166:3a9487d57a5c 99 protected:
thedo 166:3a9487d57a5c 100 USBEndpoint * bulk_in;
thedo 166:3a9487d57a5c 101 USBEndpoint * bulk_out;
thedo 166:3a9487d57a5c 102 USBHost * host;
thedo 166:3a9487d57a5c 103 USBDeviceConnected * dev;
thedo 166:3a9487d57a5c 104
thedo 166:3a9487d57a5c 105 uint8_t buf_out[WANDONGLE_MAX_OUTEP_SIZE];
thedo 166:3a9487d57a5c 106 volatile uint32_t buf_out_len;
thedo 166:3a9487d57a5c 107 uint32_t max_out_size;
thedo 166:3a9487d57a5c 108 volatile bool lock_tx;
thedo 166:3a9487d57a5c 109 volatile bool cb_tx_en;
thedo 166:3a9487d57a5c 110 volatile bool cb_tx_pending;
thedo 166:3a9487d57a5c 111 Mutex tx_mtx;
thedo 166:3a9487d57a5c 112
thedo 166:3a9487d57a5c 113 uint8_t buf_in[WANDONGLE_MAX_INEP_SIZE];
thedo 166:3a9487d57a5c 114 volatile uint32_t buf_in_len;
thedo 166:3a9487d57a5c 115 volatile uint32_t buf_in_read_pos;
thedo 166:3a9487d57a5c 116 volatile bool lock_rx;
thedo 166:3a9487d57a5c 117 volatile bool cb_rx_en;
thedo 166:3a9487d57a5c 118 volatile bool cb_rx_pending;
thedo 166:3a9487d57a5c 119 Mutex rx_mtx;
thedo 166:3a9487d57a5c 120
thedo 166:3a9487d57a5c 121 IUSBHostSerialListener* listener;
thedo 166:3a9487d57a5c 122
thedo 166:3a9487d57a5c 123 void reset();
thedo 166:3a9487d57a5c 124
thedo 166:3a9487d57a5c 125 void rxHandler();
thedo 166:3a9487d57a5c 126 void txHandler();
thedo 166:3a9487d57a5c 127
thedo 166:3a9487d57a5c 128 };
thedo 166:3a9487d57a5c 129
thedo 166:3a9487d57a5c 130 #endif /* USBHOST_3GMODULE */
thedo 166:3a9487d57a5c 131
thedo 166:3a9487d57a5c 132 #endif
thedo 166:3a9487d57a5c 133