Commit a6b11402 authored by 时昊's avatar 时昊

Merge branch 'shihao' into 'dev'

Shihao

See merge request !32
parents be1b7cbf 135bbb3b
#include "Backlight.h"
#include "Components.h"
#define BACK_LIGHT_Val_1 100
#define BACK_LIGHT_Val_2 300
#define BACK_LIGHT_Val_3 500
#define BACK_LIGHT_Val_4 700
#define BACK_LIGHT_Val_5 900
typedef struct
{
Light_uint16_t Temperature; /* 温度 */
......@@ -377,4 +383,32 @@ void BackLight_Service(void)
{
Backlight_Operate.SetPwmCbk(0);
}
}
\ No newline at end of file
}
void BackLight_Process(void)
{
if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_5) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_5);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_4) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_4);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_3) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_3);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_2) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_2);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_1) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_1);
}
else
{
;
}
}
......@@ -22,7 +22,7 @@
#endif /* NULL */
void Backlight_KL30_Wakeup_Init(void);
void BackLight_Process(void);
......
......@@ -65,6 +65,10 @@ void Menu_User_Init(void)
Menu_Init_st.enMenuItemLen = MENU_ITEM_MAX;
Menu_Init_st.uintMenuConfig = 0x0001;
Menu_Init_st.uintMenuCursorMemoryDepth = 0;
Menu_Item_Select_Set(MENU_ITEM_SELECT_DAYTIME, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
Menu_Item_Select_Set(MENU_ITEM_UNIT_KM, 1);
Menu_Item_Select_Set(MENU_ITEM_LANGUAGE_CHINESE, 1);
Menu_Init((uint8_t *)u8MenuRamData, (Menu_Item_Attribute_st_t *)stMenuItemAttribute, (Menu_Init_st_t *)&Menu_Init_st);
}
......@@ -76,6 +80,10 @@ void Menu_User_WAKEUP(void)
Menu_Init_st.enMenuItemLen = MENU_ITEM_MAX;
Menu_Init_st.uintMenuConfig = 0x0001;
Menu_Init_st.uintMenuCursorMemoryDepth = 0;
Menu_Item_Select_Set(MENU_ITEM_SELECT_DAYTIME, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
Menu_Item_Select_Set(MENU_ITEM_UNIT_KM, 1);
Menu_Item_Select_Set(MENU_ITEM_LANGUAGE_CHINESE, 1);
Menu_Wake_Up_Init((uint8_t *)u8MenuRamData, (Menu_Item_Attribute_st_t *)stMenuItemAttribute, (Menu_Init_st_t *)&Menu_Init_st);
}
......@@ -326,12 +334,15 @@ void Menu_Logic_Operation_Bluetooth_Back(Menu_Key_en_t enKeyType)
void Menu_Logic_Operation_Clock_Hour_Tenb(Menu_Key_en_t enKeyType)
{
// counter_val.time.RTC_Hours = (MenuData.Dis_Hour_Tenb*10 + MenuData.Dis_Hour_Bit);
// counter_val.time.RTC_Minutes = (MenuData.Dis_Minute_Tenb*10 + MenuData.Dis_Minute_Bit);
// if(MENU_KEY_CONFIRM_SHORT == enKeyType)
// {
// RTC_SetTime(&counter_val.time);
// }
RTE_RTC_Get_CounterValue(&counter_val);
counter_val.time.RTC_Hours = RTC_Bcd2ToByte(counter_val.time.RTC_Hours);
counter_val.time.RTC_Minutes = RTC_Bcd2ToByte(counter_val.time.RTC_Minutes);
MenuData.Dis_Hour_Tenb = counter_val.time.RTC_Hours / 10;
MenuData.Dis_Hour_Bit = counter_val.time.RTC_Hours % 10;
MenuData.Dis_Minute_Tenb = counter_val.time.RTC_Minutes / 10;
MenuData.Dis_Minute_Bit = counter_val.time.RTC_Minutes % 10;
}
void Menu_Logic_Operation_Clock_Hour_Bit(Menu_Key_en_t enKeyType)
......@@ -371,11 +382,7 @@ void Menu_Logic_Operation_Clock_Hour_Tenb_Set(Menu_Key_en_t enKeyType)
uint8_t updataDir = 0u;
uint8_t datmax = 0u;
uint8_t datmin = 0u;
// RTE_RTC_Get_CounterValue(&counter_val);
// counter_val.time.RTC_Hours = RTC_Bcd2ToByte(counter_val.time.RTC_Hours);
// counter_val.time.RTC_Minutes = RTC_Bcd2ToByte(counter_val.time.RTC_Minutes);
// MenuData.Dis_Hour_Tenb = counter_val.time.RTC_Hours / 10;
if(enKeyType == MENU_KEY_DOWN_SHORT)
{
......
......@@ -68,6 +68,7 @@ static void Power_KL30_Init(void)
Menu_User_Init();
Can_Init();
Protocol_KL30_Wakeup_Init();
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 100);
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(KL15_AD_IN, Trigger_Rising);
FaultCode_Init();
}
......@@ -110,7 +111,7 @@ static void Power_OVP_Init(void)
static void Power_IG_OFF_Init(void)
{
Line_In_KL15_OFF_Init();
RTE_GPIO_Set_Level(Blacklight_PWM, 0);
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 0);
}
static void Power_IG_ON_Init(void)
......@@ -168,18 +169,10 @@ static Power_Status_em Power_Stay_OFF(void)
}
else
{
if ((Common_GetIgnOffTime() < 1000))
if ((Common_GetIgnOffTime() < 20000))
{
u8PowerSts = EM_IGN_OFF;
}
else
{
//igoff大于1s且下15电才进休眠,否则一直保持在igoff状态
//if(Sys_Read_KL15_Voltage() < 5000)
{
u8PowerSts = EM_IGN_Sleep_Init;
}
}
}
return u8PowerSts;
......@@ -195,7 +188,7 @@ static Power_Status_em Power_Stay_Protect(void)
/* 关闭所有外设,坪保留AD采集,电溝状思切�? */
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 0);
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Disable);
//CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Disable);
}
u8PowerSts = EM_IGN_OFF_Init;
/* 电溝模弝正常 */
......@@ -208,15 +201,10 @@ static Power_Status_em Power_Stay_Protect(void)
if ( SYS_OPR_STAT_RUN )
{
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
//CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
return u8PowerSts;
}
//进入异常电压,电源库里直接将15电等于0,则直接退出,状态是igoff,下15则进入休眠
// if ( SYS_OPR_STAT_IGN_OFF )
// {
// break;
// }
}
}
......
/*
* TrmerM.c
*
* Created on: 2024年2月21日
* Created on: 2024�?2�?21�?
*/
#include <stdint.h>
// #include "gpio.h"
......@@ -25,21 +25,21 @@ typedef struct
// /*占空比精度千分之一*/
// extern void TimerB_PWM_Channel_Duty_Set(TIMERB_Channel_en_t enTimerBChannel, uint16_t u16Duty);
// extern void TimerB_PWM_Channel_Start(TIMERB_Channel_en_t enTimerBChannel);
// /*调用该函数后,仅重新调用开始函数功能即可正常使*/
// /*调用该函数后,仅重新调用开始函数功能即可正常使�?*/
// extern void TimerB_PWM_Channel_Stop(TIMERB_Channel_en_t enTimerBChannel);
// /*仅休眠时可调用,调用该函数后需要重新初始化相关通道才可以正常使用*/
// /*仅休眠时可调用,调用该函数后需要重新初始化相关通道才可以正常使用�?*/
// extern void TimerB_PWM_Channel_Sleep(TIMERB_Channel_en_t enTimerBChannel);
TMM_InitTypeDef TIMM_InitStructure[2] = {0};
static uint32_t cycle_pulse[2]; //一个周期的时钟 //频率
static uint32_t high_level_Pulse[2][3]; //高电平时钟数 //占空
static uint32_t cycle_pulse[2]; //一个周期的时钟�? //频率
static uint32_t high_level_Pulse[2][3]; //高电平时钟数 //占空�?
static uint32_t pwm_duty[2][3];
/**
* @brief 设置TimerM的定时器x的模式为比较输出
*
* @param counter 定时
* @param counter 定时�?
* @param freq 比较输出频率
* @return uint8_t 返回0成功,非0失败
*/
......@@ -48,20 +48,32 @@ uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t
if (counter == TIMERM_COUNTER0)
{
TIMM_InitStructure[counter].TMM_Select = TMM0;
TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_A|TMM_Channel_B|TMM_Channel_C|TMM_Channel_D;
TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
TIMM_InitStructure[counter].TMM_Intp = TMM_Int_NONE; ///compare match interrupt enable A (IMIEA)
}
else if (counter == TIMERM_COUNTER1)
{
TIMM_InitStructure[counter].TMM_Select = TMM1;
TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_A|TMM_Channel_B;//|TMM_Channel_C|TMM_Channel_D;
TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
TIMM_InitStructure[counter].TMM_Intp = TMM_Int_NONE; ///compare match interrupt enable A (IMIEA)
}
else
{
return 1;
}
TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_A|TMM_Channel_B|TMM_Channel_C|TMM_Channel_D;
TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
TIMM_InitStructure[counter].TMM_Intp = TMM_Int_IMIA; ///compare match interrupt enable A (IMIEA)
// TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_A|TMM_Channel_B|TMM_Channel_C|TMM_Channel_D;
// TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
// TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
// TIMM_InitStructure[counter].TMM_Intp = TMM_Int_IMIA; ///compare match interrupt enable A (IMIEA)
if (freq > 2000)
{
......@@ -83,7 +95,7 @@ uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t
return 1;
}
TIMM_InitStructure[counter].TMM_CHA_Pulse = cycle_pulse[counter] & 0x0FFFF;//这里需要计算,调试 period; //周期设置为period
TIMM_InitStructure[counter].TMM_CHA_Pulse = cycle_pulse[counter] & 0x0FFFF;//这里需要计算,调试�? period; //周期设置为period
......@@ -103,23 +115,34 @@ uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t
//uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t freq)//, uint32_t PWM_Clock //SystemCoreClock
//{
// if (counter == TIMERM_COUNTER0)
// SystemCoreClock = 64000000UL;
//
// if (counter == TIMERM_COUNTER0)
// {
// TIMM_InitStructure[counter].TMM_Select = TMM0;
//
// TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_B|TMM_Channel_C|TMM_Channel_D;
// TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
// TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
// TIMM_InitStructure[counter].TMM_Intp = TMM_Int_IMIA; ///compare match interrupt enable A (IMIEA)
// }
// else if (counter == TIMERM_COUNTER1)
// {
// TIMM_InitStructure[counter].TMM_Select = TMM1;
// TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_B;
// TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
// TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
// TIMM_InitStructure[counter].TMM_Intp = TMM_Int_IMIA; ///compare match interrupt enable A (IMIEA)
// }
// else
// {
// return 1;
// }
//
// TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_A|TMM_Channel_B|TMM_Channel_C|TMM_Channel_D;
// TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
// TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
// TIMM_InitStructure[counter].TMM_Intp = TMM_Int_IMIA; ///compare match interrupt enable A (IMIEA)
//// TIMM_InitStructure[counter].TMM_Channel = TMM_Channel_A|TMM_Channel_B|TMM_Channel_C|TMM_Channel_D;
//// TIMM_InitStructure[counter].TMM_Mode = TMM_Mode_PWM;
//// TIMM_InitStructure[counter].TMM_CounterClear = TM_Clear_Match_TMGRA; //when TM is matched with TMGRA, TM0 is cleared
//// TIMM_InitStructure[counter].TMM_Intp = TMM_Int_IMIA; ///compare match interrupt enable A (IMIEA)
//
// if (freq > 2000)
// {
......@@ -141,7 +164,7 @@ uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t
// return 1;
// }
//
// TIMM_InitStructure[counter].TMM_CHA_Pulse = cycle_pulse[counter] & 0x0FFFF;//这里需要计算,调试 period; //周期设置为period
// TIMM_InitStructure[counter].TMM_CHA_Pulse = cycle_pulse[counter] & 0x0FFFF;//这里需要计算,调试�? period; //周期设置为period
//
//
//
......@@ -164,9 +187,9 @@ uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t
/**
* @brief 设置timerM定时器x通道x的占空比
*
* @param counter 定时
* @param counter 定时�?
* @param ch 通道
* @param duty 占空比 xxxx/1000 千分之
* @param duty 占空�? xxxx/1000 千分�?
* @param ActiveLevel 0负占空比 1正占空比
* @return uint8_t 返回0成功,非0失败
*/
......@@ -178,7 +201,7 @@ uint8_t TimerM_PWM_CH_Output_init(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Ch
switch (ch)
{
case TIMERM_CHB:
TIMM_InitStructure[counter].TMM_CHB_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRB. 占空:duty2/period
TIMM_InitStructure[counter].TMM_CHB_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRB. 占空�?:duty2/period
TIMM_InitStructure[counter].TMM_PWM.TMM_CHB.TMM_PWMInitLevel = TMM_PWMInitLevel_High;
TIMM_InitStructure[counter].TMM_PWM.TMM_CHB.TMM_PWMActiveLevel = ActiveLevel;
if (counter == TIMERM_COUNTER0)
......@@ -194,7 +217,7 @@ uint8_t TimerM_PWM_CH_Output_init(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Ch
break;
case TIMERM_CHC:
TIMM_InitStructure[counter].TMM_CHC_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRC. 占空:duty2/period
TIMM_InitStructure[counter].TMM_CHC_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRC. 占空�?:duty2/period
TIMM_InitStructure[counter].TMM_PWM.TMM_CHC.TMM_PWMInitLevel = TMM_PWMInitLevel_High;
TIMM_InitStructure[counter].TMM_PWM.TMM_CHC.TMM_PWMActiveLevel = ActiveLevel;
if (counter == TIMERM_COUNTER0)
......@@ -209,7 +232,7 @@ uint8_t TimerM_PWM_CH_Output_init(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Ch
break;
case TIMERM_CHD:
TIMM_InitStructure[counter].TMM_CHD_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRD. 占空:duty3/period
TIMM_InitStructure[counter].TMM_CHD_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRD. 占空�?:duty3/period
TIMM_InitStructure[counter].TMM_PWM.TMM_CHD.TMM_PWMInitLevel = TMM_PWMInitLevel_High;//TMM_PWMInitLevel_High;//
TIMM_InitStructure[counter].TMM_PWM.TMM_CHD.TMM_PWMActiveLevel = ActiveLevel;//TMM_PWMActiveLevel_Low;//TMM_PWMActiveLevel_High;//
if (counter == TIMERM_COUNTER0)
......@@ -264,7 +287,7 @@ extern void TMM1_Set_Counter(uint8_t ch,uint16_t value);
*
* @param counter 定时器x
* @param ch 通道x
* @param duty 占空 千分之一
* @param duty 占空�? 千分之一
* @return uint8_t 返回0成功,非0失败
*/
uint8_t TimerM_PWM_set_duty(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Channel_en_t ch, uint16_t duty )
......@@ -302,11 +325,11 @@ uint8_t TimerM_PWM_set_duty(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Channel_
*
* @param counter 定时器x
* @param freq PWM频率
* @return uint8_t 0成功 0失败
* @return uint8_t 0成功 �?0失败
*
* @note 频率范围有两种,50~2000 2001~最大,如果初始话的频率和目标频率在一个区间可以使用TimerM_PWM_set_freq2函数来优雅的切换频率
* @note 频率范围有两种,50~2000 2001~最大,如果初始话的频率和目标频率在一个区间可以使用TimerM_PWM_set_freq2函数来优雅的切换频率�?
* 如果不在一个频率区间就需要使用TimerM_PWM_set_freq来不优雅的切换频率,
* 如果看不懂注释也使用TimerM_PWM_set_freq来切换频率
* 如果看不懂注释也使用TimerM_PWM_set_freq来切换频率�?
*/
uint8_t TimerM_PWM_set_freq(TIMERM_PWM_Counter_en_t counter, uint16_t freq )
{
......
......@@ -5,6 +5,7 @@
#include "RTE.h"
#include "UDS_ISO14229_Server.h"
#include "FaultCode.h"
extern _Menu_Data MenuData;
void Sys_Pseudo_Real_Time_Tasks(void)
{
......@@ -53,17 +54,17 @@ void Sys_50ms_Tasks(void)
g_u8Cursor_Posittion = Menu_Get_Current_Cursor_Information();
// if((MenuData.Dis_Hour_Tenb*10 + MenuData.Dis_Hour_Bit) > 23)
// {
// MenuData.Dis_Hour_Tenb = 2;
// MenuData.Dis_Hour_Bit = 3;
// }
if((MenuData.Dis_Hour_Tenb*10 + MenuData.Dis_Hour_Bit) > 23)
{
MenuData.Dis_Hour_Tenb = 2;
MenuData.Dis_Hour_Bit = 3;
}
// if((MenuData.Dis_Minute_Tenb*10 + MenuData.Dis_Minute_Bit) > 59)
// {
// MenuData.Dis_Minute_Tenb = 5;
// MenuData.Dis_Minute_Bit = 9;
// }
if((MenuData.Dis_Minute_Tenb*10 + MenuData.Dis_Minute_Bit) > 59)
{
MenuData.Dis_Minute_Tenb = 5;
MenuData.Dis_Minute_Bit = 9;
}
}
uint32_t ODOtest = 0;
......@@ -82,6 +83,8 @@ void Sys_100ms_Tasks(void)
//Data_Mileage_Clear();
RTE_GPIO_Config(RTE_GPIO_PORT05_PIN04, GpioOut_High);
BackLight_Process();
//TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 100);
// aaa = Menu_Item_Select_Get(MENU_ITEM_SELECT_AUTO);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment