void main() { uint32 f; /* frequency in hz */ f = 200; systemInit(); usbInit(); /* PWM duty cycle */ T1CC1L = 0x40; T1CC1H = 0x00; /* setup Timer 1, alt location 2 and prescaler 128*/ t1Init(IO_LOC_ALT_2, PRESCALER_128); /* setup Channel 1, compare mode, clear on compare up and peripheral*/ t1ChannelInit(CHANNEL1, COMPARE_MODE, CLR_ON_COMP_UP, PERIPHERAL); /* start Timer 1 by setting it's mode to modulo */ t1Mode(MODE_MODULO); /* set Timer 1 frequency */ setT1Frequency(f); while(1) { boardService(); updateLeds(); usbComService(); } }
/** Configures the USB and radio communication then calls the processBytesFromUsb and * processBytesFromRadio functions. **/ void main() { // required by wixel api: // http://pololu.github.io/wixel-sdk/group__libraries.html systemInit(); usbInit(); radioLinkInit(); // wait for a wireless pairing // between two wixels // blink yellow LED while connection is being established while(!radioLinkConnected()) { yellowLedOn ^= 1; updateLeds(); delayMs(DELAY_MS); } // turn off LED yellowLedOn = 0; // process bytes while(1) { boardService(); updateLeds(); usbComService(); processBytesFromUsb(); processBytesFromRadio(); } }
void main() { uint32 last_ms; systemInit(); //configure the P1_2 and P1_3 IO pins makeAllOutputs(LOW); //initialise Anlogue Input 0 P0INP = 0x1; //initialise the USB port usbInit(); usbComRequestLineStateChangeNotification(LineStateChangeCallback); last_ms = getMs(); while (1) { boardService(); usbComService(); if((getMs()-last_ms) >=5000){ LED_YELLOW_TOGGLE(); printf("batteryPercent: %i\r\n", batteryPercent(adcRead(0 | ADC_REFERENCE_INTERNAL))); last_ms=getMs(); } } }
void main() { systemInit(); usbInit(); while(1) { boardService(); updateLeds(); usbComService(); processBytesFromUsb(); } }
void main() { systemInit(); usbInit(); perTestTxInit(); while(1) { boardService(); updateLeds(); usbComService(); sendRadioBursts(); } }
void main() { systemInit(); //Among other things, allocates byte arrays for sending commands. dynamixel_init(); // Oooh. what's this? setDigitalOutput(param_arduino_DTR_pin, LOW); ioTxSignals(0); //usbInit(); uart1Init(); uart1SetBaudRate(param_baud_rate); // Initial setting of serial mode updateSerialMode(); // Set up P1_5 to be the radio's TX debug signal. // P1DIR |= (1<<5); // IOCFG0 = 0b011011; // P1_5 = PA_PD (TX mode) // P1DIR |= 0x20; //Enable pin P1_5 while(1) { uint32 ms; uint16 now; uint16 speed; updateSerialMode(); boardService(); updateLeds(); errorService(); // Code for oscillating a servo back and forth ms = getMs(); // Get current time in ms now = ms % (uint32)10000; // 10 sec for a full swing if(now >= (uint16)5000){ // Goes from 0ms...5000ms now = (uint16)10000 - now; // then 5000ms...0ms } speed = interpolate(now, 0, 5000, 100, 900); // speed is really the position. ax12SetGOAL_POSITION(32, speed); delayMs(30); } }
void main() { systemInit(); usbInit(); analogInputsInit(); while(1) { boardService(); updateLeds(); usbComService(); sendReportIfNeeded(); } }
void main() { systemInit(); usbInit(); setup_DS1820(); while(1) { boardService(); updateLeds(); usbComService(); handleOneWire(); } }
void main() { systemInit(); usbInit(); usbComLineCodingChangeHandler = &lineCodingChanged; uart1Init(); lineCodingChanged(); while(1) { boardService(); updateLeds(); usbComService(); usbToUartService(); } }
void main(void) { systemInit(); radioQueueInit(); //Empfaenger initialisieren radioQueueAllowCrcErrors = 1; //Fehlerhafte Pakete zulassen uart1Init(); //Serielle Schnittstelle initialisieren lineCodingChanged(); //Einstellen der Schnittstellen Eigenschaft while(1) { updateLeds(); //Status der LEDs veraendern boardService(); usbComService(); radioToUart1Service(); //Empfangen der Daten } }
void main() { systemInit(); setDigitalOutput(param_arduino_DTR_pin, LOW); ioTxSignals(0); usbInit(); uart1Init(); uart1SetBaudRate(param_baud_rate); if (param_serial_mode != SERIAL_MODE_USB_UART) { radioComRxEnforceOrdering = 1; radioComInit(); } // Set up P1_5 to be the radio's TX debug signal. P1DIR |= (1<<5); IOCFG0 = 0b011011; // P1_5 = PA_PD (TX mode) while(1) { updateSerialMode(); boardService(); updateLeds(); errorService(); /* toggle_led();*/ if (param_serial_mode != SERIAL_MODE_USB_UART) { radioComTxService(); } usbComService(); switch(currentSerialMode) { case SERIAL_MODE_USB_RADIO: usbToRadioService(); break; case SERIAL_MODE_UART_RADIO: uartToRadioService(); break; case SERIAL_MODE_USB_UART: usbToUartService(); break; } } }
void main() { int8 SPI_SEND = 0; int8 prev_send = 0; systemInit(); setDigitalOutput(param_arduino_DTR_pin, LOW); ioTxSignals(0); usbInit(); spi0MasterInit(); spi0MasterSetFrequency(38400); // uart1Init(); // uart1SetBaudRate(param_baud_rate); if (param_serial_mode != SERIAL_MODE_USB_SPI) { radioComRxEnforceOrdering = 1; radioComInit(); } // Set up P1_5 to be the radio's TX debug signal. //P1DIR |= (1<<5); //IOCFG0 = 0b011011; // P1_5 = PA_PD (TX mode) while(1) { updateSerialMode(); boardService(); updateLeds(); //errorService(); if(!spi0MasterBusy() && SPI_SEND != prev_send){ spi0MasterSendByte(SPI_SEND); prev_send = SPI_SEND; } if (param_serial_mode != SERIAL_MODE_USB_SPI) { radioComTxService(); } usbComService(); // switch(currentSerialMode) // { // case SERIAL_MODE_USB_RADIO: usbToRadioService(); break; // case SERIAL_MODE_SPI_RADIO: uartToRadioService(); break; // case SERIAL_MODE_USB_SPI: usbToUartService(); break; // } switch(usbComRxReceiveByte()){ case 0: // STOP SPI_SEND += 15; SPI_SEND = (SPI_SEND%255); break; case 1: // Initialize SPI_SEND -= 15; SPI_SEND = (SPI_SEND%255); break; } } }
void main() { // uint32 ms; // uint32 now; // uint8 cmdrAlive = 0; // Here we define what pins we will be using for PWM. // uint8 CODE pwmPins[] = {ptrGunMotor->pwmpin}; uint8 CODE pwmPins[] = {11}; MOTOR gunMotor = MAKE_MOTOR_3_PIN(pwmPins[0], 12, 13); //(PWM, B, A) MOTOR *ptrGunMotor = &gunMotor; // setDigitalOutput(param_arduino_DTR_pin, LOW); // ioTxSignals(0); // Initialize UARTs uart0Init(); uart0SetBaudRate(param_baud_rate_UART); uart1Init(); uart1SetBaudRate(param_baud_rate_XBEE); pwmStart((uint8 XDATA *)pwmPins, sizeof(pwmPins), 10000); guns_firing_duration = 125; // time in ms gunbutton = zFALSE; solenoid_on_duration = 80; // time in ms solenoidbutton = zFALSE; laserbutton = zFALSE; systemInit(); // Initialize other stuff index_cmdr = -1; /// MAIN LOOP /// while(1) { // updateSerialMode(); boardService(); updateLeds(); errorService(); // cmdr counts down from CMDR_ALIVE_CNT by -1 whenever no packets are received? cmdrAlive = (uint8) CLAMP(cmdrAlive + CmdrReadMsgs(), 0, CMDR_ALIVE_CNT); // ms = getMs(); // Get current time in ms // now = getMs(); // now = ms % (uint32)10000; // 10 sec for a full swing // if(now >= (uint16)5000){ // Goes from 0ms...5000ms // now = (uint16)10000 - now; // then 5000ms...0ms // } // speed = interpolate(now, 0, 5000, 100, 900); if (laserbutton == zTRUE && cmdrAlive > 0){ // uart0TxSendByte('L'); setDigitalOutput(param_laser_pin, HIGH); } else {setDigitalOutput(param_laser_pin, LOW);} //FIRE THE GUNS!!!!! //Resets timer while gunbutton is held down. if (gunbutton == zTRUE){ // uart0TxSendByte('Z'); guns_firing = zTRUE; setMotorSpeed(ptrGunMotor, -60); //NOTE: (7.2 / 12.6) * 127 = 72.5714286 guns_firing_start_time = getMs(); } //Check whether to stop firing guns if (guns_firing && clockHasElapsed(guns_firing_start_time, guns_firing_duration)){ // uart0TxSendByte('X'); guns_firing = zFALSE; setMotorSpeed(ptrGunMotor, 0); //NOTE: (7.2 / 12.6) * 127 = 72.5714286 guns_firing_start_time = getMs(); } //Activate solenoid for hopup feed unjammer if (solenoidbutton == zTRUE){ // uart0TxSendByte('Z'); solenoid_on = zTRUE; setDigitalOutput(10, HIGH); solenoid_on_start_time = getMs(); } //Check whether to disable solenoid if (solenoid_on && clockHasElapsed(solenoid_on_start_time, solenoid_on_duration)){ // uart0TxSendByte('X'); solenoid_on = zFALSE; setDigitalOutput(10, LOW); solenoid_on_start_time = getMs(); } delayMs(5); } }