mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Committer:
funshine
Date:
Sat Apr 08 17:03:55 2017 +0000
Revision:
162:16168a1438f3
Parent:
149:156823d33999
add code to handle serial port rx error in uart_irq()

Who changed what in which revision?

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