RasPi Direct Hardware Access
Integrated peripheral access without operating system drivers.
|
This is a light-weight library for easy access to the Raspberry Pi's integrated peripherals. It can be used from user mode as well as from kernel mode, and it works fine from a real-time context of one of the real-time Linux patches like Xenomai. It even works when doing bare-metal programming. Note that this library does not handle the on-board LAN chip of Model B RasPis. That one is accessed through USB.
The latest version can be obtained via GitHub: https://github.com/offis/raspi-directhw
raspi/hw.h
contains base register declarations, most importantly HW. Many registers are specified down to the individual register bit.
It also contains helper functions for GPIO and system timer access. raspi/uart.h
, raspi/spi.h
, and raspi/spisl.h
contain more hardware helpers.
In order to use this API, you need to include raspi/hw.c
in (exactly) one of your source files. There are no C files to compile, and thus no libraries to link. Everything is small enough to use inline static declarations efficiently.
If running in user mode you need to call raspi_map_hw()
at the start of your program. After initialization, HW is the single entry point to all registers.
A final warning: Always use memory_barrier()
in appropriate places, no matter what you use, API helpers or direct register access.
See Modules for an API overview and gpio_test.c for a basic code example.
Copyright (c) 2013 OFFIS e.V.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.