Vijayaraghavan Narayanan / VLX6180X_API
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers platform.cpp Source File

platform.cpp

00001 /*******************************************************************************
00002 ################################################################################
00003 #                             (C) STMicroelectronics 2014
00004 #
00005 # This program is free software; you can redistribute it and/or modify it under
00006 # the terms of the GNU General Public License version 2 and only version 2 as
00007 # published by the Free Software Foundation.
00008 #
00009 # This program is distributed in the hope that it will be useful, but WITHOUT
00010 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00012 # details.
00013 #
00014 # You should have received a copy of the GNU General Public License along with
00015 # this program; if not, write to the Free Software Foundation, Inc.,
00016 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 #
00018 #------------------------------------------------------------------------------
00019 #                             Imaging Division
00020 ################################################################################
00021 ********************************************************************************/
00022 
00023 #include "definitions.h"
00024 #include "platform.h"
00025 #include "debug.h"
00026 #include "i2c_log.h"
00027 #ifndef __KERNEL__
00028 #include "i2c_stm32_mbed.h"
00029 #include "timer_stm32_mbed.h"
00030 #else
00031 #include <linux/i2c.h>
00032 #define I2C_M_WR            0x00
00033 #endif
00034 static char time_str[255];
00035 
00036 void debug1_print(char* pBuffer)
00037 {
00038     //output to UART
00039     serial_printf(pBuffer);
00040 }
00041 
00042 void debug2_print(char* pBuffer)
00043 {
00044     //output to UART
00045     serial_printf(pBuffer);
00046 }
00047 
00048 void i2c_initialise(uint32_t addr)
00049 {
00050     stm32_i2c_initialise(addr);
00051 }
00052 
00053 void i2c_close()
00054 {
00055     stm32_i2c_close();
00056 }
00057 
00058 void i2c_write_byte(uint32_t reg, uint8_t data, uint8_t baseAddr)
00059 {
00060     stm32_i2c_write_byte(reg, data, baseAddr);
00061     i2c_log_outputWriteByteMsg(data, reg);
00062 }
00063 
00064 
00065 void i2c_write_word(uint32_t reg, uint16_t data, uint8_t baseAddr)
00066 {
00067     stm32_i2c_write_word(reg, data, baseAddr);
00068     i2c_log_outputWriteWordMsg(data, reg);
00069 }
00070 
00071 void i2c_write(uint32_t reg, uint8_t *data, int32_t size, uint8_t baseAddr)
00072 {
00073     stm32_i2c_write(reg, data, size, baseAddr);
00074     i2c_log_outputWriteMsg(data, reg, size);
00075 }
00076 
00077 uint8_t i2c_read_byte(uint32_t reg, uint8_t baseAddr)
00078 {
00079     uint8_t data = stm32_i2c_read_byte(reg, baseAddr);
00080     i2c_log_outputReadByteMsg(data, reg);
00081     return data;
00082 }
00083 
00084 uint16_t i2c_read_word(uint32_t reg, uint8_t baseAddr)
00085 {
00086     uint16_t data = stm32_i2c_read_word(reg, baseAddr);
00087     i2c_log_outputReadWordMsg(data, reg);
00088     return data;
00089 }
00090 
00091 uint32_t i2c_read_uint32(uint32_t reg, uint8_t baseAddr)
00092 {
00093     uint32_t data = stm32_i2c_read_int(reg, baseAddr);
00094     i2c_log_outputReadIntMsg(data, reg);
00095     return data;
00096 }
00097 
00098 void i2c_read(uint32_t reg, uint8_t *dataOut, int32_t size, uint8_t baseAddr)
00099 {
00100     stm32_i2c_read(reg, dataOut, size, baseAddr);
00101     i2c_log_outputReadMsg(dataOut, reg, size);
00102 }
00103 
00104 void timer_start()
00105 {
00106     stm32_timer_start();
00107 }
00108 
00109 double_t timer_elapsedTime()
00110 {
00111     return stm32_timer_elapsed_time();
00112 }
00113 
00114 void timer_stop()
00115 {
00116     stm32_timer_stop();
00117 }
00118 
00119 void timer_wait_ms(int32_t ms)
00120 {
00121     stm32_timer_wait_ms((int)ms);
00122 }
00123 
00124 void timer_wait_us(int32_t us)
00125 {
00126     stm32_timer_wait_us((int)us);
00127 }
00128 
00129 uint32_t timer_get_clock_time_usecs()
00130 {
00131     return stm32_timer_get_clock_time_usecs();
00132 }
00133 
00134 uint32_t timer_get_clock_time_msecs()
00135 {
00136     return stm32_timer_get_clock_time_msecs();
00137 }
00138 
00139 char* timer_get_clock_timestamp()
00140 {
00141     stm32_timer_get_clock_timestamp(time_str);
00142     return time_str;
00143 }
00144