I.MX6 Piezo Buzzer Control with pwm_backlight?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I.MX6 Piezo Buzzer Control with pwm_backlight?

Jump to solution
4,712 Views
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.

Labels (3)
0 Kudos
Reply
1 Solution
1,997 Views
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

View solution in original post

0 Kudos
Reply
4 Replies
1,998 Views
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 Kudos
Reply
1,997 Views
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 Kudos
Reply
1,997 Views
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 Kudos
Reply