2525#include "board_driver_usb.h"
2626#include "sam_ba_usb.h"
2727#include "sam_ba_cdc.h"
28+ #include "board_driver_led.h"
2829
2930const char RomBOOT_Version [] = SAM_BA_VERSION ;
3031const char RomBOOT_ExtendedCapabilities [] = "[Arduino:XYZ]" ;
@@ -102,8 +103,64 @@ void sam_ba_monitor_init(uint8_t com_interface)
102103#endif
103104}
104105
106+ /*
107+ * Central SAM-BA monitor putdata function using the board LEDs
108+ */
109+ static uint32_t sam_ba_putdata (t_monitor_if * pInterface , void const * data , uint32_t length )
110+ {
111+ uint32_t result ;
112+
113+ LEDTX_on ();
114+ result = pInterface -> putdata (data , length );
115+ LEDTX_off ();
116+
117+ return result ;
118+ }
119+
120+ /*
121+ * Central SAM-BA monitor getdata function using the board LEDs
122+ */
123+ static uint32_t sam_ba_getdata (t_monitor_if * pInterface , void const * data , uint32_t length )
124+ {
125+ uint32_t result ;
126+
127+ LEDRX_on ();
128+ result = pInterface -> getdata (data , length );
129+ LEDRX_off ();
130+
131+ return result ;
132+ }
133+
134+ /*
135+ * Central SAM-BA monitor putdata function using the board LEDs
136+ */
137+ static uint32_t sam_ba_putdata_xmd (t_monitor_if * pInterface , void const * data , uint32_t length )
138+ {
139+ uint32_t result ;
140+
141+ LEDTX_on ();
142+ result = pInterface -> putdata_xmd (data , length );
143+ LEDTX_off ();
144+
145+ return result ;
146+ }
147+
148+ /*
149+ * Central SAM-BA monitor getdata function using the board LEDs
150+ */
151+ static uint32_t sam_ba_getdata_xmd (t_monitor_if * pInterface , void const * data , uint32_t length )
152+ {
153+ uint32_t result ;
154+
155+ LEDRX_on ();
156+ result = pInterface -> getdata_xmd (data , length );
157+ LEDRX_off ();
158+
159+ return result ;
160+ }
161+
105162/**
106- * \brief This function allows data rx by USART
163+ * \brief This function allows data emission by USART
107164 *
108165 * \param *data Data pointer
109166 * \param length Length of the data
@@ -141,10 +198,10 @@ void sam_ba_putdata_term(uint8_t* data, uint32_t length)
141198 buf [1 ] = 'x' ;
142199 buf [length * 2 + 2 ] = '\n' ;
143200 buf [length * 2 + 3 ] = '\r' ;
144- ptr_monitor_if -> putdata ( buf , length * 2 + 4 );
201+ sam_ba_putdata ( ptr_monitor_if , buf , length * 2 + 4 );
145202 }
146203 else
147- ptr_monitor_if -> putdata ( data , length );
204+ sam_ba_putdata ( ptr_monitor_if , data , length );
148205 return ;
149206}
150207
@@ -187,12 +244,12 @@ static void put_uint32(uint32_t n)
187244
188245 buff [7 - i ] = d > 9 ? 'A' + d - 10 : '0' + d ;
189246 }
190- ptr_monitor_if -> putdata ( buff , 8 );
247+ sam_ba_putdata ( ptr_monitor_if , buff , 8 );
191248}
192249
193250static void sam_ba_monitor_loop (void )
194251{
195- length = ptr_monitor_if -> getdata ( data , SIZEBUFMAX );
252+ length = sam_ba_getdata ( ptr_monitor_if , data , SIZEBUFMAX );
196253 ptr = data ;
197254
198255 for (i = 0 ; i < length ; i ++ , ptr ++ )
@@ -203,7 +260,7 @@ static void sam_ba_monitor_loop(void)
203260 {
204261 if (b_terminal_mode )
205262 {
206- ptr_monitor_if -> putdata ( "\n\r" , 2 );
263+ sam_ba_putdata ( ptr_monitor_if , "\n\r" , 2 );
207264 }
208265 if (command == 'S' )
209266 {
@@ -235,13 +292,13 @@ static void sam_ba_monitor_loop(void)
235292 ptr -- ;
236293 //Do we expect more data ?
237294 if (j < current_number )
238- ptr_monitor_if -> getdata_xmd ( ptr_data , current_number - j );
295+ sam_ba_getdata_xmd ( ptr_monitor_if , ptr_data , current_number - j );
239296
240297 __asm("nop" );
241298 }
242299 else if (command == 'R' )
243300 {
244- ptr_monitor_if -> putdata_xmd ( ptr_data , current_number );
301+ sam_ba_putdata_xmd ( ptr_monitor_if , ptr_data , current_number );
245302 }
246303 else if (command == 'O' )
247304 {
@@ -282,35 +339,35 @@ static void sam_ba_monitor_loop(void)
282339 else if (command == 'T' )
283340 {
284341 b_terminal_mode = 1 ;
285- ptr_monitor_if -> putdata ( "\n\r" , 2 );
342+ sam_ba_putdata ( ptr_monitor_if , "\n\r" , 2 );
286343 }
287344 else if (command == 'N' )
288345 {
289346 if (b_terminal_mode == 0 )
290347 {
291- ptr_monitor_if -> putdata ( "\n\r" , 2 );
348+ sam_ba_putdata ( ptr_monitor_if , "\n\r" , 2 );
292349 }
293350 b_terminal_mode = 0 ;
294351 }
295352 else if (command == 'V' )
296353 {
297- ptr_monitor_if -> putdata ( "v" , 1 );
298- ptr_monitor_if -> putdata ( (uint8_t * ) RomBOOT_Version , strlen (RomBOOT_Version ));
299- ptr_monitor_if -> putdata ( " " , 1 );
300- ptr_monitor_if -> putdata ( (uint8_t * ) RomBOOT_ExtendedCapabilities , strlen (RomBOOT_ExtendedCapabilities ));
301- ptr_monitor_if -> putdata ( " " , 1 );
354+ sam_ba_putdata ( ptr_monitor_if , "v" , 1 );
355+ sam_ba_putdata ( ptr_monitor_if , (uint8_t * ) RomBOOT_Version , strlen (RomBOOT_Version ));
356+ sam_ba_putdata ( ptr_monitor_if , " " , 1 );
357+ sam_ba_putdata ( ptr_monitor_if , (uint8_t * ) RomBOOT_ExtendedCapabilities , strlen (RomBOOT_ExtendedCapabilities ));
358+ sam_ba_putdata ( ptr_monitor_if , " " , 1 );
302359 ptr = (uint8_t * ) & (__DATE__ );
303360 i = 0 ;
304361 while (* ptr ++ != '\0' )
305362 i ++ ;
306- ptr_monitor_if -> putdata ( (uint8_t * ) & (__DATE__ ), i );
307- ptr_monitor_if -> putdata ( " " , 1 );
363+ sam_ba_putdata ( ptr_monitor_if , (uint8_t * ) & (__DATE__ ), i );
364+ sam_ba_putdata ( ptr_monitor_if , " " , 1 );
308365 i = 0 ;
309366 ptr = (uint8_t * ) & (__TIME__ );
310367 while (* ptr ++ != '\0' )
311368 i ++ ;
312- ptr_monitor_if -> putdata ( (uint8_t * ) & (__TIME__ ), i );
313- ptr_monitor_if -> putdata ( "\n\r" , 2 );
369+ sam_ba_putdata ( ptr_monitor_if , (uint8_t * ) & (__TIME__ ), i );
370+ sam_ba_putdata ( ptr_monitor_if , "\n\r" , 2 );
314371 }
315372 else if (command == 'X' )
316373 {
@@ -334,7 +391,7 @@ static void sam_ba_monitor_loop(void)
334391 }
335392
336393 // Notify command completed
337- ptr_monitor_if -> putdata ( "X\n\r" , 3 );
394+ sam_ba_putdata ( ptr_monitor_if , "X\n\r" , 3 );
338395 }
339396 else if (command == 'Y' )
340397 {
@@ -393,7 +450,7 @@ static void sam_ba_monitor_loop(void)
393450 }
394451
395452 // Notify command completed
396- ptr_monitor_if -> putdata ( "Y\n\r" , 3 );
453+ sam_ba_putdata ( ptr_monitor_if , "Y\n\r" , 3 );
397454 }
398455 else if (command == 'Z' )
399456 {
@@ -412,17 +469,17 @@ static void sam_ba_monitor_loop(void)
412469 crc = serial_add_crc (* data ++ , crc );
413470
414471 // Send response
415- ptr_monitor_if -> putdata ( "Z" , 1 );
472+ sam_ba_putdata ( ptr_monitor_if , "Z" , 1 );
416473 put_uint32 (crc );
417- ptr_monitor_if -> putdata ( "#\n\r" , 3 );
474+ sam_ba_putdata ( ptr_monitor_if , "#\n\r" , 3 );
418475 }
419476
420477 command = 'z' ;
421478 current_number = 0 ;
422479
423480 if (b_terminal_mode )
424481 {
425- ptr_monitor_if -> putdata ( ">" , 1 );
482+ sam_ba_putdata ( ptr_monitor_if , ">" , 1 );
426483 }
427484 }
428485 else
0 commit comments