Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
I2CTester.h
00001 /* 00002 * Copyright (c) 2019, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef I2C_TESTER_H 00019 #define I2C_TESTER_H 00020 00021 #include "MbedTester.h" 00022 00023 00024 class I2CTester: public MbedTester { 00025 public: 00026 00027 I2CTester(const PinList *form_factor, const PinList *exclude_pins) 00028 : MbedTester(form_factor, exclude_pins) 00029 { 00030 00031 } 00032 00033 /* **I2C peripheral functions** */ 00034 00035 /** 00036 * Get the number of start conditions since last I2C reset 00037 * 00038 * @return The number of start conditions 00039 */ 00040 uint8_t num_starts(); 00041 00042 /** 00043 * Get the number of stop conditions since last I2C reset 00044 * 00045 * @return The number of stop conditions 00046 */ 00047 uint8_t num_stops(); 00048 00049 /** 00050 * Get the number of ACKs since last I2C reset 00051 * 00052 * @return The number of ACKs 00053 */ 00054 uint16_t num_acks(); 00055 00056 /** 00057 * Get the number of NACKs since last I2C reset 00058 * 00059 * @return The number of NACKs 00060 */ 00061 uint16_t num_nacks(); 00062 00063 /** 00064 * Read the number of transfers which have occurred 00065 * 00066 * @return The number of I2C transfers that have completed since 00067 * i2c was reset, including the device address byte. 00068 */ 00069 uint16_t transfer_count(); 00070 00071 /** 00072 * Read a checksum of data send to the tester 00073 * 00074 * @return The sum of all bytes sent to the tester since reset 00075 */ 00076 uint32_t get_receive_checksum(); 00077 00078 /** 00079 * Read a checksum the tester calculated for data it has already sent 00080 * 00081 * @return The sum of all bytes the tester has sent since reset 00082 */ 00083 uint32_t get_send_checksum(); 00084 00085 /** 00086 * Get the I2C slave state number 00087 * 00088 * @return The state number 00089 */ 00090 uint8_t state_num(); 00091 00092 /** 00093 * Get the number of times the device address has been sent correctly 00094 * 00095 * @return The number of times the device address has been sent correctly 00096 */ 00097 uint8_t num_dev_addr_matches(); 00098 00099 /** 00100 * Get the number of times the device address has been sent incorrectly 00101 * 00102 * @return The number of times the device address has been sent incorrectly 00103 */ 00104 uint8_t num_dev_addr_mismatches(); 00105 00106 /** 00107 * Set the I2C slave device address 00108 * 00109 * @param addr New address for slave device 00110 */ 00111 void set_device_address(uint16_t addr); 00112 00113 /** 00114 * Get the I2C slave device address 00115 * 00116 * @return The slave device address 00117 */ 00118 uint16_t get_device_address(); 00119 00120 /** 00121 * Set SDA (test mode) 00122 * 00123 * @param value Test value for SDA 00124 */ 00125 void set_sda(uint8_t value); 00126 00127 /** 00128 * Get the value written to slave in the fourth to last transaction 00129 * 00130 * @return value written to slave in the fourth to last transaction 00131 */ 00132 uint8_t get_prev_to_slave_4(); 00133 00134 /** 00135 * Get the value written to slave in the third to last transaction 00136 * 00137 * @return value written to slave in the third to last transaction 00138 */ 00139 uint8_t get_prev_to_slave_3(); 00140 00141 /** 00142 * Get the value written to slave in the second to last transaction 00143 * 00144 * @return value written to slave in the second to last transaction 00145 */ 00146 uint8_t get_prev_to_slave_2(); 00147 00148 /** 00149 * Get the value written to slave in the last transaction 00150 * 00151 * @return value written to slave in the last transaction 00152 */ 00153 uint8_t get_prev_to_slave_1(); 00154 00155 /** 00156 * Set the value to be read from slave in next read transaction 00157 * 00158 * @param value Value to be read from slave in next read transaction 00159 */ 00160 void set_next_from_slave(uint8_t value); 00161 00162 /** 00163 * Get the value to be read from slave in next read transaction 00164 * 00165 * @return Value to be read from slave in next read transaction 00166 */ 00167 uint8_t get_next_from_slave(); 00168 00169 /** 00170 * Read the number of writes which have occurred 00171 * 00172 * @return The number of I2C writes that have completed since 00173 * i2c was reset, not including the device address byte 00174 */ 00175 uint16_t num_writes(); 00176 00177 /** 00178 * Read the number of reads which have occurred 00179 * 00180 * @return The number of I2C reads that have completed since 00181 * i2c was reset, not including the device address byte 00182 */ 00183 uint16_t num_reads(); 00184 00185 }; 00186 00187 #endif
Generated on Tue Jul 12 2022 13:54:24 by
