stmbl/stm32f303/troller.txt

76 lines
1.8 KiB
Plaintext

#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;