make square wave isr optional
This commit is contained in:
parent
666dc51a21
commit
2d60475b81
|
@ -46,7 +46,7 @@
|
|||
/** @} */
|
||||
#define I2C_ADDR 0x68 /**< DS1307 I2C address (fixed to 0b1101000) */
|
||||
|
||||
#if defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_EXTI)
|
||||
#if defined(SQUARE_WAVE_EXTI) && defined(SQUARE_WAVE_IRQ) && defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_HANDLING) && SQUARE_WAVE_HANDLING
|
||||
volatile bool square_wave_flag = false;
|
||||
#endif
|
||||
|
||||
|
@ -67,16 +67,18 @@ void rtc_setup(void)
|
|||
i2c_peripheral_enable(I2C); // enable I2C after configuration completed
|
||||
|
||||
/* setup square wave interrupt input */
|
||||
#if defined(SQUARE_WAVE_RCC) && defined(SQUARE_WAVE_PORT) && defined(SQUARE_WAVE_PIN) && defined(SQUARE_WAVE_EXTI) && defined(SQUARE_WAVE_IRQ)
|
||||
#if defined(SQUARE_WAVE_RCC) && defined(SQUARE_WAVE_PORT) && defined(SQUARE_WAVE_PIN)
|
||||
rcc_periph_clock_enable(SQUARE_WAVE_RCC); // enable GPIO peripheral
|
||||
gpio_set_mode(SQUARE_WAVE_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, SQUARE_WAVE_PIN); // set pin to input with pull up
|
||||
gpio_set(SQUARE_WAVE_PORT, SQUARE_WAVE_PIN); // pull up since the square wave output is open drain
|
||||
#if defined(SQUARE_WAVE_EXTI) && defined(SQUARE_WAVE_IRQ) && defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_HANDLING) && SQUARE_WAVE_HANDLING
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable alternate function clock for external interrupt
|
||||
exti_select_source(SQUARE_WAVE_EXTI, SQUARE_WAVE_PORT); // mask external interrupt of this pin only for this port
|
||||
exti_set_trigger(SQUARE_WAVE_EXTI, EXTI_TRIGGER_FALLING); // trigger on falling
|
||||
exti_enable_request(SQUARE_WAVE_EXTI); // enable external interrupt
|
||||
nvic_enable_irq(SQUARE_WAVE_IRQ); // enable interrupt
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -444,7 +446,7 @@ bool rtc_write_time(uint8_t seconds, uint8_t minutes, uint8_t hours, uint8_t day
|
|||
return rtc_write_memory(0, data, LENGTH(data)); // write time values on RTC
|
||||
}
|
||||
|
||||
#if defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_EXTI)
|
||||
#if defined(SQUARE_WAVE_EXTI) && defined(SQUARE_WAVE_IRQ) && defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_HANDLING) && SQUARE_WAVE_HANDLING
|
||||
/** @brief square wave input interrupt */
|
||||
void SQUARE_WAVE_ISR(void)
|
||||
{
|
||||
|
|
|
@ -30,9 +30,10 @@
|
|||
#define SQUARE_WAVE_EXTI EXTI10 /**< GPIO external interrupt (exti 10 for pin 12) */
|
||||
#define SQUARE_WAVE_IRQ NVIC_EXTI15_10_IRQ /**< GPIO line interrupt (interrupt for line 15 to 10 for pin 10) */
|
||||
#define SQUARE_WAVE_ISR exti15_10_isr /**< GPIO line interrupt service routine (isr for line 15 to 10 for pin 10) */
|
||||
#define SQUARE_WAVE_HANDLING true /**< to to have the library handle the square wave interrupt (setting square_wave_flag) */
|
||||
/** @} */
|
||||
|
||||
#if defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_EXTI)
|
||||
#if defined(SQUARE_WAVE_EXTI) && defined(SQUARE_WAVE_IRQ) && defined(SQUARE_WAVE_ISR) && defined(SQUARE_WAVE_HANDLING) && SQUARE_WAVE_HANDLING
|
||||
extern volatile bool square_wave_flag; /**< set on square wave output */
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue