テスト用

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Mon Jul 07 13:43:31 2014 +0100
Revision:
37:c29c330d942c
Parent:
0:eff01767de02
changes required to upgrade to V7 of the soft-device

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:eff01767de02 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
bogdanm 0:eff01767de02 2 *
bogdanm 0:eff01767de02 3 * The information contained herein is property of Nordic Semiconductor ASA.
bogdanm 0:eff01767de02 4 * Terms and conditions of usage are described in detail in NORDIC
bogdanm 0:eff01767de02 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
bogdanm 0:eff01767de02 6 *
bogdanm 0:eff01767de02 7 * Licensees are granted free, non-transferable use of the information. NO
bogdanm 0:eff01767de02 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
bogdanm 0:eff01767de02 9 * the file.
bogdanm 0:eff01767de02 10 */
bogdanm 0:eff01767de02 11
bogdanm 0:eff01767de02 12 /* Attention!
Rohit Grover 37:c29c330d942c 13 * To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile
bogdanm 0:eff01767de02 14 * qualification listings, this section of source code must not be modified.
bogdanm 0:eff01767de02 15 */
bogdanm 0:eff01767de02 16
bogdanm 0:eff01767de02 17 /** @file
bogdanm 0:eff01767de02 18 * @brief Contains definition of ble_date_time structure.
bogdanm 0:eff01767de02 19 */
bogdanm 0:eff01767de02 20
bogdanm 0:eff01767de02 21 /** @file
bogdanm 0:eff01767de02 22 *
bogdanm 0:eff01767de02 23 * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type
bogdanm 0:eff01767de02 24 * @{
bogdanm 0:eff01767de02 25 * @ingroup ble_sdk_srv
bogdanm 0:eff01767de02 26 * @brief Definition of ble_date_time_t type.
bogdanm 0:eff01767de02 27 */
bogdanm 0:eff01767de02 28
bogdanm 0:eff01767de02 29 #ifndef BLE_DATE_TIME_H__
bogdanm 0:eff01767de02 30 #define BLE_DATE_TIME_H__
bogdanm 0:eff01767de02 31
bogdanm 0:eff01767de02 32 #include <stdint.h>
bogdanm 0:eff01767de02 33
bogdanm 0:eff01767de02 34 /**@brief Date and Time structure. */
bogdanm 0:eff01767de02 35 typedef struct
bogdanm 0:eff01767de02 36 {
bogdanm 0:eff01767de02 37 uint16_t year;
bogdanm 0:eff01767de02 38 uint8_t month;
bogdanm 0:eff01767de02 39 uint8_t day;
bogdanm 0:eff01767de02 40 uint8_t hours;
bogdanm 0:eff01767de02 41 uint8_t minutes;
bogdanm 0:eff01767de02 42 uint8_t seconds;
bogdanm 0:eff01767de02 43 } ble_date_time_t;
bogdanm 0:eff01767de02 44
bogdanm 0:eff01767de02 45 static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time,
bogdanm 0:eff01767de02 46 uint8_t * p_encoded_data)
bogdanm 0:eff01767de02 47 {
bogdanm 0:eff01767de02 48 uint8_t len = uint16_encode(p_date_time->year, p_encoded_data);
bogdanm 0:eff01767de02 49
bogdanm 0:eff01767de02 50 p_encoded_data[len++] = p_date_time->month;
bogdanm 0:eff01767de02 51 p_encoded_data[len++] = p_date_time->day;
bogdanm 0:eff01767de02 52 p_encoded_data[len++] = p_date_time->hours;
bogdanm 0:eff01767de02 53 p_encoded_data[len++] = p_date_time->minutes;
bogdanm 0:eff01767de02 54 p_encoded_data[len++] = p_date_time->seconds;
bogdanm 0:eff01767de02 55
bogdanm 0:eff01767de02 56 return len;
bogdanm 0:eff01767de02 57 }
bogdanm 0:eff01767de02 58
bogdanm 0:eff01767de02 59 static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time,
bogdanm 0:eff01767de02 60 const uint8_t * p_encoded_data)
bogdanm 0:eff01767de02 61 {
bogdanm 0:eff01767de02 62 uint8_t len = sizeof(uint16_t);
bogdanm 0:eff01767de02 63
bogdanm 0:eff01767de02 64 p_date_time->year = uint16_decode(p_encoded_data);
bogdanm 0:eff01767de02 65 p_date_time->month = p_encoded_data[len++];
bogdanm 0:eff01767de02 66 p_date_time->day = p_encoded_data[len++];
bogdanm 0:eff01767de02 67 p_date_time->hours = p_encoded_data[len++];
bogdanm 0:eff01767de02 68 p_date_time->minutes = p_encoded_data[len++];
bogdanm 0:eff01767de02 69 p_date_time->seconds = p_encoded_data[len++];
bogdanm 0:eff01767de02 70
bogdanm 0:eff01767de02 71 return len;
bogdanm 0:eff01767de02 72 }
bogdanm 0:eff01767de02 73
bogdanm 0:eff01767de02 74 #endif // BLE_DATE_TIME_H__
bogdanm 0:eff01767de02 75
bogdanm 0:eff01767de02 76 /** @} */