Пример #1
0
uint32_t rain_configs_update(){
	rain_printf("\r\nRain Configurations Update\r\n");

	uint8_t configuration = (m_rain.m_amb)->rain_configuration;

	//Reset count
	m_rain.timer_count  = 0;

	//Sensors enable configs
	m_rain.IS_RAIN_ENABLED = (configuration & AMB_ENABLE_BIT);

	//Rate configs
	switch(((configuration & AMB_RATE_BITS) >> 5)){
		case 0b000:
			m_rain.ticks = msec_to_ticks(10000000); //0.0001 Hz
			break;
		case 0b001:
			m_rain.ticks = msec_to_ticks(1000000);  //0.001 Hz
			break;
		case 0b010:
			m_rain.ticks = msec_to_ticks(100000);   //0.01 Hz
			break;
		case 0b011:
			m_rain.ticks = msec_to_ticks(10000);    //0.1 Hz
			break;
		case 0b111:
		default: //If not recognized set max rate
			m_rain.ticks = msec_to_ticks(READ_FREQ);     //0.5 Hz
			break;
	}

	rain_printf("rain_configs_update() Ok!\r\n\r\n");
	return NRF_SUCCESS;
}
Пример #2
0
uint32_t lum_configs_update(){
	lum_printf("\r\nLuminosity Configurations Update\r\n");

	uint8_t configuration = (m_lum.m_amb)->lum_configuration;

	//Reset count
	m_lum.timer_count  = 0;

	//Sensors enable configs
	m_lum.IS_LUM_ENABLED = (configuration & AMB_ENABLE_BIT);

	//Rate configs
	switch(((configuration & AMB_RATE_BITS) >> 5)){
		case 0b000:
			m_lum.ticks = msec_to_ticks(10000000); //0.0001 Hz
			break;
		case 0b001:
			m_lum.ticks = msec_to_ticks(1000000);  //0.001 Hz
			break;
		case 0b010:
			m_lum.ticks = msec_to_ticks(100000);   //0.01 Hz
			break;
		case 0b011:
			m_lum.ticks = msec_to_ticks(10000);    //0.1 Hz
			break;
		case 0b111:
		default: //If not recognized set max rate
			m_lum.ticks = msec_to_ticks(2000);     //0.5 Hz
			break;
	}

	lum_printf("lum_configs_update() Ok!\r\n\r\n");
	return NRF_SUCCESS;
}
Пример #3
0
uint32_t temp_configs_update(){
	temp_printf("\r\nExternal Temperature Configurations Update\r\n");

	uint8_t configuration = (m_temp.m_amb)->temp_configuration;

	//Reset count
	m_temp.timer_count  = 0;

	//Sensors enable configs
	m_temp.IS_TEMP_ENABLED = (configuration & AMB_ENABLE_BIT);

	//Rate configs
	switch(((configuration & AMB_RATE_BITS) >> 5)){
		case 0b000:
			m_temp.ticks = msec_to_ticks(10000000); //0.0001 Hz
			break;
		case 0b001:
			m_temp.ticks = msec_to_ticks(1000000);  //0.001 Hz
			break;
		case 0b010:
			m_temp.ticks = msec_to_ticks(100000);   //0.01 Hz
			break;
		case 0b011:
			m_temp.ticks = msec_to_ticks(10000);    //0.1 Hz
			break;
		case 0b111:
		default: //If not recognized set max rate
			m_temp.ticks = msec_to_ticks(READ_FREQ);     //0.5 Hz
			break;
	}

	temp_printf("temp_configs_update() Ok!\r\n\r\n");
	return NRF_SUCCESS;
}
Пример #4
0
Файл: test.c Проект: onkwon/yaos
static void test_timer()
{
	struct timer ttt;
	while (1) {
		flag = 0;
		ttt.expires = systick + msec_to_ticks(500);
		ttt.event = t1;
		add_timer(&ttt);

		msleep(900);
		while (flag == 0);
	}
}