mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Jul 17 09:15:10 2015 +0100
Revision:
592:a274ee790e56
Parent:
579:53297373a894
Synchronized with git revision e7144f83a8d75df80c4877936b6ffe552b0be9e6

Full URL: https://github.com/mbedmicro/mbed/commit/e7144f83a8d75df80c4877936b6ffe552b0be9e6/

More API implementation for SAMR21

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 579:53297373a894 1 #include <system.h>
mbed_official 579:53297373a894 2 #include <system_interrupt.h>
mbed_official 579:53297373a894 3 #include <extint.h>
mbed_official 579:53297373a894 4 #include <conf_extint.h>
mbed_official 579:53297373a894 5
mbed_official 579:53297373a894 6 #if !defined(EXTINT_CLOCK_SOURCE) || defined(__DOXYGEN__)
mbed_official 579:53297373a894 7 # warning EXTINT_CLOCK_SOURCE is not defined, assuming GCLK_GENERATOR_0.
mbed_official 579:53297373a894 8
mbed_official 579:53297373a894 9 /** Configuration option, setting the EIC clock source which can be used for
mbed_official 579:53297373a894 10 * EIC edge detection or filtering. This option may be overridden in the module
mbed_official 579:53297373a894 11 * configuration header file \c conf_extint.h.
mbed_official 579:53297373a894 12 */
mbed_official 579:53297373a894 13 # define EXTINT_CLOCK_SOURCE GCLK_GENERATOR_0
mbed_official 579:53297373a894 14 #endif
mbed_official 579:53297373a894 15
mbed_official 579:53297373a894 16 /**
mbed_official 579:53297373a894 17 * \internal
mbed_official 579:53297373a894 18 * Internal driver device instance struct.
mbed_official 579:53297373a894 19 */
mbed_official 579:53297373a894 20 struct _extint_module _extint_dev;
mbed_official 579:53297373a894 21
mbed_official 579:53297373a894 22 /**
mbed_official 579:53297373a894 23 * \brief Determin if the general clock is required
mbed_official 579:53297373a894 24 *
mbed_official 579:53297373a894 25 * \param[in] filter_input_signal Filter the raw input signal to prevent noise
mbed_official 579:53297373a894 26 * \param[in] detection_criteria Edge detection mode to use (\ref extint_detect)
mbed_official 579:53297373a894 27 */
mbed_official 579:53297373a894 28 #define _extint_is_gclk_required(filter_input_signal, detection_criteria) \
mbed_official 579:53297373a894 29 ((filter_input_signal) ? true : (\
mbed_official 579:53297373a894 30 (EXTINT_DETECT_RISING == (detection_criteria)) ? true : (\
mbed_official 579:53297373a894 31 (EXTINT_DETECT_FALLING == (detection_criteria)) ? true : (\
mbed_official 579:53297373a894 32 (EXTINT_DETECT_BOTH == (detection_criteria)) ? true : false))))
mbed_official 579:53297373a894 33
mbed_official 579:53297373a894 34 static void _extint_enable(void);
mbed_official 579:53297373a894 35 static void _extint_disable(void);
mbed_official 579:53297373a894 36
mbed_official 579:53297373a894 37 /**
mbed_official 579:53297373a894 38 * \brief Determines if the hardware module(s) are currently synchronizing to the bus.
mbed_official 579:53297373a894 39 *
mbed_official 579:53297373a894 40 * Checks to see if the underlying hardware peripheral module(s) are currently
mbed_official 579:53297373a894 41 * synchronizing across multiple clock domains to the hardware bus, This
mbed_official 579:53297373a894 42 * function can be used to delay further operations on a module until such time
mbed_official 579:53297373a894 43 * that it is ready, to prevent blocking delays for synchronization in the
mbed_official 579:53297373a894 44 * user application.
mbed_official 579:53297373a894 45 *
mbed_official 579:53297373a894 46 * \return Synchronization status of the underlying hardware module(s).
mbed_official 579:53297373a894 47 *
mbed_official 579:53297373a894 48 * \retval true If the module synchronization is ongoing
mbed_official 579:53297373a894 49 * \retval false If the module has completed synchronization
mbed_official 579:53297373a894 50 */
mbed_official 579:53297373a894 51 static inline bool extint_is_syncing(void)
mbed_official 579:53297373a894 52 {
mbed_official 579:53297373a894 53 Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
mbed_official 579:53297373a894 54
mbed_official 579:53297373a894 55 for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
mbed_official 579:53297373a894 56 if (eics[i]->STATUS.reg & EIC_STATUS_SYNCBUSY) {
mbed_official 579:53297373a894 57 return true;
mbed_official 579:53297373a894 58 }
mbed_official 579:53297373a894 59 }
mbed_official 579:53297373a894 60 return false;
mbed_official 579:53297373a894 61 }
mbed_official 579:53297373a894 62 /**
mbed_official 579:53297373a894 63 * \internal
mbed_official 579:53297373a894 64 * \brief Initializes and enables the External Interrupt driver.
mbed_official 579:53297373a894 65 *
mbed_official 579:53297373a894 66 * Enable the clocks used by External Interrupt driver.
mbed_official 579:53297373a894 67 *
mbed_official 579:53297373a894 68 * Resets the External Interrupt driver, resetting all hardware
mbed_official 579:53297373a894 69 * module registers to their power-on defaults, then enable it for further use.
mbed_official 579:53297373a894 70 *
mbed_official 579:53297373a894 71 * Reset the callback list if callback mode is used.
mbed_official 579:53297373a894 72 *
mbed_official 579:53297373a894 73 * This function must be called before attempting to use any NMI or standard
mbed_official 579:53297373a894 74 * external interrupt channel functions.
mbed_official 579:53297373a894 75 *
mbed_official 579:53297373a894 76 * \note When SYSTEM module is used, this function will be invoked by
mbed_official 579:53297373a894 77 * \ref system_init() automatically if the module is included.
mbed_official 579:53297373a894 78 */
mbed_official 579:53297373a894 79 void _system_extint_init(void);
mbed_official 579:53297373a894 80 void _system_extint_init(void)
mbed_official 579:53297373a894 81 {
mbed_official 579:53297373a894 82 Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
mbed_official 579:53297373a894 83
mbed_official 579:53297373a894 84 /* Turn on the digital interface clock */
mbed_official 579:53297373a894 85 system_apb_clock_set_mask(SYSTEM_CLOCK_APB_APBA, PM_APBAMASK_EIC);
mbed_official 579:53297373a894 86
mbed_official 579:53297373a894 87 /* Configure the generic clock for the module and enable it */
mbed_official 579:53297373a894 88 struct system_gclk_chan_config gclk_chan_conf;
mbed_official 579:53297373a894 89 system_gclk_chan_get_config_defaults(&gclk_chan_conf);
mbed_official 579:53297373a894 90 gclk_chan_conf.source_generator = EXTINT_CLOCK_SOURCE;
mbed_official 579:53297373a894 91 system_gclk_chan_set_config(EIC_GCLK_ID, &gclk_chan_conf);
mbed_official 579:53297373a894 92
mbed_official 579:53297373a894 93 /* Enable the clock anyway, since when needed it will be requested
mbed_official 579:53297373a894 94 * by External Interrupt driver */
mbed_official 579:53297373a894 95 system_gclk_chan_enable(EIC_GCLK_ID);
mbed_official 579:53297373a894 96
mbed_official 579:53297373a894 97 /* Reset all EIC hardware modules. */
mbed_official 579:53297373a894 98 for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
mbed_official 579:53297373a894 99 eics[i]->CTRL.reg |= EIC_CTRL_SWRST;
mbed_official 579:53297373a894 100 }
mbed_official 579:53297373a894 101
mbed_official 579:53297373a894 102 while (extint_is_syncing()) {
mbed_official 579:53297373a894 103 /* Wait for all hardware modules to complete synchronization */
mbed_official 579:53297373a894 104 }
mbed_official 579:53297373a894 105
mbed_official 579:53297373a894 106 /* Reset the software module */
mbed_official 579:53297373a894 107 // TEMP: Commented by V
mbed_official 579:53297373a894 108 //#if EXTINT_CALLBACK_MODE == true
mbed_official 579:53297373a894 109 /* Clear callback registration table */
mbed_official 579:53297373a894 110 for (uint8_t j = 0; j < EIC_NUMBER_OF_INTERRUPTS; j++) {
mbed_official 579:53297373a894 111 _extint_dev.callbacks[j] = NULL;
mbed_official 579:53297373a894 112 }
mbed_official 579:53297373a894 113 system_interrupt_enable(SYSTEM_INTERRUPT_MODULE_EIC);
mbed_official 579:53297373a894 114 //#endif
mbed_official 579:53297373a894 115
mbed_official 579:53297373a894 116 /* Enables the driver for further use */
mbed_official 579:53297373a894 117 _extint_enable();
mbed_official 579:53297373a894 118 }
mbed_official 579:53297373a894 119
mbed_official 579:53297373a894 120 /**
mbed_official 579:53297373a894 121 * \internal
mbed_official 579:53297373a894 122 * \brief Enables the External Interrupt driver.
mbed_official 579:53297373a894 123 *
mbed_official 579:53297373a894 124 * Enables EIC modules.
mbed_official 579:53297373a894 125 * Registered callback list will not be affected if callback mode is used.
mbed_official 579:53297373a894 126 */
mbed_official 579:53297373a894 127 void _extint_enable(void)
mbed_official 579:53297373a894 128 {
mbed_official 579:53297373a894 129 Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
mbed_official 579:53297373a894 130
mbed_official 579:53297373a894 131 /* Enable all EIC hardware modules. */
mbed_official 579:53297373a894 132 for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
mbed_official 579:53297373a894 133 eics[i]->CTRL.reg |= EIC_CTRL_ENABLE;
mbed_official 579:53297373a894 134 }
mbed_official 579:53297373a894 135
mbed_official 579:53297373a894 136 while (extint_is_syncing()) {
mbed_official 579:53297373a894 137 /* Wait for all hardware modules to complete synchronization */
mbed_official 579:53297373a894 138 }
mbed_official 579:53297373a894 139 }
mbed_official 579:53297373a894 140
mbed_official 579:53297373a894 141 /**
mbed_official 579:53297373a894 142 * \internal
mbed_official 579:53297373a894 143 * \brief Disables the External Interrupt driver.
mbed_official 579:53297373a894 144 *
mbed_official 579:53297373a894 145 * Disables EIC modules that were previously started via a call to
mbed_official 579:53297373a894 146 * \ref _extint_enable().
mbed_official 579:53297373a894 147 * Registered callback list will not be affected if callback mode is used.
mbed_official 579:53297373a894 148 */
mbed_official 579:53297373a894 149 void _extint_disable(void)
mbed_official 579:53297373a894 150 {
mbed_official 579:53297373a894 151 Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
mbed_official 579:53297373a894 152
mbed_official 579:53297373a894 153 /* Disable all EIC hardware modules. */
mbed_official 579:53297373a894 154 for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
mbed_official 579:53297373a894 155 eics[i]->CTRL.reg &= ~EIC_CTRL_ENABLE;
mbed_official 579:53297373a894 156 }
mbed_official 579:53297373a894 157
mbed_official 579:53297373a894 158 while (extint_is_syncing()) {
mbed_official 579:53297373a894 159 /* Wait for all hardware modules to complete synchronization */
mbed_official 579:53297373a894 160 }
mbed_official 579:53297373a894 161 }
mbed_official 579:53297373a894 162
mbed_official 579:53297373a894 163 /**
mbed_official 579:53297373a894 164 * \brief Initializes an External Interrupt channel configuration structure to defaults.
mbed_official 579:53297373a894 165 *
mbed_official 579:53297373a894 166 * Initializes a given External Interrupt channel configuration structure to a
mbed_official 579:53297373a894 167 * set of known default values. This function should be called on all new
mbed_official 579:53297373a894 168 * instances of these configuration structures before being modified by the
mbed_official 579:53297373a894 169 * user application.
mbed_official 579:53297373a894 170 *
mbed_official 579:53297373a894 171 * The default configuration is as follows:
mbed_official 579:53297373a894 172 * \li Wake the device if an edge detection occurs whilst in sleep
mbed_official 579:53297373a894 173 * \li Input filtering disabled
mbed_official 579:53297373a894 174 * \li Internal pull-up enabled
mbed_official 579:53297373a894 175 * \li Detect falling edges of a signal
mbed_official 579:53297373a894 176 *
mbed_official 579:53297373a894 177 * \param[out] config Configuration structure to initialize to default values
mbed_official 579:53297373a894 178 */
mbed_official 579:53297373a894 179 void extint_chan_get_config_defaults(
mbed_official 579:53297373a894 180 struct extint_chan_conf *const config)
mbed_official 579:53297373a894 181 {
mbed_official 579:53297373a894 182 /* Sanity check arguments */
mbed_official 579:53297373a894 183 Assert(config);
mbed_official 579:53297373a894 184
mbed_official 579:53297373a894 185 /* Default configuration values */
mbed_official 579:53297373a894 186 config->gpio_pin = 0;
mbed_official 579:53297373a894 187 config->gpio_pin_mux = 0;
mbed_official 579:53297373a894 188 config->gpio_pin_pull = EXTINT_PULL_UP;
mbed_official 579:53297373a894 189 config->wake_if_sleeping = true;
mbed_official 579:53297373a894 190 config->filter_input_signal = false;
mbed_official 579:53297373a894 191 config->detection_criteria = EXTINT_DETECT_FALLING;
mbed_official 579:53297373a894 192 }
mbed_official 579:53297373a894 193
mbed_official 579:53297373a894 194 /**
mbed_official 579:53297373a894 195 * \brief Writes an External Interrupt channel configuration to the hardware module.
mbed_official 579:53297373a894 196 *
mbed_official 579:53297373a894 197 * Writes out a given configuration of an External Interrupt channel
mbed_official 579:53297373a894 198 * configuration to the hardware module. If the channel is already configured,
mbed_official 579:53297373a894 199 * the new configuration will replace the existing one.
mbed_official 579:53297373a894 200 *
mbed_official 579:53297373a894 201 * \param[in] channel External Interrupt channel to configure
mbed_official 579:53297373a894 202 * \param[in] config Configuration settings for the channel
mbed_official 579:53297373a894 203
mbed_official 579:53297373a894 204 */
mbed_official 579:53297373a894 205 void extint_chan_set_config(
mbed_official 579:53297373a894 206 const uint8_t channel,
mbed_official 579:53297373a894 207 const struct extint_chan_conf *const config)
mbed_official 579:53297373a894 208 {
mbed_official 579:53297373a894 209 /* Sanity check arguments */
mbed_official 579:53297373a894 210 Assert(config);
mbed_official 579:53297373a894 211 /* Sanity check clock requirements */
mbed_official 579:53297373a894 212 Assert(!(!system_gclk_gen_is_enabled(EXTINT_CLOCK_SOURCE) &&
mbed_official 579:53297373a894 213 _extint_is_gclk_required(config->filter_input_signal,
mbed_official 579:53297373a894 214 config->detection_criteria)));
mbed_official 579:53297373a894 215
mbed_official 579:53297373a894 216 struct system_pinmux_config pinmux_config;
mbed_official 579:53297373a894 217 system_pinmux_get_config_defaults(&pinmux_config);
mbed_official 579:53297373a894 218
mbed_official 579:53297373a894 219 pinmux_config.mux_position = config->gpio_pin_mux;
mbed_official 579:53297373a894 220 pinmux_config.direction = SYSTEM_PINMUX_PIN_DIR_INPUT;
mbed_official 579:53297373a894 221 pinmux_config.input_pull = (enum system_pinmux_pin_pull)config->gpio_pin_pull;
mbed_official 579:53297373a894 222 system_pinmux_pin_set_config(config->gpio_pin, &pinmux_config);
mbed_official 579:53297373a894 223
mbed_official 579:53297373a894 224 /* Get a pointer to the module hardware instance */
mbed_official 579:53297373a894 225 Eic *const EIC_module = _extint_get_eic_from_channel(channel);
mbed_official 579:53297373a894 226
mbed_official 579:53297373a894 227 uint32_t config_pos = (4 * (channel % 8));
mbed_official 579:53297373a894 228 uint32_t new_config;
mbed_official 579:53297373a894 229
mbed_official 579:53297373a894 230 /* Determine the channel's new edge detection configuration */
mbed_official 579:53297373a894 231 new_config = (config->detection_criteria << EIC_CONFIG_SENSE0_Pos);
mbed_official 579:53297373a894 232
mbed_official 579:53297373a894 233 /* Enable the hardware signal filter if requested in the config */
mbed_official 579:53297373a894 234 if (config->filter_input_signal) {
mbed_official 579:53297373a894 235 new_config |= EIC_CONFIG_FILTEN0;
mbed_official 579:53297373a894 236 }
mbed_official 579:53297373a894 237
mbed_official 579:53297373a894 238 /* Clear the existing and set the new channel configuration */
mbed_official 579:53297373a894 239 EIC_module->CONFIG[channel / 8].reg
mbed_official 579:53297373a894 240 = (EIC_module->CONFIG[channel / 8].reg &
mbed_official 579:53297373a894 241 ~((EIC_CONFIG_SENSE0_Msk | EIC_CONFIG_FILTEN0) << config_pos)) |
mbed_official 579:53297373a894 242 (new_config << config_pos);
mbed_official 579:53297373a894 243
mbed_official 579:53297373a894 244 /* Set the channel's new wake up mode setting */
mbed_official 579:53297373a894 245 if (config->wake_if_sleeping) {
mbed_official 579:53297373a894 246 EIC_module->WAKEUP.reg |= (1UL << channel);
mbed_official 579:53297373a894 247 } else {
mbed_official 579:53297373a894 248 EIC_module->WAKEUP.reg &= ~(1UL << channel);
mbed_official 579:53297373a894 249 }
mbed_official 579:53297373a894 250 }
mbed_official 579:53297373a894 251
mbed_official 579:53297373a894 252 /**
mbed_official 579:53297373a894 253 * \brief Writes an External Interrupt NMI channel configuration to the hardware module.
mbed_official 579:53297373a894 254 *
mbed_official 579:53297373a894 255 * Writes out a given configuration of an External Interrupt NMI channel
mbed_official 579:53297373a894 256 * configuration to the hardware module. If the channel is already configured,
mbed_official 579:53297373a894 257 * the new configuration will replace the existing one.
mbed_official 579:53297373a894 258 *
mbed_official 579:53297373a894 259 * \param[in] nmi_channel External Interrupt NMI channel to configure
mbed_official 579:53297373a894 260 * \param[in] config Configuration settings for the channel
mbed_official 579:53297373a894 261 *
mbed_official 579:53297373a894 262 * \returns Status code indicating the success or failure of the request.
mbed_official 579:53297373a894 263 * \retval STATUS_OK Configuration succeeded
mbed_official 579:53297373a894 264 * \retval STATUS_ERR_PIN_MUX_INVALID An invalid pinmux value was supplied
mbed_official 579:53297373a894 265 * \retval STATUS_ERR_BAD_FORMAT An invalid detection mode was requested
mbed_official 579:53297373a894 266 */
mbed_official 579:53297373a894 267 enum status_code extint_nmi_set_config(
mbed_official 579:53297373a894 268 const uint8_t nmi_channel,
mbed_official 579:53297373a894 269 const struct extint_nmi_conf *const config)
mbed_official 579:53297373a894 270 {
mbed_official 579:53297373a894 271 /* Sanity check arguments */
mbed_official 579:53297373a894 272 Assert(config);
mbed_official 579:53297373a894 273 /* Sanity check clock requirements */
mbed_official 579:53297373a894 274 Assert(!(!system_gclk_gen_is_enabled(EXTINT_CLOCK_SOURCE) &&
mbed_official 579:53297373a894 275 _extint_is_gclk_required(config->filter_input_signal,
mbed_official 579:53297373a894 276 config->detection_criteria)));
mbed_official 579:53297373a894 277
mbed_official 579:53297373a894 278 struct system_pinmux_config pinmux_config;
mbed_official 579:53297373a894 279 system_pinmux_get_config_defaults(&pinmux_config);
mbed_official 579:53297373a894 280
mbed_official 579:53297373a894 281 pinmux_config.mux_position = config->gpio_pin_mux;
mbed_official 579:53297373a894 282 pinmux_config.direction = SYSTEM_PINMUX_PIN_DIR_INPUT;
mbed_official 579:53297373a894 283 pinmux_config.input_pull = SYSTEM_PINMUX_PIN_PULL_UP;
mbed_official 579:53297373a894 284 pinmux_config.input_pull = (enum system_pinmux_pin_pull)config->gpio_pin_pull;
mbed_official 579:53297373a894 285 system_pinmux_pin_set_config(config->gpio_pin, &pinmux_config);
mbed_official 579:53297373a894 286
mbed_official 579:53297373a894 287 /* Get a pointer to the module hardware instance */
mbed_official 579:53297373a894 288 Eic *const EIC_module = _extint_get_eic_from_channel(nmi_channel);
mbed_official 579:53297373a894 289
mbed_official 579:53297373a894 290 uint32_t new_config;
mbed_official 579:53297373a894 291
mbed_official 579:53297373a894 292 /* Determine the NMI's new edge detection configuration */
mbed_official 579:53297373a894 293 new_config = (config->detection_criteria << EIC_NMICTRL_NMISENSE_Pos);
mbed_official 579:53297373a894 294
mbed_official 579:53297373a894 295 /* Enable the hardware signal filter if requested in the config */
mbed_official 579:53297373a894 296 if (config->filter_input_signal) {
mbed_official 579:53297373a894 297 new_config |= EIC_NMICTRL_NMIFILTEN;
mbed_official 579:53297373a894 298 }
mbed_official 579:53297373a894 299
mbed_official 579:53297373a894 300 /* Disable EIC and general clock to configure NMI */
mbed_official 579:53297373a894 301 _extint_disable();
mbed_official 579:53297373a894 302 system_gclk_chan_disable(EIC_GCLK_ID);
mbed_official 579:53297373a894 303
mbed_official 579:53297373a894 304 EIC_module->NMICTRL.reg = new_config;
mbed_official 579:53297373a894 305
mbed_official 579:53297373a894 306 /* Enable the general clock and EIC after configure NMI */
mbed_official 579:53297373a894 307 system_gclk_chan_enable(EIC_GCLK_ID);
mbed_official 579:53297373a894 308 _extint_enable();
mbed_official 579:53297373a894 309
mbed_official 579:53297373a894 310 return STATUS_OK;
mbed_official 579:53297373a894 311 }
mbed_official 579:53297373a894 312
mbed_official 579:53297373a894 313 /**
mbed_official 579:53297373a894 314 * \brief Enables an External Interrupt event output.
mbed_official 579:53297373a894 315 *
mbed_official 579:53297373a894 316 * Enables one or more output events from the External Interrupt module. See
mbed_official 579:53297373a894 317 * \ref extint_events "here" for a list of events this module supports.
mbed_official 579:53297373a894 318 *
mbed_official 579:53297373a894 319 * \note Events cannot be altered while the module is enabled.
mbed_official 579:53297373a894 320 *
mbed_official 579:53297373a894 321 * \param[in] events Struct containing flags of events to enable
mbed_official 579:53297373a894 322 */
mbed_official 579:53297373a894 323 void extint_enable_events(
mbed_official 579:53297373a894 324 struct extint_events *const events)
mbed_official 579:53297373a894 325 {
mbed_official 579:53297373a894 326 /* Sanity check arguments */
mbed_official 579:53297373a894 327 Assert(events);
mbed_official 579:53297373a894 328
mbed_official 579:53297373a894 329 /* Array of available EICs. */
mbed_official 579:53297373a894 330 Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
mbed_official 579:53297373a894 331
mbed_official 579:53297373a894 332 /* Update the event control register for each physical EIC instance */
mbed_official 579:53297373a894 333 for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
mbed_official 579:53297373a894 334 uint32_t event_mask = 0;
mbed_official 579:53297373a894 335
mbed_official 579:53297373a894 336 /* Create an enable mask for the current EIC module */
mbed_official 579:53297373a894 337 for (uint32_t j = 0; j < 32; j++) {
mbed_official 579:53297373a894 338 if (events->generate_event_on_detect[(32 * i) + j]) {
mbed_official 579:53297373a894 339 event_mask |= (1UL << j);
mbed_official 579:53297373a894 340 }
mbed_official 579:53297373a894 341 }
mbed_official 579:53297373a894 342
mbed_official 579:53297373a894 343 /* Enable the masked events */
mbed_official 579:53297373a894 344 eics[i]->EVCTRL.reg |= event_mask;
mbed_official 579:53297373a894 345 }
mbed_official 579:53297373a894 346 }
mbed_official 579:53297373a894 347
mbed_official 579:53297373a894 348 /**
mbed_official 579:53297373a894 349 * \brief Disables an External Interrupt event output.
mbed_official 579:53297373a894 350 *
mbed_official 579:53297373a894 351 * Disables one or more output events from the External Interrupt module. See
mbed_official 579:53297373a894 352 * \ref extint_events "here" for a list of events this module supports.
mbed_official 579:53297373a894 353 *
mbed_official 579:53297373a894 354 * \note Events cannot be altered while the module is enabled.
mbed_official 579:53297373a894 355 *
mbed_official 579:53297373a894 356 * \param[in] events Struct containing flags of events to disable
mbed_official 579:53297373a894 357 */
mbed_official 579:53297373a894 358 void extint_disable_events(
mbed_official 579:53297373a894 359 struct extint_events *const events)
mbed_official 579:53297373a894 360 {
mbed_official 579:53297373a894 361 /* Sanity check arguments */
mbed_official 579:53297373a894 362 Assert(events);
mbed_official 579:53297373a894 363
mbed_official 579:53297373a894 364 /* Array of available EICs. */
mbed_official 579:53297373a894 365 Eic *const eics[EIC_INST_NUM] = EIC_INSTS;
mbed_official 579:53297373a894 366
mbed_official 579:53297373a894 367 /* Update the event control register for each physical EIC instance */
mbed_official 579:53297373a894 368 for (uint32_t i = 0; i < EIC_INST_NUM; i++) {
mbed_official 579:53297373a894 369 uint32_t event_mask = 0;
mbed_official 579:53297373a894 370
mbed_official 579:53297373a894 371 /* Create a disable mask for the current EIC module */
mbed_official 579:53297373a894 372 for (uint32_t j = 0; j < 32; j++) {
mbed_official 579:53297373a894 373 if (events->generate_event_on_detect[(32 * i) + j]) {
mbed_official 579:53297373a894 374 event_mask |= (1UL << j);
mbed_official 579:53297373a894 375 }
mbed_official 579:53297373a894 376 }
mbed_official 579:53297373a894 377
mbed_official 579:53297373a894 378 /* Disable the masked events */
mbed_official 579:53297373a894 379 eics[i]->EVCTRL.reg &= ~event_mask;
mbed_official 579:53297373a894 380 }
mbed_official 579:53297373a894 381 }