update credits
[librepilot.git] / flight / pios / inc / pios_spi.h
blob93218d667361e147dae768aedee32503a5e465f4
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
5 * @addtogroup PIOS_SPI SPI Functions
6 * @{
8 * @file pios_spi.h
9 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
10 * @brief SPI functions header.
11 * @see The GNU Public License (GPL) Version 3
13 *****************************************************************************/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * for more details.
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #ifndef PIOS_SPI_H
31 #define PIOS_SPI_H
33 /* Global types */
34 typedef enum {
35 PIOS_SPI_PRESCALER_2 = 0,
36 PIOS_SPI_PRESCALER_4 = 1,
37 PIOS_SPI_PRESCALER_8 = 2,
38 PIOS_SPI_PRESCALER_16 = 3,
39 PIOS_SPI_PRESCALER_32 = 4,
40 PIOS_SPI_PRESCALER_64 = 5,
41 PIOS_SPI_PRESCALER_128 = 6,
42 PIOS_SPI_PRESCALER_256 = 7
43 } SPIPrescalerTypeDef;
45 /* Public Functions */
46 extern int32_t PIOS_SPI_SetClockSpeed(uint32_t spi_id, SPIPrescalerTypeDef spi_prescaler);
47 extern int32_t PIOS_SPI_RC_PinSet(uint32_t spi_id, uint32_t slave_id, uint8_t pin_value);
48 extern int32_t PIOS_SPI_TransferByte(uint32_t spi_id, uint8_t b);
49 extern int32_t PIOS_SPI_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len, void *callback);
50 extern int32_t PIOS_SPI_Busy(uint32_t spi_id);
51 extern int32_t PIOS_SPI_ClaimBus(uint32_t spi_id);
52 extern int32_t PIOS_SPI_ClaimBusISR(uint32_t spi_id, bool *woken);
53 extern int32_t PIOS_SPI_ReleaseBus(uint32_t spi_id);
54 extern int32_t PIOS_SPI_ReleaseBusISR(uint32_t spi_id, bool *woken);
55 extern void PIOS_SPI_IRQ_Handler(uint32_t spi_id);
56 extern void PIOS_SPI_SetPrescalar(uint32_t spi_id, uint32_t prescalar);
58 #endif /* PIOS_SPI_H */
60 /**
61 * @}
62 * @}