|
@@ -13,18 +13,18 @@
|
|
|
Beginning of File, do not put anything above here except notes
|
|
|
Compiler Directives:
|
|
|
*************************************************************************/
|
|
|
-#ifdef RUN_ARCH_SIM
|
|
|
+ #ifdef RUN_ARCH_SIM
|
|
|
#include "switchhall.h"
|
|
|
|
|
|
-SWITCHHALL_OUT switchhall_stOut = SWITCHHALL_OUT_DEFAULT;
|
|
|
+ SWITCHHALL_OUT switchhall_stOut = SWITCHHALL_OUT_DEFAULT;
|
|
|
|
|
|
-void switchhall_voInit(void)
|
|
|
-{}
|
|
|
-void switchhall_voTim3Int(void)
|
|
|
-{}
|
|
|
-void switchhall_voPosCalTbc(void)
|
|
|
-{}
|
|
|
-#else
|
|
|
+ void switchhall_voInit(void)
|
|
|
+ {}
|
|
|
+ void switchhall_voTim3Int(void)
|
|
|
+ {}
|
|
|
+ void switchhall_voPosCalTbc(void)
|
|
|
+ {}
|
|
|
+ #else
|
|
|
#include "gd32f30x.h"
|
|
|
#include "typedefine.h"
|
|
|
#include "syspar.h"
|
|
@@ -80,30 +80,30 @@ static void switchhall_voSectorJudge(void)
|
|
|
{
|
|
|
/* HALLA(PC8), HALLB(PC7), PHALLC(PC6), wzy */
|
|
|
|
|
|
- if(gpio_input_bit_get(GPIOC,GPIO_PIN_6) != 0)
|
|
|
- {
|
|
|
- switchhall_stOut.uwSectorNum = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- switchhall_stOut.uwSectorNum = 1;
|
|
|
- }
|
|
|
- if(gpio_input_bit_get(GPIOC,GPIO_PIN_8) != 0)
|
|
|
- {
|
|
|
- switchhall_stOut.uwSectorNum |= 0<<1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- switchhall_stOut.uwSectorNum |= 1<<1;
|
|
|
- }
|
|
|
- if(gpio_input_bit_get(GPIOC,GPIO_PIN_7) != 0)
|
|
|
- {
|
|
|
- switchhall_stOut.uwSectorNum |= 0<<2;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- switchhall_stOut.uwSectorNum |= 1<<2;
|
|
|
- }
|
|
|
+// if(iGpio_Read(HW_GPIO_HALL_A_PIN) != 0)
|
|
|
+// {
|
|
|
+// switchhall_stOut.uwSectorNum = 0;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// switchhall_stOut.uwSectorNum = 1;
|
|
|
+// }
|
|
|
+// if(iGpio_Read(HW_GPIO_HALL_B_PIN) != 0)
|
|
|
+// {
|
|
|
+// switchhall_stOut.uwSectorNum |= 0<<1;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// switchhall_stOut.uwSectorNum |= 1<<1;
|
|
|
+// }
|
|
|
+// if(iGpio_Read(HW_GPIO_HALL_C_PIN) != 0)
|
|
|
+// {
|
|
|
+// switchhall_stOut.uwSectorNum |= 0<<2;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// switchhall_stOut.uwSectorNum |= 1<<2;
|
|
|
+// }
|
|
|
|
|
|
|
|
|
// switchhall_stOut.uwSectorNum = GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_6);
|
|
@@ -135,49 +135,49 @@ void switchhall_voTim3Int(void)
|
|
|
/* Capture Value */
|
|
|
if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_UP) == SET)
|
|
|
{
|
|
|
- if(curSpeed_state.state == StartUp || curSpeed_state.state == Open2Clz || curSpeed_state.state == ClzLoop)
|
|
|
- {
|
|
|
- if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH0) == SET)
|
|
|
- {
|
|
|
- switchhall_stCap.uwState = (UWORD)timer_channel_capture_value_register_read(TIMER2, TIMER_INT_FLAG_CH0);
|
|
|
- timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH0);
|
|
|
- }
|
|
|
- else if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH1) == SET)
|
|
|
- {
|
|
|
- switchhall_stCap.uwState = (UWORD)timer_channel_capture_value_register_read(TIMER2, TIMER_INT_FLAG_CH1);
|
|
|
- timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH1);
|
|
|
- }
|
|
|
- else if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH2) == SET)
|
|
|
- {
|
|
|
- switchhall_stCap.uwState = (UWORD)timer_channel_capture_value_register_read(TIMER2, TIMER_INT_FLAG_CH2);
|
|
|
- timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH2);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- switchhall_stCap.uwState=0;
|
|
|
- }
|
|
|
+ // if(curSpeed_state.state == StartUp || curSpeed_state.state == Open2Clz || curSpeed_state.state == ClzLoop)
|
|
|
+ // {
|
|
|
+ // if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH0) == SET)
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwState = (UWORD)timer_channel_capture_value_register_read(TIMER2, TIMER_INT_FLAG_CH0);
|
|
|
+ // timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH0);
|
|
|
+ // }
|
|
|
+ // else if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH1) == SET)
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwState = (UWORD)timer_channel_capture_value_register_read(TIMER2, TIMER_INT_FLAG_CH1);
|
|
|
+ // timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH1);
|
|
|
+ // }
|
|
|
+ // else if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH2) == SET)
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwState = (UWORD)timer_channel_capture_value_register_read(TIMER2, TIMER_INT_FLAG_CH2);
|
|
|
+ // timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH2);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwState=0;
|
|
|
+ // }
|
|
|
|
|
|
- if (switchhall_stCap.uwState > timer_counter_read(TIMER2))
|
|
|
- {
|
|
|
- switchhall_stCap.ulCapValue = switchhall_stCap.uwState;
|
|
|
- switchhall_stCap.slCapValueDelta = (SLONG)switchhall_stCap.uwCaptureOverFlowCnt * 60000 + (SLONG)switchhall_stCap.ulCapValue - (SLONG)switchhall_stCap.ulCapValuePre;
|
|
|
- switchhall_stCap.uwCaptureOverFlowCnt ++;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- switchhall_stCap.uwCaptureOverFlowCnt ++;
|
|
|
- }
|
|
|
+ // if (switchhall_stCap.uwState > timer_counter_read(TIMER2))
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.ulCapValue = switchhall_stCap.uwState;
|
|
|
+ // switchhall_stCap.slCapValueDelta = (SLONG)switchhall_stCap.uwCaptureOverFlowCnt * 60000 + (SLONG)switchhall_stCap.ulCapValue - (SLONG)switchhall_stCap.ulCapValuePre;
|
|
|
+ // switchhall_stCap.uwCaptureOverFlowCnt ++;
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwCaptureOverFlowCnt ++;
|
|
|
+ // }
|
|
|
|
|
|
- if (switchhall_stCap.uwCaptureOverFlowCnt > 3000)
|
|
|
- {
|
|
|
- switchhall_stCap.uwCaptureOverFlowCnt=0;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- switchhall_stCap.uwCaptureOverFlowCnt = 0;
|
|
|
- }
|
|
|
-
|
|
|
+ // if (switchhall_stCap.uwCaptureOverFlowCnt > 3000)
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwCaptureOverFlowCnt=0;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // switchhall_stCap.uwCaptureOverFlowCnt = 0;
|
|
|
+ // }
|
|
|
+ switchhall_stCap.uwCaptureOverFlowCnt ++;
|
|
|
timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_UP);
|
|
|
}
|
|
|
else if (timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH0)== SET)
|