Exemple #1
0
// to be called from systick
void Mdm_Worker()
{
	if (timer != 0) {
		timer --;
	}

	if (timer == 1) {
		if (Mdm_state == MDM_STATE_CMD) {
			LED_GREEN(LED_OFF);
			LED_YELLOW(LED_OFF);
			LED_RED(LED_OFF);

			// cmd timeout
			cmd_len = 0;
		} else if (Mdm_state == MDM_STATE_COMM) {
			// timeouted :(
			LED_YELLOW(LED_ON);

			// turn off receiver
			RFM_IdleMode();

			// turn off led in 'timeout'.
			timer = Mdm_CMDTimeout;
			Mdm_state = MDM_STATE_CMD;
		} else if (Mdm_state == MDM_STATE_ANALYZER) {
			// start sample
			ADC_start();
		}
	}
}
Exemple #2
0
void Mdm_AnalyzerStart(uint16_t s, uint16_t e, uint16_t d)
{
	a_delta = 1;
	a_freq = 96;
	a_stop = 3903;
	a_start = 96;

	if ((s >= 96) && (s < 3903)) {
		a_freq = s;
		a_start = s;
	}

	if ((e > 96) && (s <= 3903)) {
		a_stop = e;
	}

	a_delta = d;
	
	// set lowest possible frequency
	RFM_SetFreq(a_freq);

	// enable scan mode
	RFM_ScanMode();

	// enable ADC
	ADC_scan(1);

	timer = Mdm_SniffTimeout;

	LED_GREEN(LED_ON);
	LED_RED(LED_ON);
}
Exemple #3
0
void Mdm_RfmTxDoneCb()
{
	timer = Mdm_RXTimeout; 	

	LED_RED(LED_OFF);
	LED_GREEN(LED_ON);
}
Exemple #4
0
void GPIO_Configuration(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;

	// JTAG enabled in debug mode !!! (see also .gdbinit)
	if (DEBUG_ON != 1) {
		GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
	}

	// set PA[0-4] as analog inputs
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	// set LEDs
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	// pins to default state
	LED_RED(Bit_SET); // off
	LED_GREEN(Bit_SET); // off
	LED_YELLOW(Bit_SET); // off
}
Exemple #5
0
void Mdm_SniffStop()
{
	// disable sniff mode
	RFM_IdleMode();

	LED_GREEN(LED_OFF);
	LED_YELLOW(LED_OFF);
}
Exemple #6
0
void Mdm_SniffStart(uint8_t a)
{
	// enable sniff mode
	RFM_SniffMode(a);

	LED_GREEN(LED_ON);
	LED_YELLOW(LED_ON);
}
Exemple #7
0
void Mdm_AnalyzerStop()
{
	// disable ADC
	ADC_scan(0);

	// disable scan mode
	RFM_IdleMode();

	LED_GREEN(LED_OFF);
	LED_RED(LED_OFF);
}
Exemple #8
0
int main(void)
{
	// System Clocks Configuration
	RCC_Configuration();

	// NVIC configuration
	NVIC_Configuration();

	// Configure the GPIO ports
	GPIO_Configuration();

	__disable_irq();
	PWR_Init();
	CANController_Init();
	SPI1_Slave_Init();
	SYS_Init();

	LED_GREEN(Bit_RESET); // on
	__enable_irq();

	while (1) {
	}
}
Exemple #9
0
int main()
{
	CLEAR_WRITE();
	SET_STOPMOTOR();
	CLEAR_SCANMEDIA();
	CLEAR_MEDIASET();
	CLEAR_READY();
	
	//setup led and button gpio
    GPIO_SetMode(LED_G_PORT, LED_G_PIN, GPIO_PMD_OUTPUT);
    GPIO_SetMode(LED_R_PORT, LED_R_PIN, GPIO_PMD_OUTPUT);
    GPIO_SetMode(SWITCH_PORT, SWITCH_PIN, GPIO_PMD_INPUT);
    GPIO_SetMode(IRDATA_PORT, IRDATA_PIN, GPIO_PMD_INPUT);
	LED_GREEN(0);
	LED_RED(1);

	detect_board_version();

    /* Unlock protected registers */
    SYS_UnlockReg();

    SYS_Init();

    /* Lock protected registers */
    SYS_LockReg();

    UART0_Init();
	SPI_Init();

	TIMER_Open(TIMER0, TIMER_CONTINUOUS_MODE, 6000000);
	TIMER_Open(TIMER1, TIMER_PERIODIC_MODE, TRANSFER_RATE * 2);
	TIMER_Open(TIMER3, TIMER_PERIODIC_MODE, TRANSFER_RATE * 2);
	TIMER_EnableInt(TIMER1);
	TIMER_EnableInt(TIMER3);

	/* Open USB controller */
    USBD_Open(&gsInfo, HID_ClassRequest, NULL);

    /* Init Endpoint configuration for HID */
    HID_Init();

    /* Start USB device */
    USBD_Start();

    /* Enable USB device interrupt */
    NVIC_EnableIRQ(USBD_IRQn);

	LED_GREEN(1);
	LED_RED(0);
    printf("\n\nnuc123-fdsemu v%d.%02d build %d started.  Compiled on "__DATE__" at "__TIME__"\n",version / 100,version % 100,BUILDNUM);
    printf("--CPU @ %0.3f MHz\n", (double)SystemCoreClock / 1000000.0f);
    printf("--SPI0 @ %0.3f MHz\n", (double)SPI_GetBusClock(SPI0) / 1000000.0f);
    printf("--SPI1 @ %0.3f MHz\n", (double)SPI_GetBusClock(SPI1) / 1000000.0f);
    printf("--Detected board version: %d (config = %d %d %d)\n", boardver,PA12,PA13,PA14);
	
	NVIC_SetPriority(USBD_IRQn,2);
	NVIC_SetPriority(TMR1_IRQn,1);
	NVIC_SetPriority(TMR2_IRQn,0);
	NVIC_SetPriority(TMR3_IRQn,0);
	NVIC_SetPriority(GPAB_IRQn,0);
	NVIC_SetPriority(EINT0_IRQn,0);

	flash_init();
	sram_init();

	fds_init();

	print_block_info(0);
	while(1) {
		if(havepacket) {
			havepacket = 0;
//			process_send_feature(epdata,64);
		}
		console_tick();
		fds_tick();
	}
}
Exemple #10
0
int main(void)
{
	Init();

	DBG_MSG("----- Power On -----");

	if(USBDevice_PlugIn())
	{
		DBG_MSG( "Usb Init Started");
		USB_Init();
	}else{
		DBG_MSG("FileSystem_Init");
		FileSystem_Init();
		fileTest();
	}

	while(true);//Stop here

	char color[] = {0xff, 0xff, 0x00};
	WS2812_Set(0, 3, color);
	color[0] = 0x00;
	color[2] = 0xff;
	WS2812_Set(3, 3, color);
	color[0] = 0xff;
	color[1] = 0x00;
	WS2812_Set(6, 3, color);

	LED_RED(true);
	Delay_ms(200);
	LED_GREEN(true);
	Delay_ms(200);
	LED_BLUE(true);
	

	DBG_MSG("Temperature: %f", TMP102_GetTemp());
	DBG_MSG("Temperature: %f", TMP102_GetTemp());

	// WavePlayer_Init();
	// WavePlayerMenu_Start("/", "teq.wav");
	// WavePlayer_Start();

	// Reflective_Start();

	// Analog_SetChannel(PHOTOTRANS_1_CH, true);
	// Analog_SetChannel(PHOTOTRANS_2_CH, true);
	// Analog_SetChannel(PHOTOTRANS_3_CH, true);
	// Analog_SetChannel(PHOTOTRANS_4_CH, true);
	// Analog_SetChannel(PHOTOTRANS_5_CH, true);

	Delay_ms(2000);

	MPU9250_InitProcedure();

	SysTick_t tick = 0;
	while(true) {
		float accel[3], gyro[3], mag[3];
		float yaw, pitch, roll;


		if(GetSystemTick() - tick > 1000){
			if(MPU9250_CheckNewSample()){
				MPU9250_Get9AxisData(accel, gyro, mag);
				MPU9250_CalcOrientation(&yaw, &pitch, &roll);
			}
			DBG_MSG("Temperature: %f", TMP102_GetTemp());

			// DBG_MSG("ADC: %d %d %d %d %d",
			// 	Analog_GetChannelValue(PHOTOTRANS_1_CH),
			// 	Analog_GetChannelValue(PHOTOTRANS_2_CH),
			// 	Analog_GetChannelValue(PHOTOTRANS_3_CH),
			// 	Analog_GetChannelValue(PHOTOTRANS_4_CH),
			// 	Analog_GetChannelValue(PHOTOTRANS_5_CH)
			// );
			for (int i = 0; i < 3; ++i)
			{
				DBG_MSG("MPU-Accel-%c: %f", i+'X', accel[i]);
			}
			for (int i = 0; i < 3; ++i)
			{
				DBG_MSG("MPU-Gyro-%c: %f", i+'X', gyro[i]);
			}
			for (int i = 0; i < 3; ++i)
			{
				DBG_MSG("MPU-Mag-%c: %f", i+'X', mag[i]);
			}
			DBG_MSG("MPU-Temp: %f", MPU9250_GetTemperature());
			DBG_MSG("yaw: %f, pitch: %f, roll: %f", yaw, pitch, roll);
			tick = GetSystemTick();
		}
	}
}