Example #1
0
/**
 * \brief Decode CAN messages.
 *
 *  \param p_mailbox Pointer to CAN Mailbox structure.
 */
static void decode_can_msg(can_mb_conf_t *p_mailbox)
{
	uint32_t ul_led_Ctrl = p_mailbox->ul_datal;

	puts("CAN message:" STRING_EOL);
	if (ul_led_Ctrl == CAN_MSG_TOGGLE_LED_0) {
		puts("  Toggle LED 0" STRING_EOL);
		ioport_toggle_pin_level(LED0_GPIO);
	} else if (ul_led_Ctrl == CAN_MSG_TOGGLE_LED_1) {
		puts("  Toggle LED 1" STRING_EOL);
		ioport_toggle_pin_level(LED1_GPIO);
	}
}
Example #2
0
/**
 * \brief Test IOPORT pin level is getting changed.
 *
 * This function set the direction of CONF_OUT_PIN to output mode with pull-up
 * enabled and read the status of pin using CONF_IN_PIN which is configured in
 * input mode.
 *
 * The pin CONF_OUT_PIN and CONF_IN_PIN are shorted using a jumper.
 *
 * \param test Current test case.
 */
static void run_ioport_pin_test(const struct test_case *test)
{
	static volatile pin_mask_t pin_val;

	/* Set output direction on the given IO Pin */
	ioport_set_pin_dir(CONF_OUT_PIN, IOPORT_DIR_OUTPUT);

	/* Set direction and pull-up on the given IO Pin */
	ioport_set_pin_dir(CONF_IN_PIN, IOPORT_DIR_INPUT);
	ioport_set_pin_mode(CONF_IN_PIN, IOPORT_MODE_PULLUP);

	/* Set IO pin as high */
	ioport_set_pin_level(CONF_OUT_PIN, IOPORT_PIN_LEVEL_HIGH);
	delay_ms(10);
	pin_val = ioport_get_pin_level(CONF_IN_PIN);
	test_assert_true(test, pin_val == 1,
			"IOPORT Set pin level high test failed");

	/* Set IO pin as low */
	ioport_set_pin_level(CONF_OUT_PIN, IOPORT_PIN_LEVEL_LOW);
	delay_ms(10);
	pin_val = ioport_get_pin_level(CONF_IN_PIN);
	test_assert_true(test, pin_val == 0,
			"IOPORT Set pin level low test failed");

	/* Toggle IO pin */
	ioport_toggle_pin_level(CONF_OUT_PIN);
	delay_ms(10);
	pin_val = ioport_get_pin_level(CONF_IN_PIN);
	test_assert_true(test, pin_val == 1,
			"IOPORT Set pin level toggle test failed");
}
Example #3
0
/**
* \brief Executive command form PC to the target.
*
*/
static void executive_command(uint8_t* receive_buf)
{
	struct adp_msg_packet_data *receive_buf_s = (struct adp_msg_packet_data *)receive_buf;
	
	switch(receive_buf_s->stream_id) {
		case STREAM_ID_LED_TOGGLE:
			ioport_toggle_pin_level(USER_LED_PIN);
			break;
			
		case STREAM_ID_HYST_LOW:
			if(receive_buf_s->bytes_sent >= 2) {
				hyst_low = (uint16_t)receive_buf_s->data[0] | ((uint16_t)receive_buf_s->data[1] << 8);
			}
			break;
		
		case STREAM_ID_HYST_HIGH:
			if(receive_buf_s->bytes_sent >= 2) {
				hyst_high = (uint16_t)receive_buf_s->data[0] | ((uint16_t)receive_buf_s->data[1] << 8);
			}
			break;
		
		default:
			break;
	}
}
int main(void)
{
	/* Use static volatile to make it available in debug watch */
	static volatile bool pin_val;

	sysclk_init();
	board_init();
	ioport_init();

	delay_init(sysclk_get_cpu_hz());

	/* Set output direction on the given LED IOPORTs */
	ioport_set_pin_dir(EXAMPLE_LED, IOPORT_DIR_OUTPUT);

	/* Set direction and pullup on the given button IOPORT */
	ioport_set_pin_dir(EXAMPLE_BUTTON, IOPORT_DIR_INPUT);
	ioport_set_pin_mode(EXAMPLE_BUTTON, IOPORT_MODE_PULLUP);

	/* Set LED IOPORTs high */
	ioport_set_pin_level(EXAMPLE_LED, IOPORT_PIN_LEVEL_HIGH);

	while (true) {
		/* Toggle LED IOPORTs with half a second interval */
		ioport_toggle_pin_level(EXAMPLE_LED);
		delay_ms(500);

		/* Get value from button port */
		/* Use watch with debugger to see it */
		pin_val = ioport_get_pin_level(EXAMPLE_BUTTON);
	}
}
Example #5
0
void blink2(void *p) {
	
	while (1) {
		
		ioport_toggle_pin_level(YELLOW);
		vTaskDelay(100);
	}
}
Example #6
0
void blink1(void *p) {
	
	while (1) {
		
		ioport_toggle_pin_level(RED);
        vTaskDelay(1000);
	}
}
Example #7
0
void led_error (uint8_t error)
{
	cpu_irq_disable();
	ioport_set_pin_level(LED_1,true);
	ioport_set_pin_level(LED_2,true);
	ioport_set_pin_level(LED_3,true);
		
	while(1)
	{
		delay_ms(100);
		if ((error & 1) == 1)
			ioport_toggle_pin_level(LED_1);
		if ((error & 2) == 2)
			ioport_toggle_pin_level(LED_2);
		if ((error & 4) == 4)
			ioport_toggle_pin_level(LED_3);
	}
	
}
Example #8
0
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
	if( uxLED < partestNUM_LEDS )
	{
		taskENTER_CRITICAL();
		{
			ioport_toggle_pin_level( ulLED[ uxLED ] );
		}
		taskEXIT_CRITICAL();
	}
}
void ZX_Handler(uint32_t id, uint32_t mask) {	
	ioport_toggle_pin_level(LED1_GPIO);
	ioport_toggle_pin_level(FP_LED2_GPIO);
	if (zx_count == 60) {
		zx_count = 0;
		epoch++;
	}
		
	zx_count++;		
		
	read_voltage();
	read_current();
	read_period();
		
	char* measurement = create_measurement_string();

	printf("%s\r\n", measurement);

	free(measurement);
}
Example #10
0
void TC2_Handler(void)
{
	volatile uint32_t ul_dummy;

	ul_dummy = tc_get_status(TC0, 2);
	
	UNUSED(ul_dummy); // Avoid compiler warning 
	
	//ioport_toggle_pin_level(LED0_GPIO);
	ioport_toggle_pin_level(PIO_PC24_IDX);
}
void debug_idle(void)
{
	if (bTest)
	{
		if (TimerOut(BLINK_TIMER))
		{
			ResetTimer(BLINK_TIMER);
			StartTimer(BLINK_TIMER, 500);
			ioport_toggle_pin_level(BLINK_LED);
		}
	}
}
Example #12
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++;
		ioport_toggle_pin_level(LED0_GPIO);
	} while ((g_ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks);

	return ul_cnt;
}
OSStatus platform_gpio_output_trigger( const platform_gpio_t* gpio )
{
  OSStatus err = kNoErr;
  
  require_action_quiet( gpio != NULL, exit, err = kParamErr);
  platform_mcu_powersave_disable();
  
  ioport_toggle_pin_level( gpio->pin );
  
exit:
  platform_mcu_powersave_enable();
  return err;
}
Example #14
0
void led4(int state)
{
	switch (state)
	{
		case ON:
		ioport_set_pin_level(LED4,1);
		break;
		case OFF:
		ioport_set_pin_level(LED4,0);
		break;
		case TOGGLE:
		ioport_toggle_pin_level(LED4);
		break;
	}
}
Example #15
0
OSStatus mico_gpio_output_trigger( mico_gpio_t gpio )
{
  ioport_pin_t  pin = 0;
  if(gpio == (mico_gpio_t)MICO_GPIO_UNUSED ) return kUnsupportedErr;

  mico_mcu_power_save_config(false);
  
  pin = CREATE_IOPORT_PIN(gpio_mapping[gpio].bank, gpio_mapping[gpio].number);
  
  ioport_toggle_pin_level(pin);
  
  mico_mcu_power_save_config(true);
  
  return kNoErr;    
}
/**
 * \brief Initialize the clock system and blink a LED at a constant 1 Hz frequency.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	sysclk_init();
	board_init();

	/* Setup SysTick Timer for 1 msec interrupts */
	if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
		while (1) {  /* Capture error */
		}
	}

	while (1) {
		ioport_toggle_pin_level(EXAMPLE_LED_GPIO);
		mdelay(500);
	}
}
Example #17
0
void TC0_Handler(void)
{
	volatile uint32_t ul_dummy;

	/* Clear status bit to acknowledge interrupt */
	ul_dummy = tc_get_status(TC0, 0);

	/* Avoid compiler warning */
	UNUSED(ul_dummy);

#ifdef LED1_GPIO
	/** Toggle LED state. */
	ioport_toggle_pin_level(LED1_GPIO);
#endif

	printf("2 ");
}
Example #18
0
/**
 * \brief Interrupt handler for TC00. Record the number of bytes received,
 * and then restart a read transfer on the USART if the transfer was stopped.
 */
void TC00_Handler(void)
{
	static int32_t input_data = 0;
	static int32_t cnt = 0;

	/* Read TC0 Status. */
	tc_get_status(TC0, 0);

	/* Toggel I/O pin to simulate the PCCK */
	ioport_toggle_pin_level(PIN_PCCK_INPUT);

	/* PCDATA changes every two PCCK level change*/
	cnt++;
	if (cnt == 1) {
		/* Simulate PCD data */
		place_data_to_port(input_data++);
		if (input_data == BUFFER_SIZE ) {
			input_data = 0;
		}
	} else if (cnt == 2) {
		cnt =0;
	}
}
Example #19
0
static void prvQueueReceiveTask( void *pvParameters )
{
unsigned long ulReceivedValue;
const unsigned long ulExpectedValue = 100UL;

	/* Remove compiler warning about unused parameter. */
	( void ) pvParameters;

	for( ;; )
	{
		/* Wait until something arrives in the queue - this task will block
		indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
		FreeRTOSConfig.h. */
		xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );

		/*  To get here something must have been received from the queue, but
		is it the expected value?  If it is, toggle the LED. */
		if( ulReceivedValue == ulExpectedValue )
		{
			ioport_toggle_pin_level( mainTASK_LED );
			ulReceivedValue = 0U;
		}
	}
}
Example #20
0
int main (void)
{
	sysclk_init();
	ioport_init();
	
	ioport_set_pin_dir(LED_BLUE, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED_GREEN, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED_WHITE, IOPORT_DIR_OUTPUT);
	
	ioport_configure_pin(BUTTON_0, IOPORT_PULL_UP);
	ioport_configure_pin(BUTTON_1, IOPORT_PULL_UP);

	force_boot_loader();
	
	irq_initialize_vectors();
	cpu_irq_enable();
	udc_start();
	//board_init();

	while(1)
	{
		ioport_toggle_pin_level(LED_GREEN);
		delay_ms(100);
		ioport_set_pin_level(LED_BLUE, ioport_get_pin_level(BUTTON_0));
		ioport_set_pin_level(LED_WHITE, ioport_get_pin_level(BUTTON_1));
		
		char usb_in = udi_cdc_getc();
		char usb_out [17]=  "WHAT YOU TYPED: \r";//udi_cdc_getc();
		for (int i=0;i<16;i++)
		{
			udi_cdc_putc(usb_out[i]);
		}
		udi_cdc_putc(usb_in);
		udi_cdc_putc('\r');
	}
}
Example #21
0
void remote_controlled(void)
{
	/*¨Parts:
	-Leds (L)
	-Motors (M)
	-servos (S)
	-complete movement (R) */
	char part;
	int opt1=0;
	int opt2=0;
	int opt3=0;
	//scanf("%1c%1i%3i%3i",&part,&opt1,&opt2,&opt3);
	scanf("%1c%1i%3i",&part,&opt1,&opt2);
	switch (part)
	{
		/* Motors M+#of motor + speed (99 to -99) */
		case 'M':
			switch (opt1)
			{
				case 1:
				motor1(opt2);
				break;
				case 2:
				motor2(opt2);
				break;
				case 3:
				motor3(opt2);
				break;
				case 4:
				motor4(opt2);
				break;
			}
		break;
		
		case 'R':
			move(opt2,opt3);
		break;
		
		
		case 'S':
			switch(opt1)
			{
				case 1: 
					pwm_update(SERVO_0,opt2);
				break;
				case 2:
					pwm_update(SERVO_1,opt2);
				break;
				case 3:
					pwm_update(SERVO_2,opt2);
				break;
				case 4:
					pwm_update(SERVO_3,opt2);
				break;
				
			}
		break;
		
		
		/* Leds, L + # of led + option
			L1000 turn off led 1
			L1001 turn on led 1
			L1002 toggle led 1 */
		case 'L':
			switch (opt1)
			{
			case 1:
				switch(opt2)
				{
					case 0:
					ioport_set_pin_level(LED1,0);
					break;
				
					case 1:
					ioport_set_pin_level(LED1,1);
					break;
				
					case 2:
					ioport_toggle_pin_level(LED1);
					break;
				}
			break;
				
			case 2:
				switch(opt2)
				{
					case 0:
					ioport_set_pin_level(LED2,0);
					break;
					
					case 1:
					ioport_set_pin_level(LED2,1);
					break;
					
					case 2:
					ioport_toggle_pin_level(LED2);
					break;
				}
			break;
			
			case 3:
			switch(opt2)
			{
				case 0:
				ioport_set_pin_level(LED3,0);
				break;
				
				case 1:
				ioport_set_pin_level(LED3,1);
				break;
				
				case 2:
				ioport_toggle_pin_level(LED3);
				break;
			}
			break;
			
			case 4:
			switch(opt2)
			{
				case 0:
				ioport_set_pin_level(LED4,0);
				break;
				
				case 1:
				ioport_set_pin_level(LED4,1);
				break;
				
				case 2:
				ioport_toggle_pin_level(LED4);
				break;
			}
			break;
			
			case 5:
			switch(opt2)
			{
				case 0:
				ioport_set_pin_level(LED5,0);
				break;
							
				case 1:
				ioport_set_pin_level(LED5,1);
				break;
							
				case 2:
				ioport_toggle_pin_level(LED5);
				break;
			}
			break;
			
			case 6:
			switch(opt2)
			{
				case 0:
				ioport_set_pin_level(LED6,0);
				break;
				
				case 1:
				ioport_set_pin_level(LED6,1);
				break;
				
				case 2:
				ioport_toggle_pin_level(LED6);
				break;
			}
		break;
		}

// 		case 'M':
// 		break;
// 		
// 		case 'S':
// 		break;
// 		
// 		case 'R':
// 		break;
	}
}
Example #22
0
/* \brief Main entry point
 * This is an example of how to use watchdog.
 */
int main(void)
{
	struct eic_line_config eic_line_cfg;

	/* Initialize the SAM system */
	sysclk_init();
	board_init();

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

	/* Output example information */
	printf("\r\n\r\n-- Watchdog example --\r\n");
	printf("-- %s\r\n", BOARD_NAME);
	printf("-- Compiled: %s %s --\r\n", __DATE__, __TIME__);

	/* Systick configuration. */
	if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
		puts("-F- Systick configuration error\r");
	}

	/* Configure push button */
	eic_line_cfg.eic_mode = EIC_MODE_EDGE_TRIGGERED;
	eic_line_cfg.eic_edge = EIC_EDGE_FALLING_EDGE;
	eic_line_cfg.eic_level = EIC_LEVEL_LOW_LEVEL;
	eic_line_cfg.eic_filter = EIC_FILTER_DISABLED;
	eic_line_cfg.eic_async = EIC_ASYNCH_MODE;

	eic_enable(EIC);
	eic_line_set_config(EIC, GPIO_PUSH_BUTTON_EIC_LINE,
			&eic_line_cfg);
	eic_line_set_callback(EIC, GPIO_PUSH_BUTTON_EIC_LINE, set_toggle_flag,
			EIC_5_IRQn, 1);
	eic_line_enable(EIC, GPIO_PUSH_BUTTON_EIC_LINE);

	/*
	 * Intialize and enable the watchdog.
	 * Use default configuration but change timeout period
	 * to about 4.56s (Ttimeout = 2pow(PSEL+1) / Fclk_cnt = 524288 / 115000).
	 */
	wdt_get_config_defaults(&g_wdt_cfg);
	g_wdt_cfg.timeout_period = WDT_PERIOD_524288_CLK;
	wdt_init(&g_wdt_inst, WDT, &g_wdt_cfg);
	wdt_enable(&g_wdt_inst);

	puts("\r\nPlease press PB0 to simulate a deadlock.\r");

	while (1) {
		if (g_b_systick_event == true) {
			g_b_systick_event = false;

			/* Toggle LED at the given period. */
			if ((g_ul_ms_ticks % BLINK_PERIOD) == 0) {
				ioport_toggle_pin_level(LED0_GPIO);
			}

			/* Clear watchdog at the given period. */
			if ((g_ul_ms_ticks % WDT_RESTART_PERIOD) == 0) {
				wdt_clear(&g_wdt_inst);
			}
		}

		/* Simulate deadlock when button is pressed. */
		if (g_b_button_event == true) {
			puts("The program enters an infinite loop, the WDT reset will " \
					"trigger in about 5s.\r");
			wdt_clear(&g_wdt_inst);
			while (1) {
				if (g_b_systick_event == true) {
					g_b_systick_event = false;
					if ((g_ul_ms_ticks % BLINK_PERIOD) == 0) {
						printf(".");
					}
				}
			}
		}
	}
}
Example #23
0
/**
 * \brief main function : do init and loop
 */
int main(void)
{

	/* Initialize the SAM system */
	sysclk_init();
	board_init();

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

	/* Output example information */
	printf("-- AST Example 1 in Calendar Mode --\r\n");
	printf("-- %s\n\r", BOARD_NAME);
	printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

	printf("Config AST with 32 KHz oscillator.\r\n");

	/* Enable osc32 oscillator*/
	if (!osc_is_ready(OSC_ID_OSC32)) {
		osc_enable(OSC_ID_OSC32);
		osc_wait_ready(OSC_ID_OSC32);
	}

	struct ast_calendar calendar;
	calendar.FIELD.sec = 0;
	calendar.FIELD.min = 15;
	calendar.FIELD.hour = 12;
	calendar.FIELD.day = 20;
	calendar.FIELD.month = 9;
	calendar.FIELD.year = 14;

	/* Enable the AST */
	ast_enable(AST);

	struct ast_config ast_conf;
	ast_conf.mode = AST_CALENDAR_MODE;
	ast_conf.osc_type = AST_OSC_32KHZ;
	ast_conf.psel = AST_PSEL_32KHZ_1HZ;
	ast_conf.calendar = calendar;

	/* Initialize the AST */
	if (!ast_set_config(AST, &ast_conf)) {
		printf("Error initializing the AST\r\n");
		while (1) {
		}
	}

	while (1) {
		/* slow down operations */
		delay_s(1);

		ioport_toggle_pin_level(LED0_GPIO);

		/* Output the calendar */
		calendar = ast_read_calendar_value(AST);
		printf("\r");
		printf("Calendar: Year:%02u Month:%02u Day:%02u, %02uh%02um%02us ",
				(unsigned int)calendar.FIELD.year,
				(unsigned int)calendar.FIELD.month,
				(unsigned int)calendar.FIELD.day,
				(unsigned int)calendar.FIELD.hour,
				(unsigned int)calendar.FIELD.min,
				(unsigned int)calendar.FIELD.sec);
	}
}
void FP_LOAD_Handler(uint32_t id, uint32_t mask) {	
	ioport_toggle_pin_level(FP_LED0_GPIO);
	ioport_toggle_pin_level(RELAY_1_GPIO);
	ioport_toggle_pin_level(RELAY_2_GPIO);
}
Example #25
0
static void prvCheckTask( void *pvParameters )
{
TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;
TickType_t xLastExecutionTime;
static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
unsigned long ulErrorFound = pdFALSE;

	/* Just to stop compiler warnings. */
	( void ) pvParameters;

	/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
	works correctly. */
	xLastExecutionTime = xTaskGetTickCount();

	/* Cycle for ever, delaying then checking all the other tasks are still
	operating without error.  The onboard LED is toggled on each iteration.
	If an error is detected then the delay period is decreased from
	mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD.  This has the
	effect of increasing the rate at which the onboard LED toggles, and in so
	doing gives visual feedback of the system status. */
	for( ;; )
	{
		/* Delay until it is time to execute again. */
		vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );

		/* Check all the demo tasks (other than the flash tasks) to ensure
		that they are all still running, and that none have detected an error. */
		if( xAreIntQueueTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 0UL;
		}

		if( xAreMathsTaskStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 1UL;
		}

		if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 2UL;
		}

		if( xAreBlockingQueuesStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 3UL;
		}

		if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 4UL;
		}

		if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 5UL;
		}

		if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 6UL;
		}

		if( xIsCreateTaskStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 7UL;
		}

		if( xAreSemaphoreTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 8UL;
		}

		if( xAreTimerDemoTasksStillRunning( ( TickType_t ) xDelayPeriod ) != pdPASS )
		{
			ulErrorFound = 1UL << 9UL;
		}

		if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 10UL;
		}

		if( xIsQueueOverwriteTaskStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 11UL;
		}

		if( xAreEventGroupTasksStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 12UL;
		}

		if( xAreInterruptSemaphoreTasksStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 13UL;
		}

		if( xAreTaskNotificationTasksStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 14UL;
		}

		/* Check that the register test 1 task is still running. */
		if( ulLastRegTest1Value == ulRegTest1LoopCounter )
		{
			ulErrorFound = 1UL << 15UL;
		}
		ulLastRegTest1Value = ulRegTest1LoopCounter;

		/* Check that the register test 2 task is still running. */
		if( ulLastRegTest2Value == ulRegTest2LoopCounter )
		{
			ulErrorFound = 1UL << 16UL;
		}
		ulLastRegTest2Value = ulRegTest2LoopCounter;

		/* Toggle the check LED to give an indication of the system status.  If
		the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then
		everything is ok.  A faster toggle indicates an error. */
		ioport_toggle_pin_level( mainTASK_LED );

		if( ulErrorFound != pdFALSE )
		{
			/* An error has been detected in one of the tasks - flash the LED
			at a higher frequency to give visible feedback that something has
			gone wrong (it might just be that the loop back connector required
			by the comtest tasks has not been fitted). */
			xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;
		}
	}
}
Example #26
0
void Gpio::toggle() {
    ioport_toggle_pin_level(_pin);
}
Example #27
0
int main (void)
{
	init_octopus();
	
	ioport_set_pin_dir(STEP,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(DIR,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(SLEEP,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(MS1,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(MS2,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(MS3,IOPORT_DIR_OUTPUT);
	
	ioport_set_pin_level(STEP,0);
	ioport_set_pin_level(DIR,0);
	ioport_set_pin_level(SLEEP,0);
	ioport_set_pin_level(MS1,0);
	ioport_set_pin_level(MS2,0);
	ioport_set_pin_level(MS3,0);
	
	initial_animation();
	for (;;)
	{
		
		int direction;
		int step1;
		int step2;
		int step3;
		int step4;
		int step5;
		scanf("%1i%4x%4x%4x%4x%4x",&direction,&step1,&step2,&step3,&step4,&step5);
		move_stepper(direction,step1,step2,step3,step4,step5);
		
		if(switch_state(SW1) == 0)
		{
			ioport_set_pin_level(SLEEP,1);
			ioport_toggle_pin_level(DIR);
			full_step();
			for(int i=1;i<1000;i++)
			{
				ioport_toggle_pin_level(STEP);
				delay_ms(1);
			}
			ioport_set_pin_level(SLEEP,0);
			
			move_stepper(1,300,0,0,0,0);
			
// 			ioport_set_pin_level(LED1,1);
// 			delay_ms(200);
// 			ioport_set_pin_level(LED2,1);
// 			delay_ms(200);
// 			ioport_set_pin_level(LED3,1);
// 			delay_ms(200);
// 			ioport_set_pin_level(LED4,1);
// 			delay_ms(200);
// 			ioport_set_pin_level(LED5,1);
// 			delay_ms(200);
// 			ioport_set_pin_level(LED6,1);
// 			delay_ms(200);
		}
		if(switch_state(SW2) == 0)
		{
			move_stepper(1,120,60,10,5,5);
		}			
	}
}
Example #28
0
void led_activity_routine(void)
{
	
	if((get_ok_12v_status() == RETURN_NOK) || (lights_off == TRUE))
	{
		ioport_set_pin_level(IN_CLK_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_CLK_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_CLK_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_DAT_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_DAT_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_DAT_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH1_CH2_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH1_CH2_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH1_CH2_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH3_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH3_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH3_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
		return;
	}
	
	if(ioport_get_pin_level(CLK_IN_DET_GPIO))
	{		
		if(clk_in_color == GREEN)
		{
			ioport_toggle_pin_level(IN_CLK_LED3_GPIO);
		}
		else if(clk_in_color == BLUE)
		{
			ioport_toggle_pin_level(IN_CLK_LED2_GPIO);
		}
		else if(clk_in_color == RED)
		{
			ioport_toggle_pin_level(IN_CLK_LED1_GPIO);
		}
	}
	else
	{
		ioport_set_pin_level(IN_CLK_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_CLK_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_CLK_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
	}	
	
	if(ioport_get_pin_level(DATA_IN_DET_GPIO))
	{		
		if(data_in_color == GREEN)
		{
			ioport_toggle_pin_level(IN_DAT_LED3_GPIO);
		}
		else if(data_in_color == BLUE)
		{
			ioport_toggle_pin_level(IN_DAT_LED2_GPIO);
		}
		else if(data_in_color == RED)
		{
			ioport_toggle_pin_level(IN_DAT_LED1_GPIO);
		}
	}
	else
	{
		ioport_set_pin_level(IN_DAT_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_DAT_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(IN_DAT_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
	}
	
	if(!ioport_get_pin_level(OUT_PULSE_DET_GPIO)) // Signal are inverted for routing facility (OG 10.04.2014)
	{		
		if(ch_out_color == GREEN)
		{
			ioport_toggle_pin_level(OUT_CH1_CH2_LED3_GPIO);
			ioport_toggle_pin_level(OUT_CH3_LED3_GPIO);
		}
		else if(ch_out_color == BLUE)
		{
			ioport_toggle_pin_level(OUT_CH1_CH2_LED2_GPIO);
			ioport_toggle_pin_level(OUT_CH3_LED2_GPIO);
		}
		else if(ch_out_color == RED)
		{
			ioport_toggle_pin_level(OUT_CH1_CH2_LED1_GPIO);
			ioport_toggle_pin_level(OUT_CH3_LED1_GPIO);
		}
	}
	else
	{
		ioport_set_pin_level(OUT_CH1_CH2_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH1_CH2_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH1_CH2_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH3_LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH3_LED2_GPIO, IOPORT_PIN_LEVEL_HIGH);
		ioport_set_pin_level(OUT_CH3_LED3_GPIO, IOPORT_PIN_LEVEL_HIGH);
	}
	
	ioport_set_pin_level(DATA_PULSE_RST_GPIO, IOPORT_PIN_LEVEL_HIGH);
	ioport_set_pin_level(CLK_PULSE_RST_GPIO, IOPORT_PIN_LEVEL_HIGH);
	ioport_set_pin_level(OUT_PULSE_RST_GPIO, IOPORT_PIN_LEVEL_HIGH);
	asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
	ioport_set_pin_level(DATA_PULSE_RST_GPIO, IOPORT_PIN_LEVEL_LOW);
	ioport_set_pin_level(CLK_PULSE_RST_GPIO, IOPORT_PIN_LEVEL_LOW);
	ioport_set_pin_level(OUT_PULSE_RST_GPIO, IOPORT_PIN_LEVEL_LOW);
}
Example #29
0
// [main]
int main(void)
{
//! [main_step_sys_init]
	/* Initialize the SAM system */
	sysclk_init();
	board_init();
//! [main_step_sys_init]

#ifndef BOARD_NO_PUSHBUTTON_2
#if (SAMV71 || SAMV70 || SAMS70 || SAME70)
	if (GPIO_PUSH_BUTTON_2 == PIO_PB12_IDX) {
		matrix_set_system_io(matrix_get_system_io() | CCFG_SYSIO_SYSIO12);
	}
	ioport_set_pin_dir(GPIO_PUSH_BUTTON_2, IOPORT_DIR_INPUT);
	ioport_set_pin_mode(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS);
	ioport_set_pin_sense_mode(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_SENSE);
#endif
#endif
//! [main_step_console_init]
	/* Initialize the console uart */
	configure_console();
//! [main_step_console_init]

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

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

#ifndef BOARD_NO_LED_1
	puts("Configure TC.\r");
//! [main_step_tc_init]
	configure_tc();
//! [main_step_tc_init]
#endif

	puts("Configure buttons with debouncing.\r");
//! [main_step_btn_init]
	configure_buttons();
//! [main_step_btn_init]

	printf("Press %s to Start/Stop the %s blinking.\r\n",
			PUSHBUTTON_1_NAME, LED_0_NAME);

#ifndef BOARD_NO_PUSHBUTTON_2
	printf("Press %s to Start/Stop the %s blinking.\r\n",
			PUSHBUTTON_2_NAME, LED_1_NAME);
#endif

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

		/* Toggle LED state if active */
		if (g_b_led0_active) {
			ioport_toggle_pin_level(LED0_GPIO);
			printf("1 ");
		}

		/* Wait for 500ms */
		mdelay(500);
	}
//! [main_step_loop]
}
void SysTick_Handler(void)
{
	ioport_toggle_pin_level(LED_EXAMPLE_OUTPUT);
}