mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
SerialWireOutput.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef MBED_SERIALWIREOUTPUT_H 00019 #define MBED_SERIALWIREOUTPUT_H 00020 00021 #if defined(DEVICE_ITM) 00022 00023 #include "hal/itm_api.h" 00024 #include "platform/FileHandle.h" 00025 00026 namespace mbed { 00027 00028 class SerialWireOutput : public FileHandle { 00029 00030 public: 00031 00032 SerialWireOutput(void) 00033 { 00034 /* Initialize ITM using internal init function. */ 00035 mbed_itm_init(); 00036 } 00037 00038 virtual ssize_t write(const void *buffer, size_t size) 00039 { 00040 mbed_itm_send_block(ITM_PORT_SWO, buffer, size); 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 // DEVICE_ITM 00078 00079 #endif // MBED_SERIALWIREOUTPUT_H
Generated on Tue Jul 12 2022 20:41:15 by 1.7.2