/** 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(void) { uint16 speed = param_speed; uint8 port = param_port, pin=param_pin; uint8 ServoPos = 120; uint8 dir=1; systemInit(); usbInit(); InitServos(); EA=1; // Global interrupt enabled SetPin(0, port, pin); SetPin(1, 0, 1); SetPin(2, 0, 3); while (1) { delayMs(speed); usbComService(); if (dir==1) { ++ServoPos; } else { --ServoPos; } if (ServoPos > 253 || ServoPos < 2) { dir ^=1; } SetPos(0,ServoPos); SetPos(1,128); SetPos(2,64); } }
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(); } }
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(); 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; } } }