Esempio n. 1
0
static void timer_test(int flags) {
    int x;
    timer_isr_handle_t inth[4];
    my_timer_init(TIMER_GROUP_0, TIMER_0, 110000);
    my_timer_init(TIMER_GROUP_0, TIMER_1, 120000);
    my_timer_init(TIMER_GROUP_1, TIMER_0, 130000);
    my_timer_init(TIMER_GROUP_1, TIMER_1, 140000);
    timer_isr_register(TIMER_GROUP_0, TIMER_0, timer_isr, (void*)0, flags|ESP_INTR_FLAG_INTRDISABLED, &inth[0]);
    timer_isr_register(TIMER_GROUP_0, TIMER_1, timer_isr, (void*)1, flags, &inth[1]);
    timer_isr_register(TIMER_GROUP_1, TIMER_0, timer_isr, (void*)2, flags, &inth[2]);
    timer_isr_register(TIMER_GROUP_1, TIMER_1, timer_isr, (void*)3, flags, &inth[3]);
    timer_start(TIMER_GROUP_0, TIMER_0);
    timer_start(TIMER_GROUP_0, TIMER_1);
    timer_start(TIMER_GROUP_1, TIMER_0);
    timer_start(TIMER_GROUP_1, TIMER_1);

    for (x=0; x<4; x++) count[x]=0;
    printf("Interrupts allocated: %d (dis) %d %d %d\n",
            esp_intr_get_intno(inth[0]), esp_intr_get_intno(inth[1]),
            esp_intr_get_intno(inth[2]), esp_intr_get_intno(inth[3]));
    printf("Timer values on start: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
    vTaskDelay(1000 / portTICK_PERIOD_MS);
    printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
    TEST_ASSERT(count[0]==0);
    TEST_ASSERT(count[1]!=0);
    TEST_ASSERT(count[2]!=0);
    TEST_ASSERT(count[3]!=0);

    printf("Disabling timers 1 and 2...\n");
    esp_intr_enable(inth[0]);
    esp_intr_disable(inth[1]);
    esp_intr_disable(inth[2]);
    for (x=0; x<4; x++) count[x]=0;
    vTaskDelay(1000 / portTICK_PERIOD_MS);
    printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
    TEST_ASSERT(count[0]!=0);
    TEST_ASSERT(count[1]==0);
    TEST_ASSERT(count[2]==0);
    TEST_ASSERT(count[3]!=0);
    printf("Disabling other half...\n");
    esp_intr_enable(inth[1]);
    esp_intr_enable(inth[2]);
    esp_intr_disable(inth[0]);
    esp_intr_disable(inth[3]);
    for (x=0; x<4; x++) count[x]=0;
    vTaskDelay(1000 / portTICK_PERIOD_MS);
    printf("Timer values after 1 sec: %d %d %d %d\n", count[0], count[1], count[2], count[3]);
    TEST_ASSERT(count[0]==0);
    TEST_ASSERT(count[1]!=0);
    TEST_ASSERT(count[2]!=0);
    TEST_ASSERT(count[3]==0);
    printf("Done.\n");
    esp_intr_free(inth[0]);
    esp_intr_free(inth[1]);
    esp_intr_free(inth[2]);
    esp_intr_free(inth[3]);
}
Esempio n. 2
0
void test_init()
{
  my_timer_init(&myt);

  diag("----- Routine ---------------");
  diag("myt.cycles.routine          : %13llu", myt.cycles.routine);
  diag("myt.nanoseconds.routine     : %13llu", myt.nanoseconds.routine);
  diag("myt.microseconds.routine    : %13llu", myt.microseconds.routine);
  diag("myt.milliseconds.routine    : %13llu", myt.milliseconds.routine);
  diag("myt.ticks.routine           : %13llu", myt.ticks.routine);

  diag("----- Frequency -------------");
  diag("myt.cycles.frequency        : %13llu", myt.cycles.frequency);
  diag("myt.nanoseconds.frequency   : %13llu", myt.nanoseconds.frequency);
  diag("myt.microseconds.frequency  : %13llu", myt.microseconds.frequency);
  diag("myt.milliseconds.frequency  : %13llu", myt.milliseconds.frequency);
  diag("myt.ticks.frequency         : %13llu", myt.ticks.frequency);

  diag("----- Resolution ------------");
  diag("myt.cycles.resolution       : %13llu", myt.cycles.resolution);
  diag("myt.nanoseconds.resolution  : %13llu", myt.nanoseconds.resolution);
  diag("myt.microseconds.resolution : %13llu", myt.microseconds.resolution);
  diag("myt.milliseconds.resolution : %13llu", myt.milliseconds.resolution);
  diag("myt.ticks.resolution        : %13llu", myt.ticks.resolution);

  diag("----- Overhead --------------");
  diag("myt.cycles.overhead         : %13llu", myt.cycles.overhead);
  diag("myt.nanoseconds.overhead    : %13llu", myt.nanoseconds.overhead);
  diag("myt.microseconds.overhead   : %13llu", myt.microseconds.overhead);
  diag("myt.milliseconds.overhead   : %13llu", myt.milliseconds.overhead);
  diag("myt.ticks.overhead          : %13llu", myt.ticks.overhead);

  ok(1, "my_timer_init() did not crash");
}
Esempio n. 3
0
void chassis_timestamps_global_init(chassis_timestamps_global_t *gl) {
    chassis_timestamps_global_t *timestamps = gl;

    if (NULL == gl) {
        if (NULL != chassis_timestamps_global) {
            g_warning("%s: invalid attempt to reinitialize the global chassis timer info, ignoring call, still using %p",
                    G_STRLOC, (void*)chassis_timestamps_global);
            return;
        } else {
            chassis_timestamps_global = g_new0(chassis_timestamps_global_t, 1);
        }
        timestamps = chassis_timestamps_global;
        g_debug("%s: created new global chassis timer info at %p", G_STRLOC, (void*)chassis_timestamps_global);
    }
    my_timer_init(timestamps);
}
/**@brief Function for application main entry.
 */
int main(void)
{

    // Initialize	
//		nrf_gpio_cfg_output(23);
//		nrf_gpio_pin_write(23, 0);
//		nrf_gpio_pin_write(23, 1);
//		nrf_delay_ms(1000);
//		nrf_gpio_pin_write(23, 0);
		uart_init();
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
		app_button_enable();
		wdt_init();	
#ifdef  DEBUG_LOG
		printf("uart_init\r\n");
		printf("leds_init\r\n");
		printf("timers_init\r\n");
		printf("gpiote_init\r\n");
		printf("buttons_init\r\n");
		printf("wdt_init\r\n");
#endif	
	
    bond_manager_init();
    ble_stack_init();
    gap_params_init();
#ifdef  DEBUG_LOG
		printf("bond_manager_init\r\n");
		printf("ble_stack_init\r\n");
		printf("gap_params_init\r\n");
#endif


    advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
    services_init();
    conn_params_init();
    sec_params_init();	
    radio_notification_init();
#ifdef  DEBUG_LOG
		printf("advertising_init\r\n");
		printf("services_init\r\n");
		printf("conn_params_init\r\n");
		printf("radio_notification_init\r\n");
#endif

    advertising_start();
#ifdef  DEBUG_LOG
		printf("advertising_start\r\n");
#endif		
		
		
			
		HTU21D_Init();
		
#ifdef  DEBUG_LOG
		printf("HTU21D_Init\r\n");
		printf("OLED_Init\r\n");
#endif		
		
		my_timer_init();
		Auto_Time_Set();
		
#ifdef  DEBUG_LOG
		printf("rtc my_timer_init\r\n");
		printf("Auto_Time_Set\r\n");
#endif
	
		wdt_start();
#ifdef  DEBUG_LOG
		printf("wdt_start\r\n");
		printf("Enter main loop\r\n");		
#endif	

		OLED_POWER_CONTROL(1);
		nrf_delay_ms(2000);
		OLED_POWER_CONTROL(0);
    for (;;)
    {
			
			updata_by_min();
			updata_by_hour();
			power_manage();
    }
}