hathach 7 лет назад
Родитель
Сommit
20fb416783

+ 0 - 1
examples/device/cdc_msc_hid/Makefile

@@ -34,7 +34,6 @@ MKDIR = mkdir
 SED = sed
 CP = cp
 RM = rm
-AS = $(CROSS_COMPILE)as
 
 INC += -Isrc \
 	-I$(TOP)/hw \

+ 22 - 9
hw/bsp/board.h

@@ -65,6 +65,8 @@
   #include "metro_m4_express/board_metro_m4_express.h"
 #elif defined BOARD_METRO_M0_EXPRESS
   #include "metro_m0_express/board_metro_m0_express.h"
+
+// ST STM32
 #elif defined BOARD_STM32F407G_DISC1
   #include "stm32f407g_disc1/board_stm32f407g_disc1.h"
 #else
@@ -76,7 +78,7 @@
 #define board_tick2ms(tck)   ( ( ((uint64_t)(tck)) * 1000) / BOARD_TICKS_HZ )
 
 
-/// Initialize on-board peripherals
+// Initialize on-board peripherals
 void board_init(void);
 
 //--------------------------------------------------------------------+
@@ -104,17 +106,28 @@ static inline void board_led_off(void)
  */
 uint32_t board_buttons(void);
 
-/** Get a character input from UART
- * \return ASCII code of the input character or zero if none.
- */
-uint8_t  board_uart_getchar(void);
+//--------------------------------------------------------------------+
+// UART
+//--------------------------------------------------------------------+
 
-/** Send a character to UART
- * \param[in]  c the character to be sent
- */
-void board_uart_putchar(uint8_t c);
+// Get characters from UART
+int board_uart_read(uint8_t* buf, int len);
+
+// Send characters to UART
+int board_uart_write(void const * buf, int len);
 
 
+static inline int8_t board_uart_getchar(void)
+{
+  uint8_t c;
+  return board_uart_read(&c, 1) ? c : (-1);
+}
+
+static inline int board_uart_putchar(uint8_t c)
+{
+  return board_uart_write(&c, 1);
+}
+
 #ifdef __cplusplus
  }
 #endif

+ 7 - 4
hw/bsp/ea4088qs/board_ea4088qs.c

@@ -137,18 +137,21 @@ uint32_t board_buttons(void)
   return result;
 }
 
-
 //------------- UART -------------//
-uint8_t  board_uart_getchar(void)
+int board_uart_read(uint8_t* buf, int len)
 {
   //return UART_ReceiveByte(BOARD_UART_PORT);
+  (void) buf;
+  (void) len;
   return 0;
 }
 
-void board_uart_putchar(uint8_t c)
+int board_uart_write(void const * buf, int len)
 {
   //UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
-  (void) c;
+  (void) buf;
+  (void) len;
+  return 0;
 }
 
 

+ 7 - 3
hw/bsp/ea4357/board_ea4357.c

@@ -282,16 +282,20 @@ uint32_t board_buttons(void)
 //--------------------------------------------------------------------+
 // UART
 //--------------------------------------------------------------------+
-uint8_t  board_uart_getchar(void)
+int board_uart_read(uint8_t* buf, int len)
 {
   //return UART_ReceiveByte(BOARD_UART_PORT);
+  (void) buf;
+  (void) len;
   return 0;
 }
 
-void board_uart_putchar(uint8_t c)
+int board_uart_write(void const * buf, int len)
 {
   //UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
-  (void) c;
+  (void) buf;
+  (void) len;
+  return 0;
 }
 
 #endif

+ 9 - 5
hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c

@@ -128,15 +128,19 @@ uint32_t board_buttons(void)
 //--------------------------------------------------------------------+
 // UART
 //--------------------------------------------------------------------+
-void board_uart_putchar(uint8_t c)
+int board_uart_read(uint8_t* buf, int len)
 {
-  (void) c;
-  //UARTSend(&c, 1);
+//  *buffer = get_key(); TODO cannot find available code for uart getchar
+  (void) buf;
+  (void) len;
+  return 0;
 }
 
-uint8_t  board_uart_getchar(void)
+int board_uart_write(void const * buf, int len)
 {
-//  *buffer = get_key(); TODO cannot find available code for uart getchar
+  //UARTSend(&c, 1);
+  (void) buf;
+  (void) len;
   return 0;
 }
 

+ 8 - 4
hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c

@@ -153,14 +153,18 @@ uint32_t board_buttons(void)
 //--------------------------------------------------------------------+
 // UART
 //--------------------------------------------------------------------+
-void board_uart_putchar(uint8_t c)
+int board_uart_read(uint8_t* buf, int len)
 {
-  (void) c;
-//  UARTSend(&c, 1);
+  (void) buf;
+  (void) len;
+  return 0;
 }
 
-uint8_t  board_uart_getchar(void)
+int board_uart_write(void const * buf, int len)
 {
+//  UARTSend(&c, 1);
+  (void) buf;
+  (void) len;
   return 0;
 }
 

+ 10 - 5
hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c

@@ -193,15 +193,20 @@ uint32_t board_buttons(void)
 //--------------------------------------------------------------------+
 // UART
 //--------------------------------------------------------------------+
-void board_uart_putchar(uint8_t c)
+int board_uart_read(uint8_t* buf, int len)
 {
-  (void) c;
-//  UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+//  return UART_ReceiveByte(BOARD_UART_PORT);
+  (void) buf;
+  (void) len;
+  return 0;
+
 }
 
-uint8_t  board_uart_getchar(void)
+int board_uart_write(void const * buf, int len)
 {
-//  return UART_ReceiveByte(BOARD_UART_PORT);
+//  UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+  (void) buf;
+  (void) len;
   return 0;
 }
 

+ 7 - 3
hw/bsp/mcb1800/board_mcb1800.c

@@ -205,16 +205,20 @@ uint32_t board_buttons(void)
 
 
 //------------- UART -------------//
-uint8_t  board_uart_getchar(void)
+int board_uart_read(uint8_t* buf, int len)
 {
   //return UART_ReceiveByte(BOARD_UART_PORT);
+  (void) buf;
+  (void) len;
   return 0;
 }
 
-void board_uart_putchar(uint8_t c)
+int board_uart_write(void const * buf, int len)
 {
-  (void) c;
   //UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+  (void) buf;
+  (void) len;
+  return 0;
 }
 
 /*------------------------------------------------------------------*/

+ 7 - 3
hw/bsp/pca10056/board_pca10056.c

@@ -247,14 +247,18 @@ uint32_t board_buttons(void)
   return ret;
 }
 
-uint8_t board_uart_getchar(void)
+int board_uart_read(uint8_t* buf, int len)
 {
+  (void) buf;
+  (void) len;
   return 0;
 }
 
-void board_uart_putchar(uint8_t c)
+int board_uart_write(void const * buf, int len)
 {
-  (void) c;
+  (void) buf;
+  (void) len;
+  return 0;
 }
 
 #ifdef SOFTDEVICE_PRESENT

+ 2 - 2
hw/bsp/printf_retarget.c

@@ -168,8 +168,8 @@ size_t __read(int handle, unsigned char *buf, size_t bufSize)
   size_t i;
   for (i=0; i<bufSize; i++)
   {
-    uint8_t ch = board_uart_getchar();
-    if (ch == 0) break;
+    int8_t ch = board_uart_getchar();
+    if (ch == -1) break;
     buf[i] = ch;
   }