示例#1
0
int main(void)
{  

	delay_ms(100);
	led_setup();
	adc_init();
	LCD_SETUP(buffer);

	tcp_setup.Gateway = GateWay;//Gateway Address
	tcp_setup.MAC = MAC;
	tcp_setup.Source_IP = IP;//IP Address
	tcp_setup.Source_Port = 80; // Web Port
	tcp_setup.Subnet = SubNet;//SubnetMask Address
	tcp_setup.s = 0;
	tcp_socket_init(&tcp_setup);


	while(1)
	{
		if(check_for_connections(&tcp_setup)) // Wait for connection)
		{
			process_request(&tcp_setup);
			tcp_socket_init(&tcp_setup);
		}

		sprintf(buffer2,"%d",ADCRead(0));
		drawString8x12(10,60,buffer2);
	}

}
示例#2
0
int main(void)
{

  led_setup();
  led_on(LED_GREEN);
  led_on(LED_RED);

  /* Setup and hold the FPGA PROGRAM_B line low so that the FPGA does not
   * contest the flash SPI bus */
  nap_conf_b_setup();
  nap_conf_b_clear();

  spi_setup();
  sbp_setup(0);
  m25_setup();
  stm_flash_callbacks_setup();

  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

  printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");
  printf("--- M25 FLASH TEST ---\n");

  while (1) {
    DO_EVERY(300,
      led_toggle(LED_GREEN);
      led_toggle(LED_RED);
    );
    sbp_process_messages();
  }
示例#3
0
void init(void)
{
  /* Delay on start-up as some programmers reset the STM twice. */
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

  led_setup();

  nap_setup();

  s32 serial_number = nap_conf_rd_serial_number();
  if (serial_number < 0) {
    /* TODO: Handle this properly! */
    serial_number = 0x2222;
  }
  sbp_setup(serial_number);

  fault_handling_setup();

  nap_callbacks_setup();

  reset_callback_register();

  flash_callbacks_register();

  stm_unique_id_callback_register();
}
示例#4
0
int main(void)
{
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

	led_setup();

  rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3);

  debug_setup();

  printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");
  printf("--- DEBUG TEST ---\n");

  debug_register_callback(0x22, &foo_callback, &foo_callback_node);
  debug_register_callback(0x42, &led_callback, &led_callback_node);
  while(1)
  {
    debug_process_messages();
    for (u32 i = 0; i < 600000; i++)
      __asm__("nop");
  }

  while (1);
  
	return 0;
}
示例#5
0
文件: blink.c 项目: iddq/md380-re
int main(void) {

	led_setup();

	for(int i = 0; i < 4; i++) {

		red_led(1);
		green_led(1);

		sleep(500);

		red_led(0);
		green_led(0);

		sleep(500);

		red_led(1);

		sleep(500);

		red_led(0);

		sleep(500);
	}
	jump_to_app();
}
int main(void)
{
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

	led_setup();
  led_on(LED_GREEN);
  led_on(LED_RED);

  /* NAP is not required for this test. */
  nap_conf_b_setup();
  nap_conf_b_clear();

  sbp_setup(0, 0);

  while (1) {
    led_toggle(LED_RED);
    led_toggle(LED_GREEN);
    for (int i = 0; i < 10000; i++) /* Wait a bit. */
      __asm__("NOP");
    printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\r");
  }

	return 0;
}
示例#7
0
/* Our RESET handler is called instead of the official one, so this
   main() method comes before the official one.  Our global variables
   have already been initialized, but the MD380 firmware has not yet
   been initialized because we haven't called it.
   
   So the general idea is to initialize our stuff here, then trigger
   an early callback later in the MD380's main() function to perform
   any late hooks that must be applied to function pointers
   initialized in the stock firmware.
*/
int main(void) {
  dmesg_init();
  led_setup();
  
  //Done with the blinking, so start the radio application.
  printf("Starting main()\n");
  abort_to_mfgr_app();
}
示例#8
0
static void led_temperature(int led_idx, char temp)
{
	unsigned char weights[3];

	weights[CLR_R] = t2r(temp);
	weights[CLR_G] = t2g(temp);
	weights[CLR_B] = t2b(temp);
	led_setup(led_idx, weights);
}
示例#9
0
文件: fault.c 项目: iddq/md380-re
static void panic(void) {
	led_setup();
	green_led(0);
	for(;;){
		red_led(1);
		spin_sleep(200);
		red_led(0);
		spin_sleep(200);
	}
}
int main(void)
{
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

	led_setup();

  rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3);

  debug_setup();
  timer_setup();

  // Debug pins (CC1111 TX/RX)
  RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN;
	gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11);
  gpio_clear(GPIOC, GPIO10|GPIO11);


  printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");
  printf("--- DEBUG TEST ---\n");

  u32 len;

  for (u8 i=0; i<30; i++) {
    guard_below[i] = 0;
    guard_above[i] = 0;
  }

  for (u32 i=0; i<256; i++)
    buff_out[i] = (u8)i;

  while(1) {
    /* Random transmit length. */
    len = (u32)rand() % 256;
    while(debug_send_msg(0x22, len, buff_out));

    /* Check the guards for buffer over/underrun. */
    for (u8 i=0; i<30; i++) {
      if (guard_below[i] != 0)
        screaming_death();
      if (guard_above[i] != 0)
        screaming_death();
    }

    /* Introduce some timing jitter. */
    u32 jitter_delay = ((u32)rand() % 20000);
    for (u32 i = 0; i < jitter_delay; i++)
    /*for (u32 i = 0; i < 1000; i++)*/
      __asm__("nop");
  }
while (1);

	return 0;
}
示例#11
0
void pre_init(void)
{
  /* Delay on start-up as some programmers reset the STM twice. */
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

  led_setup();

  /* v2 NAP provides external clock input for the STM and
   * must be configured here. */
  nap_setup();
}
示例#12
0
void setup(){
    uart_init(UART_BAUD_SELECT_DOUBLE_SPEED(57600, F_CPU));
    //FIXME what was the following line for?
    //DDRD |= 0x02;
    pwm_setup();
    l7seg_setup();
    r0ketbeam_setup();
    input_setup();
    led_setup();
    config_setup();
    sei();
}
示例#13
0
int main(void)
{
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

	led_setup();

  rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3);

  usart_setup_common();
  usart_tx_dma_setup();

  /*printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");*/
  /*printf("--- USART DMA TEST ---\n");*/

  #define MAX_TX ((u32)(USART_TX_BUFFER_LEN*1.2))

  u8 guard_below[30];
  u8 buff_out[MAX_TX];
  u8 guard_above[30];
  u32 len;

  for (u8 i=0; i<30; i++) {
    guard_below[i] = 0;
    guard_above[i] = 0;
  }

  for (u32 i=0; i<MAX_TX; i++)
    buff_out[i] = (u8)i;

  while(1) {
    /* Random transmit length. */
    len = (u32)rand() % MAX_TX;
    while (len)
      len -= usart_write_dma(buff_out, len);

    /* Check the guards for buffer over/underrun. */
    for (u8 i=0; i<30; i++) {
      if (guard_below[i] != 0)
        screaming_death();
      if (guard_above[i] != 0)
        screaming_death();
    }

    /* Introduce some timing jitter. */
    for (u32 i = 0; i < ((u32)rand() % 10000); i++)
      __asm__("nop");
  }

  while (1);

	return 0;
}
void setup(void)
{
    led_setup();

    serial_setup();
    interrupt_setup();
    i2c_setup();

    INTCON3bits.INT2IF = 0;

    //Print a welcome message in case someone plugs it up
    printf("Welcome to the RVAsec Badge!\n\r\n\r");
}
int main(void)
{
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

	led_setup();

  rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3);

  debug_setup();
  timer_setup();

  // Debug pins (CC1111 TX/RX)
  RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN;
	gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11);
  gpio_clear(GPIOC, GPIO10|GPIO11);


  printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");
  printf("--- DEBUG RX STRESS TEST ---\n");

  static msg_callbacks_node_t callback_node;
  debug_register_callback(0x22, &callback, &callback_node);

  for (u8 i=0; i<30; i++) {
    guard_below[i] = 0;
    guard_above[i] = 0;
  }

  while(1) {
    /* Check the guards for buffer over/underrun. */
    for (u8 i=0; i<30; i++) {
      if (guard_below[i] != 0)
        screaming_death();
      if (guard_above[i] != 0)
        screaming_death();
    }

    debug_process_messages();

    //for (u32 i = 0; i < 1000; i++)
    //  __asm__("nop");
  }
while (1);

	return 0;
}
示例#16
0
文件: main.c 项目: area3001/knixx
int main(void)
{
	cm_disable_interrupts();
	clk_tree_setup();
	mco_setup();
	clock_setup();
	usb_setup();
	cli_setup();
	pwm_init();
	led_setup();
	button_setup();
	ncn_setup();
	cm_enable_interrupts();

	while (1) {
		__WFI();
	}

	return 0;
}
示例#17
0
文件: usart.c 项目: qiaoyuguo/stm32
int main(void)
{
	int i,c=0,j=0;

	led_setup();
    usart_setup();

	while (1) {

        gpio_toggle(GPIOF, GPIO_LEDS);
        usart_send_blocking(USART1, c + 'a');
        c = (c == 25) ? 0 : c+1 ;
        if((j++ % 80) == 0)
        {
            usart_send_blocking(USART1, '\r');
            usart_send_blocking(USART1, '\n');
        }
        for(i = 0; i < 800000; i++)
            __asm__("NOP");
    }
    return 0;
}
示例#18
0
/*static TCP_CONFIG tcp_setup;
uint8 MAC[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};//MAC Address
uint8 IP[4] = {192, 168, 1, 23};//IP Address
uint8 GateWay[4] = {192, 168, 1, 1};//Gateway Address
uint8 SubNet[4] = {255, 255, 255, 0};//SubnetMask Address
uint8_t Dest_IP[4] = {192, 168, 1, 103}; //DST_IP Address


uint8_t get_command();
float adc_calc = 0;
bool startup =false;
*/
int main(void)
{  

	char mystring[20];
	delay_ms(100);//100ms Delay
	led_setup();//Initial Setup for LEDs
	LCD_SETUP(buffer);//LCD Setup
	TEMP_SPI_Init();//Initialize SPI for Temperature Sensor


	LPC_GPIO1 -> FIODIR |= LED0 + LED1 + LED2 + LED3 + LED4 + LED5 + LED6 + LED7; // Define LEDs as outputs
	LPC_GPIO1 -> FIOPIN |= LED0 + LED1 + LED2 + LED3 + LED4 + LED5 + LED6 + LED7; // Assert lines high, aka turn off leds

	/*
	tcp_setup.Gateway = GateWay;//Gateway Address
	tcp_setup.MAC = MAC;
	tcp_setup.Source_IP = IP;//IP Address
	tcp_setup.Source_Port= 80; // Web Port
	tcp_setup.Subnet= SubNet;//SubnetMask Address
	tcp_setup.s= 0;
	tcp_socket_init(&tcp_setup);
*/
	//Separate code from ethernet module and temp sensor to avoid conflict with data line

	write_to_eight_bit_reg(0x40,0x00);//Writing to 8-bit registers for config and command bytes

	while(1)
	{
		delay_ms(480);
		/*if(check_for_connections(&tcp_setup)) // Wait for connection)
		{
			process_request(&tcp_setup);
			tcp_socket_init(&tcp_setup);


		}*/


		//LPC_GPIO1 -> FIOPIN ^= LED0 + LED1 + LED2;
		while(!SW0_PRESSED);//Used for debugging
		uint8_t receiveddata = read_a_eight_bit_reg( (1<<6)+ (1<<4));
		delay_ms(1000);
		setColor16(ST7735_16_BLUE);
		sprintf(mystring,"Temp: %d", receiveddata);

		drawString8x12(10,50,mystring);

		//Using leds for delay of 240ms to make it look nice and debug at the same time

		LPC_GPIO1 -> FIOPIN ^= LED0;
		delay_ms(5);
		LPC_GPIO1 -> FIOPIN ^= LED1;
		delay_ms(15);
		LPC_GPIO1 -> FIOPIN ^= LED2;
		delay_ms(25);
		LPC_GPIO1 -> FIOPIN ^= LED3;
		delay_ms(35);
		LPC_GPIO1 -> FIOPIN ^= LED4;
		delay_ms(45);
		LPC_GPIO1 -> FIOPIN ^= LED5;
		delay_ms(55);
		LPC_GPIO1 -> FIOPIN ^= LED6;
		delay_ms(65);
		LPC_GPIO1 -> FIOPIN ^= LED7;

	}

}
示例#19
0
文件: main.c 项目: Drooids/nrf
int main(void)
{
  uint8_t tx_addr[4] = { 0xaa, 0xab, 0xac, 0xad };
  uint8_t rx_addr[4] = { 0xa1, 0xa2, 0xa3, 0xa4 };

  sys_setup();

  uart_setup();

  /* setup spi first */
  spi_setup_master();
  spi_set_sck_freq(SPI_SCK_FREQ_FOSC2);

  nrf905_setup();
  nrf905_set_tx_addr(tx_addr, 4);
  nrf905_set_rx_addr(rx_addr, 4);
  nrf905_set_payload_width(2);
  nrf905_commit_config();

#if 0
  {
    uint8_t i;
    dump_config();
    for (i = 0; i != sizeof(nrf905_config); ++i)
      nrf905_config[i] = 0x2a;
    nrf905_cmd_rc();
    dump_config();
  }
#endif

#if 0
  {
    uint8_t x;
    uart_write((uint8_t*)"rx side\r\n", 9);
    uart_write((uint8_t*)"press space\r\n", 13);
    uart_read_uint8(&x);
    uart_write((uint8_t*)"starting\r\n", 10);
  }
#endif

  led_setup();

  nrf905_set_rx();

  while (1)
  {
  wait_cd:
    if (nrf905_is_cd() == 0)
    {
      led_set(LED_RED);
      while (nrf905_is_cd() == 0) ;
      /* uart_write((uint8_t*)"cd\r\n", 4); */
    }

#if 0
    while (nrf905_is_am() == 0) ;
    uart_write((uint8_t*)"am\r\n", 4);
    led_mask = LED_GREEN;
#endif

    led_set(LED_GREEN);

  wait_dr:
    while (nrf905_is_dr() == 0)
    {
      if (nrf905_is_cd() == 0) goto wait_cd;
    }
    uart_write((uint8_t*)"dr\r\n", 4);

    reset_pattern();

    /* wait(); */
    nrf905_read_payload();

    if (check_pattern() == 0)
    {
      uart_write((uint8_t*)"ok\r\n", 4);
      led_set(LED_BLUE);
    }
    else led_set(LED_GREEN);

    goto wait_dr;
  }

  return 0;
}
示例#20
0
文件: main.c 项目: MKozuch/EyeControl
int main(void)
{
    uart_setup(9600);

    led_setup();

    led_heartbeatInit();

    timer2_servoSetup();

    eyeControl_setup();
    eyeControl_init();

    for(uint8_t i = 0; i < 3; i++)
    {
        led_on(ALLLED);
        Delay_ms(200);
        led_off(ALLLED);
        Delay_ms(200);
    }

    sei();

    /*uint8_t ByteOfData;
    uint8_t ByteAddress = 46;
    ByteOfData = Eeprom_readByte(ByteAddress);
    ++ByteOfData;
    Eeprom_writeByte(ByteAddress, ByteOfData);
    logger_logVariable("eeprom @46: ", ByteOfData);*/

    int8_t ser = timer2_SERVO_NEUTRAL_PULSE;
    timer2_servoGotoNeutral();

    int16_t ticks = 0;
    Delay_ms(1);

    while(1)
    {
        logger_logVariable("", mean);

        led_off(ALLLED);

        // diode control
        if(ECSignal == LEFT) led_on(LEFTLED);
        else if(ECSignal == RIGHT) led_on(RIGHTLED);
        else if (ECSignal == REST) led_on(RESTLED);
        else if (ECSignal == CLIPPING) led_on(BLINKLED);

        // servo control
        if(ECSignal == LEFT && ticks%30 == 0) ser-=1;
        else if(ECSignal == RIGHT && ticks%30 == 0) ser+=1;
        else if (ECSignal == REST);
        else if (ECSignal == CLIPPING)
        {
            ser = timer2_SERVO_NEUTRAL_PULSE;
            timer2_servoGotoNeutral();
        }
        if(ser < timer2_SERVO_MIN_PULSE) ser = timer2_SERVO_MIN_PULSE;
        else if (ser > timer2_SERVO_MAX_PULSE) ser = timer2_SERVO_MAX_PULSE;
        timer2_servoSetPulseWidth(ser);

        Delay_ms(10);
        ticks += 1;
        ticks %= 1000;

    }
}
示例#21
0
/**
 * Entry point 
 */
int main(void) {

  /* Misc variables */
  DCPU_registers reg; // CPU registers states (at boot)

  /* Hardware initialisation */
  cli();
  led_setup();
  spi_setup(SPI_PRESCALER, SPI_MODE, SPI_BITS_ORDER);
  uart_setup(UART_BAUDRATE);
  DEBUG_STR("Main init", "UART ready");
  button_setup();
  buzzer_setup(BUZZER_FREQUENCY, BUZZER_DURATION);
  ram_setup();
  rom_setup();
  microvga_setup();
  microvga_enable();
  dcpu_register_init(&reg);
  DEBUG_STR("Main init", "done");
  sei();
  
  /* MicroVGA initialisation */
  _delay_ms(1000);         // MicroVGA boot time
  microvga_clear_screen(); // Clear screen and goto (0, 0)
  microvga_goto_cursor(0, 0);
  uart_puts_PSTR(PSTR("SkyWodd DCPU-16 hardware emulator")); // Screen test
  buzzer_beep();
  DEBUG_STR("Main init", "MicroVGA ready");
  
  /* Hardware self-test */
  DEBUG_STR("Main init", "self-test run");
  led_run_write(1); // Led test
  _delay_ms(250);
  led_run_write(0);
  led_cpu_write(1);
  _delay_ms(250);
  led_cpu_write(0);
  led_rom_write(1);
  _delay_ms(250);
  led_rom_write(0);
  led_ram_write(1);
  _delay_ms(250);
  led_ram_write(0);
  DEBUG_STR("Main init", "self-test done");
  
  /* Keyboard & MicroVGA api test */
  DEBUG_STR("Main init", "waiting for keypress");
  microvga_goto_cursor(0, 1);
  uart_puts_PSTR(PSTR("Press any key to boot ..."));
  keyboard_wait();
  uart_puts_PSTR(PSTR("Loading please wait ..."));
  dcpu_setup(reg);
  buzzer_beep();
  microvga_clear_screen();
  microvga_goto_cursor(0, 0);
  DEBUG_STR("Main init", "ready to run");
  
  /* Infinite loop */
  for(;;) {
  
    /* Handle pause */
    while(!button_get_state()); 
	
#ifdef SERIAL_DEBUG_SUPPORT
	/* Debug */
	dcpu_registers_dump();
#endif
	
	/* Fetch opcode from ROM */
    dcpu_step(); 
  }
  
}
示例#22
0
int main(void)
{
  for (u32 i = 0; i < 600000; i++)
    __asm__("nop");

	led_setup();

  // Debug pins (CC1111 TX/RX)
  RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN;
	gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11);
  gpio_clear(GPIOC, GPIO10|GPIO11);

  rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_130_944MHz_out_3v3);

  debug_setup();

  printf("\n\n# Firmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");

  swift_nap_setup();
  swift_nap_reset();
 
  led_toggle(LED_GREEN);
  led_toggle(LED_RED);

	u64 cw_power;
	float cw_freq;

	while(1) {

		printf("#PLOT_DATA_START\n");

		// Load CW ram
		cw_schedule_load(timing_count() + 1000);
		while (!(cw_get_load_done()));
		printf("# Finished loading cw ram\n");

		// Do CW detection
//		cw_start(-4e6,4e6,8e6/(SPECTRUM_LEN-1));
//		cw_start(0.5e6,0.7e6,0.2e6/(SPECTRUM_LEN-1));
    float cf = (1.575542*1e9-1.575420*1e9);
    float span = 200e3;
		cw_start(cf-span/2,cf+span/2,span/(SPECTRUM_LEN-1));
		while (!(cw_get_running_done()));
		printf("# Finished doing cw detection\n");

		for (u16 si=0;si<SPECTRUM_LEN;si++) {
			
			for (u32 dly = 0; dly < 50000; dly++)
				__asm__("nop");
			
			cw_get_spectrum_point(&cw_freq,&cw_power,si);
			
      if (~((cw_power == 0) && (cw_freq == 0))) {
//			printf("%+7.2f %lu # %d\n",cw_freq,(long unsigned int)cw_power,(unsigned int)si);
			printf("%+7.1f %lu\n",cw_freq,(long unsigned int)cw_power);
//			printf("%+4.2f %lu\n",cw_freq,(long unsigned int)cw_power);
      }
		
			u32 err = swift_nap_read_error_blocking();
			if (err) {
				printf("Error: 0x%08X\n", (unsigned int)err);
				while(1);
			}
		}

		printf("#PLOT_DATA_END\n");

	}

  while (1);
  
	return 0;
}