BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:55:34 2018 +0000
Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
bluetooth

Who changed what in which revision?

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