Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SES worksheet 7
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s4-wise
SES worksheet 7
Commits
61fdbaba
Commit
61fdbaba
authored
2 years ago
by
s4-wise
Browse files
Options
Downloads
Patches
Plain Diff
Add new file
parent
f748b109
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
worksheet7/newmain.c
+119
-0
119 additions, 0 deletions
worksheet7/newmain.c
with
119 additions
and
0 deletions
worksheet7/newmain.c
0 → 100644
+
119
−
0
View file @
61fdbaba
/********************************************************************************
* @file GPIO/IOToggle/main.c
* @author MCD Application Team
* @version V3.5.0
* @date 08-April-2011
* @brief Main program body.
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include
<stm32f10x.h>
#include
<stm32f10x_rcc.h>
#include
<stm32f10x_gpio.h>
#include
<stm32f10x_tim.h>
#include
<stm32f10x_rcc.h>
#include
<stm32f10x_exti.h>
#include
<misc.h>
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef
GPIO_InitStructure
;
static
int
yellowledval
=
0
;
void
configure_leds
(
void
)
{
/* GPIOC/A Periph clock enable */
RCC_APB2PeriphClockCmd
(
RCC_APB2Periph_GPIOA
|
RCC_APB2Periph_GPIOC
,
ENABLE
);
/* Configure PC6 in output pushpull mode */
GPIO_InitStructure
.
GPIO_Pin
=
GPIO_Pin_6
|
GPIO_Pin_7
;
GPIO_InitStructure
.
GPIO_Speed
=
GPIO_Speed_50MHz
;
GPIO_InitStructure
.
GPIO_Mode
=
GPIO_Mode_Out_PP
;
GPIO_Init
(
GPIOC
,
&
GPIO_InitStructure
);
}
void
configure_buttonsA
(
void
)
{
GPIO_InitTypeDef
GPIO_InitStructure
;
EXTI_InitTypeDef
EXTI_InitStructure
;
NVIC_InitTypeDef
NVIC_InitStructure
;
/* Initialise the GPIOA for button WKUP */
GPIO_InitStructure
.
GPIO_Pin
=
GPIO_Pin_0
;
GPIO_InitStructure
.
GPIO_Mode
=
GPIO_Mode_IN_FLOATING
;
GPIO_Init
(
GPIOA
,
&
GPIO_InitStructure
);
/* Connect Button EXTI Line to Button GPIO Pin */
GPIO_EXTILineConfig
(
GPIO_PortSourceGPIOA
,
GPIO_PinSource0
);
/*Configure Button EXTI line */
EXTI_InitStructure
.
EXTI_Line
=
EXTI_Line0
;
EXTI_InitStructure
.
EXTI_Mode
=
EXTI_Mode_Interrupt
;
EXTI_InitStructure
.
EXTI_Trigger
=
EXTI_Trigger_Rising
;
EXTI_InitStructure
.
EXTI_LineCmd
=
ENABLE
;
EXTI_Init
(
&
EXTI_InitStructure
);
/* Configure interrupts for button */
NVIC_InitStructure
.
NVIC_IRQChannel
=
EXTI0_IRQn
;
NVIC_InitStructure
.
NVIC_IRQChannelPreemptionPriority
=
0
;
NVIC_InitStructure
.
NVIC_IRQChannelSubPriority
=
1
;
NVIC_InitStructure
.
NVIC_IRQChannelCmd
=
ENABLE
;
NVIC_Init
(
&
NVIC_InitStructure
);
}
void
EXTI0_IRQHandler
()
{
if
(
EXTI_GetITStatus
(
EXTI_Line0
)
==
SET
)
{
EXTI_ClearITPendingBit
(
EXTI_Line0
);
GPIO_WriteBit
(
GPIOC
,
GPIO_Pin_7
,
(
yellowledval
)
?
Bit_SET
:
Bit_RESET
);
yellowledval
=
1
-
yellowledval
;
}
}
int
main
(
void
)
{
configure_leds
();
configure_buttonsA
();
while
(
1
)
{
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void
assert_failed
(
uint8_t
*
file
,
uint32_t
line
)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while
(
1
)
{
}
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment