![]() |
|
|||
File indexing completed on 2025-05-11 08:24:51
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup DevGrlibValIo 0007 */ 0008 0009 /* 0010 * Copyright (C) 2021 embedded brains GmbH & Co. KG 0011 * 0012 * Redistribution and use in source and binary forms, with or without 0013 * modification, are permitted provided that the following conditions 0014 * are met: 0015 * 1. Redistributions of source code must retain the above copyright 0016 * notice, this list of conditions and the following disclaimer. 0017 * 2. Redistributions in binary form must reproduce the above copyright 0018 * notice, this list of conditions and the following disclaimer in the 0019 * documentation and/or other materials provided with the distribution. 0020 * 0021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0031 * POSSIBILITY OF SUCH DAMAGE. 0032 */ 0033 0034 /* 0035 * This file is part of the RTEMS quality process and was automatically 0036 * generated. If you find something that needs to be fixed or 0037 * worded better please post a report or patch to an RTEMS mailing list 0038 * or raise a bug report: 0039 * 0040 * https://www.rtems.org/bugs.html 0041 * 0042 * For information on updating and regenerating please refer to the How-To 0043 * section in the Software Requirements Engineering chapter of the 0044 * RTEMS Software Engineering manual. The manual is provided as a part of 0045 * a release. For development sources please refer to the online 0046 * documentation at: 0047 * 0048 * https://docs.rtems.org 0049 */ 0050 0051 #ifdef HAVE_CONFIG_H 0052 #include "config.h" 0053 #endif 0054 0055 #include <string.h> 0056 #include <grlib/apbuart.h> 0057 #include <grlib/io.h> 0058 0059 #include "tx-support.h" 0060 0061 #include <rtems/test.h> 0062 0063 /** 0064 * @defgroup DevGrlibValIo spec:/dev/grlib/val/io 0065 * 0066 * @ingroup TestsuitesBspsValidationBsp0 0067 * 0068 * @brief Tests some @ref RTEMSDeviceGRLIB directives. 0069 * 0070 * This test case performs the following actions: 0071 * 0072 * - Call grlib_load_8() to load a prepared value. 0073 * 0074 * - Check that the returned value is equal to the prepared value. 0075 * 0076 * - Call grlib_load_16() to load a prepared value. 0077 * 0078 * - Check that the returned value is equal to the prepared value. 0079 * 0080 * - Call grlib_load_32() to load a prepared value. 0081 * 0082 * - Check that the returned value is equal to the prepared value. 0083 * 0084 * - Call grlib_load_64() to load a prepared value. 0085 * 0086 * - Check that the returned value is equal to the prepared value. 0087 * 0088 * - Call grlib_store_8() to store a value to an object. 0089 * 0090 * - Check that the value of the object is equal to the stored value. 0091 * 0092 * - Call grlib_store_16() to store a value to an object. 0093 * 0094 * - Check that the value of the object is equal to the stored value. 0095 * 0096 * - Call grlib_store_32() to store a value to an object. 0097 * 0098 * - Check that the value of the object is equal to the stored value. 0099 * 0100 * - Call grlib_store_64() to store a value to an object. 0101 * 0102 * - Check that the value of the object is equal to the stored value. 0103 * 0104 * - Call apbuart_outbyte_polled() to store a character to the data register. 0105 * The transmitter FIFO shall be initially non-empty. The status is checked 0106 * by apbuart_outbyte_wait(). 0107 * 0108 * - Check that the transmitter FIFO empty flag was set by ApbuartIORelax(). 0109 * 0110 * - Check that the data register was written by apbuart_outbyte_polled(). 0111 * 0112 * @{ 0113 */ 0114 0115 static void ApbuartIORelax( void *arg ) 0116 { 0117 apbuart *regs; 0118 0119 regs = arg; 0120 regs->status = 0x4; 0121 T_quiet_eq_u32( regs->data, 0 ); 0122 } 0123 0124 /** 0125 * @brief Call grlib_load_8() to load a prepared value. 0126 */ 0127 static void DevGrlibValIo_Action_0( void ) 0128 { 0129 uint8_t reg_8; 0130 uint8_t val_8; 0131 0132 reg_8 = 0x81; 0133 val_8 = grlib_load_8( ®_8 ); 0134 0135 /* 0136 * Check that the returned value is equal to the prepared value. 0137 */ 0138 T_step_eq_u8( 0, val_8, 0x81 ); 0139 } 0140 0141 /** 0142 * @brief Call grlib_load_16() to load a prepared value. 0143 */ 0144 static void DevGrlibValIo_Action_1( void ) 0145 { 0146 uint16_t reg_16; 0147 uint16_t val_16; 0148 0149 reg_16 = 0x8001; 0150 val_16 = grlib_load_16( ®_16 ); 0151 0152 /* 0153 * Check that the returned value is equal to the prepared value. 0154 */ 0155 T_step_eq_u16( 1, val_16, 0x8001 ); 0156 } 0157 0158 /** 0159 * @brief Call grlib_load_32() to load a prepared value. 0160 */ 0161 static void DevGrlibValIo_Action_2( void ) 0162 { 0163 uint32_t reg_32; 0164 uint32_t val_32; 0165 0166 reg_32 = 0x80000001; 0167 val_32 = grlib_load_32( ®_32 ); 0168 0169 /* 0170 * Check that the returned value is equal to the prepared value. 0171 */ 0172 T_step_eq_u32( 2, val_32, 0x80000001 ); 0173 } 0174 0175 /** 0176 * @brief Call grlib_load_64() to load a prepared value. 0177 */ 0178 static void DevGrlibValIo_Action_3( void ) 0179 { 0180 uint64_t reg_64; 0181 uint64_t val_64; 0182 0183 reg_64 = 0x8000000000000001; 0184 val_64 = grlib_load_64( ®_64 ); 0185 0186 /* 0187 * Check that the returned value is equal to the prepared value. 0188 */ 0189 T_step_eq_u64( 3, val_64, 0x8000000000000001 ); 0190 } 0191 0192 /** 0193 * @brief Call grlib_store_8() to store a value to an object. 0194 */ 0195 static void DevGrlibValIo_Action_4( void ) 0196 { 0197 uint8_t reg_8; 0198 0199 grlib_store_8( ®_8, 0x81 ); 0200 0201 /* 0202 * Check that the value of the object is equal to the stored value. 0203 */ 0204 T_step_eq_u8( 4, reg_8, 0x81 ); 0205 } 0206 0207 /** 0208 * @brief Call grlib_store_16() to store a value to an object. 0209 */ 0210 static void DevGrlibValIo_Action_5( void ) 0211 { 0212 uint16_t reg_16; 0213 0214 grlib_store_16( ®_16, 0x8001 ); 0215 0216 /* 0217 * Check that the value of the object is equal to the stored value. 0218 */ 0219 T_step_eq_u16( 5, reg_16, 0x8001 ); 0220 } 0221 0222 /** 0223 * @brief Call grlib_store_32() to store a value to an object. 0224 */ 0225 static void DevGrlibValIo_Action_6( void ) 0226 { 0227 uint32_t reg_32; 0228 0229 grlib_store_32( ®_32, 0x80000001 ); 0230 0231 /* 0232 * Check that the value of the object is equal to the stored value. 0233 */ 0234 T_step_eq_u32( 6, reg_32, 0x80000001 ); 0235 } 0236 0237 /** 0238 * @brief Call grlib_store_64() to store a value to an object. 0239 */ 0240 static void DevGrlibValIo_Action_7( void ) 0241 { 0242 uint64_t reg_64; 0243 0244 grlib_store_64( ®_64, 0x8000000000000001 ); 0245 0246 /* 0247 * Check that the value of the object is equal to the stored value. 0248 */ 0249 T_step_eq_u64( 7, reg_64, 0x8000000000000001 ); 0250 } 0251 0252 /** 0253 * @brief Call apbuart_outbyte_polled() to store a character to the data 0254 * register. The transmitter FIFO shall be initially non-empty. The status 0255 * is checked by apbuart_outbyte_wait(). 0256 */ 0257 static void DevGrlibValIo_Action_8( void ) 0258 { 0259 apbuart regs; 0260 0261 memset( ®s, 0, sizeof( regs ) ); 0262 SetIORelaxHandler( ApbuartIORelax, ®s ); 0263 apbuart_outbyte_polled( ®s, (char) 0xff ); 0264 SetIORelaxHandler( NULL, NULL ); 0265 0266 /* 0267 * Check that the transmitter FIFO empty flag was set by ApbuartIORelax(). 0268 */ 0269 T_step_eq_u32( 8, regs.status, APBUART_STATUS_TE ); 0270 0271 /* 0272 * Check that the data register was written by apbuart_outbyte_polled(). 0273 */ 0274 T_step_eq_u32( 9, regs.data, 0xff ); 0275 } 0276 0277 /** 0278 * @fn void T_case_body_DevGrlibValIo( void ) 0279 */ 0280 T_TEST_CASE( DevGrlibValIo ) 0281 { 0282 T_plan( 10 ); 0283 0284 DevGrlibValIo_Action_0(); 0285 DevGrlibValIo_Action_1(); 0286 DevGrlibValIo_Action_2(); 0287 DevGrlibValIo_Action_3(); 0288 DevGrlibValIo_Action_4(); 0289 DevGrlibValIo_Action_5(); 0290 DevGrlibValIo_Action_6(); 0291 DevGrlibValIo_Action_7(); 0292 DevGrlibValIo_Action_8(); 0293 } 0294 0295 /** @} */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |