AURIX Development Studio软件
[*]AURIX™ Development Studio 简称:ADS . 它是一个免费为初级阶段的开发者提供了简易的开发包的集成开发环境(IDE),包括Eclipse IDE、C编译器、多核调试器、英飞凌低层驱动程序(iLLD),没有时间和代码大小限制,允许编辑、编译和调试应用程序代码。结合大量的代码示例项目,该IDE可以用来评估AURIX™微控制器家族强大的体系结构,方便好用。
官方下载链接:AURIX™ Development Studio - Infineon Developer Centerhttps://community.infineon.com/t5/image/serverpage/image-id/110568i68D29CC4F3BD4A56/image-dimensions/778x519?v=v2
[*]AURIX™ Development Studio环境配置可参考以下链接文档(选择相应的Aurix MCU型号):
Getting Started with AURIX™ Development Studio Installation and first steps (infineon.com)
3.PinMap设定:第一步:使用ASCLIN的SPI功能,将CS(P20.8),SCL(P20.8), MOSI(P15.0) MISO(P15.1), ERUIN0(P10.7), ERUIN0(P10.8)对应MCU引脚设定好.、https://community.infineon.com/t5/image/serverpage/image-id/110569i80856C2BBCF9DA3D/image-dimensions/745x512?v=v2https://community.infineon.com/t5/image/serverpage/image-id/110570i1B810827A08C4026/image-dimensions/727x360?v=v2https://community.infineon.com/t5/image/serverpage/image-id/110571iA4AF411C86E3E65B/image-dimensions/788x459?v=v2https://community.infineon.com/t5/image/serverpage/image-id/110574iE18B9B51273113E7/image-dimensions/781x365?v=v2第二步:对原厂iLLD提供的IfxAsclin_Spi.h做一下接口的参数封装代码如下SCLIN_SPI_Master.h#ifndef ASCLIN_SPI_MASTER_H _#define ASCLIN_SPI_MASTER_H_ void init_ASCLIN_SPI_master(void); void exchange_ASCLIN_SPI_message(void);#endif /* ASCLIN_SPI_MASTER_H_ */
ASCLIN_SPI_Master.C#include "IfxAsclin_Spi.h" /*********************************************************************************************************************/ /*------------------------------------------------------Macros-------------------------------------------------------*/ /*********************************************************************************************************************/ #define SPI_BUFFER_SIZE 2 /* Size of the SPI buffer in bytes*/ #define BAUDRATE 115200 /* Define baud rate in bit/s */ #define PRESCALER 1 /* Define prescaler */ #define IFX_INTPRIO_ASCLIN1_TX 1 /* Define TX interrupt priority */ #define IFX_INTPRIO_ASCLIN1_RX 2 /* Define RX interrupt priority */ #define CLOCK_PIN IfxAsclin1_SCLK_P20_10_OUT /* Define Clock port pin */ #define MTSR_PIN IfxAsclin1_TX_P15_0_OUT /* Define MTSR port pin */ #define MRST_PIN IfxAsclin1_RXA_P15_1_IN /* Define MRST port pin */ #define CS1_PIN IfxAsclin1_SLSO_P20_8_OUT /* DefineCS1 port pin */ /*********************************************************************************************************************/ /*-------------------------------------------------Global variables--------------------------------------------------*/ /*********************************************************************************************************************/ IfxAsclin_Spi g_spiHandle; uint8 g_spiTxBuffer[] = {0X20,0}; uint8 g_spiRxBuffer; uint8 Read1; uint8 Write1; /*********************************************************************************************************************/ /*---------------------------------------------Function Implementations----------------------------------------------*/ /*********************************************************************************************************************/ /* Add SPI Interrupt Service Routines */ IFX_INTERRUPT(asclin1TxISR, 0, IFX_INTPRIO_ASCLIN1_TX); /* Transmit interrupt function */ void asclin1TxISR(void) { IfxAsclin_Spi_isrTransmit(&g_spiHandle); } IFX_INTERRUPT(asclin1RxISR, 0, IFX_INTPRIO_ASCLIN1_RX); /* Receive interrupt function */ void asclin1RxISR(void) { IfxAsclin_Spi_isrReceive(&g_spiHandle); } /* This function initializes the ASCLIN SPI module in master mode */void init_ASCLIN_SPI_master(void) { /* Initialize one instance of IfxAsclin_Spi_Config with defaultvalues */ IfxAsclin_Spi_Config spiMasterConfig; IfxAsclin_Spi_initModuleConfig(&spiMasterConfig, &MODULE_ASCLIN1); /* Set the desired baud rate */ spiMasterConfig.baudrate.prescaler = PRESCALER; spiMasterConfig.baudrate.baudrate = BAUDRATE; /* ISR priorities and service provider */ spiMasterConfig.interrupt.txPriority = IFX_INTPRIO_ASCLIN1_TX; spiMasterConfig.interrupt.rxPriority = IFX_INTPRIO_ASCLIN1_RX; spiMasterConfig.interrupt.typeOfService = IfxSrc_Tos_cpu0;
/* Pin configuration */ const IfxAsclin_Spi_Pins pins = { &CLOCK_PIN, IfxPort_OutputMode_pushPull, /* Clock output portpin (CLK) */ &MRST_PIN, IfxPort_InputMode_pullUp, /* MRST port pin (MISO)*/ &MTSR_PIN, IfxPort_OutputMode_pushPull, /* MTSR port pin (MOSI)*/ &CS1_PIN , IfxPort_OutputMode_pushPull, /* cs1 port pin (cs1)*/ IfxPort_PadDriver_cmosAutomotiveSpeed4 }; spiMasterConfig.pins = &pins; /* Initialize module with the above parameters */ IfxAsclin_Spi_initModule(&g_spiHandle, &spiMasterConfig); } /* This function exchanges a two bytes message */ void exchange_ASCLIN_SPI_message(void) { /* Exchange the two bytes message */ IfxAsclin_Spi_exchange(&g_spiHandle, g_spiTxBuffer,g_spiRxBuffer, SPI_BUFFER_SIZE); }
第三步:写传感器寄存器访问逻辑(读IIS3DWB寄存器地址20H和21H的值)Cpu0_Main.c
#include "Ifx_Types.h" #include "IfxCpu.h" #include "IfxScuWdt.h" #include "Ifx_Types.h" #include "IfxCpu.h" #include "IfxScuWdt.h" #include "ASCLIN_SPI_Master.h" #include "Bsp.h" extern uint8g_spiTxBuffer[];/*Link Transmit TX message buffer */ extern uint8g_spiRxBuffer[];/*Link Receive RX message buffer */ uint8 RX1L; uint8 RX1H; IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0; void core0_main(void) { IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!! * Enable the watchdogs and service them periodically if it is required */ IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword()); IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */ IfxCpu_emitEvent(&g_cpuSyncEvent); IfxCpu_waitEvent(&g_cpuSyncEvent, 1); init_ASCLIN_SPI_master();/*Initialized SPI */ while(1) { g_spiTxBuffer=0x20U;/* Assign access address 20H*/ exchange_ASCLIN_SPI_message(); /*Sent the address& get data */ RX1L= g_spiRxBuffer;/*Get Sensor Low 8 bit data */ waitTime(1000000); g_spiTxBuffer=0x21U;/* Assign access address 21H*/ exchange_ASCLIN_SPI_message(); RX1H= g_spiRxBuffer; /*Get Sensor High 8 bit data */ DATA=RX1H<<8|RX1L;/*High and low 8-bit data merge */ waitTime(100000000);/*Wait time for next*/
} } 第四步:编译及Flash写入程序:https://community.infineon.com/t5/image/serverpage/image-id/110575iEA269C2D035BF987/image-dimensions/756x745?v=v2第五步:启动程序调试,用示波器或逻辑分析仪检测查看波形https://community.infineon.com/t5/image/serverpage/image-id/110576i12D17044D6525FD8/image-dimensions/770x439?v=v2 (黄色为CS,绿色为主机输出)https://community.infineon.com/t5/image/serverpage/image-id/110578iCA5DE882AB92463B/image-dimensions/801x679?v=v2 (黄色主机发送,绿色主机接收,相位没调,实际相差8个bit时间)
环境IDE搭建很有必要
页:
[1]