|
| 1 | + |
| 2 | +/********************************************************************* |
| 3 | +* |
| 4 | +* OnProjectLoad |
| 5 | +* |
| 6 | +* Function description |
| 7 | +* Project load routine. Required. |
| 8 | +* |
| 9 | +********************************************************************** |
| 10 | +*/ |
| 11 | +void OnProjectLoad (void) { |
| 12 | + Edit.SysVar (VAR_POWER_SAMPLING_SPEED, FREQ_100_KHZ); |
| 13 | + Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd"); |
| 14 | + Project.AddSvdFile ("../../../../../../../cmsis-svd/data/NXP/LPC408x_7x_v0.7.svd"); |
| 15 | + |
| 16 | + Project.SetDevice ("LPC4088"); |
| 17 | + Project.SetHostIF ("USB", ""); |
| 18 | + Project.SetTargetIF ("SWD"); |
| 19 | + Project.SetTIFSpeed ("50 MHz"); |
| 20 | + Project.SetTraceSource ("Trace Pins"); |
| 21 | + Project.SetTracePortWidth (4); |
| 22 | + |
| 23 | + // User settings |
| 24 | + File.Open ("../../../../../../examples/device/cdc_msc/cmake-build-ea4088-quickstart/cdc_msc.elf"); |
| 25 | +} |
| 26 | + |
| 27 | +/********************************************************************* |
| 28 | +* |
| 29 | +* TargetReset |
| 30 | +* |
| 31 | +* Function description |
| 32 | +* Replaces the default target device reset routine. Optional. |
| 33 | +* |
| 34 | +* Notes |
| 35 | +* This example demonstrates the usage when |
| 36 | +* debugging a RAM program on a Cortex-M target device |
| 37 | +* |
| 38 | +********************************************************************** |
| 39 | +*/ |
| 40 | +//void TargetReset (void) { |
| 41 | +// |
| 42 | +// unsigned int SP; |
| 43 | +// unsigned int PC; |
| 44 | +// unsigned int VectorTableAddr; |
| 45 | +// |
| 46 | +// Exec.Reset(); |
| 47 | +// |
| 48 | +// VectorTableAddr = Elf.GetBaseAddr(); |
| 49 | +// |
| 50 | +// if (VectorTableAddr != 0xFFFFFFFF) { |
| 51 | +// |
| 52 | +// Util.Log("Resetting Program."); |
| 53 | +// |
| 54 | +// SP = Target.ReadU32(VectorTableAddr); |
| 55 | +// Target.SetReg("SP", SP); |
| 56 | +// |
| 57 | +// PC = Target.ReadU32(VectorTableAddr + 4); |
| 58 | +// Target.SetReg("PC", PC); |
| 59 | +// } |
| 60 | +//} |
| 61 | + |
| 62 | +/********************************************************************* |
| 63 | +* |
| 64 | +* BeforeTargetReset |
| 65 | +* |
| 66 | +* Function description |
| 67 | +* Event handler routine. Optional. |
| 68 | +* |
| 69 | +********************************************************************** |
| 70 | +*/ |
| 71 | +//void BeforeTargetReset (void) { |
| 72 | +//} |
| 73 | + |
| 74 | +/********************************************************************* |
| 75 | +* |
| 76 | +* AfterTargetReset |
| 77 | +* |
| 78 | +* Function description |
| 79 | +* Event handler routine. |
| 80 | +* - Sets the PC register to program reset value. |
| 81 | +* - Sets the SP register to program reset value on Cortex-M. |
| 82 | +* |
| 83 | +********************************************************************** |
| 84 | +*/ |
| 85 | +void AfterTargetReset (void) { |
| 86 | + unsigned int SP; |
| 87 | + unsigned int PC; |
| 88 | + unsigned int VectorTableAddr; |
| 89 | + |
| 90 | + VectorTableAddr = Elf.GetBaseAddr(); |
| 91 | + |
| 92 | + if (VectorTableAddr == 0xFFFFFFFF) { |
| 93 | + Util.Log("Project file error: failed to get program base"); |
| 94 | + } else { |
| 95 | + SP = Target.ReadU32(VectorTableAddr); |
| 96 | + Target.SetReg("SP", SP); |
| 97 | + |
| 98 | + PC = Target.ReadU32(VectorTableAddr + 4); |
| 99 | + Target.SetReg("PC", PC); |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +/********************************************************************* |
| 104 | +* |
| 105 | +* DebugStart |
| 106 | +* |
| 107 | +* Function description |
| 108 | +* Replaces the default debug session startup routine. Optional. |
| 109 | +* |
| 110 | +********************************************************************** |
| 111 | +*/ |
| 112 | +//void DebugStart (void) { |
| 113 | +//} |
| 114 | + |
| 115 | +/********************************************************************* |
| 116 | +* |
| 117 | +* TargetConnect |
| 118 | +* |
| 119 | +* Function description |
| 120 | +* Replaces the default target IF connection routine. Optional. |
| 121 | +* |
| 122 | +********************************************************************** |
| 123 | +*/ |
| 124 | +//void TargetConnect (void) { |
| 125 | +//} |
| 126 | + |
| 127 | +/********************************************************************* |
| 128 | +* |
| 129 | +* BeforeTargetConnect |
| 130 | +* |
| 131 | +* Function description |
| 132 | +* Event handler routine. Optional. |
| 133 | +* |
| 134 | +********************************************************************** |
| 135 | +*/ |
| 136 | +void BeforeTargetConnect (void) { |
| 137 | +} |
| 138 | + |
| 139 | +/********************************************************************* |
| 140 | +* |
| 141 | +* AfterTargetConnect |
| 142 | +* |
| 143 | +* Function description |
| 144 | +* Event handler routine. Optional. |
| 145 | +* |
| 146 | +********************************************************************** |
| 147 | +*/ |
| 148 | +//void AfterTargetConnect (void) { |
| 149 | +//} |
| 150 | + |
| 151 | +/********************************************************************* |
| 152 | +* |
| 153 | +* TargetDownload |
| 154 | +* |
| 155 | +* Function description |
| 156 | +* Replaces the default program download routine. Optional. |
| 157 | +* |
| 158 | +********************************************************************** |
| 159 | +*/ |
| 160 | +//void TargetDownload (void) { |
| 161 | +//} |
| 162 | + |
| 163 | +/********************************************************************* |
| 164 | +* |
| 165 | +* BeforeTargetDownload |
| 166 | +* |
| 167 | +* Function description |
| 168 | +* Event handler routine. Optional. |
| 169 | +* |
| 170 | +********************************************************************** |
| 171 | +*/ |
| 172 | +//void BeforeTargetDownload (void) { |
| 173 | +//} |
| 174 | + |
| 175 | +/********************************************************************* |
| 176 | +* |
| 177 | +* AfterTargetDownload |
| 178 | +* |
| 179 | +* Function description |
| 180 | +* Event handler routine. |
| 181 | +* - Sets the PC register to program reset value. |
| 182 | +* - Sets the SP register to program reset value on Cortex-M. |
| 183 | +* |
| 184 | +********************************************************************** |
| 185 | +*/ |
| 186 | +void AfterTargetDownload (void) { |
| 187 | + unsigned int SP; |
| 188 | + unsigned int PC; |
| 189 | + unsigned int VectorTableAddr; |
| 190 | + |
| 191 | + VectorTableAddr = Elf.GetBaseAddr(); |
| 192 | + |
| 193 | + if (VectorTableAddr == 0xFFFFFFFF) { |
| 194 | + Util.Log("Project file error: failed to get program base"); |
| 195 | + } else { |
| 196 | + SP = Target.ReadU32(VectorTableAddr); |
| 197 | + Target.SetReg("SP", SP); |
| 198 | + |
| 199 | + PC = Target.ReadU32(VectorTableAddr + 4); |
| 200 | + Target.SetReg("PC", PC); |
| 201 | + } |
| 202 | +} |
| 203 | + |
| 204 | +/********************************************************************* |
| 205 | +* |
| 206 | +* BeforeTargetDisconnect |
| 207 | +* |
| 208 | +* Function description |
| 209 | +* Event handler routine. Optional. |
| 210 | +* |
| 211 | +********************************************************************** |
| 212 | +*/ |
| 213 | +//void BeforeTargetDisconnect (void) { |
| 214 | +//} |
| 215 | + |
| 216 | +/********************************************************************* |
| 217 | +* |
| 218 | +* AfterTargetDisconnect |
| 219 | +* |
| 220 | +* Function description |
| 221 | +* Event handler routine. Optional. |
| 222 | +* |
| 223 | +********************************************************************** |
| 224 | +*/ |
| 225 | +//void AfterTargetDisconnect (void) { |
| 226 | +//} |
| 227 | + |
| 228 | +/********************************************************************* |
| 229 | +* |
| 230 | +* AfterTargetHalt |
| 231 | +* |
| 232 | +* Function description |
| 233 | +* Event handler routine. Optional. |
| 234 | +* |
| 235 | +********************************************************************** |
| 236 | +*/ |
| 237 | +//void AfterTargetHalt (void) { |
| 238 | +//} |
0 commit comments