Checking at configure/compile time for the features your code depends upon is the way to go. Checking for specific devices is problematic because avoiding false-positives is virtually impossible (someone could lie to you deliberately even with little effort) and the aim of such checks is to answer the question: "can I build here? If yes what code path should ...
On a computer you write to a specified 'memory address'. This address is recognised by the system as a hardware address, and the appropriate hardware receives or sends the appropriate value.
Most hardware systems have many different registers that can be set or read. Some might have a few, some might have many. These registers will be grouped into a ...
you should type:
if your file is in the current directory.
also, you might check if executable bit is set with
ls -al a.out
and if not, set it using
chmod +x a.out
however, most compilers will set executable bit for you automagically.
You need to put a ./ in front of a.out in order to execute that:
When you type the name of a program such as a.out the system looks
for the file in your PATH. On my system, PATH is set to
Yours is probably similar. To check, enter ...
I wrote a very simple kernel years ago, and ran it on a 386. I haven't done bare metal programming in years, but in broad terms you need to write some assembler code that will:
disable interrupts during the boot process
if the Pi has a memory controller, you'll need to set that up
set up a timer tick
configure the interrupt controller
set up a stack so ...
You can read the file /sys/class/thermal/thermal_zone0/temp, as specified in this answer. There it's about measuring from the command line, and the file is read with cat. But you should be able to just open the file in C. The temperature is returned in milli-degrees Centigrade and as ASCII numbers.
Perhaps like this, not tested :)
Do NOT use nano (or another text editor to put your code into) with root/sudo permissions (ie. do not edit with sudo nano, only use nano) if all you are doing is personal stuff that does not need superuser permissions.
To compile from the command line (assuming yourcode.c is the name of your C file, and program the name of the resulting program ...
Yes, you can develop elsewhere before deploying to the Pi.
However because the Pi is a different Architecture if you compile with your native compiler, your code wont be executable on the Pi.
This can be solved by using a cross-compiler. Essentially this is a second GCC compiler on your system which uses the ARM toolchain for compiling.
More information ...
I haven't looked at your code in depth, but it seems to me you're on the right track. Make sure that:
The _start symbol is indeed the one used when compiling & linking your assembly file and your C file (and that main() isn't used instead)
When calling main(), you need to use the C calling convention:
push on the stack the address of the instruction ...
Mechanical buttons and switches can suffer from switch bounce where they toggle rapidly between open and closed for several milliseconds.
You can try debouncing the button/switch in software or hardware.
Probably simplest in software.
If the level changes (on to off, or off to on) wait x milliseconds and read the gpio again. If it is still in the new ...
This depends on what libraries you wish to link your code with. If you are using the Raspbian images, the architecture is "armhf" and the compilation flags are:
If you are compiling for Debian "armel" arch, the compilation flags are different.
There is no official library
There are several options. I usually use http://wiringpi.com. This is used for the gpio utility included in recent Raspbian releases.
Joan's pigpio library is at https://github.com/joan2937/pigpio and she also has Python wrappers. If you want to use sockets or a daemon this is recommended and has good support for hardware and ...
The RPI ARM core is an ARM 1176jzf-S, the suitable flags should then be
-march=armv6zk -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp
Drop the -mfloat-abi=hard -mfpu=vfp when on a soft float distro.
These flags can be found by running gcc -mcpu=native -march=native -Q --help=target on gcc >= 4.7`
Take the time to read Jack Ganssle's debouncing guide. The first page illustrates the problem in great detail, and the second how to deal with it in hardware or software. There isn't a 'perfect' debounce method, but there are a lot of bad ones!
This is a problem you will come across repeatedly if interfacing software with switches, so it's worth taking ...
I have never tried to do this no the RPi, but I have on the Arduino platform several times, and I have used something along the lines of this Arduino code. Note you will have to rewrite a function similar to this for whatever language you are using:
unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = ...
I want to modify the distro according to my needs. [...] What about
the source for the actual distro? Is it all there? Am I insane?
The distro has sources, but these are either the same as or slightly patched versions of the original sources -- a distro does not really contain any original software per se (discounting the package manager), it is just an ...
That example from elinux uses memory-mapped IO. The kernel also exports a user space interface via /sys/class/gpio,1 which is also documented on elinux. Working in C you would use low level read()/write() instead of echo, obviously. Don't use higher level stream based functions.
Some programmers become a bit upset when told to use a file interface for ...
First and foremost:
If I were in your shoes, I would stay away from Wiegand in general!!!
Wiegand is a swipecard protocol developed in the 1980s. It does not use any form of clock signal or speed indication, the data timing is done based on the last bit that was transferred + the Wiegand delay time. This is a disadvantage but does not make it ...
That should be possible in Java, as referenced here. The library which is used is called rpi-gpio-java and is available at this URL. As stated in the notes, to make it work, please make sure your application is run as root.
Note: Above project rpi-gpio-java is no longer available on google code. Alternate option is PI4J
command to run code in /etc/rc.local
Three things to remember when putting commands in rc.local:
Don't use sudo, because the script is run as root anyway.
Unless the command exits quickly, it must fork to the background. This is accomplished by adding & to the end:
$PATH may not be set. This is a list of directories where the shell ...
This returns the same thing as reading /sys/class/thermal, i.e., the core temp. Reading the /sys file is preferable programmatically because it is just a sequence of open/read system calls, instead of a fork/execute plus a bunch of open/read/write with pipes.
How would I read the GPU temperature aswell?
The BCM2835/6 ...
To set a pin numbering scheme you use one of four Setup functions:
int wiringPiSetup (void);
int wiringPiSetupGpio (void);
int wiringPiSetupPhys (void);
int wiringPiSetupSys (void);
To use BCM GPIO numbering you would replace you would use wiringPiSetupGpio(void); and modify the pin numbers in your code appropriately.
I'm wondering, may understand that Raspberry Pi's I2C is in fact the SMBus version of I2C ?
I don't think it is limited in that sense but that is the normative way to use it. There is no such limitation with the kernel, since the protocol docs for the interface say, "If you write a driver for some I2C device, please try to use the SMBus commands if at all ...
What you are trying to achieve is almost impossible using operating system. It's really hard to have some hard real time user space mechanism inside operating system. You can try with some RT systems (I don't know if there are some RPi ports) or real time application interface (RTAI, Xenomai, RT Linux) and write some RT module.
nanosleep() suspends the ...
I can confirm that SDL_mixer works on the pi. I am working on a platform game and use SDL for graphics and sound. My sounds are in the ogg format, but SDL_mixer promises mp3 support as well. I have raspbian, every SDL package I needed I could install from the repositories.
Btw, the same game runs well and with sound on 64 bit linux too (at least Ubuntu and ...
Yes it's safe. Judging from the source code of the library, it doesn't cache the values but reads them each time you call digitalRead function so it should work as expected.
It isn't really documented in the wiringPi documentation but at least the documentation also doesn't say it's forbidden (for example for digitalWrite there ...
MAXTIMINGS means how many databits that the sensor sends is going to be read and stored (note that acording to the datasheet, it should send 40 bits in response).
In order to understand this, you have to first understand how DHT22 is sending it's data to the host computer. It uses one wire, where host sends start signal:
I misunderstood your question initially. Here is some C code that, when run, will record raw PCM data. You must pipe this to another program or lots of gibberish will be printed to the console.
/* Use the newer ALSA API */