MTK平臺pwm模式閃光燈驅動配置
- 供電引腳配置:
除flash torch兩個供電引腳按照常規配置gpio模式外,需另外將ENM pin配置成pwm模式。在dtsi中新增如下程式碼:
flash_light_pwm_pin: flash_light_pwm_pin {
pins_cmd_dat {
pinmux = <PINMUX_GPIOxxx__FUNC_PWMx>;
slew-rate = <1>;
output-high;
};
};
-
驅動檔案:
包含pwm標頭檔案:
#include <mt-plat/mtk_pwm.h> -
閃光燈flash/torch模式下的電流控制:
(1) flash mode:
No matter the status of ENM, only when ENF = “1”, Flash mode is in active and the flashing current is equal to IRF * D, D is the duty cycle of PWM signal at ENM pin, the frequency of PWM is largerthan 15KHz
對應程式碼:
flashlight_pinctrl_set(FLASHLIGHT_PINCTRL_PIN_FLASH, 0);
flashlight_pinctrl_set(FLASHLIGHT_PINCTRL_PIN_PWM_EN, 1);
mt_flashlight_led_set_pwm(0, tempPWM); //設定pwm佔空比,以實現控制flash電流大小
udelay(500);
flashlight_pinctrl_set(FLASHLIGHT_PINCTRL_PIN_FLASH, 1);
(2) torch mode:
When ENF = “0” and the timer of ENM = “1” is not less than 5ms, Movie/Torch mode will be in active. The LED current should be equal to IRM * D, D is the duty cycle of PWM signal at ENM pin. This PWM signal is sent to ENM pin after the first pulse which “1” level time is more than 5ms. When ENF = “0” and the ENM = “0” is not less than 5ms, the chip will enter into shutdown mode.
對應程式碼:
flashlight_pinctrl_set(FLASHLIGHT_PINCTRL_PIN_FLASH, 0);
flashlight_pinctrl_set(FLASHLIGHT_PINCTRL_PIN_PWM_GPIO, 1);
mdelay(6);
flashlight_pinctrl_set(FLASHLIGHT_PINCTRL_PIN_PWM_EN, 1);
mt_flashlight_led_set_pwm(0, 40);
在flash_tuning_custom.cpp中將torch duty設定為24以上的數值(示例中flash共設定24個duty),用於與flash模式做區分。驅動中檢測到torch的duty時直接呼叫torch的使能邏輯。
- mt_flashlight_led_set_pwm的實現:
int mt_flashlight_led_set_pwm(int pwm_num, u32 level)
{
struct pwm_spec_config pwm_setting;
memset(&pwm_setting, 0, sizeof(struct pwm_spec_config));
/*pwm_no is by IC HW design, this value is different by different IC(MTK doc: PWM UserGuide) ——從dws裡面檢視?*/
pwm_setting.pwm_no = pwm_num;
/*OLD or FIFO*/
pwm_setting.mode = PWM_MODE_OLD;
/*use channel in pmic, or not, default is FALSE*/
pwm_setting.pmic_pad = 0;
/*分頻係數*/
pwm_setting.clk_div = CLK_DIV32;
/*src clk is by IC HW design, this value is different by different IC(MTK doc: PWM UserGuide) ——未找到查詢對應src的方法*/
pwm_setting.clk_src = PWM_CLK_OLD_MODE_BLOCK;
/*FALSE: after the PWM wave send finished, the voltage level of this GPIO is low
TRUE: after the PWM wave send finished, the voltage level of this GPIO is high*/
pwm_setting.PWM_MODE_OLD_REGS.IDLE_VALUE = 0;
/* FALSE: there is no interval time between 2 complete waveform
TRUE: interval time between 2 complete waveform, the interval time = DATA_WIDTH*/
pwm_setting.PWM_MODE_OLD_REGS.GUARD_VALUE = 0;
/* Guard的長度,old mode下是無效值 */
pwm_setting.PWM_MODE_OLD_REGS.GDURATION = 0;
/* waveform numbers. WAVE_NUM= 0 means PWM will send output always, until disable pwm, the waveform will stoped */
pwm_setting.PWM_MODE_OLD_REGS.WAVE_NUM = 0;
/* the time of onecomplete waveform, 此處含義是一個完整波形包含100個clk */
pwm_setting.PWM_MODE_OLD_REGS.DATA_WIDTH = 100;
/* the time of high voltage level in one complete waveform, it means duty cycle, 此處含義是一個完整波形中高電平的時長為level個clk */
pwm_setting.PWM_MODE_OLD_REGS.THRESH = level;
pwm_set_spec_config(&pwm_setting);
return 0;
}
- 定義pwm使用的level tab:
static int g_duty_array[FLASHLIGHT_LEVEL_NUM] = {8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100};
level tab用於根據不同的duty設定不同等級的THRESH, 從而達到實現控制亮度的目的。詳細程式碼實現:
xxx_enable中,flash模式時:
{
……
if (g_flash_duty < FLASHLIGHT_LEVEL_NUM)
tempPWM = g_duty_array[g_flash_duty];
else
tempPWM = g_duty_array[LED3201_LEVEL_NUM - 1];
……
mt_flashlight_led_set_pwm(3, tempPWM);
……
}
相關文章
- 驅動Driver-platform平臺驅動Platform
- 【linux】驅動-7-平臺裝置驅動Linux
- 乾貨分享:開啟PWM調光之門,一起來做呼吸燈
- PYB——PWM控制驅動器+步進電機
- 路由器光訊號閃紅燈是什麼意思 路由器突然閃紅燈上不了網路由器
- rk鍵盤怎麼調燈光模式 rk機械鍵盤怎麼調燈光模式
- MTK eCos系統的有線驅動收包流程
- 雷柏鍵盤怎麼調燈光模式 雷柏機械鍵盤怎麼調燈光模式
- 華清平臺匯流排驅動201208(不同平臺)
- 傳統燈秒變AI無主燈,艾拉物聯智慧照明驅動Driver喚醒極智自然光!AI
- 鍵盤怎麼調節燈光模式 鍵盤調燈光是哪個鍵模式
- 雷神鍵盤怎麼調節燈光模式 雷神筆記本鍵盤燈光怎麼調模式筆記
- jenkins配置android自動打包平臺JenkinsAndroid
- 鍵盤燈在閃
- 機械鍵盤怎麼調燈光 機械鍵盤的燈怎麼調模式模式
- LED車燈IC降壓恆流驅動AP5103大功率95%高效率深度調光摩托車燈晶片晶片
- 科技驅動金融 | 揭秘國壽財自動測試平臺
- Threejs入門-燈光JS
- 最新高通平臺驅動開發參考文件
- 【Camera專題】-Camera幀率、黃光環境下拍照閃紅問題-【展訊平臺】
- 【UE燈光•簡介】UE4光照型別和燈光引數型別
- 【.NET 與樹莓派】PWM 調節LED小燈的亮度樹莓派
- Unity中的Light燈光Unity
- 比例閥驅動電路後級PWM濾波尖刺如何消除?PWM通過RC低通濾波器模擬DAC
- Laravel 極光推送驅動,使用極光不再那麼麻煩!Laravel
- 微星鍵盤燈光怎麼設定 微星鍵盤怎麼調燈光
- 【MTK/Chargeing/Charger/驅動/JEITA】新增電池節點改變電池溫度
- Switchquery:移動端秒級配置觸達平臺
- 事件驅動架構在 vivo 內容平臺的實踐事件架構
- 驅動開發:配置Visual Studio驅動開發環境開發環境
- 燈光系統圖繪製
- 極光筆記|極光推送在APICloud平臺的使用教程筆記APICloud
- 事件驅動及其設計模式事件設計模式
- (六)WPF資料驅動模式模式
- 雷蛇鍵盤怎麼設定燈光 雷蛇鍵盤燈光怎麼調
- 最全MTK處理器型號/聯發科晶片平臺資料介紹晶片
- 東營大海光伏助力扶貧模式,實現生態 產業 扶貧多重驅動模式產業
- Android:平臺自動設定Pinctrl的預設配置Android