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:
167:1657b442184c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 167:1657b442184c 1 /* mbed Microcontroller Library
thedo 167:1657b442184c 2 * Copyright (c) 2017 ARM Limited
thedo 167:1657b442184c 3 *
thedo 167:1657b442184c 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
thedo 167:1657b442184c 5 * of this software and associated documentation files (the "Software"), to deal
thedo 167:1657b442184c 6 * in the Software without restriction, including without limitation the rights
thedo 167:1657b442184c 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
thedo 167:1657b442184c 8 * copies of the Software, and to permit persons to whom the Software is
thedo 167:1657b442184c 9 * furnished to do so, subject to the following conditions:
thedo 167:1657b442184c 10 *
thedo 167:1657b442184c 11 * The above copyright notice and this permission notice shall be included in
thedo 167:1657b442184c 12 * all copies or substantial portions of the Software.
thedo 167:1657b442184c 13 *
thedo 167:1657b442184c 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
thedo 167:1657b442184c 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
thedo 167:1657b442184c 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
thedo 167:1657b442184c 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
thedo 167:1657b442184c 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
thedo 167:1657b442184c 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
thedo 167:1657b442184c 20 * SOFTWARE.
thedo 167:1657b442184c 21 */
thedo 167:1657b442184c 22 #ifndef MBED_FLASHIAP_H
thedo 167:1657b442184c 23 #define MBED_FLASHIAP_H
thedo 167:1657b442184c 24
thedo 167:1657b442184c 25 #if defined (DEVICE_FLASH) || defined(DOXYGEN_ONLY)
thedo 167:1657b442184c 26
thedo 167:1657b442184c 27 #include "flash_api.h"
thedo 167:1657b442184c 28 #include "platform/SingletonPtr.h"
thedo 167:1657b442184c 29 #include "platform/PlatformMutex.h"
thedo 167:1657b442184c 30
thedo 167:1657b442184c 31 namespace mbed {
thedo 167:1657b442184c 32
thedo 167:1657b442184c 33 /** \addtogroup drivers */
thedo 167:1657b442184c 34
thedo 167:1657b442184c 35 /** Flash IAP driver. It invokes flash HAL functions.
thedo 167:1657b442184c 36 *
thedo 167:1657b442184c 37 * @note Synchronization level: Thread safe
thedo 167:1657b442184c 38 * @ingroup drivers
thedo 167:1657b442184c 39 */
thedo 167:1657b442184c 40 class FlashIAP {
thedo 167:1657b442184c 41 public:
thedo 167:1657b442184c 42 FlashIAP();
thedo 167:1657b442184c 43 ~FlashIAP();
thedo 167:1657b442184c 44
thedo 167:1657b442184c 45 /** Initialize a flash IAP device
thedo 167:1657b442184c 46 *
thedo 167:1657b442184c 47 * Should be called once per lifetime of the object.
thedo 167:1657b442184c 48 * @return 0 on success or a negative error code on failure
thedo 167:1657b442184c 49 */
thedo 167:1657b442184c 50 int init();
thedo 167:1657b442184c 51
thedo 167:1657b442184c 52 /** Deinitialize a flash IAP device
thedo 167:1657b442184c 53 *
thedo 167:1657b442184c 54 * @return 0 on success or a negative error code on failure
thedo 167:1657b442184c 55 */
thedo 167:1657b442184c 56 int deinit();
thedo 167:1657b442184c 57
thedo 167:1657b442184c 58 /** Read data from a flash device.
thedo 167:1657b442184c 59 *
thedo 167:1657b442184c 60 * This method invokes memcpy - reads number of bytes from the address
thedo 167:1657b442184c 61 *
thedo 167:1657b442184c 62 * @param buffer Buffer to write to
thedo 167:1657b442184c 63 * @param addr Flash address to begin reading from
thedo 167:1657b442184c 64 * @param size Size to read in bytes
thedo 167:1657b442184c 65 * @return 0 on success, negative error code on failure
thedo 167:1657b442184c 66 */
thedo 167:1657b442184c 67 int read(void *buffer, uint32_t addr, uint32_t size);
thedo 167:1657b442184c 68
thedo 167:1657b442184c 69 /** Program data to pages
thedo 167:1657b442184c 70 *
thedo 167:1657b442184c 71 * The sectors must have been erased prior to being programmed
thedo 167:1657b442184c 72 *
thedo 167:1657b442184c 73 * @param buffer Buffer of data to be written
thedo 167:1657b442184c 74 * @param addr Address of a page to begin writing to, must be a multiple of program and sector sizes
thedo 167:1657b442184c 75 * @param size Size to write in bytes, must be a multiple of program and sector sizes
thedo 167:1657b442184c 76 * @return 0 on success, negative error code on failure
thedo 167:1657b442184c 77 */
thedo 167:1657b442184c 78 int program(const void *buffer, uint32_t addr, uint32_t size);
thedo 167:1657b442184c 79
thedo 167:1657b442184c 80 /** Erase sectors
thedo 167:1657b442184c 81 *
thedo 167:1657b442184c 82 * The state of an erased sector is undefined until it has been programmed
thedo 167:1657b442184c 83 *
thedo 167:1657b442184c 84 * @param addr Address of a sector to begin erasing, must be a multiple of the sector size
thedo 167:1657b442184c 85 * @param size Size to erase in bytes, must be a multiple of the sector size
thedo 167:1657b442184c 86 * @return 0 on success, negative error code on failure
thedo 167:1657b442184c 87 */
thedo 167:1657b442184c 88 int erase(uint32_t addr, uint32_t size);
thedo 167:1657b442184c 89
thedo 167:1657b442184c 90 /** Get the sector size at the defined address
thedo 167:1657b442184c 91 *
thedo 167:1657b442184c 92 * Sector size might differ at address ranges.
thedo 167:1657b442184c 93 * An example <0-0x1000, sector size=1024; 0x10000-0x20000, size=2048>
thedo 167:1657b442184c 94 *
thedo 167:1657b442184c 95 * @param addr Address of or inside the sector to query
thedo 167:1657b442184c 96 * @return Size of a sector in bytes or MBED_FLASH_INVALID_SIZE if not mapped
thedo 167:1657b442184c 97 */
thedo 167:1657b442184c 98 uint32_t get_sector_size(uint32_t addr) const;
thedo 167:1657b442184c 99
thedo 167:1657b442184c 100 /** Get the flash start address
thedo 167:1657b442184c 101 *
thedo 167:1657b442184c 102 * @return Flash start address
thedo 167:1657b442184c 103 */
thedo 167:1657b442184c 104 uint32_t get_flash_start() const;
thedo 167:1657b442184c 105
thedo 167:1657b442184c 106 /** Get the flash size
thedo 167:1657b442184c 107 *
thedo 167:1657b442184c 108 * @return Flash size
thedo 167:1657b442184c 109 */
thedo 167:1657b442184c 110 uint32_t get_flash_size() const;
thedo 167:1657b442184c 111
thedo 167:1657b442184c 112 /** Get the program page size
thedo 167:1657b442184c 113 *
thedo 167:1657b442184c 114 * @return Size of a program page in bytes
thedo 167:1657b442184c 115 */
thedo 167:1657b442184c 116 uint32_t get_page_size() const;
thedo 167:1657b442184c 117
thedo 167:1657b442184c 118 private:
thedo 167:1657b442184c 119
thedo 167:1657b442184c 120 /* Check if address and size are aligned to a sector
thedo 167:1657b442184c 121 *
thedo 167:1657b442184c 122 * @param addr Address of block to check for alignment
thedo 167:1657b442184c 123 * @param size Size of block to check for alignment
thedo 167:1657b442184c 124 * @return true if the block is sector aligned, false otherwise
thedo 167:1657b442184c 125 */
thedo 167:1657b442184c 126 bool is_aligned_to_sector(uint32_t addr, uint32_t size);
thedo 167:1657b442184c 127
thedo 167:1657b442184c 128 flash_t _flash;
thedo 167:1657b442184c 129 static SingletonPtr<PlatformMutex> _mutex;
thedo 167:1657b442184c 130 };
thedo 167:1657b442184c 131
thedo 167:1657b442184c 132 } /* namespace mbed */
thedo 167:1657b442184c 133
thedo 167:1657b442184c 134 #endif /* DEVICE_FLASH */
thedo 167:1657b442184c 135
thedo 167:1657b442184c 136 #endif /* MBED_FLASHIAP_H */
thedo 167:1657b442184c 137