2016-08-16 11:56:10 +02:00
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*
*/
2016-09-04 14:48:40 +02:00
/** library to control multiple software UARTs (code)
* @ file uart_soft . c
2016-08-16 11:56:10 +02:00
* @ author King Kévin < kingkevin @ cuvoodoo . info >
* @ date 2016
2016-09-04 14:48:40 +02:00
* @ note peripherals used : GPIO @ ref uart_soft_gpio , timer @ ref uart_soft_timer
2016-08-16 11:56:10 +02:00
*/
/* standard libraries */
# include <stdint.h> // standard integer types
# include <stdlib.h> // general utilities
/* STM32 (including CM3) libraries */
# include <libopencm3/stm32/rcc.h> // real-time control clock library
# include <libopencm3/stm32/gpio.h> // general purpose input output library
# include <libopencm3/stm32/timer.h> // timer library
# include <libopencm3/cm3/nvic.h> // interrupt handler
2016-09-04 14:48:40 +02:00
# include <libopencm3/stm32/exti.h> // external interrupt defines
2016-08-16 11:56:10 +02:00
2016-09-04 14:48:40 +02:00
# include "uart_soft.h" // software UART library API
2016-08-16 11:56:10 +02:00
# include "global.h" // common methods
2016-09-04 14:48:40 +02:00
/** @defgroup uart_soft_gpio GPIO used for the software UART ports
2016-08-19 21:59:22 +02:00
* @ note up to 4 pins supported , comment if unused
2016-09-04 14:48:40 +02:00
* @ warning only one port must be used per line ( pin number )
2016-08-16 11:56:10 +02:00
* @ {
*/
2016-09-04 14:48:40 +02:00
# define UART_SOFT_RX_PORT0 B
# define UART_SOFT_RX_PIN0 9
//#define UART_SOFT_RX_PORT1 A
//#define UART_SOFT_RX_PIN1 0
//#define UART_SOFT_RX_PORT2 A
//#define UART_SOFT_RX_PIN2 0
//#define UART_SOFT_RX_PORT3 A
//#define UART_SOFT_RX_PIN3 0
//#define UART_SOFT_TX_PORT0 A
//#define UART_SOFT_TX_PIN0 0
//#define UART_SOFT_TX_PORT1 A
//#define UART_SOFT_TX_PIN1 0
//#define UART_SOFT_TX_PORT2 A
//#define UART_SOFT_TX_PIN2 0
//#define UART_SOFT_TX_PORT3 A
//#define UART_SOFT_TX_PIN3 0
2016-08-16 11:56:10 +02:00
/** @} */
2016-09-04 14:48:40 +02:00
/** @defgroup uart_soft_config UART configurations (2400-115200 bps)
2016-08-18 10:45:36 +02:00
* @ note this implementation is designed for 8 bits , no parity , any stop configuration since this is the most common case
2016-08-16 11:56:10 +02:00
* @ {
*/
2016-09-04 14:48:40 +02:00
# define UART_SOFT_RX_BAUDRATE0 9600
//#define UART_SOFT_RX_BAUDRATE1 0
//#define UART_SOFT_RX_BAUDRATE2 0
//#define UART_SOFT_RX_BAUDRATE3 0
//#define UART_SOFT_TX_BAUDRATE0 0
//#define UART_SOFT_TX_BAUDRATE1 0
//#define UART_SOFT_TX_BAUDRATE2 0
//#define UART_SOFT_TX_BAUDRATE3 0
2016-08-16 11:56:10 +02:00
/** @} */
2016-09-04 14:48:40 +02:00
/** @defgroup uart_soft_timer timer used to same UART signals
2016-08-16 11:56:10 +02:00
* @ {
*/
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0)) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1)) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2)) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN0))
# define UART_SOFT_RX_TIMER 3 /**< timer peripheral for receive signals */
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_TX_PORT0) && defined(UART_SOFT_TX_PIN0)) || (defined(UART_SOFT_TX_PORT1) && defined(UART_SOFT_TX_PIN1)) || (defined(UART_SOFT_TX_PORT2) && defined(UART_SOFT_TX_PIN2)) || (defined(UART_SOFT_TX_PORT3) && defined(UART_SOFT_TX_PIN0))
# define UART_SOFT_TX_TIMER 4 /**< timer peripheral for transmit signals */
2016-08-19 21:59:22 +02:00
# endif
/** @} */
2016-09-04 14:48:40 +02:00
/** @defgroup uart_soft_state
2016-08-19 21:59:22 +02:00
* @ {
*/
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0))
volatile uint16_t rx0_state = 0 ; /**< state of the GPIO */
2016-08-19 21:59:22 +02:00
volatile uint8_t rx0_bit = 0 ; /**< next bit to receive */
2016-09-04 14:48:40 +02:00
volatile uint8_t rx0_byte = 0 ; /**< byte received */
2016-08-19 21:59:22 +02:00
# endif
2016-08-16 11:56:10 +02:00
/** @} */
2016-09-04 14:48:40 +02:00
bool uart_soft_setup ( void )
2016-08-16 11:56:10 +02:00
{
2016-08-18 10:45:36 +02:00
// verify configuration
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_BAUDRATE0) && ((UART_SOFT_RX_BAUDRATE0<2400) || (UART_SOFT_RX_BAUDRATE0>115200)))
2016-08-19 21:59:22 +02:00
return false ;
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_BAUDRATE1) && ((UART_SOFT_RX_BAUDRATE1<2400) || (UART_SOFT_RX_BAUDRATE1>115200)))
2016-08-19 21:59:22 +02:00
return false ;
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_BAUDRATE2) && ((UART_SOFT_RX_BAUDRATE2<2400) || (UART_SOFT_RX_BAUDRATE2>115200)))
2016-08-19 21:59:22 +02:00
return false ;
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_BAUDRATE3) && ((UART_SOFT_RX_BAUDRATE3<2400) || (UART_SOFT_RX_BAUDRATE3>115200)))
2016-08-19 21:59:22 +02:00
return false ;
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_TX_BAUDRATE0) && ((UART_SOFT_TX_BAUDRATE0<2400) || (UART_SOFT_TX_BAUDRATE0>115200)))
2016-08-19 21:59:22 +02:00
return false ;
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_TX_BAUDRATE1) && ((UART_SOFT_TX_BAUDRATE1<2400) || (UART_SOFT_TX_BAUDRATE1>115200)))
2016-08-18 10:45:36 +02:00
return false ;
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_TX_BAUDRATE2) && ((UART_SOFT_TX_BAUDRATE2<2400) || (UART_SOFT_TX_BAUDRATE2>115200)))
2016-08-18 10:45:36 +02:00
return false ;
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_TX_BAUDRATE3) && ((UART_SOFT_TX_BAUDRATE3<2400) || (UART_SOFT_TX_BAUDRATE3>115200)))
2016-08-19 21:59:22 +02:00
return false ;
# endif
2016-08-18 10:45:36 +02:00
2016-08-16 11:56:10 +02:00
// setup GPIOs
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_RX_PORT0 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_RX_PORT0 ) , GPIO_MODE_INPUT , GPIO_CNF_INPUT_PULL_UPDOWN , GPIO ( UART_SOFT_RX_PIN0 ) ) ; // setup GPIO pin UART receive
gpio_set ( GPIO ( UART_SOFT_RX_PORT0 ) , GPIO ( UART_SOFT_RX_PIN0 ) ) ; // pull up to avoid noise when not connected
rcc_periph_clock_enable ( RCC_AFIO ) ; // enable alternate function clock for external interrupt
exti_select_source ( EXTI ( UART_SOFT_RX_PIN0 ) , GPIO ( UART_SOFT_RX_PORT0 ) ) ; // mask external interrupt of this pin only for this port
exti_enable_request ( EXTI ( UART_SOFT_RX_PIN0 ) ) ; // enable external interrupt
exti_set_trigger ( EXTI ( UART_SOFT_RX_PIN0 ) , EXTI_TRIGGER_BOTH ) ; // trigger when button is pressed
nvic_enable_irq ( NVIC_EXTI_IRQ ( UART_SOFT_RX_PIN0 ) ) ; // enable interrupt
rx0_state = gpio_get ( GPIO ( UART_SOFT_RX_PORT0 ) , GPIO ( UART_SOFT_RX_PIN0 ) ) ; // save state of GPIO
2016-08-19 21:59:22 +02:00
rx0_bit = 0 ; // reset bits received
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_RX_PORT1 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_RX_PORT1 ) , GPIO_MODE_INPUT , GPIO_CNF_INPUT_PULL_UPDOWN , GPIO ( UART_SOFT_RX_PIN1 ) ) ; // setup GPIO pin UART receive
gpio_set ( GPIO ( UART_SOFT_RX_PORT1 ) , GPIO ( UART_SOFT_RX_PIN1 ) ) ; // pull up to avoid noise when not connected
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_RX_PORT2 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_RX_PORT2 ) , GPIO_MODE_INPUT , GPIO_CNF_INPUT_PULL_UPDOWN , GPIO ( UART_SOFT_RX_PIN2 ) ) ; // setup GPIO pin UART receive
gpio_set ( GPIO ( UART_SOFT_RX_PORT2 ) , GPIO ( UART_SOFT_RX_PIN2 ) ) ; // pull up to avoid noise when not connected
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_RX_PORT3 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_RX_PORT3 ) , GPIO_MODE_INPUT , GPIO_CNF_INPUT_PULL_UPDOWN , GPIO ( UART_SOFT_RX_PIN3 ) ) ; // setup GPIO pin UART receive
gpio_set ( GPIO ( UART_SOFT_RX_PORT3 ) , GPIO ( UART_SOFT_RX_PIN3 ) ) ; // pull up to avoid noise when not connected
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_TX_PORT0) && defined(UART_SOFT_TX_PIN0)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_TX_PORT0 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_TX_PORT0 ) , GPIO_MODE_OUTPUT_2_MHZ , GPIO_CNF_OUTPUT_PUSHPULL , GPIO ( UART_SOFT_TX_PIN0 ) ) ;
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_TX_PORT1) && defined(UART_SOFT_TX_PIN1)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_TX_PORT1 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_TX_PORT1 ) , GPIO_MODE_OUTPUT_2_MHZ , GPIO_CNF_OUTPUT_PUSHPULL , GPIO ( UART_SOFT_TX_PIN1 ) ) ;
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_TX_PORT2) && defined(UART_SOFT_TX_PIN2)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_TX_PORT2 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_TX_PORT2 ) , GPIO_MODE_OUTPUT_2_MHZ , GPIO_CNF_OUTPUT_PUSHPULL , GPIO ( UART_SOFT_TX_PIN2 ) ) ;
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_TX_PORT3) && defined(UART_SOFT_TX_PIN3)
rcc_periph_clock_enable ( RCC_GPIO ( UART_SOFT_TX_PORT3 ) ) ; // enable clock for GPIO peripheral
gpio_set_mode ( GPIO ( UART_SOFT_TX_PORT3 ) , GPIO_MODE_OUTPUT_2_MHZ , GPIO_CNF_OUTPUT_PUSHPULL , GPIO ( UART_SOFT_TX_PIN3 ) ) ;
2016-08-19 21:59:22 +02:00
# endif
2016-08-18 10:45:36 +02:00
// setup timer
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_RX_TIMER)
rcc_periph_clock_enable ( RCC_TIM ( UART_SOFT_RX_TIMER ) ) ; // enable clock for timer peripheral
timer_reset ( TIM ( UART_SOFT_RX_TIMER ) ) ; // reset timer state
timer_set_mode ( TIM ( UART_SOFT_RX_TIMER ) , TIM_CR1_CKD_CK_INT , TIM_CR1_CMS_EDGE , TIM_CR1_DIR_UP ) ; // set timer mode, use undivided timer clock, edge alignment (simple count), and count up
timer_set_prescaler ( TIM ( UART_SOFT_RX_TIMER ) , 0 ) ; // prescaler to be able to sample 2400-115200 bps (72MHz/2^16=1099<2400bps)
nvic_enable_irq ( NVIC_TIM_IRQ ( UART_SOFT_RX_TIMER ) ) ; // allow interrupt for timer
timer_enable_counter ( TIM ( UART_SOFT_RX_TIMER ) ) ; // start timer to generate interrupts for the RX pins
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_TX_TIMER)
rcc_periph_clock_enable ( RCC_TIM ( UART_SOFT_TX_TIMER ) ) ; // enable clock for timer peripheral
timer_reset ( TIM ( UART_SOFT_TX_TIMER ) ) ; // reset timer state
timer_set_mode ( TIM ( UART_SOFT_TX_TIMER ) , TIM_CR1_CKD_CK_INT , TIM_CR1_CMS_EDGE , TIM_CR1_DIR_UP ) ; // set timer mode, use undivided timer clock, edge alignment (simple count), and count up
timer_set_prescaler ( TIM ( UART_SOFT_TX_TIMER ) , 0 ) ; // prescaler to be able to sample 2400-115200 bps (72MHz/2^16=1099<2400bps)
nvic_enable_irq ( NVIC_TIM_IRQ ( UART_SOFT_TX_TIMER ) ) ; // allow interrupt for timer
2016-08-19 21:59:22 +02:00
# endif
2016-08-18 10:45:36 +02:00
return true ; // setup completed
}
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_RX_TIMER)
void TIM_ISR ( UART_SOFT_RX_TIMER ) ( void )
2016-08-18 10:45:36 +02:00
{
2016-09-04 14:48:40 +02:00
if ( timer_interrupt_source ( TIM ( UART_SOFT_RX_TIMER ) , TIM_SR_CC1IF ) ) { // got a match on compare 1 for RX0
timer_clear_flag ( TIM ( UART_SOFT_RX_TIMER ) , TIM_SR_CC1IF ) ; // clear flag
# if defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0)
led_toggle ( ) ;
rx0_byte + = ( ( gpio_get ( GPIO ( UART_SOFT_RX_PORT0 ) , GPIO ( UART_SOFT_RX_PIN0 ) ) = = 0 ? 0 : 1 ) < < ( rx0_bit - 1 ) ) ; // save bit value
if ( rx0_bit < 8 ) { // not the last bit received
timer_set_oc_value ( TIM ( UART_SOFT_RX_TIMER ) , TIM_OC1 , timer_get_counter ( TIM ( UART_SOFT_RX_TIMER ) ) + rcc_ahb_frequency / UART_SOFT_RX_BAUDRATE0 ) ; // set timer to next bit
rx0_bit + + ; // wait for next bit
} else { // last bit received
// save byte
timer_disable_irq ( TIM ( UART_SOFT_RX_TIMER ) , TIM_DIER_CC1IE ) ; // stop_interrupting
rx0_bit = 0 ; // next bit should be first bit of next byte
}
# endif
}
2016-08-16 11:56:10 +02:00
}
2016-08-19 21:59:22 +02:00
# endif
2016-09-04 14:48:40 +02:00
# if defined(UART_SOFT_TX_TIMER)
void TIM_ISR ( UART_SOFT_TX_TIMER ) ( void )
2016-08-19 21:59:22 +02:00
{
}
# endif
/** central function handling receive signal activity */
static void rx_activity ( void )
{
2016-09-04 14:48:40 +02:00
// verify if UART pin state changed
# if defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0)
if ( rx0_state ! = gpio_get ( GPIO ( UART_SOFT_RX_PORT0 ) , GPIO ( UART_SOFT_RX_PIN0 ) ) ) { // only do something if state changed
rx0_state = gpio_get ( GPIO ( UART_SOFT_RX_PORT0 ) , GPIO ( UART_SOFT_RX_PIN0 ) ) ; // save new state
if ( rx0_bit = = 0 ) { // start bit edge detected
if ( rx0_state = = 0 ) { // start bit has to be low
timer_set_oc_value ( TIM ( UART_SOFT_RX_TIMER ) , TIM_OC1 , timer_get_counter ( TIM ( UART_SOFT_RX_TIMER ) ) + ( rcc_ahb_frequency / UART_SOFT_RX_BAUDRATE0 ) * 1.5 ) ; // set timer to sample data bit 0 in 1.5 bits
timer_clear_flag ( TIM ( UART_SOFT_RX_TIMER ) , TIM_SR_CC1IF ) ; // clear flag before enabling interrupt
timer_enable_irq ( TIM ( UART_SOFT_RX_TIMER ) , TIM_DIER_CC1IE ) ; // enable timer IRQ for RX0
rx0_byte = 0 ; // reset byte value
rx0_bit + + ; // wait for first bit
}
} else { // data bit detected
timer_set_oc_value ( TIM ( UART_SOFT_RX_TIMER ) , TIM_OC1 , timer_get_counter ( TIM ( UART_SOFT_RX_TIMER ) ) + ( rcc_ahb_frequency / UART_SOFT_RX_BAUDRATE0 ) / 2 ) ; // resync timer to half a bit (good for drifting transmission, bad if the line is noisy)
}
}
# endif
2016-08-19 21:59:22 +02:00
}
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && UART_SOFT_RX_PIN0==0) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && UART_SOFT_RX_PIN1==0) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && UART_SOFT_RX_PIN2==0) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && UART_SOFT_RX_PIN3==0)
2016-08-19 21:59:22 +02:00
void exti0_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI0 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && UART_SOFT_RX_PIN0==1) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && UART_SOFT_RX_PIN1==1) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && UART_SOFT_RX_PIN2==1) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && UART_SOFT_RX_PIN3==1)
2016-08-19 21:59:22 +02:00
void exti1_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI1 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && UART_SOFT_RX_PIN0==2) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && UART_SOFT_RX_PIN1==2) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && UART_SOFT_RX_PIN2==2) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && UART_SOFT_RX_PIN3==2)
2016-08-19 21:59:22 +02:00
void exti2_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI2 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && UART_SOFT_RX_PIN0==3) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && UART_SOFT_RX_PIN1==3) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && UART_SOFT_RX_PIN2==3) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && UART_SOFT_RX_PIN3==3)
2016-08-19 21:59:22 +02:00
void exti3_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI3 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && UART_SOFT_RX_PIN0==4) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && UART_SOFT_RX_PIN1==4) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && UART_SOFT_RX_PIN2==4) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && UART_SOFT_RX_PIN3==4)
2016-08-19 21:59:22 +02:00
void exti4_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI4 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && (UART_SOFT_RX_PIN0==5 || UART_SOFT_RX_PIN0==6 || UART_SOFT_RX_PIN0==7 || UART_SOFT_RX_PIN0==8 || UART_SOFT_RX_PIN0==9)) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && (UART_SOFT_RX_PIN1==5 || UART_SOFT_RX_PIN1==6 || UART_SOFT_RX_PIN1==7 || UART_SOFT_RX_PIN1==8 || UART_SOFT_RX_PIN1==9)) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && (UART_SOFT_RX_PIN2==5 || UART_SOFT_RX_PIN2==6 || UART_SOFT_RX_PIN2==7 || UART_SOFT_RX_PIN2==8 || UART_SOFT_RX_PIN2==9)) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && (UART_SOFT_RX_PIN3==5 || UART_SOFT_RX_PIN3==6 || UART_SOFT_RX_PIN3==7 || UART_SOFT_RX_PIN3==8 || UART_SOFT_RX_PIN3==9))
2016-08-19 21:59:22 +02:00
void exti9_5_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI5 | EXTI6 | EXTI7 | EXTI8 | EXTI9 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif
2016-09-04 14:48:40 +02:00
# if (defined(UART_SOFT_RX_PORT0) && defined(UART_SOFT_RX_PIN0) && (UART_SOFT_RX_PIN0==10 || UART_SOFT_RX_PIN0==11 || UART_SOFT_RX_PIN0==12 || UART_SOFT_RX_PIN0==13 || UART_SOFT_RX_PIN0==14 || UART_SOFT_RX_PIN0==15)) || (defined(UART_SOFT_RX_PORT1) && defined(UART_SOFT_RX_PIN1) && (UART_SOFT_RX_PIN1==10 || UART_SOFT_RX_PIN1==11 || UART_SOFT_RX_PIN1==12 || UART_SOFT_RX_PIN1==13 || UART_SOFT_RX_PIN1==14 || UART_SOFT_RX_PIN1==15)) || (defined(UART_SOFT_RX_PORT2) && defined(UART_SOFT_RX_PIN2) && (UART_SOFT_RX_PIN2==10 || UART_SOFT_RX_PIN2==11 || UART_SOFT_RX_PIN2==12 || UART_SOFT_RX_PIN2==13 || UART_SOFT_RX_PIN2==14 || UART_SOFT_RX_PIN2==15)) || (defined(UART_SOFT_RX_PORT3) && defined(UART_SOFT_RX_PIN3) && (UART_SOFT_RX_PIN3==10 || UART_SOFT_RX_PIN3==11 || UART_SOFT_RX_PIN3==12 || UART_SOFT_RX_PIN3==13 || UART_SOFT_RX_PIN3==14 || UART_SOFT_RX_PIN3==15))
2016-08-19 21:59:22 +02:00
void exti15_10_isr ( void )
{
2016-09-04 14:48:40 +02:00
exti_reset_request ( EXTI10 | EXTI11 | EXTI12 | EXTI13 | EXTI14 | EXTI15 ) ; // clear interrupt flag for pin triggers this ISR (pin state will be checked independently)
rx_activity ( ) ; // check which GPIO changed
2016-08-19 21:59:22 +02:00
}
# endif