From 402324180f942b8fca05e4ec05909739db5ddd54 Mon Sep 17 00:00:00 2001 From: Nick Ward Date: Fri, 16 Sep 2022 22:36:33 +1000 Subject: [PATCH] boards: shields: add Adafruit 16-channel PWM/Servo Adds Adafruit 16-channel PWM/Servo Shield Signed-off-by: Nick Ward --- .../shields/adafruit_pca9685/Kconfig.shield | 5 ++ .../adafruit_pca9685/adafruit_pca9685.overlay | 72 +++++++++++++++++++ boards/shields/adafruit_pca9685/doc/index.rst | 45 ++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 boards/shields/adafruit_pca9685/Kconfig.shield create mode 100644 boards/shields/adafruit_pca9685/adafruit_pca9685.overlay create mode 100644 boards/shields/adafruit_pca9685/doc/index.rst diff --git a/boards/shields/adafruit_pca9685/Kconfig.shield b/boards/shields/adafruit_pca9685/Kconfig.shield new file mode 100644 index 00000000000..7e1400a73f3 --- /dev/null +++ b/boards/shields/adafruit_pca9685/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2022 Nick Ward +# SPDX-License-Identifier: Apache-2.0 + +config SHIELD_ADAFRUIT_PCA9685 + def_bool $(shields_list_contains,adafruit_pca9685) diff --git a/boards/shields/adafruit_pca9685/adafruit_pca9685.overlay b/boards/shields/adafruit_pca9685/adafruit_pca9685.overlay new file mode 100644 index 00000000000..45c20a72830 --- /dev/null +++ b/boards/shields/adafruit_pca9685/adafruit_pca9685.overlay @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022 Nick Ward + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&arduino_i2c { + status = "okay"; + + pca9685_adafruit_pca9685: pca9685@40 { + status = "okay"; + compatible = "nxp,pca9685-pwm"; + reg = <0x40>; + #pwm-cells = <2>; + }; +}; + +/ { + pwmleds { + status = "okay"; + compatible = "pwm-leds"; + + s_led0: s-led-0 { + pwms = <&pca9685_adafruit_pca9685 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led1: s-led-1 { + pwms = <&pca9685_adafruit_pca9685 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led2: s-led-2 { + pwms = <&pca9685_adafruit_pca9685 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led3: s-led-3 { + pwms = <&pca9685_adafruit_pca9685 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led4: s-led-4 { + pwms = <&pca9685_adafruit_pca9685 4 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led5: s-led-5 { + pwms = <&pca9685_adafruit_pca9685 5 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led6: s-led-6 { + pwms = <&pca9685_adafruit_pca9685 6 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led7: s-led-7 { + pwms = <&pca9685_adafruit_pca9685 7 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led8: s-led-8 { + pwms = <&pca9685_adafruit_pca9685 8 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led9: s-led-9 { + pwms = <&pca9685_adafruit_pca9685 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led10: s-led-10 { + pwms = <&pca9685_adafruit_pca9685 10 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led11: s-led-11 { + pwms = <&pca9685_adafruit_pca9685 11 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led12: s-led-12 { + pwms = <&pca9685_adafruit_pca9685 12 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led13: s-led-13 { + pwms = <&pca9685_adafruit_pca9685 13 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led14: s-led-14 { + pwms = <&pca9685_adafruit_pca9685 14 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + s_led15: s-led-15 { + pwms = <&pca9685_adafruit_pca9685 15 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; +}; diff --git a/boards/shields/adafruit_pca9685/doc/index.rst b/boards/shields/adafruit_pca9685/doc/index.rst new file mode 100644 index 00000000000..cb3e08e0d3f --- /dev/null +++ b/boards/shields/adafruit_pca9685/doc/index.rst @@ -0,0 +1,45 @@ +.. _adafruit_pca9685: + +Adafruit 16-channel PWM/Servo Shield +#################################### + +Overview +******** + +The Adafruit 16-channel PWM/Servo shield is an Arduino +UNO R3 compatible shield based on the NXP PCA9685 IC. + +More information about the shield can be found +at the `Adafruit 16-channel PWM/Servo Shield webpage`_. + +Pins Assignments +================ + ++-----------------------+---------------------+ +| Shield Connector Pin | Function | ++=======================+=====================+ +| A5 | I2C - SCL1 | ++-----------------------+---------------------+ +| A4 | I2C - SDA1 | ++-----------------------+---------------------+ + + +Programming +*********** + +Set ``-DSHIELD=adafruit_pca9685`` when you invoke ``west build``. +For example: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/led_pwm + :board: nrf52840dk_nrf52840 + :shield: adafruit_pca9685 + :goals: build + +References +********** + +.. target-notes:: + +.. _Adafruit 16-channel PWM/Servo Shield webpage: + https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield?view=all