Zeroday Hong / mbed-dev

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
<> 144:ef7eb2e8f9f7 1 /*
<> 144:ef7eb2e8f9f7 2 * Copyright (c) 2015 Nordic Semiconductor ASA
<> 144:ef7eb2e8f9f7 3 * All rights reserved.
<> 144:ef7eb2e8f9f7 4 *
<> 144:ef7eb2e8f9f7 5 * Redistribution and use in source and binary forms, with or without modification,
<> 144:ef7eb2e8f9f7 6 * are permitted provided that the following conditions are met:
<> 144:ef7eb2e8f9f7 7 *
<> 144:ef7eb2e8f9f7 8 * 1. Redistributions of source code must retain the above copyright notice, this list
<> 144:ef7eb2e8f9f7 9 * of conditions and the following disclaimer.
<> 144:ef7eb2e8f9f7 10 *
<> 144:ef7eb2e8f9f7 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
<> 144:ef7eb2e8f9f7 12 * integrated circuit in a product or a software update for such product, must reproduce
<> 144:ef7eb2e8f9f7 13 * the above copyright notice, this list of conditions and the following disclaimer in
<> 144:ef7eb2e8f9f7 14 * the documentation and/or other materials provided with the distribution.
<> 144:ef7eb2e8f9f7 15 *
<> 144:ef7eb2e8f9f7 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
<> 144:ef7eb2e8f9f7 17 * used to endorse or promote products derived from this software without specific prior
<> 144:ef7eb2e8f9f7 18 * written permission.
<> 144:ef7eb2e8f9f7 19 *
<> 144:ef7eb2e8f9f7 20 * 4. This software, with or without modification, must only be used with a
<> 144:ef7eb2e8f9f7 21 * Nordic Semiconductor ASA integrated circuit.
<> 144:ef7eb2e8f9f7 22 *
<> 144:ef7eb2e8f9f7 23 * 5. Any software provided in binary or object form under this license must not be reverse
<> 144:ef7eb2e8f9f7 24 * engineered, decompiled, modified and/or disassembled.
<> 144:ef7eb2e8f9f7 25 *
<> 144:ef7eb2e8f9f7 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<> 144:ef7eb2e8f9f7 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
<> 144:ef7eb2e8f9f7 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 144:ef7eb2e8f9f7 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
<> 144:ef7eb2e8f9f7 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
<> 144:ef7eb2e8f9f7 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
<> 144:ef7eb2e8f9f7 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
<> 144:ef7eb2e8f9f7 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<> 144:ef7eb2e8f9f7 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
<> 144:ef7eb2e8f9f7 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 144:ef7eb2e8f9f7 36 *
<> 144:ef7eb2e8f9f7 37 */
<> 144:ef7eb2e8f9f7 38
<> 144:ef7eb2e8f9f7 39
<> 144:ef7eb2e8f9f7 40
<> 144:ef7eb2e8f9f7 41 #ifndef GATTC_CACHE_MANAGER_H__
<> 144:ef7eb2e8f9f7 42 #define GATTC_CACHE_MANAGER_H__
<> 144:ef7eb2e8f9f7 43
<> 144:ef7eb2e8f9f7 44 #include <stdint.h>
<> 144:ef7eb2e8f9f7 45 #include "sdk_errors.h"
<> 144:ef7eb2e8f9f7 46 #include "nrf_ble.h"
<> 144:ef7eb2e8f9f7 47 #include "nrf_ble_gap.h"
<> 144:ef7eb2e8f9f7 48 #include "peer_manager_types.h"
<> 144:ef7eb2e8f9f7 49
<> 144:ef7eb2e8f9f7 50
<> 144:ef7eb2e8f9f7 51 /**
<> 144:ef7eb2e8f9f7 52 * @cond NO_DOXYGEN
<> 144:ef7eb2e8f9f7 53 * @defgroup gattc_cache_manager GATT Client Cache Manager
<> 144:ef7eb2e8f9f7 54 * @ingroup peer_manager
<> 144:ef7eb2e8f9f7 55 * @{
<> 144:ef7eb2e8f9f7 56 * @brief An internal module of @ref peer_manager. A module for managing persistent storing of GATT
<> 144:ef7eb2e8f9f7 57 * attributes pertaining to the GATT client role of the local device.
<> 144:ef7eb2e8f9f7 58 */
<> 144:ef7eb2e8f9f7 59
<> 144:ef7eb2e8f9f7 60
<> 144:ef7eb2e8f9f7 61 /**@brief Events that can come from the GATT Cache Manager module.
<> 144:ef7eb2e8f9f7 62 */
<> 144:ef7eb2e8f9f7 63 typedef enum
<> 144:ef7eb2e8f9f7 64 {
<> 144:ef7eb2e8f9f7 65 GCCM_EVT_REMOTE_DB_UPDATED, /**< Values for the specified data has been updated in persistent storage. */
<> 144:ef7eb2e8f9f7 66 GCCM_EVT_REMOTE_DB_STORED, /**< New values for the specified data has been written in persistent storage. */
<> 144:ef7eb2e8f9f7 67 } gccm_evt_id_t;
<> 144:ef7eb2e8f9f7 68
<> 144:ef7eb2e8f9f7 69
<> 144:ef7eb2e8f9f7 70 typedef struct
<> 144:ef7eb2e8f9f7 71 {
<> 144:ef7eb2e8f9f7 72 gccm_evt_id_t evt_id;
<> 144:ef7eb2e8f9f7 73 pm_peer_id_t peer_id;
<> 144:ef7eb2e8f9f7 74 } gccm_evt_t;
<> 144:ef7eb2e8f9f7 75
<> 144:ef7eb2e8f9f7 76 /**@brief Event handler for events from the GATT Client Cache Manager module.
<> 144:ef7eb2e8f9f7 77 *
<> 144:ef7eb2e8f9f7 78 * @param[in] event The event that has happened.
<> 144:ef7eb2e8f9f7 79 * @param[in] peer The id of the peer the event pertains to.
<> 144:ef7eb2e8f9f7 80 * @param[in] flags The data the event pertains to.
<> 144:ef7eb2e8f9f7 81 */
<> 144:ef7eb2e8f9f7 82 typedef void (*gccm_evt_handler_t)(gccm_evt_t const * p_event);
<> 144:ef7eb2e8f9f7 83
<> 144:ef7eb2e8f9f7 84
<> 144:ef7eb2e8f9f7 85 /**@brief Function for initializing the GATT Client Cache Manager module.
<> 144:ef7eb2e8f9f7 86 *
<> 144:ef7eb2e8f9f7 87 * @param[in] evt_handler Callback for events from the GATT Client Cache Manager module.
<> 144:ef7eb2e8f9f7 88 *
<> 144:ef7eb2e8f9f7 89 * @retval NRF_SUCCESS Initialization was successful.
<> 144:ef7eb2e8f9f7 90 * @retval NRF_ERROR_NULL evt_handler was NULL.
<> 144:ef7eb2e8f9f7 91 */
<> 144:ef7eb2e8f9f7 92 ret_code_t gccm_init(gccm_evt_handler_t evt_handler);
<> 144:ef7eb2e8f9f7 93
<> 144:ef7eb2e8f9f7 94
<> 144:ef7eb2e8f9f7 95 /**@brief Function for storing a discovered remote database persistently.
<> 144:ef7eb2e8f9f7 96 *
<> 144:ef7eb2e8f9f7 97 * @param[in] peer_id Peer to store the database for.
<> 144:ef7eb2e8f9f7 98 * @param[in] p_remote_db Database values to store as an array. Can be NULL if n_services is 0.
<> 144:ef7eb2e8f9f7 99 * @param[in] n_services Number of services in p_remote_db array. If 0, values are cleared.
<> 144:ef7eb2e8f9f7 100 *
<> 144:ef7eb2e8f9f7 101 * @retval NRF_SUCCESS Store procedure successfully started.
<> 144:ef7eb2e8f9f7 102 * @retval NRF_ERROR_NOT_FOUND The peer id is invalid or unallocated.
<> 144:ef7eb2e8f9f7 103 * @retval NRF_ERROR_INVALID_STATE Module is not initialized.
<> 144:ef7eb2e8f9f7 104 */
<> 144:ef7eb2e8f9f7 105 ret_code_t gccm_remote_db_store(pm_peer_id_t peer_id,
<> 144:ef7eb2e8f9f7 106 ble_gatt_db_srv_t * p_remote_db,
<> 144:ef7eb2e8f9f7 107 uint32_t n_services);
<> 144:ef7eb2e8f9f7 108
<> 144:ef7eb2e8f9f7 109
<> 144:ef7eb2e8f9f7 110 /**@brief Function for retrieving a persistently stored remote database.
<> 144:ef7eb2e8f9f7 111 *
<> 144:ef7eb2e8f9f7 112 * @param[in] peer_id Peer to retrieve data for.
<> 144:ef7eb2e8f9f7 113 * @param[out] p_remote_db If p_n_services was large enough: Copied database values.
<> 144:ef7eb2e8f9f7 114 * @param[inout] p_n_services In: Size of provided p_remote_db array. Out: Size of data in flash.
<> 144:ef7eb2e8f9f7 115 *
<> 144:ef7eb2e8f9f7 116 * @note p_n_services is always updated with the size of the data to be retrieved. The data is only
<> 144:ef7eb2e8f9f7 117 * copied if p_remote_db is large enough (p_n_services is large enough initially).
<> 144:ef7eb2e8f9f7 118 *
<> 144:ef7eb2e8f9f7 119 * @retval NRF_SUCCESS Data retrieved successfully.
<> 144:ef7eb2e8f9f7 120 * @retval NRF_ERROR_NOT_FOUND The peer ID is invalid or unallocated.
<> 144:ef7eb2e8f9f7 121 * @retval NRF_ERROR_INVALID_STATE Module is not initialized.
<> 144:ef7eb2e8f9f7 122 */
<> 144:ef7eb2e8f9f7 123 ret_code_t gccm_remote_db_retrieve(pm_peer_id_t peer_id,
<> 144:ef7eb2e8f9f7 124 ble_gatt_db_srv_t * p_remote_db,
<> 144:ef7eb2e8f9f7 125 uint32_t * p_n_services);
<> 144:ef7eb2e8f9f7 126
<> 144:ef7eb2e8f9f7 127
<> 144:ef7eb2e8f9f7 128 /** @}
<> 144:ef7eb2e8f9f7 129 * @endcond
<> 144:ef7eb2e8f9f7 130 */
<> 144:ef7eb2e8f9f7 131
<> 144:ef7eb2e8f9f7 132 #endif /* GATTC_CACHE_MANAGER_H__ */