nyx_error_t nyx_sensor_magnetic_field_event_get_item(nyx_event_handle_t handle, nyx_sensor_magnetic_field_event_item_t *event_out_ptr)
{
	nyx_event_t* e = (nyx_event_t*)handle;
	CHECK_EVENT(e);
	CHECK_EVENT_TYPE(e, NYX_EVENT_SENSOR_MAGNETIC_FIELD);
	nyx_event_sensor_magnetic_field_t* a = (nyx_event_sensor_magnetic_field_t*)e;
	*event_out_ptr = a->item;
	return NYX_ERROR_NONE;
}
nyx_error_t nyx_sensor_orientation_event_get_item(nyx_event_handle_t handle, nyx_sensor_orientation_event_item_t *event_out_ptr)
{
	nyx_event_t* e = (nyx_event_t*)handle;
	CHECK_EVENT(e);
	CHECK_EVENT_TYPE(e, NYX_EVENT_SENSOR_ORIENTATION);
	nyx_event_sensor_orientation_t* a = (nyx_event_sensor_orientation_t*)e;
	*event_out_ptr = a->item;
	return NYX_ERROR_NONE;
}
nyx_error_t nyx_sensor_bearing_event_get_item(nyx_event_handle_t handle, nyx_sensor_bearing_event_item_t *event_out_ptr)
{
	nyx_event_t* e = (nyx_event_t*)handle;
	CHECK_EVENT(e);
	CHECK_EVENT_TYPE(e, NYX_EVENT_SENSOR_BEARING);
	nyx_event_sensor_bearing_t* a = (nyx_event_sensor_bearing_t*)e;
	*event_out_ptr = a->item;
	return NYX_ERROR_NONE;
}
nyx_error_t nyx_sensor_als_event_get_intensity(nyx_event_handle_t handle,
        int32_t *intensity_in_lux_out_ptr)
{
	nyx_event_t *e = (nyx_event_t *)handle;
	CHECK_EVENT(e);
	CHECK_EVENT_TYPE(e, NYX_EVENT_SENSOR_ALS);
	nyx_event_sensor_als_t *a = (nyx_event_sensor_als_t *)e;
	*intensity_in_lux_out_ptr = a->item.intensity_in_lux;
	return NYX_ERROR_NONE;
}
Beispiel #5
0
nyx_error_t nyx_touchpanel_event_get_type(nyx_event_handle_t handle, nyx_touchpanel_event_type_t *type_out_ptr)
{
     nyx_event_t* e = (nyx_event_t*)handle;
     CHECK_EVENT(e);
     CHECK_EVENT_TYPE(e, NYX_EVENT_TOUCHPANEL);

     nyx_event_touchpanel_t* a = (nyx_event_touchpanel_t*)e;
     *type_out_ptr = a->type;
     return NYX_ERROR_NONE;
}
Beispiel #6
0
nyx_error_t nyx_touchpanel_event_get_touches(nyx_event_handle_t handle,
    nyx_touchpanel_event_item_t** touches_out_ptr,
    int32_t *count_out_ptr)
{
     nyx_event_t* e = (nyx_event_t*)handle;
     CHECK_EVENT(e);
     CHECK_EVENT_TYPE(e, NYX_EVENT_TOUCHPANEL);

     nyx_event_touchpanel_t* a = (nyx_event_touchpanel_t*)e;

     *touches_out_ptr = a->item_array;
     *count_out_ptr = a->item_count;
     return NYX_ERROR_NONE;
}
Beispiel #7
0
int main()
{
        /* init the structs in the array and shm area */
	int i,j;
	for(i = 0; i < CHANNELS; i++ ){
		pwm_sys[i].pin = i;
		pwm_sys[i].hi_time = 0;
		data_sock->info[PRU][i] = 0;
	}

	/* timer initializations */
	timer_init();

	pwm_sys[0].hi_time = 5; //just for test purposes

	/* main soft-pwm generation loop */
	while(1){
			j = 0;

		/* update pins */
	
			//read the values of hi time 
			i = (pwm_sys[0].hi_time > units_elapsed);
			j |= i << pwm_sys[0].pin;
			
			i = (pwm_sys[1].hi_time > units_elapsed);
			j |= i << pwm_sys[1].pin;

			i = (pwm_sys[2].hi_time > units_elapsed);
			j |= i << pwm_sys[2].pin;

			i = (pwm_sys[3].hi_time > units_elapsed);
			j |= i << pwm_sys[3].pin;

			i = (pwm_sys[4].hi_time > units_elapsed);
			j |= i << pwm_sys[4].pin;

			i = (pwm_sys[5].hi_time > units_elapsed);
			j |= i << pwm_sys[5].pin;

			i = (pwm_sys[6].hi_time > units_elapsed);
			j |= i << pwm_sys[6].pin;

			i = (pwm_sys[7].hi_time > units_elapsed);
			j |= i << pwm_sys[7].pin;
			
			//assign to the output
			__R30 = j;

		/* inc the counter */
			units_elapsed++;

		/* if one time period is over */
			if(units_elapsed == RESOLUTION){
				//reset the time unit count => start of new time period
				units_elapsed = 0;

				if (CHECK_EVENT(EV_PRU0_PRU1)){

					/* clear the system event */
                			PINTC_SICR = EV_PRU0_PRU1; //17
					
					/* update the pru_sys array */
					for(i=0; i<CHANNELS; i++)
               					pwm_sys[i].hi_time = data_sock->info[PRU][i];

				}

			}
		 							
			
		/*** till here no more than 2K inst ***/
		
		/* loop along till timer is up	*/
		
			while(!( PIEP_CMP_STATUS & (2) )){ //0b10
				//just wait
			}
			
		/* the timer has gone off */
			
			//reassign value cmp1
			PIEP_CMP_CMP1 =  ((US * TIME_UNIT) + PIEP_COUNT);

			//clear the interrupt from cmp1
			PIEP_CMP_STATUS = CMD_STATUS_CMP_HIT(1);
			
	}

	return 0;
}