Workflow

  1. 1.
    Create an FREQM device instance struct, which will be associated with an FREQM peripheral hardware instance.
    static struct freqm_module freqm_instance;
    
    Note: Device instance structures shall never go out of scope when in use.
  2. 2.
    Create a new function configure_freqm(), which will be used to configure the overall FREQM peripheral.
    void configure_freqm(void)
    
  3. 3.
    Create an FREQM peripheral configuration structure that will be filled out to set the module configuration.
    struct freqm_config config_freqm;
    
  4. 4.
    Fill the FREQM peripheral configuration structure with the default module configuration values.
    freqm_get_config_defaults(&config_freqm);
    config_freqm.ref_clock_circles = 255;
    
  5. 5.
    Initialize the FREQM peripheral and associate it with the software instance structure that was defined previously.
    freqm_init(&freqm_instance, FREQM, &config_freqm);
    
  6. 6.
    Create a new callback function.
    void freqm_complete_callback(void)
    {
        freqm_read_done = true;
    }
    
  7. 7.
    Create a callback status software flag.
    bool volatile freqm_read_done = false;
    
  8. 8.
    Let the callback function set the flag to true when read job done.
    freqm_read_done = true;
    
  9. 9.
    Create a new function configure_freqm_callback(), which will be used to configure the callbacks.
    void configure_freqm_callback(void)
    {
        freqm_register_callback(&freqm_instance, freqm_complete_callback,
                FREQM_CALLBACK_MEASURE_DONE);
        freqm_enable_callback(&freqm_instance, FREQM_CALLBACK_MEASURE_DONE);
    }
    
  10. 10.
    Register callback function.
    freqm_register_callback(&freqm_instance, freqm_complete_callback,
            FREQM_CALLBACK_MEASURE_DONE);
    
  11. 11.
    Enable the callbacks.
    freqm_enable_callback(&freqm_instance, FREQM_CALLBACK_MEASURE_DONE);
    
  12. 12.
    Enable the now initialized FREQM peripheral.
    freqm_enable(&freqm_instance);
    
    Note: This should not be done until after the FREQM is setup and ready to be used.