Exemplo n.º 1
0
// main programm
void main(void)
{
   // Hardware initialization
   HW_init();
   // setup interrupts
   setup_timer1(TMR_INTERNAL|TMR_DIV_BY_256);   
   
   // Command buffer initialization
   init_ESPBuffer();

   while(true)
   {
      // usb for debug
      usb_task();
      
      // wi-fi esp8266
      wifi_task();
      
      /*******************************
      * *****************************
      * User code must be situated here!
      * *****************************
      *******************************/

   }//while(true)
}
Exemplo n.º 2
0
void init_RFID()
{
	uint8_t gpio=255;
	uint32_t spi_speed=10000000L;
	if (HW_init(spi_speed,gpio)) fprintf(stderr, "HW init failure\n"); // Если не удалось инициализировать RC522 выходим.
	InitRc522();
}
Exemplo n.º 3
0
Arquivo: phy.c Projeto: BeeeOn/sensors
void PHY_init(PHY_init_t params){
    
    HW_init();
    
    HW_disableConfig();
    HW_disableData();
    
    PHY_STORAGE.send_done = false;
    PHY_STORAGE.cca_noise_treshold = params.cca_noise_treshold;


    //----  configuring the RF link --------------------------------    
    for (uint8_t i = 0; i <= 31; i++) {
        //setup freq
        if((i << 1)== R1CNTREG ){
          set_chanel_freq_rate (params.channel, params.band, params.bitrate);
          //jump over R1CNTREG, P1CNTREG, S1CNTREG
          i+=3;
        }
        
        if((i << 1)== TXPARAMREG ){
          set_power(params.power);
          //jump over TXPARAMREG
          i+=1;
        }

        if((i << 1)== FDEVREG){
          set_bitrate(params.bitrate);
          //jump over FDEVREG, BRREG
          i+=2;
        }
        if((i << 1)== FILCONREG){
          // already done in previous call of set_bitrate(params.bitrate);
          i+=1;
        }
        set_register(i<<1, InitConfigRegs[i]);
    }
    
    for (uint8_t i = 0; i <= 31; i++) {
      uint8_t reg_val = get_register(i<<1);
    }
    
    send_reload_radio();

    HW_clearIRQ0();
    HW_enableIRQ0();

    HW_clearIRQ1();
    HW_enableIRQ1();
}
Exemplo n.º 4
0
int main(void)
{
	firmware_info.magic_string[0];	// prevent firmware_info being optimized away

	WATCHDOG_ON;
	
	// set idle sleep mode, turn off stuff we don't need
	SLEEP.CTRL	= SLEEP_SMODE_IDLE_gc | SLEEP_SEN_bm;
	PR.PRGEN	= PR_XCL_bm | PR_RTC_bm;
	PR.PRPA		= PR_DAC_bm | PR_ADC_bm | PR_AC_bm;
	PR.PRPC		= PR_TWI_bm | PR_USART0_bm | PR_SPI_bm | PR_HIRES_bm | PR_TC5_bm;
	PR.PRPD		= PR_TWI_bm | PR_SPI_bm | PR_HIRES_bm | PR_TC4_bm | PR_TC5_bm;

	HW_init();
	PSX_init();
	KBUS_init();

	// start interrupts
	HW_CCPWrite(&PMIC.CTRL, PMIC_RREN_bm | PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm);
	sei();
	
	KBUS_run();
}
Exemplo n.º 5
0
/* 
    Initialization of MLME 
    Given memory allocation
*/
void MLME_init(mlme_data_t *mlme_p)
{   
    int i=0;

//printk("MLME_init=0x%x\n",MLME_init); 
    
    spin_lock_init(&(macp->mlme_lock));
    
    /* scan type */
    //mlme_p->mScan_type=MLME_PASSIVE_SCAN;
    mlme_p->mScan_type=MLME_ACTIVE_SCAN;
    
    /* init hw layer */
    HW_init(mlme_p);
//printk("get channel info\n");    
    /* get channel info */
    HW_ioctl(mlme_p->hw_private,HW_CMD_GET_CHANNEL_INFO,mlme_p->mChannel_info,0);
//printk("get support rate\n");    
    /* get support rate */
    HW_ioctl(mlme_p->hw_private,HW_CMD_GET_RATE_INFO,mlme_p->mRate_info,0);
    if(mlme_dbg_level&MLME_DEBUG_MLME_BASIC_MSG)
        printk("mlme_init:support rate=%x %x %x %x %x\n",mlme_p->mRate_info[0],mlme_p->mRate_info[1],
            mlme_p->mRate_info[2],mlme_p->mRate_info[3],mlme_p->mRate_info[4]);

    /* authention method */
    mlme_p->mAuth_config=MLME_AUTH_ALG_OPEN;
//printk("basic rate\n");        
  	/* basic rate */
  	mlme_p->basic_rate_config=0;
  	while(1)
  	{  	    
        //printk("i=%d\n",i);
  	    if(mlme_p->mRate_info[i]==0)
  	        break;
  	    if(mlme_p->mRate_info[i]>mlme_p->basic_rate_config)
  	        mlme_p->basic_rate_config=mlme_p->mRate_info[i];
  	    i++;
    }

  	if(mlme_dbg_level&MLME_DEBUG_MLME_BASIC_MSG)
        printk("mlme_init:basic_rate=0x%x\n",mlme_p->basic_rate_config);
//printk("clean table\n");    
    /* init BSS table */
    mlme_clean_table(mlme_p);
            
    mlme_p->mChannel_config=MLME_CHANNEL_NOCHECK;        //set config channel to NOCHECK
    mlme_p->mMode=MLME_INFRA_MODE;    //with BSS mode
    mlme_p->mLastBeaconTime=0;
    fw_memset(mlme_p->mBssid_config,0xff,MACADDR_LEN);
//printk("mlme_reset\n");    
    /* state machine reset */    
    mlme_reset(mlme_p);
       
    fw_memset(mlme_p->bss.mEssid,0,MACADDR_LEN);
    
    mlme_p->bss.mPrivacy=MLME_AUTH_ALG_OPEN;
    mlme_p->mInterval_config=BEACON_INTERVAL;
//    mlme_p->mCap_config=MLME_CAP_NULL; //with ESS bit
    //fw_printf(MLME_DBG_LEVEL1,"init ok:[0x%x]%d\n",&mlme_p->bss.mPrivacy,mlme_p->bss.mPrivacy);
//printk("init timer\n");
    /* init timer */
    fw_init_timer(&mlme_p->mlmetimer);
    fw_init_timer(&mlme_p->routinetimer);

    /* init MLME status */
    mlme_p->mInit=1;
}