diff options
author | barthess <barthess@yandex.ru> | 2014-12-27 22:15:39 +0300 |
---|---|---|
committer | barthess <barthess@yandex.ru> | 2014-12-27 22:18:30 +0300 |
commit | 0c93d4077931fc46c0f468e712cc7110a3d3456e (patch) | |
tree | 77341a4753d716391c089f6660d55b13bc10d72d /testhal/STM32/STM32F1xx | |
parent | 82b8855e83fe93bd4f7857169d519811d17a6534 (diff) | |
download | ChibiOS-Contrib-0c93d4077931fc46c0f468e712cc7110a3d3456e.tar.gz ChibiOS-Contrib-0c93d4077931fc46c0f468e712cc7110a3d3456e.tar.bz2 ChibiOS-Contrib-0c93d4077931fc46c0f468e712cc7110a3d3456e.zip |
[1-wire] Cosmetical cleanups
Diffstat (limited to 'testhal/STM32/STM32F1xx')
-rw-r--r-- | testhal/STM32/STM32F1xx/onewire/mcuconf.h | 6 | ||||
-rw-r--r-- | testhal/STM32/STM32F1xx/onewire/onewire_test.c | 79 | ||||
-rw-r--r-- | testhal/STM32/STM32F1xx/onewire/readme.txt | 32 |
3 files changed, 81 insertions, 36 deletions
diff --git a/testhal/STM32/STM32F1xx/onewire/mcuconf.h b/testhal/STM32/STM32F1xx/onewire/mcuconf.h index 503d284..807293a 100644 --- a/testhal/STM32/STM32F1xx/onewire/mcuconf.h +++ b/testhal/STM32/STM32F1xx/onewire/mcuconf.h @@ -115,7 +115,7 @@ #define STM32_ICU_USE_TIM1 FALSE
#define STM32_ICU_USE_TIM2 FALSE
#define STM32_ICU_USE_TIM3 FALSE
-#define STM32_ICU_USE_TIM4 TRUE
+#define STM32_ICU_USE_TIM4 FALSE
#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_USE_TIM8 FALSE
#define STM32_ICU_TIM1_IRQ_PRIORITY 7
@@ -131,8 +131,8 @@ #define STM32_PWM_USE_ADVANCED FALSE
#define STM32_PWM_USE_TIM1 FALSE
#define STM32_PWM_USE_TIM2 FALSE
-#define STM32_PWM_USE_TIM3 FALSE
-#define STM32_PWM_USE_TIM4 TRUE
+#define STM32_PWM_USE_TIM3 TRUE
+#define STM32_PWM_USE_TIM4 FALSE
#define STM32_PWM_USE_TIM5 FALSE
#define STM32_PWM_USE_TIM8 FALSE
#define STM32_PWM_TIM1_IRQ_PRIORITY 7
diff --git a/testhal/STM32/STM32F1xx/onewire/onewire_test.c b/testhal/STM32/STM32F1xx/onewire/onewire_test.c index 7d0de69..682ed71 100644 --- a/testhal/STM32/STM32F1xx/onewire/onewire_test.c +++ b/testhal/STM32/STM32F1xx/onewire/onewire_test.c @@ -24,35 +24,48 @@ ****************************************************************************** */ -#if defined(BOARD_ST_STM32F4_DISCOVERY) -#if ONEWIRE_USE_STRONG_PULLUP -#error "F4 Discovery board has not enough voltage for this feature" -#endif +#if defined(BOARD_ST_STM32F4_DISCOVERY) || \ + defined(BOARD_ST_STM32F0_DISCOVERY) || \ + defined(BOARD_ST_STM32F0308_DISCOVERY) + #if ONEWIRE_USE_STRONG_PULLUP + #error "This board has not enough voltage for this feature" + #endif #endif -#if defined(BOARD_ST_STM32F4_DISCOVERY) -#define GPIOB_ONEWIRE GPIOB_PIN8 -#define ONEWIRE_PAD_MODE_ACTIVE (PAL_MODE_ALTERNATE(2) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUDR_PULLUP) -#define search_led_off() (palClearPad(GPIOD, GPIOD_LED4)) -#define search_led_on() (palSetPad(GPIOD, GPIOD_LED4)) -#define ONEWIRE_MASTER_CHANNEL 2 -#define ONEWIRE_SAMPLE_CHANNEL 3 +#if defined(BOARD_ST_STM32F0308_DISCOVERY) + #define ONEWIRE_PORT GPIOB + #define ONEWIRE_PIN GPIOB_PIN0 + #define ONEWIRE_PAD_MODE_ACTIVE (PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUDR_PULLUP) + #define search_led_off() (palClearPad(GPIOC, GPIOC_LED4)) + #define search_led_on() (palSetPad(GPIOC, GPIOC_LED4)) + #define ONEWIRE_MASTER_CHANNEL 2 + #define ONEWIRE_SAMPLE_CHANNEL 3 +#elif defined(BOARD_ST_STM32F4_DISCOVERY) + #define ONEWIRE_PORT GPIOB + #define ONEWIRE_PIN GPIOB_PIN0 + #define ONEWIRE_PAD_MODE_ACTIVE (PAL_MODE_ALTERNATE(2) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUDR_PULLUP) + #define search_led_off() (palClearPad(GPIOD, GPIOD_LED4)) + #define search_led_on() (palSetPad(GPIOD, GPIOD_LED4)) + #define ONEWIRE_MASTER_CHANNEL 2 + #define ONEWIRE_SAMPLE_CHANNEL 3 #elif defined(BOARD_OLIMEX_STM32_103STK) -#define GPIOB_ONEWIRE 8 -#define ONEWIRE_PAD_MODE_IDLE PAL_MODE_INPUT -#define ONEWIRE_PAD_MODE_ACTIVE PAL_MODE_STM32_ALTERNATE_OPENDRAIN -#define search_led_on() (palClearPad(GPIOC, GPIOC_LED)) -#define search_led_off() (palSetPad(GPIOC, GPIOC_LED)) -#define ONEWIRE_MASTER_CHANNEL 2 -#define ONEWIRE_SAMPLE_CHANNEL 3 + #define ONEWIRE_PORT GPIOB + #define ONEWIRE_PIN 0 + #define ONEWIRE_PAD_MODE_IDLE PAL_MODE_INPUT + #define ONEWIRE_PAD_MODE_ACTIVE PAL_MODE_STM32_ALTERNATE_OPENDRAIN + #define search_led_on() (palClearPad(GPIOC, GPIOC_LED)) + #define search_led_off() (palSetPad(GPIOC, GPIOC_LED)) + #define ONEWIRE_MASTER_CHANNEL 2 + #define ONEWIRE_SAMPLE_CHANNEL 3 #else -#define GPIOB_ONEWIRE GPIOB_TACHOMETER -#include "pads.h" -#define ONEWIRE_PAD_MODE_ACTIVE (PAL_MODE_ALTERNATE(2) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUDR_PULLUP) -#define search_led_on red_led_on -#define search_led_off red_led_off -#define ONEWIRE_MASTER_CHANNEL 2 -#define ONEWIRE_SAMPLE_CHANNEL 3 + #define ONEWIRE_PORT GPIOB + #define GPIOB_ONEWIRE GPIOB_TACHOMETER + #include "pads.h" + #define ONEWIRE_PAD_MODE_ACTIVE (PAL_MODE_ALTERNATE(2) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUDR_PULLUP) + #define search_led_on red_led_on + #define search_led_off red_led_off + #define ONEWIRE_MASTER_CHANNEL 2 + #define ONEWIRE_SAMPLE_CHANNEL 3 #endif /* @@ -82,17 +95,17 @@ static void strong_pullup_release(void); static uint8_t testbuf[12]; -static float temperature[3]; +static int32_t temperature[3]; /* * */ static const onewireConfig ow_cfg = { - &PWMD4, + &PWMD3, ONEWIRE_MASTER_CHANNEL, ONEWIRE_SAMPLE_CHANNEL, - GPIOB, - GPIOB_ONEWIRE, + ONEWIRE_PORT, + ONEWIRE_PIN, #if defined(STM32F1XX) ONEWIRE_PAD_MODE_IDLE, #endif @@ -140,11 +153,11 @@ static void strong_pullup_release(void) { */ void onewireTest(void) { - uint16_t tmp; + int16_t tmp; uint8_t rombuf[24]; size_t devices_on_bus = 0; size_t i = 0; - volatile bool presence; + bool presence; onewireObjectInit(&OWD1); onewireStart(&OWD1, &ow_cfg); @@ -209,11 +222,11 @@ void onewireTest(void) { osalDbgCheck(testbuf[8] == onewireCRC(testbuf, 8)); tmp = 0; tmp |= (testbuf[1] << 8) | testbuf[0]; - temperature[i] = tmp * 0.0625; + temperature[i] = (tmp * 625) / 10; } } else { - osalSysHalt(""); + osalSysHalt("No devices found"); } osalThreadSleep(1); /* enforce ChibiOS's stack overflow check */ } diff --git a/testhal/STM32/STM32F1xx/onewire/readme.txt b/testhal/STM32/STM32F1xx/onewire/readme.txt new file mode 100644 index 0000000..f10ae0b --- /dev/null +++ b/testhal/STM32/STM32F1xx/onewire/readme.txt @@ -0,0 +1,32 @@ +*****************************************************************************
+** ChibiOS/RT HAL - 1-Wire driver demo for STM32F1xx. **
+*****************************************************************************
+
+** TARGET **
+
+The demo will on an Olimex STM32_103STK board.
+
+** The Demo **
+
+The application demonstrates the use of the STM32F1xx 1-Wire driver.
+
+** Board Setup **
+
+To use demo you have to power your 1-wire device from 5V bus on board
+and connect DQ line to PB0 pin. Do not forget about external pullup
+resistor to 5V (4k7 recommended).
+
+** Build Procedure **
+
+The demo has been tested using the free Codesourcery GCC-based toolchain
+and YAGARTO.
+Just modify the TRGT line in the makefile in order to use different GCC ports.
+
+** Notes **
+
+Some files used by the demo are not part of ChibiOS/RT but are copyright of
+ST Microelectronics and are licensed under a different license.
+Also note that not all the files present in the ST library are distributed
+with ChibiOS/RT, you can find the whole library on the ST web site:
+
+ http://www.st.com
|