From b0446e4b01f921b6a2cd6fcd2289daf1e7e6b8aa Mon Sep 17 00:00:00 2001 From: Alex Taradov Date: Sun, 17 Jul 2016 23:42:10 -0700 Subject: [PATCH] Implemented LED logic --- README.md | 3 ++- dap.c | 4 +--- dap.h | 1 - platform/samd21/dap_config.h | 12 ++++++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7353b66..e71a8f5 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,12 @@ Your configuration file will need to define the following pin manipulation funct Note that all pin manipulation functions are required even if one of the interfaces (JTAG or SWD) is not enabled. -Additionally configuration file must contain basic initialization functions: +Additionally configuration file must provide basic initialization and control functions: * DAP_CONFIG_SETUP() * DAP_CONFIG_DISCONNECT() * DAP_CONFIG_CONNECT_SWD() * DAP_CONFIG_CONNECT_JTAG() + * DAP_CONFIG_LED() diff --git a/dap.c b/dap.c index 2f0ed57..216fd06 100644 --- a/dap.c +++ b/dap.c @@ -652,9 +652,7 @@ static void dap_led(uint8_t *req, uint8_t *resp) int index = req[0]; int state = req[1]; - // TODO: Actually set LED state - (void)index; - (void)state; + DAP_CONFIG_LED(index, state); resp[0] = DAP_OK; } diff --git a/dap.h b/dap.h index d08e49b..abf2a1d 100644 --- a/dap.h +++ b/dap.h @@ -30,7 +30,6 @@ #define _DAP_H_ /*- Includes ----------------------------------------------------------------*/ -#include #include /*- Prototypes --------------------------------------------------------------*/ diff --git a/platform/samd21/dap_config.h b/platform/samd21/dap_config.h index e55c35d..17fa37e 100644 --- a/platform/samd21/dap_config.h +++ b/platform/samd21/dap_config.h @@ -41,6 +41,8 @@ HAL_GPIO_PIN(TDO, A, 9) HAL_GPIO_PIN(nTRST, B, 23) HAL_GPIO_PIN(nRESET, A, 2) +HAL_GPIO_PIN(LED, B, 30) + #define DAP_CONFIG_ENABLE_SWD //#define DAP_CONFIG_ENABLE_JTAG @@ -171,6 +173,9 @@ static inline void DAP_CONFIG_SETUP(void) HAL_GPIO_nRESET_in(); HAL_GPIO_SWDIO_TMS_pullup(); + + HAL_GPIO_LED_out(); + HAL_GPIO_LED_set(); } //----------------------------------------------------------------------------- @@ -222,5 +227,12 @@ static inline void DAP_CONFIG_CONNECT_JTAG(void) HAL_GPIO_nTRST_set(); } +//----------------------------------------------------------------------------- +static inline void DAP_CONFIG_LED(int index, int state) +{ + if (0 == index) + HAL_GPIO_LED_write(!state); +} + #endif // _DAP_CONFIG_H_