Пример #1
0
static int usb_flash_image(int partition, int filesize, unsigned long addr)
{
	if(partition >= 0)
	{
		char buffer[256];
		unsigned long addr_in_flash=0;

		switch(partition)
		{
			case 0:
				addr_in_flash=CFG_FLASH_BASE;	//	U-Boot
				printf("Update 'u-boot' partition...\n");
				break;

			case 1:
				addr_in_flash=CFG_ENV_ADDR;	//	U-Boot env
				printf("Update 'u-boot-env' partition...\n");
				break;

			case 2:
				addr_in_flash=CFG_LOAD_ADDR;	//	firmware
				printf("Update 'firmware' partition...\n");
				break;

			case 3:
				addr_in_flash=CFG_FLASH_BASE+OFFSET_MAC_DATA_BLOCK;	//	ART
				printf("Update 'art' partition...\n");
				break;

			case 4:
				addr_in_flash=CFG_FLASH_BASE;	//	full memory dump, all partitions
				printf("Update all partitions from binary dump...\n");
				break;
		}

		sprintf(buffer,
			"erase 0x%X +0x%X; cp.b 0x%X 0x%X 0x%X",
			addr_in_flash,
			filesize,
			addr,
			addr_in_flash,
			filesize);

		if(bsb_run(buffer))
		{
			blink_led(3,250);
			printf("Partition successfully updated\n");
			return 0;
		}
		else
		{
			blink_led(10,100);
			printf("Partition update failed\n");
			return -1;
		}
	}
}
Пример #2
0
int data_byte_rate(int rate){

	rate = rate*2;

	for(;;){
		long long int first = get_byte_received("eth1");
		long long int first_up = get_byte_trasmitted("eth1");

		long long int first2 = get_byte_received("eth0");
		long long int first_up2 = get_byte_trasmitted("eth0");

		sleep(2);

		long long int second2 = get_byte_received("eth0");
		long long int second_up2 = get_byte_trasmitted("eth0");

		long long int second = get_byte_received("eth1");
		long long int second_up = get_byte_trasmitted("eth1");

		// Calculate the data rate

		long long int difference = second - first;
		long long int difference2 = second2 - first2;

		long long int difference_up = second_up - first_up;
		long long int difference_up2 = second_up2 - first_up2;


		//printf("difference: %lld difference2: %lld \n",difference,difference2);
		//printf("difference up: %lld difference up2: %lld \n",difference_up, difference_up2);
		//printf("state: %d\n",plug_state());

		if(plug_state() == 1){
			command("ledctrl Ethernet On");
			if (difference != 0 || difference2 != 0){
				if (difference > rate || difference2 > rate){
					blink_led();
				}else{
					command("ledctrl Ethernet On");
				}

			}
			if (difference_up != 0 || difference_up2 !=0){
				if (difference_up > rate || difference_up2 > rate){
					blink_led();
				}else{
					command("ledctrl Ethernet On");
				}
			}
		}else{
			command("ledctrl Ethernet Off");
		}
	}
}
Пример #3
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Initialize chip */
  CHIP_Init();
  
  setupSWO();

  /* Enable HFXO */
  CMU_OscillatorEnable(cmuOsc_HFXO, true, true);

  /* Switch HFCLK to HFXO */
  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);

  /* Turn off HFRCO */
  CMU_OscillatorEnable(cmuOsc_HFRCO, false, false);

  BSP_LedsInit();

  while (1)
  {
    /* Blink led three times, with a factor 1 million delay */
    blink_led(1000000, 3);

    /* Turn on LFRCO */
    CMU_OscillatorEnable(cmuOsc_LFRCO, true, true);

    /* Select LFRCO */
    CMU_ClockSelectSet(cmuClock_HF, cmuSelect_LFRCO);

    /* Maximum prescaling for smalles frequency (64 Hz) */
    CMU_ClockDivSet(cmuClock_CORE, cmuClkDiv_512);

    /* Turn off HFXO */
    CMU_OscillatorEnable(cmuOsc_HFXO, false, false);

    /* Blink led three times, with a factor 1 delay */
    blink_led(1, 3);

    /* Turn on HFXO */
    CMU_OscillatorEnable(cmuOsc_HFXO, true, true);

    /* Select HFXO */
    CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);

    /* No prescaling for maximum clock frequency (32 MHz) */
    CMU_ClockDivSet(cmuClock_CORE, cmuClkDiv_1);

    /* Turn off LFRCO */
    CMU_OscillatorEnable(cmuOsc_LFRCO, false, false);
  }
}
Пример #4
0
int main()
{
	int idata n;
	//int idata i;
	int idata A_re[8];
	int idata A_im[8];
	//int idata W_re[4];
	//int idata W_im[4]; 
	//int idata A_re[16];
	//int idata A_im[16];
	//int idata W_re[8];
	//int idata W_im[8]; 

	
	store_cpu_rate(16);

	P0_DIR &= ~0x28;
	P0_ALT &= ~0x28;

	for(n=0;n<6;n++)
	{
		blink_led();
		mdelay(400);
	}
	//A_re = (double*)malloc(sizeof(double)*n); 
	//A_im = (double*)malloc(sizeof(double)*n); 
	//W_re = (double*)malloc(sizeof(double)*n/2); 
	//W_im = (double*)malloc(sizeof(double)*n/2); 
	//assert(A_re != NULL && A_im != NULL && W_re != NULL && W_im != NULL); 
	
	while(1)
	{
	//for (i=0; i<3; i++) {
		//init_array(n, A_re, A_im); 
		n = 8;
		blink_led();

		//compute_W(n, W_re, W_im); 
		//fft(n, A_re, A_im, W_re, W_im);
		permute_bitrev(n, A_re, A_im);

		mdelay(100);
	//}
	}
	//free(A_re); 
	//free(A_im); 
	//free(W_re); 
	//free(W_im); 
	//exit(0);
	return 0;
}
Пример #5
0
void teleop::spin_once(void)
{
  // Stabilize when not controlled.
  {
    _control.angular.x *= 0.9f;
    _control.angular.y *= 0.9f;
    _control.angular.z *= 0.9f;

    _control.linear.x *= 0.9f;
    _control.linear.y *= 0.9f;
    _control.linear.z *= 0.9f;
  }

  // Update values.
  {
    _x_i += (_control.linear.x - _x_prev) * _rate_ms / 1000.f;
    _x_d  = 1000.f * (_control.linear.x - _x_prev) / _rate_ms;

    _x_prev = _control.linear.x;
  }

  // Is ball detected or not ?
  if (_move && !_controlled_by_joy)
  {
    if (!_ball_detected && _ball_miss == 0)
    {
      // Set ball as detected.
      _ball_detected = true;

      // Reset PID values.
      _x_p = _x_i = _x_d = _x_prev = 0.f;

      blink_led(BLINK_GREEN, 5, 1);
    }

    if (_ball_detected && _ball_miss > NUM_MISS_FOR_LOST)
    {
      _ball_detected = false;
      blink_led(BLINK_ORANGE, 5, 1);
    }

    // Update ball miss.
    _ball_miss++;
  }

  // Publish velocity.
  _ardrone_velocity_publisher.publish(_control);
}
Пример #6
0
int
cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
    size_t newlen, struct proc *p)
{
	int oldval, ret;

	/* all sysctl names at this level are terminal */
	if (namelen != 1)
		return (ENOTDIR);		/* overloaded */

	switch (name[0]) {
	case CPU_CONSDEV: {
		dev_t consdev;
		if (cn_tab != NULL)
			consdev = cn_tab->cn_dev;
		else
			consdev = NODEV;
		return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
		    sizeof consdev));
	}

	case CPU_LED_BLINK:
		oldval = led_blink;
		ret = sysctl_int(oldp, oldlenp, newp, newlen, &led_blink);
		if (oldval != led_blink)
			blink_led(NULL);
		return (ret);

	default:
		return (EOPNOTSUPP);
	}
	/* NOTREACHED */
}
Пример #7
0
void power_sim(void) {
	P2OUT |= SIM_POW;
	delay_ms(2000);
	P2OUT &= ~SIM_POW;
	delay_ms(10000);
	blink_led(LED_GREEN, 2);
}
Пример #8
0
/*
 * ----------------------------------------------------
 * Default blink action on the LED.
 * ----------------------------------------------------
 */
int led_default_blink(char *led_name, char *blink_type)
{
    /* Generic error reporter */
    int rc = -1;

    /* How long the LED needs to be in on and off state while blinking */
    const char *on_duration = NULL;
    const char *off_duration = NULL;
    if(strcmp(blink_type, "setBlinkSlow") == 0)
    {
        //*Delay 900 millisec before 'on' and delay 900 millisec before off */
        on_duration = "900";
        off_duration = "900";
    }
    else if(strcmp(blink_type, "setBlinkFast") == 0)
    {
        /* Delay 200 millisec before 'on' and delay 200 millisec before off */
        on_duration = "200";
        off_duration = "200";
    }
    else
    {
        fprintf(stderr,"Invalid blink operation:[%s]\n",blink_type);
        return rc;
    }

    rc = blink_led(led_name, on_duration, off_duration);

    return rc;
}
Пример #9
0
boolean load_address(uint64_t *addr,uint8_t number){
	blink_led();
	uint32_t position;
	boolean sucess;
	*addr=0;
	position=((number)*8);
	file=SD.open("addr.lst",FILE_READ);
	if (file){
		sucess=file.seek(position);
		if (sucess==false || position==file.size()){
			return false;
		}
		uint8_t buffer[8]={NULL};
		for(int i=0;i<8;i++){
			buffer[i]=(uint8_t)file.read();
		}
		for (int i=7;i>=0;i--){
			*addr|=buffer[i];
			if (i!=0)
			*addr=*addr<<8;
		}
	}else{
		printf("file error\r\n");
		return false;
	}
	file.close();
	return sucess;
}
Пример #10
0
void main()
{

	char i;
	idata SHA1Context sha;

	store_cpu_rate(16);

    P0_DIR &= ~0x28;
    P0_ALT &= ~0x28;

	serial_init(19200);


	for(i=0;i<6;i++)
	{
		blink_led();
		mdelay(400);
	}	
	
	sha_counter++;

	while(1)
	{
		SHA1Reset(&sha);
		SHA1Input(&sha, (const unsigned char *) TESTA, 3);

		SHA1Result(&sha);
		sha_counter++;
		//blink_led();
		int_print(sha_counter);
		puts("\r\n");
	}	

}
Пример #11
0
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  switch (id) {
    // The OS-Toggle function toggles our concept of mac or windows
    case FNOSTOGGLE:
      if (IS_RELEASED(record->event)) {
        is_mac = !is_mac;
        // Blink blue for mac, red otherwise
        blink_led(is_mac ? 3 : 1);
      }
      return;

    // The copy-cut function sends the copy key sequence for mac or windows
    // when it is pressed.  If shift is held down, it will send the cut key
    // sequence instead, and cancels the shift modifier.
    case FNCOPYCUT:
      if (IS_RELEASED(record->event)) {
        int8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));

        // Implicitly release the shift key so that it doesn't
        // mess with the macro that we play back
        unregister_mods(shifted);

        if (shifted) {
          action_macro_play(is_mac ? mac_cut : win_cut);
        } else {
          action_macro_play(is_mac ? mac_copy : win_copy);
        }
      }
      return;
  }
}
Пример #12
0
static int check_packet_count(int fd) {
    struct lux_packet response;
    struct lux_packet packet2 = {
        .destination = ADDRESS, 
        .command = LUX_CMD_GET_PKTCNT,
        .index = 0,
        .payload_length = 0,
    };
    int rc = lux_command(fd, &packet2, &response, LUX_RETRY);
    if (rc < 0) {
        PERROR("Packet check count failed");
        return -1;
    }

    printf("Received packet for %#08x; cmd=%#02x; idx=%d; plen=%d; data=",
            response.destination, response.command, response.index, response.payload_length);
    uint32_t *x = (uint32_t *) response.payload;
    /*
    uint32_t good_packet;
    uint32_t malformed_packet;
    uint32_t packet_overrun;
    uint32_t bad_checksum;
    uint32_t rx_interrupted;
    */
    printf("good:%d malfm:%d ovrun:%d badcrc:%d rxint:%d xaddr:%d\n", x[0], x[1], x[2], x[3], x[4], x[5]);
    return 0;
}


static int blink_led(int fd, uint32_t addr, int count) {
    struct lux_packet packet = {
        .destination = addr, 
        .command = LUX_CMD_SET_LED,
        .index = 0,
        .payload_length = 1,
    };
    struct lux_packet response;

    while (count--) {
        packet.payload[0] = 1;
        int rc = lux_command(fd, &packet, &response, LUX_ACK | LUX_RETRY);
        if (rc < 0) PERROR("Unable to write LED on msg");
        usleep(100000);

        packet.payload[0] = 0;
        rc = lux_command(fd, &packet, &response, LUX_ACK | LUX_RETRY);
        if (rc < 0) PERROR("Unable to write LED off msg");
        usleep(100000);
    }

    return 0;
}

int main(void) {
    //int fd = lux_uri_open("serial:///dev/ttyACM0");
    int fd = lux_uri_open("udp://127.0.0.1:1365");
    check_packet_count(fd);
    blink_led(fd, 0xFFFFFFFF, 10);
    return 0;
}
Пример #13
0
void ram(void) {

	splash_scene();

	long frame_count = 0;
	init_game();

	while(1) {
		frame_count++;

		lcdFill(0);
		update_platforms(frame_count);
		move_player(frame_count);
		draw_platforms();
		draw_player();
		draw_hud();
		blink_led();
		lcdDisplay();

		if(!game.running) {
			if(!gameover_scene()){
                delayms_queue_plus(10,1);
				return;
            }
			init_game();
		}
        delayms_queue_plus(24,0);
	}
}
Пример #14
0
int main(void) {
	initSleep();
	*((int*)GPREG0)=0;
	while(1){
		/*
		blink_led();
		runFib(3);
		runFib(3);
		blink_led();
		blink_led();
		*/
		runFib(48);
		runFib(24);
		runFib(12);
		runFib(3);
		//fibonacci(30);
		EnterDeepSleep();
		//test_int++;
		(*(int*)GPREG0)++;
		int wakeTemp=*((int*)GPREG0);
		//int wakeTemp = test_int+1;

		for(i=0;i<wakeTemp;i++){
			blink_led();
		}
	}
}
Пример #15
0
void add_names_to_devices(){
	uint8_t i=0;
	uint64_t mask=0xFFFFFFFFFF000000LL;
	dev device;
	uint8_t tam;
	printf("Please add names to the devices\r\n");
	while(load_address(&RFbuffer.destino,i)){
		blink_led();
		device.addr=RFbuffer.destino;
		RFbuffer.comando=all_on;
		radio.stopListening();
		radio.openWritingPipe((RFbuffer.destino & mask));
		radio.write(&RFbuffer,sizeof(RFbuffer));
		radio.startListening();
		printf("enter name for device:%d,with addr:%lX%08lX\r\n",i+1,(uint32_t)(device.addr>>32),(uint32_t)device.addr);
		while(!Serial.available());
		do {
			blink_led();
			tam=Serial.readBytes(device.name,sizeof(device));
			if (tam>=sizeof(device.name)){
				printf("name must be smaller than 7 letter\r\n");
			}else{
				device.name[tam]='\0';
				printf("device name set to:");
				int n=0;
				do{
					printf("%c",device.name[n]);
					n++;
				} while (device.name[n]!='\0');
				printf("\r\n");
				file=SD.open("devs.lst",FILE_WRITE);
				if (file){
					file.write((byte *)&device,sizeof(device));
				}
				file.close();
			}
		} while (tam>=sizeof(device.name));
		RFbuffer.comando=all_off;
		radio.stopListening();
		radio.openWritingPipe((RFbuffer.destino & mask));
		radio.write(&RFbuffer,sizeof(RFbuffer));
		radio.startListening();
		i++;
	}
	printf("done\r\n");
	return;
}
Пример #16
0
void blink_fast()
{
	int i;
	mdelay(400);
	for(i=0;i<12;i++)	
	{
		blink_led();	
		mdelay(400);
	}
}
Пример #17
0
void save_new_address(uint64_t *addr){
	blink_led();
	printf("addr:%lX%08lX added to addr.lst file.\r\n",(uint32_t)(*addr>>32),(uint32_t)*addr);
	file=SD.open("addr.lst",FILE_WRITE);
	if (file){
		file.write((byte *)addr,8);
	}
	file.close();
	return;
}
Пример #18
0
void blink2()
{
	int i;
	for(i=0;i<4;i++)
	{
		blink_led();
		mdelay(400);
	}
	mdelay(1000);	
}
Пример #19
0
void run_task(uint8_t *Task)
{
	switch(Task[2])
	{
		case '0':
		send_string("boot");
		break;
		case '1':
		page_address = Task[9] << 8;
		page_address |= Task[8];
		readFlashPage(page_address, 128);
		send_buff(gBuffer, 128);
		Task[2] = 0;
		break;
		case '2':
		Task[2] = 0;
		break;
		case '3':
		page_address = Task[9] << 8;
		page_address |= Task[8];
		for (uint16_t i = 0; i < SPM_PAGESIZE; i++)
		gBuffer[i] = data_buffer[i + 16];
		writeFlashPage(page_address,SPM_PAGESIZE);
		send_string("page done");
		Task[2] = 0;
		break;
		case '4':
		eraseFlash();
		send_string("erase ok");
		Task[2] = 0;
		break;
		case '5':
		Task[2] = 0;
		break;
		case '6':
		fill_page();
		send_buff(gBuffer, 256);
		Task[2] = 0;
		break;
		case '7':
		blink_led();
		Task[2] = 0;
		break;
		case '8':
		MCUCR |= 1<<IVCE;
		MCUCR = 0<<IVSEL;
		send_string("jump ok");
		jump_to_app();		// Jump to application sector
		Task[2] = 0;
		break;
		default:
		Task[2] = 0;
	}
}
Пример #20
0
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_TIM1_Init();
  MX_TIM2_Init();

  /* USER CODE BEGIN 2 */
	HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
	HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);
	HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);
	HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_3);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	while (1) {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
		blink_led(&htim2, TIM_CHANNEL_1);
		blink_led(&htim1, TIM_CHANNEL_1);
		blink_led(&htim1, TIM_CHANNEL_2);
		blink_led(&htim1, TIM_CHANNEL_3);
	}
  /* USER CODE END 3 */

}
Пример #21
0
static void openwrt_factory_reset()
{
	struct jffs2_unknown_node *node;
	
	u32 i;
	u32 crc;
	printf("Searching for JFFS2 filesystem\n");
	for (i = CFG_LOAD_ADDR; i < CFG_LOAD_ADDR + 0xFC0000; i++)
	{
		node = (struct jffs2_unknown_node *) i;
		if (node->magic == JFFS2_MAGIC_BITMASK)
		{
			crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
			if (crc == node->hdr_crc)
			{
				printf("JFFS2 Magic Bitmask with correct CRC at 0x%X\n", node);
				printf("Replacing Magic Bitmask with 0xDEADCODE...\n");
				static unsigned char eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};
				static unsigned char *pad = eof_mark;
				char buffer[256];
				sprintf(buffer,
						"erase 0x%X +0x%X; cp.b 0x%X 0x%X 0x%X",
						node, 4, pad, node, 4);
				if(bsb_run(buffer))
				{
					blink_led(3,250);
					printf("Done\n");
				}
				else
				{
					blink_led(10,100);
					printf("Error writing to flash\n");
				}
				bsb_run("reset");
			}
		}
	}
	printf("JFFS2 not found.\n");
	blink_led(10,100);
}
Пример #22
0
int main (void) {
  /* Main Thread of the TcpNet */

  init ();
  LEDrun = __TRUE;
  dhcp_tout = DHCP_TOUT;
  while (1) {
    timer_poll ();
    main_TcpNet ();
    dhcp_check ();
    blink_led ();
  }
}
Пример #23
0
Файл: main.c Проект: iotbot/oss7
void rx_callback(Trans_Rx_Query_Result* rx_res)
{
	system_watchdog_timer_reset();

	blink_led();

	dll_foreground_frame_t* frame = (dll_foreground_frame_t*) (rx_res->nwl_rx_res->dll_rx_res->frame);
	log_print_string("Received Query from :%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x;",
					frame->address_ctl->source_id[0] >> 4, frame->address_ctl->source_id[0] & 0x0F,
					frame->address_ctl->source_id[1] >> 4, frame->address_ctl->source_id[1] & 0x0F,
					frame->address_ctl->source_id[2] >> 4, frame->address_ctl->source_id[2] & 0x0F,
					frame->address_ctl->source_id[3] >> 4, frame->address_ctl->source_id[3] & 0x0F,
					frame->address_ctl->source_id[4] >> 4, frame->address_ctl->source_id[4] & 0x0F,
					frame->address_ctl->source_id[5] >> 4, frame->address_ctl->source_id[5] & 0x0F,
					frame->address_ctl->source_id[6] >> 4, frame->address_ctl->source_id[6] & 0x0F,
					frame->address_ctl->source_id[7] >> 4, frame->address_ctl->source_id[7] & 0x0F);
	log_print_string("RSS: %d dBm", rx_res->nwl_rx_res->dll_rx_res->rssi);
	log_print_string("Netto Link: %d dBm", rx_res->nwl_rx_res->dll_rx_res->rssi  - frame->frame_header.tx_eirp);

	switch (rx_res->d7aqp_command.command_code & 0x0F)
	{
		case D7AQP_OPCODE_ANNOUNCEMENT_FILE:
		{
			D7AQP_Single_File_Return_Template* sfr_tmpl = (D7AQP_Single_File_Return_Template*) rx_res->d7aqp_command.command_data;
			log_print_string("D7AQP File Announcement received");
			log_print_string(" - file 0x%x starting from byte %d", sfr_tmpl->return_file_id, sfr_tmpl->file_offset);
			log_print_data(sfr_tmpl->file_data, sfr_tmpl->isfb_total_length - sfr_tmpl->file_offset);

			log_print_string(" isfb_total_length %d", sfr_tmpl->isfb_total_length);
		}
	}

	if (rx_res->d7aqp_command.command_extension & D7AQP_COMMAND_EXTENSION_NORESPONSE)
	{
		// Restart channel scanning
		start_channel_scan = true;
	} else {
		// send ack
		// todo: put outside interrupt
		// todo: use dialog template

		command.command_code = D7AQP_COMMAND_CODE_EXTENSION | D7AQP_COMMAND_TYPE_RESPONSE | D7AQP_OPCODE_ANNOUNCEMENT_FILE;
		command.command_extension = D7AQP_COMMAND_EXTENSION_NORESPONSE;
		command.dialog_template = NULL;
		command.command_data = NULL;

		led_on(3);
		trans_tx_query(&command, 0xFF, RECEIVE_CHANNEL, TX_EIRP);
	}

}
Пример #24
0
void main() 
{
	idata char i,j,k = 5;

	store_cpu_rate(16);
	/* init led */
	P0_DIR &= ~0x28;
	P0_ALT &= ~0x28;

	for (i = 0; i < 6; i++) {
		blink_led();
		mdelay(400);
	}
	/* init serial */
	serial_init(19200);

	while(1)
	{
		/* make a fully connected matrix */
		for (i=0;i<NUM_NODES;i++) {
			for (j=0;j<NUM_NODES;j++) {
				/* make it more sparce */
				AdjMatrix[i][j]= k;
				k++;
			}
		}

		/* finds 10 shortest paths between nodes */
		for (i=0,j=NUM_NODES/2;i<10;i++,j++) {
			j=j%NUM_NODES;
			dijkstra(i,j);
		}
	
		blink_led();
		//mdelay(100);
	}	

}
Пример #25
0
void ECO_PAGE_MANAGER()
{
	unsigned int i;	

	#pragma asm
		;POP LCALL ADDR_HIGHT
		POP	SP_ADDR_H+01H
		MOV	SP_ADDR_H,#00H

		;POP LCALL ADDR_LOW	
		POP	SP_ADDR_L+01H
		MOV	SP_ADDR_L,#00H
		
		;POP Function Address
		POP	PAGE_ADDR_H+01H
		MOV	PAGE_ADDR_H,#00H

		POP	PAGE_ADDR_L+01H
		MOV  	PAGE_ADDR_L,#00H

	#pragma endasm	
	
	//Check POP instruction 
	for(i=0;i<PAGE_ADDR_H;i++)
	{	
		blink_led();
		mdelay(400);
	}	
	
	//Check Table	
		

	
	//Set Return Address Back
	#pragma asm

		CLR	A
		MOV	A,SP_ADDR_L	
		PUSH	ACC	

		CLR	A
		MOV	A,SP_ADDR_H
		PUSH	ACC

		RET	
	#pragma endasm
	
}
Пример #26
0
void get_user_input(char *buffer,size_t tamanho){
	blink_led();
	size_t tam;
	while(!Serial.available());
	if (tamanho>1){
		tam=Serial.readBytes(buffer,tamanho);
		*(buffer+tam)='\0';
	}else{
		tam=1;
		*buffer=Serial.read();
	}
	for(int i=0;i<tam;i++)
		printf("%c",*(buffer+i));
	printf("\r\n");
	return;
}
Пример #27
0
void SHA1Reset(SHA1Context idata *context)
{
    context->Length_Low             = 0;
    context->Length_High            = 0;
    context->Message_Block_Index    = 0;

    context->Message_Digest[0]      = 0x67452301;
    context->Message_Digest[1]      = 0xEFCDAB89;
    context->Message_Digest[2]      = 0x98BADCFE;
    context->Message_Digest[3]      = 0x10325476;
    context->Message_Digest[4]      = 0xC3D2E1F0;

    context->Computed   = 0;
    context->Corrupted  = 0;
	blink_led();
}
Пример #28
0
boolean save_to_file(char *nome,uint8_t *what,size_t tamanho,uint8_t onde){
	blink_led();
	uint32_t pos;
	pos=onde*tamanho;
	file=SD.open(nome,FILE_WRITE);
	if (file){
		if (file.seek(pos)==false || pos==file.size()){
			return false;
		}
		file.write(what,tamanho);
		file.close();
		return true;
	}else{
		printf("file error\r\n");
		return false;
	}
}
Пример #29
0
int main() 
{
	char i, j , k = 5;
	//char u = 1, v = 2, w = 4;

	store_cpu_rate(16);

	P0_DIR &= ~0x28;
	P0_ALT &= ~0x28;

	serial_init(19200);

	for(n=0;n<6;n++)
	{
		blink_led();
		mdelay(400);
	}

	n = GRAPHSIZE;


	while(1)
	{
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				dist[i][j] = (k++)%30;
		//n = -1;
		//for (i = 0; i < 6; i++) {
		//fscanf(fin, "%d%d%d", &u, &v, &w);
		//	dist[u][v] = w++;
		//	n = MAX(u, MAX(v+w, n));
		//}
		//fclose(fin);
		for(j=0;j<n;j++)	
			dijkstra(j);

		dij_counter++;

		int_print(dij_counter);
		puts("\r\n");
		
		printD();
	}

	return 0;
}
Пример #30
0
int main()
{
	unsigned char idx;
	unsigned int i = 0;
	store_cpu_rate(16);
	P0_DIR &= ~0x28;
	P0_ALT &= ~0x28;

	rf_init();
	rf_configure(cfg);
	serial_init(19200);	
	eco_page_init();
	
	//long_function(4,6,8,4);

	msg[0] = 0x0A;
	msg[1] = 0x00;
	/* ADDR */
	msg[2] = 0x02;
	msg[3] = 0xA0;
	/* LEN */
	msg[4] = 0x02;
	msg[5] = 0xDD;
	msg[6] = 0xCC;
	
	for(idx = 4; idx > 0; idx--)
	{
		blink_led();		
		mdelay(300);
	}

	mdelay(1000);

	while(1)
	{
		blink4();
		rf_send(dst_addr, 3, msg, 7);
		blink2();
		mdelay(200);	
		blink6();
	}

	return 0;
}