diff options
Diffstat (limited to 'wirish')
| -rw-r--r-- | wirish/boards/maple.cpp | 13 | ||||
| -rw-r--r-- | wirish/boards/maple.h | 13 | ||||
| -rw-r--r-- | wirish/boards/maple_mini.cpp | 5 | ||||
| -rw-r--r-- | wirish/boards/maple_mini.h | 6 | ||||
| -rw-r--r-- | wirish/boards/maple_native.cpp | 16 | ||||
| -rw-r--r-- | wirish/boards/maple_native.h | 10 | ||||
| -rw-r--r-- | wirish/wirish.h | 1 | ||||
| -rw-r--r-- | wirish/wirish_debug.h | 54 | 
8 files changed, 107 insertions, 11 deletions
| diff --git a/wirish/boards/maple.cpp b/wirish/boards/maple.cpp index 5122290..2d35e7b 100644 --- a/wirish/boards/maple.cpp +++ b/wirish/boards/maple.cpp @@ -88,7 +88,15 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {      {GPIOC,   NULL, NULL,  6, 0, ADCx}, /* D35/PC6 */      {GPIOC,   NULL, NULL,  7, 0, ADCx}, /* D36/PC7 */      {GPIOC,   NULL, NULL,  8, 0, ADCx}, /* D37/PC8 */ -    {GPIOC,   NULL, NULL,  9, 0, ADCx}  /* D38/PC9 (BUT) */ +    {GPIOC,   NULL, NULL,  9, 0, ADCx}, /* D38/PC9 (BUT) */ + +    /* JTAG header */ + +    {GPIOA,   NULL, NULL, 13, 0, ADCx}, /* D39/PA13 */ +    {GPIOA,   NULL, NULL, 14, 0, ADCx}, /* D40/PA14 */ +    {GPIOA,   NULL, NULL, 15, 0, ADCx}, /* D41/PA15 */ +    {GPIOB,   NULL, NULL,  3, 0, ADCx}, /* D42/PB3  */ +    {GPIOB,   NULL, NULL,  4, 0, ADCx}, /* D43/PB4  */  };  extern const uint8 boardPWMPins[] __FLASH__ = { @@ -100,7 +108,8 @@ extern const uint8 boardADCPins[] __FLASH__ = {  };  extern const uint8 boardUsedPins[] __FLASH__ = { -    BOARD_LED_PIN, BOARD_BUTTON_PIN +    BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN, +    BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN  };  #endif diff --git a/wirish/boards/maple.h b/wirish/boards/maple.h index 1867de8..4a4465c 100644 --- a/wirish/boards/maple.h +++ b/wirish/boards/maple.h @@ -54,7 +54,7 @@  /* Total number of GPIO pins that are broken out to headers and   * intended for general use. */ -#define BOARD_NR_GPIO_PINS      39 +#define BOARD_NR_GPIO_PINS      44  /* Number of pins capable of PWM output */  #define BOARD_NR_PWM_PINS       16 @@ -64,6 +64,15 @@  /* Number of pins already connected to external hardware.  For Maple,   * these are just BOARD_LED_PIN and BOARD_BUTTON_PIN. */ -#define BOARD_NR_USED_PINS       2 +#define BOARD_NR_USED_PINS       7 + +/* + * Debug port pins + */ +#define BOARD_JTMS_SWDIO_PIN    39 +#define BOARD_JTCK_SWCLK_PIN    40 +#define BOARD_JTDI_PIN          41 +#define BOARD_JTDO_PIN          42 +#define BOARD_NJTRST_PIN        43  #endif diff --git a/wirish/boards/maple_mini.cpp b/wirish/boards/maple_mini.cpp index cd2827d..02d62c7 100644 --- a/wirish/boards/maple_mini.cpp +++ b/wirish/boards/maple_mini.cpp @@ -32,13 +32,14 @@  #include "maple_mini.h"  #include "gpio.h" +#include "wirish_debug.h"  #ifdef BOARD_maple_mini  /* Since we want the Serial Wire/JTAG pins as GPIOs, disable both SW   * and JTAG debug support */  void boardInit(void) { -    afio_mapr_swj_config(AFIO_MAPR_SWJ_NO_JTAG_NO_SW); +    disableDebugPorts();  }  extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { @@ -89,7 +90,7 @@ extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {  };  extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { -    3, 4, 5, 6, 7, 8, 9, 10, 11, 33  // NB 33 is LED +    3, 4, 5, 6, 7, 8, 9, 10, 11, 33  // NB: 33 is BOARD_LED_PIN  };  #define USB_DP 23 diff --git a/wirish/boards/maple_mini.h b/wirish/boards/maple_mini.h index 8b7ae64..3df1da8 100644 --- a/wirish/boards/maple_mini.h +++ b/wirish/boards/maple_mini.h @@ -59,4 +59,10 @@  #define BOARD_NR_ADC_PINS         10  #define BOARD_NR_USED_PINS         4 +#define BOARD_JTMS_SWDIO_PIN      22 +#define BOARD_JTCK_SWCLK_PIN      21 +#define BOARD_JTDI_PIN            20 +#define BOARD_JTDO_PIN            19 +#define BOARD_NJTRST_PIN          18 +  #endif diff --git a/wirish/boards/maple_native.cpp b/wirish/boards/maple_native.cpp index adc9497..0b25bd4 100644 --- a/wirish/boards/maple_native.cpp +++ b/wirish/boards/maple_native.cpp @@ -72,7 +72,8 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {      {GPIOB, TIMER4, NULL,  9, 4, ADCx}, /* D26/PB9 */      /* Bottom header */ -    /* Note: D{49, 50, 51} are also TIMER2_CH{2, 3, 4}, respectively. */ +    /* Note: D{48, 49, 50, 51} are also TIMER2_CH{1, 2, 3, 4}, respectively. */ +    /* TODO remap timer 2 in boardInit(); make the appropriate changes here */      {GPIOD,   NULL, NULL,  2, 0, ADCx}, /* D27/PD2 */      {GPIOD,   NULL, NULL,  3, 0, ADCx}, /* D28/PD3 */ @@ -150,7 +151,15 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {      {GPIOG,   NULL, NULL,  4, 0, ADCx}, /* D97/PG4 */      {GPIOD,   NULL, NULL,  9, 0, ADCx}, /* D98/PD9 */      {GPIOG,   NULL, NULL,  5, 0, ADCx}, /* D99/PG5 */ -    {GPIOD,   NULL, NULL, 10, 0, ADCx}  /* D100/PD10 */ +    {GPIOD,   NULL, NULL, 10, 0, ADCx}, /* D100/PD10 */ + +    /* JTAG header */ + +    {GPIOA,   NULL, NULL, 13, 0, ADCx}, /* D101/PA13 */ +    {GPIOA,   NULL, NULL, 14, 0, ADCx}, /* D102/PA14 */ +    {GPIOA,   NULL, NULL, 15, 0, ADCx}, /* D103/PA15 */ +    {GPIOB,   NULL, NULL,  3, 0, ADCx}, /* D104/PB3  */ +    {GPIOB,   NULL, NULL,  4, 0, ADCx}  /* D105/PB4  */  };  extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = { @@ -164,7 +173,8 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {  /* FIXME! see comment by BOARD_NR_USED_PINS in maple_native.h */  extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { -    BOARD_LED_PIN, BOARD_BUTTON_PIN +    BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN, +    BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN  };  #endif diff --git a/wirish/boards/maple_native.h b/wirish/boards/maple_native.h index 10dafa6..13df153 100644 --- a/wirish/boards/maple_native.h +++ b/wirish/boards/maple_native.h @@ -58,12 +58,18 @@  #define BOARD_UART5_TX_PIN      21  #define BOARD_UART5_RX_PIN      29 -#define BOARD_NR_GPIO_PINS      101 +#define BOARD_NR_GPIO_PINS      106  #define BOARD_NR_PWM_PINS       18  #define BOARD_NR_ADC_PINS       21  /* FIXME! this isn't true at all; almost all of the triple header pins   * are used by the FSMC by default.  Fix this (and the corresponding   * boardUsedPins definition in maple_native.cpp) by QA time. */ -#define BOARD_NR_USED_PINS      2 +#define BOARD_NR_USED_PINS      7 + +#define BOARD_JTMS_SWDIO_PIN    101 +#define BOARD_JTCK_SWCLK_PIN    102 +#define BOARD_JTDI_PIN          103 +#define BOARD_JTDO_PIN          104 +#define BOARD_NJTRST_PIN        105  #endif diff --git a/wirish/wirish.h b/wirish/wirish.h index 4cc142d..d30ad20 100644 --- a/wirish/wirish.h +++ b/wirish/wirish.h @@ -39,6 +39,7 @@  #include "bits.h"  #include "pwm.h"  #include "ext_interrupts.h" +#include "wirish_debug.h"  #include "wirish_math.h"  #include "wirish_time.h"  #include "HardwareSPI.h" diff --git a/wirish/wirish_debug.h b/wirish/wirish_debug.h new file mode 100644 index 0000000..d4c0bab --- /dev/null +++ b/wirish/wirish_debug.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * The MIT License + * + * Copyright (c) 2011 LeafLabs, LLC. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + *****************************************************************************/ + +/** + * @file wirish_debug.h + * @brief High level debug port configuration + */ + +/** + * @brief Disable the JTAG and Serial Wire (SW) debug ports. + * + * You can call this function in order to use the JTAG and SW debug + * pins as ordinary GPIOs. + * + * @see enableDebugPorts() + */ +static inline void disableDebugPorts(void) { +    afio_cfg_debug_ports(AFIO_DEBUG_NONE); +} + +/** + * @brief Enable the JTAG and Serial Wire (SW) debug ports. + * + * After you call this function, the JTAG and SW debug pins will no + * longer be usable as GPIOs. + * + * @see disableDebugPorts() + */ +static inline void enableDebugPorts(void) { +    afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ); +} | 
