author | Laurent Bessard |
Wed, 06 Mar 2013 23:22:36 +0100 | |
changeset 775 | c8df14b3a388 |
parent 417 | ae068232859c |
permissions | -rw-r--r-- |
413 | 1 |
/* |
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
|
3 |
||
4 |
Copyright (C): Andreas GLAUSER |
|
5 |
||
6 |
See COPYING file for copyrights details. |
|
7 |
||
8 |
This library is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU Lesser General Public |
|
10 |
License as published by the Free Software Foundation; either |
|
11 |
version 2.1 of the License, or (at your option) any later version. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
*/ |
|
22 |
||
23 |
// DS 401 Digital IO handling according DS 401 V2.1 "Device Profile for Generic I/O Modules" |
|
24 |
||
25 |
// Includes for the Canfestival |
|
26 |
#include "ds401.h" |
|
27 |
||
28 |
unsigned char digital_input_handler(CO_Data* d, unsigned char *newInput, unsigned char size) |
|
29 |
{ |
|
30 |
unsigned char loops, i, input, transmission = 0; |
|
31 |
||
32 |
loops = (sizeof(Read_Inputs_8_Bit) <= size) ? sizeof(Read_Inputs_8_Bit) : size; |
|
33 |
||
34 |
for (i=0; i < loops; i++) |
|
35 |
{ |
|
36 |
input = *newInput ^ Polarity_Input_8_Bit[i]; |
|
37 |
if (Read_Inputs_8_Bit[i] != input) |
|
38 |
{ |
|
39 |
if (Global_Interrupt_Enable_Digital) |
|
40 |
{ |
|
41 |
if ((Interrupt_Mask_Any_Change_8_Bit[i] & (Read_Inputs_8_Bit[i] ^ input)) |
|
42 |
|| (Interrupt_Mask_Low_to_High_8_Bit[i] & ~Read_Inputs_8_Bit[i] & input) |
|
43 |
|| (Interrupt_Mask_High_to_Low_8_Bit[i] & Read_Inputs_8_Bit[i] & ~input)) |
|
44 |
transmission = 1; |
|
45 |
} |
|
46 |
// update object dict |
|
47 |
Read_Inputs_8_Bit[i] = input; |
|
48 |
} |
|
49 |
newInput++; |
|
50 |
} |
|
51 |
if (transmission) |
|
417
ae068232859c
Forces an emission of PDO by resetting the COB of the last message
peter
parents:
413
diff
changeset
|
52 |
{ |
ae068232859c
Forces an emission of PDO by resetting the COB of the last message
peter
parents:
413
diff
changeset
|
53 |
/* force emission of PDO by artificially changing last emitted*/ |
ae068232859c
Forces an emission of PDO by resetting the COB of the last message
peter
parents:
413
diff
changeset
|
54 |
d->PDO_status[0].last_message.cob_id = 0; |
413 | 55 |
sendPDOevent(d); |
417
ae068232859c
Forces an emission of PDO by resetting the COB of the last message
peter
parents:
413
diff
changeset
|
56 |
} |
413 | 57 |
|
58 |
return 1; |
|
59 |
} |
|
60 |
||
61 |
unsigned char digital_output_handler(CO_Data* d, unsigned char *newOutput, unsigned char size) |
|
62 |
{ |
|
63 |
unsigned char loops, i, error, type; |
|
64 |
unsigned char varsize = 1; |
|
65 |
||
66 |
loops = (sizeof(Write_Outputs_8_Bit) <= size) ? sizeof(Write_Outputs_8_Bit) : size; |
|
67 |
||
68 |
for (i=0; i < loops; i++) |
|
69 |
{ |
|
70 |
getODentry(d, 0x1001, 0x0, &error, &varsize, &type, RO); |
|
71 |
if ((getState(d) == Stopped) || (error != 0)) // node stopped or error |
|
72 |
{ |
|
73 |
Write_Outputs_8_Bit[i] &= (~Error_Mode_Outputs_8_Bit[i] | Error_Value_Outputs_8_Bit[i]); |
|
74 |
Write_Outputs_8_Bit[i] |= (Error_Mode_Outputs_8_Bit[i] & Error_Value_Outputs_8_Bit[i]); |
|
75 |
} |
|
76 |
*newOutput = Write_Outputs_8_Bit[i] ^ Change_Polarity_Outputs_8_Bit[i]; |
|
77 |
newOutput++; |
|
78 |
} |
|
79 |
return 1; |
|
80 |
} |
|
81 |
||
82 |
unsigned char analog_input_handler(CO_Data* d, unsigned int *newInput, unsigned char size) |
|
83 |
{ |
|
84 |
return 0; |
|
85 |
} |
|
86 |
||
87 |
unsigned char analog_output_handler(CO_Data* d, unsigned int *newOutput, unsigned char size) |
|
88 |
{ |
|
89 |
return 0; |
|
90 |
} |
|
91 |
||
92 |
||
93 |