/* initialize the IO subsystems for the appropriate dongles */ static void io_init(void) { #ifdef IMME #ifdef IMMEDONGLE // CC1110 on IMME pink dongle // IM-ME Dongle. It's a CC1110, so no USB stuffs. Still, a bit of stuff to init for talking // to it's own Cypress USB chip P0SEL |= (BIT5 | BIT3); // Select SCK and MOSI as SPI P0DIR |= BIT4 | BIT6; // SSEL and LED as output P0 &= ~(BIT4 | BIT2); // Drive SSEL and MISO low P1IF = 0; // clear P1 interrupt flag IEN2 |= IEN2_P1IE; // enable P1 interrupt P1IEN |= BIT1; // enable interrupt for P1.1 P1DIR |= BIT0; // P1.0 as output, attention line to cypress P1 &= ~BIT0; // not ready to receive #else // full blown IMME with screen and keyboard //Disable WDT IEN2&=~IEN2_WDTIE; IEN0&=~EA; setIOPorts(); configureSPI(); LCDReset(); //Startup display. setDisplayStart(0); SSN = LOW; setNormalReverse(0); erasescreen(); drawstr(0,0, "IMME SNIFF v0.1"); SSN = HIGH; //immeLCDInitScreen(); //sleepMillis(100); #endif #else // CC1111 #ifdef DONSDONGLES // CC1111 USB Dongle // turn on LED and BUTTON P1DIR |= 3; // Activate BUTTON - Do we need this? //CC1111EM_BUTTON = 1; #else // CC1111 USB (ala Chronos watch dongle), we just need LED P1DIR |= 3; #endif // CC1111 #ifndef VIRTUAL_COM // Turn off LED LED = 0; #endif #endif // conditional }
void main(void) { //Disable WDT IEN2&=~IEN2_WDTIE; IEN0&=~EA; xtalClock(); // fastest speed setIOPorts(); configureSPI(); LCDReset(); setDisplayStart(0); //Start the game right-off. zombiegotcha(); }
int main(void) { int i; xtalClock(); setIOPorts(); configureSPI(); LCDReset(); clear(); SSN = LOW; for (i = 0; i < 8; i++) { setCursor(i, i*8); printf("KEEP HACKING"); } SSN = HIGH; while (1); }
void decodeUsbPacket(uint8_t* pui8PacketBuffer, uint32_t ui32PacketSize) { switch (pui8PacketBuffer[0]) { //---------------Configuration--------------------- case CONFIGURE_SPI: configureSPI(&pui8PacketBuffer[1]); break; case CONFIGURE_RF: configureRF(&pui8PacketBuffer[1]); break; case CONFIGURE_RF_TX_ADDRESS: configureRFTxAddress(&pui8PacketBuffer[1]); break; //------------------Robot Communication------------------ case TRANSMIT_DATA_TO_ROBOT: transmitMessageToRobot(pui8PacketBuffer, false); break; case TRANSMIT_DATA_TO_ROBOT_ACK: transmitMessageToRobot(pui8PacketBuffer, true); break; case RECEIVE_DATA_FROM_ROBOT: receiveDataFromRobot(pui8PacketBuffer, false); break; case RECEIVE_DATA_FROM_ROBOT_COMMAND: receiveDataFromRobot(pui8PacketBuffer, true); break; default: // signalUnhandleError(); break; } }
int main(void) { //set up systick SysTick_Config(SystemCoreClock / 1000); configureSPI(); configureGPIO(); // uint16_t thispin = 0x00; // uint8_t up = 0x01; while(1) { // thispin = 0x0100; // while (thispin != 0x0000) { // if(up&0x01) // { // GPIO_SetBits(GPIOE, thispin); // thispin = thispin << 1; // } else { // GPIO_ResetBits(GPIOE, thispin); // thispin = thispin << 1; // } // delay(100); // } // // up ^= 0x01; GPIO_SetBits(GPIOA, GPIO_Pin_4); SPI_I2S_SendData16(SPI1, 0xA5); while(!SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE)); while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY)); GPIO_ResetBits(GPIOA, GPIO_Pin_4); GPIOE->ODR ^= 0xFF00; delay(100); } }
void main(void) { bit test_radio = 0; bit bounce_radio = 0; /* Initialize app modules. Not reinitialized upon reset. */ message_init(); compose_init(); inbox_init(); info_init(); reset: sleepy_ = 0; state_ = STATE_VIEW; if (bounce_radio) { repeater_mode(); } /* Initialize system modules. */ clock_init(); setIOPorts(); configureSPI(); LCDReset(); radio_init(); random_init(); inbox_draw(); if (test_radio) { run_test_radio(); } /* Main loop. */ radio_listen(); while (1) { poll_keyboard(); /* Send and receive messages. */ message_tick(); /* Handle background tasks (like progress bar) */ if (compose_tick() && state_ == STATE_COMPOSE) { compose_draw(); } if (info_tick() && state_ == STATE_INFO) { info_draw(); } /* go to sleep (more or less a shutdown) if power button pressed */ if (sleepy_) { clear(); clock_delayms(1000); SSN = LOW; LCDPowerSave(); SSN = HIGH; sleep(); /* reset on wake */ goto reset; } } }
//=====================================System Initializations========================================// void _init (void){ int i; DWORD res = 0; //-------------------------------------General System--------------------------------------------// SimpleUart(0,SystemBaud);assign_stdio(0); // Serial port 0 for Data SimpleUart(1,SystemBaud); // Serial port 1 for Debug EnableSmartTraps(); #ifdef _DEBUG InitGDBStubNoBreak( 1, 115200 ); #endif OSChangePrio(MAIN_PRIO); //Other EnableSerialUpdate(); iprintf("\n\n\n\n\n\n\n\nINITIALIZATION\n"); putleds(8); iprintf("Version Number --> %s\n", ftos(versionNo, 3)); createVERIFY_KEY(); // Using versionNo to update Flash DDBB //--------------------------------------I2C Bus Connection---------------------------------------// I2CInit(MCF5213_I2C_ADDRESS, I2C_FREQUENCY); // Initialize I2C with Predefined Address (0x20) // Set frequency division to 768 (66Mhz CF clock --> 88,25 Khz I2C bus) iprintf(" .Initialized I2C address for MCF5213: 0x%x\r\n",MCF5213_I2C_ADDRESS); iprintf(" -Set I2C Frequency division: %x (MCF internal CLK / 1280)\r\n",I2C_FREQUENCY); //-------------------------------------SPI Bus Connection----------------------------------------// res=true; for (i = 0; i<PSU_NUMBER; i++){ res &=configureSPI( INIT_SPI_ORDER, INIT_SPI_CPOL, INIT_SPI_CPHA, INIT_SPI_CLKRATE, i2CtoSPIAddress[i]); } if(res==I2C_OK){iprintf(" .SPI bus configured\r\n");} else{iprintf(" .SPI configuration ERROR - Coudn't be configured\r\n");} //-----------------------------------RDACs with minimum value------------------------------------// res = 0; for (i = 0; i<PSU_NUMBER; i++){ setValRDAC(INITIAL_VOLTAGE, (i&0x1?UPPER_SLAVE_SPI_ADDRESS:LOWER_SLAVE_SPI_ADDRESS), i2CtoSPIAddress[i]); res |= getI2CResultRDAC(); } if(res==I2C_OK){iprintf(" .RDACs set to minimum value\r\n");} else{iprintf(" .RDAC setting ERROR - Couldn't be set to minimum value\r\n");} //----------------------------------------DataLists----------------------------------------------// initializeValuesPSUsSnIs(); // Load psuList values from RAM or set them to default for (i = 0; i<PSU_NUMBER; i++){ // Start all PSU objects in OFF status, regardless of the loaded status psuList[i].relayStatus = OFF; psuList[i].psuStatus = OFF; psuList[i].ReadyToConnect = false; } //-------------------------------------------GPIO------------------------------------------------// RESET_RHEOSTATS.function( PIN21_GPIO ); // RDAC Reset LED_OUT_ON.function( PIN7_GPIO ); // LED OUT iprintf(" .Pin 21 (TIN3) set as GPIO for RDAC Reset\r\n"); iprintf(" .Pin 7 (IRQ4) set as GPIO for LED OUT\r\n"); //----------------------------------Analog to Digital Converter----------------------------------// Pins[13].function( PIN13_AN0 ); // Configure the A2D pin nº13 as analog input EnableAD(); initMUX(); // Initializes all the Pins used for Mux control res=configureSPI( INIT_SPI_ORDER, INIT_SPI_CPOL, INIT_SPI_CPHA, INIT_SPI_CLKRATE, AGC_I2C_ADDRESS); minAGC(); // Initializes the AGC with minimum gain res = (getI2CResultAGC()==I2C_OK); if(res){iprintf(" .ADC initialized\r\n");} else{iprintf(" .ADC initialization ERROR\r\n");} //--------------------------------------Button Interruption--------------------------------------// SetUpIRQ1(); iprintf(" .Button Interruption Set\r\n"); //---------------------------------------TimerInterruptions--------------------------------------// //SetUpPITR(0, 8294, 1); //Use PITR 0, Wait 8294 clocks, Divide by 2 from table 17-3, 2KHz - NOT IN USE, messes with RTOS Tasks. Best left unused SetUpPITR(1, 16588, 1); // Use PITR 1, Wait 16588 clocks, Divide by 2 from table 17-3, 1KHz - Interrupt in charge of A2D sampling iprintf(" .Timers initialized\r\n"); //----------------------------------------- RTOS Tasks-------------------------------------------// OSSimpleTaskCreate( alarmTask, ALARM_PRIO ); iprintf(" .alarmTask initialized\r\n"); iprintf(" .MonitorSem %s\n", (allSemInit()==OS_NO_ERR?"Initialized CORRECTLY":"Initialization ERROR")); OSSimpleTaskCreate( monitorTask, MONITOR_PRIO ); iprintf(" .monitorTask initialized\r\n"); iprintf("APPLICATION INITIALIZED\n\nPress one key to begin \n\n"); WAIT_FOR_KEYBOARD putleds(0); }
void main(void) { u16 i; pktbuf = radio_getbuf(); ch = 0; reset: centerFreq = DEFAULT_FREQ; userFreq = centerFreq; sleepy = 0; packetDone = 0; xtalClock(); setIOPorts(); configureSPI(); LCDReset(); radio_init(); clear(); printDebugHeader(); setFrequency(centerFreq); printDebugFrequency(centerFreq, ch); while (1) { poll_keyboard(); pollPacket(); /* Show current RSSI */ SSN = LOW; setCursor(5, 78); printf("%3u", (RSSI ^ 0x80)); SSN = HIGH; /* TODO Mod this when more than one channel */ if (userFreq != centerFreq) { centerFreq = setFrequency(userFreq); chan_table[ch].ss = 0; chan_table[ch].max = 0; printDebugFrequency(centerFreq, ch); } /* Go to sleep (more or less a shutdown) if power button pressed */ if (sleepy) { clear(); sleepMillis(1000); SSN = LOW; LCDPowerSave(); SSN = HIGH; while (1) { sleep(); /* Power button depressed long enough to wake? */ sleepy = 0; for (i = 0; i < DEBOUNCE_COUNT; i++) { sleepMillis(DEBOUNCE_PERIOD); if (keyscan() != KPWR) sleepy = 1; } if (!sleepy) break; } /* Reset on wake */ goto reset; } } }