//initialize routine void Initialize(void) { InitializeIO(); //set up IO (directions and functions) // OpenSPI(SPI_FOSC_16, MODE_00, SMPMID); //open SPI1 spi1_open(); //open SPI1 nrf24l01_initialize_debug(true, 1, false); //initialize the 24L01 to the debug configuration as TX, 1 data byte, and auto-ack disabled }
void Initialize() { int pbClk = SYSTEMConfigPerformance(SYS_FREQ); InitializeIO(); //set up IO (directions and functions) initUART1(pbClk); SpiInitDevice(1, 1, 0, 0); nrf24l01_initialize_debug(true, width, false); //initialize the 24L01 to the debug configuration as RX, 1 data byte, and auto-ack disabled }
//initialize routine void Initialize() { // InitializeIO(); //set up IO (directions and functions) CLKPR = _BV(CLKPCE); // enable clock scalar update CLKPR = 0x00; // set to 8Mhz DDRC = 0XFF; // set port C to output usart0_open(); //open UART0 spi1_open(); //open SPI1 nrf24l01_initialize_debug(false, 1, true); //initialize the 24L01 to the debug configuration as TX, 1 data byte, and auto-ack enabled }
void main(void) { unsigned int channel = CHANNEL; unsigned char data = 0x07; // DBGU output configuration TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK); // Configuration PIT (Periodic Interrupt Timer) ConfigurePit(); // Configuration TC (Timer Counter) ConfigureTc(); // Configuration PIO (Paralell In and Out port), Init Interrupt on PIO ConfigureButtons(); ConfigureLeds(); // Configuration Radio Module nRF24L (PIO and SPI), ConfigureButtons must be executed before ConfigureNRF24L(); ConfigureUSART0(); ConfigureUSART1(); //initialize proximity sensor ir_init(); Global_Variable_Init(); while(Timer0Tick<2); // wait until NRF24L01 power up nrf24l01_power_up(True); while(Timer0Tick<4); // wait until NRF24L01 stand by Timer0Tick = 0; //initialize the 24L01 to the debug configuration as RX and auto-ack disabled nrf24l01_initialize_debug(True, nrf_TX_RX_SIZE, False); nrf24l01_write_register(0x06, &data, 1); nrf24l01_set_as_rx(True); Delay_US(130); nrf24l01_set_rf_ch(channel); nrf24l01_flush_rx(); Delay_US(300); while (1) { if(Timer0Tick!=0){ Timer0Tick = 0; Check_Battery(0); odometry(0); ProxRead_m(); Send_Coord(); Delay_US(10000);//give time for the coming message feedbackController(goalx, goaly, goaldist); } Check_Wireless(); }//while }//main
void __ISR(_UART1_VECTOR, ipl2) IntUart1Handler(void) { // Is this an RX interrupt? if (mU2RXGetIntFlag()) { // Clear the RX interrupt Flag mU2RXClearIntFlag(); char change = (char) ReadUART1(); if (change == ']') { width++; if (width > 32) { width = width - 32; } } if (change == '[') { width--; if (width < 1) { width = width + 32; } } // Echo what we just received. sprintf(RS232_Out_Buffer, "Width: %d \r\n", width); putsUART1(RS232_Out_Buffer); //reset chip to new width nrf24l01_initialize_debug(true, width, false); } // We don't care about TX interrupt if (mU2TXGetIntFlag()) { mU2TXClearIntFlag(); } }
int main(void) { int i; unsigned char add[5]={110,110,8,110,110}; /*!< At this stage the microcontroller clock setting is already configured to 120 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f2xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f2xx.c file */ #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif initLED(); init_Timer(); //while(1); /*Initialize LCD and Leds */ //LCD_LED_Init(); delay_ms(500); for(i=0;i<100;i++) { setNumber(i); delay_ms(10); } beep(40); offSegment(3); delay_ms(100); setNumber(0); delay_ms(100); beep(40); offSegment(3); delay_ms(100); setNumber(0); delay_ms(100); beep(40); //USART2_Init(); //USART3_Init(); init_NRF1_IO(); init_NRF2_IO(); SPI1_Config(); SPI3_Config(); SPI_Cmd(SPI1, ENABLE); SPI_Cmd(SPI3, ENABLE); nrf24l01_initialize_debug(false, TX_PAYLOAD_SIZE, false); nrf24l01_clear_flush(); add[2]=8; nrf24l01_set_tx_addr(add , 5); add[2]=30; nrf24l01_set_rx_addr(add,5,0); nrf24l01_set_rf_ch(tx_channel); nrf24l02_initialize_debug(false, RX_PAYLOAD_SIZE, false); nrf24l02_clear_flush(); add[2]=8; nrf24l02_set_tx_addr(add , 5); add[2]=30; nrf24l02_set_rx_addr(add,5,0); nrf24l02_set_rf_ch(rx_channel); nrf24l02_set_as_rx(true); /* configure ethernet */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* UDP echoserver */ udp_echoserver_init(); /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); process_incoming_rf(); if(firstPacketRecieved==0) { demo(); setNumber(22); } } }
int main (void) { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); //Driver initialization ds_systick_init(); ds_delay_init(); ds_uart_init(); ds_rtc_init(); ds_i2c1_init(); ds_nordic_init(); ds_therm_init(); if (SysTick_Config(SystemCoreClock / 1000)) while (1); //Initialize the nordic library nrf24l01_initialize_debug(false, 32, true); //Clear queues and interrupts //Need to fill txdata[] with our data nrf24l01_clear_flush(); char rxdata[32]; char txdata[32]; // txdata[0] = 'h'; // txdata[1] = ' '; // txdata[2] = 't'; // txdata[3] = 'i'; // txdata[4] = 'm'; float temp = 0; int i; // for (i = 5; i < 30; i++) { // txdata[i] = '!'; // } // txdata[30] = '\n'; // txdata[31] = '\0'; while (1) { for (i = 0; i < 5000; i++) { ds_delay_uS(1000); } temp = ds_therm_read_degC(ds_read_therm()); sprintf(txdata, "%f\n", temp); nrf24l01_write_tx_float(&temp, 32, true); while(!(nrf24l01_irq_pin_active() && (nrf24l01_irq_tx_ds_active() || nrf24l01_irq_max_rt_active()))); //Confirms acknowledge //if (!nrf24l01_irq_max_rt_active()) { // nrf24l01_irq_clear_all(); // nrf24l01_set_as_rx(true); //} //else { // nrf24l01_flush_tx(); //get the unsent character out of the TX FIFO // nrf24l01_irq_clear_all(); //clear all interrupts // printf("Node: Failed to send %c\n",txdata); //} //Waits for data and reads it //while(!(nrf24l01_irq_pin_active() && nrf24l01_irq_rx_dr_active())); //nrf24l01_read_rx_payload(rxdata, 32); nrf24l01_irq_clear_all(); //printf(rxdata); } //puts into transmit mode - not needed for base station ds_delay_uS(130); nrf24l01_set_as_tx(); }
void main(void) { unsigned int channel = CHANNEL; unsigned char data = 0x07; unsigned char t1; unsigned char t2; unsigned int tmpcount = 0; unsigned char wl_data[10]; unsigned char rs_line[20]; unsigned char rs_data[10]; unsigned char tmp_data[50]; // DBGU output configuration TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK); // Configuration PIT (Periodic Interrupt Timer) ConfigurePit(); // Configuration TC (Timer Counter) ConfigureTc(); // Configuration PIO (Paralell In and Out port), Init Interrupt on PIO ConfigureButtons(); ConfigureLeds(); // Configuration Radio Module nRF24L (PIO and SPI), ConfigureButtons must be executed before ConfigureNRF24L(); ConfigureUSART0(); ConfigureUSART1(); while(Timer1Tick<2); // wait until NRF24L01 power up nrf24l01_power_up(True); while(Timer1Tick<4); // wait until NRF24L01 stand by Timer1Tick = 0; //initialize the 24L01 to the debug configuration as RX and auto-ack disabled nrf24l01_initialize_debug(True, nrf_TX_RX_SIZE, False); nrf24l01_write_register(0x06, &data, 1); nrf24l01_set_as_rx(True); Delay_US(130); nrf24l01_set_rf_ch(channel); nrf24l01_flush_rx(); Delay_US(300); reset_wl = 1; while (1) { if( nrf_Data > 0 ) { nrf_Data = 0; for( t1 = 0; t1<8; t1++ ) { wl_data[t1] = nrfRxMessage.Data[t1]; } LED_Toggle(LED_Green); writeByteSequence_8(wl_data); } if(messageUSART1){ messageUSART1 = 0; pmsgRead(tmp_data); while (tmp_data[tmpcount]!='\n'){ t1 = tmp_data[tmpcount]; tmpcount++; if( t1 >= '0' && t1 <= '9' ) { // If character is 0-9 convert it to num if( count < 20) { rs_line[count] = t1-'0'; count++; } } if( t1 >= 'A' && t1 <= 'F' ) { // If character A-F convert to 10-15 if( count < 20) { rs_line[count] = t1-'A'+10; count++; } } } // If character is a line break send packet for( count = 0; count <10; count++ ) { // Convert from 16*4 to 8*8 t1 = (rs_line[count*2])<<4; t2 = rs_line[count*2+1]; rs_data[count] = t1 | t2; } count = 0; tmpcount = 0; if( nrf_Transmission_Done == 1 ) { TX_packet_BASE(rs_data); // Send packet. LED_Toggle(LED_Yellow); } }//if msg flag has been raised }//while }//main