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 #ifndef MBED_SERIALWIREOUTPUT_H 00018 #define MBED_SERIALWIREOUTPUT_H 00019 00020 #if defined(DEVICE_ITM) 00021 00022 #include "hal/itm_api.h" 00023 #include "platform/FileHandle.h" 00024 00025 namespace mbed { 00026 00027 class SerialWireOutput : public FileHandle { 00028 00029 public: 00030 00031 SerialWireOutput(void) 00032 { 00033 /* Initialize ITM using internal init function. */ 00034 mbed_itm_init(); 00035 } 00036 00037 virtual ssize_t write(const void *buffer, size_t size) 00038 { 00039 mbed_itm_send_block(ITM_PORT_SWO, buffer, size); 00040 00041 return size; 00042 } 00043 00044 virtual ssize_t read(void *buffer, size_t size) 00045 { 00046 /* Reading is not supported by this file handle */ 00047 return -EBADF; 00048 } 00049 00050 virtual off_t seek(off_t offset, int whence = SEEK_SET) 00051 { 00052 /* Seeking is not support by this file handler */ 00053 return -ESPIPE; 00054 } 00055 00056 virtual off_t size() 00057 { 00058 /* Size is not defined for this file handle */ 00059 return -EINVAL; 00060 } 00061 00062 virtual int isatty() 00063 { 00064 /* File handle is used for terminal output */ 00065 return true; 00066 } 00067 00068 virtual int close() 00069 { 00070 return 0; 00071 } 00072 }; 00073 00074 } // namespace mbed 00075 00076 #endif // DEVICE_ITM 00077 00078 #endif // MBED_SERIALWIREOUTPUT_H
Generated on Wed Jul 13 2022 01:21:56 by
1.7.2