Exemplo n.º 1
0
int main()
{
	MSS_GPIO_init();
	Yellowstone_init();
	Max19706_init(MSS_SPI_SLAVE_1);
	Joshua_init();
	Teton_init();

	Max2830_set_frequency(2405000000uL);
	Max2830_set_tx_gain(15);

	set_mode(RADIO_TX_MODE);
	BB_CTRL->MUX1 = MUX_PATH_TX;
	BB_CTRL->MUX2 = MUX_PATH_TX;

	MSS_TIM1_init(MSS_TIMER_PERIODIC_MODE);
	MSS_TIM1_enable_irq();
	MSS_TIM2_init(MSS_TIMER_ONE_SHOT_MODE);
	MSS_TIM2_enable_irq();

	MSS_TIM1_load_background(packet_rate * MICRO_SEC_DIV);
	MSS_TIM1_start();

	while( 1 )
	{
		if (spi_cmd_length > 0)
		{
			process_spi_cmd_buf((const char*)spi_cmd_buf, spi_cmd_length);
			spi_cmd_length = 0;
		}

		if (tx_done_it_flag)
		{
			tx_done_it_flag = 0;
			int32_t jitter = ((int8_t)lfsr_rand()) * packet_var;
			MSS_TIM1_load_background((uint32_t)((int32_t)packet_rate + jitter) * MICRO_SEC_DIV);
		}

		if (sfd_it_flag)
		{
			sfd_it_flag = 0;
		}

		if (rx_done_it_flag)
		{
			rx_done_it_flag = 0;
		}
	}
}
Exemplo n.º 2
0
int main()
{
	//uint32_t count;

	MSS_GPIO_init();
	MSS_GPIO_config( MSS_GPIO_0, MSS_GPIO_OUTPUT_MODE);
	MSS_GPIO_config( MSS_GPIO_1, MSS_GPIO_OUTPUT_MODE);


	MSS_I2C_init(&g_mss_i2c1 , IMU_ADDRESS_WRITE, MSS_I2C_PCLK_DIV_256 );
	imu_init();

	//one timer tick is 10ns at 100Mhz
	MSS_TIM1_init( MSS_TIMER_PERIODIC_MODE);
	MSS_TIM1_enable_irq();
	MSS_TIM1_load_background(100000);
	MSS_TIM1_start();

	MSS_TIM2_init( MSS_TIMER_ONE_SHOT_MODE);







	while( 1 ) {

		//int16_t x_accl = imu_accl_x();
		//int16_t y_accl = imu_accl_y();
		//int16_t z_accl = imu_accl_z();



	    X_GYRO = imu_gyro_x();
	    Y_ACCL = imu_accl_y();
		//uint16_t y_gyro = imu_gyro_y();
		//uint16_t z_gyro = imu_gyro_z();


		//printf("Avg X: %f\r\n", avg_x);
		//printf("Accel X: %i\n\r", x_accl);
		//printf("Accel Y: %u\n\r", y_accl);
		//printf("Accel Z: %u\n\r", z_accl);

		//printf("Gyro X: %u\r\n", x_gyro);
		//printf("Gyro Y: %u\r\n", y_gyro);
		//printf("Gyro Z: %u\r\n", z_gyro);



		//150000 = 1.5ms pulse
		//1.49ms pulse = equilibrium point
		uint32_t pulsewidth_right = 150000 + (angle/90.0)*100000;
		uint32_t pulsewidth_left = 150000 - (angle/90.0)*100000;
		uint32_t period = 2000000;
		MSS_TIM2_load_immediate(period);
	    MSS_TIM2_start();

	    while (MSS_TIM2_get_current_value() > 0) {

	    	if (MSS_TIM2_get_current_value() > (period - pulsewidth_right))
	    		MSS_GPIO_set_output( MSS_GPIO_0, 1);
	    	else
	    		MSS_GPIO_set_output( MSS_GPIO_0, 0);

	    	if (MSS_TIM2_get_current_value() > (period - pulsewidth_left))
                MSS_GPIO_set_output( MSS_GPIO_1, 1);
            else
                MSS_GPIO_set_output( MSS_GPIO_1, 0);
	    }
	}

	return 0;
}