You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
1.9 KiB
88 lines
1.9 KiB
#ifndef __COMMON_H
|
|
#define __COMMON_H
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "stdint.h"
|
|
#include <stdlib.h>
|
|
#include "stdbool.h"
|
|
#include "usart.h"
|
|
#include "stm32f10x.h"
|
|
#include "Common_Type.h"
|
|
#include "kernel.h"
|
|
#include "time.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#pragma anon_unions
|
|
|
|
#define GPIO_Type GPIO_TypeDef
|
|
|
|
#undef NULL
|
|
#define NULL ((void *)0)
|
|
|
|
//#define TRUE 1
|
|
//#define FALSE 0
|
|
|
|
//CAN
|
|
#define IOCTL_CMD_CAN_FILTER_ADD 1 //添加过滤器
|
|
#define IOCTL_CMD_CAN_FILTER_MASK_ADD 2 //添加过滤器掩码
|
|
#define IOCTL_CMD_CAN_FILTER_INIT 3 //初始化过滤器
|
|
#define IOCTL_CAN_SET_FILTER_ALL 4 //全接收模式
|
|
#define IOCTL_CAN_CLEAR_RXBUFF 5 //清除缓冲区
|
|
#define IOCTL_CAN_GET_NEXTMAILID 6 //获取下一封邮箱的CAN ID
|
|
|
|
|
|
#define TASK_LOCK \
|
|
{ \
|
|
__disable_irq();
|
|
#define TASK_UNLOCK \
|
|
__enable_irq(); \
|
|
}
|
|
|
|
|
|
#define DISABLE_IRQ(IRQChannel) NVIC->ICER[IRQChannel >> 0x05] = (uint32_t)0x01 << (IRQChannel & (uint8_t)0x1F)
|
|
|
|
#define ENABLE_IRQ(IRQChannel) NVIC->ISER[IRQChannel >> 0x05] = (uint32_t)0x01 << (IRQChannel & (uint8_t)0x1F)
|
|
|
|
|
|
extern unsigned short int Get1MsTickVal(void);
|
|
#define clock() Get1MsTickVal()
|
|
|
|
extern void Delay_ms(uint16_t ms);
|
|
#define sleep(ms) Delay_ms(ms)
|
|
|
|
typedef enum
|
|
{
|
|
INSTANCE_CAN1 = 0,
|
|
INSTANCE_CAN2
|
|
} can_instance;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
INT16U SlowRecoverCounter; /* 慢恢复时间, 单位1ms */
|
|
INT16U FastRecoverCounter; /* 快恢复时间, 单位1ms */
|
|
INT16U Threshold; /* 快恢复转到慢恢复阈值 */
|
|
INT16U DtcOccurCnt; /* 连续多少次产生Busoff DTC */
|
|
INT16U BusOffRecoverTime; /* Message received AND message sent on CAN successfully 连续时间 */
|
|
} tCanBusOffConfigTyp;
|
|
|
|
|
|
typedef enum
|
|
{
|
|
st_BusNormal,
|
|
st_BusOff
|
|
} eBusOffStateType;
|
|
|
|
typedef struct
|
|
{
|
|
INT8U Can1_BusOff_Flag;
|
|
INT8U Can2_BusOff_Flag;
|
|
} BusOff_t;
|
|
|
|
extern BusOff_t x_BusOff;
|
|
|
|
extern int h_can1;
|
|
|
|
#endif
|
|
|