Nordic stack and drivers for the mbed BLE API

Fork of nRF51822 by Nordic Semiconductor

Committer:
marcpl
Date:
Sat May 09 17:04:09 2015 +0000
Revision:
162:5fd73fb47b21
Parent:
103:138bdc859cc9
Add a quick and dirty workaround in the nRF51822 library in order to avoid duplicate definition of GPIOTE_IRQHandler.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 103:138bdc859cc9 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
rgrover1 103:138bdc859cc9 2 *
rgrover1 103:138bdc859cc9 3 * The information contained herein is property of Nordic Semiconductor ASA.
rgrover1 103:138bdc859cc9 4 * Terms and conditions of usage are described in detail in NORDIC
rgrover1 103:138bdc859cc9 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
rgrover1 103:138bdc859cc9 6 *
rgrover1 103:138bdc859cc9 7 * Licensees are granted free, non-transferable use of the information. NO
rgrover1 103:138bdc859cc9 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
rgrover1 103:138bdc859cc9 9 * the file.
rgrover1 103:138bdc859cc9 10 *
rgrover1 103:138bdc859cc9 11 */
rgrover1 103:138bdc859cc9 12
rgrover1 103:138bdc859cc9 13 #include "app_gpiote.h"
rgrover1 103:138bdc859cc9 14 #include <stdlib.h>
rgrover1 103:138bdc859cc9 15 #include <string.h>
rgrover1 103:138bdc859cc9 16 #include "app_util.h"
rgrover1 103:138bdc859cc9 17 #include "app_util_platform.h"
rgrover1 103:138bdc859cc9 18 #include "nrf_error.h"
rgrover1 103:138bdc859cc9 19 #include "nrf_gpio.h"
rgrover1 103:138bdc859cc9 20
rgrover1 103:138bdc859cc9 21
rgrover1 103:138bdc859cc9 22 /**@brief GPIOTE user type. */
rgrover1 103:138bdc859cc9 23 typedef struct
rgrover1 103:138bdc859cc9 24 {
rgrover1 103:138bdc859cc9 25 uint32_t pins_mask; /**< Mask defining which pins user wants to monitor. */
rgrover1 103:138bdc859cc9 26 uint32_t pins_low_to_high_mask; /**< Mask defining which pins will generate events to this user when toggling low->high. */
rgrover1 103:138bdc859cc9 27 uint32_t pins_high_to_low_mask; /**< Mask defining which pins will generate events to this user when toggling high->low. */
rgrover1 103:138bdc859cc9 28 uint32_t sense_high_pins; /**< Mask defining which pins are configured to generate GPIOTE interrupt on transition to high level. */
rgrover1 103:138bdc859cc9 29 app_gpiote_event_handler_t event_handler; /**< Pointer to function to be executed when an event occurs. */
rgrover1 103:138bdc859cc9 30 } gpiote_user_t;
rgrover1 103:138bdc859cc9 31
rgrover1 103:138bdc859cc9 32 STATIC_ASSERT(sizeof(gpiote_user_t) <= GPIOTE_USER_NODE_SIZE);
rgrover1 103:138bdc859cc9 33 STATIC_ASSERT(sizeof(gpiote_user_t) % 4 == 0);
rgrover1 103:138bdc859cc9 34
rgrover1 103:138bdc859cc9 35 static uint32_t m_enabled_users_mask; /**< Mask for tracking which users are enabled. */
rgrover1 103:138bdc859cc9 36 static uint8_t m_user_array_size; /**< Size of user array. */
rgrover1 103:138bdc859cc9 37 static uint8_t m_user_count; /**< Number of registered users. */
rgrover1 103:138bdc859cc9 38 static gpiote_user_t * mp_users = NULL; /**< Array of GPIOTE users. */
rgrover1 103:138bdc859cc9 39
rgrover1 103:138bdc859cc9 40
rgrover1 103:138bdc859cc9 41 /**@brief Function for toggling sense level for specified pins.
rgrover1 103:138bdc859cc9 42 *
rgrover1 103:138bdc859cc9 43 * @param[in] p_user Pointer to user structure.
rgrover1 103:138bdc859cc9 44 * @param[in] pins Bitmask specifying for which pins the sense level is to be toggled.
rgrover1 103:138bdc859cc9 45 */
rgrover1 103:138bdc859cc9 46 static void sense_level_toggle(gpiote_user_t * p_user, uint32_t pins)
rgrover1 103:138bdc859cc9 47 {
rgrover1 103:138bdc859cc9 48 uint32_t pin_no;
rgrover1 103:138bdc859cc9 49
rgrover1 103:138bdc859cc9 50 for (pin_no = 0; pin_no < NO_OF_PINS; pin_no++)
rgrover1 103:138bdc859cc9 51 {
rgrover1 103:138bdc859cc9 52 uint32_t pin_mask = (1 << pin_no);
rgrover1 103:138bdc859cc9 53
rgrover1 103:138bdc859cc9 54 if ((pins & pin_mask) != 0)
rgrover1 103:138bdc859cc9 55 {
rgrover1 103:138bdc859cc9 56 uint32_t sense;
rgrover1 103:138bdc859cc9 57
rgrover1 103:138bdc859cc9 58 // Invert sensing.
rgrover1 103:138bdc859cc9 59 if ((p_user->sense_high_pins & pin_mask) == 0)
rgrover1 103:138bdc859cc9 60 {
rgrover1 103:138bdc859cc9 61 sense = GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos;
rgrover1 103:138bdc859cc9 62 p_user->sense_high_pins |= pin_mask;
rgrover1 103:138bdc859cc9 63 }
rgrover1 103:138bdc859cc9 64 else
rgrover1 103:138bdc859cc9 65 {
rgrover1 103:138bdc859cc9 66 sense = GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos;
rgrover1 103:138bdc859cc9 67 p_user->sense_high_pins &= ~pin_mask;
rgrover1 103:138bdc859cc9 68 }
rgrover1 103:138bdc859cc9 69
rgrover1 103:138bdc859cc9 70 NRF_GPIO->PIN_CNF[pin_no] &= ~GPIO_PIN_CNF_SENSE_Msk;
rgrover1 103:138bdc859cc9 71 NRF_GPIO->PIN_CNF[pin_no] |= sense;
rgrover1 103:138bdc859cc9 72 }
rgrover1 103:138bdc859cc9 73 }
rgrover1 103:138bdc859cc9 74 }
rgrover1 103:138bdc859cc9 75
rgrover1 103:138bdc859cc9 76
rgrover1 103:138bdc859cc9 77 /**@brief Function for handling the GPIOTE interrupt.
rgrover1 103:138bdc859cc9 78 */
marcpl 162:5fd73fb47b21 79 /* DIRTY WORKAROUND --> https://github.com/mbedmicro/mbed/issues/1045
rgrover1 103:138bdc859cc9 80 void GPIOTE_IRQHandler(void)
rgrover1 103:138bdc859cc9 81 {
rgrover1 103:138bdc859cc9 82 uint8_t i;
rgrover1 103:138bdc859cc9 83 uint32_t pins_changed;
rgrover1 103:138bdc859cc9 84 uint32_t pins_state = NRF_GPIO->IN;
rgrover1 103:138bdc859cc9 85
rgrover1 103:138bdc859cc9 86 // Clear event.
rgrover1 103:138bdc859cc9 87 NRF_GPIOTE->EVENTS_PORT = 0;
rgrover1 103:138bdc859cc9 88
rgrover1 103:138bdc859cc9 89 // Check all users.
rgrover1 103:138bdc859cc9 90 for (i = 0; i < m_user_count; i++)
rgrover1 103:138bdc859cc9 91 {
rgrover1 103:138bdc859cc9 92 gpiote_user_t * p_user = &mp_users[i];
rgrover1 103:138bdc859cc9 93
rgrover1 103:138bdc859cc9 94 // Check if user is enabled.
rgrover1 103:138bdc859cc9 95 if (((1 << i) & m_enabled_users_mask) != 0)
rgrover1 103:138bdc859cc9 96 {
rgrover1 103:138bdc859cc9 97 uint32_t transition_pins;
rgrover1 103:138bdc859cc9 98 uint32_t event_low_to_high;
rgrover1 103:138bdc859cc9 99 uint32_t event_high_to_low;
rgrover1 103:138bdc859cc9 100
rgrover1 103:138bdc859cc9 101 // Find set of pins on which there has been a transition.
rgrover1 103:138bdc859cc9 102 transition_pins = (pins_state ^ ~p_user->sense_high_pins) & p_user->pins_mask;
rgrover1 103:138bdc859cc9 103
rgrover1 103:138bdc859cc9 104 // Toggle SENSE level for all pins that have changed state.
rgrover1 103:138bdc859cc9 105 sense_level_toggle(p_user, transition_pins);
rgrover1 103:138bdc859cc9 106
rgrover1 103:138bdc859cc9 107 // Second read after setting sense.
rgrover1 103:138bdc859cc9 108 // Check if any pins have changed while serving this interrupt.
rgrover1 103:138bdc859cc9 109 pins_changed = NRF_GPIO->IN ^ pins_state;
rgrover1 103:138bdc859cc9 110 if (pins_changed)
rgrover1 103:138bdc859cc9 111 {
rgrover1 103:138bdc859cc9 112 // Transition pins detected in late stage.
rgrover1 103:138bdc859cc9 113 uint32_t late_transition_pins;
rgrover1 103:138bdc859cc9 114
rgrover1 103:138bdc859cc9 115 pins_state |= pins_changed;
rgrover1 103:138bdc859cc9 116
rgrover1 103:138bdc859cc9 117 // Find set of pins on which there has been a transition.
rgrover1 103:138bdc859cc9 118 late_transition_pins = (pins_state ^ ~p_user->sense_high_pins) & p_user->pins_mask;
rgrover1 103:138bdc859cc9 119
rgrover1 103:138bdc859cc9 120 // Toggle SENSE level for all pins that have changed state in last phase.
rgrover1 103:138bdc859cc9 121 sense_level_toggle(p_user, late_transition_pins);
rgrover1 103:138bdc859cc9 122
rgrover1 103:138bdc859cc9 123 // Update pins that has changed state since the interrupt occurred.
rgrover1 103:138bdc859cc9 124 transition_pins |= late_transition_pins;
rgrover1 103:138bdc859cc9 125 }
rgrover1 103:138bdc859cc9 126
rgrover1 103:138bdc859cc9 127 // Call user event handler if an event has occurred.
rgrover1 103:138bdc859cc9 128 event_high_to_low = (~pins_state & p_user->pins_high_to_low_mask) & transition_pins;
rgrover1 103:138bdc859cc9 129 event_low_to_high = (pins_state & p_user->pins_low_to_high_mask) & transition_pins;
rgrover1 103:138bdc859cc9 130
rgrover1 103:138bdc859cc9 131 if ((event_low_to_high | event_high_to_low) != 0)
rgrover1 103:138bdc859cc9 132 {
rgrover1 103:138bdc859cc9 133 p_user->event_handler(event_low_to_high, event_high_to_low);
rgrover1 103:138bdc859cc9 134 }
rgrover1 103:138bdc859cc9 135 }
rgrover1 103:138bdc859cc9 136 }
rgrover1 103:138bdc859cc9 137 }
marcpl 162:5fd73fb47b21 138 */
rgrover1 103:138bdc859cc9 139
rgrover1 103:138bdc859cc9 140 /**@brief Function for sense disabling for all pins for specified user.
rgrover1 103:138bdc859cc9 141 *
rgrover1 103:138bdc859cc9 142 * @param[in] user_id User id.
rgrover1 103:138bdc859cc9 143 */
rgrover1 103:138bdc859cc9 144 static void pins_sense_disable(app_gpiote_user_id_t user_id)
rgrover1 103:138bdc859cc9 145 {
rgrover1 103:138bdc859cc9 146 uint32_t pin_no;
rgrover1 103:138bdc859cc9 147
rgrover1 103:138bdc859cc9 148 for (pin_no = 0; pin_no < 32; pin_no++)
rgrover1 103:138bdc859cc9 149 {
rgrover1 103:138bdc859cc9 150 if ((mp_users[user_id].pins_mask & (1 << pin_no)) != 0)
rgrover1 103:138bdc859cc9 151 {
rgrover1 103:138bdc859cc9 152 NRF_GPIO->PIN_CNF[pin_no] &= ~GPIO_PIN_CNF_SENSE_Msk;
rgrover1 103:138bdc859cc9 153 NRF_GPIO->PIN_CNF[pin_no] |= GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos;
rgrover1 103:138bdc859cc9 154 }
rgrover1 103:138bdc859cc9 155 }
rgrover1 103:138bdc859cc9 156 }
rgrover1 103:138bdc859cc9 157
rgrover1 103:138bdc859cc9 158
rgrover1 103:138bdc859cc9 159 uint32_t app_gpiote_init(uint8_t max_users, void * p_buffer)
rgrover1 103:138bdc859cc9 160 {
rgrover1 103:138bdc859cc9 161 if (p_buffer == NULL)
rgrover1 103:138bdc859cc9 162 {
rgrover1 103:138bdc859cc9 163 return NRF_ERROR_INVALID_PARAM;
rgrover1 103:138bdc859cc9 164 }
rgrover1 103:138bdc859cc9 165
rgrover1 103:138bdc859cc9 166 // Check that buffer is correctly aligned.
rgrover1 103:138bdc859cc9 167 if (!is_word_aligned(p_buffer))
rgrover1 103:138bdc859cc9 168 {
rgrover1 103:138bdc859cc9 169 return NRF_ERROR_INVALID_PARAM;
rgrover1 103:138bdc859cc9 170 }
rgrover1 103:138bdc859cc9 171
rgrover1 103:138bdc859cc9 172 // Initialize file globals.
rgrover1 103:138bdc859cc9 173 mp_users = (gpiote_user_t *)p_buffer;
rgrover1 103:138bdc859cc9 174 m_user_array_size = max_users;
rgrover1 103:138bdc859cc9 175 m_user_count = 0;
rgrover1 103:138bdc859cc9 176 m_enabled_users_mask = 0;
rgrover1 103:138bdc859cc9 177
rgrover1 103:138bdc859cc9 178 memset(mp_users, 0, m_user_array_size * sizeof(gpiote_user_t));
rgrover1 103:138bdc859cc9 179
rgrover1 103:138bdc859cc9 180 // Initialize GPIOTE interrupt (will not be enabled until app_gpiote_user_enable() is called).
rgrover1 103:138bdc859cc9 181 NRF_GPIOTE->INTENCLR = 0xFFFFFFFF;
rgrover1 103:138bdc859cc9 182
rgrover1 103:138bdc859cc9 183 NVIC_ClearPendingIRQ(GPIOTE_IRQn);
rgrover1 103:138bdc859cc9 184 NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_HIGH);
rgrover1 103:138bdc859cc9 185 NVIC_EnableIRQ(GPIOTE_IRQn);
rgrover1 103:138bdc859cc9 186
rgrover1 103:138bdc859cc9 187 return NRF_SUCCESS;
rgrover1 103:138bdc859cc9 188 }
rgrover1 103:138bdc859cc9 189
rgrover1 103:138bdc859cc9 190
rgrover1 103:138bdc859cc9 191 uint32_t app_gpiote_user_register(app_gpiote_user_id_t * p_user_id,
rgrover1 103:138bdc859cc9 192 uint32_t pins_low_to_high_mask,
rgrover1 103:138bdc859cc9 193 uint32_t pins_high_to_low_mask,
rgrover1 103:138bdc859cc9 194 app_gpiote_event_handler_t event_handler)
rgrover1 103:138bdc859cc9 195 {
rgrover1 103:138bdc859cc9 196 // Check state and parameters.
rgrover1 103:138bdc859cc9 197 if (mp_users == NULL)
rgrover1 103:138bdc859cc9 198 {
rgrover1 103:138bdc859cc9 199 return NRF_ERROR_INVALID_STATE;
rgrover1 103:138bdc859cc9 200 }
rgrover1 103:138bdc859cc9 201 if (event_handler == NULL)
rgrover1 103:138bdc859cc9 202 {
rgrover1 103:138bdc859cc9 203 return NRF_ERROR_INVALID_PARAM;
rgrover1 103:138bdc859cc9 204 }
rgrover1 103:138bdc859cc9 205 if (m_user_count >= m_user_array_size)
rgrover1 103:138bdc859cc9 206 {
rgrover1 103:138bdc859cc9 207 return NRF_ERROR_NO_MEM;
rgrover1 103:138bdc859cc9 208 }
rgrover1 103:138bdc859cc9 209
rgrover1 103:138bdc859cc9 210 // Allocate new user.
rgrover1 103:138bdc859cc9 211 mp_users[m_user_count].pins_mask = pins_low_to_high_mask | pins_high_to_low_mask;
rgrover1 103:138bdc859cc9 212 mp_users[m_user_count].pins_low_to_high_mask = pins_low_to_high_mask;
rgrover1 103:138bdc859cc9 213 mp_users[m_user_count].pins_high_to_low_mask = pins_high_to_low_mask;
rgrover1 103:138bdc859cc9 214 mp_users[m_user_count].event_handler = event_handler;
rgrover1 103:138bdc859cc9 215
rgrover1 103:138bdc859cc9 216 *p_user_id = m_user_count++;
rgrover1 103:138bdc859cc9 217
rgrover1 103:138bdc859cc9 218 // Make sure SENSE is disabled for all pins.
rgrover1 103:138bdc859cc9 219 pins_sense_disable(*p_user_id);
rgrover1 103:138bdc859cc9 220
rgrover1 103:138bdc859cc9 221 return NRF_SUCCESS;
rgrover1 103:138bdc859cc9 222 }
rgrover1 103:138bdc859cc9 223
rgrover1 103:138bdc859cc9 224
rgrover1 103:138bdc859cc9 225 uint32_t app_gpiote_user_enable(app_gpiote_user_id_t user_id)
rgrover1 103:138bdc859cc9 226 {
rgrover1 103:138bdc859cc9 227 uint32_t pin_no;
rgrover1 103:138bdc859cc9 228 uint32_t pins_state;
rgrover1 103:138bdc859cc9 229
rgrover1 103:138bdc859cc9 230 // Check state and parameters.
rgrover1 103:138bdc859cc9 231 if (mp_users == NULL)
rgrover1 103:138bdc859cc9 232 {
rgrover1 103:138bdc859cc9 233 return NRF_ERROR_INVALID_STATE;
rgrover1 103:138bdc859cc9 234 }
rgrover1 103:138bdc859cc9 235 if (user_id >= m_user_count)
rgrover1 103:138bdc859cc9 236 {
rgrover1 103:138bdc859cc9 237 return NRF_ERROR_INVALID_PARAM;
rgrover1 103:138bdc859cc9 238 }
rgrover1 103:138bdc859cc9 239
rgrover1 103:138bdc859cc9 240 // Clear any pending event.
rgrover1 103:138bdc859cc9 241 NRF_GPIOTE->EVENTS_PORT = 0;
rgrover1 103:138bdc859cc9 242 pins_state = NRF_GPIO->IN;
rgrover1 103:138bdc859cc9 243
rgrover1 103:138bdc859cc9 244 // Enable user.
rgrover1 103:138bdc859cc9 245 if (m_enabled_users_mask == 0)
rgrover1 103:138bdc859cc9 246 {
rgrover1 103:138bdc859cc9 247 NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
rgrover1 103:138bdc859cc9 248 }
rgrover1 103:138bdc859cc9 249 m_enabled_users_mask |= (1 << user_id);
rgrover1 103:138bdc859cc9 250
rgrover1 103:138bdc859cc9 251 // Enable sensing for all pins for specified user.
rgrover1 103:138bdc859cc9 252 mp_users[user_id].sense_high_pins = 0;
rgrover1 103:138bdc859cc9 253 for (pin_no = 0; pin_no < 32; pin_no++)
rgrover1 103:138bdc859cc9 254 {
rgrover1 103:138bdc859cc9 255 uint32_t pin_mask = (1 << pin_no);
rgrover1 103:138bdc859cc9 256
rgrover1 103:138bdc859cc9 257 if ((mp_users[user_id].pins_mask & pin_mask) != 0)
rgrover1 103:138bdc859cc9 258 {
rgrover1 103:138bdc859cc9 259 uint32_t sense;
rgrover1 103:138bdc859cc9 260
rgrover1 103:138bdc859cc9 261 if ((pins_state & pin_mask) != 0)
rgrover1 103:138bdc859cc9 262 {
rgrover1 103:138bdc859cc9 263 sense = GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos;
rgrover1 103:138bdc859cc9 264 }
rgrover1 103:138bdc859cc9 265 else
rgrover1 103:138bdc859cc9 266 {
rgrover1 103:138bdc859cc9 267 sense = GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos;
rgrover1 103:138bdc859cc9 268 mp_users[user_id].sense_high_pins |= pin_mask;
rgrover1 103:138bdc859cc9 269 }
rgrover1 103:138bdc859cc9 270
rgrover1 103:138bdc859cc9 271 NRF_GPIO->PIN_CNF[pin_no] &= ~GPIO_PIN_CNF_SENSE_Msk;
rgrover1 103:138bdc859cc9 272 NRF_GPIO->PIN_CNF[pin_no] |= sense;
rgrover1 103:138bdc859cc9 273 }
rgrover1 103:138bdc859cc9 274 }
rgrover1 103:138bdc859cc9 275
rgrover1 103:138bdc859cc9 276 return NRF_SUCCESS;
rgrover1 103:138bdc859cc9 277 }
rgrover1 103:138bdc859cc9 278
rgrover1 103:138bdc859cc9 279
rgrover1 103:138bdc859cc9 280 uint32_t app_gpiote_user_disable(app_gpiote_user_id_t user_id)
rgrover1 103:138bdc859cc9 281 {
rgrover1 103:138bdc859cc9 282 // Check state and parameters.
rgrover1 103:138bdc859cc9 283 if (mp_users == NULL)
rgrover1 103:138bdc859cc9 284 {
rgrover1 103:138bdc859cc9 285 return NRF_ERROR_INVALID_STATE;
rgrover1 103:138bdc859cc9 286 }
rgrover1 103:138bdc859cc9 287 if (user_id >= m_user_count)
rgrover1 103:138bdc859cc9 288 {
rgrover1 103:138bdc859cc9 289 return NRF_ERROR_INVALID_PARAM;
rgrover1 103:138bdc859cc9 290 }
rgrover1 103:138bdc859cc9 291
rgrover1 103:138bdc859cc9 292 // Disable sensing for all pins for specified user.
rgrover1 103:138bdc859cc9 293 pins_sense_disable(user_id);
rgrover1 103:138bdc859cc9 294
rgrover1 103:138bdc859cc9 295 // Disable user.
rgrover1 103:138bdc859cc9 296 m_enabled_users_mask &= ~(1UL << user_id);
rgrover1 103:138bdc859cc9 297 if (m_enabled_users_mask == 0)
rgrover1 103:138bdc859cc9 298 {
rgrover1 103:138bdc859cc9 299 NRF_GPIOTE->INTENCLR = GPIOTE_INTENSET_PORT_Msk;
rgrover1 103:138bdc859cc9 300 }
rgrover1 103:138bdc859cc9 301
rgrover1 103:138bdc859cc9 302 return NRF_SUCCESS;
rgrover1 103:138bdc859cc9 303 }
rgrover1 103:138bdc859cc9 304
rgrover1 103:138bdc859cc9 305
rgrover1 103:138bdc859cc9 306 uint32_t app_gpiote_pins_state_get(app_gpiote_user_id_t user_id, uint32_t * p_pins)
rgrover1 103:138bdc859cc9 307 {
rgrover1 103:138bdc859cc9 308 gpiote_user_t * p_user;
rgrover1 103:138bdc859cc9 309
rgrover1 103:138bdc859cc9 310 // Check state and parameters.
rgrover1 103:138bdc859cc9 311 if (mp_users == NULL)
rgrover1 103:138bdc859cc9 312 {
rgrover1 103:138bdc859cc9 313 return NRF_ERROR_INVALID_STATE;
rgrover1 103:138bdc859cc9 314 }
rgrover1 103:138bdc859cc9 315 if (user_id >= m_user_count)
rgrover1 103:138bdc859cc9 316 {
rgrover1 103:138bdc859cc9 317 return NRF_ERROR_INVALID_PARAM;
rgrover1 103:138bdc859cc9 318 }
rgrover1 103:138bdc859cc9 319
rgrover1 103:138bdc859cc9 320 // Get pins.
rgrover1 103:138bdc859cc9 321 p_user = &mp_users[user_id];
rgrover1 103:138bdc859cc9 322 *p_pins = NRF_GPIO->IN & p_user->pins_mask;
rgrover1 103:138bdc859cc9 323
rgrover1 103:138bdc859cc9 324 return NRF_SUCCESS;
rgrover1 103:138bdc859cc9 325 }
rgrover1 103:138bdc859cc9 326
rgrover1 103:138bdc859cc9 327 #if defined(SVCALL_AS_NORMAL_FUNCTION) || defined(SER_CONNECTIVITY)
rgrover1 103:138bdc859cc9 328 uint32_t app_gpiote_input_event_handler_register(const uint8_t channel,
rgrover1 103:138bdc859cc9 329 const uint32_t pin,
rgrover1 103:138bdc859cc9 330 const uint32_t polarity,
rgrover1 103:138bdc859cc9 331 app_gpiote_input_event_handler_t event_handler)
rgrover1 103:138bdc859cc9 332 {
rgrover1 103:138bdc859cc9 333 (void)sense_level_toggle(NULL, pin);
rgrover1 103:138bdc859cc9 334 return NRF_ERROR_NOT_SUPPORTED;
rgrover1 103:138bdc859cc9 335 }
rgrover1 103:138bdc859cc9 336
rgrover1 103:138bdc859cc9 337 uint32_t app_gpiote_input_event_handler_unregister(const uint8_t channel)
rgrover1 103:138bdc859cc9 338 {
rgrover1 103:138bdc859cc9 339 return NRF_ERROR_NOT_SUPPORTED;
rgrover1 103:138bdc859cc9 340 }
rgrover1 103:138bdc859cc9 341
rgrover1 103:138bdc859cc9 342 uint32_t app_gpiote_end_irq_event_handler_register(app_gpiote_input_event_handler_t event_handler)
rgrover1 103:138bdc859cc9 343 {
rgrover1 103:138bdc859cc9 344 return NRF_ERROR_NOT_SUPPORTED;
rgrover1 103:138bdc859cc9 345 }
rgrover1 103:138bdc859cc9 346
rgrover1 103:138bdc859cc9 347 uint32_t app_gpiote_end_irq_event_handler_unregister(void)
rgrover1 103:138bdc859cc9 348 {
rgrover1 103:138bdc859cc9 349 return NRF_ERROR_NOT_SUPPORTED;
rgrover1 103:138bdc859cc9 350 }
rgrover1 103:138bdc859cc9 351
rgrover1 103:138bdc859cc9 352 uint32_t app_gpiote_enable_interrupts(void)
rgrover1 103:138bdc859cc9 353 {
rgrover1 103:138bdc859cc9 354 return NRF_ERROR_NOT_SUPPORTED;
rgrover1 103:138bdc859cc9 355 }
rgrover1 103:138bdc859cc9 356
rgrover1 103:138bdc859cc9 357 uint32_t app_gpiote_disable_interrupts(void)
rgrover1 103:138bdc859cc9 358 {
rgrover1 103:138bdc859cc9 359 return NRF_ERROR_NOT_SUPPORTED;
rgrover1 103:138bdc859cc9 360 }
marcpl 162:5fd73fb47b21 361 #endif // SVCALL_AS_NORMAL_FUNCTION || SER_CONNECTIVITY