mirror of
https://github.com/rene-dev/stmbl.git
synced 2024-12-25 01:52:13 +00:00
comments, cleanup
This commit is contained in:
parent
bca285ee38
commit
0728904359
@ -48,6 +48,7 @@ extern "C" {
|
||||
#define STRINGIFY(x) STRINGIFY_(x)
|
||||
|
||||
//TODO: change type to typeof()
|
||||
//TODO: change __old_val__ to something more useful
|
||||
#define RISING_EDGE(sig)\
|
||||
({static float __old_val__ = 0.0; uint8_t ret = (sig) > __old_val__; __old_val__ = (sig); ret;})
|
||||
|
||||
|
@ -92,60 +92,3 @@ RT(
|
||||
);
|
||||
|
||||
ENDCOMP;
|
||||
|
||||
//http://stackoverflow.com/questions/32947972/stm32-how-to-make-pulse-count-up-down-with-timer
|
||||
// #include "mbed.h"
|
||||
// #include "stm32f4xx.h"
|
||||
// #include "stm32f4xx_hal_tim_ex.h"
|
||||
//
|
||||
// TIM_HandleTypeDef timer;
|
||||
// TIM_Encoder_InitTypeDef encoder;
|
||||
//
|
||||
// //direction to PA_9 -- step to PA_8
|
||||
//
|
||||
// int main(){
|
||||
// GPIO_InitTypeDef GPIO_InitStruct;
|
||||
// __TIM1_CLK_ENABLE();
|
||||
// __GPIOA_CLK_ENABLE();
|
||||
// GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
|
||||
// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
// GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
// GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||
// GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
|
||||
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
//
|
||||
// timer.Instance = TIM1;
|
||||
// timer.Init.Period = 0xffff;
|
||||
// timer.Init.Prescaler = 1;
|
||||
// timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
// timer.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
//
|
||||
//
|
||||
// encoder.EncoderMode = TIM_ENCODERMODE_TI1;
|
||||
// encoder.IC1Filter = 0x0f;
|
||||
// encoder.IC1Polarity = TIM_INPUTCHANNELPOLARITY_RISING; //step signal
|
||||
// encoder.IC1Prescaler = TIM_ICPSC_DIV1;
|
||||
// encoder.IC1Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
//
|
||||
// encoder.IC2Filter = 0x0f;
|
||||
// encoder.IC2Polarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE; //check direction
|
||||
// encoder.IC2Prescaler = TIM_ICPSC_DIV1;
|
||||
// encoder.IC2Selection = TIM_ICSELECTION_INDIRECTTI;
|
||||
//
|
||||
// HAL_TIM_Encoder_Init(&timer, &encoder);
|
||||
// HAL_TIM_Encoder_Start(&timer,TIM_CHANNEL_1);
|
||||
//
|
||||
//
|
||||
// TIM1->EGR = 1; // Generate an update event
|
||||
// TIM1->CR1 = 1; // Enable the counter
|
||||
//
|
||||
//
|
||||
// while (1) {
|
||||
// int16_t count1;
|
||||
// count1=TIM1->CNT;
|
||||
//
|
||||
// printf("%d\r\n", count1);
|
||||
// wait(1.0);
|
||||
//
|
||||
// };
|
||||
// }
|
||||
|
@ -153,6 +153,7 @@ void link_pid(){
|
||||
hal_link_pins("fault0.brake", "io0.brake");
|
||||
hal_link_pins("fault0.hv_fan", "io0.fan");
|
||||
|
||||
//TODO: merge enable_out and enable_pid
|
||||
hal_link_pins("fault0.enable_out", "hv0.enable");
|
||||
hal_link_pins("fault0.enable_pid", "pid0.enable");
|
||||
|
||||
|
@ -313,7 +313,7 @@ int main(void)
|
||||
frt_period_time_hal_pin = hal_map_pin("net0.frt_period");
|
||||
|
||||
link_pid();
|
||||
hal_comp_init();
|
||||
hal_comp_init();//call init function of all comps
|
||||
|
||||
if(hal.pin_errors + hal.comp_errors == 0){
|
||||
hal_start();
|
||||
|
@ -20,7 +20,7 @@
|
||||
#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)
|
||||
#define AMP(a) (((a) * AREF / ARES * (ACS_DOWN + ACS_UP) / ACS_DOWN - ACS_OFFSET) / ACS_VPA)
|
||||
|
||||
#else //iramx v3.1-v3.3 hardware
|
||||
#define RCUR 0.0181//shunt
|
||||
@ -34,12 +34,12 @@
|
||||
#define PWM_V TIM1->CCR2
|
||||
#define PWM_W TIM1->CCR3
|
||||
|
||||
#define AMP(a) ((a * AREF / ARES - AREF / (R10 + R11) * R11) / (RCUR * R10) * (R10 + R11))
|
||||
#define TEMP(a) (log10f(a * AREF / ARES * TPULLUP / (AREF - a * AREF / ARES)) * (-53) + 290)
|
||||
#define AMP(a) (((a) * AREF / ARES - AREF / (R10 + R11) * R11) / (RCUR * R10) * (R10 + R11))
|
||||
#define TEMP(a) (log10f((a) * AREF / ARES * TPULLUP / (AREF - a * AREF / ARES)) * (-53) + 290)
|
||||
|
||||
#endif
|
||||
|
||||
#define VOLT(a) (a / ARES * AREF / VDIVDOWN * (VDIVUP + VDIVDOWN))
|
||||
#define VOLT(a) ((a) / ARES * AREF / VDIVDOWN * (VDIVUP + VDIVDOWN))
|
||||
|
||||
volatile uint16_t ADCConvertedValue[100];//DMA buffer for ADC
|
||||
volatile uint8_t rxbuf[50];//DMA buffer for UART RX
|
||||
|
Loading…
Reference in New Issue
Block a user