static int __init lenovo_sl_laptop_init(void)
{
	int ret;
	acpi_status status;

	hkey_handle = ec0_handle = NULL;

	if (acpi_disabled)
		return -ENODEV;

	lensl_wq = create_singlethread_workqueue(LENSL_WORKQUEUE_NAME);
	if (!lensl_wq) {
		vdbg_printk(LENSL_ERR, "Failed to create a workqueue\n");
		return -ENOMEM;
	}

	status = acpi_get_handle(NULL, LENSL_HKEY, &hkey_handle);
	if (ACPI_FAILURE(status)) {
		vdbg_printk(LENSL_ERR,
			"Failed to get ACPI handle for %s\n", LENSL_HKEY);
		return -ENODEV;
	}
	status = acpi_get_handle(NULL, LENSL_EC0, &ec0_handle);
	if (ACPI_FAILURE(status)) {
		vdbg_printk(LENSL_ERR,
			"Failed to get ACPI handle for %s\n", LENSL_EC0);
		return -ENODEV;
	}

	lensl_pdev = platform_device_register_simple(LENSL_DRVR_NAME, -1,
							NULL, 0);
	if (IS_ERR(lensl_pdev)) {
		ret = PTR_ERR(lensl_pdev);
		lensl_pdev = NULL;
		vdbg_printk(LENSL_ERR, "Failed to register platform device\n");
		return ret;
	}

	ret = hkey_inputdev_init();
	if (ret)
		return -ENODEV;

	radio_init(LENSL_BLUETOOTH);
	radio_init(LENSL_WWAN);
	radio_init(LENSL_UWB);

	led_init();
	mutex_init(&hkey_poll_mutex);
	hwmon_init();

	if (debug_ec)
		lenovo_sl_procfs_init();

	vdbg_printk(LENSL_INFO, "Loaded Lenovo ThinkPad SL Series driver\n");
	return 0;
}
Exemple #2
0
void board_init() {
   // disable watchdog timer
   WDTCTL     =  WDTPW + WDTHOLD;
   
   // setup clock speed
   DCOCTL    |=  DCO0 | DCO1 | DCO2;             // MCLK at ~8MHz
   BCSCTL1   |=  RSEL0 | RSEL1 | RSEL2;          // MCLK at ~8MHz
                                                 // by default, ACLK from 32kHz XTAL which is running
   
   // initialize pins
   P4DIR     |=  0x20;                           // [P4.5] radio VREG:  output
   P4DIR     |=  0x40;                           // [P4.6] radio reset: output
   
   // initialize bsp modules
   debugpins_init();
   leds_init();
   uart_init();
   spi_init();
   bsp_timer_init();
   radio_init();
   radiotimer_init();
   
   // enable interrupts
   __bis_SR_register(GIE);
}
Exemple #3
0
/**
 * main function
 * @return int return type required by ANSI/ISO standard.
 */
int main(void)
{
  gpio_config();

  //Initialize the LCD display
  if (!nrf6350_lcd_init())
  {
    show_error();
  }

  // Clear the display and print a welcome message
  if (!nrf6350_lcd_write_string("    RF TEST     ", MAX_CHARACTERS_PER_LINE, LCD_UPPER_LINE, 0))
  {
    show_error();
  }
  
  if (!nrf6350_lcd_write_string("   SCROLL DOWN  ", MAX_CHARACTERS_PER_LINE, LCD_LOWER_LINE, 0))
  {
    show_error();
  }

  // Init peripherals needed by radio
  radio_init();

  wait_for_joystick_movement();     // so that the test title is visible on display until joystick status is changed

  menu_help_testrun_when_idle();  // This function will never return
}
int main(void)
{
	uart_config_default_stdio();
	uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
	
	spi_init();
	radio_init();
	sei();
	
	printf("\nTX Test. Type in a packet:\n");
	
	txtest_configure_radio();

	//====================//
	//Communications Test
	char temp;
	temp = rfm22b_read(DTYPE);
	temp = rfm22b_read(DVERS);
	temp = rfm22b_read(INTEN1);
	temp = rfm22b_read(INTEN2);
	temp = rfm22b_read(OMFC1);
	temp = rfm22b_read(OMFC2);

	
    while(1)
    {
		
        txtest_fill_packet_from_uart();
		txtest_send_current_packet();
		printf("Transmit done. Type another:\n\n");
    }
}
Exemple #5
0
int main(void)
{

	init();

	radio_lora_settings_t s;
	s.spreading_factor = 12;
	s.bandwidth = BANDWIDTH_20_8K;
	s.coding_rate = CODING_4_5;
	s.implicit_mode = 0;
	s.crc_en = 1;
	s.low_datarate = 1;

	_delay_ms(100);

	radio_init();
	radio_write_lora_config(&s);
	radio_high_power();
	radio_set_frequency(FREQ_434_100);

	uint16_t i = 100;
    while(1)
    {
    	GPIOB_ODR = 0;
    	uint8_t v = radio_read_version();

    	uint8_t l = snprintf(buff,30,"HELLOsfsfd: %d     \r\n",i);
    	radio_tx_packet(buff,l);
    	_delay_ms(6500);
    	GPIOB_ODR = (1<<1);
    	_delay_ms(500);
    	i++;

    }
}
Exemple #6
0
void maca_init(void) {
    reset_maca();
    radio_init();
    flyback_init();
    init_phy();
    set_channel(0); /* things get weird if you never set a channel */
    set_power(0);   /* set the power too --- who knows what happens if you don't */
    free_head = 0;
    tx_head = 0;
    rx_head = 0;
    rx_end = 0;
    tx_end = 0;
    dma_tx = 0;
    dma_rx = 0;
    free_all_packets();

#if DEBUG_MACA
    Print_Packets("maca_init");
#endif

    /* initial radio command */
    /* nop, promiscuous, no cca */
    *MACA_CONTROL =
        (prm_mode << PRM) |
        (NO_CCA << MACA_MODE);

    enable_irq(MACA);
    *INTFRC = (1 << INT_NUM_MACA);
}
Exemple #7
0
void maca_init(void) {
    reset_maca();
    radio_init();
    flyback_init();
    init_phy();
    free_head = 0;
    tx_head = 0;
    rx_head = 0;
    rx_end = 0;
    tx_end = 0;
    dma_tx = 0;
    dma_rx = 0;
    free_all_packets();

#if DEBUG_MACA
    Print_Packets("maca_init");
#endif

    /* initial radio command */
    /* nop, promiscuous, no cca */
    *MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);

    enable_irq(MACA);
    *INTFRC = (1 << INT_NUM_MACA);
}
Exemple #8
0
int main(void)
{
       /* Setup radio input outputs */
  radio_init();

       /* Setup timer to 50hz (from timer1.c) */
  /* Clear the timer counter */
  TCNT1  = 0;

  /* Prescaler will be FCPU/256 (Set bit CS02). 
   * So Timer freq will be 16000000/256 = 62500Hz
   * We want 50Hz; 62500/50 = 1250. So we want an 
   * interrupt every 1250 timer1 ticks. */
  OCR1A   = 1250;

  /* TIMSK:  Enable Compare Match Interrupts (Set bit OCIE1A)*/
  TIMSK  |= _BV(OCIE1A);
  /* TCCR1B: Clear timer on compare match    (Set bit WGM12) */
  TCCR1B |= _BV(WGM12);
  /* TCCR1B: Prescaler to FCPU/256 & Enable  (Set bit CS12)  */
  TCCR1B |= _BV(CS12);

       /* Turn on interrupts */
  sei();

       /* Start the radio */
  radio_send();

       /* Sleep */
  for (;;) sleep_mode();
}
void radio_configure()
{
    GPIO_InitTypeDef  GPIO_InitStructure;  
  
    //enable GPIOB, Clock
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE);
    
    //Configure PB.01 as SLP_TR pin of RF
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
  
    //Configure PB.11 as RST pin of RF
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_11;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
    
    //set /RST pin high(never reset)
    GPIO_SetBits(GPIOB, GPIO_Pin_11);
    
    spi_init();
    radio_init();
    
    GPIOB->ODR |= 0X0002;
}
Exemple #10
0
void
main(void)
{
    // Stash board info from the bootloader before we let anything touch
    // the SFRs.
    //
    g_board_frequency = BOARD_FREQUENCY_REG;
    g_board_bl_version = BOARD_BL_VERSION_REG;

    // try to load parameters; set them to defaults if that fails.
    // this is done before hardware_init() to get the serial speed
    // XXX default parameter selection should be based on board info
    //
    if (!param_load())
        param_default();

    // setup boolean features
    feature_mavlink_framing = param_get(PARAM_MAVLINK)?true:false;
    feature_opportunistic_resend = param_get(PARAM_OPPRESEND)?true:false;
    feature_golay = param_get(PARAM_ECC)?true:false;
    feature_rtscts = param_get(PARAM_RTSCTS)?true:false;

    // Do hardware initialisation.
    hardware_init();

    // do radio initialisation
    radio_init();

    // turn on the receiver
    if (!radio_receiver_on()) {
        panic("failed to enable receiver");
    }

    tdm_serial_loop();
}
Exemple #11
0
void main(void) {
   //configuring
   P1OUT |=  0x04;                               // set P1.2 for debug
   P4DIR  |= 0x20;                               // P4.5 as output (for debug)
   
   gina_init();
   scheduler_init();
   leds_init();
   
   if (*(&eui64+3)==0x09) {                      // this is a GINA board (not a basestation)
      gyro_init();
      large_range_accel_init();
      magnetometer_init();
      sensitive_accel_temperature_init();
   }
   
   radio_init();
   timer_init();
   
   P1OUT &= ~0x04;                               // clear P1.2 for debug
   
   //check sensor configuration is right
   gyro_get_config();
   large_range_accel_get_config();
   magnetometer_get_config();
   sensitive_accel_temperature_get_config();

   //scheduler_push_task(ID_TASK_APPLICATION);
   
   scheduler_register_application_task(&task_application_imu_radio, 0, FALSE);

   scheduler_start();
}
Exemple #12
0
char p2p_init()
{
    char cfg_location = '?';

    /* === read node configuration data ===================================== */
    /* 1st trial: read from EEPROM */
    if (get_node_config_eeprom(&NodeConfig, 0) == 0)
    {
        /* using EEPROM config */;
        cfg_location = 'E';
    }
    /* 2nd trial: read from FLASHEND */
    else if (get_node_config(&NodeConfig) == 0)
    {
        /* using FLASHEND config */;
        cfg_location = 'F';
    }
    /* 3rd trial: read default values compiled into the application */
    else
    {
        /* using application default config */;
        memcpy_P(&NodeConfig, (PGM_VOID_P) & nc_flash, sizeof(node_config_t));
        cfg_location = 'D';
    }

    radio_init(rxbuf, sizeof(rxbuf)/sizeof(rxbuf[0]));
    radio_set_state(STATE_OFF);

    radio_set_param(RP_IDLESTATE(STATE_OFF));
    radio_set_param(RP_CHANNEL(NodeConfig.channel));
    radio_set_param(RP_SHORTADDR(NodeConfig.short_addr));
    radio_set_param(RP_PANID(NodeConfig.pan_id));

    return cfg_location;
}
Exemple #13
0
void board_init()
{
    RCC_Configuration();//Configure rcc
    NVIC_Configuration();//configure NVIC and Vector Table
    
    //configure ALL GPIO to AIN to get lowest power
    GPIO_Config_ALL_AIN();
    //configuration GPIO to measure the time from sleep to 72MHz
    GPIO_Configuration();
    
    GPIO_InitTypeDef  GPIO_InitStructure;
  
    //enable GPIOB, Clock
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE);
    
    //Configure PB.01 as SLP_TR pin of RF
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
  
    //Configure PB.11 as RST pin of RF
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_11;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
    
    //set /RST pin high(never reset)
    GPIO_SetBits(GPIOB, GPIO_Pin_11);
    
    // Configure PB.10 as input floating (EXTI Line10)
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
    
    GPIOB->ODR |= 0X0400;//set low
    
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource10);//Connect EXTI Line10 to PB.10
    EXTI_ClearITPendingBit(EXTI_Line10);

    //Configures EXTI line 10 to generate an interrupt on rising edge
    EXTI_InitTypeDef  EXTI_InitStructure; 
    EXTI_InitStructure.EXTI_Line    = EXTI_Line10;
    EXTI_InitStructure.EXTI_Mode    = EXTI_Mode_Interrupt; 
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
    EXTI_InitStructure.EXTI_LineCmd = ENABLE; 
    EXTI_Init(&EXTI_InitStructure);
    
    // initialize board
    leds_init();
    uart_init();
    spi_init();
    bsp_timer_init();
    radio_init();
    radiotimer_init();
    debugpins_init();
    //enable nvic for the radio
    NVIC_radio();
}
Exemple #14
0
int main(void) {
    di();
    OSCCON = 0x78;
    led_init();
    //sound_init();
    radio_init();
    motors_init();
    adc_init();
    ei();

    while (1) {
        /* Listen for incoming radio packet */
        if (radio_rx()) {
            /* If a radio packet is pending
             * send it immediately
             */
            if (radio_len != 0) {
                /* Send a packet */
                unsigned char c;
                LATB |= 0x01;
                radio_tx_start();
                radio_tx_data(radio_len);
                for (c = 0; c < radio_len; c++)
                    radio_tx_data(radio_data[c]);
                radio_tx_finish();
                LATB &= ~0x01;
            }
        }

        /* Read ADC values sequentally */
        {
            static char adc_ptr = 0;
            const char adc_addr[6] = {4, 15, 11, 9, 30, 13};
            /* Reading value */
            char adc_id = adc_addr[adc_ptr];
            adc_measure(adc_id);
            adc_data[adc_ptr << 1] = ADRESH;
            adc_data[(adc_ptr << 1) | 1] = ADRESL;
            /* Incrementing address */
            adc_ptr++;
            if (adc_ptr >= 6)
                adc_ptr = 0;
#ifdef FALSE_DEF
            /* Checking battery voltage */
            if (adc_id == 13) {
                /* Voltage less then 3.0V */
                if (ADRESH == 0 && ADRESL < 144) {
                    /* Power off */
                    LATA = 0;
                    LATB = 0;
                    LATC = 0;
                    di();
                    SLEEP();
                }
            }
#endif
        }
    }
}
Exemple #15
0
PROCESS_THREAD(mac_process, ev, data)
{

  PROCESS_POLLHANDLER(mac_pollhandler());


  PROCESS_BEGIN();

  radio_status_t return_value;

  /* init radio */
  /** \todo: this screws up if calosc is set to TRUE, find out why? */
  return_value = radio_init(false, NULL, NULL, NULL);

#if DEBUG
  if (return_value == RADIO_SUCCESS) {
    printf("Radio init successful.\n");
  } else {
    printf("Radio init failed with return: %d\n", return_value);
  }
#endif

  uint8_t eeprom_channel;
  uint8_t eeprom_check;
  
  eeprom_channel = eeprom_read_byte((uint8_t *)9);
  eeprom_check = eeprom_read_byte((uint8_t *)10);
  
  if ((eeprom_channel < 11) || (eeprom_channel > 26) || ((uint8_t)eeprom_channel != (uint8_t)~eeprom_check)) {
#if UIP_CONF_USE_RUM
	eeprom_channel = 19; //Default
#else
	eeprom_channel = 24; //Default
#endif
  }

  radio_set_operating_channel(eeprom_channel);
  radio_use_auto_tx_crc(true);
  radio_set_trx_state(TRX_OFF);

  mac_init();

  /* Set up MAC function pointers and sicslowpan callback. */
  pmac_driver->set_receive_function = setinput;
  pmac_driver->send = sicslowmac_dataRequest;
  sicslowpan_init(pmac_driver);

  ieee_15_4_init(&ieee15_4ManagerAddress);

  radio_set_trx_state(RX_AACK_ON);

  while(1) {
    PROCESS_YIELD();
    mac_task(ev, data);

  }

  PROCESS_END();
}
Exemple #16
0
int main()
{
    log_serial = new Serial(DEBUG_TX, DEBUG_RX);
    log_serial->baud(9600);
    DigitalIn sw2(SW2);
    DigitalIn sw3(SW3);

    for (int i = 0; i < SERVO_COUNT; i++) {
        paint_heads[i] = PAINT_NEUTRAL;
    }

    radio_init(1500);

    const uint64_t remote_addr64 = UINT64(0x0013A200, 0x40d4f162);
    const XBeeLib::RemoteXBeeZB remoteDevice = XBeeLib::RemoteXBeeZB(
            remote_addr64);

    packet pkt;
    const char *data = "what's up man?";
    strncpy((char *) &pkt.data, data, 100);
    pkt.len = strlen(data);

    radio_send(pkt);
    radio_bcast(pkt);
    radio_send(pkt, remoteDevice);

    uint8_t current_head = 0;

    log_serial->printf("Hello!\r\n");

    while (true) {
        packet pkt;
        if (radio_recv(pkt, 0)) {
            printf(
                    "\r\nGot a %s RX packet [%08lx:%08lx|%04x], "
                    "len %d\r\nData: ",
                    pkt.broadcast ? "BROADCAST" : "UNICAST",
                    uint32_t (pkt.remote_addr64 >> 32),
                    uint32_t (pkt.remote_addr64 & 0xFFFFFFFF),
                    pkt.remote_addr16,
                    pkt.len);
            printf("%.*s\r\n", pkt.len, pkt.data);
        }

        if (sw2 == 0) {
            printf("painting\r\n");
            while (sw2 == 0);
            paint_heads[current_head % SERVO_COUNT] = PAINT_SPRAY;
            wait(PAINT_TIME);
            paint_heads[current_head % SERVO_COUNT] = PAINT_NEUTRAL;
        }

        if (sw3 == 0) {
            printf("head %d\r\n", current_head);
            current_head++;
            while (sw3 == 0);
        }
    }
Exemple #17
0
void platform_init_OT() {

    buffers_init(); //buffers init must be first in order to do core dumps
    vl_init();      //Veelite init must be second

    radio_init();   //radio init third

    sys_init();     //system init last
}
Exemple #18
0
static void hardware_init()
{
    platform_init();
    event_init();
    soft_timer_init();

    phy_set_power(platform_phy, PHY_POWER_m30dBm);
    radio_init(receive_callback);
}
Exemple #19
0
void os_init () {
    memset(&OS, 0x00, sizeof(OS));
    hal_init();
    radio_init();
    LMIC_init();

	// Run os_runloop in a FreeRTOS task
	xTaskCreate(os_runloop, "lmic", tskDEFStack * 10, NULL, tskIDLE_PRIORITY, &xRunLoop);
}
Exemple #20
0
/* Repeater mode, for use with a standalone dev board */
void repeater_mode() {
  CLKCON = (1<<7) | (0<<6) | (0<<3) | (0<<0); //26MHz crystal oscillator for cpu and timer
  while (CLKCON & CLKCON_OSC);  //wait for clock stability
  
  P1DIR=0x03;   //LEDs on P1.1 and P1.0

#define LEDR P1_1
#define LEDG P1_0
  clock_delayms(100);

  radio_init();
  
  clock_delayms(100);

//    clear();
  while (1) {
    LEDR = 1; LEDG = 0;
  //  print_message(" ",2,0);
  //  print_message(" ",3,0);
  //  print_message("* Listening...        ",0,0);
    radio_listen();
    while (!radio_receive_poll(buf)) {
      clock_delayms(100);
      LEDG ^= 1;
  //    SSN = LOW;
  //    setCursor(0, 15*5);
  //    printf("%d %d %d", rf_packet_ix, rf_packet_n, rf_packet[0]); 
  //    SSN = HIGH;
    }
    buf[21]='\0';
 //   print_message("                                       ",1,0);
 //   print_message(buf, 1, 0);

    LEDR = 0; LEDG = 0;

    RFST = RFST_SIDLE;
    clock_delayms(3000);

    LEDR = 0; LEDG = 1;
 //   print_message("* Sending...",2,0);

    radio_send_packet(buf, strlen(buf) + 1);
    while (radio_still_sending()) {          
      clock_delayms(100);
 //     SSN = LOW;
 //     setCursor(2, 15*5);
 //     printf("%d %d %d", rf_packet_ix, rf_packet_n, rf_packet[0]); 
 //     SSN = HIGH;
    }
 //   print_message("* SENT!", 3, 0);
    RFST = RFST_SIDLE;
    clock_delayms(100);

  }
}
Exemple #21
0
void main(void) {
   //configuring
   P1OUT |=  0x04;                               // set P1.2 for debug
   P4DIR  |= 0x20;                               // P4.5 as output (for debug)
   
   gina_init();
   scheduler_init();
   leds_init();
   
   if (*(&eui64+3)==0x09) {                      // this is a GINA board (not a basestation)
      magnetometer_init();
   }
   
   radio_init();
   timer_init();
   
   P1OUT &= ~0x04;                               // clear P1.2 for debug
   
   //check sensor configuration is right
   magnetometer_get_config();

   //scheduler_push_task(ID_TASK_APPLICATION);
   
   //initialize variables
   timer_period = 0x033333; //set the timer frequency to 80Hz
   
   for (int c=0;c<9;c++)
   {
     delay[c] = 0;
     out[c] = 0;
   }

   alpha[0]=	0.423466145992279;
   alpha[1]=	0.359764546155930;
   alpha[2]=	0.134587764739990;
   alpha[3]=	0.445259362459183;
   alpha[4]=	0.134587764739990;
   alpha[5]=	0.400678455829620;
   alpha[6]=	0.134587764739990;
   alpha[7]=	0.160087645053864;
   alpha[8]=	0.134587764739990;
   
   //FSM variable initialization
   threshold = 0.1096;
   state = NOCAR; //initial state
   FSMcounter = 0;
   maxCount = 10; //change?
   minCount = 2;
   seenCar=0;
   
   scheduler_register_application_task(&task_application_intersection, 410, TRUE);

   scheduler_start();
}
Exemple #22
0
void main_entry(void)
{
	TBeaconBuffer pkt;
	const TiBeacon* ib = (TiBeacon*)&pkt.buf[BT_IB_PREFIX_SIZE];
	uint32_t tag_id;

	/* enabled LED output */
	nrf_gpio_cfg_output(CONFIG_LED_PIN);
	nrf_gpio_pin_set(CONFIG_LED_PIN);

	/* enabled input pin */
	nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL);

	/* initialize UART */
	uart_init();

	/* start timer */
	timer_init();

	/* calculate tag ID from NRF_FICR->DEVICEID */
	tag_id = crc32((void*)&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID));

	/* start radio */
	debug_printf("\n\rInitializing Reader[%08X] v" PROGRAM_VERSION "\n\r",
		tag_id);
	radio_init();

	/* enter main loop */
	nrf_gpio_pin_clear(CONFIG_LED_PIN);
	while(TRUE)
	{
		if(!radio_rx(&pkt))
			__WFE();
		else
			/* check for iBeacon signature */
			if( (pkt.buf[1] >= 36) && !memcmp(
					&pkt.buf[BT_PREFIX+BT_MAC_SIZE],
					&g_iBeacon_sig,
					sizeof(g_iBeacon_sig)
				) )
			{
				debug_printf("> ");
				print_guid(ib->guid);
				debug_printf(",%i,%i,0x%04X,0x%04X,%i\n\r",
					pkt.rssi,
					ib->txpower,
					ntohs(ib->major),
					ntohs(ib->minor),
					pkt.channel
					);
			}
	}
}
Exemple #23
0
void os_init () {

    memset(&OS, 0x00, sizeof(OS));

    hal_init();

	//Serial.println("os_init:: Starting radio_init"); 
	//delay(1);
    radio_init();

    LMIC_init();
}
Exemple #24
0
int main(void)
{
	gpio_init();
	rng_init();
	clock_init();
	radio_init();
	average_init();
	
	while (true){
		sniffer_loop();
	}
	
}
Exemple #25
0
void radio_reset() {
	 /* Wait for ongoing TX to complete (e.g. this could be an outgoing ACK) */
	  while(HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE);
      //flush fifos
	  CC2538_RF_CSP_ISFLUSHRX();
	  CC2538_RF_CSP_ISFLUSHTX();

	  /* Don't turn off if we are off as this will trigger a Strobe Error */
	  if(HWREG(RFCORE_XREG_RXENABLE) != 0) {
	    CC2538_RF_CSP_ISRFOFF();
	  }
	  radio_init();
}
Exemple #26
0
OT_WEAK void dll_init(void) {
    /// Initialize Radio
    radio_init();

    /// Initialize all upper-layer elements of the protocol stack
    network_init();
    m2qp_init();
    auth_init();

    /// Load the Network settings from ISF 0 to the dll.netconf buffer, reset
    /// the session, and send system to idle.
    dll_refresh();
}
Exemple #27
0
void application_start()
{
	leds_init();
	button_init();
	
	radio_init(NODE_ID, true); //true indicates receives radio message for ALL nodes
	radio_set_power(1);
	radio_start();
	
	serial_init(9600);
	
	timer_init(&timer1, TIMER_MILLISECONDS, 1000, 100);
	timer_start(&timer1);
}
Exemple #28
0
//
// Application init
//
void application_start()
{
	leds_init();
	button_init();
	
	radio_init(NODE_ID, false);
	radio_set_power(1);
	radio_start();
	
	serial_init(9600);
	
	timer_init(&timer1, TIMER_MILLISECONDS, 1000, 100);
	timer_start(&timer1);
}
/**
 * The entry point to the application.
 */
int main(void) {
  /* Hardware Setup - Don't leave MCLK floating */
  LPC_GPIO0->DIR |= (1 << 1);

  SystemInit();

  /* Start the SPI Bus first, that's really important */
  general_spi_init();

  /* Power monitoring - Turn off the battery measurement circuit */
  pwrmon_init();

  /* LED */
  LED_ON();

  /* Initialise the flash memory first so this gets off the SPI bus */
  flash_spi_init();
  flash_init();
  flash_setup();
  spi_shutdown();

  /* Optionally wipe the memory. This may take a few seconds... */
  wipe_mem();

  /* Initialise the memory writing code */
  init_write();

  /* Try to initialise the audio interface */
  if (wm8737_init() < 0) { /* If it fails */
    while (1); /* Wait here forever! */
  }

  /**
   * This delay of approximately 5 seconds is so we can
   * re-program the chip before it goes to sleep
   */
  uint32_t i = 1000*1000*3;
  while (i-- > 0);

  /* Initialise the radio stack */
  radio_init(radio_rx_callback);
  /* Initialise the time */
  time_init();

  /* Sleep forever, let the wakeup loop in sleeping.c handle everything */
  infinite_deep_sleep();

  return 0;
}
Exemple #30
0
void board_init(void) {
   uint8_t delay;
   
   // disable watchdog timer
   WDTCTL     =  WDTPW + WDTHOLD;
   
   //===== clocking
   
   DCOCTL     = 0;                               // we are not using the DCO
   BCSCTL1    = 0;                               // we are not using the DCO
   BCSCTL2    = SELM_2 | (SELS | DIVS_3) ;       // MCLK=XT2, SMCLK=XT2/8
   
   // the MSP detected that the crystal is not running (it's normal, it is
   // starting). It set the OFIFG flag, causing the MSP430 to switch back to
   // the DC0. By software, we need to clear that flag, causing the MSP430 to
   // switch back to using the XT2 as a clocking source, but verify that it
   // stays cleared. This is explained in detail in Section 4.2.6 "Basic Clock
   // Module Fail-Safe Operation" of slau049f, pdf page 119.
   
   do {
      IFG1   &= ~OFIFG;                          // clear OSCFault flag
      for (delay=0;delay<0xff;delay++) {         // busy wait for at least 50us
          __no_operation();
      }
   } while ((IFG1 & OFIFG) != 0);                // repeat until OSCFault flag stays cleared
   
   //===== pins
   
   P3DIR     |=  0x01;                           // [P3.0] radio VREG:  output
   P1DIR     |=  0x80;                           // [P1.7] radio reset: output
   P1DIR     &= ~0x20;                           // [P1.5] radio SFD:   input
   P1IES     &= ~0x20;                           // [P1.5] radio SFD:   low->high
   P1IFG     &= ~0x20;                           // [P1.5] radio SFD:   clear interrupt flag
   P1IE      |=  0x20;                           // [P1.5] radio SFD:   interrupt enabled
   
   //===== bsp modules
   
   debugpins_init();
   leds_init();
   uart_init();
   spi_init();
   bsp_timer_init();
   radio_init();
   radiotimer_init();
   
   //===== enable interrupts
   
   __bis_SR_register(GIE);
}