1 |
|
---|
2 | /** \addtogroup platform */
|
---|
3 | /** @{*/
|
---|
4 | /**
|
---|
5 | * \defgroup platform_interface Network interface and other utility functions
|
---|
6 | * @{
|
---|
7 | */
|
---|
8 |
|
---|
9 | /* mbed Microcontroller Library
|
---|
10 | * Copyright (c) 2006-2013 ARM Limited
|
---|
11 | *
|
---|
12 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
13 | * you may not use this file except in compliance with the License.
|
---|
14 | * You may obtain a copy of the License at
|
---|
15 | *
|
---|
16 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
17 | *
|
---|
18 | * Unless required by applicable law or agreed to in writing, software
|
---|
19 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
21 | * See the License for the specific language governing permissions and
|
---|
22 | * limitations under the License.
|
---|
23 | */
|
---|
24 | #ifndef MBED_INTERFACE_H
|
---|
25 | #define MBED_INTERFACE_H
|
---|
26 |
|
---|
27 | #include <stdarg.h>
|
---|
28 |
|
---|
29 | #include "device.h"
|
---|
30 |
|
---|
31 | /* Mbed interface mac address
|
---|
32 | * if MBED_MAC_ADD_x are zero, interface uid sets mac address,
|
---|
33 | * otherwise MAC_ADD_x are used.
|
---|
34 | */
|
---|
35 | #define MBED_MAC_ADDR_INTERFACE 0x00
|
---|
36 | #define MBED_MAC_ADDR_0 MBED_MAC_ADDR_INTERFACE
|
---|
37 | #define MBED_MAC_ADDR_1 MBED_MAC_ADDR_INTERFACE
|
---|
38 | #define MBED_MAC_ADDR_2 MBED_MAC_ADDR_INTERFACE
|
---|
39 | #define MBED_MAC_ADDR_3 MBED_MAC_ADDR_INTERFACE
|
---|
40 | #define MBED_MAC_ADDR_4 MBED_MAC_ADDR_INTERFACE
|
---|
41 | #define MBED_MAC_ADDR_5 MBED_MAC_ADDR_INTERFACE
|
---|
42 | #define MBED_MAC_ADDRESS_SUM (MBED_MAC_ADDR_0 | MBED_MAC_ADDR_1 | MBED_MAC_ADDR_2 | MBED_MAC_ADDR_3 | MBED_MAC_ADDR_4 | MBED_MAC_ADDR_5)
|
---|
43 |
|
---|
44 | #ifdef __cplusplus
|
---|
45 | extern "C" {
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #if DEVICE_SEMIHOST
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * \defgroup platform_interface interface functions
|
---|
52 | * @{
|
---|
53 | */
|
---|
54 |
|
---|
55 | /** Functions to control the mbed interface
|
---|
56 | *
|
---|
57 | * mbed Microcontrollers have a built-in interface to provide functionality such as
|
---|
58 | * drag-n-drop download, reset, serial-over-usb, and access to the mbed local file
|
---|
59 | * system. These functions provide means to control the interface suing semihost
|
---|
60 | * calls it supports.
|
---|
61 | */
|
---|
62 |
|
---|
63 | /** Determine whether the mbed interface is connected, based on whether debug is enabled
|
---|
64 | *
|
---|
65 | * @returns
|
---|
66 | * 1 if interface is connected,
|
---|
67 | * 0 otherwise
|
---|
68 | */
|
---|
69 | int mbed_interface_connected(void);
|
---|
70 |
|
---|
71 | /** Instruct the mbed interface to reset, as if the reset button had been pressed
|
---|
72 | *
|
---|
73 | * @returns
|
---|
74 | * 1 if successful,
|
---|
75 | * 0 otherwise (e.g. interface not present)
|
---|
76 | */
|
---|
77 | int mbed_interface_reset(void);
|
---|
78 |
|
---|
79 | /** This will disconnect the debug aspect of the interface, so semihosting will be disabled.
|
---|
80 | * The interface will still support the USB serial aspect
|
---|
81 | *
|
---|
82 | * @returns
|
---|
83 | * 0 if successful,
|
---|
84 | * -1 otherwise (e.g. interface not present)
|
---|
85 | */
|
---|
86 | int mbed_interface_disconnect(void);
|
---|
87 |
|
---|
88 | /** This will disconnect the debug aspect of the interface, and if the USB cable is not
|
---|
89 | * connected, also power down the interface. If the USB cable is connected, the interface
|
---|
90 | * will remain powered up and visible to the host
|
---|
91 | *
|
---|
92 | * @returns
|
---|
93 | * 0 if successful,
|
---|
94 | * -1 otherwise (e.g. interface not present)
|
---|
95 | */
|
---|
96 | int mbed_interface_powerdown(void);
|
---|
97 |
|
---|
98 | /** This returns a string containing the 32-character UID of the mbed interface
|
---|
99 | * This is a weak function that can be overwritten if required
|
---|
100 | *
|
---|
101 | * @param uid A 33-byte array to write the null terminated 32-byte string
|
---|
102 | *
|
---|
103 | * @returns
|
---|
104 | * 0 if successful,
|
---|
105 | * -1 otherwise (e.g. interface not present)
|
---|
106 | */
|
---|
107 | int mbed_interface_uid(char *uid);
|
---|
108 |
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | /** This returns a unique 6-byte MAC address, based on the interface UID
|
---|
112 | * If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)
|
---|
113 | *
|
---|
114 | * This is a weak function that can be overwritten if you want to provide your own mechanism to
|
---|
115 | * provide a MAC address.
|
---|
116 | *
|
---|
117 | * @param mac A 6-byte array to write the MAC address
|
---|
118 | */
|
---|
119 | void mbed_mac_address(char *mac);
|
---|
120 |
|
---|
121 | /** Cause the mbed to flash the BLOD (Blue LEDs Of Death) sequence
|
---|
122 | */
|
---|
123 | void mbed_die(void);
|
---|
124 |
|
---|
125 | /** Print out an error message. This is typically called when
|
---|
126 | * handling a crash.
|
---|
127 | *
|
---|
128 | * @note Synchronization level: Interrupt safe
|
---|
129 | *
|
---|
130 | * @param format C string that contains data stream to be printed.
|
---|
131 | * Code snippets below show valid format.
|
---|
132 | *
|
---|
133 | * @code
|
---|
134 | * mbed_error_printf("Failed: %s, file: %s, line %d \n", expr, file, line);
|
---|
135 | * @endcode
|
---|
136 | *
|
---|
137 | */
|
---|
138 | void mbed_error_printf(const char* format, ...);
|
---|
139 |
|
---|
140 | /** Print out an error message. Similar to mbed_error_printf
|
---|
141 | * but uses a va_list.
|
---|
142 | *
|
---|
143 | * @note Synchronization level: Interrupt safe
|
---|
144 | *
|
---|
145 | * @param format C string that contains data stream to be printed.
|
---|
146 | * @param arg Variable arguments list
|
---|
147 | *
|
---|
148 | */
|
---|
149 | void mbed_error_vfprintf(const char * format, va_list arg);
|
---|
150 | /** @}*/
|
---|
151 |
|
---|
152 | #ifdef __cplusplus
|
---|
153 | }
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | /** @}*/
|
---|