-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSWD_PhysicalLayer.h
141 lines (124 loc) · 6.46 KB
/
SWD_PhysicalLayer.h
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/******************************************************************************
* File Name: SWD_PhysicalLayer.h
* Version 1.0
*
* Description:
* This header file contains the macro definitions, function declarations for
* the physical layer of the SWD protocol. These include -
* a.) Setting a output pin high or low
* b.) Reading the logic level of an input pin
* c.) Configuring the drive mode of the programming pin
*
* The pin manipulation routines are defined both as macros and functions.
* The macros are used in "Step 1. DeviceAcquire()" as the function has strict
* timing requirements for execution. Using the macros instead of fuctions
* reduces execution overhead.
*
* The pin manipulation functions are used instead of macros in all other
* places to save code space.
*
* Note:
* The macros, functions defined here are specific to PSoC 5LP Host Programmer.
* Modify them as applicable for your Host Programmer.
*
*******************************************************************************
* Copyright (c) 2013-2016, Cypress Semiconductor Corporation.
*******************************************************************************
* This software is owned by Cypress Semiconductor Corporation (Cypress) and is
* protected by and subject to worldwide patent protection (United States and
* foreign), United States copyright laws and international treaty provisions.
* Cypress hereby grants to licensee a personal, non-exclusive, non-transferable
* license to copy, use, modify, create derivative works of, and compile the
* Cypress Source Code and derivative works for the sole purpose of creating
* custom software in support of licensee product to be used only in conjunction
* with a Cypress integrated circuit as specified in the applicable agreement.
* Any reproduction, modification, translation, compilation, or representation of
* this software except as specified above is prohibited without the express
* written permission of Cypress.
*
* Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
* REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* Cypress reserves the right to make changes without further notice to the
* materials described herein. Cypress does not assume any liability arising out
* of the application or use of any product or circuit described herein. Cypress
* does not authorize its products for use as critical components in life-support
* systems where a malfunction or failure may reasonably be expected to result in
* significant injury to the user. The inclusion of Cypress' product in a life-
* support systems application implies that the manufacturer assumes all risk of
* such use and in doing so indemnifies Cypress against all charges. Use may be
* limited by and subject to the applicable Cypress software license agreement.
******************************************************************************/
#ifndef __SWD_PHYSICALLAYER_H
#define __SWD_PHYSICALLAYER_H
/* Host programmer registers, mask values are defined in "RegisterDefines.h" */
//#include "RegisterDefines.h"
#include <Arduino.h>
#define SWDIO_PIN 4
#define SWDCK_PIN 2
#define XRES_PIN 15
/***************************** USER ATTENTION REQUIRED ************************
***************************** HOST PROCESSOR SPECIFIC *************************
**************** Macros for Host Pin Drive mode configuration *****************
*
* Uses the register definitions, mask values in "RegisterDefines.h" to
* configure the pin drive mode
*
* SWDIO pin on host side - CMOS output (host writes data to target PSoC 4),
* High Z digital input (host reads data from target
* PSoC 4 or when host is not programming target
* PSoC 4 (idle))
*
* SWDCK pin on host side - CMOS output (when host is programming target PSoC 4),
* High Z digital input (when host is not programming
* target PSoC 4 (idle))
*
* XRES pin on host side - CMOS output (when host is programming target PSoC 4)
* High Z digital input (when host is not programming
* target PSoC 4 (idle))
*
* Modify these as applicable to your Host Programmer
******************************************************************************/
#define SWDIO_DRIVEMODE_HIGHZIN pinMode(SWDIO_PIN, INPUT)
#define SWDIO_DRIVEMODE_CMOSOUT pinMode(SWDIO_PIN, OUTPUT)
#define SWDCK_DRIVEMODE_HIGHZIN pinMode(SWDCK_PIN, INPUT)
#define SWDCK_DRIVEMODE_CMOSOUT pinMode(SWDCK_PIN, OUTPUT)
#define XRES_DRIVEMODE_HIGHZIN pinMode(XRES_PIN, INPUT)
#define XRES_DRIVEMODE_CMOSOUT pinMode(XRES_PIN, OUTPUT)
/***************************** USER ATTENTION REQUIRED ************************
***************************** HOST PROCESSOR SPECIFIC *************************
**************** Macros for driving output pins on host side ******************
*
* Uses the register definitions, mask values in "RegisterDefines.h" to drive
* output pins either to logic high (suffixed by 'HIGH') or
* logic low (suffixed by 'LOW')
*
* Modify these as applicable to your Host Programmer
******************************************************************************/
#define SWDIO_OUTPUT_HIGH digitalWrite(SWDIO_PIN, HIGH)
#define SWDIO_OUTPUT_LOW digitalWrite(SWDIO_PIN, LOW)
#define SWDCK_OUTPUT_HIGH digitalWrite(SWDCK_PIN, HIGH)
#define SWDCK_OUTPUT_LOW digitalWrite(SWDCK_PIN, LOW)
#define XRES_OUTPUT_HIGH digitalWrite(XRES_PIN, HIGH)
#define XRES_OUTPUT_LOW digitalWrite(XRES_PIN, LOW)
/******************************************************************************
* Function Prototypes
******************************************************************************/
/* The below fuctions are for pin manipulation, and their definitions in
SWD_PhysicalLayer.c are the same as the corresponding macro defitnions
above. */
void SetSwdckHigh(void);
void SetSwdckLow(void);
void SetSwdckCmosOutput(void);
void SetSwdckHizInput(void);
void SetSwdioHigh(void);
void SetSwdioLow(void);
void SetSwdioCmosOutput(void);
unsigned char ReadSwdio(void);
void SetSwdioHizInput(void);
void SetXresHigh(void);
void SetXresLow(void);
void SetXresCmosOutput(void);
void SetXresHizInput(void);
#endif /* __SWD_PHYSICALLAYER_H */
/*[] END OF FILE */