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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 2:87dc86a7288b
- Parent:
- 1:73d739c64e4c
--- a/main.cpp Sat Mar 21 11:21:32 2015 +0000 +++ b/main.cpp Tue May 12 09:15:11 2015 +0000 @@ -22,7 +22,8 @@ /* Defines -----------------------------------------------------------------------*/ -// In some mbed libraries are not included these definines +// In some mbed libraries these defines are not included +// please uncomment if the example is not working //#define GPIOE_BASE (AHB2PERIPH_BASE + 0x1000) //#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) @@ -31,17 +32,17 @@ //mbed - initialization of peripherals -InterruptIn button(PA_0); // inicialize button on STM32F3 discovery -Ticker toggle_ticker; // inicialize ticker +InterruptIn button(PA_0); // initialize button on STM32F3 discovery +Ticker toggle_ticker; // initialize ticker /* Functions----------------------------------------------------------------------*/ /******************************************************************************* * Function Name : toggle. -* Description : Blinks whit 8 LEDs if ticker interval reached. +* Description : Blinks with 8 LEDs if ticker interval reached. * Input : None. -* Output : Blinks whit 8 LEDs. +* Output : Blinks with 8 LEDs. * Return : None. *******************************************************************************/ @@ -60,7 +61,7 @@ *******************************************************************************/ void pressed() { - // Switch pins PE_15 to PE_8 to log. 1 , where LEDs are attached to + // Switch pins PE_15 to PE_8 (LEDs) to high level HAL_GPIO_WritePin(GPIOE , GPIO_PIN_15 | GPIO_PIN_14 | GPIO_PIN_13 | GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_9 | GPIO_PIN_8 , GPIO_PIN_SET); } @@ -74,36 +75,36 @@ int main() { - //inicialize power (clock source) to port E (GPIOE) + //initialize power (clock source) to port E (GPIOE) __GPIOE_CLK_ENABLE(); // RCC->AHBENR |= RCC_AHBPeriph_GPIOE; // if __GPIOE_CLK_ENABLE(); is not defined - //inicialize pins - // atructure to set GPIO + // initialize pins + // structure to set GPIO GPIO_InitTypeDef GPIO_InitStruct; - //Specifies the operating mode for the selected pins. + // Specifies the operating mode for the selected pins. // Output Push Pull Mode GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - //Specifies the Pull-up or Pull-Down activation for the selected pins. - //Pull-up activation + // Specifies the Pull-up or Pull-Down activation for the selected pins. + // Pull-up activation GPIO_InitStruct.Pull = GPIO_PULLUP; - //Specifies the speed for the selected pins. - //High speed + // Specifies the speed for the selected pins. + // High speed GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; - //Specifies the GPIO pins to be configured. - //Pins 15 to 8 + // Specifies the GPIO pins to be configured. + // Pins 15 to 8 GPIO_InitStruct.Pin = GPIO_PIN_15 | GPIO_PIN_14 | GPIO_PIN_13 | GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_9 | GPIO_PIN_8; - //Inicialize pins PE_15 to PE_8 + // Initialize pins PE_15 to PE_8 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - // button was pressed, call function pressed + // Button was pressed, call function pressed() button.fall(&pressed); // Init the ticker with the address of the function (toggle) to be attached and the interval (1 s) toggle_ticker.attach(&toggle, 1); - // infinity loop + // infinite loop while (1) { } }