本文主要在很对ATC平台支持ARM2倒车的时,系统启动通过ARM1的GPIO通知MCU打开系统背光。通过系统中在MIPI接口连接CVBS转MIPI输入倒车时,系统倒车将不走ARM2,这个时候GPIO通知MCU就不能放到ARM2代码逻辑中,直接在LK的LCD初始化之后调用GPIO设置即可。
但是在使用ARM2快速倒车的时候,LCD的初始化和LOGO的显示部分将在ARM2代码中进行,同时系统PWM背光的初始化也在ARM2中进行的,这样直接导致的结果就是ARM通知MCU打开背光使能只能够在ARM2中进行,方法如下:
1、定义系统启动时候ARM通知MCU打开背光使能的GPIO脚:
vendor\autochips\proprietary\arm2\display\inc\cust_leds.h
#define BACKLIGHT_EN_PIN GPIO30
2、在背光打开和关闭函数中添加通知MCU打开背光使能和悲观关闭的GPIO模式,具体打开和关闭将在LCD初始化打开PWM时进行,如下:
vendor\autochips\proprietary\arm2\display\src\mt_leds.c
void mt65xx_backlight_on(void)
{
static unsigned int First_SetBacklight = 1;
if(First_SetBacklight == 1) {
Printf("[LEDS]ARM2: mt65xx_backlight_on \n\r");
mt_set_gpio_mode(BACKLIGHT_EN_PIN, GPIO_MODE_00);// GPIO MODE
mt_set_gpio_dir(BACKLIGHT_EN_PIN, GPIO_DIR_OUT);
//mt_set_gpio_out(BACKLIGHT_EN_PIN, GPIO_OUT_ONE);
mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, LED_DEFAULT);
First_SetBacklight = 0;
}
//else {
//[LEDS]ARM2: backlight is lightting
//Printf("[LEDS]ARM2: backlight is lightting! \n\r");
//}
}
void mt65xx_backlight_off(void)
{
printf("[LEDS]ARM2: mt65xx_backlight_off \n\r");
mt_set_gpio_mode(BACKLIGHT_EN_PIN, GPIO_MODE_00);// GPIO MODE
mt_set_gpio_dir(BACKLIGHT_EN_PIN, GPIO_DIR_OUT);
//mt_set_gpio_out(BACKLIGHT_EN_PIN, GPIO_OUT_ZERO);
mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, LED_OFF);
}
3、在LCD初始化打开背光时使能够这个通知MCU的GPIO和关闭GPIO,如下:
因为ARM2的代码中在打开和关闭背光并没有直接调用到mt65xx_backlight_on()和mt65xx_backlight_off()函数,而是直接调用
disp_bls_set_backlight()会掉函数通过直接设置寄存器的方式实现的,如下:
vendor\autochips\proprietary\arm2\display\src\ddp_bls.c
int disp_bls_set_backlight(unsigned int level)
{
printf("[DDP] disp_bls_set_backlight: %d, CG = 0x%x, BLS_EN = 0x%x, PWM_DUTY = %d\n",
level,
DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
DISP_REG_GET(DISP_REG_BLS_EN),
DISP_REG_GET(DISP_REG_BLS_PWM_DUTY));
if (level && (!(DISP_REG_GET(DISP_REG_BLS_EN) & 0x10000)))
{
disp_bls_config();
}
#ifdef USE_DISP_BLS_MUTEX
disp_bls_get_mutex();
#else
DISP_REG_SET(DISP_REG_BLS_DEBUG, 0x3);
#endif
#if USE_TPS61165
printf("[ARM2] [DDP_PWM] TPS61165 pwm_level = %d\n",level);
level = 255 - level;
printf("[ARM2] [DDP_PWM] reserve pwm_level = %d\n",level);
#endif
if (level > 0)
mt_set_gpio_out(BACKLIGHT_EN_PIN, GPIO_OUT_ONE);
else
mt_set_gpio_out(BACKLIGHT_EN_PIN, GPIO_OUT_ZERO);
//直接通过寄存器设置系统背光的亮度级别
DISP_REG_SET(DISP_REG_BLS_PWM_DUTY, brightness_mapping(level));
printf("[DDP] PWM_DUTY: %x\n", DISP_REG_GET(DISP_REG_BLS_PWM_DUTY));
#ifdef USE_DISP_BLS_MUTEX
disp_bls_release_mutex();
#else
DISP_REG_SET(DISP_REG_BLS_DEBUG, 0x0);
#endif
return 0;
}
vendor\autochips\proprietary\arm2\display\src\cust_leds.c
static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
{"red", MT65XX_LED_MODE_PMIC, MT65XX_LED_PMIC_NLED_ISINK2,{0,0,0,0,0}},
{"green", MT65XX_LED_MODE_PMIC, MT65XX_LED_PMIC_NLED_ISINK1,{0,0,0,0,0}},
{"blue", MT65XX_LED_MODE_PMIC, MT65XX_LED_PMIC_NLED_ISINK0,{0,0,0,0,0}},
{"jogball-backlight", MT65XX_LED_MODE_NONE, -1,{0}},
{"keyboard-backlight",MT65XX_LED_MODE_NONE, -1,{0}},
{"button-backlight", MT65XX_LED_MODE_NONE, -1,{0}},
{"lcd-backlight", MT65XX_LED_MODE_CUST_BLS_PWM, (int)disp_bls_set_backlight,{0,1,0,0,0}},
};