示例#1
0
//Calls gpio_port_init() four times to initialize the pins of port TC that each LED is connected to.
void uc_led_init()
{
    gpio_port_init(gpio_port_tc, uc_led_1, gpio_funct_gpio, gpio_data_dir_out, gpio_pin_state_low);
    gpio_port_init(gpio_port_tc, uc_led_2, gpio_funct_gpio, gpio_data_dir_out, gpio_pin_state_low);
    gpio_port_init(gpio_port_tc, uc_led_3, gpio_funct_gpio, gpio_data_dir_out, gpio_pin_state_low);
    gpio_port_init(gpio_port_tc, uc_led_4, gpio_funct_gpio, gpio_data_dir_out, gpio_pin_state_low);
}
示例#2
0
//Calls gpio_port_init() to initialize port DD so we can use sub-switches 1, 2, 3, and 4.
void uc_dipsw_init() 
{
	gpio_port_init(gpio_port_dd,uc_dipsw_1,gpio_funct_gpio,gpio_data_dir_in,gpio_pin_state_x);
	gpio_port_init(gpio_port_dd,uc_dipsw_2,gpio_funct_gpio,gpio_data_dir_in,gpio_pin_state_x);
	gpio_port_init(gpio_port_dd,uc_dipsw_3,gpio_funct_gpio,gpio_data_dir_in,gpio_pin_state_x);
	gpio_port_init(gpio_port_dd,uc_dipsw_4,gpio_funct_gpio,gpio_data_dir_in,gpio_pin_state_x);
    //gpio_port_init(p_port, p_pin, p_funct, p_data_dir, p_state);
}
示例#3
0
/*
 * configures switch for polling
 */
void uc_sw_init(switch_t p_switch)
{
	if(p_switch == switch_1)
	{
		//setup GPIO for relevant pin
		gpio_port_init(port_C, pin_3, alt_1, input);
		
		//enable pullup res
		PORTC_PCR3 |= 1 << 1;
	}
	
	if(p_switch == switch_3)
	{
		gpio_port_init(port_C, pin_12, alt_1, input);
		PORTC_PCR12 |= 1 << 1;
	}
}
示例#4
0
/*
 *  Initializes LED GPIOs.
 */
void CAR_LED_init()
{
	//CS/RCLK
	gpio_port_init(port_E, pin_19, alt_1, output);
	gpio_set_pin_state(port_E, pin_19, 1);
	//output enable
	gpio_port_init(port_B, pin_3, alt_1, output);
	gpio_set_pin_state(port_B, pin_3, 0);
	//clear and reset
	gpio_port_init(port_B, pin_2, alt_1, output);
	gpio_set_pin_state(port_B, pin_2, 0);
	gpio_set_pin_state(port_B, pin_2, 1);
	
	CAR_LED_set_color(car_led_0, car_led_off);
	CAR_LED_set_color(car_led_1, car_led_off);
	CAR_LED_set_color(car_led_2, car_led_off);
	CAR_LED_set_color(car_led_3, car_led_off);
	CAR_LED_update();
}
示例#5
0
/*
 * configures switch as interrupt
 */
void uc_sw_init_int(switch_t p_switch, callback_t p_callback)
{
	if(p_switch == switch_1)
	{
		//setup GPIO for relevant pin
		gpio_port_init(port_C, pin_3, alt_1, input);
		
		//enable pullup res
		PORTC_PCR3 |= 1 << 1;
		gpio_enable_interrupt(port_C, pin_3, trig_int_negedge, p_callback);
	}
	
	if(p_switch == switch_3)
	{
		gpio_port_init(port_C, pin_12, alt_1, input);
		PORTC_PCR12 |= 1 << 1;
		
		gpio_enable_interrupt(port_C, pin_12, trig_int_negedge, p_callback);
	}
	
	
}
示例#6
0
void uc_pushb_init(int_isr p_pb1_callback, int_isr p_pb2_callback)
{
	g_pb1_callback = p_pb1_callback;
	g_pb2_callback = p_pb2_callback;
	
	//void gpio_port_init(int p_port, int p_pin, int p_funct, int p_data_dir, int p_state)
	gpio_port_init(gpio_port_ta, uc_pb_1, gpio_funct_primary, gpio_data_dir_in, gpio_pin_state_high);
	gpio_port_init(gpio_port_ta, uc_pb_2, gpio_funct_primary, gpio_data_dir_in, gpio_pin_state_high);
	//Call gpt_disable()
	gpt_disable();
	//Call gpt_incap_config() to configure pin 0 for input capture on the falling edge
	gpt_incap_config(gpt_pin_0,gpt_incap_edge_rising);
	//Call gpt_incap_config() to configure pin 1 for input capture on the falling edge
	gpt_incap_config(gpt_pin_1,gpt_incap_edge_rising);
	//Call int_configure(gpt0_int_src, gpt0_int_level, gpt0_int_priority, uc_pushb1_isr) 
	int_config(gpt0_int_src, gpt0_int_level, gpt0_int_priority, uc_pushb1_isr);
	//Call int_configure(gpt1_int_src, gpt1_int_level, gpt1_int_priority, uc_pushb2_isr) 
	int_config(gpt1_int_src, gpt1_int_level, gpt1_int_priority, uc_pushb2_isr);
	//Call gpt_enable() to enable the GPT module
	gpt_enable();

}