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
00001 #define USE_STM32L476G_DISCO_REVC 00002 #include "stm32l476g_discovery.h" 00003 00004 // main() runs in its own thread in the OS 00005 // (note the calls to wait below for delays) 00006 00007 00008 /*************** TODO *************** 00009 Joystik up=> LED4 ON 00010 Joystik down=> LED5 ON 00011 00012 Hint: Use UP_JOY_xxx definitions 00013 */ 00014 int main() { 00015 00016 LED4_GPIO_CLK_ENABLE(); 00017 LED5_GPIO_CLK_ENABLE(); 00018 UP_JOY_GPIO_CLK_ENABLE(); 00019 DOWN_JOY_GPIO_CLK_ENABLE(); 00020 00021 GPIO_InitTypeDef gpio; 00022 00023 gpio.Mode = GPIO_MODE_OUTPUT_PP; 00024 gpio.Pull = GPIO_NOPULL; 00025 gpio.Speed = GPIO_SPEED_FREQ_LOW; 00026 gpio.Pin = LED4_PIN; 00027 HAL_GPIO_Init(LED4_GPIO_PORT, &gpio); 00028 00029 gpio.Pin = LED5_PIN; 00030 HAL_GPIO_Init(LED5_GPIO_PORT, &gpio); 00031 00032 00033 gpio.Mode = GPIO_MODE_INPUT; 00034 gpio.Pull = GPIO_PULLDOWN; 00035 gpio.Pin = UP_JOY_PIN; 00036 HAL_GPIO_Init(UP_JOY_GPIO_PORT, &gpio); 00037 00038 gpio.Pin = DOWN_JOY_PIN; 00039 HAL_GPIO_Init(DOWN_JOY_GPIO_PORT, &gpio); 00040 00041 HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN); 00042 HAL_Delay(300); 00043 HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN); 00044 HAL_Delay(300); 00045 HAL_GPIO_TogglePin(LED5_GPIO_PORT, LED5_PIN); 00046 HAL_Delay(300); 00047 HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN); 00048 HAL_Delay(300); 00049 00050 while (1) { 00051 } 00052 } 00053
Generated on Tue Jul 12 2022 10:59:56 by
