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.
 
 

145 lines
3.2 KiB

/*
* Dashboard.c
*
* Created on: Apr 4, 2023
* Author: Stefa
*/
#include <main.h>
#include <Dashboard.h>
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<numberofwords)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, StartPageAddress, Data[sofar]) == HAL_OK)
{
StartPageAddress += 4; // use StartPageAddress += 2 for half word and 8 for double word
sofar++;
}
else
{
/* Error occurred while writing data in Flash memory*/
/* return HAL_FLASH_GetError ();
}
}
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
/* HAL_FLASH_Lock();
return 0;
}
void Flash_Read_Data (uint32_t StartPageAddress, uint32_t *RxBuf, uint16_t numberofwords)
{
while (1)
{
*RxBuf = *(__IO uint32_t *)StartPageAddress;
StartPageAddress += 4;
RxBuf++;
if (!(numberofwords--)) break;
}
}
*/