-
Notifications
You must be signed in to change notification settings - Fork 410
/
Copy pathtroller.txt
76 lines (63 loc) · 1.85 KB
/
troller.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#define ADC_channels 4
#define VDIVUP 1000000.0
#define VDIVDOWN 4990.0
#define PWM_U TIM1->CCR3
#define PWM_V TIM1->CCR2
#define PWM_W TIM1->CCR1
#define ACS_VPA 0.066 // ACS712 V/A
#define ACS_UP 2000.0
#define ACS_DOWN 3000.0
#define ACS_OFFSET 2.5
#define AMP(a) (((a) * AREF / ARES * (ACS_DOWN + ACS_UP) / ACS_DOWN - ACS_OFFSET) / ACS_VPA)
#else //iramx v3.1-v3.3 hardware
#ifdef TROLLER
//PINA0 IN0 DC link
//PINA6 IN6 iu
//PINA7 IN7 iv
//PINB0 IN8 iw
//PINA5 IN5 uu
//PINA4 IN4 uv
//PINA1 IN1 uw
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOB, &GPIO_InitStructure);
#else
void hv_enable(){
#ifdef TROLLER
GPIO_SetBits(GPIOB,GPIO_Pin_1);
GPIO_SetBits(GPIOB,GPIO_Pin_2);
GPIO_SetBits(GPIOB,GPIO_Pin_3);
#else
GPIO_SetBits(GPIOB,GPIO_Pin_6);
#endif
hv_enabled = 1;
}
void hv_disable(){
#ifdef TROLLER
GPIO_ResetBits(GPIOB,GPIO_Pin_1);
GPIO_ResetBits(GPIOB,GPIO_Pin_2);
GPIO_ResetBits(GPIOB,GPIO_Pin_3);
#else
GPIO_ResetBits(GPIOB,GPIO_Pin_6);
#endif
hv_enabled = 0;
}
#ifdef TROLLER
//shutdown pins
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//GPIO_ResetBits(GPIOC,GPIO_Pin_2);//green led off
#else
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
#ifdef TROLLER
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
#else
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
#endif
TIM_OCInitStructure.TIM_Pulse = 0;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;