Configure EVENTS for fault input

  1. Create a event resource instance struct for the EVENTS module to store.
    struct events_resource event_resource;
    
    Note: This should never go out of scope as long as the resource is in use. In most cases, this should be global.
  2. Create an event channel configuration struct, which can be filled out to adjust the configuration of a single event channel.
    struct events_config config;
    
  3. Initialize the event channel configuration struct with the module's default values.
    events_get_config_defaults(&config);
    
    Note: This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
  4. Adjust the configuration struct to request that the channel be attached to the specified event generator, and that the asynchronous event path be used. Here the EIC channel connected to board button is the event generator.
    config.generator = CONF_FAULT_EVENT_GENERATOR;
    config.path      = EVENTS_PATH_ASYNCHRONOUS;
    
  5. Allocate and configure the channel using the configuration structure.
    events_allocate(&event_resource, &config);
    
    Note: The existing configuration struct may be re-used, as long as any values that have been altered from the default settings are taken into account by the user application.
  6. Attach an user to the channel. Here the user is TCC channel 0 event, which has been configured as input of Recoverable Fault.
    events_attach_user(&event_resource, CONF_FAULT_EVENT_USER);