diff --git a/os/hal/include/onewire.h b/os/hal/include/onewire.h index 290a9b30..b2c64629 100644 --- a/os/hal/include/onewire.h +++ b/os/hal/include/onewire.h @@ -67,7 +67,7 @@ /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ - +#if ONEWIRE_USE_STRONG_PULLUP /** * @brief 1-wire strong pull up assert callback type. */ @@ -77,6 +77,7 @@ typedef void (*onewire_pullup_assert_t)(void); * @brief 1-wire strong pull up release callback type. */ typedef void (*onewire_pullup_release_t)(void); +#endif /* ONEWIRE_USE_STRONG_PULLUP */ /** * @brief 1-wire read bit callback type. @@ -97,6 +98,7 @@ typedef enum { #endif } onewire_state_t; +#if ONEWIRE_USE_SEARCH_ROM /** * @brief Search ROM procedure possible state. */ @@ -113,6 +115,7 @@ typedef enum { ONEWIRE_SEARCH_ROM_FIRST = 0, /**< First search run. */ ONEWIRE_SEARCH_ROM_NEXT = 1 /**< Next search run. */ } search_iteration_t; +#endif /* ONEWIRE_USE_SEARCH_ROM */ /** * @brief Driver configuration structure. @@ -147,6 +150,7 @@ typedef struct { #endif } onewireConfig; +#if ONEWIRE_USE_SEARCH_ROM /** * @brief Search ROM registry. Contains small variables used * in 'search ROM' procedure. @@ -212,6 +216,7 @@ typedef struct { */ int8_t prev_zero_branch; } onewire_search_rom_t; +#endif /* ONEWIRE_USE_SEARCH_ROM */ /** * @brief Onewire registry. Some small variables combined @@ -268,10 +273,12 @@ typedef struct { * @brief Pointer to I/O data buffer. */ uint8_t *buf; +#if ONEWIRE_USE_SEARCH_ROM /** * @brief Search ROM helper structure. */ onewire_search_rom_t search_rom; +#endif /* ONEWIRE_USE_SEARCH_ROM */ /** * @brief Thread waiting for I/O completion. */ @@ -297,14 +304,16 @@ extern "C" { void onewireStop(onewireDriver *owp); bool onewireReset(onewireDriver *owp); void onewireRead(onewireDriver *owp, uint8_t *rxbuf, size_t rxbytes); + uint8_t onewireCRC(const uint8_t *buf, size_t len); void onewireWrite(onewireDriver *owp, uint8_t *txbuf, size_t txbytes, systime_t pullup_time); +#if ONEWIRE_USE_SEARCH_ROM size_t onewireSearchRom(onewireDriver *owp, uint8_t *result, size_t max_rom_cnt); - uint8_t onewireCRC(const uint8_t *buf, size_t len); +#endif /* ONEWIRE_USE_SEARCH_ROM */ #if ONEWIRE_SYNTH_SEARCH_TEST void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit); uint_fast8_t _synth_ow_read_bit(void); diff --git a/os/hal/src/onewire.c b/os/hal/src/onewire.c index 825bb635..df86e26e 100644 --- a/os/hal/src/onewire.c +++ b/os/hal/src/onewire.c @@ -84,8 +84,10 @@ static void ow_read_bit_cb(PWMDriver *pwmp, onewireDriver *owp); static void pwm_read_bit_cb(PWMDriver *pwmp); static void ow_write_bit_cb(PWMDriver *pwmp, onewireDriver *owp); static void pwm_write_bit_cb(PWMDriver *pwmp); +#if ONEWIRE_USE_SEARCH_ROM static void ow_search_rom_cb(PWMDriver *pwmp, onewireDriver *owp); static void pwm_search_rom_cb(PWMDriver *pwmp); +#endif /*===========================================================================*/ /* Driver exported variables. */ @@ -182,12 +184,14 @@ static void pwm_write_bit_cb(PWMDriver *pwmp) { ow_write_bit_cb(pwmp, &OWD1); } +#if ONEWIRE_USE_SEARCH_ROM /** * @brief PWM adapter */ static void pwm_search_rom_cb(PWMDriver *pwmp) { ow_search_rom_cb(pwmp, &OWD1); } +#endif /* ONEWIRE_USE_SEARCH_ROM */ /** * @brief Write bit routine. @@ -319,6 +323,7 @@ static void ow_write_bit_cb(PWMDriver *pwmp, onewireDriver *owp) { owp->reg.bit++; } +#if ONEWIRE_USE_SEARCH_ROM /** * @brief Helper function for collision handler * @@ -514,6 +519,7 @@ static void search_clean_iteration(onewire_search_rom_t *sr) { sr->reg.bit_buf = 0; sr->reg.result = ONEWIRE_SEARCH_ROM_LAST; } +#endif /* ONEWIRE_USE_SEARCH_ROM */ /*===========================================================================*/ /* Driver exported functions. */ @@ -755,6 +761,7 @@ void onewireWrite(onewireDriver *owp, uint8_t *txbuf, #endif } +#if ONEWIRE_USE_SEARCH_ROM /** * @brief Performs tree search on bus. * @note This function does internal 1-wire reset calls every search @@ -833,6 +840,7 @@ size_t onewireSearchRom(onewireDriver *owp, uint8_t *result, else return owp->search_rom.reg.devices_found; } +#endif /* ONEWIRE_USE_SEARCH_ROM */ /* * Include test code (if enabled). diff --git a/testhal/STM32/STM32F4xx/onewire/halconf_community.h b/testhal/STM32/STM32F4xx/onewire/halconf_community.h index e5ac5e9f..7f64b2b2 100644 --- a/testhal/STM32/STM32F4xx/onewire/halconf_community.h +++ b/testhal/STM32/STM32F4xx/onewire/halconf_community.h @@ -61,13 +61,18 @@ /*===========================================================================*/ /* 1-wire driver related settings. */ /*===========================================================================*/ - /** - * @brief Enables strong pull up support. + * @brief Enables strong pull up feature. * @note Disabling this option saves both code and data space. */ #define ONEWIRE_USE_STRONG_PULLUP FALSE +/** + * @brief Enables search ROM feature. + * @note Disabling this option saves both code and data space. + */ +#define ONEWIRE_USE_SEARCH_ROM TRUE + #endif /* _HALCONF_COMMUNITY_H_ */ /** @} */