Răsfoiți Sursa

correct read()/write() retarget for msp430, fix msp430 button state

hathach 6 ani în urmă
părinte
comite
71a4076e73
2 a modificat fișierele cu 13 adăugiri și 6 ștergeri
  1. 9 2
      hw/bsp/board.c
  2. 4 4
      hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c

+ 9 - 2
hw/bsp/board.c

@@ -26,6 +26,13 @@
 
 
 #include "board.h"
 #include "board.h"
 
 
+#if defined(__MSP430__)
+  #define sys_write   write
+  #define sys_read    read
+#else
+  #define sys_write   _write
+  #define sys_read    _read
+#endif
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // MACRO TYPEDEF CONSTANT ENUM DECLARATION
 // MACRO TYPEDEF CONSTANT ENUM DECLARATION
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
@@ -45,13 +52,13 @@
 
 
 // newlib read()/write() retarget
 // newlib read()/write() retarget
 
 
-TU_ATTR_USED int _write (int fhdl, const void *buf, size_t count)
+TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
 {
 {
   (void) fhdl;
   (void) fhdl;
   return board_uart_write(buf, count);
   return board_uart_write(buf, count);
 }
 }
 
 
-TU_ATTR_USED int _read (int fhdl, char *buf, size_t count)
+TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
 {
 {
   (void) fhdl;
   (void) fhdl;
   return board_uart_read((uint8_t*) buf, count);
   return board_uart_read((uint8_t*) buf, count);

+ 4 - 4
hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c

@@ -34,7 +34,7 @@
 
 
 #define BUTTON_PORT           P1IN
 #define BUTTON_PORT           P1IN
 #define BUTTON_PIN            BIT1
 #define BUTTON_PIN            BIT1
-#define BUTTON_STATE_ACTIVE   1
+#define BUTTON_STATE_ACTIVE   0
 
 
 uint32_t cnt = 0;
 uint32_t cnt = 0;
 
 
@@ -161,7 +161,7 @@ void board_led_write(bool state)
 
 
 uint32_t board_button_read(void)
 uint32_t board_button_read(void)
 {
 {
-  return (P1IN & BIT1);
+  return ((P1IN & BIT1) >> 1) == BUTTON_STATE_ACTIVE;
 }
 }
 
 
 int board_uart_read(uint8_t * buf, int len)
 int board_uart_read(uint8_t * buf, int len)
@@ -173,7 +173,7 @@ int board_uart_read(uint8_t * buf, int len)
     buf[i] = UCA1RXBUF;
     buf[i] = UCA1RXBUF;
   }
   }
 
 
-  return 0;
+  return len;
 }
 }
 
 
 int board_uart_write(void const * buf, int len)
 int board_uart_write(void const * buf, int len)
@@ -187,7 +187,7 @@ int board_uart_write(void const * buf, int len)
     UCA1TXBUF = char_buf[i];
     UCA1TXBUF = char_buf[i];
   }
   }
 
 
-  return 0;
+  return len;
 }
 }
 
 
 #if CFG_TUSB_OS  == OPT_OS_NONE
 #if CFG_TUSB_OS  == OPT_OS_NONE