aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-17 08:45:43 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-17 08:45:43 +0000
commit4ff96215eddade6e541f1a97af5364e754ccee7c (patch)
tree28b310e8dc99a8a4714d59cd8b73327ef66c3054
parenteea844796a2cdbea9f4ddf51f9766ff3964984b6 (diff)
downloadChibiOS-4ff96215eddade6e541f1a97af5364e754ccee7c.tar.gz
ChibiOS-4ff96215eddade6e541f1a97af5364e754ccee7c.tar.bz2
ChibiOS-4ff96215eddade6e541f1a97af5364e754ccee7c.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3323 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--boards/ST_STM32L_DISCOVERY/board.h68
-rw-r--r--demos/ARMCM3-STM32L152-DISCOVERY/main.c11
-rw-r--r--os/hal/platforms/STM32/GPIOv2/pal_lld.h30
3 files changed, 93 insertions, 16 deletions
diff --git a/boards/ST_STM32L_DISCOVERY/board.h b/boards/ST_STM32L_DISCOVERY/board.h
index 845113f57..9e6802b26 100644
--- a/boards/ST_STM32L_DISCOVERY/board.h
+++ b/boards/ST_STM32L_DISCOVERY/board.h
@@ -95,15 +95,39 @@
* PA15 - JTDI (alternate 0).
*/
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON) | \
+ PIN_MODE_INPUT(1) | \
+ PIN_MODE_INPUT(2) | \
+ PIN_MODE_INPUT(3) | \
+ PIN_MODE_INPUT(4) | \
+ PIN_MODE_INPUT(5) | \
+ PIN_MODE_INPUT(6) | \
+ PIN_MODE_INPUT(7) | \
+ PIN_MODE_INPUT(8) | \
+ PIN_MODE_INPUT(9) | \
+ PIN_MODE_INPUT(10) | \
+ PIN_MODE_INPUT(11) | \
+ PIN_MODE_INPUT(12) | \
PIN_MODE_ALTERNATE(13) | \
PIN_MODE_ALTERNATE(14) | \
PIN_MODE_ALTERNATE(15))
#define VAL_GPIOA_OTYPER 0x00000000
#define VAL_GPIOA_OSPEEDR 0xFFFFFFFF
-#define VAL_GPIOA_PUPDR (~(PIN_PUDR_FLOATING(GPIOA_BUTTON) | \
- PIN_PUDR_FLOATING(13) | \
- PIN_PUDR_FLOATING(14) | \
- PIN_PUDR_FLOATING(15)))
+#define VAL_GPIOA_PUPDR (PIN_PUDR_PULLUP(GPIOA_BUTTON) | \
+ PIN_PUDR_PULLUP(1) | \
+ PIN_PUDR_PULLUP(2) | \
+ PIN_PUDR_PULLUP(3) | \
+ PIN_PUDR_PULLUP(4) | \
+ PIN_PUDR_PULLUP(5) | \
+ PIN_PUDR_PULLUP(6) | \
+ PIN_PUDR_PULLUP(7) | \
+ PIN_PUDR_PULLUP(8) | \
+ PIN_PUDR_PULLUP(9) | \
+ PIN_PUDR_PULLUP(10) | \
+ PIN_PUDR_PULLUP(11) | \
+ PIN_PUDR_PULLUP(12) | \
+ PIN_PUDR_FLOATING(13) | \
+ PIN_PUDR_FLOATING(14) | \
+ PIN_PUDR_FLOATING(15))
#define VAL_GPIOA_ODR 0xFFFFFFFF
#define VAL_GPIOA_AFRL 0x00000000
#define VAL_GPIOA_AFRH 0x00000000
@@ -116,16 +140,40 @@
* PB6 - GPIOB_LED4 (output push-pull).
* PB7 - GPIOB_LED3 (output push-pull).
*/
-#define VAL_GPIOB_MODER (PIN_MODE_ALTERNATE(3) | \
+#define VAL_GPIOB_MODER (PIN_MODE_INPUT(0) | \
+ PIN_MODE_INPUT(1) | \
+ PIN_MODE_INPUT(2) | \
+ PIN_MODE_ALTERNATE(3) | \
PIN_MODE_ALTERNATE(4) | \
+ PIN_MODE_INPUT(5) | \
PIN_MODE_OUTPUT(GPIOB_LED4) | \
- PIN_MODE_OUTPUT(GPIOB_LED3))
+ PIN_MODE_OUTPUT(GPIOB_LED3) | \
+ PIN_MODE_INPUT(8) | \
+ PIN_MODE_INPUT(9) | \
+ PIN_MODE_INPUT(10) | \
+ PIN_MODE_INPUT(11) | \
+ PIN_MODE_INPUT(12) | \
+ PIN_MODE_INPUT(13) | \
+ PIN_MODE_INPUT(14) | \
+ PIN_MODE_INPUT(15))
#define VAL_GPIOB_OTYPER 0x00000000
#define VAL_GPIOB_OSPEEDR 0xFFFFFFFF
-#define VAL_GPIOB_PUPDR (~(PIN_PUDR_FLOATING(3) | \
- PIN_PUDR_FLOATING(4) | \
- PIN_PUDR_FLOATING(GPIOB_LED4) | \
- PIN_PUDR_FLOATING(GPIOB_LED3)))
+#define VAL_GPIOB_PUPDR (PIN_PUDR_PULLUP(0) | \
+ PIN_PUDR_PULLUP(1) | \
+ PIN_PUDR_PULLUP(2) | \
+ PIN_PUDR_FLOATING(3) | \
+ PIN_PUDR_FLOATING(4) | \
+ PIN_PUDR_PULLUP(5) | \
+ PIN_PUDR_FLOATING(GPIOB_LED4) | \
+ PIN_PUDR_FLOATING(GPIOB_LED3) | \
+ PIN_PUDR_PULLUP(8) | \
+ PIN_PUDR_PULLUP(9) | \
+ PIN_PUDR_PULLUP(10) | \
+ PIN_PUDR_PULLUP(11) | \
+ PIN_PUDR_PULLUP(12) | \
+ PIN_PUDR_PULLUP(13) | \
+ PIN_PUDR_PULLUP(14) | \
+ PIN_PUDR_PULLUP(15))
#define VAL_GPIOB_ODR 0xFFFFFF3F
#define VAL_GPIOB_AFRL 0x00000000
#define VAL_GPIOB_AFRH 0x00000000
diff --git a/demos/ARMCM3-STM32L152-DISCOVERY/main.c b/demos/ARMCM3-STM32L152-DISCOVERY/main.c
index 3eaddc5fc..a21d12dae 100644
--- a/demos/ARMCM3-STM32L152-DISCOVERY/main.c
+++ b/demos/ARMCM3-STM32L152-DISCOVERY/main.c
@@ -60,16 +60,19 @@ int main(void) {
/*
* Activates the serial driver 1 using the driver default configuration.
+ * PA9 and PA10 are routed to USART1.
*/
sdStart(&SD1, NULL);
+ palSetPadMode(GPIOA, 9, PAL_MODE_ALT_OUTPUT_PUSHPULL(7));
+ palSetPadMode(GPIOA, 10, PAL_MODE_ALT_INPUT(7));
/*
* If the user button is pressed after the reset then the test suite is
* executed immediately before activating the various device drivers in
* order to not alter the benchmark scores.
*/
-// if (palReadPad(GPIOA, GPIOA_BUTTON))
-// TestThread(&SD1);
+ if (palReadPad(GPIOA, GPIOA_BUTTON))
+ TestThread(&SD1);
/*
* Initializes the SPI driver 1.
@@ -106,8 +109,8 @@ int main(void) {
* driver 1.
*/
while (TRUE) {
-// if (palReadPad(GPIOA, GPIOA_BUTTON))
-// TestThread(&SD1);
+ if (palReadPad(GPIOA, GPIOA_BUTTON))
+ TestThread(&SD1);
chThdSleepMilliseconds(500);
}
}
diff --git a/os/hal/platforms/STM32/GPIOv2/pal_lld.h b/os/hal/platforms/STM32/GPIOv2/pal_lld.h
index 0f9f22441..aa8dc2d73 100644
--- a/os/hal/platforms/STM32/GPIOv2/pal_lld.h
+++ b/os/hal/platforms/STM32/GPIOv2/pal_lld.h
@@ -96,6 +96,32 @@
PAL_STM32_PUDR_PULLDOWN)
/**
+ * @brief Alternate input high-Z pad.
+ *
+ * @param[in] n alternate function selector
+ */
+#define PAL_MODE_ALT_INPUT(n) (PAL_STM32_MODE_INPUT | \
+ PAL_STM32_ALTERNATE(n))
+
+/**
+ * @brief Alternate input pad with weak pull up resistor.
+ *
+ * @param[in] n alternate function selector
+ */
+#define PAL_MODE_ALT_INPUT_PULLUP(n) (PAL_STM32_MODE_INPUT | \
+ PAL_STM32_PUDR_PULLUP | \
+ PAL_STM32_ALTERNATE(n))
+
+/**
+ * @brief Alternate input pad with weak pull down resistor.
+ *
+ * @param[in] n alternate function selector
+ */
+#define PAL_MODE_ALT_INPUT_PULLDOWN(n) (PAL_STM32_MODE_INPUT | \
+ PAL_STM32_PUDR_PULLDOWN | \
+ PAL_STM32_ALTERNATE(n))
+
+/**
* @brief Analog input mode.
*/
#define PAL_MODE_INPUT_ANALOG PAL_STM32_MODE_ANALOG
@@ -117,7 +143,7 @@
*
* @param[in] n alternate function selector
*/
-#define PAL_MODE_ALTERNATE_PUSHPULL(n) (PAL_STM32_MODE_ALTERNATE | \
+#define PAL_MODE_ALT_OUTPUT_PUSHPULL(n) (PAL_STM32_MODE_ALTERNATE | \
PAL_STM32_OTYPE_PUSHPULL | \
PAL_STM32_ALTERNATE(n))
@@ -126,7 +152,7 @@
*
* @param[in] n alternate function selector
*/
-#define PAL_MODE_ALTERNATE_OPENDRAIN(n) (PAL_STM32_MODE_ALTERNATE | \
+#define PAL_MODE_ALT_OUTPUT_OPENDRAIN(n) (PAL_STM32_MODE_ALTERNATE | \
PAL_STM32_OTYPE_OPENDRAIN | \
PAL_STM32_ALTERNATE(n))