usb-rs485: enable rs485 mode.
Tested on the f1 with a LA only, but traces look good and as expected. future work to actually hook it up to a rs485 device.
This commit is contained in:
parent
4f75e629e7
commit
18df4064d3
2 changed files with 12 additions and 16 deletions
|
|
@ -99,24 +99,23 @@ void usart2_isr(void)
|
|||
if (usart_get_interrupt_source(USART2, USART_SR_TXE)) {
|
||||
if (ringb_depth(&tx_ring) == 0) {
|
||||
// turn off tx empty interrupts, nothing left to send
|
||||
usart_disable_tx_interrupt(USART2);
|
||||
cdcacm_arch_txirq(0, 0);
|
||||
ER_DPRINTF("OFF\n");
|
||||
// Turn on tx complete interrupts, for rs485 de
|
||||
// USART_CR1(USART2) |= ~USART_CR1_TCIE;
|
||||
USART_CR1(USART2) |= USART_CR1_TCIE;
|
||||
} else {
|
||||
int c = ringb_get(&tx_ring);
|
||||
usart_send(USART2, c);
|
||||
}
|
||||
}
|
||||
// usbser-irq-txc? rs485 is auto on some devices, but can be emulated anyway
|
||||
// if (usart_get_interrupt_source(USART2, USART_SR_TC)) {
|
||||
// ER_DPRINTF("TC");
|
||||
// // turn off the complete irqs, we're done now.
|
||||
// USART_SR(USART2) &= ~USART_SR_TC;
|
||||
// USART_CR1(USART2) &= ~USART_CR1_TCIE;
|
||||
// gpio_clear(LED_TX_PORT, LED_TX_PIN);
|
||||
// gpio_clear(RS485DE_PORT, RS485DE_PIN);
|
||||
// }
|
||||
if (usart_get_interrupt_source(USART2, USART_SR_TC)) {
|
||||
ER_DPRINTF("TC");
|
||||
// turn off the complete irqs, we're done now.
|
||||
USART_CR1(USART2) &= ~USART_CR1_TCIE;
|
||||
USART_SR(USART2) &= ~USART_SR_TC;
|
||||
cdcacm_arch_pin(0, CDCACM_PIN_RS485DE, 0);
|
||||
}
|
||||
gpio_really(GPIOA, GPIO5, 0);
|
||||
}
|
||||
|
||||
|
|
@ -185,10 +184,7 @@ int main(void)
|
|||
// IRQ timing
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO5);
|
||||
|
||||
|
||||
// gpio_mode_setup(RS485DE_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
|
||||
// RS485DE_PIN);
|
||||
gpio_set_mode(RS485DE_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, RS485DE_PIN);
|
||||
|
||||
usart_setup();
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ extern "C" {
|
|||
#define LED_RX_PIN GPIO13
|
||||
#define LED_TX_PORT GPIOC
|
||||
#define LED_TX_PIN GPIO13
|
||||
#define RS485DE_PORT GPIOB
|
||||
#define RS485DE_PIN GPIO9 // FIXME? (disconnected, just a pin))
|
||||
#define RS485DE_PORT GPIOA
|
||||
#define RS485DE_PIN GPIO8
|
||||
/* TODO: should really make a stm32f4discovery.h file... */
|
||||
#elif defined STM32F4
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue