Ejemplo n.º 1
0
void init(void) {
    initLeds();
    initTimer();
    initPWM();
    initSpi();
    LIS302DL_Init();
}
Ejemplo n.º 2
0
void initApp(void){

    TRISA=0;
    TRISB=0;
    TRISD=0;

    PORTA=0;
    PORTB=0;
    PORTD=0;

  //  OSCCONbits_t.IDLEN idle/sleep
  //  OSCCONbits_t.IRCF0 //speed from 8mhz to 32k
  //  OSCCONbits_t.IRCF1
  //  OSCCONbits_t.IRCF2
  //  OSCCONbits_t.OSTS ////oscilator timer ended
  //  OSCCONbits_t.IOFS //stable or not
  //  OSCCONbits_t.SCS0 //internal
  //  OSCCONbits_t.SCS1 //timer / primal oscilator

    OSCCON=0b01110011; //8Mhz / internal
  //  LATCbits_t.LATC0=1; //external
    LATC0=1;
    
 //   WDTCON=0x00;
    initSpi();
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: hl1itj/Team3
void
InitDebug(void)
{
#ifdef DEBUG
	irqInit();
	initSpi();
	initDebug();
	BreakPoint();
#endif
}
Ejemplo n.º 4
0
void DWM1000_Anchor::init() {
	INFO("HSPI");
//_________________________________________________INIT SPI ESP8266

	resetChip();
	initSpi();
	enableIsr();

	uint64_t eui = 0xF1F2F3F4F5F6F7F;
	dwt_seteui((uint8_t*) &eui);
	dwt_geteui((uint8_t*) &eui);
	LOG<< HEX << "EUID : "<< eui <<FLUSH;
	dwt_seteui((uint8_t*) &eui);
	dwt_geteui((uint8_t*) &eui);
	LOG<< HEX << "EUID : "<< eui <<FLUSH;

//	dwt_softreset();
	deca_sleep(100);

	if (dwt_initialise(DWT_LOADUCODE)) {
		LOG<< " dwt_initialise failed " << FLUSH;
	} else
	LOG<< " dwt_initialise done." << FLUSH;
	if (dwt_configure(&config)) {
		LOG<< " dwt_configure failed " << FLUSH;
	} else
	LOG<< " dwt_configure done." << FLUSH;

	uint32_t device_id = dwt_readdevid();
	uint32_t part_id = dwt_getpartid();
	uint32_t lot_id = dwt_getlotid();

	LOG<< HEX << " device id : " << device_id << ", part id : " << part_id << ", lot_id :" << lot_id <<FLUSH;

	/* Apply default antenna delay value. See NOTE 1 below. */
	dwt_setrxantennadelay(RX_ANT_DLY);
	dwt_settxantennadelay(TX_ANT_DLY);

	/* Set expected response's delay and timeout. See NOTE 4 and 5 below.
	 * As this example only handles one incoming frame with always the same delay and timeout, those values can be set here once for all. */
	dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS);
	dwt_setrxtimeout(RESP_RX_TIMEOUT_UUS);

	dwt_initialise(DWT_LOADUCODE);
	// Configure the callbacks from the dwt library
	dwt_setcallbacks(txcallback, rxcallback);

	_count = 0;
}
Ejemplo n.º 5
0
void SpiLcd::init(uint8_t latchPin)
{
	_latchPin = latchPin;
	pinMode(_latchPin, OUTPUT);
	
	_displayfunction = LCD_FUNCTIONSET | LCD_4BITMODE;

	initSpi();   
		
	for(uint8_t i = 0; i<4; i++){
		for(uint8_t j = 0; j<20; j++){
			content[i][j]=' '; // initialize on all spaces
		}
		content[i][20]='\0'; // NULL terminate string
	}
}
Ejemplo n.º 6
0
int main() {
	int i=0;
	int ret,j;
	static u8 data[512];
	
	
	cur_song_init();
	init_usart();
	initSystick();
	delay(1000);
	printf("\r\n\r\n-------- start -------\r\n");
	
//	shot();
//	while (1);
	
	initSpi();
	SD_Init();
	readBlock(0,data);
	
	init_mp3();
	Mp3Reset();
	mute();
	init_fetch();
	
  //send_fetch_play_list();
  while (1) loop();

// 	println("start shot...");
// 	for(i=1;i<=3573;i++){
// 		readBlock(i,data);
// 		for(j=0;j<512;j++) {
// 			printf("%c",data[j]);
// 		}
// 	}
// 	println("shot over");

// 	println("--- 0");
//  	ret = get_millisecond();
//  	for(i=1;i<1000;i++)
//  		writeBlock(i,data);
// 	readBlock(990,data);
//  	printf("--- %d\r\n",get_millisecond() - ret);
}
Ejemplo n.º 7
0
void 
wl_init_complete_cb(void* ctx) 
{
	struct ctx_server *hs = ctx;
    struct ip_addr ipaddr, netmask, gw;
	wl_err_t wl_status;
	
	if (hs->net_cfg.dhcp_enabled == INIT_IP_CONFIG)
	{
		IP4_ADDR(&gw, 0,0,0,0);
		IP4_ADDR(&ipaddr, 0,0,0,0);
		IP4_ADDR(&netmask, 0,0,0,0);
			
		/* default is dhcp enabled */
		hs->net_cfg.dhcp_enabled = DYNAMIC_IP_CONFIG;
	}

    start_ip_stack(&hs->net_cfg,
                   ipaddr,
                   netmask,
                   gw);
    netif_set_status_callback(hs->net_cfg.netif, ip_status_cb);

    INFO_INIT("Starting CM...\n");
    /* start connection manager */
    wl_status = wl_cm_init(wl_cm_scan_cb, wl_cm_conn_cb, wl_cm_disconn_cb, hs);
    ASSERT(wl_status == WL_SUCCESS, "failed to init wl conn mgr");
    wl_cm_start();

    wl_scan();

    if (initSpi(hs)){
    	WARN("Spi not initialized\n");
    }else
    {
    	initSpiComplete = true;
        AVAIL_FOR_SPI();
    }

    hs->wl_init_complete = 1;
}
Ejemplo n.º 8
0
void main(void)
{
  // Stop watchdog timer
  WDTCTL = WDTPW + WDTHOLD;
  
  // set clocks
  BCSCTL1 = CALBC1_1MHZ;
  DCOCTL = CALDCO_1MHZ;
  BCSCTL2 &= ~(DIVS_3);

  // port 1 init  
  P1DIR |= LED1 + LED2;
  P1OUT = 0x00;
  
  P2DIR |= RFM70_CSN + RFM70_CE;
  P2OUT = 0x00;
  P2OUT |= RFM70_CSN;
  
  //init button
  P1DIR &= ~BUTTON;  
  P1OUT |= BUTTON;
  P1REN |= BUTTON;
  
  working_mode = MODE_PC_CONN_WAIT;

  // init ADC
  configureAdcTempSensor();
  
  // init SPI
  initSpi();
  
   // wait to init SPI slave device
  __delay_cycles(200);
  
  // init UART
  initUart();
  
  // delay
  __delay_cycles(200);

  // wait for correct data by reading status register
  while (rx != 0x0E) {
    rx = rfm70Nop();
    // turn on red led while not initialized
    P1OUT |= LED1;
    P1OUT |= LED2;
    __delay_cycles(200);
  }
  // got slave response, turn red led off
  P1OUT &= ~LED1;
  P1OUT &= ~LED2;
  
  __bis_SR_register(LPM0_bits + GIE);
  
  // working ...
  rfm70Init();
  rfm70SetRxMode();
  while (1) {
    // detect carrier
    rfm70ReadRegister(rfm70_buffer, RFM70_CD, 1);
    if (rfm70_buffer[0] == 0x01) {
      P1OUT |= LED1;
    }
    else {
      P1OUT &= ~LED1;
    }
    // receive data
    rfm70ReadRegister(rfm70_buffer, RFM70_R_RX_PL_WID, 1);
    rx = rfm70Nop();
    if (rx & (1 << 6)) {
      rfm70ReadRxPayload(rfm70_buffer, 1);
      //sendUart(rfm70_buffer[0]);
      //sendUart('T');
      if (rfm70_buffer[0] == 0xFF) {
        P1OUT |= LED1;
      }
      else {
        P1OUT &= ~LED1;
      }
      // clear interrupt status
      rfm70_buffer[0] = 0x00;
      rfm70WriteRegister(rfm70_buffer, RFM70_STATUS, 1);
    }
  }

  //__bis_SR_register(LPM0_bits + GIE);
}
Ejemplo n.º 9
0
int main(void)
{
  uint16_t vector_start = 0;
  uint16_t vector_end = 0;

  /* Initialize chip */
  CHIP_Init();

  // start HFXO
  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);

  /* Start LFXO, and use LFXO for low-energy modules */
  CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
  CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFXO);

  CMU_ClockEnable(cmuClock_GPIO, true);

  delay_init();

  initLeuart();

  initSpi();

#if 0
  printf("cmuClock_HF:     %" PRIu32 "\r\n", CMU_ClockFreqGet(cmuClock_HF));
  printf("cmuClock_CORE:   %" PRIu32 "\r\n", CMU_ClockFreqGet(cmuClock_CORE));
  printf("cmuClock_HFPER:  %" PRIu32 "\r\n", CMU_ClockFreqGet(cmuClock_HFPER));
  printf("cmuClock_TIMER1: %" PRIu32 "\r\n", CMU_ClockFreqGet(cmuClock_TIMER1));
#endif

  init_analog_switches();

  printf("\r\n* vector test *\r\n");

  while (1)
  {
    char c;

    c = leuart_blocking_read_char();
    switch(c)
    {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    	vector_start = vector_end;
    	vector_end = 4095 * (c - '0') / 9;
    	break;

    case 'v':
    	printf("vector from %d to %d\r\n", vector_start, vector_end);
    	setDAC(0, true, vector_start);
    	set_analog_switch(T1, false);
    	setDAC(0, true, vector_end);
    	TIMER_CounterSet(T2_TIMER, 0);
    	TIMER_Enable(T2_TIMER, true);
    	while(T2_TIMER->STATUS & TIMER_STATUS_RUNNING)
    		;
      	set_analog_switch(T1, true);
    	break;

    default:
    	break;
    }
  }
}