TSL2561 light-to-digital converter demo for HiKey 960  

分享到:

wolfkin
Level 2Admin
注册时间:3年 前
帖子数: 27
2017年7月12日 上午11:25  

hikey960上移植了tsl2561光感芯片现在跟大家交流下移植办法

硬件准备:

Hikey960

[attach]26[/attach]

96Boards Sensors

[attach]27[/attach]

TSL2561

[attach]30[/attach]

移植过程:

参考硬件原理图,板子引出了2I2C接口,分别是I2C0I2C7.

[attach]33[/attach]

现在开始添加代码。

aosp\hikey-linaro\arch\arm64\boot\dts\hisilicon\hi3660.dtsi中配置I2C0,这样就可以编进kernel

 

i2c0: i2c@FFD71000 {

                            compatible = "snps,designware-i2c";

                            reg = <0x0 0xFFD71000 0x0 0x1000>;

                            interrupts = <0 118 4>;

                        #address-cells = <1>;

                        #size-cells = <0>;

                            clock-frequency = <400000>;

                            clocks = <&crg_ctrl HI3660_CLK_GATE_I2C0>;

                            resets = <&iomcu_rst HI3660_RST_I2C0>;

                            pinctrl-names = "default";

                            pinctrl-0 = <&i2c0_pmx_func &i2c0_cfg_func>;

                            status = "ok";

                           

                            TSL2561_i2c: TSL2561_i2c@29 {

                                     compatible = "tsl,TSL2561_i2c";

                                     reg = <0x29>;

                                     status = "ok";

                            };

                           

                   };

因为I2C2I2C7是复用的,所以如果要使用I2C7,请注意要把I2C2 disable掉。

[attach]32[/attach]

i2c2: i2c@FFD73000 {

                            compatible = "snps,designware-i2c";

                            reg = <0x0 0xFFD73000 0x0 0x1000>;

                            interrupts = <0 120 4>;

                        #address-cells = <1>;

                        #size-cells = <0>;

                            clock-frequency = <400000>;

                            clocks = <&crg_ctrl HI3660_CLK_GATE_I2C2>;

                            resets = <&iomcu_rst HI3660_RST_I2C2>;

                            pinctrl-names = "default";

                            pinctrl-0 = <&i2c2_pmx_func &i2c2_cfg_func>;

                            status = "disabled";

                   };

将参考代码放到aosp\hikey-linaro\drivers目录下,然后配置此目录下的kconfig文件和Makefile

Kconfig中添加

source "drivers/sl2561_hikey/Kconfig"

Makefile中添加

obj-$(CONFIG_TSL2561)           += tsl2561_hikey/

 

最后在Z:\aosp\hikey-linaro\arch\arm64\configs\hikey960_defconfig中添加对应的宏。

CONFIG_TSL2561=y

到此代码的添加已经结束。

 

接下来就是编译,按照编译教程所述,先编译kernel,然后将kernel生成的image.gzdtb文件重命名并放入aosp中,最后全编aosp。编译完成后烧录image即可。

 

最后来验证一下,开机进入adb,正常情况会在如下路径下生成对应的节点,然后cat data,就会出现数据。

[attach]31[/attach]

移植完毕,还望斧正

将代码和大家共享

https://github.com/archermind666/tsl2561_on_hikey

 

 

编辑:2年 前

回复引用
  
Working

登陆 或者 注册