fix nrf51822 i2c & spi conflict

Dependencies:   BLE_API eMPL_MPU6050 nRF51822

Fork of Seeed_Tiny_BLE_Flash by Darren Huang

Committer:
yihui
Date:
Tue Nov 17 07:48:56 2015 +0000
Revision:
5:b8c02645e6af
fix i2c & spi conflict

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 5:b8c02645e6af 1 /* mbed Microcontroller Library
yihui 5:b8c02645e6af 2 * Copyright (c) 2015 ARM Limited
yihui 5:b8c02645e6af 3 *
yihui 5:b8c02645e6af 4 * Licensed under the Apache License, Version 2.0 (the "License");
yihui 5:b8c02645e6af 5 * you may not use this file except in compliance with the License.
yihui 5:b8c02645e6af 6 * You may obtain a copy of the License at
yihui 5:b8c02645e6af 7 *
yihui 5:b8c02645e6af 8 * http://www.apache.org/licenses/LICENSE-2.0
yihui 5:b8c02645e6af 9 *
yihui 5:b8c02645e6af 10 * Unless required by applicable law or agreed to in writing, software
yihui 5:b8c02645e6af 11 * distributed under the License is distributed on an "AS IS" BASIS,
yihui 5:b8c02645e6af 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
yihui 5:b8c02645e6af 13 * See the License for the specific language governing permissions and
yihui 5:b8c02645e6af 14 * limitations under the License.
yihui 5:b8c02645e6af 15 */
yihui 5:b8c02645e6af 16 #ifndef MBED_TRANSACTION_H
yihui 5:b8c02645e6af 17 #define MBED_TRANSACTION_H
yihui 5:b8c02645e6af 18
yihui 5:b8c02645e6af 19 #include "platform.h"
yihui 5:b8c02645e6af 20 #include "FunctionPointer.h"
yihui 5:b8c02645e6af 21
yihui 5:b8c02645e6af 22 namespace mbed {
yihui 5:b8c02645e6af 23
yihui 5:b8c02645e6af 24 /** Transaction structure
yihui 5:b8c02645e6af 25 */
yihui 5:b8c02645e6af 26 typedef struct {
yihui 5:b8c02645e6af 27 void *tx_buffer; /**< Tx buffer */
yihui 5:b8c02645e6af 28 size_t tx_length; /**< Length of Tx buffer*/
yihui 5:b8c02645e6af 29 void *rx_buffer; /**< Rx buffer */
yihui 5:b8c02645e6af 30 size_t rx_length; /**< Length of Rx buffer */
yihui 5:b8c02645e6af 31 uint32_t event; /**< Event for a transaction */
yihui 5:b8c02645e6af 32 event_callback_t callback; /**< User's callback */
yihui 5:b8c02645e6af 33 uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */
yihui 5:b8c02645e6af 34 } transaction_t;
yihui 5:b8c02645e6af 35
yihui 5:b8c02645e6af 36 /** Transaction class defines a transaction.
yihui 5:b8c02645e6af 37 */
yihui 5:b8c02645e6af 38 template<typename Class>
yihui 5:b8c02645e6af 39 class Transaction {
yihui 5:b8c02645e6af 40 public:
yihui 5:b8c02645e6af 41 Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) {
yihui 5:b8c02645e6af 42 }
yihui 5:b8c02645e6af 43
yihui 5:b8c02645e6af 44 Transaction() : _obj(), _data() {
yihui 5:b8c02645e6af 45 }
yihui 5:b8c02645e6af 46
yihui 5:b8c02645e6af 47 ~Transaction() {
yihui 5:b8c02645e6af 48 }
yihui 5:b8c02645e6af 49
yihui 5:b8c02645e6af 50 /** Get object's instance for the transaction
yihui 5:b8c02645e6af 51 *
yihui 5:b8c02645e6af 52 * @return The object which was stored
yihui 5:b8c02645e6af 53 */
yihui 5:b8c02645e6af 54 Class* get_object() {
yihui 5:b8c02645e6af 55 return _obj;
yihui 5:b8c02645e6af 56 }
yihui 5:b8c02645e6af 57
yihui 5:b8c02645e6af 58 /** Get the transaction
yihui 5:b8c02645e6af 59 *
yihui 5:b8c02645e6af 60 * @return The transaction which was stored
yihui 5:b8c02645e6af 61 */
yihui 5:b8c02645e6af 62 transaction_t* get_transaction() {
yihui 5:b8c02645e6af 63 return &_data;
yihui 5:b8c02645e6af 64 }
yihui 5:b8c02645e6af 65
yihui 5:b8c02645e6af 66 private:
yihui 5:b8c02645e6af 67 Class* _obj;
yihui 5:b8c02645e6af 68 transaction_t _data;
yihui 5:b8c02645e6af 69 };
yihui 5:b8c02645e6af 70
yihui 5:b8c02645e6af 71 }
yihui 5:b8c02645e6af 72
yihui 5:b8c02645e6af 73 #endif