コード例 #1
0
ファイル: bitparam-test.c プロジェクト: JoZie/hcos-plugins
noinstrument void __report_field_access(void *record_ptr, const char *record,
					const char *field, int field_index,
					int is_write, int is_marked,
					unsigned long bitmask, int *scratch,
					const char *filename, int lineno,
					int index, int struct_index)
{
  printf("Struct %s with bitmask: 0x%08lx\n", (is_write ? "assign" : "access"),
	 bitmask);

  check_report(record_ptr, record, field, field_index, is_write, is_marked,
	       bitmask, scratch, filename, lineno);
}
コード例 #2
0
ファイル: main.c プロジェクト: BlueSkyGjj/nRF52
int main(void)
{
    uint32_t err_code;
    bool forever = true;
    uint32_t  number_of_pulses;
    uint32_t  min_number_of_pulses = 2;
    uint32_t  max_number_of_pulses = 0;
    int32_t   pulses;
    int32_t   sign = 1;
    
    err_code = nrf_drv_qdec_init(NULL, qdec_event_handler);
    APP_ERROR_CHECK(err_code);
    
    max_number_of_pulses = nrf_qdec_reportper_to_value(QDEC_CONFIG_REPORTPER);

    // initialize quadrature encoder simulator
    qenc_init((nrf_qdec_ledpol_t)nrf_qdec_ledpol_get());

    while (forever)
    {
      // change a number and sign of pulses produced by simulator in a loop
      for (number_of_pulses=min_number_of_pulses; number_of_pulses<= max_number_of_pulses; number_of_pulses++ )
      {
        pulses = sign*number_of_pulses;      // pulses have sign
        qenc_pulse_count_set(pulses);        // set pulses to be produced by encoder
        nrf_drv_qdec_enable();               // start burst sampling clock, clock will be stopped by REPORTRDY event
        while (! m_report_ready_flag)                         // wait for a report
        {
          __WFE();
        }
        m_report_ready_flag = false;
        check_report(pulses);                 // check if pulse count is as expected, assert otherwise
      }
      min_number_of_pulses = 1;               // only first run is specific, for 1 there would be no call back...
      sign = -sign;                           // change sign of pulses in a loop
    }
    return -1;                                // this should never happen
}