The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Mon Mar 19 15:30:13 2018 +0000
Revision:
162:dbaafcfe0e9d
Parent:
TARGET_WIZwiki_W7500/TARGET_WIZNET/TARGET_W7500x/W7500x_Peripheral_Library/W7500x_i2c.h@107:4f6c30876dfa
mbed library. Release version 160

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /* mbed Microcontroller Library
Kojto 107:4f6c30876dfa 2 *******************************************************************************
Kojto 107:4f6c30876dfa 3 * Copyright (c) 2015 WIZnet Co.,Ltd. All rights reserved.
Kojto 107:4f6c30876dfa 4 * All rights reserved.
Kojto 107:4f6c30876dfa 5 *
Kojto 107:4f6c30876dfa 6 * Redistribution and use in source and binary forms, with or without
Kojto 107:4f6c30876dfa 7 * modification, are permitted provided that the following conditions are met:
Kojto 107:4f6c30876dfa 8 *
Kojto 107:4f6c30876dfa 9 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 107:4f6c30876dfa 10 * this list of conditions and the following disclaimer.
Kojto 107:4f6c30876dfa 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 107:4f6c30876dfa 12 * this list of conditions and the following disclaimer in the documentation
Kojto 107:4f6c30876dfa 13 * and/or other materials provided with the distribution.
Kojto 107:4f6c30876dfa 14 * 3. Neither the name of ARM Limited nor the names of its contributors
Kojto 107:4f6c30876dfa 15 * may be used to endorse or promote products derived from this software
Kojto 107:4f6c30876dfa 16 * without specific prior written permission.
Kojto 107:4f6c30876dfa 17 *
Kojto 107:4f6c30876dfa 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 107:4f6c30876dfa 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 107:4f6c30876dfa 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 107:4f6c30876dfa 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 107:4f6c30876dfa 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 107:4f6c30876dfa 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 107:4f6c30876dfa 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 107:4f6c30876dfa 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 107:4f6c30876dfa 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 107:4f6c30876dfa 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 107:4f6c30876dfa 28 *******************************************************************************
Kojto 107:4f6c30876dfa 29 */
Kojto 107:4f6c30876dfa 30 /*include -------------------------------------*/
Kojto 107:4f6c30876dfa 31 #ifndef __W7500X_I2C_H
Kojto 107:4f6c30876dfa 32 #define __W7500X_I2C_H
Kojto 107:4f6c30876dfa 33
Kojto 107:4f6c30876dfa 34 #include "W7500x.h"
Kojto 107:4f6c30876dfa 35
Kojto 107:4f6c30876dfa 36
Kojto 107:4f6c30876dfa 37 typedef enum {
Kojto 107:4f6c30876dfa 38 I2C_PA_5 = 0x05,
Kojto 107:4f6c30876dfa 39 I2C_PA_6 = 0x06,
Kojto 107:4f6c30876dfa 40 I2C_PA_9 = 0x09,
Kojto 107:4f6c30876dfa 41 I2C_PA_10 = 0x0A,
Kojto 107:4f6c30876dfa 42 I2C_PC_4 = 0x24,
Kojto 107:4f6c30876dfa 43 I2C_PC_5 = 0x25,
Kojto 107:4f6c30876dfa 44 I2C_PC_8 = 0x28,
Kojto 107:4f6c30876dfa 45 // Not connected
Kojto 107:4f6c30876dfa 46 I2C_NC = (int)0xFFFFFFFF
Kojto 107:4f6c30876dfa 47 } I2C_PinName;
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 typedef struct
Kojto 107:4f6c30876dfa 50 {
Kojto 107:4f6c30876dfa 51 I2C_PinName scl;
Kojto 107:4f6c30876dfa 52 I2C_PinName sda;
Kojto 107:4f6c30876dfa 53 }I2C_ConfigStruct;
Kojto 107:4f6c30876dfa 54
Kojto 107:4f6c30876dfa 55
Kojto 107:4f6c30876dfa 56 #define I2C_PORT(X) (((uint32_t)(X) >> 4) & 0xF) // port number (0=A, 1=B, 2=C, 3=D)
Kojto 107:4f6c30876dfa 57 #define I2C_PIN_INDEX(X) (1 << ((uint32_t)(X) & 0xF)) // pin index : flag bit
Kojto 107:4f6c30876dfa 58
Kojto 107:4f6c30876dfa 59 uint32_t I2C_Init(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 60
Kojto 107:4f6c30876dfa 61 void I2C_WriteBitSDA(I2C_ConfigStruct* conf, uint8_t data);
Kojto 107:4f6c30876dfa 62 void I2C_WriteBitSCL(I2C_ConfigStruct* conf, uint8_t data);
Kojto 107:4f6c30876dfa 63 uint8_t I2C_ReadBitSDA(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 64
Kojto 107:4f6c30876dfa 65 void I2C_SendACK(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 66 void I2C_SendNACK(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 67
Kojto 107:4f6c30876dfa 68 uint8_t I2C_WriteByte(I2C_ConfigStruct* conf, uint8_t data);
Kojto 107:4f6c30876dfa 69 uint8_t I2C_ReadByte(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 70
Kojto 107:4f6c30876dfa 71 void I2C_Start(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 72 void I2C_Stop(I2C_ConfigStruct* conf);
Kojto 107:4f6c30876dfa 73
Kojto 107:4f6c30876dfa 74 int I2C_Write(I2C_ConfigStruct* conf, uint8_t addr, uint8_t* data, uint32_t len);
Kojto 107:4f6c30876dfa 75 int I2C_WriteRepeated(I2C_ConfigStruct* conf, uint8_t addr, uint8_t* data, uint32_t len);
Kojto 107:4f6c30876dfa 76 int I2C_Read(I2C_ConfigStruct* conf, uint8_t addr, uint8_t* data, uint32_t len);
Kojto 107:4f6c30876dfa 77 int I2C_ReadRepeated(I2C_ConfigStruct* conf, uint8_t addr, uint8_t* data, uint32_t len);
Kojto 107:4f6c30876dfa 78
Kojto 107:4f6c30876dfa 79
Kojto 107:4f6c30876dfa 80 #endif //__W7500X_I2C_H
Kojto 107:4f6c30876dfa 81