Skip to content

Commit

Permalink
Merge pull request #6 from SushiBits/master
Browse files Browse the repository at this point in the history
Allow CMSIS-DAP HAL to function without LEDs
  • Loading branch information
devanlai authored Nov 27, 2018
2 parents c3766cb + 85bb13e commit 6e96c1b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ GTAGS
*.map

# ignore local makefile settings
src/local.mk
src/local.mk

# Ignore macOS crap
.DS_Store
14 changes: 14 additions & 0 deletions src/stm32f042/DAP/CMSIS_DAP_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,52 +149,66 @@ static __inline uint32_t PIN_SWCLK_TCK_IN (void) {
}

static __inline uint32_t PIN_nRESET_IN (void) {
#if defined(nRESET_GPIO_PORT) && defined(nRESET_GPIO_PIN)
return (GPIO_IDR(nRESET_GPIO_PORT) & nRESET_GPIO_PIN) ? 0x1 : 0x0;
#else
return 1;
#endif
}

static __inline void PIN_nRESET_OUT (uint32_t bit) {
#if defined(nRESET_GPIO_PORT) && defined(nRESET_GPIO_PIN)
if (bit & 0x1) {
GPIO_BSRR(nRESET_GPIO_PORT) = nRESET_GPIO_PIN;
} else {
GPIO_BRR(nRESET_GPIO_PORT) = nRESET_GPIO_PIN;
}
#endif
}

static __inline void LED_CONNECTED_OUT (uint32_t bit) {
#if defined(LED_CON_GPIO_PORT) && defined(LED_CON_GPIO_PIN)
if ((bit & 0x1) ^ LED_OPEN_DRAIN) {
gpio_set(LED_CON_GPIO_PORT, LED_CON_GPIO_PIN);
} else {
gpio_clear(LED_CON_GPIO_PORT, LED_CON_GPIO_PIN);
}
#endif
}

static __inline void LED_RUNNING_OUT (uint32_t bit) {
#if defined(LED_RUN_GPIO_PORT) && defined(LED_RUN_GPIO_PIN)
if ((bit & 0x1) ^ LED_OPEN_DRAIN) {
gpio_set(LED_RUN_GPIO_PORT, LED_RUN_GPIO_PIN);
} else {
gpio_clear(LED_RUN_GPIO_PORT, LED_RUN_GPIO_PIN);
}
#endif
}

static __inline void LED_ACTIVITY_OUT (uint32_t bit) {
#if defined(LED_ACT_GPIO_PORT) && defined(LED_ACT_GPIO_PIN)
if ((bit & 0x1) ^ LED_OPEN_DRAIN) {
gpio_set(LED_ACT_GPIO_PORT, LED_ACT_GPIO_PIN);
} else {
gpio_clear(LED_ACT_GPIO_PORT, LED_ACT_GPIO_PIN);
}
#endif
}

static __inline void DAP_SETUP (void) {
LED_ACTIVITY_OUT(0);
LED_RUNNING_OUT(0);
LED_CONNECTED_OUT(0);

#if defined(nRESET_GPIO_PORT) && defined(nRESET_GPIO_PIN)
// Configure nRESET as an open-drain output
GPIO_BSRR(nRESET_GPIO_PORT) = nRESET_GPIO_PIN;

gpio_set_output_options(nRESET_GPIO_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_LOW, nRESET_GPIO_PIN);

gpio_mode_setup(nRESET_GPIO_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, nRESET_GPIO_PIN);
#endif
}

static __inline uint32_t RESET_TARGET (void) { return 0; }
Expand Down

0 comments on commit 6e96c1b

Please sign in to comment.