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 const unsigned char *buf = static_cast<const unsigned char *>(buffer); 00037 00038 /* Send buffer one character at a time over the ITM SWO port */ 00039 for (size_t i = 0; i < size; i++) { 00040 mbed_itm_send(ITM_PORT_SWO, buf[i]); 00041 } 00042 return size; 00043 } 00044 00045 virtual ssize_t read(void *buffer, size_t size) 00046 { 00047 /* Reading is not supported by this file handle */ 00048 return -EBADF; 00049 } 00050 00051 virtual off_t seek(off_t offset, int whence = SEEK_SET) 00052 { 00053 /* Seeking is not support by this file handler */ 00054 return -ESPIPE; 00055 } 00056 00057 virtual off_t size() 00058 { 00059 /* Size is not defined for this file handle */ 00060 return -EINVAL; 00061 } 00062 00063 virtual int isatty() 00064 { 00065 /* File handle is used for terminal output */ 00066 return true; 00067 } 00068 00069 virtual int close() 00070 { 00071 return 0; 00072 } 00073 }; 00074 00075 } // namespace mbed 00076 00077 #endif
Generated on Tue Jul 12 2022 12:22:20 by
