amiro-blt / Target / Source / com.h @ a8ddce31
History | View | Annotate | Download (6.315 KB)
1 | 69661903 | Thomas Schöpping | /************************************************************************************//** |
---|---|---|---|
2 | * \file Source\com.h
|
||
3 | * \brief Bootloader communication interface header file.
|
||
4 | * \ingroup Core
|
||
5 | * \internal
|
||
6 | *----------------------------------------------------------------------------------------
|
||
7 | * C O P Y R I G H T
|
||
8 | *----------------------------------------------------------------------------------------
|
||
9 | * Copyright (c) 2011 by Feaser http://www.feaser.com All rights reserved
|
||
10 | *
|
||
11 | *----------------------------------------------------------------------------------------
|
||
12 | * L I C E N S E
|
||
13 | *----------------------------------------------------------------------------------------
|
||
14 | * This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||
15 | * modify it under the terms of the GNU General Public License as published by the Free
|
||
16 | * Software Foundation, either version 3 of the License, or (at your option) any later
|
||
17 | * version.
|
||
18 | *
|
||
19 | * OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||
20 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
21 | * PURPOSE. See the GNU General Public License for more details.
|
||
22 | *
|
||
23 | * You should have received a copy of the GNU General Public License along with OpenBLT.
|
||
24 | * If not, see <http://www.gnu.org/licenses/>.
|
||
25 | *
|
||
26 | * A special exception to the GPL is included to allow you to distribute a combined work
|
||
27 | * that includes OpenBLT without being obliged to provide the source code for any
|
||
28 | * proprietary components. The exception text is included at the bottom of the license
|
||
29 | * file <license.html>.
|
||
30 | *
|
||
31 | * \endinternal
|
||
32 | ****************************************************************************************/
|
||
33 | #ifndef COM_H
|
||
34 | #define COM_H
|
||
35 | |||
36 | #if (BOOT_COM_ENABLE > 0) |
||
37 | /****************************************************************************************
|
||
38 | * Macro definitions
|
||
39 | ****************************************************************************************/
|
||
40 | /** \brief Defines the maximum number of bytes for transport layer reception
|
||
41 | * depending on the activates interface(s).
|
||
42 | */
|
||
43 | #define BOOT_COM_RX_MAX_DATA (1) |
||
44 | /* update in case CAN interface uses more */
|
||
45 | #if (BOOT_COM_CAN_RX_MAX_DATA > BOOT_COM_RX_MAX_DATA)
|
||
46 | #undef BOOT_COM_RX_MAX_DATA
|
||
47 | #define BOOT_COM_RX_MAX_DATA (BOOT_COM_CAN_RX_MAX_DATA)
|
||
48 | #endif
|
||
49 | /* update in case UART interface uses more */
|
||
50 | #if (BOOT_COM_UART_RX_MAX_DATA > BOOT_COM_RX_MAX_DATA)
|
||
51 | #undef BOOT_COM_RX_MAX_DATA
|
||
52 | #define BOOT_COM_RX_MAX_DATA (BOOT_COM_UART_RX_MAX_DATA)
|
||
53 | #endif
|
||
54 | /* update in case USB interface uses more */
|
||
55 | #if (BOOT_COM_USB_RX_MAX_DATA > BOOT_COM_RX_MAX_DATA)
|
||
56 | #undef BOOT_COM_RX_MAX_DATA
|
||
57 | #define BOOT_COM_RX_MAX_DATA (BOOT_COM_USB_RX_MAX_DATA)
|
||
58 | #endif
|
||
59 | /* update in case NET interface uses more */
|
||
60 | #if (BOOT_COM_NET_RX_MAX_DATA > BOOT_COM_RX_MAX_DATA)
|
||
61 | #undef BOOT_COM_RX_MAX_DATA
|
||
62 | #define BOOT_COM_RX_MAX_DATA (BOOT_COM_NET_RX_MAX_DATA)
|
||
63 | #endif
|
||
64 | |||
65 | /** \brief Defines the maximum number of bytes for transport layer transmission
|
||
66 | * depending on the activates interface(s).
|
||
67 | */
|
||
68 | #define BOOT_COM_TX_MAX_DATA (1) |
||
69 | /* update in case CAN interface uses more */
|
||
70 | #if (BOOT_COM_CAN_TX_MAX_DATA > BOOT_COM_TX_MAX_DATA)
|
||
71 | #undef BOOT_COM_TX_MAX_DATA
|
||
72 | #define BOOT_COM_TX_MAX_DATA (BOOT_COM_CAN_TX_MAX_DATA)
|
||
73 | #endif
|
||
74 | /* update in case UART interface uses more */
|
||
75 | #if (BOOT_COM_UART_TX_MAX_DATA > BOOT_COM_TX_MAX_DATA)
|
||
76 | #undef BOOT_COM_TX_MAX_DATA
|
||
77 | #define BOOT_COM_TX_MAX_DATA (BOOT_COM_UART_TX_MAX_DATA)
|
||
78 | #endif
|
||
79 | /* update in case USB interface uses more */
|
||
80 | #if (BOOT_COM_USB_TX_MAX_DATA > BOOT_COM_TX_MAX_DATA)
|
||
81 | #undef BOOT_COM_TX_MAX_DATA
|
||
82 | #define BOOT_COM_TX_MAX_DATA (BOOT_COM_USB_TX_MAX_DATA)
|
||
83 | #endif
|
||
84 | /* update in case NET interface uses more */
|
||
85 | #if (BOOT_COM_NET_TX_MAX_DATA > BOOT_COM_TX_MAX_DATA)
|
||
86 | #undef BOOT_COM_TX_MAX_DATA
|
||
87 | #define BOOT_COM_TX_MAX_DATA (BOOT_COM_NET_TX_MAX_DATA)
|
||
88 | #endif
|
||
89 | |||
90 | |||
91 | /****************************************************************************************
|
||
92 | * Plausibility
|
||
93 | ****************************************************************************************/
|
||
94 | #if (BOOT_COM_TX_MAX_DATA < 1) |
||
95 | #undef BOOT_COM_TX_MAX_DATA
|
||
96 | #define BOOT_COM_TX_MAX_DATA (8) |
||
97 | #endif
|
||
98 | |||
99 | #if (BOOT_COM_TX_MAX_DATA > 256) |
||
100 | #error "COM.H, BOOT_COM_TX_MAX_DATA cannot be larger than 256." |
||
101 | #endif
|
||
102 | |||
103 | #if (BOOT_COM_RX_MAX_DATA < 1) |
||
104 | #undef BOOT_COM_RX_MAX_DATA
|
||
105 | #define BOOT_COM_RX_MAX_DATA (8) |
||
106 | #endif
|
||
107 | |||
108 | #if (BOOT_COM_RX_MAX_DATA > 65536) |
||
109 | #error "COM.H, BOOT_COM_RX_MAX_DATA cannot be larger than 65536." |
||
110 | #endif
|
||
111 | |||
112 | |||
113 | /****************************************************************************************
|
||
114 | * Type definitions
|
||
115 | ****************************************************************************************/
|
||
116 | /** \brief Enumeration for the different communication interfaces. */
|
||
117 | typedef enum |
||
118 | { |
||
119 | COM_IF_UART, /**< UART interface */
|
||
120 | COM_IF_CAN, /**< CAN interface */
|
||
121 | COM_IF_USB, /**< USB interface */
|
||
122 | COM_IF_BLUETOOTH, /**< BLUETOOTH interface */
|
||
123 | COM_IF_NET, /**< NET interface */
|
||
124 | COM_IF_OTHER /**< Other interface */
|
||
125 | } tComInterfaceId; |
||
126 | |||
127 | |||
128 | /****************************************************************************************
|
||
129 | * Function prototypes
|
||
130 | ****************************************************************************************/
|
||
131 | void ComInit(void); |
||
132 | void ComTask(void); |
||
133 | void ComFree(void); |
||
134 | blt_int16u ComGetActiveInterfaceMaxRxLen(void);
|
||
135 | blt_int16u ComGetActiveInterfaceMaxTxLen(void);
|
||
136 | void ComTransmitPacket(blt_int8u *data, blt_int16u len);
|
||
137 | blt_bool ComIsConnected(void);
|
||
138 | #if (BOOTLOADER_OF_MAIN_DEVICE > 0) |
||
139 | blt_bool ComWasConnectedToMain(void);
|
||
140 | 470d0567 | Thomas Schöpping | void ComTransmitPacketDirect(blt_int8u *data, blt_int8u len);
|
141 | 69661903 | Thomas Schöpping | #endif /* BOOTLOADER_OF_MAIN_DEVICE > 0 */ |
142 | |||
143 | #endif /* BOOT_COM_ENABLE > 0 */ |
||
144 | |||
145 | #endif /* COM_H */ |
||
146 | /*********************************** end of com.h **************************************/
|