swdp.h (1555B)
1 /* swdp.h 2 * 3 * Copyright 2011 Brian Swetland <swetland@frotz.net> 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef _SWDP_H_ 19 #define _SWDP_H_ 20 21 void swdp_reset(void); 22 int swdp_write(unsigned reg, unsigned val); 23 int swdp_read(unsigned reg, unsigned *val); 24 25 unsigned swdp_ap_write(unsigned reg, unsigned val); 26 unsigned swdp_ap_read(unsigned reg); 27 28 unsigned swdp_ahb_read(unsigned addr); 29 void swdp_ahb_write(unsigned addr, unsigned value); 30 31 /* swdp_read/write() register codes */ 32 #define RD_IDCODE 0xA5 // 10100101 33 #define RD_DPCTRL 0xB1 // 10110001 34 #define RD_RESEND 0xA9 // 10101001 35 #define RD_BUFFER 0xBD // 10111101 36 37 #define WR_ABORT 0x81 // 10000001 38 #define WR_DPCTRL 0x95 // 10010101 39 #define WR_SELECT 0x8D // 10001101 40 #define WR_BUFFER 0x99 // 10011001 41 42 #define RD_AP0 0xE1 // 11100001 43 #define RD_AP1 0xF5 // 11110101 44 #define RD_AP2 0xED // 11101101 45 #define RD_AP3 0xF9 // 11111001 46 47 #define WR_AP0 0xC5 // 11000101 48 #define WR_AP1 0xD1 // 11010001 49 #define WR_AP2 0xC9 // 11001001 50 #define WR_AP3 0xDD // 11011101 51 52 #endif 53