ssd1306 i2c .h - JohnHau/mis GitHub Wiki

/**

  • original author: Tilen Majerle[email protected]

  • modification for STM32f10x: Alexander Lutsai[email protected]

    Copyright (C) Alexander Lutsai, 2016 Copyright (C) Tilen Majerle, 2015

    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 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, see http://www.gnu.org/licenses/.

*/ #ifndef ssd1306_I2C_H #define ssd1306_I2C_H 161

#include "stm32f10x.h" #include "stm32f10x_i2c.h" #include "stm32f10x_rcc.h" #include "stm32f10x_gpio.h"

#ifndef ssd1306_I2C_TIMEOUT #define ssd1306_I2C_TIMEOUT 20000 #endif

void ssd1306_I2C_Init();

/**

  • @brief Writes single byte to slave
  • @param *I2Cx: I2C used
  • @param address: 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used
  • @param reg: register to write to
  • @param data: data to be written
  • @retval None / void ssd1306_I2C_Write(I2C_TypeDef I2Cx, uint8_t address, uint8_t reg, uint8_t data);

/**

  • @brief Writes multi bytes to slave
  • @param *I2Cx: I2C used
  • @param address: 7 bit slave address, left aligned, bits 7:1 are used, LSB bit is not used
  • @param reg: register to write to
  • @param *data: pointer to data array to write it to slave
  • @param count: how many bytes will be written
  • @retval None / void ssd1306_I2C_WriteMulti(I2C_TypeDef I2Cx, uint8_t address, uint8_t reg, uint8_t *data, uint16_t count);

/**

  • @brief I2C Start condition
  • @param *I2Cx: I2C used
  • @param address: slave address
  • @param direction: master to slave or slave to master
  • @param ack: ack enabled or disabled
  • @retval Start condition status
  • @note For private use / int16_t ssd1306_I2C_Start(I2C_TypeDef I2Cx, uint8_t address, uint8_t direction, uint8_t ack);

/**

  • @brief Stop condition on I2C
  • @param *I2Cx: I2C used
  • @retval Stop condition status
  • @note For private use / uint8_t ssd1306_I2C_Stop(I2C_TypeDef I2Cx);

/**

  • @brief Writes to slave
  • @param *I2Cx: I2C used
  • @param data: data to be sent
  • @retval None
  • @note For private use / void ssd1306_I2C_WriteData(I2C_TypeDef I2Cx, uint8_t data);

#endif