#include "main.h" #include "spi_func.h" #include "spidev.h" #include "CddSbc.h" #include "CddBoost.h" #include "CddSpi.h" #include "Dio_Cfg.h" static int gcd(int a, int b) ; static int lcm_multiple(int numbers[], int length); int32_t TIMER_FLAGS[ ] = {1,2,5,10,100,150,200,1000}; int32_t TIMER_RELOADValue = 1000; uint8 Spi_Stat = 0; Std_VersionInfoType Ex_Spi_VersionInfo; void InitSPI(void) { MCALLIB_DEV_ASSERT_START(); #if EN_SPI #if(SPI_PRECOMPILE_SUPPORT == STD_ON) Spi_Init(NULL_PTR); #else Spi_Init(&Spi_Config); #endif Spi_GetVersionInfo(&Ex_Spi_VersionInfo); Spi_Stat = 1; /*get timer lcm*/ TIMER_RELOADValue = lcm_multiple(TIMER_FLAGS,sizeof(TIMER_FLAGS)/sizeof(uint32_t)); MCALLIB_DEV_ASSERT(TIMER_RELOADValue>0); #if (SBCTEST) //GMX /* boost Enable pin pull-high */ CddBoost_IOInit(); CddSbc_Init(); // CddSbc_SetWdgWindowModeAnd200ms(); CddSbc_SetWdgTimeoutModeAnd200ms(); //change Watch dog is independent #endif Gpt_EnableNotification(GptConf_GptChannelConfiguration_GptChlSPI); Gpt_StartTimer(GptConf_GptChannelConfiguration_GptChlSPI, 1000); //start GPT for SPI InitSPI_Dev(); #endif MCALLIB_DEV_ASSERT_END(); } static int gcd(int a, int b) { while (b != 0) { int temp = b; b = a % b; a = temp; } return a; } static int lcm_multiple(int numbers[], int length) { int result = numbers[0]; for (int i = 1; i < length; i++) { result = (result * numbers[i]) / gcd(result, numbers[i]); } return result; } void GPT_Notif_SPI(void) { } void Spi_Drv_ExternalDeviceConfig_SpiExternalDevice_0(void) { } void Spi_Drv_PhyUnitConfig_SpiPhyUnit_0(void) { } void Ex_Spi_StpJobEndNotification(void) { Dio_WriteChannel(0x0020U, STD_HIGH);//DioConf_DioChannel_PTB0 } void Ex_Spi_StpJobStartNotification(void) { Dio_WriteChannel(0x0020U, STD_LOW);//DioConf_DioChannel_PTB0 Dio_WriteChannel(0x0048U, STD_LOW);//DioConf_DioChannel_PTB0 } void Ex_Spi_SbcJobEndNotification(void) { Dio_WriteChannel(0x0048U, STD_HIGH);//DioConf_DioChannel_PTB0 } void Ex_Spi_SbcJobStartNotification(void) { Dio_WriteChannel(0x0048U, STD_LOW);//DioConf_DioChannel_PTB0 } void Ex_Spi_BuckJobEndNotification(void) { Dio_WriteChannel(0x0031U,STD_HIGH);//DioConf_DioChannel_PTB17 Dio_WriteChannel(0x0048U, STD_HIGH);//DioConf_DioChannel_PTB0 } void Ex_Spi_BuckJobStartNotification(void) { Dio_WriteChannel(0x0031U,STD_LOW);//DioConf_DioChannel_PTB17 Dio_WriteChannel(0x0048U, STD_LOW);//DioConf_DioChannel_PTB0 } void Ex_Spi_BoostJobEndNotification(void) { Dio_WriteChannel(0x0048U, STD_HIGH);//DioConf_DioChannel_PTB0 } void Ex_Spi_BoostJobStartNotification(void) { Dio_WriteChannel(0x0048U, STD_LOW);//DioConf_DioChannel_PTB0 } uint8 Spi_Stat_Get(void) { return Spi_Stat; } void Spi_Drv_0_DmaTxIrqHandler(uint32 LogicChIndex) { } void Spi_Drv_1_DmaTxIrqHandler(uint32 LogicChIndex) { } void Spi_Drv_0_DmaRxIrqHandler(uint32 LogicChIndex) { } void Spi_Drv_1_DmaRxIrqHandler(uint32 LogicChIndex) { }