-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathhwdefs.h
53 lines (42 loc) · 1.87 KB
/
hwdefs.h
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
#ifndef HWDEFS_H_INCLUDED
#define HWDEFS_H_INCLUDED
//Common for any config
//Maximum value for over current limit timer
#define OCURMAX 4096
#define USART_BAUDRATE 115200
//Maximum PWM frequency is 36MHz/2^MIN_PWM_DIGITS
#define MIN_PWM_DIGITS 11
#define PWM_TIMER TIM1
#define PWM_TIMRST RST_TIM1
#define PWM_TIMER_IRQ NVIC_TIM1_UP_IRQ
#define pwm_timer_isr tim1_up_isr
#define REV_CNT_RCC_ENR RCC_APB1ENR_TIM3EN
#define rev_timer_isr tim3_isr
#define REV_CNT_TIMER TIM3
#define REV_CNT_TIMRST RST_TIM3
#define OVER_CUR_TIMER hwRev == HW_BLUEPILL ? TIM2 : TIM4
#define OVER_CUR_NEG hwRev == HW_BLUEPILL ? TIM_OC1 : TIM_OC2
#define OVER_CUR_POS hwRev == HW_BLUEPILL ? TIM_OC2 : TIM_OC3
//Address of parameter block in flash
#define FLASH_PAGE_SIZE 1024
#define PARAM_BLKSIZE FLASH_PAGE_SIZE
#define PARAM_BLKNUM 1 //last block of 1k
#define CAN_BLKSIZE 1024
#define CAN1_BLKNUM 2 //second to last block of 1k
#define CAN2_BLKNUM 4 //second to last block of 1k
#define REV_CNT_IC hwRev == HW_REV1 ? TIM_IC3 : TIM_IC1
#define REV_CNT_OC hwRev == HW_REV1 ? TIM_OC3 : TIM_OC1
#define REV_CNT_CCR hwRev == HW_REV1 ? TIM3_CCR3 : TIM3_CCR1
#define REV_CNT_CCR_PTR hwRev == HW_REV1 ? (uint32_t)&TIM3_CCR3 : (uint32_t)&TIM3_CCR1
#define REV_CNT_SR hwRev == HW_REV1 ? TIM_SR_CC3IF : TIM_SR_CC1IF
#define REV_CNT_DMAEN hwRev == HW_REV1 ? TIM_DIER_CC3DE : TIM_DIER_CC1DE
#define REV_CNT_DMACHAN hwRev == HW_REV1 ? DMA_CHANNEL2 : DMA_CHANNEL6
#define NORTH_EXC_PORT hwRev == HW_BLUEPILL ? GPIOC : GPIOD
#define NORTH_EXC_PIN hwRev == HW_BLUEPILL ? GPIO14 : GPIO2
#define NORTH_EXC_EXTI hwRev == HW_BLUEPILL ? EXTI14 : EXTI2
typedef enum
{
HW_REV1, HW_REV2, HW_REV3, HW_TESLA, HW_BLUEPILL, HW_PRIUS, HW_MINI, HW_LEAF2, HW_LEAF3, HW_BMWI3
} HWREV;
extern HWREV hwRev;
#endif // HWDEFS_H_INCLUDED