1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00
LibrePilot/flight/PiOS/inc/pios_i2c.h
gussy ff73ab5a80 More updates to cross-target compatibility.
Added PIOS_I2C into AHRS code.
Added PIOS_HMC5843 Module.




git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@617 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-05-12 08:18:49 +00:00

64 lines
2.3 KiB
C

/**
******************************************************************************
*
* @file pios_i2c.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Thorsten Klose (tk@midibox.org)
* @brief I2C functions header.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_I2C_H
#define PIOS_I2C_H
/* Local defines */
#define I2C_ERROR_INVALID_PORT -1
#define I2C_ERROR_GENERAL -2
#define I2C_ERROR_UNSUPPORTED_TRANSFER_TYPE -3
#define I2C_ERROR_TIMEOUT -4
#define I2C_ERROR_ARBITRATION_LOST -5
#define I2C_ERROR_BUS -6
#define I2C_ERROR_SLAVE_NOT_CONNECTED -7
#define I2C_ERROR_UNEXPECTED_EVENT -8
#define I2C_ERROR_RX_BUFFER_OVERRUN -9
#define I2C_ERROR_BUSY -10
/* Global Types */
typedef enum {
I2C_Read,
I2C_Write,
I2C_Write_WithoutStop
} I2CTransferTypeDef;
/* Public Functions */
extern int32_t PIOS_I2C_Init(void);
extern int32_t PIOS_I2C_TransferCheck(void);
extern int32_t PIOS_I2C_TransferWait(void);
extern int32_t PIOS_I2C_Transfer(I2CTransferTypeDef transfer, uint8_t address, uint8_t *buffer, uint16_t len);
extern void PIOS_I2C_StartTransfer(I2CTransferTypeDef transfer, uint8_t address, uint8_t *buffer, uint16_t len);
#ifdef PIOS_INCLUDE_FREERTOS
extern bool PIOS_I2C_LockDevice(portTickType timeout);
extern void PIOS_I2C_UnlockDevice(void);
#endif // PIOS_INCLUDE_FREERTOS
#endif /* PIOS_I2C_H */