Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

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