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