Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ant_stack_handler_types.h Source File

ant_stack_handler_types.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  *
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  *
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  *
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  *
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00027  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  */
00032 
00033 /**@file
00034  *
00035  * @defgroup ant_stack_handler_types Types definitions for ANT support in SoftDevice handler.
00036  * @{
00037  * @ingroup  softdevice_handler
00038  * @brief    This file contains the declarations of types required for ANT stack support. These
00039  *           types will be defined when the preprocessor define ANT_STACK_SUPPORT_REQD is defined.
00040  */
00041 
00042 #ifndef ANT_STACK_HANDLER_TYPES_H__
00043 #define ANT_STACK_HANDLER_TYPES_H__
00044 
00045 #ifdef ANT_STACK_SUPPORT_REQD
00046 
00047 #include <stdlib.h>
00048 
00049 #define ANT_STACK_EVT_MSG_BUF_SIZE      32                                                /**< Size of ANT event message buffer. This will be provided to the SoftDevice while fetching an event. */
00050 #define ANT_STACK_EVT_STRUCT_SIZE       (sizeof(ant_evt_t))                               /**< Size of the @ref ant_evt_t structure. This will be used by the @ref softdevice_handler to internal event buffer size needed. */
00051 
00052 /**@brief ANT stack event type. */
00053 typedef struct
00054 {
00055     uint8_t channel;                                                                      /**< Channel number. */
00056     uint8_t event;                                                                        /**< Event code. */
00057     uint8_t evt_buffer[ANT_STACK_EVT_MSG_BUF_SIZE];                                       /**< Event message buffer. */
00058 } ant_evt_t;
00059 
00060 /**@brief Application ANT stack event handler type. */
00061 typedef void (*ant_evt_handler_t) (ant_evt_t * p_ant_evt);
00062 
00063 /**@brief     Function for registering for ANT events.
00064  *
00065  * @details   The application should use this function to register for receiving ANT events from
00066  *            the SoftDevice. If the application does not call this function, then any ANT event
00067  *            that may be generated by the SoftDevice will NOT be fetched. Once the application has
00068  *            registered for the events, it is not possible to  possible to cancel the registration.
00069  *            However, it is possible to register a different function for handling the events at
00070  *            any point of time.
00071  *
00072  * @param[in] ant_evt_handler Function to be called for each received ANT event.
00073  *
00074  * @retval    NRF_SUCCESS     Successful registration.
00075  * @retval    NRF_ERROR_NULL  Null pointer provided as input.
00076  */
00077 uint32_t softdevice_ant_evt_handler_set(ant_evt_handler_t ant_evt_handler);
00078 
00079 #else
00080 
00081 // The ANT Stack support is not required.
00082 
00083 #define ANT_STACK_EVT_STRUCT_SIZE       0                                                 /**< Since the ANT stack support is not required, this is equated to 0, so that the @ref softdevice_handler.h can compute the internal event buffer size without having to care for ANT events.*/
00084 
00085 #endif // ANT_STACK_SUPPORT_REQD
00086 
00087 #endif // ANT_STACK_HANDLER_TYPES_H__
00088 
00089 /** @} */