首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

RTT Shell控制台

硬件开发 16.41KB 28 需要积分: 1
立即下载

资源介绍:

RTT Shell控制台
/********************************************************************* * SEGGER MICROCONTROLLER GmbH & Co. KG * * Solutions for real time microcontroller applications * ********************************************************************** * * * (c) 2014-2014 SEGGER Microcontroller GmbH & Co. KG * * * * Internet: www.segger.com Support: support@segger.com * * * ********************************************************************** ---------------------------------------------------------------------- File : SEGGER_RTT.c Purpose : Implementation of SEGGER real-time terminal (RTT) which allows real-time terminal communication on targets which support debugger memory accesses while the CPU is running. Type "int" is assumed to be 32-bits in size H->T Host to target communication T->H Target to host communication RTT channel 0 is always present and reserved for Terminal usage. Name is fixed to "Terminal" ---------------------------END-OF-HEADER------------------------------ */ #include "SEGGER_RTT_Conf.h" #include "SEGGER_RTT.h" #include // for memcpy /********************************************************************* * * Defines, configurable * ********************************************************************** */ #ifndef BUFFER_SIZE_UP #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host #endif #ifndef BUFFER_SIZE_DOWN #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) #endif #ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (1) // Number of up-buffers (T->H) available on this target #endif #ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (1) // Number of down-buffers (H->T) available on this target #endif #ifndef SEGGER_RTT_LOCK #define SEGGER_RTT_LOCK() #endif #ifndef SEGGER_RTT_UNLOCK #define SEGGER_RTT_UNLOCK() #endif #ifndef SEGGER_RTT_IN_RAM #define SEGGER_RTT_IN_RAM (0) #endif /********************************************************************* * * Defines, fixed * ********************************************************************** */ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MEMCPY(a, b, c) memcpy((a),(b),(c)) // // For some environments, NULL may not be defined until certain headers are included // #ifndef NULL #define NULL 0 #endif /********************************************************************* * * Types * ********************************************************************** */ // // Description for a circular buffer (also called "ring buffer") // which is used as up- (T->H) or down-buffer (H->T) // typedef struct { const char* sName; // Optional name. Standard names so far are: "Terminal", "VCom" char* pBuffer; // Pointer to start of buffer int SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. volatile int WrOff; // Position of next item to be written by either host (down-buffer) or target (up-buffer). Must be volatile since it may be modified by host (down-buffer) volatile int RdOff; // Position of next item to be read by target (down-buffer) or host (up-buffer). Must be volatile since it may be modified by host (up-buffer) int Flags; // Contains configuration flags } RING_BUFFER; // // RTT control block which describes the number of buffers available // as well as the configuration for each buffer // // typedef struct { char acID[16]; // Initialized to "SEGGER RTT" int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2) int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2) RING_BUFFER aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host RING_BUFFER aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target } SEGGER_RTT_CB; /********************************************************************* * * Static data * ********************************************************************** */ // // Allocate buffers for channel 0 // static char _acUpBuffer [BUFFER_SIZE_UP]; static char _acDownBuffer[BUFFER_SIZE_DOWN]; // // Initialize SEGGER Real-time-Terminal control block (CB) // static SEGGER_RTT_CB _SEGGER_RTT = { #if SEGGER_RTT_IN_RAM "SEGGER RTTI", #else "SEGGER RTT", #endif SEGGER_RTT_MAX_NUM_UP_BUFFERS, SEGGER_RTT_MAX_NUM_DOWN_BUFFERS, {{ "Terminal", &_acUpBuffer[0], sizeof(_acUpBuffer), 0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }}, {{ "Terminal", &_acDownBuffer[0], sizeof(_acDownBuffer), 0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }}, }; /********************************************************************* * * Static code * ********************************************************************** */ /********************************************************************* * * _strlen * * Function description * ANSI compatible function to determine the length of a string * * Return value * Length of string in bytes. * * Parameters * s Pointer to \0 terminated string. * * Notes * (1) s needs to point to an \0 terminated string. Otherwise proper functionality of this function is not guaranteed. */ static int _strlen(const char* s) { int Len; Len = 0; if (s == NULL) { return 0; } do { if (*s == 0) { break; } Len++; s++; } while (1); return Len; } /********************************************************************* * * _Init * * Function description * In case SEGGER_RTT_IN_RAM is defined, * _Init() modifies the ID of the RTT CB to allow identifying the * RTT Control Block Structure in the data segment. */ static void _Init(void) { #if SEGGER_RTT_IN_RAM if (_SEGGER_RTT.acID[10] == 'I') { _SEGGER_RTT.acID[10] = '\0'; } #endif } /********************************************************************* * * Public code * ********************************************************************** */ /********************************************************************* * * SEGGER_RTT_Read * * Function description * Reads characters from SEGGER real-time-terminal control block * which have been previously stored by the host. * * Parameters * BufferIndex Index of Down-buffer to be used. (e.g. 0 for "Terminal") * pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to. * BufferSize Size of the target application buffer * * Return values * Number of bytes that have been read */ int SEGGER_RTT_Read(unsigned BufferIndex, char* pBuffer, unsigned BufferSize) { int NumBytesRem; unsigned NumBytesRead; int RdOff; int WrOff; SEGGER_RTT

资源文件列表:

Shell.zip 大约有9个文件
  1. Shell/
  2. Shell/console.c 13.41KB
  3. Shell/console.h 1.87KB
  4. Shell/SEGGER_RTT.c 17.4KB
  5. Shell/SEGGER_RTT.h 3.49KB
  6. Shell/SEGGER_RTT_Conf.h 3KB
  7. Shell/SEGGER_RTT_printf.c 12.41KB
  8. Shell/shell.c 5.29KB
  9. Shell/shell.h 1.02KB
0评论
提交 加载更多评论
其他资源 Obsidium Unpacker by winndy .zip
Obsidium Unpacker by winndy .zip
基于springboot的人员信息管理(简单版)
基于springboot的人员信息管理(简单版)
qq登录第三方jar包,Sdk4J.jar
qq登录第三方jar包,Sdk4J.jar
6-protues仿真(protues8.7).zip
6-protues仿真(protues8.7).zip
6-protues仿真(protues8.7).zip 6-protues仿真(protues8.7).zip 6-protues仿真(protues8.7).zip
cmake-3.30.3-windows-x86-64
cmake-3.30.3-windows-x86_64.zip
dubbo test 测试工具
dubbo test 测试工具
IEEE的latex模板
IEEE的latex模板
navicat121工具
navicat121工具