1 /**
2  * CANopenNode types.
3  *
4  * Defines common types for CANopenNode.
5  *
6  * @file        CO_types.h
7  * @ingroup     CO_CANopen
8  * @author      Olivier Desenfans
9  * @copyright   2004 - 2020 Janez Paternoster
10  *
11  * This file is part of CANopenNode, an opensource CANopen Stack.
12  * Project home page is <https://github.com/CANopenNode/CANopenNode>.
13  * For more information on CANopen see <http://www.can-cia.org/>.
14  *
15  * Licensed under the Apache License, Version 2.0 (the "License");
16  * you may not use this file except in compliance with the License.
17  * You may obtain a copy of the License at
18  *
19  *     http://www.apache.org/licenses/LICENSE-2.0
20  *
21  * Unless required by applicable law or agreed to in writing, software
22  * distributed under the License is distributed on an "AS IS" BASIS,
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  * See the License for the specific language governing permissions and
25  * limitations under the License.
26  */
27 
28 #ifndef CO_TYPES_H
29 #define CO_TYPES_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
35 /**
36  * Return values of some CANopen functions.
37  *
38  * A function should return 0 on success and a negative value on error.
39  */
40 typedef enum {
41     /** Operation completed successfully */
42     CO_ERROR_NO = 0,
43     /** Error in function arguments */
44     CO_ERROR_ILLEGAL_ARGUMENT = -1,
45     /** Memory allocation failed */
46     CO_ERROR_OUT_OF_MEMORY = -2,
47     /** Function timeout */
48     CO_ERROR_TIMEOUT = -3,
49     /** Illegal baudrate passed to function CO_CANmodule_init() */
50     CO_ERROR_ILLEGAL_BAUDRATE = -4,
51     /** Previous message was not processed yet */
52     CO_ERROR_RX_OVERFLOW = -5,
53     /** previous PDO was not processed yet */
54     CO_ERROR_RX_PDO_OVERFLOW = -6,
55     /** Wrong receive message length */
56     CO_ERROR_RX_MSG_LENGTH = -7,
57     /** Wrong receive PDO length */
58     CO_ERROR_RX_PDO_LENGTH = -8,
59     /** Previous message is still waiting, buffer full */
60     CO_ERROR_TX_OVERFLOW = -9,
61     /** Synchronous TPDO is outside window */
62     CO_ERROR_TX_PDO_WINDOW = -10,
63     /** Transmit buffer was not confugured properly */
64     CO_ERROR_TX_UNCONFIGURED = -11,
65     /** Error in function function parameters */
66     CO_ERROR_PARAMETERS = -12,
67     /** Stored data are corrupt */
68     CO_ERROR_DATA_CORRUPT = -13,
69     /** CRC does not match */
70     CO_ERROR_CRC = -14,
71     /** Sending rejected because driver is busy. Try again */
72     CO_ERROR_TX_BUSY = -15,
73     /** Command can't be processed in current state */
74     CO_ERROR_WRONG_NMT_STATE = -16,
75     /** Syscall failed */
76     CO_ERROR_SYSCALL = -17,
77     /** Driver not ready */
78     CO_ERROR_INVALID_STATE = -18,
79 } CO_ReturnError_t;
80 
81 #ifdef __cplusplus
82 }
83 #endif /* __cplusplus */
84 
85 /** @} */
86 #endif /* CO_TYPES_H */
87