123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- #ifndef NRF_SDH_ANT_H__
- #define NRF_SDH_ANT_H__
- #include "ant_parameters.h"
- #include "app_util.h"
- #include "nrf_section_iter.h"
- #include "sdk_errors.h"
- #include <stdint.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define NRF_SDH_ANT_EVT_CHANNEL_FIELD_SIZE 1
- #define NRF_SDH_ANT_EVT_EVENT_FIELD_SIZE 1
- #define NRF_SDH_ANT_BUF_SIZE ANT_ENABLE_GET_REQUIRED_SPACE( \
- NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED, \
- NRF_SDH_ANT_ENCRYPTED_CHANNELS, \
- NRF_SDH_ANT_BURST_QUEUE_SIZE, \
- NRF_SDH_ANT_EVENT_QUEUE_SIZE)
- #define NRF_SDH_ANT_MESSAGE_SIZE ((CEIL_DIV(MESG_BUFFER_SIZE, sizeof(uint32_t))) * sizeof(uint32_t))
- #define NRF_SDH_ANT_EVT_BUF_SIZE ((CEIL_DIV(NRF_SDH_ANT_MESSAGE_SIZE + \
- NRF_SDH_ANT_EVT_CHANNEL_FIELD_SIZE + \
- NRF_SDH_ANT_EVT_EVENT_FIELD_SIZE, \
- sizeof(uint32_t))) * sizeof(uint32_t))
- #if !(defined(__LINT__))
- #define NRF_SDH_ANT_OBSERVER(_name, _prio, _handler, _context) \
- STATIC_ASSERT(NRF_SDH_ANT_ENABLED, "NRF_SDH_ANT_ENABLED not set!"); \
- STATIC_ASSERT(_prio < NRF_SDH_ANT_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
- NRF_SECTION_SET_ITEM_REGISTER(sdh_ant_observers, _prio, static nrf_sdh_ant_evt_observer_t _name) = \
- { \
- .handler = _handler, \
- .p_context = _context \
- }
- #define NRF_SDH_ANT_OBSERVERS(_name, _prio, _handler, _context, _cnt) \
- STATIC_ASSERT(NRF_SDH_ANT_ENABLED, "NRF_SDH_ANT_ENABLED not set!"); \
- STATIC_ASSERT(_prio < NRF_SDH_ANT_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
- NRF_SECTION_SET_ITEM_REGISTER(sdh_ant_observers, _prio, static nrf_sdh_ant_evt_observer_t _name[_cnt]) = \
- { \
- MACRO_REPEAT_FOR(_cnt, HANDLER_SET, _handler, _context) \
- }
- #if !(defined(DOXYGEN))
- #define HANDLER_SET(_idx, _handler, _context) \
- { \
- .handler = _handler, \
- .p_context = _context[_idx], \
- },
- #endif
- #else
- #define NRF_SDH_ANT_OBSERVER(A, B, C, D) static int semicolon_swallow_##A
- #define NRF_SDH_ANT_OBSERVERS(A, B, C, D, E) static int semicolon_swallow_##A
- #endif
- typedef struct
- {
- ANT_MESSAGE message;
- uint8_t channel;
- uint8_t event;
- } ant_evt_t;
- typedef void (*nrf_sdh_ant_evt_handler_t)(ant_evt_t * p_ant_evt, void * p_context);
- typedef struct
- {
- nrf_sdh_ant_evt_handler_t handler;
- void * p_context;
- } const nrf_sdh_ant_evt_observer_t;
- ret_code_t nrf_sdh_ant_enable(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|