Skip to content

Instantly share code, notes, and snippets.

@yunqu
Last active May 10, 2019 22:07
Show Gist options
  • Save yunqu/fb505d66d0dacf52624c25807e5d9935 to your computer and use it in GitHub Desktop.
Save yunqu/fb505d66d0dacf52624c25807e5d9935 to your computer and use it in GitHub Desktop.
LED demo using device tree overlay
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Demo: Using a Device Tree Overlay with the LED's"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/javascript": [
"\n",
"require(['notebook/js/codecell'], function(codecell) {\n",
" codecell.CodeCell.options_default.highlight_modes[\n",
" 'magic_text/x-csrc'] = {'reg':[/^%%microblaze/]};\n",
" Jupyter.notebook.events.one('kernel_ready.Kernel', function(){\n",
" Jupyter.notebook.get_cells().map(function(cell){\n",
" if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;\n",
" });\n",
"});\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from pynq import Overlay\n",
"\n",
"overlay = Overlay(\"base.bit\", dtbo=\"gpio_leds.dtbo\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"!insmod gpio-byu.ko"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from pynq import GPIO\n",
"from time import sleep\n",
"\n",
"led0 = GPIO(902, 'out')\n",
"led1 = GPIO(903, 'out')\n",
"led2 = GPIO(904, 'out')\n",
"led3 = GPIO(905, 'out')\n",
"\n",
"for i in range(3):\n",
" led0.write(1)\n",
" led1.write(1)\n",
" led2.write(1)\n",
" led3.write(1)\n",
" sleep(.5)\n",
" led0.write(0)\n",
" led1.write(0)\n",
" led2.write(0)\n",
" led3.write(0)\n",
" sleep(.5)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"!rmmod -f gpio-byu.ko"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment