diff --git a/description/overlay/arduino-spi.md b/description/overlay/arduino-spi.md new file mode 100644 index 0000000..48ea1f2 --- /dev/null +++ b/description/overlay/arduino-spi.md @@ -0,0 +1,31 @@ +#ATmega 328p / Arduino over SPI + +###Did you know that your Pi could power and program an ATmega 328p/Arduino directly, with nothing but a few wires, a breadboard, a 16Mhz crystal oscillator and some 22pF capacitors? + +Read my [complete Pico PiDuino tutorial](http://pi.gadgetoid.com/article/building-the-pico-piduino) to get started for just over £5 + +You'll need to install [Gordon's modified AVRDude](https://projects.drogon.net/raspberry-pi/gertboard/arduino-ide-installation-isp/). + +Connect 8/CEO to your ATmega's Reset/RST pin, 9/MISO to its MISO pin (D12), 10 to its MOSI pin (D11) and 11/SCLK to its SCLK pin (D13). + +Power your ATmega with the 3.3v and GND pins from your Pi, and you're good to go. + +Make sure you have no rogue SPI device drivers running and check it's connected correctly using: + +```bash +avrdude -p m328p -c gpio +``` + +To get started compiling Arduino sketches from the command line: + +```bash +sudo apt-get install arduino arduino-mk +``` + +This basic Makefile should get you started. Create a basic sketch, name it mysketch.ino and run: + +```bash +export BOARD=atmega328 +make +avrdude -p m328p -c gpio -e -U flash:w:build-cli/Arduino.hex +``` diff --git a/description/overlay/i2c.md b/description/overlay/i2c.md new file mode 100644 index 0000000..19d4e8d --- /dev/null +++ b/description/overlay/i2c.md @@ -0,0 +1,26 @@ +#I2C - Inter Integrated Circuit + +The Raspberry Pi's I2C pins are an extremely useful way to talk to many different types of external peripheral; from the MCP23017 digital IO expander, to a connected ATmega. + +You can verify the address of connected I2C peripherals with a simple one-liner: + +```bash +sudo apt-get install i2c-tools +sudo i2cdetect -y 1 +``` + +You can access i2c from Python using the smbus library: + +```bash +sudo apt-get install python-smbus +``` + +And then in Python: + +```python +import smbus +DEVICE_BUS = 1 +DEVICE_ADDR = 0x15 +bus = smbus.SMBus(DEVICE_BUS) +bus.write_byte_data(DEVICE_ADDR, 0x00, 0x01) +``` \ No newline at end of file diff --git a/description/overlay/spi.md b/description/overlay/spi.md new file mode 100644 index 0000000..32f5c6f --- /dev/null +++ b/description/overlay/spi.md @@ -0,0 +1,26 @@ +#SPI - Serial Peripheral Interface + +###Known as the four-wire serial bus, SPI lets you daisy-chain multiple compatible devices off a single set of pins by assigning them different addresses. + +A simple example of an SPI peripheral is the MCP23S17 digital IO expander chip Note the S in place of the 0 found on the I2C version. Using it in WiringPi2 is a doddle: + +```python +import wiringpi2 as wiringpi +HIGH = 1 +OUTPUT = 1 +PIN_BASE = 65 +SPI_ADDR = 0x20 +wiringpi.wiringPiSetup() +wiringpi.mcp23S17Setup(PIN_BASE,SPI_ADDR) +# 16 pins including the starting pin +mcp23S17pins = range(PIN_BASE,PIN_BASE+15) +for pin in mcp23S17pins: + wiringpi.pinMode(pin,OUTPUT) + wiringpi.digitalWrite(pin,HIGH) +``` + +You can also use the SPI port to "Bit-Bang" an ATmega 328, loading Arduino sketches onto it with Gordon's modified version of AVRDude. + +Hook up you Pi's SPI port to that of your ATmega, and power the ATmega from the 3.3v pin on the Pi. Make sure you're not running any SPI device drivers, and run "avrdude -p m328p -c gpio" to verify the connection. + +See the individual pins to learn how to connect up your ATmega. \ No newline at end of file diff --git a/description/overlay/uart.md b/description/overlay/uart.md new file mode 100644 index 0000000..afaba3f --- /dev/null +++ b/description/overlay/uart.md @@ -0,0 +1,16 @@ +#UART - Universal Asynchronous Receiver/Transmitter + +###The 2 UART pins in WiringPi are: 15, 16 + +UART is a handy, straight forward way to interface an Arduino ( or bootloaded ATmega ) with your Pi. You must, however, be careful with logic-levels between the two devices: the Pi is 3.3v and the Arduino is 5v. Connect the two and you might conjure up some magic blue smoke. + +Personally I'm a fan of building out a Arduino Bootloaded ATmega 328 circuit on a breadboard with a voltage regulator to take the Pi's 5v line and convert it to 3.3v. The ATmega 328 seems to run quite happily at 3.3v using a 16Mhz crystal and you'll then have an Arduino clone with 3.3v logic. + +Assuming you have WiringPi2-Python installed, the following python example opens the Pi's UART at 9600baud and puts 'hello world' + +```python +import wiringpi2 as wiringpi +wiringpi.wiringPiSetup() +serial = wiringpi.serialOpen('/dev/ttyAMA0',9600) +wiringpi.serialPuts(serial,'hello world!') +``` \ No newline at end of file diff --git a/generate-html.py b/generate-html.py index e5199c7..ba4330e 100755 --- a/generate-html.py +++ b/generate-html.py @@ -11,6 +11,10 @@ resource_url = '/resources/' overlays = [ + 'spi', + 'uart', + 'i2c', + 'arduino-spi', 'pibrella', 'explorer-hat-pro', 'explorer-hat', @@ -21,7 +25,7 @@ template = open('template/layout.html').read() pages = {} navs = {} -select_overlays = {} +select_overlays = [] overlays_html = '' @@ -74,7 +78,7 @@ def load_overlay(overlay): loaded['page_url'] = slugify(loaded['name']) pages[loaded['page_url']] = render_overlay_page(loaded) navs[loaded['page_url']] = render_nav(loaded['page_url'], overlay=loaded) - select_overlays[loaded['page_url']] = loaded['name'] + select_overlays.append((loaded['page_url'], loaded['name'])) return loaded def load_md(filename): @@ -143,13 +147,18 @@ def render_pin(pin_num, selected_url, overlay=None): pin_name = pin['name'] pin_text_name = pin['name'] pin_used = False + pin_link_title = [] if overlay != None and str(pin_num) in overlay['pin']: + overlay_pin = overlay['pin'][str(pin_num)] pin_text_name = '' #print(overlay) - pin_name = overlay['pin'][str(pin_num)]['name'] + pin_name = overlay_pin['name'] pin_used = True + + if 'description' in overlay_pin: + pin_link_title.append(overlay_pin['description']) #alternates = [] #for overlay in overlays: @@ -169,8 +178,9 @@ def render_pin(pin_num, selected_url, overlay=None): # pin_subname_text = '({})'.format(pin['name']) pin_name = 'BCM {} {}'.format(bcm, pin_subname) # pin_text_name = 'BCM {} {}'.format(bcm, pin_subname_text) - #if 'wiringpi' in pin['scheme']: - # wiringpi = pin['scheme']['wiringpi'] + if 'wiringpi' in pin['scheme']: + wiringpi = pin['scheme']['wiringpi'] + pin_link_title.append('Wiring Pi pin {}'.format(wiringpi)) # alternates.append(render_alternate('wiringpi','Wiring Pi pin {}'.format(wiringpi))) #print(pin_type) @@ -185,13 +195,13 @@ def render_pin(pin_num, selected_url, overlay=None): if pin_used: selected += ' overlay-pin' - return '
  • {} {}
  • \n'.format( - pin_num, - ' '.join(map(slugify,pin_type)), - selected, - pin_url, - pin_num, - pin_name + return '
  • {pin_num} {pin_name}
  • \n'.format( + pin_num = pin_num, + pin_type = ' '.join(map(slugify,pin_type)), + pin_selected = selected, + pin_url = pin_url, + pin_title = ', '.join(pin_link_title), + pin_name = pin_name ) def render_nav(url, overlay=None): @@ -215,8 +225,8 @@ pins = db['pins'] overlays = map(load_overlay,overlays) -for url in select_overlays: - overlays_html += ''.format(url, select_overlays[url]) +for url, name in select_overlays: + overlays_html += ''.format(url, name) pages['pinout'] = render_overlay_page({'name':'Index','long_description':load_md('description/index.md')}) diff --git a/overlay/arduino-spi.json b/overlay/arduino-spi.json new file mode 100644 index 0000000..83270d2 --- /dev/null +++ b/overlay/arduino-spi.json @@ -0,0 +1,30 @@ +{ + "name": "Arduino SPI", + "description": "Program Arduino with Raspberry Pi SPI", + "pin": { + "19": { + "name": "MOSI", + "direction": "output", + "active": "high", + "description": "Master Out / Slave In" + }, + "21": { + "name": "MISO", + "direction": "input", + "active": "high", + "description": "Master In / Slave Out" + }, + "23": { + "name": "SCKL", + "direction": "output", + "active": "high", + "description": "Clock" + }, + "24": { + "name": "CE0", + "direction": "output", + "active": "high", + "description": "Arduino Reset" + } + } +} diff --git a/overlay/i2c.json b/overlay/i2c.json new file mode 100644 index 0000000..b2d9b27 --- /dev/null +++ b/overlay/i2c.json @@ -0,0 +1,26 @@ +{ + "name": "I2C", + "description": "Raspberry Pi i2c pins", + "pin": { + "3": { + "name": "Data", + "direction": "both", + "active": "high" + }, + "5": { + "name": "Clock", + "direction": "both", + "active": "high" + }, + "27": { + "name": "EEPROM Data", + "direction": "both", + "active": "high" + }, + "28": { + "name": "EEPROM Clock", + "direction": "both", + "active": "high" + } + } +} diff --git a/overlay/pibrella.json b/overlay/pibrella.json index a8120e9..628311f 100644 --- a/overlay/pibrella.json +++ b/overlay/pibrella.json @@ -1,6 +1,6 @@ { "name": "Pibrella", - "manufacturer": "Pimoroni", + "manufacturer": "Pimoroni Vs Cyntech", "url": "https://github.com/pimoroni/pibrella", "description": "An all-in-one light, sound, input and output add-on board.", "pincount": 26, diff --git a/overlay/spi.json b/overlay/spi.json new file mode 100644 index 0000000..f14b6c5 --- /dev/null +++ b/overlay/spi.json @@ -0,0 +1,37 @@ +{ + "name": "SPI", + "description": "Raspberry Pi SPI pins", + "pincount": 5, + "pin": { + "19": { + "name": "MOSI", + "direction": "output", + "active": "high", + "description": "Master Out / Slave In" + }, + "21": { + "name": "MISO", + "direction": "input", + "active": "high", + "description": "Master In / Slave Out" + }, + "23": { + "name": "SCKL", + "direction": "output", + "active": "high", + "description": "Clock" + }, + "24": { + "name": "CE0", + "direction": "output", + "active": "high", + "description": "Chip Select 0" + }, + "26": { + "name": "CE1", + "direction": "output", + "active": "high", + "description": "Chip Select 1" + } + } +} diff --git a/overlay/uart.json b/overlay/uart.json new file mode 100644 index 0000000..52f0c05 --- /dev/null +++ b/overlay/uart.json @@ -0,0 +1,16 @@ +{ + "name": "UART", + "description": "Raspberry Pi UART pins", + "pin": { + "8": { + "name": "TXD / Transmit", + "direction": "output", + "active": "high" + }, + "10": { + "name": "RXD / Receive", + "direction": "input", + "active": "high" + } + } +} diff --git a/resources/pinout.css b/resources/pinout.css index a8ec063..cac52b7 100644 --- a/resources/pinout.css +++ b/resources/pinout.css @@ -8,6 +8,8 @@ table td, table th {border:1px solid #073642;padding:5px;} table th {background:#073642;color:#EBE6D3;} table * {text-align:left;font-size:13px;} +h2 {font-size:18px;margin-top:20px;} + .main-nav { position:absolute; right:0px; @@ -51,6 +53,7 @@ nav#gpio { .bottom .phys {color:#002B36;} .bottom .active .phys, .bottom :hover .phys, .bottom .legend .phys {color:#FFF;} + #content { float:left; background:#EBE6D3; @@ -58,11 +61,9 @@ nav#gpio { min-height:600px; padding-bottom:60px; } + #content article { - background:#EBE6D3; padding:20px; - width:460px; - min-height:680px; } nav#gpio ul.top { position:absolute; @@ -303,4 +304,13 @@ li.legend_ledborg {background:#000000;} ul.legend li.legend_ledborg a {color:#FFFFFF;} li.legend_clockatoo {background:#D33682;} span.alternate {display:none;} -ol.linenums {margin-left:30px;} \ No newline at end of file +ol.linenums {margin-left:30px;} + +@media (min-width:1200px){ + #container { + width:1200px; + } + #content { + width:700px; + } +} \ No newline at end of file diff --git a/template/layout.html b/template/layout.html index 0f6d619..5100091 100644 --- a/template/layout.html +++ b/template/layout.html @@ -1,13 +1,14 @@ - + Raspberry Pi Pinout - Rev 2 Board + - +
    @@ -25,7 +26,7 @@
  • @Gadgetoid
  • Contribute
  • -

    Pinout

    +

    Pinout

    Learn more about: