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.
ds401.c
00001 /* 00002 This file is part of CanFestival, a library implementing CanOpen Stack. 00003 00004 Copyright (C): Andreas GLAUSER 00005 00006 See COPYING file for copyrights details. 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 // DS 401 Digital IO handling according DS 401 V2.1 "Device Profile for Generic I/O Modules" 00024 00025 // Includes for the Canfestival 00026 #include "ds401.h" 00027 00028 unsigned char digital_input_handler(CO_Data* d, unsigned char *newInput, unsigned char size) 00029 { 00030 unsigned char loops, i, input, transmission = 0; 00031 00032 loops = (sizeof(Read_Inputs_8_Bit) <= size) ? sizeof(Read_Inputs_8_Bit) : size; 00033 00034 for (i=0; i < loops; i++) 00035 { 00036 input = *newInput ^ Polarity_Input_8_Bit[i]; 00037 if (Read_Inputs_8_Bit[i] != input) 00038 { 00039 if (Global_Interrupt_Enable_Digital) 00040 { 00041 if ((Interrupt_Mask_Any_Change_8_Bit[i] & (Read_Inputs_8_Bit[i] ^ input)) 00042 || (Interrupt_Mask_Low_to_High_8_Bit[i] & ~Read_Inputs_8_Bit[i] & input) 00043 || (Interrupt_Mask_High_to_Low_8_Bit[i] & Read_Inputs_8_Bit[i] & ~input)) 00044 transmission = 1; 00045 } 00046 // update object dict 00047 Read_Inputs_8_Bit[i] = input; 00048 } 00049 newInput++; 00050 } 00051 if (transmission) 00052 { 00053 /* force emission of PDO by artificially changing last emitted*/ 00054 d->PDO_status[0].last_message.cob_id = 0; 00055 sendPDOevent(d); 00056 } 00057 00058 return 1; 00059 } 00060 00061 unsigned char digital_output_handler(CO_Data* d, unsigned char *newOutput, unsigned char size) 00062 { 00063 unsigned char loops, i, error, type; 00064 /* fixed warning due to data size mismatch - not much of an issue since the 00065 data is last on the stack unless another function was called... */ 00066 //unsigned char varsize = 1; 00067 uint32_t varsize = 1; 00068 00069 loops = (sizeof(Write_Outputs_8_Bit) <= size) ? sizeof(Write_Outputs_8_Bit) : size; 00070 00071 for (i=0; i < loops; i++) 00072 { 00073 /* warning because varsize is 8bits and the parameter is a pointer (32bit) 00074 used for address to return a value */ 00075 getODentry(d, 0x1001, 0x0, &error, &varsize, &type, RO); 00076 if ((getState(d) == Stopped) || (error != 0)) // node stopped or error 00077 { 00078 Write_Outputs_8_Bit[i] &= (~Error_Mode_Outputs_8_Bit[i] | Error_Value_Outputs_8_Bit[i]); 00079 Write_Outputs_8_Bit[i] |= (Error_Mode_Outputs_8_Bit[i] & Error_Value_Outputs_8_Bit[i]); 00080 } 00081 *newOutput = Write_Outputs_8_Bit[i] ^ Change_Polarity_Outputs_8_Bit[i]; 00082 newOutput++; 00083 } 00084 return 1; 00085 } 00086 00087 unsigned char analog_input_handler(CO_Data* d, unsigned int *newInput, unsigned char size) 00088 { 00089 return 0; 00090 } 00091 00092 unsigned char analog_output_handler(CO_Data* d, unsigned int *newOutput, unsigned char size) 00093 { 00094 return 0; 00095 } 00096 00097 00098
Generated on Tue Jul 12 2022 17:24:12 by
1.7.2