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.
Dependents: USBMSD_LPC_HelloWorld lpcterm2 Simple-CMSIS-DAP 11u35_usbLocalFilesystem
TransferCore.h
00001 // TransferCore.h 2013/9/14 00002 #pragma once 00003 #include "SWD.h" 00004 00005 // DAP Transfer Request 00006 #define DAP_TRANSFER_MATCH_VALUE (1<<4) 00007 #define DAP_TRANSFER_MATCH_MASK (1<<5) 00008 00009 // DAP Transfer Response 00010 #define DAP_TRANSFER_MISMATCH (1<<4) 00011 00012 template<typename T> 00013 T LD(uint8_t* buf) { 00014 T data = 0; 00015 for(int i = sizeof(T)-1; i >= 0; i--) { 00016 data <<= 8; 00017 data |= buf[i]; 00018 } 00019 return data; 00020 } 00021 00022 template<typename T> 00023 void ST(uint8_t* buf, T data) { 00024 for(int i = 0; i < sizeof(T); i++) { 00025 buf[i] = data>>(8*i); 00026 } 00027 } 00028 00029 class transData { 00030 public: 00031 void init(uint8_t* base, int pos); 00032 void append(uint32_t data); 00033 uint8_t* data(); 00034 int length(); 00035 00036 template<typename T> 00037 T get() { 00038 T data = LD<T>(_base+_pos); 00039 _pos += sizeof(T); 00040 return data; 00041 } 00042 protected: 00043 uint8_t* _base; 00044 int _pos; 00045 }; 00046 00047 class TransferCore { 00048 public: 00049 int Transfer(SWD* swd, uint8_t* request, uint8_t* response); 00050 int TransferBlock(SWD* swd, uint8_t* request, uint8_t* response); 00051 uint16_t match_retry; // Number of retries if read value does not match 00052 uint32_t match_mask; // Match Mask 00053 private: 00054 uint8_t read(uint8_t cmd); 00055 uint8_t write(uint8_t cmd); 00056 uint8_t read_block(uint8_t cmd, int count); 00057 uint8_t write_block(uint8_t cmd, int count); 00058 00059 bool post_read; 00060 bool check_write; 00061 transData reqData; 00062 transData resData; 00063 int response_count; 00064 protected: 00065 SWD* _swd; 00066 };
Generated on Mon Jul 18 2022 08:44:24 by
1.7.2