Skip to content

Commit 24e6a2b

Browse files
committed
Initial commit
0 parents  commit 24e6a2b

126 files changed

Lines changed: 72028 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
firmware/pico-sdk
2+
firmware/source/build/
3+
firmware/source/config.h.in
4+
*.idea
5+
dist
6+
u2if.egg-info
7+
build
8+
*.txt.user
9+
__pycache__
10+
venv/

LICENSE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
See License files for the three parts of the u2if project:
2+
- python library: source/LICENSE
3+
- firmware for raspberry pico: firmware/source/LICENSE
4+
- KiCad dev. board: board/LICENSE
5+

README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# u2if project
2+
3+
u2if(USB to interfaces) is an attempt to implement some of the MicroPython "machine" module functionalities on a computer.
4+
The goal is to be able to communicate with breakout boards (sensors, lcd...) simply from a python program on x86 machine. It uses a Raspberry PICO microcontroller to make the interface between the computer (USB) and peripherals/protocols.
5+
6+
<p align="center"><img src="images/principle.png"/></p>
7+
8+
**Python led swith on/off**:
9+
```python
10+
import time
11+
from machine import u2if, Pin
12+
13+
# Initialize GPIO to output and set the value HIGH
14+
led = Pin(u2if.GP_3, Pin.OUT, value=Pin.HIGH)
15+
time.sleep(1)
16+
# Switch off the led
17+
led.value(Pin.LOW)
18+
```
19+
20+
## Caution
21+
22+
It is in experimental state and not everything has been tested. Use with caution. It is supposed to work on windows, linux and Mac.
23+
To work in Linux in non-root, an udev rules has to be added (See [Firmware readme](firmware/README.md)).
24+
25+
26+
## Why this project ?
27+
When I want to retrieve values from a sensor or even to play with a led or a button from the PC, I make an arduino program that communicate to the PC via the serial port. That umplies to define a serial "protocol" between the PC and the arduino and it is not necessarily reusable because it is specific.
28+
29+
Solutions already exist, for example [Blinka](https://github.com/adafruit/Adafruit_Blinka) from Adafruit via the FT2232H in CircuitPython or pyftdi in Python with the same IC.
30+
31+
Nevertheless I find it interesting to implement a majority of the functionalities of the machine module and add other protocols.
32+
33+
## Implemented Interfaces
34+
The following features are coded:
35+
36+
* machine.Pin: input (+irq, +debounced), output (+pull down/up).
37+
* machine.Signal
38+
* machine.ADC: read (12bits)
39+
* machine.UART
40+
* machine.I2C
41+
* machine.SPI
42+
* machine.PWM
43+
44+
Other features to do:
45+
* WS2812B led driver
46+
* I2S
47+
* ...
48+
49+
## Licenses and Project directories
50+
This repository is presented as the sources of a python project ([License](source/LICENSE)).
51+
But it also contains the following projects:
52+
53+
* [firmware](firmware/): PICO firmware, binary and C++ source [License](firmware/source/LICENSE).
54+
* [examples](examples/): Python program examples.
55+
* [board](board/): Example of a pico headers board for this project ([License](firmware/source/LICENSE)).
56+
57+
58+
## How to use it
59+
60+
### Upload PICO firmware
61+
See [Firmware README](firmware/README.md)
62+
63+
### Install u2if python package
64+
65+
Install python package from release file (u2if-*.*.tar.gz) with python3 -m pip install dist/u2if-*.*.tar.gz
66+
67+
## Build u2if python package
68+
69+
To build package if wanted :
70+
71+
* If needed, install build: python3 -m pip install --upgrade build
72+
* Build it: python3 -m build
73+
74+
75+
### Examples
76+
77+
There is no documentation but [examples](examples/) can help to use this library :
78+
79+
* Led On/Off
80+
* Switch with or whithour irq and debouncing
81+
* PWM controlling servo-motor
82+
* Display testing: SSD1306 (I2C and SPI), GC9A01 (round lcd)
83+
* Some sensors simple test: MPU9250 (IMU), VL53L0X (range), BMP280(Temp)
84+
* UART read/Write
85+
* Analog read.
86+
* Rotrary encoder
87+
* I2C scan
88+
* ...
89+
90+
91+
## u2if pinout
92+
93+
For simplicity, the pins of the SPI, I2C and UART devices have been fixed. If a peripheral is not used, its pins can be used as a classic I/O.
94+
<p align="center"><img src="images/u2if_pinout.png"/></p>
95+
96+
## Troubleshooting
97+
### Import error using MicroPython module
98+
#### import ustruct
99+
100+
The ustruct module is belongs by micropython. There is a micropython-cpython-ustruct compatibility module, but it doesn't seem to work for me. If necessary modify:
101+
```python
102+
import ustruct
103+
```
104+
to:
105+
```python
106+
import struct as ustruct
107+
```
108+
109+
#### import utime & const
110+
111+
Install micropython-cpython-utime and micropython-cpython-micropython.
112+
113+
114+

board/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# From https://raw.githubusercontent.com/github/gitignore/master/KiCad.gitignore
2+
# For PCBs designed using KiCad: http://www.kicad-pcb.org/
3+
# Format documentation: http://kicad-pcb.org/help/file-formats/
4+
5+
# Temporary files
6+
*.000
7+
*.bak
8+
*.bck
9+
*.kicad_pcb-bak
10+
*.kicad_sch-bak
11+
*.kicad_prl
12+
*.sch-bak
13+
*~
14+
_autosave-*
15+
*.tmp
16+
*-save.pro
17+
*-save.kicad_pcb
18+
fp-info-cache
19+
20+
# Netlist files (exported from Eeschema)
21+
*.net
22+
23+
# Autorouter files (exported from Pcbnew)
24+
*.dsn
25+
*.ses
26+
27+
# Exported BOM files
28+
*.xml
29+
*.csv
30+

board/LICENSE

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Project u2if (KiCad dev. board):
2+
--------------------------------
3+
4+
MIT License
5+
6+
Copyright (c) 2021 execuc
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE.
25+
26+
27+
28+
External library licenses:
29+
--------------------------
30+
31+
--------------
32+
KiCad library:
33+
--------------
34+
35+
Creative Commons CC-BY-SA 4.0 License
36+
------------------------------------------------------------------------------
37+
38+
------------------------------------------------------------------------------
39+
Raspberry Pico KiCad library (https://github.com/HeadBoffin/RP_Silicon_KiCad):
40+
------------------------------------------------------------------------------
41+
The original Raspberry Pi Foundation / Trading license:
42+
43+
These design files are made available openly, with no limitations.
44+
45+
Permission to use, copy, modify, and/or distribute this design for
46+
any purpose with or without fee is hereby granted.
47+
48+
THE DESIGN IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
49+
WITH REGARD TO THIS DESIGN INCLUDING ALL IMPLIED WARRANTIES OF
50+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
51+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
52+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
53+
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
54+
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS DESIGN.
55+
56+
57+
Which looks rather like the UnLicense:
58+
59+
This is free and unencumbered software released into the public domain.
60+
61+
Anyone is free to copy, modify, publish, use, compile, sell, or
62+
distribute this software, either in source code form or as a compiled
63+
binary, for any purpose, commercial or non-commercial, and by any
64+
means.
65+
66+
In jurisdictions that recognize copyright laws, the author or authors
67+
of this software dedicate any and all copyright interest in the
68+
software to the public domain. We make this dedication for the benefit
69+
of the public at large and to the detriment of our heirs and
70+
successors. We intend this dedication to be an overt act of
71+
relinquishment in perpetuity of all present and future rights to this
72+
software under copyright law.
73+
74+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
76+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
77+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
78+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
79+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
80+
OTHER DEALINGS IN THE SOFTWARE.
81+
82+
For more information, please refer to <https://unlicense.org>
83+
84+
85+
-------------------------------------------------------------------------------------------------------------------------
86+
87+
88+
89+

board/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PICO headers dev board
2+
3+
<p align="center"><img src="images/pcb_3d.png"/></p>
4+
5+
It's a kicad project of a PCB with some I/O but mostly headers.
6+
Zipped gerber file is available: [Gerber file](pico-dev/gerber/pico-dev.zip)
7+
8+
**Caution**: I am not an electronic engineer, check schematics and PCB before using it !
9+
10+
<p align="center"><img src="images/pcb.jpg"/></p>
11+
12+

board/images/pcb.jpg

145 KB
Loading

board/images/pcb_3d.png

122 KB
Loading
69.2 KB
Loading
62.8 KB
Loading

0 commit comments

Comments
 (0)