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