Code Monkey home page Code Monkey logo

bootlin-nunchuk's Introduction

Nunchuk Driver

A sample Linux I2C driver for the Nintendo Wii Nunchuk (RVL-004). The driver supports the following inputs using the input subsystem:

  • Z Button
  • C Button
  • Joystick (X and Y)

This project is based on Bootlin's embedded Linux trainings (see References section below).

Tested on BeagleBone Black hardware running mainline Linux version 5.10.179.

Hardware

Building the kernel module

To cross-compile, run the following command (using a cross-compiling toolchain provided by Ubuntu as an example):

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

Device Tree

To enable Nunchuk functionality on your board, add the following entry to the device tree:

&i2c1 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c1_pins>;
	
	status = "okay";
	clock-frequency = <100000>;
	
	joystick@52 {
		compatible = "nintendo,nunchuk";
		reg = <0x52>;
	};
};

Nunchuk

Connect the Nunchuk to the I2C1 bus of the BeagleBone Black board (pins 17 and 18 of P9, see pinout). The Nunchuk should show up at address 0x52:

# i2cdetect -r 1
i2cdetect: WARNING! This program can confuse your I2C bus
Continue? [y/N] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- 52 -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Load the kernel module to verify the driver finds the device:

# modprobe nunchuk

Finally, run the evtest application to test the inputs:

# evtest

References

bootlin-nunchuk's People

Contributors

prdktntwcklr avatar

Watchers

 avatar

bootlin-nunchuk's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.