LPC11U35 ADC Tick & USBSerial
Dependents: SmallDoseMeter_SingleCH_AE_lpc11u35_V1_00
mbed/i2c_api.h@0:871ab6846b18, 2018-02-19 (annotated)
- Committer:
- H_Tsunemoto
- Date:
- Mon Feb 19 08:51:33 2018 +0000
- Revision:
- 0:871ab6846b18
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
H_Tsunemoto | 0:871ab6846b18 | 1 | /* mbed Microcontroller Library |
H_Tsunemoto | 0:871ab6846b18 | 2 | * Copyright (c) 2006-2013 ARM Limited |
H_Tsunemoto | 0:871ab6846b18 | 3 | * |
H_Tsunemoto | 0:871ab6846b18 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
H_Tsunemoto | 0:871ab6846b18 | 5 | * you may not use this file except in compliance with the License. |
H_Tsunemoto | 0:871ab6846b18 | 6 | * You may obtain a copy of the License at |
H_Tsunemoto | 0:871ab6846b18 | 7 | * |
H_Tsunemoto | 0:871ab6846b18 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
H_Tsunemoto | 0:871ab6846b18 | 9 | * |
H_Tsunemoto | 0:871ab6846b18 | 10 | * Unless required by applicable law or agreed to in writing, software |
H_Tsunemoto | 0:871ab6846b18 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
H_Tsunemoto | 0:871ab6846b18 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
H_Tsunemoto | 0:871ab6846b18 | 13 | * See the License for the specific language governing permissions and |
H_Tsunemoto | 0:871ab6846b18 | 14 | * limitations under the License. |
H_Tsunemoto | 0:871ab6846b18 | 15 | */ |
H_Tsunemoto | 0:871ab6846b18 | 16 | #ifndef MBED_I2C_API_H |
H_Tsunemoto | 0:871ab6846b18 | 17 | #define MBED_I2C_API_H |
H_Tsunemoto | 0:871ab6846b18 | 18 | |
H_Tsunemoto | 0:871ab6846b18 | 19 | #include "device.h" |
H_Tsunemoto | 0:871ab6846b18 | 20 | |
H_Tsunemoto | 0:871ab6846b18 | 21 | #if DEVICE_I2C |
H_Tsunemoto | 0:871ab6846b18 | 22 | |
H_Tsunemoto | 0:871ab6846b18 | 23 | #ifdef __cplusplus |
H_Tsunemoto | 0:871ab6846b18 | 24 | extern "C" { |
H_Tsunemoto | 0:871ab6846b18 | 25 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 26 | |
H_Tsunemoto | 0:871ab6846b18 | 27 | typedef struct i2c_s i2c_t; |
H_Tsunemoto | 0:871ab6846b18 | 28 | |
H_Tsunemoto | 0:871ab6846b18 | 29 | enum { |
H_Tsunemoto | 0:871ab6846b18 | 30 | I2C_ERROR_NO_SLAVE = -1, |
H_Tsunemoto | 0:871ab6846b18 | 31 | I2C_ERROR_BUS_BUSY = -2 |
H_Tsunemoto | 0:871ab6846b18 | 32 | }; |
H_Tsunemoto | 0:871ab6846b18 | 33 | |
H_Tsunemoto | 0:871ab6846b18 | 34 | void i2c_init (i2c_t *obj, PinName sda, PinName scl); |
H_Tsunemoto | 0:871ab6846b18 | 35 | void i2c_frequency (i2c_t *obj, int hz); |
H_Tsunemoto | 0:871ab6846b18 | 36 | int i2c_start (i2c_t *obj); |
H_Tsunemoto | 0:871ab6846b18 | 37 | int i2c_stop (i2c_t *obj); |
H_Tsunemoto | 0:871ab6846b18 | 38 | int i2c_read (i2c_t *obj, int address, char *data, int length, int stop); |
H_Tsunemoto | 0:871ab6846b18 | 39 | int i2c_write (i2c_t *obj, int address, const char *data, int length, int stop); |
H_Tsunemoto | 0:871ab6846b18 | 40 | void i2c_reset (i2c_t *obj); |
H_Tsunemoto | 0:871ab6846b18 | 41 | int i2c_byte_read (i2c_t *obj, int last); |
H_Tsunemoto | 0:871ab6846b18 | 42 | int i2c_byte_write (i2c_t *obj, int data); |
H_Tsunemoto | 0:871ab6846b18 | 43 | |
H_Tsunemoto | 0:871ab6846b18 | 44 | #if DEVICE_I2CSLAVE |
H_Tsunemoto | 0:871ab6846b18 | 45 | void i2c_slave_mode (i2c_t *obj, int enable_slave); |
H_Tsunemoto | 0:871ab6846b18 | 46 | int i2c_slave_receive(i2c_t *obj); |
H_Tsunemoto | 0:871ab6846b18 | 47 | int i2c_slave_read (i2c_t *obj, char *data, int length); |
H_Tsunemoto | 0:871ab6846b18 | 48 | int i2c_slave_write (i2c_t *obj, const char *data, int length); |
H_Tsunemoto | 0:871ab6846b18 | 49 | void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask); |
H_Tsunemoto | 0:871ab6846b18 | 50 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 51 | |
H_Tsunemoto | 0:871ab6846b18 | 52 | #ifdef __cplusplus |
H_Tsunemoto | 0:871ab6846b18 | 53 | } |
H_Tsunemoto | 0:871ab6846b18 | 54 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 55 | |
H_Tsunemoto | 0:871ab6846b18 | 56 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 57 | |
H_Tsunemoto | 0:871ab6846b18 | 58 | #endif |