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 class SerialWireOutput : public FileHandle { 00023 public: 00024 SerialWireOutput(void) 00025 { 00026 /* Initialize ITM using internal init function. */ 00027 mbed_itm_init(); 00028 } 00029 00030 virtual ssize_t write(const void *buffer, size_t size) 00031 { 00032 const unsigned char *buf = static_cast<const unsigned char *>(buffer); 00033 00034 /* Send buffer one character at a time over the ITM SWO port */ 00035 for (size_t i = 0; i < size; i++) { 00036 mbed_itm_send(ITM_PORT_SWO, buf[i]); 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 #endif
Generated on Tue Jul 12 2022 13:31:26 by
