I.MX6 Piezo Buzzer Control with pwm_backlight?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I.MX6 Piezo Buzzer Control with pwm_backlight?

ソリューションへジャンプ
4,223件の閲覧回数
mukelarvin
Contributor IV

Hey everyone,

I'm trying to run a small CEM 1203 buzzer directly from one of the PWMs on my I.MX6. Is there a convenient way to change the period of a pwm-backlight platform device?

Thanks,

L.M.

ラベル(3)
0 件の賞賛
1 解決策
1,508件の閲覧回数
EricNelson
Senior Contributor II

Hi Luke,

You can use this code to allow frequencies in the form of musical "notes" centered around middle-C:

     https://github.com/boundarydevices/linux-imx6/commit/63b106e30a42e5ee89c4c7d0644e853f013276db

If you name your platform device "buzzer", you can access the buzzer in sysfs like so:

~/$ echo -n C > /sys/class/leds/buzzer/note   # turn on middle C

~/$ echo -n ' ' > /sys/class/leds/buzzer/note # turn it off

元の投稿で解決策を見る

0 件の賞賛
4 返答(返信)
1,509件の閲覧回数
EricNelson
Senior Contributor II

Hi Luke,

You can use this code to allow frequencies in the form of musical "notes" centered around middle-C:

     https://github.com/boundarydevices/linux-imx6/commit/63b106e30a42e5ee89c4c7d0644e853f013276db

If you name your platform device "buzzer", you can access the buzzer in sysfs like so:

~/$ echo -n C > /sys/class/leds/buzzer/note   # turn on middle C

~/$ echo -n ' ' > /sys/class/leds/buzzer/note # turn it off

0 件の賞賛
1,508件の閲覧回数
mukelarvin
Contributor IV

Hi Eric,

Thanks for the tip, I've updated the leds-pwm.c driver as you suggested but I'm not sure how to register the platform device.

I'm still on kernel 3.0.35 and all the examples I have use leds-gpio or pwm-backlight. I haven't had to add a platform device yet but looking at leds_pwm.h and other platform devices I came up with this:

static struct led_pwm  imx6_led_pwms[] = {

  {

  .name = "buzzer",

  .default_trigger = ,

  .pwm_id = 2,

  .active_low = ,

  .max_brightness = ,

  .pwm_period_ns = ,

  }

};

static struct led_pwm_platform_data imx6q_led_pwms_data = {

  .leds = imx6q_pwm_leds,

  .num_leds = ARRAY_SIZE(imx6q_led_pwms),

};

static struct platform_device imx6q_pwm_led_device = {

  .name = "leds-pwm",

  .id = 1,

  .num_resources = ,

  .dev = {

    .platform_data = &imx6q_led_pwms_data,

  }

};

static void __init imx6q_add_device_led_pwms(void)

{

  platform_device_register(&imx6q_pwm_led_device);

}

Could you help me fill in the blanks? Or point me towards an example?

0 件の賞賛
1,508件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Luke

please look at sect. 8.6 "Buzzer" below

Linux Software User Manual (i.MX6) - BlueWiki

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛