mbed_interface.h 4.5 KB

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