/* * Dashboard.c * * Created on: Apr 4, 2023 * Author: Stefa */ #include #include uint8_t AMS_Status_latch = 0; uint8_t AMS_Latch = 0; uint32_t uwuTick_Start =0; void AMS_Indicator(uint8_t AMS_Status) { // AMS_Latch = Flash_Read_NUM(0x08041000 ); if ((AMS_Status==0 && AMS_Latch==0 )) { HAL_GPIO_WritePin(GPIOA, AMS_Indicator_Pin, 0); uwuTick_Start=0; //Flash_Write_NUM(0x08041000, AMS_Status); } if (AMS_Status== 1) { //uwuTick_Start=uwTick; //if(uwTick - uwuTick_Start > 2000){ HAL_GPIO_WritePin(GPIOA, AMS_Indicator_Pin, 0); //AMS_Latch=1; //Flash_Write_NUM(0x08041000, 1); //} } //uint8_t data[1]; //data[0] = 0; // sys_sendCan2Msg(0x420, 1, &data[0]); } void rubm_processCan1RxMsg(uint32_t stdId, uint32_t dlc, uint8_t *data) { switch (stdId) { case 0x550: //ToDo ID für AMS Indicator festlegen { return 0; } case 0x700: { return 0; } case 0x400: { uint8_t d = *data; AMS_Indicator(d); if (d == 1) { AMS_Status_latch = 1; } } } } void rubm_processCan2RxMsg(uint32_t stdId, uint32_t dlc, uint8_t *data) { switch (stdId) { case 0x400: { AMS_Indicator(data[0]); } } } void Delay(uint32_t milliseconds) { /* Initially clear flag */ (void) SysTick->CTRL; while (milliseconds != 0) { /* COUNTFLAG returns 1 if timer counted to 0 since the last flag read */ milliseconds -= (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) >> SysTick_CTRL_COUNTFLAG_Pos; } } /* uint32_t Flash_Write_Data (uint32_t StartPageAddress, uint32_t *Data, uint16_t numberofwords) { static FLASH_EraseInitTypeDef EraseInitStruct; uint32_t PAGEError; int sofar=0; /* Unlock the Flash to enable the flash control register access *************/ // HAL_FLASH_Unlock(); /* /* Erase the user Flash area*/ /* uint32_t StartPage = GetPage(StartPageAddress); uint32_t EndPageAdress = StartPageAddress + numberofwords*4; uint32_t EndPage = GetPage(EndPageAdress); /* Fill EraseInit structure*/ /* EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES; EraseInitStruct.PageAddress = StartPage; EraseInitStruct.NbPages = ((EndPage - StartPage)/FLASH_PAGE_SIZE) +1; if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK) { /*Error occurred while page erase.*/ /* return HAL_FLASH_GetError (); } /* Program the user Flash area word by word*/ /* while (sofar