int main (void) { SysCtlClockSet (SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ); configureUART (); printf ("cpu-gauge.\r\n"); // Enable the GPIO port that is used for the on-board LED. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); // // USB config : Enable the GPIO peripheral used for USB, and configure the USB pins. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD); // GPIOPinTypeUSBAnalog(GPIO_PORTD_AHB_BASE, GPIO_PIN_4 | GPIO_PIN_5); // ButtonsInit(); // printf ("Buttons OK.\r\n"); motorInit (); printf ("Motor initialized.\r\n"); printf ("Test sequence : +40 steps.\r\n"); motorRun (40); printf ("Test sequence : -40 steps.\r\n"); motorRun (-40); printf ("Test sequence : OK.\r\n"); SysCtlDelay (DELAY_COEFFICIENT_SCD / 10); uint8_t ui8ButtonsChanged, ui8Buttons; while (1) { ButtonsPoll(&ui8ButtonsChanged, &ui8Buttons); if (ui8ButtonsChanged) { if(ui8Buttons & LEFT_BUTTON) { printf ("pressed\r\n"); } else { printf ("released\r\n"); } } } }
int main(void) { uint8_t cmdBuf[128]; uint8_t i; // Init peripherals. // Clock is set to 32MHz. clockInit(); // This UART is connected to the UC3 device and provides connectivity // via USB. uartInit(&UARTC0, 8); // 115,200 BAUD // This UART will be connected to the RadioBlocks device. uartInit(&UARTF0, 8); // 115,200 BAUD // Init the globals. isrLen = 0; cmdLen = 0; cmdFlag = 0; testCmd = 0; wakeCmd = 0; isrCmd = 0; ackStatus = 0; // Fun! ledFlag = 0; // These are used to help in debug. Used to print strings // to USARTC0 which is connected to the xplained-a1 usb // port through the on-board UC3. userEnd = 0; userStart = 0; // DEBUG - Create delay timer. //startTimer(1000); // One millisecond test. // Configure PORTA as output to measure delay timer... // These pins are on Xplained header J2 PORT_SetPinsAsOutput( &PORTA, 0xFF ); // Use one of the Xplained-A1 pins. SW4 - PD4 PORT_SetPinsAsInput( &PORTD, 0x10 ); // Check UART operation //testUartTx(); // Enable global interrupts. sei(); // Create a function pointer to use with the user uart (UARTC0). void (*puartBuf)(uint8_t* , uint8_t); // Assign that function pointer to the send data to RadioBlocks. puartBuf = &sendUARTF0; /////////////////////// TEST CODE ////////////////// #if 0 for(uint16_t i=0; i<CIRCSIZE; i++) sniffBuff[i] = 255; toggleLed(puartBuf, LED_TOGGLE, uartBuf); testRequest(puartBuf, uartBuf); setAddress(puartBuf, 0x1234, uartBuf); getAddress(puartBuf, uartBuf); sleepRequest(puartBuf, 1000, uartBuf); settingsRequest(puartBuf, uartBuf, RESTORE_CURRENT_SETTINGS); configureUART(puartBuf, DATA_BITS_8, PARITY_NONE, STOP_BITS_1, BAUD_115200, uartBuf); setPanid(puartBuf, 0x5678, uartBuf); getPanid(puartBuf, uartBuf); setChannel(puartBuf, CHANNEL_16, uartBuf); getChannel(puartBuf,uartBuf); setTRXState(puartBuf, TX_ON, uartBuf); getTRXState(puartBuf, uartBuf); dataRequest(puartBuf, 0x0001, DATA_OPTION_NONE, 0x42, 6, testBuf, uartBuf); setTxPower(puartBuf, TX_POWER_2_8_DBM, uartBuf); getTxPower(puartBuf, uartBuf); //setSecurityKey(puartBuf, uint8_t* key, uartBuf); // max 16 bytes. #endif toggleLed(puartBuf, LED_TOGGLE, uartBuf); processResponse(); usartUartPrint(); testRequest(puartBuf, uartBuf); processResponse(); usartUartPrint(); processResponse(); usartUartPrint(); setAddress(puartBuf, 0x1234, uartBuf); processResponse(); usartUartPrint(); getAddress(puartBuf, uartBuf); processResponse(); usartUartPrint(); processResponse(); usartUartPrint(); setPanid(puartBuf, 0x5678, uartBuf); processResponse(); usartUartPrint(); getPanid(puartBuf, uartBuf); processResponse(); usartUartPrint(); processResponse(); usartUartPrint(); setChannel(puartBuf, CHANNEL_16, uartBuf); processResponse(); usartUartPrint(); getChannel(puartBuf,uartBuf); processResponse(); usartUartPrint(); processResponse(); usartUartPrint(); // setTRXState(puartBuf, TX_ON, uartBuf); // processResponse(); // getTRXState(puartBuf, uartBuf); // processResponse(); // processResponse(); setTxPower(puartBuf, TX_POWER_2_8_DBM, uartBuf); processResponse(); usartUartPrint(); getTxPower(puartBuf, uartBuf); processResponse(); usartUartPrint(); processResponse(); usartUartPrint(); dataRequest(puartBuf, 0x0001, DATA_OPTION_NONE, 0x42, 6, testBuf, uartBuf); processResponse(); usartUartPrint(); setTRXState(puartBuf, RX_ON, uartBuf); processResponse(); usartUartPrint(); getTRXState(puartBuf, uartBuf); processResponse(); usartUartPrint(); processResponse(); usartUartPrint(); while(1) { processResponse(); usartUartPrint(); // Fun. // toggleLed(puartBuf, LED_TOGGLE, uartBuf); // timerLoop(100); // WARNING, can BLOCK a loooong time. // processResponse(); // testBuf[5]++; // setTRXState(puartBuf, TX_ON, uartBuf); // processResponse(); // dataRequest(puartBuf, 0x0001, DATA_OPTION_NONE, 0x42, 6, testBuf, uartBuf); // processResponse(); // setTRXState(puartBuf, RX_ON, uartBuf); // processResponse(); /* USER CODE HERE! */ } }
//***************************************************************************** //***************************************************************************** int main(void) { //char posArray[40]; PLL_Init(); initPollingUART0(); //initPollingUART1(); UART0_TxPoll("\n\r\n\r\n\r*****Chiposizer V.9****"); UART0_TxPoll("\n\rInitializing GPIO Ports..."); initGPIOPorts(); UART0_TxPoll("\n\rInitializing PWM Modules..."); initPWM(); UART0_TxPoll("\n\rInitializing Timers..."); initTimers(); UART0_TxPoll("\n\rInitializing Effects..."); initPremadeEffects(); UART0_TxPoll("\n\rInitializing Channels..."); initChannels(); setCurrentChannel(ch5); UART0_TxPoll("\n\rEntering Main Loop"); recordLoopNum = 0; configureUART(); while(1){ if (checkMsgs(myMsgBuffer)){ handleLCDinput(myMsgBuffer[2], myMsgBuffer[4], currentCh->note->effects); } if (alertEffect) { alertEffect = false; updateAllEffects(); } if (alertScan) { alertScan = false; /*if (recordLoopNum < 1000) { recordLoopNum++; } else if (!recordLoop) { recordLoop = true; cur = testList.head; UART0_TxPoll("\n\rBegin Record Loop"); } if (!recordLoop) { keyNumber = scanMatrix(scanningMatrix); keyNumberPtr = malloc(sizeof(int8_t)); *keyNumberPtr = keyNumber; add(&testList, keyNumberPtr); } else { keyNumber = *((int8_t*) cur->data); if (cur == testList.tail) { cur = testList.head; } else { cur = cur->next; } }*/ keyNumber = scanMatrix(scanningMatrix); updateKey(currentCh->note, keyNumber); //printMatrix(scanningMatrix); } updateAllTuningWords(); } };
int main(){ unsigned long ulClockMS=0; // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // MAP_FPUEnable(); MAP_FPULazyStackingEnable(); // // Set the clocking to run directly from the crystal. // MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); MAP_IntMasterDisable(); configureQEI(); configurePWM(); /*leftmotor_pid.setMaxOutput(255); leftmotor_pid.setMinOutput(-255); leftmotor_pid.setGains(12.0,5.0,0.0); leftmotor_pid.setSampleTime(1.0/QEILOOPFREQUENCY);*/ leftmotor_pid.setInputLimits(-100,100); leftmotor_pid.setOutputLimits(-255,255); leftmotor_pid.setBias(0.0); leftmotor_pid.setMode(AUTO_MODE); configureUART(); MAP_IntMasterEnable(); // Get the current processor clock frequency. ulClockMS = MAP_SysCtlClockGet() / (3 * 1000); int char_counter=0; char inputbuffer[10]; while(1){ inputbuffer[char_counter]=UARTgetc(); char_counter++; if (char_counter==3){ inputbuffer[3]=0; goal_vel=atoi(inputbuffer); char_counter=0; } //uint32_t pos = MAP_QEIPositionGet(QEI1_BASE); /*uint32_t vel = MAP_QEIVelocityGet(QEI1_BASE); //UARTprintf("pos : %u \n",pos);QEIDirectionGet(QEI1_BASE)*/ /*UARTprintf("vel : %d pwm %d\n",vel,pwm_value); MAP_SysCtlDelay(ulClockMS*50);*/ } return 0; }