Comments (6)
Doing the pin setup manually won't load the kernel driver, which is the key point of raspi-config. Anyhow here's the documentation to do what you asked for.
The function you want is https://godoc.org/periph.io/x/periph/host/bcm283x#Pin.SetFunc
Documentation is at https://godoc.org/periph.io/x/periph/conn/pin#PinFunc
Constants are at https://godoc.org/periph.io/x/periph/conn/i2c#pkg-constants
from periph.
Can you explain what you are trying to achieve? We never used wiringpi.
from periph.
Ok, I'll try my best.
The whole setup is for the I2C. Basically, the first 4 lines of wiringPi code are setting the GPIO0
and GPIO1
to input mode and then sets the pin functionality to operational mode 4 (use as I2C).
You can check the datasheet (page 102) for the operational modes and see this post explaining what this mode 0b100
means (translates ALT0 or operational mode 4).
The last 4 lines, sets the GPIO2
and GPIO3
to output and sets to HIGH.
from periph.
Then what about enabling i2c1 in raspi-config then use i2creg?
from periph.
References:
- https://godoc.org/periph.io/x/periph/conn/i2c/i2creg
- https://godoc.org/periph.io/x/periph/host/rpi
- https://www.raspberrypi.org/documentation/configuration/raspi-config.md
from periph.
Then what about enabling i2c1 in raspi-config then use i2creg?
Because I'm having a REST server that's written in Go which is supposed to have an endpoint that does the pin setup. So I wanted to use this lib to achieve that instead of calling exec.
Thanks for the references, but do you have some example illustrating how to setup some pins as I2C using i2creg?
from periph.
Related Issues (20)
- All pins are exported during bcm283x Init HOT 3
- Support for firmata HOT 2
- gpio-read: bcm283x-gpio (GPIO7): pull cannot be used when subsystem gpiomem not initialized. HOT 21
- Go get fetches v3.4.0 if using go modules HOT 3
- Support for BME680 HOT 3
- Halt() does not unblock WaitForEdge() HOT 3
- Feature SSD1322 HOT 5
- mfrc522 constantly returns "IRQ error" after first read HOT 11
- spi to slow HOT 5
- onewire didnot work HOT 9
- Omega2: declare headers HOT 3
- Experimental serial package doesn't export essential func HOT 7
- Unable to set GPIO pin pull on Raspberry Pi 4 HOT 19
- MFRC522 hang on WaitForEdge HOT 2
- HX711: unstable readings and reading before data is ready HOT 2
- spi: rename MISO/MOSI to COPI/CIPO HOT 2
- I2C documentation not clear on read/write operation HOT 2
- MFRC522 - Problem reading Tag HOT 3
- pmem example code incorrect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from periph.