diff --git a/diode_tester/Core/Inc/main.h b/diode_tester/Core/Inc/main.h
index 218d3a3..7551e7f 100644
--- a/diode_tester/Core/Inc/main.h
+++ b/diode_tester/Core/Inc/main.h
@@ -57,6 +57,34 @@ void Error_Handler(void);
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
+#define PhaseAHiResponse_Pin GPIO_PIN_3
+#define PhaseAHiResponse_GPIO_Port GPIOA
+#define PhaseAHiResponse_EXTI_IRQn EXTI3_IRQn
+#define PhaseALoResponse_Pin GPIO_PIN_4
+#define PhaseALoResponse_GPIO_Port GPIOA
+#define PhaseALoResponse_EXTI_IRQn EXTI4_IRQn
+#define PhaseBHiResponse_Pin GPIO_PIN_5
+#define PhaseBHiResponse_GPIO_Port GPIOA
+#define PhaseBHiResponse_EXTI_IRQn EXTI9_5_IRQn
+#define PhaseBLoResponse_Pin GPIO_PIN_6
+#define PhaseBLoResponse_GPIO_Port GPIOA
+#define PhaseBLoResponse_EXTI_IRQn EXTI9_5_IRQn
+#define PhaseAHi_Pin GPIO_PIN_0
+#define PhaseAHi_GPIO_Port GPIOB
+#define PhaseALo_Pin GPIO_PIN_1
+#define PhaseALo_GPIO_Port GPIOB
+#define PhaseBHi_Pin GPIO_PIN_10
+#define PhaseBHi_GPIO_Port GPIOB
+#define PhaseBLo_Pin GPIO_PIN_11
+#define PhaseBLo_GPIO_Port GPIOB
+#define PhaseAHiSignal_Pin GPIO_PIN_12
+#define PhaseAHiSignal_GPIO_Port GPIOB
+#define PhaseALoSignal_Pin GPIO_PIN_13
+#define PhaseALoSignal_GPIO_Port GPIOB
+#define PhaseBHiSignal_Pin GPIO_PIN_14
+#define PhaseBHiSignal_GPIO_Port GPIOB
+#define PhaseBLoSignal_Pin GPIO_PIN_15
+#define PhaseBLoSignal_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
diff --git a/diode_tester/Core/Inc/stm32f1xx_it.h b/diode_tester/Core/Inc/stm32f1xx_it.h
index a62cee0..e0d4bdf 100644
--- a/diode_tester/Core/Inc/stm32f1xx_it.h
+++ b/diode_tester/Core/Inc/stm32f1xx_it.h
@@ -55,7 +55,10 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void EXTI3_IRQHandler(void);
+void EXTI4_IRQHandler(void);
void DMA1_Channel1_IRQHandler(void);
+void EXTI9_5_IRQHandler(void);
void TIM2_IRQHandler(void);
void TIM3_IRQHandler(void);
void USART1_IRQHandler(void);
diff --git a/diode_tester/Core/Interfaces/modbus.c b/diode_tester/Core/Interfaces/modbus.c
index 8738425..73de147 100644
--- a/diode_tester/Core/Interfaces/modbus.c
+++ b/diode_tester/Core/Interfaces/modbus.c
@@ -93,9 +93,9 @@ extern TIM_HandleTypeDef rs_htim;
RS_HandleTypeDef hmodbus1;
/* DEFINE REGISTERS/COILS */
+MB_DeviceIdentificationTypeDef MB_INFO;
MB_DataStructureTypeDef MB_DATA;
RS_MsgTypeDef MODBUS_MSG;
-MB_DeviceIdentificationTypeDef MB_INFO;
uint32_t delay_scide = 1;
uint32_t numb_scide = 10;
diff --git a/diode_tester/Core/Src/gpio.c b/diode_tester/Core/Src/gpio.c
index ee5f6ad..fc4bdf5 100644
--- a/diode_tester/Core/Src/gpio.c
+++ b/diode_tester/Core/Src/gpio.c
@@ -54,7 +54,8 @@ void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11, GPIO_PIN_RESET);
+ HAL_GPIO_WritePin(GPIOB, PhaseAHi_Pin|PhaseALo_Pin|PhaseBHi_Pin|PhaseBLo_Pin
+ |PhaseAHiSignal_Pin|PhaseALoSignal_Pin|PhaseBHiSignal_Pin|PhaseBLoSignal_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : PC13 */
GPIO_InitStruct.Pin = GPIO_PIN_13;
@@ -69,13 +70,31 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
- /*Configure GPIO pins : PB0 PB1 PB10 PB11 */
- GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11;
+ /*Configure GPIO pins : PAPin PAPin PAPin PAPin */
+ GPIO_InitStruct.Pin = PhaseAHiResponse_Pin|PhaseALoResponse_Pin|PhaseBHiResponse_Pin|PhaseBLoResponse_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /*Configure GPIO pins : PBPin PBPin PBPin PBPin
+ PBPin PBPin PBPin PBPin */
+ GPIO_InitStruct.Pin = PhaseAHi_Pin|PhaseALo_Pin|PhaseBHi_Pin|PhaseBLo_Pin
+ |PhaseAHiSignal_Pin|PhaseALoSignal_Pin|PhaseBHiSignal_Pin|PhaseBLoSignal_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+ /* EXTI interrupt init*/
+ HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(EXTI3_IRQn);
+
+ HAL_NVIC_SetPriority(EXTI4_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(EXTI4_IRQn);
+
+ HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
+
}
/* USER CODE BEGIN 2 */
diff --git a/diode_tester/Core/Src/stm32f1xx_it.c b/diode_tester/Core/Src/stm32f1xx_it.c
index 7d33653..ff35f45 100644
--- a/diode_tester/Core/Src/stm32f1xx_it.c
+++ b/diode_tester/Core/Src/stm32f1xx_it.c
@@ -203,6 +203,42 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32f1xx.s). */
/******************************************************************************/
+/**
+ * @brief This function handles EXTI line3 interrupt.
+ */
+void EXTI3_IRQHandler(void)
+{
+ /* USER CODE BEGIN EXTI3_IRQn 0 */
+ __disable_irq();
+
+ HAL_GPIO_TogglePin(PhaseAHiSignal_GPIO_Port, PhaseAHiSignal_Pin);
+
+ __enable_irq();
+ /* USER CODE END EXTI3_IRQn 0 */
+ HAL_GPIO_EXTI_IRQHandler(PhaseAHiResponse_Pin);
+ /* USER CODE BEGIN EXTI3_IRQn 1 */
+
+ /* USER CODE END EXTI3_IRQn 1 */
+}
+
+/**
+ * @brief This function handles EXTI line4 interrupt.
+ */
+void EXTI4_IRQHandler(void)
+{
+ /* USER CODE BEGIN EXTI4_IRQn 0 */
+ __disable_irq();
+
+ HAL_GPIO_TogglePin(PhaseALoSignal_GPIO_Port, PhaseALoSignal_Pin);
+
+ __enable_irq();
+ /* USER CODE END EXTI4_IRQn 0 */
+ HAL_GPIO_EXTI_IRQHandler(PhaseALoResponse_Pin);
+ /* USER CODE BEGIN EXTI4_IRQn 1 */
+
+ /* USER CODE END EXTI4_IRQn 1 */
+}
+
/**
* @brief This function handles DMA1 channel1 global interrupt.
*/
@@ -217,6 +253,28 @@ void DMA1_Channel1_IRQHandler(void)
/* USER CODE END DMA1_Channel1_IRQn 1 */
}
+/**
+ * @brief This function handles EXTI line[9:5] interrupts.
+ */
+void EXTI9_5_IRQHandler(void)
+{
+ /* USER CODE BEGIN EXTI9_5_IRQn 0 */
+ __disable_irq();
+
+ if (__HAL_GPIO_EXTI_GET_IT(PhaseBHiResponse_Pin) != 0x00u)
+ HAL_GPIO_TogglePin(PhaseBHiSignal_GPIO_Port, PhaseBHiSignal_Pin);
+ if (__HAL_GPIO_EXTI_GET_IT(PhaseBLoResponse_Pin) != 0x00u)
+ HAL_GPIO_TogglePin(PhaseBLoSignal_GPIO_Port, PhaseBLoSignal_Pin);
+
+ __enable_irq();
+ /* USER CODE END EXTI9_5_IRQn 0 */
+ HAL_GPIO_EXTI_IRQHandler(PhaseBHiResponse_Pin);
+ HAL_GPIO_EXTI_IRQHandler(PhaseBLoResponse_Pin);
+ /* USER CODE BEGIN EXTI9_5_IRQn 1 */
+
+ /* USER CODE END EXTI9_5_IRQn 1 */
+}
+
/**
* @brief This function handles TIM2 global interrupt.
*/
diff --git a/diode_tester/MDK-ARM/diode_tester.uvoptx b/diode_tester/MDK-ARM/diode_tester.uvoptx
index 31a4b0e..984c7c7 100644
--- a/diode_tester/MDK-ARM/diode_tester.uvoptx
+++ b/diode_tester/MDK-ARM/diode_tester.uvoptx
@@ -148,24 +148,7 @@
-U53FF72064980555724221187 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL08000 -FP0($$Device:STM32F103C6$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2
-
-
- 0
- 0
- 227
- 1
- 134244270
- 0
- 0
- 0
- 0
- 0
- 1
- ../Core/Src/stm32f1xx_it.c
-
- \\diode_tester\../Core/Src/stm32f1xx_it.c\227
-
-
+
0
@@ -303,6 +286,10 @@
+
+ System Viewer\GPIOB
+ 35904
+
System Viewer\TIM2
35899
diff --git a/diode_tester/diode_tester.ioc b/diode_tester/diode_tester.ioc
index 479873a..74ff930 100644
--- a/diode_tester/diode_tester.ioc
+++ b/diode_tester/diode_tester.ioc
@@ -39,21 +39,29 @@ Mcu.Name=STM32F103C(4-6)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PC13-TAMPER-RTC
Mcu.Pin1=PC14-OSC32_IN
-Mcu.Pin10=PA10
-Mcu.Pin11=PA13
-Mcu.Pin12=PA14
-Mcu.Pin13=VP_SYS_VS_Systick
-Mcu.Pin14=VP_TIM2_VS_ClockSourceINT
-Mcu.Pin15=VP_TIM3_VS_ClockSourceINT
+Mcu.Pin10=PB1
+Mcu.Pin11=PB10
+Mcu.Pin12=PB11
+Mcu.Pin13=PB12
+Mcu.Pin14=PB13
+Mcu.Pin15=PB14
+Mcu.Pin16=PB15
+Mcu.Pin17=PA9
+Mcu.Pin18=PA10
+Mcu.Pin19=PA13
Mcu.Pin2=PD0-OSC_IN
+Mcu.Pin20=PA14
+Mcu.Pin21=VP_SYS_VS_Systick
+Mcu.Pin22=VP_TIM2_VS_ClockSourceINT
+Mcu.Pin23=VP_TIM3_VS_ClockSourceINT
Mcu.Pin3=PD1-OSC_OUT
Mcu.Pin4=PA0-WKUP
-Mcu.Pin5=PB0
-Mcu.Pin6=PB1
-Mcu.Pin7=PB10
-Mcu.Pin8=PB11
-Mcu.Pin9=PA9
-Mcu.PinsNb=16
+Mcu.Pin5=PA3
+Mcu.Pin6=PA4
+Mcu.Pin7=PA5
+Mcu.Pin8=PA6
+Mcu.Pin9=PB0
+Mcu.PinsNb=24
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103C6Tx
@@ -62,6 +70,9 @@ MxDb.Version=DB.6.0.121
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
+NVIC.EXTI3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
+NVIC.EXTI4_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
+NVIC.EXTI9_5_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
@@ -81,16 +92,56 @@ PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
+PA3.GPIOParameters=GPIO_Label
+PA3.GPIO_Label=PhaseAHiResponse
+PA3.Locked=true
+PA3.Signal=GPXTI3
+PA4.GPIOParameters=GPIO_Label
+PA4.GPIO_Label=PhaseALoResponse
+PA4.Locked=true
+PA4.Signal=GPXTI4
+PA5.GPIOParameters=GPIO_Label
+PA5.GPIO_Label=PhaseBHiResponse
+PA5.Locked=true
+PA5.Signal=GPXTI5
+PA6.GPIOParameters=GPIO_Label
+PA6.GPIO_Label=PhaseBLoResponse
+PA6.Locked=true
+PA6.Signal=GPXTI6
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
+PB0.GPIOParameters=GPIO_Label
+PB0.GPIO_Label=PhaseAHi
PB0.Locked=true
PB0.Signal=GPIO_Output
+PB1.GPIOParameters=GPIO_Label
+PB1.GPIO_Label=PhaseALo
PB1.Locked=true
PB1.Signal=GPIO_Output
+PB10.GPIOParameters=GPIO_Label
+PB10.GPIO_Label=PhaseBHi
PB10.Locked=true
PB10.Signal=GPIO_Output
+PB11.GPIOParameters=GPIO_Label
+PB11.GPIO_Label=PhaseBLo
PB11.Locked=true
PB11.Signal=GPIO_Output
+PB12.GPIOParameters=GPIO_Label
+PB12.GPIO_Label=PhaseAHiSignal
+PB12.Locked=true
+PB12.Signal=GPIO_Output
+PB13.GPIOParameters=GPIO_Label
+PB13.GPIO_Label=PhaseALoSignal
+PB13.Locked=true
+PB13.Signal=GPIO_Output
+PB14.GPIOParameters=GPIO_Label
+PB14.GPIO_Label=PhaseBHiSignal
+PB14.Locked=true
+PB14.Signal=GPIO_Output
+PB15.GPIOParameters=GPIO_Label
+PB15.GPIO_Label=PhaseBLoSignal
+PB15.Locked=true
+PB15.Signal=GPIO_Output
PC13-TAMPER-RTC.Locked=true
PC13-TAMPER-RTC.Signal=GPIO_Output
PC14-OSC32_IN.GPIOParameters=GPIO_PuPd
@@ -157,6 +208,14 @@ RCC.USBFreq_Value=72000000
RCC.VCOOutput2Freq_Value=8000000
SH.ADCx_IN0.0=ADC1_IN0,IN0
SH.ADCx_IN0.ConfNb=1
+SH.GPXTI3.0=GPIO_EXTI3
+SH.GPXTI3.ConfNb=1
+SH.GPXTI4.0=GPIO_EXTI4
+SH.GPXTI4.ConfNb=1
+SH.GPXTI5.0=GPIO_EXTI5
+SH.GPXTI5.ConfNb=1
+SH.GPXTI6.0=GPIO_EXTI6
+SH.GPXTI6.ConfNb=1
TIM3.IPParameters=Period,Prescaler,TIM_MasterOutputTrigger
TIM3.Period=65535
TIM3.Prescaler=72-1