RasPi Direct Hardware Access
Integrated peripheral access without operating system drivers.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Macros | Functions
spi.h File Reference

This file contains the whole API as static inline functions, since all functions are very short. More...

#include "raspi/hw.h"
#include <stdint.h>

Go to the source code of this file.

Macros

#define raspi_SPI_FIFOSIZE   16
 Size of both, the read and the write FIFO.
 

Functions

static void spi_init (uint32_t speed)
 Configure SPI hardware for speed bit/s.
 
static void spi_start (int destination)
 Start SPI transfer to destination (0 or 1, corresponding to the available chip select lines). The receive FIFO will be cleared.
 
static void spi_stop (void)
 Stop SPI transfer. Block until all pending data is transmitted.
 
static int spi_poll (int num)
 Return true if at least num bytes are available in the receive FIFO. Only guaranteed to work correctly with num == 1. Larger values may return true even if less bytes (but at least one) are available.
 
static uint8_t spi_read (void)
 Read a single byte received via SPI. Block if FIFO is currently empty. Note that SPI only receives while sending, so each spi_read() must be paired with an spi_write().
 
static void spi_write (uint8_t data)
 Send data via SPI. Block if FIFO is currently full. spi_start() must be called before.
 
static void spi_flush (void)
 Block until transmit FIFO is empty.
 

Detailed Description

This file contains the whole API as static inline functions, since all functions are very short.

There is no accompanying C file.

License

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.