void Mdm_RfmTxDoneCb() { timer = Mdm_RXTimeout; LED_RED(LED_OFF); LED_GREEN(LED_ON); }
// 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(); } } }
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); }
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 }
void updateLeds() { usbShowStatusWithGreenLed(); LED_YELLOW(0); // Turn on the red LED if we are sending a burst. LED_RED((uint16)(packetsSent < 100)); }
void updateLeds() { usbShowStatusWithGreenLed(); //LED_YELLOW_TOGGLE(); //LED_YELLOW(1); LED_RED(0); }
void Mdm_AnalyzerStop() { // disable ADC ADC_scan(0); // disable scan mode RFM_IdleMode(); LED_GREEN(LED_OFF); LED_RED(LED_OFF); }
void updateLeds() { usbShowStatusWithGreenLed(); // NOTE: The code below is bad because it is reading two bytes of timeMs, // and the interrupt that updates timeMs could fire between those two reads. if (blinkYellow) { uint32 time = getMs(); if (time >= nextToggle) { LED_YELLOW_TOGGLE(); nextToggle = time + randomNumber(); } } else { LED_YELLOW(1); } LED_RED(0); }
/** Functions *****************************************************************/ void updateLeds() { LED_GREEN_TOGGLE(); //Die gruene LED blinkt bei Daten LED_YELLOW(ACM_CONTROL_LINE_DTR); //Funktioniert nicht so wie gedacht LED_RED(0); //Ist einfach aus }
/** Functions *****************************************************************/ void updateLeds() { usbShowStatusWithGreenLed(); LED_YELLOW(usbComRxControlSignals() & ACM_CONTROL_LINE_DTR); LED_RED(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(); } }
void updateLeds() { static BIT dimYellowLed = 0; static uint16 lastRadioActivityTime; uint16 now; usbShowStatusWithGreenLed(); now = (uint16)getMs(); if (currentSerialMode == SERIAL_MODE_USB_SPI) { // The radio is not being used, so turn off the yellow LED. LED_YELLOW(0); } else if (!radioLinkConnected()) { // We have not connected to another device wirelessly yet, so do a // 50% blink with a period of 1024 ms. LED_YELLOW(now & 0x200 ? 1 : 0); } else { // We have connected. if ((now & 0x3FF) <= 20) { // Do a heartbeat every 1024ms for 21ms. LED_YELLOW(1); } else if (dimYellowLed) { static uint8 DATA count; count++; LED_YELLOW((count & 0x7)==0); } else { LED_YELLOW(0); } } if (radioLinkActivityOccurred) { radioLinkActivityOccurred = 0; dimYellowLed ^= 1; //dimYellowLed = 1; lastRadioActivityTime = now; } if ((uint16)(now - lastRadioActivityTime) > 32) { dimYellowLed = 0; } if ((uint8)(now - lastErrorTime) > 100) { errorOccurredRecently = 0; } LED_RED(errorOccurredRecently || uartRxDisabled); }
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(); } } }
void updateLeds() { usbShowStatusWithGreenLed(); LED_YELLOW(0); LED_RED(0); }
void updateLeds() { usbShowStatusWithGreenLed(); LED_RED(serialProtocolError); }