Skip to content

arthurloukes/nesmini_usb_adapter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NES Mini Controller USB Adapter for attiny85

This code will work with an attiny85 (or probably whatever similar AVR microcontroller once the Makefile are changed and the pins constants adapted - SDA, SCL and the two Data for the V-USB part) hooked to a NES Mini Controller via I2C and with the proper hardware required for a USB connection.

  • The first part acts as a generic USB gamepad using the V-USB library (it's a basic example modified to use a gamepad descriptor and send the proper report. Not an expert on this library, so maybe it can be improved, fixed or optimized; but as far as I'm concerned it does the work pretty well!).

  • The second part uses a custom handmade bunch of functions to communicate with the NES Mini Controller via I2C.

    • nesminicontrollerdrv.c implements the Controller poll. It reads from the proper register and fetch the bytes related to the pressed buttons. There are a few constants for each button that can be used to check which one was pressed (it allows multiple buttons pressed at the same time).

    • i2cattiny85/i2cattiny85.c contains some low-level functions to send and read bytes using the SDA and SCL lines. In this case the file is set for the attiny85 pins, but it can be changed if another microcontroller is used (didn't try that, but in theory it should work).

Some extra considerations

Since I'm using an attiny85 I needed to change a few things in order to make the V-USB library work with it. This post helps me a lot.

Some changes need to be done to modify the CPU speed (also fuses!) among with the use of an Oscillator Calibration function.

The input pins are also different than the ones in the post, since one of those pins is also used as the SDA signal. To avoid conflicts between the "USB pins" and the "I2C pins" I changed one of the USB Data pins to another one. Check the usbconfig.h file for more info about how to re-arrange the 4 pins.

Useful links

https://www.obdev.at/products/vusb/index.html The V-USB library, software implementation for low-speed USB device on AVR microcontrollers

https://www.ruinelli.ch/how-to-use-v-usb-on-an-attiny85 How to make the original V-USB library examples work in an attiny85

https://thewanderingengineer.com/2014/08/11/pin-change-interrupts-on-attiny85/ Pin change Interrupts on attiny85

https://en.wikipedia.org/wiki/I%C2%B2C The I2C page on Wikipedia

http://wiibrew.org/wiki/Wiimote/Extension_Controllers Info about the Nintendo Extension Controllers (like the Mini consoles or the Wii Nunchuk)

http://albertgonzalez.coffee/projects/snes_mini_arduino/ When I started tinkering with this Mini Controllers I did some stuff using Arduinos instead of "raw" AVR's. Here are some of the notes I wrote about connecting (S)NES Mini Controllers to an Arduino board.

http://eleccelerator.com/fusecalc/fusecalc.php?chip=attiny85 Fuse calculator

About

NES Mini Controller USB Adapter for attiny85

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 42.8%
  • Assembly 38.7%
  • PHP 9.9%
  • HTML 6.2%
  • Makefile 2.4%