Exemplo n.º 1
0
void ui_usb_sof_event(void)
{
	static uint16_t counter_sof = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			LED_Toggle(LED0_GPIO);
		}
	}
}
Exemplo n.º 2
0
int Spark_Save_Firmware_Chunk(FileTransfer::Descriptor& file, const uint8_t* chunk, void* reserved)
{
    TimingFlashUpdateTimeout = 0;
    int result = -1;
    system_notify_event(firmware_update, firmware_update_progress, &file);
    if (file.store==FileTransfer::Store::FIRMWARE)
    {
        result = HAL_FLASH_Update(chunk, file.chunk_address, file.chunk_size, NULL);
        LED_Toggle(LED_RGB);
    }
    return result;
}
Exemplo n.º 3
0
Arquivo: LED.c Projeto: mdunne/ANIMA
/****************************************************************************
 Function: LED_InvertBank

 Parameters
     bank: one of the #define'd LED_BANKx values.
     pattern: char, which LEDs to toggle.

 Returns
     char: SUCCESS or ERROR

 Description
     Forces the LEDs in (bank) to toggle for each bit that is high in the pattern.

 Notes: none.

 Author: Gabriel Hugh Elkaim, 2011.12.25 01:16
 ****************************************************************************/
char LED_InvertBank(unsigned char bank, unsigned char pattern) {
    char i;
    pattern &= FULLBANK;
    if (ledStatus.led_on == FALSE) return ERROR;
    if ((bank & LED_BANK1) && (ledStatus.one_on)) {
        for (i = 0; i < NUMLEDSPERBANK; i++) {
            if (pattern & (1 << i)) LED_Toggle(i);
        }
        return SUCCESS;
    }
    return ERROR;
}
Exemplo n.º 4
0
void
SysTickHandler(void)
{
    g_ulTickCount++;
    cofanie++;

    if((g_ulTickCount % 100) == 0)
    {
        LED_Toggle(BOTH_LEDS);
    }
    PushButtonDebouncer();
    BumpSensorDebouncer();
}
Exemplo n.º 5
0
int main( void )
{
  bsp_gpio_init();
  bsp_temp_init();
  bsp_serial_init(NULL);

  while (1) {
    LED_Toggle();
    delay_ms(100);

    printf("chip temperature : %.2f degC\r\n", TEMP_GetTemperature());
  }
}
Exemplo n.º 6
0
static bool appDataInd(NWK_DataInd_t *ind)
{
  AppMessage_t *msg = (AppMessage_t *)ind->data;

  LED_Toggle(LED_DATA);

  msg->lqi = ind->lqi;
  msg->rssi = ind->rssi;
#if APP_COORDINATOR
  appSendMessage(ind->data, ind->size);
#endif  
  return true;
}
Exemplo n.º 7
0
/**
 * \brief Toggle led at the given time.
 *
 * \param ul_dly_ticks  Delay to wait for, in milliseconds.
 *
 * \return Led toggle times.
 */
static uint32_t toggle_led_test(uint32_t ul_dly_ticks)
{
	int32_t ul_cnt = 0;
	uint32_t ul_cur_ticks;

	ul_cur_ticks = g_ul_ms_ticks;
	do {
		ul_cnt++;
		LED_Toggle(LED0);
	} while ((g_ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks);

	return ul_cnt;
}
Exemplo n.º 8
0
void ui_usb_sof_event(void)
{
	bool b_btn_state;
	static bool btn_suspend = false;
	static uint16_t counter_sof = 0;
	static uint16_t counter_sof_move_refresh = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			if (ui_hid_mouse_plug || ui_msc_plug) {
				LED_Toggle(LED0);
			} else {
				LED_On(LED0);
			}
			if (ui_test_done && !ui_test_result) {
				/* Test fail then blink BL */
				backlight_toggle();
			}
		}
		/* Scan button to enter in suspend mode and remote wakeup */
		b_btn_state = (!ioport_get_pin_level(GPIO_PUSH_BUTTON_0)) ?
				true : false;
		if (b_btn_state != btn_suspend) {
			/* Button have changed */
			btn_suspend = b_btn_state;
			if (b_btn_state) {
				/* Button has been pressed */
				LED_Off(LED0);
				backlight_off();
				ui_enable_asynchronous_interrupt();
				uhc_suspend(true);
				return;
			}
		}

		/* Move the remote mouse pointer on the Board Monitor screen */
		if (++counter_sof_move_refresh > 100) {
			counter_sof_move_refresh = 0;
			bm_mouse_pointer_move(bm_x / 8, bm_y / 8);
		}

		/* Power on a LED when the mouse button down */
		if (ui_nb_down) {
			LED_On(LED0);
		}
	}
}
__interrupt
#endif
static void tc_irq(void)
{
	// Increment the ms seconds counter
	tc_tick++;

	// Clear the interrupt flag. This is a side effect of reading the TC SR.
	tc_read_sr(EXAMPLE_TC, EXAMPLE_TC_CHANNEL);

	// specify that an interrupt has been raised
	update_timer = true;
	// Toggle a GPIO pin (this pin is used as a regular GPIO pin).
	LED_Toggle(LED0);
}
Exemplo n.º 10
0
void FastBlink()
{
	LED_Off(LED0|LED1|LED2|LED3);

	unsigned int counter = 0;

	while (1)
	{
		//if (counter % 1)
		LED_Toggle(LED0);

		if (counter % 2)
		LED_Toggle(LED1);

		if (counter % 4)
		LED_Toggle(LED2);

		if (counter % 8)
		LED_Toggle(LED3);

		counter++;
		cpu_delay_ms(2, FOSCRC);
	}
}
Exemplo n.º 11
0
/**
 * \brief Main code entry point.
 */
int main( void )
{
	/* Prepare the hardware */
	prvSetupHardware();

	/* Usi initialization */
	usi_init();

	/* Initialize USI communication structure */
	x_phy_serial_msg.uc_protocol_type = PROTOCOL_USER_DEFINED;

	while (1) {
		usi_process();
		/* blink led 0 */
		if (b_led_swap) {
			b_led_swap = false;
#if (BOARD == SAM4CMP_DB || BOARD == SAM4CMS_DB)
			LED_Toggle(LED4);
#else
			LED_Toggle(LED0);
#endif
		}
	}
}
Exemplo n.º 12
0
/**
   * @brief Reports the name of the source file and the source line number
   * where the assert_param error has occurred.
   * @param file: pointer to the source file name
   * @param line: assert_param error line source number
   * @retval None
   */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  MX_IWDG_Init();
  for (;;) {
	  /* Fast blinking LED */
    __HAL_IWDG_RELOAD_COUNTER(&hiwdg);
    LED_Toggle();
	  HAL_Delay(70);
  }
  /* USER CODE END 6 */

}
/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
void SysTick_Handler(void)
{
	static uint8_t count_time=0;
  OS_TimeMS ++;
	
	count_time++;
	if(count_time == 10)
	{
		GUI_TOUCH_Exec();			//每10ms调用一次,触发调用触摸驱动
		count_time =0;
	}	
  
	LED_Toggle();						//每100ms反转一次led
	
	
}
Exemplo n.º 14
0
Arquivo: ui.c Projeto: InSoonPark/asf
void ui_usb_sof_event(void)
{
	static uint16_t counter_sof = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			LED_Toggle(LED_0_PIN);
			if (ui_test_done && !ui_test_result) {
				/* Test fail */
				LED_Off(LED_0_PIN);
			}
		}
	}
}
/****************************************************************************************************
 * @fn      I2C_Slave_Wait_Completion
 *          This function allows application to pend on completion for slave transfer
 *
 ***************************************************************************************************/
static void I2C_Slave_Wait_Completion( void )
{
    OS_RESULT result;
    static uint32_t dessimate = 0;

    result = os_evt_wait_or( I2C_SLAVE_XFER_DONE, MSEC_TO_TICS(500));
    if (result == OS_R_TMO)
    {
        dessimate++;
        if ((dessimate & 0x1) == 0)
        {
            SensorHubIntLow(); //Deassert Interrupt
            //D1_printf("\t### WARNING - Timedout on I2C Slave completion (%d) ###\r\n", dessimate);
            LED_Toggle(LED_YELLOW);
        }
    }
}
Exemplo n.º 16
0
Arquivo: ui.c Projeto: InSoonPark/asf
void ui_usb_sof_event(void)
{
	bool b_btn_state;
	static bool btn_suspend = false;
	static uint16_t counter_sof = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			if (ui_hid_mouse_plug || ui_msc_plug) {
				LED_Toggle(LED0);
			} else {
				LED_On(LED0);
			}
			if (ui_test_done) {
				if (ui_test_result) {
					/* Test successful */
					LED_On(LED0);
				} else {
					/* Test fail */
					LED_Off(LED0);
				}
			}
		}
		/* Scan button to enter in suspend mode and remote wakeup */
		b_btn_state = (!ioport_get_pin_level(GPIO_PUSH_BUTTON_0)) ?
				true : false;
		if (b_btn_state != btn_suspend) {
			/* Button have changed */
			btn_suspend = b_btn_state;
			if (b_btn_state) {
				/* Button has been pressed */
				LED_Off(LED0);
				ui_enable_asynchronous_interrupt();
				uhc_suspend(true);
				return;
			}
		}

		/* Power on a LED when the mouse button down */
		if (ui_nb_down) {
			LED_On(LED0);
		}
	}
}
Exemplo n.º 17
0
void app_alert()
{

    while (1)
    {
     
		#if LED_COUNT > 0
		LED_Toggle(LED0);
		#endif

		#if LED_COUNT > 1
		LED_Toggle(LED1);
		#endif

		#if LED_COUNT > 2
		LED_Toggle(LED2);
		#endif

		#if LED_COUNT > 3
		LED_Toggle(LED3);
		#endif

		#if LED_COUNT > 4
		LED_Toggle(LED4);
		#endif

		#if LED_COUNT > 5
		LED_Toggle(LED5);
		#endif

		#if LED_COUNT > 6
		LED_Toggle(LED6);
		#endif

		#if LED_COUNT > 7
		LED_Toggle(LED7);
		#endif
                delay_us(0xFFFF);
	}
        
        

    }
Exemplo n.º 18
0
portTASK_FUNCTION(LED_Run_Task, pvParameters)
{
	while(1)
	{
//		while (xSemaphoreTake(DALI_LEDs_Task_Signal, 10) == pdTRUE) // 10ms timeout
//		{
//			uint8_t i = 10;
//			while(i--)
//			{
//				DALI_LED_Toggle();
//				vTaskDelay(20);
//			}
//		}
		LED_Toggle();
		vTaskDelay(300);
	}
//	vTaskDelete(NULL);
}
Exemplo n.º 19
0
int main(void) {
uint32_t t;
uint32_t sindex = 0;
int i;

    SystemCoreClockSet(MSI48M_CLOCKSRC,0,2,0);

    SysTick_Config(SystemCoreClock/1000);

    APBPeripheralClockSet(0,0); /* Enable APBx */

    RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; /* Enable SysConfig, Comp, etc. */

    t = LED_Init(LED_ALL);

    t = LCD_Init();

    result = t;

    LED_Toggle(LED_GREEN);

    LCD_WriteString("hello");
    Delay(10000);

    LCD_WriteSegments(allsegs);
    Delay(10000);

    LCD_WriteToRAM(alldispsegs);
    Delay(10000);


    LCD_Clear();


    for (;;) {
        for(i=0;i<6;i++) {
            segs[i] = sorder[sindex];
        }
        LCD_WriteSegments(segs);
        Delay(2000);
        sindex++;
        if( sindex >= sizeof(sorder)/sizeof(uint32_t)) sindex = 0;
    }
}
Exemplo n.º 20
0
Arquivo: ui.c Projeto: gstroe/Arm
void ui_usb_sof_event(void)
{
	bool b_btn_state;
	static bool btn_suspend_and_remotewakeup = false;
	static uint16_t counter_sof = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			LED_Toggle(LED_YELLOW0);
		}

		/* Scan button to enter in suspend mode and remote wakeup */
		/*b_btn_state = (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)) ?
		        true : false;*/
		b_btn_state = true;

		if (b_btn_state != btn_suspend_and_remotewakeup) {
			/* Button have changed */
			btn_suspend_and_remotewakeup = b_btn_state;

			if (b_btn_state) {
				/* Button has been pressed */
				ui_enable_asynchronous_interrupt();
				USBH_suspend(true);
				return;
			}
		}

		/* Power on a LED when the mouse move */
		if (!ui_x && !ui_y && !ui_scroll) {
#if 2 == LED_NUM
			LED_Clear(LED_YELLOW1);
#endif
		} else {
			ui_x = ui_y = ui_scroll = 0;
#if 2 == LED_NUM
			LED_Set(LED_YELLOW1);
#endif
		}
	}
}
/*! \brief Toggle LED
 */
int32_t toggle_led(uint32_t number_of_toggles)
{
	volatile uint32_t start_count, end_count;
	int32_t result = 0;

	start_count = Get_system_register(AVR32_COUNT);

	for (uint32_t i = 0; i < number_of_toggles; i++) {
		LED_Toggle(LED0);
	}

	end_count = Get_system_register(AVR32_COUNT);
	result = end_count - start_count;

	print(EXAMPLE_USART, "       - Number of cycles: ");
	print_ulong(EXAMPLE_USART, result);
	print(EXAMPLE_USART, "\r\n");

	return result;
}
Exemplo n.º 22
0
Arquivo: main.c Projeto: marekr/asf
/** \brief User prompt routine
 *
 * This routine prompts the user to press the button and then waits
 * for him to do so.
 */
static void prompt_user(char *prompt_string)
{
	/* Output prompt string */
	printf("%s\r\n", prompt_string);

	/* Wait for user to push button before continuing */
	LED_Off(ALL_LEDS);

	/* Just blink LED until button is pushed */
	while (!SWITCH_PRESSED) {
		LED_Toggle(PROMPT_LED);
		delay_ms(100);
	}

	LED_Off(PROMPT_LED);

	/* Wait until button is released */
	while (SWITCH_PRESSED) {
	}
}
Exemplo n.º 23
0
int main(void)
{
    serial_init();
    printf("Hello world!\n");
    
    printf("Malloc 1024 bytes... ");
    int i = 0;
    char *data = malloc(1024 * sizeof(char));

    printf("[%s]\n", (data == NULL ? "FAIL" : " OK "));
    printf("Global var @ %p\n", external);
    printf("Local var  @ %p\n", &i);
    printf("Heap var   @ %p\n", data);

    while(1) {
        printf("Toggle! %d\n", i++);
        LED_Toggle(LED0);
        delay_ms(500);
    }
}
Exemplo n.º 24
0
void ui_usb_sof_event(void)
{
	static uint16_t counter_sof = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {

		// Display device enumerated and in active mode
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			LED_Toggle(LED1);
		}

		// Power on a LED when the mouse move
		if (!ui_x && !ui_y && !ui_scroll) {
			LED_Off(LED2);
		}else{
			ui_x = ui_y = ui_scroll = 0;
			LED_On(LED2);
		}
	}
}
Exemplo n.º 25
0
//@{
void Task_Blink_Red(SSTEvent event){
static uint32_t lasttick = 0;

    if(event.sig!=SST_SIGNAL_TASKINIT) {
        if( blinking ) {
            // static int state = 0
            // if (state == 0) {
            //    LED_Write(LED_RED,0);
            // } else {
            //    LED_Write(0,LED_RED);
            // }
            //
            if( msTick > (lasttick+semiperiod_red) ) {
                LED_Toggle(LED_RED);
                lasttick = msTick;
            };
        } else {
            LED_Write(0,LED_RED);
        }
    }
}
Exemplo n.º 26
0
Arquivo: main.c Projeto: gstroe/Arm
/* Handler for MCAN1, Line 1 */
void MCAN1_Line1_Handler(void)
{
	if (MCAN_IsMessageStoredToRxDedBuffer(&mcan1Config)) {
		MCAN_ClearMessageStoredToRxBuffer(&mcan1Config);
		if (MCAN_IsNewDataInRxDedBuffer(&mcan1Config, RX_BUFFER_0)) {
			MCAN_GetRxDedBuffer(&mcan1Config, RX_BUFFER_0, (Mailbox64Type *)
				&rxMailbox0);
		// verify data
			if (rxMailbox0.data[0] == MSG_ID_0_DATA1) {
				// Toggle LED #0 To Indicate New Message Received in Interrupt
				LED_Toggle(0);
				rxdCntr++;
			}
		}
		if (MCAN_IsNewDataInRxDedBuffer(&mcan1Config, RX_BUFFER_1)) {
			MCAN_GetRxDedBuffer(&mcan1Config, RX_BUFFER_1, (Mailbox64Type *)
				&rxMailbox1);
		rxdCntr++;
		}
	}
}
Exemplo n.º 27
0
/**
 * @brief Function to handle the LED States based on application state.
 *
 *
 * @param callback_parameter  callback parameter if any.
 */
static void led_handling(void *callback_parameter)
{
	switch (node_status) {
	case ZID_CONNECTING:
	case ALL_IN_ONE_START:
		sw_timer_start(APP_TIMER,
				PAIR_WAIT_PERIOD,
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)led_handling,
				NULL);
		LED_Toggle(LED_NWK_SETUP);
		break;

	default:
		sw_timer_stop(APP_TIMER);
		break;
	}

	/* Keep compiler happy */
	callback_parameter = callback_parameter;
}
Exemplo n.º 28
0
void ui_host_sof_event(void)
{
	bool b_btn_state;
	static bool btn_suspend_and_remotewakeup = false;
	static uint16_t counter_sof = 0;
	static uint16_t counter_sof_move_refresh = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		/* Display device enumerated and in active mode */
		if (++counter_sof > ui_device_speed_blink) {
			counter_sof = 0;
			LED_Toggle(LED0);
		}

		/* Scan button to enter in suspend mode and remote wakeup */
		b_btn_state = !ioport_get_pin_level(GPIO_PUSH_BUTTON_0);
		if (b_btn_state != btn_suspend_and_remotewakeup) {
			/* Button have changed */
			btn_suspend_and_remotewakeup = b_btn_state;
			if (b_btn_state) {
				/* Button has been pressed */
				ui_enable_asynchronous_interrupt();
				LED_Off(LED0);
				uhc_suspend(true);
				return;
			}
		}

		/* Move the remote mouse pointer on the Board Monitor screen */
		if (++counter_sof_move_refresh > 200) {
			counter_sof_move_refresh = 0;
			bm_mouse_pointer_move(bm_x / 8, bm_y / 8);
		}

		/* Power on a LED when the mouse button down */
		if (ui_nb_down) {
			LED_On(LED0);
		}
	}
}
Exemplo n.º 29
0
/**
 *  \brief getting-started Application entry point.
 *
 *  \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	/* Initialize the SAM system */
	sysclk_init();
	board_init();

	/* Initialize the console uart */
	configure_console();

	/* Output example information */
	puts(STRING_HEADER);

	/* Configure systick for 1 ms */
	puts("Configure system tick to get 1ms tick period.\r");
	if (SysTick_Config(sysclk_get_cpu_hz() / BLINK_PERIOD)) {
		puts("-F- Systick configuration error\r");
		while (1);
	}

	puts("Configure button.\r");
	configure_button();
	puts("Configure TC.\r");
	configure_tc();

	printf("Press %s to Start/Stop LED0 blinking.\r\n", BUTTON_0_NAME);

	while (1) {
		/* Wait for LED to be active */
		while (!g_b_led0_active);

		/* Toggle LED state if active */
		if (g_b_led0_active == 1) {
			LED_Toggle(LED0);
			printf("1 ");
		}

		/* Wait for 500ms */
		mdelay(500);
	}
}
Exemplo n.º 30
0
void led_task(packet_t *pkt)
{
	switch(pkt->subTask)
	{
	case led_off:
		LED_Off(led_pinNum(pkt->buf[0]));
		alarm_new(20, "Device turned off LED %i", pkt->buf[0]);
		break;
	case led_on:
		LED_On(led_pinNum(pkt->buf[0]));
		alarm_new(20, "Device turned on LED %i", pkt->buf[0]);
		break;
	case led_toggle:
		LED_Toggle(led_pinNum(pkt->buf[0]));
		alarm_new(20, "Device toggled LED %i", pkt->buf[0]);
		break;
	case led_status:
		break;
	case led_report:
		break;
	}
}