Coder Social home page Coder Social logo

pj_rpi's People

Contributors

argorain avatar pieter-jan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pj_rpi's Issues

SET_GPIO_ALT(28, 0) doesn't work

Hello.

I tried to use GPIO28 and GPIO29 as I2C.
So, I used SET_GPIO_ALT(28, 0) and SET_GPIO_ALT(29, 0) after INP_GPIO(28) and INP_GPIO(29), respectively.
But, my code, which worked fine with I2C-1, doesn't work with that command.
GPIO28, GPIO29 pins are not woking in I2C mode.
I looked through the bcm2385 library and it looks all the parts related to GPIO setting is the same.

Any idea?

improvement for macro OUT_GPIO and SET_GPIO_ALT

define them like this and we will not forget to call INP_GPIO:

define OUT_GPIO(g) INP_GPIO(g); _(gpio.addr + ((g)/10)) |= (1<<(((g)%10)_3))

define SET_GPIO_ALT(g,a) INP_GPIO(g); _(gpio.addr + (((g)/10))) |= (((a)<=3?(a) + 4:(a)==4?3:2)<<(((g)%10)_3))

wrapping macros

Hi there!

I tend to forget things... so why not wrap the INP_GPIO macro inside the OUT_GPIO and SET_GPIO_ALT ones? Like so:

#define OUT_GPIO(g)       do { \
  INP_GPIO(g); \
  *(gpio.addr + ((g)/10)) |=  (1<<(((g)%10)*3)); \
} while(0)

#define SET_GPIO_ALT(g,a) do { \
  INP_GPIO(g); \
  *(gpio.addr + (((g)/10))) |= (((a)<=3?(a) + 4:(a)==4?3:2)<<(((g)%10)*3)); \
} while(0)

Also helps to get cleaner code. Tested on my rpi and works great ;)

incorrect macro GPIO_READ

define GPIO_READ(g) *(gpio.addr + 13) &= (1<<(g))

should be

define GPIO_READ(g) (*(gpio.addr + 13) &= (1<<(g)))

otherwise, consider the following code:
if (GPIO_READ(echo) != 0) {
}

the operator "&=" has very low prority, even lower than "!=".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.