changed low freq. clock source to IRC

Dependents:   BLE_ANCS_SDAPI_IRC

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_date_time.h Source File

ble_date_time.h

Go to the documentation of this file.
00001 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
00002 *
00003 * The information contained herein is property of Nordic Semiconductor ASA.
00004 * Terms and conditions of usage are described in detail in NORDIC
00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006 *
00007 * Licensees are granted free, non-transferable use of the information. NO
00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009 * the file.
00010 */
00011 
00012 /* Attention! 
00013 *  To maintain compliance with Nordic Semiconductor ASA�s Bluetooth profile 
00014 *  qualification listings, this section of source code must not be modified.
00015 */
00016 
00017 /** @file
00018  * @brief Contains definition of ble_date_time structure.
00019  */
00020 
00021 /** @file
00022  *
00023  * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type
00024  * @{
00025  * @ingroup ble_sdk_srv
00026  * @brief Definition of ble_date_time_t type.
00027  */
00028 
00029 #ifndef BLE_DATE_TIME_H__
00030 #define BLE_DATE_TIME_H__
00031 
00032 #include <stdint.h>
00033 #include "nordic_global.h"
00034 
00035 /**@brief Date and Time structure. */
00036 typedef struct
00037 {
00038     uint16_t year;
00039     uint8_t  month;
00040     uint8_t  day;
00041     uint8_t  hours;
00042     uint8_t  minutes;
00043     uint8_t  seconds;
00044 } ble_date_time_t;
00045 
00046 static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time,
00047                                              uint8_t *               p_encoded_data)
00048 {
00049     uint8_t len = uint16_encode(p_date_time->year, p_encoded_data);
00050     
00051     p_encoded_data[len++] = p_date_time->month;
00052     p_encoded_data[len++] = p_date_time->day;
00053     p_encoded_data[len++] = p_date_time->hours;
00054     p_encoded_data[len++] = p_date_time->minutes;
00055     p_encoded_data[len++] = p_date_time->seconds;
00056     
00057     return len;
00058 }
00059 
00060 static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time,
00061                                              const uint8_t *   p_encoded_data)
00062 {
00063     uint8_t len = sizeof(uint16_t);
00064     
00065     p_date_time->year    = uint16_decode(p_encoded_data);
00066     p_date_time->month   = p_encoded_data[len++];
00067     p_date_time->day     = p_encoded_data[len++]; 
00068     p_date_time->hours   = p_encoded_data[len++];
00069     p_date_time->minutes = p_encoded_data[len++];
00070     p_date_time->seconds = p_encoded_data[len++];
00071     
00072     return len;
00073 }
00074 
00075 #endif // BLE_DATE_TIME_H__
00076 
00077 /** @} */