-
Notifications
You must be signed in to change notification settings - Fork 0
/
peripherals_hooks.c
169 lines (141 loc) · 4.47 KB
/
peripherals_hooks.c
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/******************************************************************************
* Copyright (c) 2019 - Hemant Sharma - All Rights Reserved
*
* Feel free to use this Code at your own risk for your own purposes.
*
*******************************************************************************/
/******************************************************************************
* Title: Peripherals Hooks Source
* Filename: peripherals_hooks.c
* Author: HS
* Origin Date:
* Version:
* Notes:
*
* Change History
* --------------
*
*******************************************************************************/
/** @file: peripherals_hooks.c
* @brief: This source file contains callback functions for peripherals
*/
/******************************************************************************
* Includes
*******************************************************************************/
/* Include peripherals files*/
#include <dri_uart_extern.h>
#include <dri_can_extern.h>
#include <dri_rtc_extern.h>
#include <dri_scu_extern.h>
/* Include Standard Headers */
#include <dri_mem.h>
/******************************************************************************
* Preprocessor Constants
*******************************************************************************/
/******************************************************************************
* Configuration Constants
*******************************************************************************/
/******************************************************************************
* Variables
*******************************************************************************/
/******************************************************************************
* Functions
*******************************************************************************/
#if (UART_CALLBACK_HANDLER_USED == 1U)
/* UART Callback handler */
void UART_callback_handler( const eUART_Channel channel, unsigned char *p_data, const eUART_Event event );
void UART_callback_handler( const eUART_Channel channel, unsigned char *p_data, const eUART_Event event )
{
/* Local variables */
unsigned char * p_data_l = p_data;
/* Check events */
switch( event )
{
default:
case UART_EVENT_TX_COMPLETE:
if( UART_CHANNEL_0 == channel )
{
/* Transmission successful! */
__asm("NOP");
}
break;
case UART_EVENT_RX_COMPLETE:
if( UART_CHANNEL_0 == channel )
{
/* Reception successful! */
__asm("NOP");
}
break;
case UART_EVENT_RX_CHAR:
switch( channel )
{
default:
case UART_CHANNEL_0:
/* Reception successfull, transmit received data */
UART_Api_Functions.fp_transmit( &UART_Channel_0, p_data_l, 1 );
break;
case UART_CHANNEL_2:
/* Reception successfull, transmit received data */
break;
}
break;
}
}
#endif /* UART_CALLBACK_HANDLER_USED */
/* CAN Callback Handler */
#if (CAN_CALLBACK_HANDLER_USED == 1U)
void CAN_callback_handler( void * p_channel, const eCAN_EventType event_type, const eCAN_Event event );
void CAN_callback_handler( void * p_channel, const eCAN_EventType event_type, const eCAN_Event event )
{
DRIVER_ASSERT_NRET( NULL == p_channel );
/* Local Variables */
tStCAN_NodeConfiguartion * const p_config_l = ((tStCAN_Node *)p_channel)->p_config;
tStCAN_Control * const p_control_l = ((tStCAN_Node *)p_channel)->p_control;
/* Check Event Type */
switch( event_type )
{
default:
case CAN_EVENT_TYPE_NODE_TRANSFER:
/* Check Node Transfer event */
switch( event )
{
default:
case CAN_EVENT_NODE_TRANSFER_TRANSMIT:
if( (1 == p_control_l->state.init) && (1 == p_control_l->state.tx_busy) )
{
p_control_l->state.tx_busy = 0;
}
break;
case CAN_EVENT_NODE_TRANSFER_RECEIVE:
if( (1 == p_control_l->state.init) && (0 == p_control_l->state.rx_busy) )
{
XMC_CAN_MO_ReceiveData( p_config_l->p_message_rx );
p_control_l->state.rx_busy = 0;
}
else/* Direct Read Data from CAN Node in a common Mo */
{
}
break;
}
break; /* CAN_EVENT_TYPE_NODE_TRANSFER */
}
}
#endif
/* SCU Callback Handler */
#if (SCU_CALLBACK_HANDLER_USED == 1U)
void SCU_callback_handler( void );
void SCU_callback_handler( void )
{
__asm("NOP");
}
#endif
/* RTC Callback Handler */
#if (RTC_CALLBACK_HANDLER_USED == 1U)
void RTC_callback_handler( void * p_channel, const eRTC_Events event );
void RTC_callback_handler( void * p_channel, const eRTC_Events event )
{
(void) p_channel;
(void) event;
}
#endif
/********************************** End of File *******************************/