Skip to content

Commit da4c5ac

Browse files
committed
0
1 parent b5c3f09 commit da4c5ac

File tree

201 files changed

+6499
-2761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+6499
-2761
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
4+
5+
<component name="EventRecorderStub" version="1.0.0"/> <!--name and version of the component-->
6+
<events>
7+
</events>
8+
9+
</component_viewer>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "stm32f10x.h"
2+
3+
4+
uint16_t LightCount = 0;
5+
6+
void LightSensor_Init(void){
7+
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
8+
9+
GPIO_InitTypeDef GPIO_InitStructure;
10+
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
11+
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
12+
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
13+
GPIO_Init(GPIOA, &GPIO_InitStructure);
14+
15+
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource10);
16+
17+
EXTI_InitTypeDef EXTI_InitStruct;
18+
EXTI_InitStruct.EXTI_Line = EXTI_Line10;
19+
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
20+
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
21+
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Falling;
22+
EXTI_Init(&EXTI_InitStruct);
23+
24+
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
25+
26+
NVIC_InitTypeDef NVIC_InitStruct;
27+
NVIC_InitStruct.NVIC_IRQChannel = EXTI15_10_IRQn;
28+
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
29+
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 1;
30+
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 1;
31+
NVIC_Init(&NVIC_InitStruct);
32+
33+
}
34+
35+
uint16_t Get_Count(void) {
36+
uint16_t temp = LightCount;
37+
LightCount = 0;
38+
return temp;
39+
}
40+
41+
void EXTI15_10_IRQHandler(void) {
42+
if (EXTI_GetITStatus(EXTI_Line10) == SET) {
43+
if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_10) == 0) {
44+
LightCount++;
45+
}
46+
EXTI_ClearITPendingBit(EXTI_Line10);
47+
}
48+
}

0-1 Lighting_Rate/Hardware/LightSensor.h renamed to 0-1 Lighting_Counter/Hardware/LightSensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
void LightSensor_Init(void);
55

6-
uint8_t LightSensor_Get(void);
6+
uint8_t Get_Count(void);
77

88
#endif
4.48 MB
Binary file not shown.

0 commit comments

Comments
 (0)