Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SerialWireOutput.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #if defined(DEVICE_ITM) 00018 00019 #include "hal/itm_api.h" 00020 #include "platform/FileHandle.h" 00021 00022 namespace mbed { 00023 00024 class SerialWireOutput : public FileHandle { 00025 00026 public: 00027 00028 SerialWireOutput(void) 00029 { 00030 /* Initialize ITM using internal init function. */ 00031 mbed_itm_init(); 00032 } 00033 00034 virtual ssize_t write(const void *buffer, size_t size) 00035 { 00036 mbed_itm_send_block(ITM_PORT_SWO, buffer, size); 00037 00038 return size; 00039 } 00040 00041 virtual ssize_t read(void *buffer, size_t size) 00042 { 00043 /* Reading is not supported by this file handle */ 00044 return -EBADF; 00045 } 00046 00047 virtual off_t seek(off_t offset, int whence = SEEK_SET) 00048 { 00049 /* Seeking is not support by this file handler */ 00050 return -ESPIPE; 00051 } 00052 00053 virtual off_t size() 00054 { 00055 /* Size is not defined for this file handle */ 00056 return -EINVAL; 00057 } 00058 00059 virtual int isatty() 00060 { 00061 /* File handle is used for terminal output */ 00062 return true; 00063 } 00064 00065 virtual int close() 00066 { 00067 return 0; 00068 } 00069 }; 00070 00071 } // namespace mbed 00072 00073 #endif
Generated on Tue Aug 9 2022 00:37:19 by
1.7.2