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