Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.c@6:0018763974d3, 2017-02-25 (annotated)
- Committer:
- elmot
- Date:
- Sat Feb 25 08:59:21 2017 +0000
- Revision:
- 6:0018763974d3
- Parent:
- 3:858ea360dbbe
No comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elmot | 0:a9bbfbd216e8 | 1 | #define USE_STM32L476G_DISCO_REVC |
elmot | 0:a9bbfbd216e8 | 2 | #include "stm32l476g_discovery.h" |
elmot | 0:a9bbfbd216e8 | 3 | |
elmot | 0:a9bbfbd216e8 | 4 | // main() runs in its own thread in the OS |
elmot | 0:a9bbfbd216e8 | 5 | // (note the calls to wait below for delays) |
elmot | 2:8c4e755038ce | 6 | |
elmot | 2:8c4e755038ce | 7 | |
elmot | 2:8c4e755038ce | 8 | /*************** TODO *************** |
elmot | 2:8c4e755038ce | 9 | Joystik up=> LED4 ON |
elmot | 2:8c4e755038ce | 10 | Joystik down=> LED5 ON |
elmot | 2:8c4e755038ce | 11 | |
elmot | 2:8c4e755038ce | 12 | Hint: Use UP_JOY_xxx definitions |
elmot | 2:8c4e755038ce | 13 | */ |
elmot | 0:a9bbfbd216e8 | 14 | int main() { |
elmot | 0:a9bbfbd216e8 | 15 | |
elmot | 0:a9bbfbd216e8 | 16 | LED4_GPIO_CLK_ENABLE(); |
elmot | 0:a9bbfbd216e8 | 17 | LED5_GPIO_CLK_ENABLE(); |
elmot | 3:858ea360dbbe | 18 | UP_JOY_GPIO_CLK_ENABLE(); |
elmot | 3:858ea360dbbe | 19 | DOWN_JOY_GPIO_CLK_ENABLE(); |
elmot | 0:a9bbfbd216e8 | 20 | |
elmot | 0:a9bbfbd216e8 | 21 | GPIO_InitTypeDef gpio; |
elmot | 3:858ea360dbbe | 22 | |
elmot | 0:a9bbfbd216e8 | 23 | gpio.Mode = GPIO_MODE_OUTPUT_PP; |
elmot | 0:a9bbfbd216e8 | 24 | gpio.Pull = GPIO_NOPULL; |
elmot | 0:a9bbfbd216e8 | 25 | gpio.Speed = GPIO_SPEED_FREQ_LOW; |
elmot | 0:a9bbfbd216e8 | 26 | gpio.Pin = LED4_PIN; |
elmot | 0:a9bbfbd216e8 | 27 | HAL_GPIO_Init(LED4_GPIO_PORT, &gpio); |
elmot | 0:a9bbfbd216e8 | 28 | |
elmot | 0:a9bbfbd216e8 | 29 | gpio.Pin = LED5_PIN; |
elmot | 0:a9bbfbd216e8 | 30 | HAL_GPIO_Init(LED5_GPIO_PORT, &gpio); |
elmot | 0:a9bbfbd216e8 | 31 | |
elmot | 3:858ea360dbbe | 32 | |
elmot | 3:858ea360dbbe | 33 | gpio.Mode = GPIO_MODE_INPUT; |
elmot | 3:858ea360dbbe | 34 | gpio.Pull = GPIO_PULLDOWN; |
elmot | 3:858ea360dbbe | 35 | gpio.Pin = UP_JOY_PIN; |
elmot | 3:858ea360dbbe | 36 | HAL_GPIO_Init(UP_JOY_GPIO_PORT, &gpio); |
elmot | 3:858ea360dbbe | 37 | |
elmot | 3:858ea360dbbe | 38 | gpio.Pin = DOWN_JOY_PIN; |
elmot | 3:858ea360dbbe | 39 | HAL_GPIO_Init(DOWN_JOY_GPIO_PORT, &gpio); |
elmot | 3:858ea360dbbe | 40 | |
elmot | 3:858ea360dbbe | 41 | HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN); |
elmot | 3:858ea360dbbe | 42 | HAL_Delay(300); |
elmot | 3:858ea360dbbe | 43 | HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN); |
elmot | 3:858ea360dbbe | 44 | HAL_Delay(300); |
elmot | 3:858ea360dbbe | 45 | HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN); |
elmot | 3:858ea360dbbe | 46 | HAL_Delay(300); |
elmot | 3:858ea360dbbe | 47 | HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN); |
elmot | 3:858ea360dbbe | 48 | HAL_Delay(300); |
elmot | 3:858ea360dbbe | 49 | |
elmot | 0:a9bbfbd216e8 | 50 | while (1) { |
elmot | 0:a9bbfbd216e8 | 51 | } |
elmot | 0:a9bbfbd216e8 | 52 | } |
elmot | 0:a9bbfbd216e8 | 53 |