Code Monkey home page Code Monkey logo

mcp23008_stm32's Introduction

MCP23008_STM32

STM32 HAL driver for MCP23008 I2C 8-channel port expander. A simple, bare-bones driver, that would be easily expanded if required. Supports multiple devices on the same device on the same or difference I2C PHYs. Only port-wide operations are supported (no read-mod-write support, yet). If you add any features, please send a pull request.

Interface

To use, simply include the driver folder into the project, add the folder to the build path, and then include the header in your main.c file.

#include "MCP23008.h"

The driver impliments the following functions:

  • HAL_StatusTypeDef MCP23008_Init(I2C_HandleTypeDef *hi2c, MCP23008_HandleTypeDef *hdfm, uint8_t deviceAddress) - pass the STM32 HAL I2C handle, a MCP23008 device handle, and device address. This allows you to have more than one device (with a different address).
  • uint8_t MCP23008_SetDirection(MCP23008_HandleTypeDef *hdfm, uint8_t dir) - Set the direction register. 1=input, 0=output.
  • uint8_t MCP23008_GetDirection(MCP23008_HandleTypeDef *hdfm) - Read the direction register. 1=input, 0=output.
  • uint8_t MCP23008_SetPolarity(MCP23008_HandleTypeDef *hdfm, uint8_t pol) - Set the polarity register. 1=inverted, 0=as per pin.
  • uint8_t MCP23008_GetPolarity(MCP23008_HandleTypeDef *hdfm) - Read the polarity register. 1=inverted, 0=as per pin.
  • uint8_t MCP23008_SetPullups(MCP23008_HandleTypeDef *hdfm, uint8_t pull) - Set the pullups register. 1=pullup enabled, 0=pullup disabled.
  • uint8_t MCP23008_GetPullups(MCP23008_HandleTypeDef *hdfm) - Read the pullups register. 1=pullup enabled, 0=pullup disabled.
  • uint8_t MCP23008_WriteGPIO(MCP23008_HandleTypeDef *hdfm, uint8_t value) - Set the outputs
  • uint8_t MCP23008_ReadGPIO(MCP23008_HandleTypeDef *hdfm) - Read the inputs

mcp23008_stm32's People

Contributors

m1geo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.