Subversion Repositories idreammicro-avr

Rev

Rev 31 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \brief MCP23008 library
 * \author Copyright (C) 2012  Julien Le Sech - www.idreammicro.com
 * \version 1.0
 * \date 20121025
 *
 * This file is part of the iDreamMicro library.
 *
 * This library is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This library 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 Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 ******************************************************************************/


/**************************************************************************//**
 * \headerfile mcp23008.h
 ******************************************************************************/


#ifndef H__IDREAMMICRO__MCP23008__H
#define H__IDREAMMICRO__MCP23008__H

#ifdef _cplusplus
extern "C"{
#endif

/******************************************************************************
 * Header file inclusions.
 ******************************************************************************/


#include <stdint.h>

/******************************************************************************
 * Public macro definitions.
 ******************************************************************************/


#define MCP23008__GP0   0
#define MCP23008__GP1   1
#define MCP23008__GP2   2
#define MCP23008__GP3   3
#define MCP23008__GP4   4
#define MCP23008__GP5   5
#define MCP23008__GP6   6
#define MCP23008__GP7   7

/******************************************************************************
 * Public type definitions.
 ******************************************************************************/


/**************************************************************************//**
 * \enum mcp23008__directions
 * \brief MCP23008 pin/port directions.
 *
 * \typedef mcp23008__direction_t
 * \brief MCP23008 pin/port direction.
 ******************************************************************************/

typedef enum mcp23008__directions
{
    MCP23008__DIRECTION__INPUT, /*!<  Input. */
    MCP23008__DIRECTION__OUTPUT /*!<  Output. */
} mcp23008__direction_t;

/**************************************************************************//**
 * \enum mcp23008__levels
 * \brief MCP23008 GPIO levels.
 *
 * \typedef mcp23008__level_t
 * \brief MCP23008 GPIO level.
 ******************************************************************************/

typedef enum mcp23008__levels
{
    MCP23008__LEVEL__LOW,       /*!<  Low level. */
    MCP23008__LEVEL__HIGH       /*!<  High level. */
} mcp23008__level_t;

/**************************************************************************//**
 * \typedef mcp23008__gpio_t
 * \brief
 ******************************************************************************/

typedef uint8_t mcp23008__gpio_t;

/******************************************************************************
 * Public function prototypes.
 ******************************************************************************/


/**************************************************************************//**
 * \fn void mcp23008__initialize(uint8_t hardware_address)
 *
 * \brief Initialize MCP23008.
 *
 * \param hardware_address      Hardware address defined by pins A0 to A2.
 ******************************************************************************/

void
mcp23008__initialize
(
    uint8_t hardware_address
);

/**************************************************************************//**
 *
 ******************************************************************************/

void
mcp23008__configure_pin
(
    mcp23008__gpio_t        pin,
    mcp23008__direction_t   direction
);

/**************************************************************************//**
 *
 ******************************************************************************/

void
mcp23008__configure_port
(
    mcp23008__direction_t direction
);

/**************************************************************************//**
 *
 ******************************************************************************/

mcp23008__level_t
mcp23008__get_pin_level
(
    mcp23008__gpio_t pin
);

/**************************************************************************//**
 *
 ******************************************************************************/

void
mcp23008__set_pin_level
(
    mcp23008__gpio_t    pin,
    mcp23008__level_t   level
);

/**************************************************************************//**
 *
 ******************************************************************************/

uint8_t
mcp23008__get_port_value
(
    void
);

/**************************************************************************//**
 *
 ******************************************************************************/

void
mcp23008__set_port_value
(
    uint8_t value
);

#ifdef _cplusplus
}
#endif

#endif /* H__IDREAMMICRO__MCP23008__H */