correct compile error when using can
This commit is contained in:
parent
405a184920
commit
33de63fbe2
|
@ -15,6 +15,7 @@
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <rtdevice.h>
|
#include <rtdevice.h>
|
||||||
|
#include "gpio.h"
|
||||||
#ifdef RT_USING_CAN
|
#ifdef RT_USING_CAN
|
||||||
#define CANRT1 8
|
#define CANRT1 8
|
||||||
#define CANERR1 9
|
#define CANERR1 9
|
||||||
|
@ -28,8 +29,8 @@ static struct canledtype
|
||||||
{
|
{
|
||||||
#ifdef USING_BXCAN1
|
#ifdef USING_BXCAN1
|
||||||
{
|
{
|
||||||
{CANRT1, PIN_MODE_OUTPUT_OD,},
|
{CANRT1, PIN_MODE_OUTPUT,},
|
||||||
{CANERR1, PIN_MODE_OUTPUT_OD,},
|
{CANERR1, PIN_MODE_OUTPUT,},
|
||||||
},
|
},
|
||||||
#endif /*USING_BXCAN1*/
|
#endif /*USING_BXCAN1*/
|
||||||
#ifdef USING_BXCAN2
|
#ifdef USING_BXCAN2
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#define RT_USING_UART1
|
#define RT_USING_UART1
|
||||||
#define RT_USING_UART2
|
#define RT_USING_UART2
|
||||||
#define RT_USING_UART3
|
#define RT_USING_UART3
|
||||||
|
#define USING_BXCAN1
|
||||||
|
|
||||||
void rt_hw_board_init(void);
|
void rt_hw_board_init(void);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,12 @@
|
||||||
#define BX_CAN_FMRNUMBER 28
|
#define BX_CAN_FMRNUMBER 28
|
||||||
#define BX_CAN2_FMRSTART 14
|
#define BX_CAN2_FMRSTART 14
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef STM32F10X_HD
|
||||||
|
#undef USING_BXCAN2
|
||||||
|
|
||||||
|
#define CAN1_RX0_IRQn USB_LP_CAN1_RX0_IRQn
|
||||||
|
#define CAN1_TX_IRQn USB_HP_CAN1_TX_IRQn
|
||||||
|
#endif
|
||||||
#define BX_CAN_MAX_FILTERS (BX_CAN_FMRNUMBER * 4)
|
#define BX_CAN_MAX_FILTERS (BX_CAN_FMRNUMBER * 4)
|
||||||
#define BX_CAN_MAX_FILTER_MASKS BX_CAN_MAX_FILTERS
|
#define BX_CAN_MAX_FILTER_MASKS BX_CAN_MAX_FILTERS
|
||||||
#define BX_CAN_FILTER_MAX_ARRAY_SIZE ((BX_CAN_MAX_FILTERS + 32 - 1) / 32)
|
#define BX_CAN_FILTER_MAX_ARRAY_SIZE ((BX_CAN_MAX_FILTERS + 32 - 1) / 32)
|
||||||
|
@ -148,6 +153,7 @@ static void bxcan1_filter_init(struct rt_can_device *can)
|
||||||
}
|
}
|
||||||
calcfiltermasks(pbxcan);
|
calcfiltermasks(pbxcan);
|
||||||
}
|
}
|
||||||
|
#ifdef USING_BXCAN2
|
||||||
static void bxcan2_filter_init(struct rt_can_device *can)
|
static void bxcan2_filter_init(struct rt_can_device *can)
|
||||||
{
|
{
|
||||||
rt_uint32_t i;
|
rt_uint32_t i;
|
||||||
|
@ -234,6 +240,8 @@ static void bxcan2_filter_init(struct rt_can_device *can)
|
||||||
}
|
}
|
||||||
calcfiltermasks(pbxcan);
|
calcfiltermasks(pbxcan);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BS1SHIFT 16
|
#define BS1SHIFT 16
|
||||||
#define BS2SHIFT 20
|
#define BS2SHIFT 20
|
||||||
#define RRESCLSHIFT 0
|
#define RRESCLSHIFT 0
|
||||||
|
@ -320,6 +328,7 @@ static void bxcan1_hw_init(void)
|
||||||
NVIC_InitStructure.NVIC_IRQChannel = CAN1_TX_IRQn;
|
NVIC_InitStructure.NVIC_IRQChannel = CAN1_TX_IRQn;
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
|
#ifdef USING_BXCAN2
|
||||||
static void bxcan2_hw_init(void)
|
static void bxcan2_hw_init(void)
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
@ -345,6 +354,7 @@ static void bxcan2_hw_init(void)
|
||||||
NVIC_InitStructure.NVIC_IRQChannel = CAN2_TX_IRQn;
|
NVIC_InitStructure.NVIC_IRQChannel = CAN2_TX_IRQn;
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
static inline rt_err_t bxcan_enter_init(CAN_TypeDef *pcan)
|
static inline rt_err_t bxcan_enter_init(CAN_TypeDef *pcan)
|
||||||
{
|
{
|
||||||
uint32_t wait_ack = 0x00000000;
|
uint32_t wait_ack = 0x00000000;
|
||||||
|
@ -1010,9 +1020,11 @@ static rt_err_t configure(struct rt_can_device *can, struct can_configure *cfg)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef USING_BXCAN2
|
||||||
bxcan2_hw_init();
|
bxcan2_hw_init();
|
||||||
bxcan_init(pbxcan, cfg->baud_rate, can->config.mode);
|
bxcan_init(pbxcan, cfg->baud_rate, can->config.mode);
|
||||||
bxcan2_filter_init(can);
|
bxcan2_filter_init(can);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,41 @@
|
||||||
|
|
||||||
#ifndef BXCAN_H_
|
#ifndef BXCAN_H_
|
||||||
#define BXCAN_H_
|
#define BXCAN_H_
|
||||||
|
/* CAN Master Control Register bits */
|
||||||
|
|
||||||
|
#define MCR_DBF ((uint32_t)0x00010000) /* software master reset */
|
||||||
|
|
||||||
|
/* CAN Mailbox Transmit Request */
|
||||||
|
#define TMIDxR_TXRQ ((uint32_t)0x00000001) /* Transmit mailbox request */
|
||||||
|
|
||||||
|
/* CAN Filter Master Register bits */
|
||||||
|
#define FMR_FINIT ((uint32_t)0x00000001) /* Filter init mode */
|
||||||
|
|
||||||
|
/* Time out for INAK bit */
|
||||||
|
#define INAK_TIMEOUT ((uint32_t)0x0000FFFF)
|
||||||
|
/* Time out for SLAK bit */
|
||||||
|
#define SLAK_TIMEOUT ((uint32_t)0x0000FFFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Flags in TSR register */
|
||||||
|
#define CAN_FLAGS_TSR ((uint32_t)0x08000000)
|
||||||
|
/* Flags in RF1R register */
|
||||||
|
#define CAN_FLAGS_RF1R ((uint32_t)0x04000000)
|
||||||
|
/* Flags in RF0R register */
|
||||||
|
#define CAN_FLAGS_RF0R ((uint32_t)0x02000000)
|
||||||
|
/* Flags in MSR register */
|
||||||
|
#define CAN_FLAGS_MSR ((uint32_t)0x01000000)
|
||||||
|
/* Flags in ESR register */
|
||||||
|
#define CAN_FLAGS_ESR ((uint32_t)0x00F00000)
|
||||||
|
|
||||||
|
/* Mailboxes definition */
|
||||||
|
#define CAN_TXMAILBOX_0 ((uint8_t)0x00)
|
||||||
|
#define CAN_TXMAILBOX_1 ((uint8_t)0x01)
|
||||||
|
#define CAN_TXMAILBOX_2 ((uint8_t)0x02)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define CAN_MODE_MASK ((uint32_t) 0x00000003)
|
||||||
|
|
||||||
#endif /*BXCAN_H_*/
|
#endif /*BXCAN_H_*/
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
#include <rtdevice.h>
|
#include <rtdevice.h>
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
|
#include <gpio.h>
|
||||||
|
|
||||||
#ifdef RT_USING_PIN
|
#ifdef RT_USING_PIN
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,17 @@
|
||||||
#ifndef GPIO_H__
|
#ifndef GPIO_H__
|
||||||
#define GPIO_H__
|
#define GPIO_H__
|
||||||
|
|
||||||
|
|
||||||
|
struct stm32_hw_pin_userdata
|
||||||
|
{
|
||||||
|
int pin;
|
||||||
|
uint32_t mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PIN_USERDATA_END {-1,0}
|
||||||
|
|
||||||
|
extern struct stm32_hw_pin_userdata stm32_pins[];
|
||||||
|
|
||||||
int stm32_hw_pin_init(void);
|
int stm32_hw_pin_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F103ZE</Device>
|
<Device>STM32F103ZE</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F1xx_DFP.1.0.5</PackID>
|
<PackID>Keil.STM32F1xx_DFP.1.1.0</PackID>
|
||||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IROM(0x08000000,0x80000) IRAM(0x20000000,0x10000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
<Cpu>IROM(0x08000000,0x80000) IRAM(0x20000000,0x10000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
|
@ -37,8 +37,8 @@
|
||||||
<BinPath></BinPath>
|
<BinPath></BinPath>
|
||||||
<IncludePath></IncludePath>
|
<IncludePath></IncludePath>
|
||||||
<LibPath></LibPath>
|
<LibPath></LibPath>
|
||||||
<RegisterFilePath>ST\STM32F10x\</RegisterFilePath>
|
<RegisterFilePath></RegisterFilePath>
|
||||||
<DBRegisterFilePath>ST\STM32F10x\</DBRegisterFilePath>
|
<DBRegisterFilePath></DBRegisterFilePath>
|
||||||
<TargetStatus>
|
<TargetStatus>
|
||||||
<Error>0</Error>
|
<Error>0</Error>
|
||||||
<ExitCodeStop>0</ExitCodeStop>
|
<ExitCodeStop>0</ExitCodeStop>
|
||||||
|
@ -84,6 +84,8 @@
|
||||||
<UserProg2Name></UserProg2Name>
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
|
<nStopA1X>0</nStopA1X>
|
||||||
|
<nStopA2X>0</nStopA2X>
|
||||||
</AfterMake>
|
</AfterMake>
|
||||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||||
<SVCSIdString></SVCSIdString>
|
<SVCSIdString></SVCSIdString>
|
||||||
|
@ -106,13 +108,13 @@
|
||||||
</CommonProperty>
|
</CommonProperty>
|
||||||
<DllOption>
|
<DllOption>
|
||||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||||
<SimDllArguments></SimDllArguments>
|
<SimDllArguments> -REMAP</SimDllArguments>
|
||||||
<SimDlgDll>DARMSTM.DLL</SimDlgDll>
|
<SimDlgDll>DCM.DLL</SimDlgDll>
|
||||||
<SimDlgDllArguments>-pSTM32F103ZE</SimDlgDllArguments>
|
<SimDlgDllArguments>-pCM3</SimDlgDllArguments>
|
||||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||||
<TargetDllArguments></TargetDllArguments>
|
<TargetDllArguments></TargetDllArguments>
|
||||||
<TargetDlgDll>TARMSTM.DLL</TargetDlgDll>
|
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
||||||
<TargetDlgDllArguments>-pSTM32F103ZE</TargetDlgDllArguments>
|
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
|
||||||
</DllOption>
|
</DllOption>
|
||||||
<DebugOption>
|
<DebugOption>
|
||||||
<OPTHX>
|
<OPTHX>
|
||||||
|
@ -147,7 +149,7 @@
|
||||||
<RestoreSysVw>1</RestoreSysVw>
|
<RestoreSysVw>1</RestoreSysVw>
|
||||||
</Target>
|
</Target>
|
||||||
<RunDebugAfterBuild>0</RunDebugAfterBuild>
|
<RunDebugAfterBuild>0</RunDebugAfterBuild>
|
||||||
<TargetSelection>6</TargetSelection>
|
<TargetSelection>1</TargetSelection>
|
||||||
<SimDlls>
|
<SimDlls>
|
||||||
<CpuDll></CpuDll>
|
<CpuDll></CpuDll>
|
||||||
<CpuDllArguments></CpuDllArguments>
|
<CpuDllArguments></CpuDllArguments>
|
||||||
|
@ -161,7 +163,7 @@
|
||||||
<PeripheralDll></PeripheralDll>
|
<PeripheralDll></PeripheralDll>
|
||||||
<PeripheralDllArguments></PeripheralDllArguments>
|
<PeripheralDllArguments></PeripheralDllArguments>
|
||||||
<InitializationFile></InitializationFile>
|
<InitializationFile></InitializationFile>
|
||||||
<Driver>Segger\JL2CM3.dll</Driver>
|
<Driver>BIN\UL2CM3.DLL</Driver>
|
||||||
</TargetDlls>
|
</TargetDlls>
|
||||||
</DebugOption>
|
</DebugOption>
|
||||||
<Utilities>
|
<Utilities>
|
||||||
|
@ -171,10 +173,10 @@
|
||||||
<RunIndependent>0</RunIndependent>
|
<RunIndependent>0</RunIndependent>
|
||||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||||
<Capability>1</Capability>
|
<Capability>1</Capability>
|
||||||
<DriverSelection>4099</DriverSelection>
|
<DriverSelection>4096</DriverSelection>
|
||||||
</Flash1>
|
</Flash1>
|
||||||
<bUseTDR>1</bUseTDR>
|
<bUseTDR>1</bUseTDR>
|
||||||
<Flash2>Segger\JL2CM3.dll</Flash2>
|
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||||
<Flash3>"" ()</Flash3>
|
<Flash3>"" ()</Flash3>
|
||||||
<Flash4></Flash4>
|
<Flash4></Flash4>
|
||||||
<pFcarmOut></pFcarmOut>
|
<pFcarmOut></pFcarmOut>
|
||||||
|
@ -359,11 +361,13 @@
|
||||||
<wLevel>0</wLevel>
|
<wLevel>0</wLevel>
|
||||||
<uThumb>0</uThumb>
|
<uThumb>0</uThumb>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<uC99>0</uC99>
|
<uC99>1</uC99>
|
||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
|
<v6Lang>0</v6Lang>
|
||||||
|
<v6LangP>0</v6LangP>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls></MiscControls>
|
||||||
<Define>STM32F10X_HD, USE_STDPERIPH_DRIVER</Define>
|
<Define>USE_STDPERIPH_DRIVER</Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>.;..\..\components\CMSIS\Include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\init;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m3;Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;Libraries\STM32F10x_StdPeriph_Driver\inc;applications;drivers</IncludePath>
|
<IncludePath>.;..\..\components\CMSIS\Include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\init;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m3;Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;Libraries\STM32F10x_StdPeriph_Driver\inc;applications;drivers</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
|
@ -398,7 +402,7 @@
|
||||||
<ScatterFile></ScatterFile>
|
<ScatterFile></ScatterFile>
|
||||||
<IncludeLibs></IncludeLibs>
|
<IncludeLibs></IncludeLibs>
|
||||||
<IncludeLibsPath></IncludeLibsPath>
|
<IncludeLibsPath></IncludeLibsPath>
|
||||||
<Misc> --keep __fsym_* --keep __vsym_* --keep __rt_init* </Misc>
|
<Misc>--keep __fsym_* --keep __vsym_* --keep __rt_init*</Misc>
|
||||||
<LinkerInputFile></LinkerInputFile>
|
<LinkerInputFile></LinkerInputFile>
|
||||||
<DisabledWarnings></DisabledWarnings>
|
<DisabledWarnings></DisabledWarnings>
|
||||||
</LDads>
|
</LDads>
|
||||||
|
@ -418,6 +422,11 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>applications\startup.c</FilePath>
|
<FilePath>applications\startup.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>canapp.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\applications\canapp.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -443,6 +452,16 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>drivers\usart.c</FilePath>
|
<FilePath>drivers\usart.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>bxcan.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\drivers\bxcan.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>gpio.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\drivers\gpio.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -708,6 +727,16 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\components\drivers\src\workqueue.c</FilePath>
|
<FilePath>..\..\components\drivers\src\workqueue.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>pin.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\components\drivers\misc\pin.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>can.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\..\components\drivers\can\can.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -786,7 +815,7 @@
|
||||||
<File>
|
<File>
|
||||||
<FileName>components.c</FileName>
|
<FileName>components.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\..\components\init\components.c</FilePath>
|
<FilePath>..\..\src\components.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
@ -80,6 +80,13 @@
|
||||||
#define FINSH_USING_SYMTAB
|
#define FINSH_USING_SYMTAB
|
||||||
#define FINSH_USING_DESCRIPTION
|
#define FINSH_USING_DESCRIPTION
|
||||||
|
|
||||||
|
#define RT_USING_PIN
|
||||||
|
|
||||||
|
#define RT_USING_CAN
|
||||||
|
|
||||||
|
#define RT_CAN_USING_BUS_HOOK
|
||||||
|
|
||||||
|
#define RT_CAN_USING_HDR
|
||||||
/* SECTION: device filesystem */
|
/* SECTION: device filesystem */
|
||||||
/* #define RT_USING_DFS */
|
/* #define RT_USING_DFS */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue