@@ -85,6 +85,11 @@ t_monitor_if * ptr_monitor_if;
85
85
volatile bool b_terminal_mode = false;
86
86
volatile bool b_sam_ba_interface_usart = false;
87
87
88
+ /* Pulse generation counters to keep track of the time remaining for each pulse type */
89
+ #define TX_RX_LED_PULSE_PERIOD 100
90
+ volatile uint16_t txLEDPulse = 0 ; // time remaining for Tx LED pulse
91
+ volatile uint16_t rxLEDPulse = 0 ; // time remaining for Rx LED pulse
92
+
88
93
void sam_ba_monitor_init (uint8_t com_interface )
89
94
{
90
95
#if SAM_BA_INTERFACE == SAM_BA_UART_ONLY || SAM_BA_INTERFACE == SAM_BA_BOTH_INTERFACES
@@ -110,9 +115,10 @@ static uint32_t sam_ba_putdata(t_monitor_if* pInterface, void const* data, uint3
110
115
{
111
116
uint32_t result ;
112
117
113
- LEDTX_on ();
114
118
result = pInterface -> putdata (data , length );
115
- LEDTX_off ();
119
+
120
+ LEDTX_on ();
121
+ txLEDPulse = TX_RX_LED_PULSE_PERIOD ;
116
122
117
123
return result ;
118
124
}
@@ -124,9 +130,13 @@ static uint32_t sam_ba_getdata(t_monitor_if* pInterface, void const* data, uint3
124
130
{
125
131
uint32_t result ;
126
132
127
- LEDRX_on ();
128
133
result = pInterface -> getdata (data , length );
129
- LEDRX_off ();
134
+
135
+ if (result )
136
+ {
137
+ LEDRX_on ();
138
+ rxLEDPulse = TX_RX_LED_PULSE_PERIOD ;
139
+ }
130
140
131
141
return result ;
132
142
}
@@ -138,9 +148,10 @@ static uint32_t sam_ba_putdata_xmd(t_monitor_if* pInterface, void const* data, u
138
148
{
139
149
uint32_t result ;
140
150
141
- LEDTX_on ();
142
151
result = pInterface -> putdata_xmd (data , length );
143
- LEDTX_off ();
152
+
153
+ LEDTX_on ();
154
+ txLEDPulse = TX_RX_LED_PULSE_PERIOD ;
144
155
145
156
return result ;
146
157
}
@@ -152,9 +163,13 @@ static uint32_t sam_ba_getdata_xmd(t_monitor_if* pInterface, void const* data, u
152
163
{
153
164
uint32_t result ;
154
165
155
- LEDRX_on ();
156
166
result = pInterface -> getdata_xmd (data , length );
157
- LEDRX_off ();
167
+
168
+ if (result )
169
+ {
170
+ LEDRX_on ();
171
+ rxLEDPulse = TX_RX_LED_PULSE_PERIOD ;
172
+ }
158
173
159
174
return result ;
160
175
}
@@ -510,6 +525,15 @@ static void sam_ba_monitor_loop(void)
510
525
}
511
526
}
512
527
528
+ void sam_ba_monitor_sys_tick (void )
529
+ {
530
+ /* Check whether the TX or RX LED one-shot period has elapsed. if so, turn off the LED */
531
+ if (txLEDPulse && !(-- txLEDPulse ))
532
+ LEDTX_off ();
533
+ if (rxLEDPulse && !(-- rxLEDPulse ))
534
+ LEDRX_off ();
535
+ }
536
+
513
537
/**
514
538
* \brief This function starts the SAM-BA monitor.
515
539
*/
0 commit comments