Skip to content

Commit

Permalink
Disable pins to allow pwm output on pwm pins. USB_DM pin not yet work…
Browse files Browse the repository at this point in the history
…ing..
  • Loading branch information
jonatanolofsson committed Oct 15, 2014
1 parent 3022380 commit 5dbc2ae
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
42 changes: 36 additions & 6 deletions wirish/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,15 @@ void HardwareSerial::irq_dma_tx(void) {
}
}

#if BOARD_HAVE_USART1
void irq_usart_dma_tx_1(void) {Serial1.irq_dma_tx();}
#endif
#if BOARD_HAVE_USART2
void irq_usart_dma_tx_2(void) {Serial2.irq_dma_tx();}
#endif
#if BOARD_HAVE_USART3
void irq_usart_dma_tx_3(void) {Serial3.irq_dma_tx();}
#endif

void HardwareSerial::irq_dma_rx(void) {
dma_irq_cause cause = dma_get_irq_cause(this->usart_device->dma_device, this->usart_device->dma_rx_tube);
Expand All @@ -217,22 +223,37 @@ void HardwareSerial::irq_dma_rx(void) {
dmaRx = NULL;
}

#if BOARD_HAVE_USART1
void irq_usart_dma_rx_1(void) {Serial1.irq_dma_rx();}
#endif
#if BOARD_HAVE_USART2
void irq_usart_dma_rx_2(void) {Serial2.irq_dma_rx();}
#endif
#if BOARD_HAVE_USART3
void irq_usart_dma_rx_3(void) {Serial3.irq_dma_rx();}
#endif

void HardwareSerial::setup_dma_tx(void) {
void(*irq)(void);
#if BOARD_HAVE_USART3
if(this->tx_pin == Serial3.tx_pin) {
irq = irq_usart_dma_tx_3;
dmaTxConf.tube_req_src = DMA_REQ_SRC_USART3_TX;
} else if(this->tx_pin == Serial2.tx_pin) {
} else
#endif
#if BOARD_HAVE_USART2
if(this->tx_pin == Serial2.tx_pin) {
irq = irq_usart_dma_tx_2;
dmaTxConf.tube_req_src = DMA_REQ_SRC_USART2_TX;
} else if(this->tx_pin == Serial1.tx_pin) {
} else
#endif
#if BOARD_HAVE_USART1
if(this->tx_pin == Serial1.tx_pin) {
irq = irq_usart_dma_tx_1;
dmaTxConf.tube_req_src = DMA_REQ_SRC_USART1_TX;
} else return;
} else
#endif
return;

dma_attach_interrupt(this->usart_device->dma_device, this->usart_device->dma_tx_tube, irq);

Expand All @@ -251,16 +272,25 @@ void HardwareSerial::setup_dma_tx(void) {
}
void HardwareSerial::setup_dma_rx(void) {
void(*irq)(void);
#if BOARD_HAVE_USART3
if(this->rx_pin == Serial3.rx_pin) {
irq = irq_usart_dma_rx_3;
dmaRxConf.tube_req_src = DMA_REQ_SRC_USART3_RX;
} else if(this->rx_pin == Serial2.rx_pin) {
} else
#endif
#if BOARD_HAVE_USART2
if(this->rx_pin == Serial2.rx_pin) {
irq = irq_usart_dma_rx_2;
dmaRxConf.tube_req_src = DMA_REQ_SRC_USART2_RX;
} else if(this->rx_pin == Serial1.rx_pin) {
} else
#endif
#if BOARD_HAVE_USART1
if(this->rx_pin == Serial1.rx_pin) {
irq = irq_usart_dma_rx_1;
dmaRxConf.tube_req_src = DMA_REQ_SRC_USART1_RX;
} else return;
} else
#endif
return;

dma_attach_interrupt(this->usart_device->dma_device, this->usart_device->dma_rx_tube, irq);

Expand Down
4 changes: 2 additions & 2 deletions wirish/boards/maple_mini/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {
};

extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {
3, 4, 5, 8, 9, 10, 11, 15, 16, 25, 26, 27
3, 4, 5, 8, 9, 10, 11, 15, 16, 24, 25, 26, 27
};

extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
Expand All @@ -101,5 +101,5 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
#define USB_DM 24

extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
BOARD_LED_PIN, BOARD_BUTTON_PIN, USB_DP, USB_DM
BOARD_LED_PIN, BOARD_BUTTON_PIN//, USB_DP, USB_DM
};
8 changes: 4 additions & 4 deletions wirish/boards/maple_mini/include/board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@
#define BOARD_SPI2_SCK_PIN 30

#define BOARD_NR_GPIO_PINS 34
#define BOARD_NR_PWM_PINS 12
#define BOARD_NR_PWM_PINS 13
#define BOARD_NR_ADC_PINS 9
#define BOARD_NR_USED_PINS 4
#define BOARD_NR_USED_PINS 2

#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

#define BOARD_USB_DISC_DEV GPIOB
#define BOARD_USB_DISC_BIT 9
//#define BOARD_USB_DISC_DEV GPIOB
//#define BOARD_USB_DISC_BIT 9

enum {
PB11, PB10, PB2, PB0, PA7, PA6, PA5, PA4, PA3, PA2, PA1, PA0, PC15, PC14,
Expand Down
6 changes: 3 additions & 3 deletions wirish/include/wirish/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ bool boardUsesPin(uint8 pin);
#define BOARD_HAVE_USART(n) (defined(BOARD_USART##n##_TX_PIN) && \
defined(BOARD_USART##n##_RX_PIN))
/** Feature test: nonzero iff the board has USART1. */
#define BOARD_HAVE_USART1 BOARD_HAVE_USART(1)
#define BOARD_HAVE_USART1 (false && BOARD_HAVE_USART(1))
/** Feature test: nonzero iff the board has USART2, 0 otherwise. */
#define BOARD_HAVE_USART2 BOARD_HAVE_USART(2)
#define BOARD_HAVE_USART2 (false && BOARD_HAVE_USART(2))
/** Feature test: nonzero iff the board has USART3, 0 otherwise. */
#define BOARD_HAVE_USART3 BOARD_HAVE_USART(3)
/** Feature test: nonzero iff the board has UART4, 0 otherwise. */
Expand Down Expand Up @@ -167,7 +167,7 @@ bool boardUsesPin(uint8 pin);
/**
* @brief Feature test: nonzero iff the board has SerialUSB.
*/
#define BOARD_HAVE_SERIALUSB (defined(BOARD_USB_DISC_DEV) && \
#define BOARD_HAVE_SERIALUSB (false && defined(BOARD_USB_DISC_DEV) && \
defined(BOARD_USB_DISC_BIT))

#endif

0 comments on commit 5dbc2ae

Please sign in to comment.