void main(void) { uint16_t i; serialInit(9600); vw_setup(600); puts("PIC Receiver Demo\n"); vw_rx_start(); while(1) { if (vw_have_message()) { uint8_t len = VW_MAX_MESSAGE_LEN; if (vw_recv(text, &len)) { for (i = 0; i < len; i++) putchar(text[i]); putchar('\n'); } } } }
// setup the output pins and the RF link void setup() { // initialize the LED 1 pins pinMode(LED1_RED, OUTPUT); pinMode(LED1_GREEN, OUTPUT); pinMode(LED1_BLUE, OUTPUT); // initialize the LED 2 pins pinMode(LED2_RED, OUTPUT); pinMode(LED2_GREEN, OUTPUT); pinMode(LED2_BLUE, OUTPUT); _selfTest(); // Start serial communication for debug output Serial.begin(9600); Serial.println("XFVWLamp ready"); // Initialize and start VirtualWire vw_set_rx_pin(RX_PIN); // Set the receive pin to RX_PIN vw_set_tx_pin(TX_PIN); vw_set_ptt_pin(PTT_PIN); vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
int main(void) { mcusr_save = MCUSR; MCUSR = 0; wdt_disable(); if (!(mcusr_save & WDRF)) { seqnum = 0; } #ifdef SN_TEMP_DDR // configure pin for analog SN_TEMP_DDR &= ~SN_TEMP_MASK; // set as input SN_TEMP_PORT &= ~SN_TEMP_MASK; // pull-ups off DIDR0 |= SN_TEMP_MASK; // disable digital input buffer #endif SN_LED_DDR |= SN_LED_MASK; // set as output SN_LED_PORT &= ~SN_LED_MASK; vw_setup(); #ifdef SN_RX_CAPABLE vw_rx_start(); #endif for (int i=0;i<3;i++) { send_status(SN_ADDRESS_BROADCAST); vw_wait_tx(); } for (;;) { #ifdef SN_RX_CAPABLE if (vw_have_message()) { uint8_t len = sizeof(msg); if (vw_get_message((uint8_t *)&msg, &len)) { if (msg.header.destination == SN_ADDRESS_ME|| msg.header.destination == SN_ADDRESS_BROADCAST) { process_msg(); } else { // TODO - consider routing here } } else { // bad message } } #endif #ifdef SN_TX_CAPABLE // Process any outgoing stuff if (millis() - last_status > STATUS_PERIOD) { send_status(SN_ADDRESS_BROADCAST); } if (millis() - last_sensor_data > SENSOR_PERIOD) { send_sensor_data(SN_ADDRESS_BROADCAST); } #endif // SN_TX_CAPABLE #ifdef USE_MILLIS //set_sleep_mode(SLEEP_MODE_IDLE); //sleep_enable(); //sleep_cpu(); //sleep_disable(); #endif } }
void setup() { pinMode( TX_PIN, OUTPUT ); vw_set_tx_pin(TX_PIN); vw_setup(8000); // Bits per sec (half this though as running at 8mhz) pinMode( STATUS_LED, OUTPUT ); pinMode( IR_LED, OUTPUT ); digitalWrite( STATUS_LED, LOW ); }
///////////////////////////////////// // // Initialize the radio interface // void init_radio(void) { vw_set_ptt_pin(10); // defaults to 10 vw_set_rx_pin(11); // defaults to 11 vw_set_tx_pin(12); // defaults to 12 vw_setup(2000); // set up for 2000 bps vw_rx_start(); // start the rx radio_go = 1; // mark the rf system "up" }
void CommClass::init() { #ifdef USE_433MHZ #ifdef WIRELESS_TRANSFER vw_set_ptt_inverted(true); vw_set_tx_pin(WIRELESS_433MHZ_TRANSFER_PIN); vw_setup(WIRELESS_SPEED);// speed of data transfer bits per second #endif #ifdef WIRELESS_RECEIVE vw_set_ptt_inverted(true); vw_set_rx_pin(WIRELESS_433MHZ_RECEIVE_PIN); vw_setup(WIRELESS_SPEED); // Bits per sec vw_rx_start(); // Start the receiver PLL running latestDataType = TYPE_NONE; #endif #endif //USE_433MHZ #ifdef USE_NRF24L rf24_module.begin(); rf24_module.setAutoAck(1); // Ensure autoACK is enabled rf24_module.enableAckPayload(); // Allow optional ack payloads rf24_module.setRetries(0, 10); // Smallest time between retries, max no. of retries rf24_module.setPayloadSize(MAX_PAYLOAD); // Here we are sending 1-byte payloads to test the call-response speed rf24_module.setDataRate(RF24_1MBPS); #ifdef WIRELESS_TRANSFER rf24_module.openWritingPipe((uint8_t*)WIRELESS_QUAD_ADDR); rf24_module.openReadingPipe(1, (uint8_t*)WIRELESS_QUAD_CTRL); #endif #ifdef WIRELESS_RECEIVE rf24_module.openWritingPipe((uint8_t*)WIRELESS_QUAD_CTRL); rf24_module.openReadingPipe(1, (uint8_t*)WIRELESS_QUAD_ADDR); #endif rf24_module.startListening(); // Start listening rf24_module.powerUp(); rf24_module.printDetails(); // Dump the configuration of the rf unit for debugging #endif //USE_NRF24L #ifdef USE_APC_220 //apc220.begin(WIRELESS_SPEED); #endif //USE_APC_220 }
void setup() { Serial.begin(9600); // Debugging only Serial.println("setup"); // Initialise the IO and ISR vw_set_ptt_inverted(true); // Required for DR3100 vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
void setup() { Serial.begin(9600); // Debugging only Serial.println("Receiver begin"); // Initialise the IO and ISR vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
void setup() { Serial.begin(115200); Serial.println("setup"); pinMode( RADIO_RX, INPUT ); vw_set_rx_pin( RADIO_RX ); vw_setup(8000); // Bits per sec vw_rx_start(); // Start the receiver PLL running pinMode( STATUS_LED, OUTPUT ); digitalWrite( STATUS_LED, HIGH ); }
void setup() { // Inicializamos el monitor serie Serial.begin(9600); // Marcamos el pin del LED como salida para tenerlo de referencia pinMode(13, OUTPUT); // Inicializamos el receptor de señal vw_set_ptt_inverted(true); vw_setup(2000); vw_rx_start(); }
void setup() { delay(1000); Serial.begin( 9600 ); // Debugging only vw_set_rx_pin( RECEIVE_PIN ); vw_set_ptt_inverted( true ); // Required for DR3100 vw_setup( 2000 ); // Bits per sec vw_rx_start(); // Start the receiver PLL running lcd.begin( 16, 2 ); delay( 2000 ); }
void setup() { Serial.begin(9600); Serial.println("setup"); relays[0] = createRelay(PORT_0); relays[1] = createRelay(PORT_1); relays[2] = createRelay(PORT_2); relays[3] = createRelay(PORT_3); vw_set_rx_pin(PORT_RF); vw_setup(4000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
// initialize library and set device uid int radio_init(radio_uid uid, uint16_t speed, uint8_t tx_pin, uint8_t rx_pin, uint8_t enable_receiver) { // Serial.print("init"); state.uid = uid; vw_set_tx_pin(tx_pin); vw_set_rx_pin(rx_pin); vw_setup(speed); if( enable_receiver ){ vw_rx_start(); } }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //P1DIR |= BIT0; // Set P1.0 to output direction //TA0CCTL0 = CCIE; // CCR0 interrupt enabled //TA0CTL = TASSEL_2 + MC_1 + TACLR + TAIE + ID_3; // SMCLK/8, upmode //TA0CCR0 = 0xffff; // 12.5 Hz vw_setup(1000); //vw_rx_start(); //P1DIR |= BIT4; uint8_t count = 1; while(1) { char msg[7] = {'h','e','l','l','o',' ','#'}; msg[6] = count; vw_send((uint8_t *)msg, 7); vw_wait_tx(); // Wait until the whole message is gone __delay_cycles(3/cycletime); count = count + 1; } /*while(1) { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; if (vw_get_message(buf, &buflen)) // Non-blocking { //int i; P1OUT |= BIT4; // Flash a light to show received good message __delay_cycles(1/cycletime); // Message with a good checksum received, dump it. //Serial.print("Got: "); //for (i = 0; i < buflen; i++) //{ // Serial.print(buf[i], HEX); // Serial.print(' '); //} //Serial.println(); P1OUT &= ~BIT4; } }*/ }
void setup() { // initialize VirtualWire vw_set_rx_pin( rxPin ); vw_setup( BAUD ); vw_rx_start(); // initialize relay and led pins pinMode( relayPin, OUTPUT ); pinMode( ledPin, OUTPUT ); digitalWrite( ledPin, HIGH ); delay( 100 ); digitalWrite( ledPin, LOW ); delay( 100 ); digitalWrite( ledPin, HIGH ); delay( 100 ); digitalWrite( ledPin, LOW ); }
void Vc4Shader::Emit_Prologue_VS() { assert(this->uShaderType == D3D10_SB_VERTEX_SHADER); VC4_ASSERT(cInput < 16); // VR_SETUP:NUM limitation, vpm only can read up to 16 values. { Vc4Instruction Vc4Inst(vc4_load_immediate_32); Vc4Register vr_setup(VC4_QPU_ALU_REG_A, VC4_QPU_WADDR_VPMVCD_RD_SETUP); Vc4Register value; value.SetImmediateI(MAKE_VR_SETUP(cInput, 1, true, false, VC4_QPU_32BIT_VECTOR, 0)); Vc4Inst.Vc4_a_LOAD32(vr_setup, value); Vc4Inst.Emit(CurrentStorage); } { Vc4Instruction Vc4Inst(vc4_load_immediate_32); Vc4Register vw_setup(VC4_QPU_ALU_REG_B, VC4_QPU_WADDR_VPMVCD_WR_SETUP); Vc4Register value; value.SetImmediateI(MAKE_VW_SETUP(1, true, false, VC4_QPU_32BIT_VECTOR, 0)); Vc4Inst.Vc4_a_LOAD32(vw_setup, value); Vc4Inst.Emit(CurrentStorage); } for (uint8_t iRegUsed = 0, iRegIndex = 0; iRegUsed < this->cInput; iRegIndex++) { Vc4Instruction Vc4Inst; Vc4Register raX = this->InputRegister[iRegIndex / 4][iRegIndex % 4]; if (raX.GetFlags().valid) { assert(raX.GetMux() == VC4_QPU_ALU_REG_A || raX.GetMux() == VC4_QPU_ALU_REG_B); Vc4Register vpm(raX.GetMux(), VC4_QPU_RADDR_VPM); Vc4Inst.Vc4_a_MOV(raX, vpm); Vc4Inst.Emit(CurrentStorage); iRegUsed++; } } { // Emit a NOP Vc4Instruction Vc4Inst; Vc4Inst.Emit(CurrentStorage); } }
void RFEasy::_init() { vw_setup(_rx_frequency); }
void main (void) { unsigned int i; bool MUDA=false; //char null_0 [sizeof(unsigned long)*8+1]; //char null_1 [sizeof(unsigned long)*8+1]; //float *input = (float*)malloc(DATA_SIZE*sizeof(float)); //float *output = (float*)malloc(DATA_SIZE*sizeof(float)); //FOSC = INTOSC_EC, the actual value for FOSC<3:0> = b'1001', which accesses the internal clock and sets RA6 as a Fosc/4 pin. // OSCCON=0b110; // 4 mhz // OSCCON=0b111; // 8 mhz // OSCCON=0b11110010; // 8 mhz , SCS<1:0> = b'10', which activates the internal oscillator. //IRCF0=0; //IRCF1=1; //IRCF2=1; // SCS1=1; // SCS0=0; /* REGISTER 2-2: OSCCON: OSCILLATOR CONTROL REGISTER IDLEN IRCF2 IRCF1 IRCF0 OSTS IOFS SCS1 SCS0 bit 7 ................................ bit 0 bit 7 IDLEN:Idle Enable bit 1= Device enters Idle mode on SLEEPinstruction 0= Device enters Sleep mode on SLEEPinstruction bit 6-4 IRCF2:IRCF0:Internal Oscillator Frequency Select bits 111= 8 MHz (INTOSC drives clock directly) 110= 4 MHz 101= 2 MHz 100= 1 MHz 011= 500 kHz 010= 250 kHz 001= 125 kHz 000= 31 kHz (from either INTOSC/256 or INTRC directly) bit 3 OSTS:Oscillator Start-up Time-out Status bit 1= Oscillator Start-up Timer time-out has expired; primary oscillator is running 0= Oscillator Start-up Timer time-out is running; primary oscillator is not ready bit 2 IOFS:INTOSC Frequency Stable bit 1= INTOSC frequency is stable 0= INTOSC frequency is not stable bit 1-0 SCS1:SCS0:System Clock Select bits 1x= Internal oscillator 01= Timer1 oscillator 00= Primary oscillator Note 1: Depends on the state of the IESO Configuration bit. 2: Source selected by the INTSRC bit (OSCTUNE<7>), see text. 3: Default output frequency of INTOSC on Reset */ TRISB=0x00; // configura PORTB para saida do LCD TRISD6=0; // configura LED TRISD7=0; // configura LED TRISD2=0; // configura LED de while TRISD3=0; // configura LED de Interrupcao TRISA0=1; // configura ENTRADA do TERMISTOR LM35 TRISA1=1; // configura ENTRADA do LDR TRISA2=1; // configura ENTRADA para botao de estado do GIE //CCP1CON=0x00; //CCP2CON=0x00; /* * If either of the CCP modules is configured in Compare * mode to generate a Special Event Trigger * (CCP1M3:CCP1M0 or CCP2M3:CCP2M0 = 1011), * this signal will reset Timer1. The trigger from CCP2 will * also start an A/D conversion if the A/D module is * enabled (see Section 15.3.4 ?Special Event Trigger? * for more information). */ ADCON1bits.PCFG=0b1101; // Configura somente as portas AN0 e AN1 como AD ADFM=1; // utiliza o total de 10 bits no ADRES /* * Página 33 de 74O bit de ADFM tem a função de organizar o resultado da * conversão A/D, de forma que o osvalores convertidos sejam justificados * a direita ou a esquerda nos registradores ADRESH e ADRESL. Caso venhamos * configurar ADFM = 1, organizamos o valor da conversão a direita,ou seja, * os oitos bits menos significativo será armazendo em ADRESL, e os 2 bits * maissignificativo serão armazenados em ADRESH.Caso ADFM = 0, * justificaremos a esquerda os valores de conversão, desta forma os * oitosbits mais significativos ficarão em ADRESH e os 2 menos * significativo ficará em ADRESL. */ for(i=0;i<10;i++) { LED2=1; LED1=0; Delay1KTCYx(50); // 50 ms LED2=0; LED1=1; Delay1KTCYx(50); } LED1=0; initLCD(); //####################################################################### //####################################################################### //####################################################################### //####################################################################### while(BusyXLCD()); WriteCmdXLCD(0x01); SetDDRamAddr(0x00); putrsXLCD ("PIC18F4550 LuzTempRF"); vw_setup(600); // inicializa o modulo RF com 600 bps // apenas um teste para imprimir o tamanho do float //sprintf(msg, "%s%d%c", "I", sizeof(float), NULL); //Delay1KTCYx(100); vw_send("INIT", 5); Delay10KTCYx(250); aferir(); // Primeira Afericao, ainda fora do contador do TIMER1 //Delay10KTCYx(250); configTimers(); // ativa os parametros de contador do TIMER1 com 500ms while (1) { if (PORTAbits.RA2) { if (!MUDA) { aferir(); GIE=1;} MUDA=true; } else { if (MUDA) { aferir();GIE=0;} MUDA=false; } LATDbits.LD2=~PORTDbits.RD2; } }
void SetupRFDataTxnLink(int transmit_pin, int baudRate) { vw_set_tx_pin(transmit_pin); vw_setup(baudRate); }
void SetupRFDataRxnLink(int rx_pin, int baudRate) { vw_set_rx_pin(rx_pin); vw_setup(baudRate); vw_rx_start(); }
void setup(void) { status.reset(); /// Discrete & Analog IO pinMode(13, OUTPUT); // Arduino on-board LED pinMode(A0, OUTPUT); // Buzzer /// Comm. Channels // UART Serial.begin(115200); Serial.flush(); Serial.println("Starting up greenOmatic Duemilanove Testbed..."); Serial.print("Program compiled on "); Serial.print(__DATE__); Serial.print(" at "); Serial.println(__TIME__); Serial.println(); // RF #ifdef INTERFACE_ASK_RX pinMode(RF_RX_PIN, INPUT); vw_set_rx_pin(RF_RX_PIN); vw_setup(RF_BAUD); vw_rx_start (); Serial.print ("ASK RF Receiver configured on PIN "); Serial.print (RF_RX_PIN); Serial.print (" @ "); Serial.print (RF_BAUD, DEC); Serial.println(" baud."); #endif //INTERFACE_ASK_RX // Ethernet #ifdef INTERFACE_ETHERNET Serial.print("Starting Ethernet... "); #ifdef ETHERNET_DYNAMIC_IP int eth_stat = Ethernet.begin(mac); if (0 == eth_stat) { Serial.println(" Problem starting ethernet !"); status.ethernet_valid = status.ERROR; } else { Serial.print("Ethernet started, IP = "); Serial.println( Ethernet.localIP() ); status.ethernet_valid = status.VALID; } #else Ethernet.begin(mac, IPaddr); Serial.print("Ethernet started, IP = "); Serial.println( Ethernet.localIP() ); status.ethernet_valid = status.VALID; #endif //ETHERNET_DYNAMIC_IP #ifdef ETHERNET_WEBSERVER server.begin(); #endif //ETHERNET_WEBSERVER #ifdef ETHERNET_UDPCLIENT Udp.begin(localPort); #endif //ETHERNET_UDPCLIENT #endif /// Peripherals // I2C RTC #ifdef PERIPHERAL_RTCC Wire.begin(); rtc.begin(); if (rtc.isrunning()) { status.time_valid = status.VALID; GetDatetimeString(rtc.now()); Serial.print("RTCC configured on I2C. Time is currently "); Serial.println(currentTime); #ifdef ETHERNET_UDPCLIENT //TODO: Get NTP Time #else // Compare RTC time to this programs compile time DateTime rtcTime = rtc.now(); DateTime compileTime(F(__DATE__), F(__TIME__)); // If the compile-time is later (more recent) than the current RTC time, update the RTC if (compileTime.secondstime() > rtcTime.secondstime()) { Serial.println("Program compile-time is later than RTC time; updating RTC."); rtc.adjust( DateTime(F(__DATE__), F(__TIME__)) ); } #endif //ETHERNET_UDPCLIENT } else { status.time_valid = status.ERROR; // TODO, can we narrow this down further like with the DS1307RTC library? } #endif Serial.println("\nInitialization complete!\n\n"); }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer UCSCTL3 = SELREF_2; // Set DCO FLL reference = REFO UCSCTL4 |= SELA_2; // Set ACLK = REFO UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx // Loop until XT1,XT2 & DCO stabilizes - In this case only DCO has to stabilize do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags }while (SFRIFG1&OFIFG); // Test oscillator fault flag __bis_SR_register(SCG0); // Disable the FLL control loop UCSCTL1 = DCORSEL_5; // Select DCO range 16MHz operation UCSCTL2 |= 249; // Set DCO Multiplier for 8MHz // (N + 1) * FLLRef = Fdco // (249 + 1) * 32768 = 8MHz __bic_SR_register(SCG0); // Enable the FLL control loop // Worst-case settling time for the DCO when the DCO range bits have been // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx // UG for optimization. // 32 x 32 x 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle __delay_cycles(250000); //P1DIR |= BIT0; // Set P1.0 to output direction //TA0CCTL0 = CCIE; // CCR0 interrupt enabled //TA0CTL = TASSEL_2 + MC_1 + TACLR + TAIE + ID_3; // SMCLK/8, upmode //TA0CCR0 = 0xffff; // 12.5 Hz vw_setup(1000); vw_rx_start(); P1DIR |= BIT4; /*uint8_t count = 1; while(1) { char msg[7] = {'h','e','l','l','o',' ','#'}; msg[6] = count; vw_send((uint8_t *)msg, 7); vw_wait_tx(); // Wait until the whole message is gone __delay_cycles(5/cycletime); count = count + 1; }*/ while(1) { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; if (vw_get_message(buf, &buflen)) // Non-blocking { //int i; P1OUT |= BIT4; // Flash a light to show received good message __delay_cycles(1/cycletime); // Message with a good checksum received, dump it. //Serial.print("Got: "); //for (i = 0; i < buflen; i++) //{ // Serial.print(buf[i], HEX); // Serial.print(' '); //} //Serial.println(); P1OUT &= ~BIT4; } } }
//------------------------------------End of Watchdog---------------------------------------------// //Setup// void setup () { vw_setup(2000); // Radio Baud Rate// vw_set_tx_pin(RadioTXPin ); // Set DATA radio TX Pin// NOTE: MUST BE PWM PIN pinMode(DataRadioSwitch,OUTPUT); }