-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSoC4_HSSP_Arduino.ino
104 lines (87 loc) · 2.61 KB
/
PSoC4_HSSP_Arduino.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "ProgrammingSteps.h"
unsigned char currentStep;
void setup() {
// put your setup code here, to run once:
unsigned char programResult;
unsigned char errorStatus;
unsigned char sromErrorStatus;
Serial.begin(115200);
Serial.println("");
Serial.println("Programming PSoC 4");
programResult = ProgramDevice();
if (programResult == SUCCESS) {
Serial.println("HSSP Success");
}
else {
Serial.println("HSSP Fail Step");
Serial.println(currentStep, DEC);
errorStatus = ReadHsspErrorStatus();
Serial.println("Err");
Serial.println(errorStatus, HEX);
if ((errorStatus & SROM_TIMEOUT_ERROR) == 0x01) {
sromErrorStatus = ReadSromStatus();
Serial.println("SROM");
Serial.println(sromErrorStatus, HEX);
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}
/******************************************************************************
* Function Name: ProgramDevice
*******************************************************************************
* Summary:
* This function sequentially calls all the functions required to program a
* PSoC 4/PSoC Analog Coprocessor. These functions are defined in ProgrammingSteps.h.
*
* Parameters:
* None.
*
* Return:
* SUCCESS - All the programming steps executed successfully
* FAILURE - HSSP programming fails in any one of the programming step
*
******************************************************************************/
unsigned char ProgramDevice(void)
{
currentStep = 1;
Serial.println(currentStep);
if (DeviceAcquire() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (VerifySiliconId() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (EraseAllFlash() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (ChecksumPrivileged() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (ProgramFlash() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (VerifyFlash() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (ProgramProtectionSettings() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (VerifyProtectionSettings() == FAILURE)
return (FAILURE);
currentStep++;
Serial.println(currentStep);
if (VerifyChecksum() == FAILURE)
return (FAILURE);
ExitProgrammingMode();
/* All the steps were completed successfully */
return (SUCCESS);
}