diff --git a/lib/onewire_master.c b/lib/onewire_master.c index 51f444f..186cb72 100644 --- a/lib/onewire_master.c +++ b/lib/onewire_master.c @@ -15,7 +15,7 @@ /** library for 1-wire protocol as master * @file * @author King Kévin - * @date 2017-2018 + * @date 2017-2020 * @note peripherals used: timer @ref onewire_master_timer, GPIO @ref onewire_master_gpio * @note overdrive mode is not provided * @implements 1-Wire protocol description from Book of iButton Standards @@ -38,6 +38,13 @@ #include "interrupt.h" // runtime interrupt table #include "onewire_master.h" // own definitions +/** @defgroup onewire_master_gpio GPIO used for 1-wire signal + * @note external pull-up resistor on pin is required (< 5 kOhm) + * @{ + */ +#define ONEWIRE_MASTER_PIN PC9 /**< GPIO pin */ +/** @} */ + /** @defgroup onewire_master_timer timer used to measure 1-wire signal timing * @{ */ @@ -83,7 +90,7 @@ void TIM_ISR(ONEWIRE_MASTER_TIMER)(void) case ONEWIRE_STATE_MASTER_RESET: // reset pulse has been started timer_clear_flag(TIM(ONEWIRE_MASTER_TIMER), TIM_SR_CC4IF); // clear output compare flag timer_enable_irq(TIM(ONEWIRE_MASTER_TIMER), TIM_DIER_CC4IE); // enable compare interrupt for presence detection - gpio_set(GPIO(ONEWIRE_MASTER_PORT),GPIO(ONEWIRE_MASTER_PIN)); // set signal high again for slaves to respond + gpio_set(GPIO_PORT(ONEWIRE_MASTER_PIN),GPIO_PIN(ONEWIRE_MASTER_PIN)); // set signal high again for slaves to respond onewire_master_state = ONEWIRE_STATE_SLAVE_PRESENCE; // set new state break; case ONEWIRE_STATE_SLAVE_PRESENCE: // waiting for slave presence but none received @@ -93,8 +100,8 @@ void TIM_ISR(ONEWIRE_MASTER_TIMER)(void) break; case ONEWIRE_STATE_MASTER_READ: // end of time slot and recovery time for reading bit case ONEWIRE_STATE_MASTER_WRITE: // end of time slot and recovery time for writing bit - if (buffer_bit - * @date 2017-2018 + * @date 2017-2020 * @note peripherals used: timer @ref onewire_master_timer, GPIO @ref onewire_master_gpio * @note overdrive mode is not provided */ #pragma once -/** @defgroup onewire_master_gpio GPIO used for 1-wire signal - * @note external pull-up resistor on pin is required (< 5 kOhm) - * @{ - */ -#define ONEWIRE_MASTER_PORT C /**< GPIO port */ -#define ONEWIRE_MASTER_PIN 9 /**< GPIO pin */ -/** @} */ - /** setup 1-wire peripheral */ void onewire_master_setup(void);