Driver of ST X-NUCLEO-OUT01A1 Industrial Digital output expansion board based on ISO8200BQ component.
Dependents: HelloWorld_OUT01A1
ISO8200BQ.cpp
00001 /** 00002 ****************************************************************************** 00003 * @file ISO8200BQ.cpp 00004 * @author ST CLab 00005 * @version V1.0.0 00006 * @date 1 February 2018 00007 * @brief Implementation of a ISO8200BQ class 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Includes ------------------------------------------------------------------*/ 00039 00040 #include "ISO8200BQ.h" 00041 00042 00043 /* Class Implementation ------------------------------------------------------*/ 00044 00045 /** Constructor 00046 * @param OUT_EN Output enable pin. 00047 * @param N_SYNC Input-to-output synchronization signal. Active low. 00048 * @param N_LOAD Load input data signal. Active low. 00049 */ 00050 00051 ISO8200BQ::ISO8200BQ(PinName OUT_EN, PinName N_SYNC, 00052 PinName N_LOAD) : _out_en(OUT_EN), _n_sync(N_SYNC), _n_load(N_LOAD) 00053 { 00054 /* start with the component disabled*/ 00055 _out_en = 0; 00056 }; 00057 00058 /** 00059 * @brief Getting the ID of the component. 00060 * @param id Pointer to an allocated variable to store the ID into. 00061 * @retval "0" in case of success, an error code otherwise. 00062 */ 00063 int ISO8200BQ::read_id(uint8_t *id = NULL) 00064 { 00065 return 0; 00066 } 00067 00068 /** 00069 * 00070 * @brief One time device initialization 00071 * 00072 * @param void 00073 * @retval "0" in case of success, an error code otherwise. 00074 */ 00075 int ISO8200BQ::init(void *init) 00076 { 00077 /* initalize with SYNC and LOAD signals disabled*/ 00078 _n_sync = _n_load = 1; 00079 return 0; 00080 } 00081 00082 /** 00083 * 00084 * @brief Enable/Disable all outputs 00085 * 00086 * @param enable Enable the outputs when true, disable otherwise 00087 */ 00088 void ISO8200BQ::enable_outputs(bool enable) { 00089 _out_en = enable ? 1 : 0; 00090 } 00091 00092 /** 00093 * 00094 * @brief Get outputs enabling status 00095 * 00096 * @retval Returns true if outputs are enabled, false otherwise 00097 */ 00098 bool ISO8200BQ::are_outputs_enabled (void) { 00099 return (_out_en == 0) ? false : true; 00100 } 00101 00102 /** 00103 * 00104 * @brief Load input pin status into input buffer (synch mode) 00105 * 00106 */ 00107 void ISO8200BQ::sync_mode_load_inputs (void) { 00108 _n_load = 1; //disabled 00109 _n_sync = 1; //disabled 00110 wait_us(20); //tdis(sync) 00111 _n_load = 0; //enabled 00112 } 00113 00114 /** 00115 * 00116 * @brief Update outputs accordingly to input buffer (synch mode) 00117 * 00118 */ 00119 void ISO8200BQ::sync_mode_update_outputs(void) { 00120 wait_us(100); // tw(load) 00121 _n_load = 1; //disabled 00122 wait_us(1); //tsu(load) 00123 _n_sync = 0; //enabled 00124 wait_us(100); // tw(sync) 00125 _n_sync = 1; // trigger output updates (on rising edge) 00126 } 00127 00128 /** 00129 * 00130 * @brief Update outputs accordingly to input pins (direct mode) 00131 * 00132 */ 00133 void ISO8200BQ::direct_mode (void) { 00134 _n_load = 0; //enabled 00135 _n_sync = 0; //enabled 00136 wait_us(1); //tinld 00137 } 00138 00139
Generated on Tue Jul 12 2022 20:17:02 by 1.7.2