コード例 #1
0
ファイル: boxcar.c プロジェクト: karlp/karlnet
int main(void)
{
	clock_setup();
	gpio_setup();
	systick_setup();
	adc_off(ADC1);
	usart_enable_all_pins();
	usart_console_setup();
	printf("hello!\n");
	// power up the RHT chip...
	dht_power(true);
	delay_ms(2000);
	setup_tim7();
	platform_simrf_init();
	// interrupt pin from mrf
	platform_mrf_interrupt_enable();

	simrf_soft_reset();
	simrf_init();
	simrf_immediate_sleep();

	simrf_pan_write(0xcafe);
	uint16_t pan_sanity_check = simrf_pan_read();
	printf("pan read back in as %#x\n", pan_sanity_check);
	simrf_address16_write(0x1111);

	adc_power_on(ADC1);
	adc_reset_calibration(ADC1);
	adc_calibration(ADC1);

	jack_setup(&jack1, &state.jack_machine1);
	jack_setup(&jack2, &state.jack_machine2);

	//state.rf_dest_id = 0x4202;
	state.rf_dest_id = 0x1;

	while (1) {
		struct jacks_result_t jr1, jr2;
		simrf_check_flags(NULL, &handle_tx);
		loop_forever();
		jack_run_task(&state.jack_machine1, &jr1);
		if (jr1.ready) {
			printf("Channel 1 result: %d\n", jr1.value);
		}
		jack_run_task(&state.jack_machine2, &jr2);
		if (jr2.ready) {
			printf("Channel 2 result: %d\n", jr2.value);
		}
		task_send_data(&state);
		__WFI();
	}

	return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: BuFran/libopencm3-examples
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();
	printf("hi guys!\n");
	setup_buttons();
	setup_tim6();
	setup_tim7();
	while (1) {
		;
	}

	return 0;
}
コード例 #3
0
ファイル: boxcar.c プロジェクト: karlp/karlnet
void start_rht_read(void)
{
	// First, move the pins up and down to get it going...
	gpio_set_mode(PORT_RHT_IO, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, PIN_RHT_IO);
	gpio_clear(PORT_RHT_IO, PIN_RHT_IO);
	delay_ms(20); // docs say 1-10ms is enough....
	gpio_set(PORT_RHT_IO, PIN_RHT_IO);
	// want to wait for 40us here, but we're ok with letting some code delay us..
	state.bitcount = 0;
	state.seen_startbit = false;
	state.rht_timeout = false;
	nvic_enable_irq(RHT_NVIC);
	// pull up will finish the job here for us.
	gpio_set_mode(PORT_RHT_IO, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, PIN_RHT_IO);
	exti_select_source(RHT_EXTI, PORT_RHT_IO);
	exti_set_trigger(RHT_EXTI, EXTI_TRIGGER_FALLING);
	exti_enable_request(RHT_EXTI);
	setup_tim7();
}