summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2014-03-11 17:16:13 +0700
committerhathach <[email protected]>2014-03-11 17:16:13 +0700
commit52785c9fd659ff02a108e4e95145a3f2cd527de5 (patch)
treedb08b4c9bb903056caca71397b757ec0fc6e25dd
parentd6566400fd6fd96d02fd12733b72b8fa0eb22cdd (diff)
NGX4330 device os none work well with lpcxpresso
-rw-r--r--demos/bsp/boards/ngx/board_ngx4330.c43
-rw-r--r--demos/device/src/tusb_config.h2
2 files changed, 42 insertions, 3 deletions
diff --git a/demos/bsp/boards/ngx/board_ngx4330.c b/demos/bsp/boards/ngx/board_ngx4330.c
index 79f9d78fb..0709db2f9 100644
--- a/demos/bsp/boards/ngx/board_ngx4330.c
+++ b/demos/bsp/boards/ngx/board_ngx4330.c
@@ -42,14 +42,29 @@
#define BOARD_UART_PORT LPC_USART0
-#define BOARD_MAX_LEDS 2
const static struct {
uint8_t mux_port;
uint8_t mux_pin;
uint8_t gpio_port;
uint8_t gpio_pin;
-}leds[BOARD_MAX_LEDS] = { {2, 11, 1, 11}, {2, 12, 1,12} };
+}leds[] = { {2, 11, 1, 11}, {2, 12, 1,12} };
+
+enum {
+ BOARD_MAX_LEDS = sizeof(leds) / sizeof(leds[0])
+};
+
+const static struct {
+ uint8_t mux_port;
+ uint8_t mux_pin;
+
+ uint8_t gpio_port;
+ uint8_t gpio_pin;
+}buttons[] = { {0x02, 7, 0, 7 } };
+
+enum {
+ BOARD_BUTTON_COUNT = sizeof(buttons) / sizeof(buttons[0])
+};
void board_init(void)
{
@@ -73,6 +88,13 @@ void board_init(void)
GPIO_SetDir(leds[i].gpio_port, BIT_(leds[i].gpio_pin), 1); // output
}
+ //------------- BUTTONS -------------//
+ for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++)
+ {
+ scu_pinmux(buttons[i].mux_port, buttons[i].mux_pin, GPIO_NOPULL, FUNC0);
+ GPIO_SetDir(buttons[i].gpio_port, BIT_(buttons[i].gpio_pin), 0);
+ }
+
//------------- UART init -------------//
scu_pinmux(0x6 ,4, MD_PDN | MD_EZI, FUNC2); // UART0_TXD
scu_pinmux(0x6 ,5, MD_PDN | MD_EZI, FUNC2); // UART0_RXD
@@ -104,6 +126,23 @@ void board_leds(uint32_t on_mask, uint32_t off_mask)
}
//--------------------------------------------------------------------+
+// BUTTONS
+//--------------------------------------------------------------------+
+static bool button_read(uint8_t id)
+{
+ return !BIT_TEST_( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
+}
+
+uint32_t board_buttons(void)
+{
+ uint32_t result = 0;
+
+ for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) result |= (button_read(i) ? BIT_(i) : 0);
+
+ return result;
+}
+
+//--------------------------------------------------------------------+
// UART
//--------------------------------------------------------------------+
uint8_t board_uart_getchar(void)
diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h
index 19d40e023..d8f20b14e 100644
--- a/demos/device/src/tusb_config.h
+++ b/demos/device/src/tusb_config.h
@@ -85,7 +85,7 @@
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
#define TUSB_CFG_DEVICE_HID_MOUSE 1
#define TUSB_CFG_DEVICE_HID_GENERIC 0
-#define TUSB_CFG_DEVICE_MSC 0
+#define TUSB_CFG_DEVICE_MSC 1
#define TUSB_CFG_DEVICE_CDC 1
//--------------------------------------------------------------------+