vlx lib
platform.h@0:bc9f26b5dadf, 2015-02-08 (annotated)
- Committer:
- vijaynvr
- Date:
- Sun Feb 08 14:26:51 2015 +0000
- Revision:
- 0:bc9f26b5dadf
working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vijaynvr | 0:bc9f26b5dadf | 1 | /******************************************************************************* |
vijaynvr | 0:bc9f26b5dadf | 2 | ################################################################################ |
vijaynvr | 0:bc9f26b5dadf | 3 | # |
vijaynvr | 0:bc9f26b5dadf | 4 | # This program is free software; you can redistribute it and/or modify it under |
vijaynvr | 0:bc9f26b5dadf | 5 | # the terms of the GNU General Public License version 2 and only version 2 as |
vijaynvr | 0:bc9f26b5dadf | 6 | # published by the Free Software Foundation. |
vijaynvr | 0:bc9f26b5dadf | 7 | # |
vijaynvr | 0:bc9f26b5dadf | 8 | # This program is distributed in the hope that it will be useful, but WITHOUT |
vijaynvr | 0:bc9f26b5dadf | 9 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
vijaynvr | 0:bc9f26b5dadf | 10 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
vijaynvr | 0:bc9f26b5dadf | 11 | # details. |
vijaynvr | 0:bc9f26b5dadf | 12 | # |
vijaynvr | 0:bc9f26b5dadf | 13 | # You should have received a copy of the GNU General Public License along with |
vijaynvr | 0:bc9f26b5dadf | 14 | # this program; if not, write to the Free Software Foundation, Inc., |
vijaynvr | 0:bc9f26b5dadf | 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
vijaynvr | 0:bc9f26b5dadf | 16 | # |
vijaynvr | 0:bc9f26b5dadf | 17 | #------------------------------------------------------------------------------ |
vijaynvr | 0:bc9f26b5dadf | 18 | # Imaging Division |
vijaynvr | 0:bc9f26b5dadf | 19 | ################################################################################ |
vijaynvr | 0:bc9f26b5dadf | 20 | ********************************************************************************/ |
vijaynvr | 0:bc9f26b5dadf | 21 | |
vijaynvr | 0:bc9f26b5dadf | 22 | /** |
vijaynvr | 0:bc9f26b5dadf | 23 | * @file platform.h |
vijaynvr | 0:bc9f26b5dadf | 24 | * |
vijaynvr | 0:bc9f26b5dadf | 25 | * @brief All platform specific declarations to be used by the High Level API are defined here. |
vijaynvr | 0:bc9f26b5dadf | 26 | * The developer is responsible for providing the implementation of the prototypes declared. |
vijaynvr | 0:bc9f26b5dadf | 27 | * |
vijaynvr | 0:bc9f26b5dadf | 28 | */ |
vijaynvr | 0:bc9f26b5dadf | 29 | |
vijaynvr | 0:bc9f26b5dadf | 30 | #ifndef _PLATFORM |
vijaynvr | 0:bc9f26b5dadf | 31 | #define _PLATFORM |
vijaynvr | 0:bc9f26b5dadf | 32 | #ifndef __KERNEL__ |
vijaynvr | 0:bc9f26b5dadf | 33 | #include <stdbool.h> |
vijaynvr | 0:bc9f26b5dadf | 34 | #include <stdint.h> |
vijaynvr | 0:bc9f26b5dadf | 35 | #endif |
vijaynvr | 0:bc9f26b5dadf | 36 | /** @brief Typedef defining .\n |
vijaynvr | 0:bc9f26b5dadf | 37 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 38 | */ |
vijaynvr | 0:bc9f26b5dadf | 39 | #ifndef TRUE |
vijaynvr | 0:bc9f26b5dadf | 40 | #define TRUE 1 |
vijaynvr | 0:bc9f26b5dadf | 41 | #endif |
vijaynvr | 0:bc9f26b5dadf | 42 | |
vijaynvr | 0:bc9f26b5dadf | 43 | #ifndef FALSE |
vijaynvr | 0:bc9f26b5dadf | 44 | #define FALSE 0 |
vijaynvr | 0:bc9f26b5dadf | 45 | #endif |
vijaynvr | 0:bc9f26b5dadf | 46 | |
vijaynvr | 0:bc9f26b5dadf | 47 | /** @brief Typedef defining 8 bit unsigned char type.\n |
vijaynvr | 0:bc9f26b5dadf | 48 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 49 | */ |
vijaynvr | 0:bc9f26b5dadf | 50 | typedef unsigned char bool_t; |
vijaynvr | 0:bc9f26b5dadf | 51 | |
vijaynvr | 0:bc9f26b5dadf | 52 | #ifndef _STDINT_H |
vijaynvr | 0:bc9f26b5dadf | 53 | |
vijaynvr | 0:bc9f26b5dadf | 54 | /** @brief Typedef defining 64 bit unsigned long type.\n |
vijaynvr | 0:bc9f26b5dadf | 55 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 56 | */ |
vijaynvr | 0:bc9f26b5dadf | 57 | typedef unsigned long long uint64_t; |
vijaynvr | 0:bc9f26b5dadf | 58 | |
vijaynvr | 0:bc9f26b5dadf | 59 | /** @brief Typedef defining 64 bit long type.\n |
vijaynvr | 0:bc9f26b5dadf | 60 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 61 | */ |
vijaynvr | 0:bc9f26b5dadf | 62 | typedef long long long64_t; |
vijaynvr | 0:bc9f26b5dadf | 63 | |
vijaynvr | 0:bc9f26b5dadf | 64 | /** @brief Typedef defining 32 bit unsigned int type.\n |
vijaynvr | 0:bc9f26b5dadf | 65 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 66 | */ |
vijaynvr | 0:bc9f26b5dadf | 67 | typedef unsigned int uint32_t; |
vijaynvr | 0:bc9f26b5dadf | 68 | |
vijaynvr | 0:bc9f26b5dadf | 69 | /** @brief Typedef defining 32 bit int type.\n |
vijaynvr | 0:bc9f26b5dadf | 70 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 71 | */ |
vijaynvr | 0:bc9f26b5dadf | 72 | typedef int int32_t; |
vijaynvr | 0:bc9f26b5dadf | 73 | |
vijaynvr | 0:bc9f26b5dadf | 74 | /** @brief Typedef defining 16 bit unsigned short type.\n |
vijaynvr | 0:bc9f26b5dadf | 75 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 76 | */ |
vijaynvr | 0:bc9f26b5dadf | 77 | typedef unsigned short uint16_t; |
vijaynvr | 0:bc9f26b5dadf | 78 | |
vijaynvr | 0:bc9f26b5dadf | 79 | /** @brief Typedef defining 16 bit short type.\n |
vijaynvr | 0:bc9f26b5dadf | 80 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 81 | */ |
vijaynvr | 0:bc9f26b5dadf | 82 | typedef short int16_t; |
vijaynvr | 0:bc9f26b5dadf | 83 | |
vijaynvr | 0:bc9f26b5dadf | 84 | /** @brief Typedef defining 8 bit unsigned char type.\n |
vijaynvr | 0:bc9f26b5dadf | 85 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 86 | */ |
vijaynvr | 0:bc9f26b5dadf | 87 | typedef unsigned char uint8_t; |
vijaynvr | 0:bc9f26b5dadf | 88 | |
vijaynvr | 0:bc9f26b5dadf | 89 | /** @brief Typedef defining 8 bit char type.\n |
vijaynvr | 0:bc9f26b5dadf | 90 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 91 | */ |
vijaynvr | 0:bc9f26b5dadf | 92 | typedef signed char int8_t; |
vijaynvr | 0:bc9f26b5dadf | 93 | |
vijaynvr | 0:bc9f26b5dadf | 94 | #endif //_STDINT_H |
vijaynvr | 0:bc9f26b5dadf | 95 | |
vijaynvr | 0:bc9f26b5dadf | 96 | /** @brief Typedef defining 64 bit double type.\n |
vijaynvr | 0:bc9f26b5dadf | 97 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 98 | */ |
vijaynvr | 0:bc9f26b5dadf | 99 | typedef double double_t; |
vijaynvr | 0:bc9f26b5dadf | 100 | |
vijaynvr | 0:bc9f26b5dadf | 101 | /** @brief Typedef defining 32 bit float type.\n |
vijaynvr | 0:bc9f26b5dadf | 102 | * The developer should modify this to suit the platform being deployed. |
vijaynvr | 0:bc9f26b5dadf | 103 | */ |
vijaynvr | 0:bc9f26b5dadf | 104 | typedef float float_t; |
vijaynvr | 0:bc9f26b5dadf | 105 | |
vijaynvr | 0:bc9f26b5dadf | 106 | #ifndef NULL |
vijaynvr | 0:bc9f26b5dadf | 107 | #define NULL 0 |
vijaynvr | 0:bc9f26b5dadf | 108 | #endif |
vijaynvr | 0:bc9f26b5dadf | 109 | |
vijaynvr | 0:bc9f26b5dadf | 110 | /** |
vijaynvr | 0:bc9f26b5dadf | 111 | * @brief Method to print a given string to the program output. |
vijaynvr | 0:bc9f26b5dadf | 112 | */ |
vijaynvr | 0:bc9f26b5dadf | 113 | void debug1_print(char *pBuffer); |
vijaynvr | 0:bc9f26b5dadf | 114 | |
vijaynvr | 0:bc9f26b5dadf | 115 | /** |
vijaynvr | 0:bc9f26b5dadf | 116 | * @brief Method to print a given string to the program output. |
vijaynvr | 0:bc9f26b5dadf | 117 | */ |
vijaynvr | 0:bc9f26b5dadf | 118 | void debug2_print(char *pBuffer); |
vijaynvr | 0:bc9f26b5dadf | 119 | |
vijaynvr | 0:bc9f26b5dadf | 120 | /** |
vijaynvr | 0:bc9f26b5dadf | 121 | * Method to initialise a given I2C device for a given I2C |
vijaynvr | 0:bc9f26b5dadf | 122 | * address. |
vijaynvr | 0:bc9f26b5dadf | 123 | */ |
vijaynvr | 0:bc9f26b5dadf | 124 | void i2c_initialise(uint32_t addr); |
vijaynvr | 0:bc9f26b5dadf | 125 | |
vijaynvr | 0:bc9f26b5dadf | 126 | /** |
vijaynvr | 0:bc9f26b5dadf | 127 | * Method to close device if opened. |
vijaynvr | 0:bc9f26b5dadf | 128 | */ |
vijaynvr | 0:bc9f26b5dadf | 129 | void i2c_close(); |
vijaynvr | 0:bc9f26b5dadf | 130 | |
vijaynvr | 0:bc9f26b5dadf | 131 | /** |
vijaynvr | 0:bc9f26b5dadf | 132 | * Method to write a single byte to a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 133 | * Throws WriteFail upon failure. |
vijaynvr | 0:bc9f26b5dadf | 134 | */ |
vijaynvr | 0:bc9f26b5dadf | 135 | void i2c_write_byte(uint32_t reg, uint8_t data, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 136 | |
vijaynvr | 0:bc9f26b5dadf | 137 | /** |
vijaynvr | 0:bc9f26b5dadf | 138 | * Method to write a single word to a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 139 | * Throws WriteFail upon failure. |
vijaynvr | 0:bc9f26b5dadf | 140 | */ |
vijaynvr | 0:bc9f26b5dadf | 141 | void i2c_write_word(uint32_t reg, uint16_t data, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 142 | |
vijaynvr | 0:bc9f26b5dadf | 143 | /** |
vijaynvr | 0:bc9f26b5dadf | 144 | * Method to write an array of bytes to a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 145 | * Throws WriteFail upon failure. |
vijaynvr | 0:bc9f26b5dadf | 146 | */ |
vijaynvr | 0:bc9f26b5dadf | 147 | void i2c_write(uint32_t reg, uint8_t *data, int32_t size, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 148 | |
vijaynvr | 0:bc9f26b5dadf | 149 | /** |
vijaynvr | 0:bc9f26b5dadf | 150 | * Method to read a single byte from a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 151 | * Throws ReadFail upon error. |
vijaynvr | 0:bc9f26b5dadf | 152 | */ |
vijaynvr | 0:bc9f26b5dadf | 153 | uint8_t i2c_read_byte(uint32_t reg, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 154 | |
vijaynvr | 0:bc9f26b5dadf | 155 | /** |
vijaynvr | 0:bc9f26b5dadf | 156 | * Method to read a two byte word from a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 157 | * Throws ReadFail upon error. |
vijaynvr | 0:bc9f26b5dadf | 158 | */ |
vijaynvr | 0:bc9f26b5dadf | 159 | uint16_t i2c_read_word(uint32_t reg, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 160 | |
vijaynvr | 0:bc9f26b5dadf | 161 | /** |
vijaynvr | 0:bc9f26b5dadf | 162 | * Method to read an int32 from a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 163 | * Throws ReadFail upon error. |
vijaynvr | 0:bc9f26b5dadf | 164 | */ |
vijaynvr | 0:bc9f26b5dadf | 165 | uint32_t i2c_read_uint32(uint32_t reg, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 166 | |
vijaynvr | 0:bc9f26b5dadf | 167 | /** |
vijaynvr | 0:bc9f26b5dadf | 168 | * Method to read multiple bytes from a given I2C reg index. |
vijaynvr | 0:bc9f26b5dadf | 169 | * Throws ReadFail upon error. |
vijaynvr | 0:bc9f26b5dadf | 170 | */ |
vijaynvr | 0:bc9f26b5dadf | 171 | void i2c_read(uint32_t reg, uint8_t* data, int32_t size, uint8_t baseAddr); |
vijaynvr | 0:bc9f26b5dadf | 172 | |
vijaynvr | 0:bc9f26b5dadf | 173 | /** |
vijaynvr | 0:bc9f26b5dadf | 174 | * Method to start the timer. |
vijaynvr | 0:bc9f26b5dadf | 175 | */ |
vijaynvr | 0:bc9f26b5dadf | 176 | void timer_start(); |
vijaynvr | 0:bc9f26b5dadf | 177 | |
vijaynvr | 0:bc9f26b5dadf | 178 | /** |
vijaynvr | 0:bc9f26b5dadf | 179 | * Method reporting the number of seconds elapsed since the timer was started. |
vijaynvr | 0:bc9f26b5dadf | 180 | */ |
vijaynvr | 0:bc9f26b5dadf | 181 | double_t timer_elapsedTime(); |
vijaynvr | 0:bc9f26b5dadf | 182 | |
vijaynvr | 0:bc9f26b5dadf | 183 | /** |
vijaynvr | 0:bc9f26b5dadf | 184 | * Method to stop the timer. |
vijaynvr | 0:bc9f26b5dadf | 185 | */ |
vijaynvr | 0:bc9f26b5dadf | 186 | void timer_stop(); |
vijaynvr | 0:bc9f26b5dadf | 187 | |
vijaynvr | 0:bc9f26b5dadf | 188 | /** |
vijaynvr | 0:bc9f26b5dadf | 189 | * Method to wait a given number of ms. |
vijaynvr | 0:bc9f26b5dadf | 190 | */ |
vijaynvr | 0:bc9f26b5dadf | 191 | void timer_wait_ms(int32_t ms); |
vijaynvr | 0:bc9f26b5dadf | 192 | |
vijaynvr | 0:bc9f26b5dadf | 193 | /** |
vijaynvr | 0:bc9f26b5dadf | 194 | * Method to wait a given number of us |
vijaynvr | 0:bc9f26b5dadf | 195 | */ |
vijaynvr | 0:bc9f26b5dadf | 196 | void timer_wait_us(int32_t us); |
vijaynvr | 0:bc9f26b5dadf | 197 | |
vijaynvr | 0:bc9f26b5dadf | 198 | /** |
vijaynvr | 0:bc9f26b5dadf | 199 | * Method to report the current clock time in us. |
vijaynvr | 0:bc9f26b5dadf | 200 | */ |
vijaynvr | 0:bc9f26b5dadf | 201 | uint32_t timer_get_clock_time_usecs(); |
vijaynvr | 0:bc9f26b5dadf | 202 | |
vijaynvr | 0:bc9f26b5dadf | 203 | /** |
vijaynvr | 0:bc9f26b5dadf | 204 | * Method to report the current clock time in ms. |
vijaynvr | 0:bc9f26b5dadf | 205 | */ |
vijaynvr | 0:bc9f26b5dadf | 206 | uint32_t timer_get_clock_time_msecs(); |
vijaynvr | 0:bc9f26b5dadf | 207 | |
vijaynvr | 0:bc9f26b5dadf | 208 | #endif /* _PLATFORM */ |
vijaynvr | 0:bc9f26b5dadf | 209 | |
vijaynvr | 0:bc9f26b5dadf | 210 |