-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
123 lines (107 loc) · 3.76 KB
/
main.c
File metadata and controls
123 lines (107 loc) · 3.76 KB
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
/******************************************************************************
* File Name: main.c
*
* Description: This is the source code for the XMC4300 SSC EtherCAT Application
* for ModusToolbox.
*
* Related Document: See README.md
*
******************************************************************************
*
* Copyright (c) 2015-2025, Infineon Technologies AG
* All rights reserved.
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include "cybsp.h"
#include "cy_utils.h"
#include "mtb_xmc_ecat.h"
#include "XMC_ESCObjects.h"
#include "ecatappl.h"
#include "applInterface.h"
#define MAP2LEVEL(x) ((x==0)?XMC_GPIO_OUTPUT_LEVEL_LOW:XMC_GPIO_OUTPUT_LEVEL_HIGH)
void process_app(TOBJ7000 *OUT_GENERIC, TOBJ6000 *IN_GENERIC);
void SYNC0IRQHandler(void);
void SYNC1IRQHandler(void);
void process_app(TOBJ7000 *OUT_GENERIC, TOBJ6000 *IN_GENERIC)
{
/* OUTPUT PROCESSING */
/* Check bitfield set by master OUT_GEN_Bit1..8 and set LEDs accordingly */
XMC_GPIO_SetOutputLevel(CYBSP_USER_LED1_PORT, CYBSP_USER_LED1_PIN, MAP2LEVEL(OUT_GENERIC->OUT_GEN_Bit1));
XMC_GPIO_SetOutputLevel(CYBSP_USER_LED2_PORT, CYBSP_USER_LED2_PIN, MAP2LEVEL(OUT_GENERIC->OUT_GEN_Bit2));
/* INPUT PROCESSING */
/*Check Button 1 and set IN_GEN_Bit1, which is sent to master accordingly*/
if (XMC_GPIO_GetInput(CYBSP_USER_BTN1_PORT, CYBSP_USER_BTN1_PIN))
{
IN_GENERIC->IN_GEN_Bit1 = 1;
}
else
{
IN_GENERIC->IN_GEN_Bit1 = 0;
}
}
int main(void)
{
cy_rslt_t result;
/* Initialize the device and board peripherals */
result = cybsp_init();
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
mtb_xmc_ecat_init();
while(1U)
{
MainLoop();
}
}
void ERU1_0_IRQHandler(void)
{
SYNC0IRQHandler(); // Call the Sync0 handler
}
void SYNC0IRQHandler(void)
{
Sync0_Isr();
}
void ERU1_2_IRQHandler(void)
{
SYNC1IRQHandler(); // Call the Sync1 handler
}
void SYNC1IRQHandler(void)
{
Sync1_Isr();
}
void mtb_xmc_enable_user_int()
{
NVIC_EnableIRQ(ECAT_ERU_SYNC0_IRQN);
NVIC_EnableIRQ(ECAT_ERU_SYNC1_IRQN);
}
void mtb_xmc_disable_user_int()
{
NVIC_DisableIRQ(ECAT_ERU_SYNC0_IRQN);
NVIC_DisableIRQ(ECAT_ERU_SYNC1_IRQN);
}
/* [] END OF FILE */