コード例 #1
0
/**
 * \brief Set the LCD backlight level.
 *
 * \param ul_level backlight level.
 *
 * \note pin BOARD_AAT31XX_SET_GPIO must be configured before calling aat31xx_set_backlight.
 */
void aat31xx_set_backlight(uint32_t ul_level)
{
	volatile uint32_t ul_delay;
	uint32_t i;

#ifdef CONF_BOARD_AAT3155
	ul_level = AAT31XX_MAX_BACKLIGHT_LEVEL - ul_level + 1;
#endif

#ifdef CONF_BOARD_AAT3193
	ul_level = AAT31XX_MAX_BACKLIGHT_LEVEL - ul_level + 1;
#endif

	/* Ensure valid level */
	ul_level = (ul_level > AAT31XX_MAX_BACKLIGHT_LEVEL) ? AAT31XX_MAX_BACKLIGHT_LEVEL : ul_level;
	ul_level = (ul_level < AAT31XX_MIN_BACKLIGHT_LEVEL) ? AAT31XX_MIN_BACKLIGHT_LEVEL : ul_level;

	/* Set new backlight level */
	for (i = 0; i < ul_level; i++) {
		ioport_set_pin_level(BOARD_AAT31XX_SET_GPIO, IOPORT_PIN_LEVEL_LOW);
		ul_delay = DELAY_PULSE;
		while (ul_delay--) {
		}

		ioport_set_pin_level(BOARD_AAT31XX_SET_GPIO, IOPORT_PIN_LEVEL_HIGH);

		ul_delay = DELAY_PULSE;
		while (ul_delay--) {
		}
	}

	ul_delay = DELAY_ENABLE;
	while (ul_delay--) {
	}
}
コード例 #2
0
ファイル: unit_tests.c プロジェクト: 70year/MICO
/**
 * \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");
}
コード例 #3
0
ファイル: main.c プロジェクト: AlexShiLucky/freertos
/**
 *  \brief Process Buttons Events
 *
 *  Change active states of LEDs when corresponding button events happened.
 */
static void ProcessButtonEvt(uint8_t uc_button)
{
// [main_button1_evnt_process]
	if (uc_button == 0) {
		g_b_led0_active = !g_b_led0_active;
		if (!g_b_led0_active) {
			ioport_set_pin_level(LED0_GPIO, IOPORT_PIN_LEVEL_HIGH);
		}
	}
// [main_button1_evnt_process]
#ifdef LED1_GPIO 
	else {
// [main_button2_evnt_process]
		g_b_led1_active = !g_b_led1_active;

		/* Enable LED#2 and TC if they were enabled */
		if (g_b_led1_active) {
			ioport_set_pin_level(LED1_GPIO, IOPORT_PIN_LEVEL_LOW);
			tc_start(TC0, 0);
		}
		/* Disable LED#2 and TC if they were disabled */
		else {
			ioport_set_pin_level(LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
			tc_stop(TC0, 0);
		}
// [main_button2_evnt_process]
	}
#endif
}
コード例 #4
0
ファイル: peripherals_module.c プロジェクト: Toussaic/main
void setup_rf_attenuator(uint16_t atten)
{	
	volatile uint32_t data;
	
	__attribute__((unused)) uint16_t dummy;
	__attribute__((unused)) uint8_t dummy2;
	
	current_attenution = atten;
	
	// Clear receive buffer
	//while((spi_read_status(SPI0) & SPI_SR_RDRF) == 0);
	spi_read(SPI0, &dummy, &dummy2);
	
	data = (uint32_t)atten & 0x007F;
	data = __RBIT(data);
	data >>= 16;
	spi_write(SPI0, data, SPI_ALT_CHIP_SEL, 0);
	/* Wait transfer done. */
	while((spi_read_status(SPI0) & SPI_SR_RDRF) == 0);
	spi_read(SPI0, &dummy, &dummy2);
	
	ioport_set_pin_level(RF_ATTEN_SLOAD_GPIO, IOPORT_PIN_LEVEL_HIGH);
	for(int i=0;i<30;i++);
	ioport_set_pin_level(RF_ATTEN_SLOAD_GPIO, IOPORT_PIN_LEVEL_LOW);
}
コード例 #5
0
void write_header_SD(void)
{
	ioport_set_pin_level(LED_SD_USE, IOPORT_PIN_LEVEL_LOW); //accendo led esterno
	if(open_append(&log_file_object, (char const *)file_name))
		terminate("Error opening logfile!");
	//scrivo intestazione file di log a seconda del modello scelto
	switch(model)
	{	
		case log:
			f_printf(&log_file_object, "Model:%s Interval:%ds  Vout:%dmV\r\n", modelStrings[model], interval, log_vout);
			break;
		case bat:
			f_printf(&log_file_object, "Model:%s Interval:%ds Vmax:%dmV Vexp:%dmV Qexp:%dmAh Vnom:%dmV Qnom:%dmAh Qtot:%dmAh Rint:%dmOhm Isam:%dmAh\r\n", 
					modelStrings[model], interval, bat_vmax, bat_vexp, bat_qexp, bat_vnom, bat_qnom, bat_qtot, bat_rint, bat_isam);
			sprintf(str, "Calculated values:E0:%lf K:%lf A:%lf B:%lf\r\n", bat_param[0], bat_param[1], bat_param[2], bat_param[3]);
			f_printf(&log_file_object, "%s", str);
			break;
	/*	case phv:
			//impl
			break;
		case tec:
			//impl
			break;
	*/
	}
	f_printf(&log_file_object, "Data Ora Tensione(mV) Corrente(uA)\r\n");
	ioport_set_pin_level(LED_SD_USE, IOPORT_PIN_LEVEL_HIGH); //spengo led esterno
}
コード例 #6
0
ファイル: nvm_example.c プロジェクト: kerichsen/asf
/*! \brief NVM Example Main
 *
 * The NVM example begins by initializing required board resources.  The
 * system clock and basic GPIO pin mapping are established.
 *
 * A memory location on the Non volatile memory is written with a fixed test
 * pattern which is then read back into a separate buffer. As a basic sanity
 * check, the original write-buffer values are compared with values read to
 * a separate buffer.  An LED on the development board is illuminated when there
 * is a match between the written and read data.
 *
 * \return Nothing.
 */
int main(void)
{
	mem_type_t mem;

	sysclk_init();
	board_init();

	/* Test internal flash */
	mem = INT_FLASH;
	if (test_mem(mem, (uint32_t)TEST_ADDRESS_INT) == STATUS_OK) {
		/* Turn on LED to indicate success */
		ioport_set_pin_level(NVM_EXAMPLE_LED0, false);
	}

#if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX)
	/* Test external dataflash */
	mem = AT45DBX;
	if (test_mem(mem, (uint32_t)TEST_ADDRESS_EXT) == STATUS_OK) {
		/* Turn on LED to indicate success */
		ioport_set_pin_level(NVM_EXAMPLE_LED1, false);
	}
#endif

	/* Turn on LED to indicate tests are complete */
	ioport_set_pin_level(NVM_EXAMPLE_LED2, false);

	while (1) {
	}
}
コード例 #7
0
ファイル: gpio.c プロジェクト: JBTech/OS-CC2540
void init_gpio_pins(void)
{
	ioport_enable_pin(LED_1);
	ioport_enable_pin(LED_2);
	ioport_enable_pin(LED_3);

	ioport_enable_pin(HM_10_RESET);
	ioport_enable_pin(HM_10_DD);
	ioport_enable_pin(HM_10_DC);
	ioport_enable_pin(HM_10_MSG);
	
	ioport_set_pin_dir(LED_1, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED_2, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED_3, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(HM_10_RESET, IOPORT_DIR_INPUT);
	ioport_set_pin_dir(HM_10_DD, IOPORT_DIR_INPUT);
	ioport_set_pin_dir(HM_10_DC, IOPORT_DIR_INPUT);
	ioport_set_pin_dir(HM_10_MSG, IOPORT_DIR_INPUT);

	ioport_set_pin_level(LED_1, false);
	ioport_set_pin_level(LED_2, false);
	ioport_set_pin_level(LED_3, false); // LED's on
	
	
	/*ioport_set_pin_level(HM_10_DD, false); // DC,DD low
	ioport_set_pin_level(HM_10_DC, false);
	ioport_set_pin_level(HM_10_RESET, false); // HM-10 in reset (reset low)*/
}
コード例 #8
0
ファイル: OctopusBot.c プロジェクト: Nickiler531/AR-smart
void blink(void){
	ioport_set_pin_level(LED1,ON);
	ioport_set_pin_level(LED2,ON);
	delay_s(1);
	ioport_set_pin_level(LED1,OFF);
	ioport_set_pin_level(LED2,OFF);
	delay_s(1);
}
コード例 #9
0
void close_logfile_SD()
{
	ioport_set_pin_level(LED_SD_USE, IOPORT_PIN_LEVEL_LOW); //accendo led esterno
	strncpy(buffer, buffer, buffer_p-buffer);
	f_printf(&log_file_object, buffer);
	f_close(&log_file_object); //chiudo file
	ioport_set_pin_level(LED_SD_USE, IOPORT_PIN_LEVEL_HIGH); //spengo led esterno
}
コード例 #10
0
void init_temp_sens()
{
	ioport_set_pin_dir(TEMP_CLK, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(TEMP_CS, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(TEMP_IO, IOPORT_DIR_INPUT);
	ioport_set_pin_level(TEMP_CS,1);
	ioport_set_pin_level(TEMP_CLK,0);
}
コード例 #11
0
ファイル: ui.c プロジェクト: InSoonPark/asf
void ui_process(uint16_t framenumber)
{
	if (0 == framenumber) {
		ioport_set_pin_level(LED0_PIN,LED0_ACTIVE);
	}
	if (1000 == framenumber) {
		ioport_set_pin_level(LED0_PIN,LED0_INACTIVE);
	}
}
コード例 #12
0
/**
 * \internal
 * \brief Reset the display using the digital control interface
 *
 * Controls the reset pin of the display controller to reset the display.
 */
static void ili9341_reset_display(void)
{
	ioport_set_pin_level(CONF_ILI9341_RESET_PIN, true);
	delay_ms(10);
	ioport_set_pin_level(CONF_ILI9341_RESET_PIN, false);
	delay_ms(10);
	ioport_set_pin_level(CONF_ILI9341_RESET_PIN, true);
	delay_ms(150);
}
コード例 #13
0
/**
 * \brief Set the led status and send back the new status.
 *
 * \param name String containing the led status request.
 * \param recv_buf Receive buffer.
 * \param recv_len Receive buffer length.
 *
 * \return 0.
 */
static int cgi_led(const char *name, char *recv_buf, size_t recv_len)
{
	UNUSED(recv_buf);
	UNUSED(recv_len);
	UNUSED(name);

	char *query_str = strstr(name, "?") + 1;
	size_t query_str_len = strlen(query_str);
	int led_id;
	int led_pio;
	int led_cmd;

	http_tokenizeGetRequest(query_str, query_str_len);

	if (http_getValue(query_str, query_str_len, CGI_LED_ID_KEY, key_value,
			sizeof(key_value)) < 0) {
		goto error;
	}

	led_id = atoi(key_value);

	if (http_getValue(query_str, query_str_len, CGI_LED_CMD_KEY, key_value,
			sizeof(key_value)) < 0) {
		goto error;
	}

	led_cmd = atoi(key_value);

	if (led_id == 0) {
		led_pio = LED2_GPIO;
	} else if (led_id == 1) {
		led_pio = LED1_GPIO;
	} else if (led_id == 2) {
		led_pio = LED0_GPIO;
	} else if (led_id == 3) {
		led_pio = LED3_GPIO;
	}

	if (led_cmd) {
		ioport_set_pin_level(led_pio, LED2_ACTIVE_LEVEL);
		SET_LED_STATUS(status.led_status, led_id);
	} else {
		ioport_set_pin_level(led_pio, LED2_INACTIVE_LEVEL);
		CLEAR_LED_STATUS(status.led_status, led_id);
	}

	sprintf((char *)tx_buf, "{\"n\":%d, \"set\":,%d}", led_id, led_cmd);

	http_sendOk(HTTP_CONTENT_JSON);
	http_write((const char *)tx_buf, strlen((char *)tx_buf));
	return 0;

error:
	http_sendInternalErr(HTTP_CONTENT_JSON);
	return 0;
}
コード例 #14
0
ファイル: task_addon.c プロジェクト: dwildmark/DA210A
void task_addon(void *pvParameters)
{
	portTickType xLastWakeTime;
	const portTickType xTimeIncrement = taskADDON_PERIOD;
	xLastWakeTime = xTaskGetTickCount();
	bool switch_top;
	bool switch_btm;
	while(1){
		switch_top = ioport_get_pin_level(ADDON_SWITCH_TOP);
		switch_btm = ioport_get_pin_level(ADDON_SWITCH_BTM);
		if(addon_up && (!switch_top)) {
			ioport_set_pin_level(ADDON_DIR_PIN_CW, ADDON_DIR_HIGH);
			ioport_set_pin_level(ADDON_DIR_PIN_CCW, ADDON_DIR_LOW);
			ioport_set_pin_level(ADDON_DRIVE_PIN, true);
		} else if(addon_down && (!switch_btm)) {
			ioport_set_pin_level(ADDON_DIR_PIN_CW, ADDON_DIR_LOW);
			ioport_set_pin_level(ADDON_DIR_PIN_CCW, ADDON_DIR_HIGH);
			ioport_set_pin_level(ADDON_DRIVE_PIN, true);
		} else {
			ioport_set_pin_level(ADDON_DRIVE_PIN, false);
			ioport_set_pin_level(ADDON_DIR_PIN_CW, ADDON_DIR_LOW);
			ioport_set_pin_level(ADDON_DIR_PIN_CCW, ADDON_DIR_LOW);
			addon_up = false;
			addon_down = false;
		}
		vTaskDelayUntil(&xLastWakeTime, xTimeIncrement);
	}
}
コード例 #15
0
ファイル: PWMFunctions.c プロジェクト: kajm/PingPong
/* Funktionen initierar PWM-signalen */
void pwm_setup(void)
{
	pmc_enable_periph_clk(ID_PWM);
	pwm_channel_disable(PWM, PWM_CHANNEL);
	
	pwm_clock_t clock_setting = {
		.ul_clka = PWM_FREQUENCY * PWM_PERIOD,
		.ul_clkb = 0,
		.ul_mck = SYS_CLOCK
	};
	
	pwm_init(PWM, &clock_setting);
	
	pwm_channel_instance.alignment = PWM_ALIGN_LEFT;
	pwm_channel_instance.polarity = PWM_LOW;
	pwm_channel_instance.ul_prescaler = PWM_CMR_CPRE_CLKA;
	pwm_channel_instance.ul_period = PWM_PERIOD;
	pwm_channel_instance.ul_duty = PWM_INIT_DUTY_CYCLE;
	pwm_channel_instance.channel = PWM_CHANNEL;
	
	pwm_channel_init(PWM, &pwm_channel_instance);
	pio_set_peripheral(PWM_PIO, PWM_PERIPHERAL, PWM_PIN);
	pwm_channel_enable(PWM, PWM_CHANNEL);
}


/* Funktionen uppdaterar PWM-signalens duty-cycle */
void update_pwm(int ul_duty)
{
	// Kontrollerar så att angiven duty-cycle befinner sig inom rätt område (0-1000).
	if(ul_duty < PWM_MIN_DUTY_CYCLE)
	{
		pwm_channel_update_duty(PWM, &pwm_channel_instance, PWM_MIN_DUTY_CYCLE);
	}
	else if(ul_duty > PWM_MAX_DUTY_CYCLE)
	{
		pwm_channel_update_duty(PWM, &pwm_channel_instance, PWM_MAX_DUTY_CYCLE);
	}
	else
	{
		pwm_channel_update_duty(PWM, &pwm_channel_instance, ul_duty);
	}
}


/* Funktionen initierar motor-shielden */
void motor_shield_setup(void)
{
	ioport_set_pin_dir(PIO_PD8_IDX, IOPORT_DIR_OUTPUT);
	ioport_set_pin_level(PIO_PD8_IDX, IOPORT_PIN_LEVEL_HIGH);
	
	ioport_set_pin_dir(PIO_PC21_IDX, IOPORT_DIR_OUTPUT);
	ioport_set_pin_level(PIO_PC21_IDX, IOPORT_PIN_LEVEL_LOW);
}
コード例 #16
0
ファイル: peripherals_module.c プロジェクト: Toussaic/main
void enable_disable_clock_delay(uint16_t status)
{
	if(status == TRUE)
	{
		is_clock_delay_en = TRUE;
		ioport_set_pin_level(CLOCK_DELAY_EN_GPIO, IOPORT_PIN_LEVEL_LOW);
	}
	else
	{
		is_clock_delay_en = FALSE;
		ioport_set_pin_level(CLOCK_DELAY_EN_GPIO, IOPORT_PIN_LEVEL_HIGH);
	}
}
コード例 #17
0
void parseCommand(void)
{
	char byte1;
	char byte2;
	char byte3;
	char byte4;
	
	buf_get(&byte1);
	buf_get(&byte2);
	buf_get(&byte3);
	buf_get(&byte4);
	
	if(byte1 & CMD_TYPE_bm){
		CMDstate = Speed;
		if(byte1 & ML_DIR_bm){
			ioport_set_pin_level(PE0,1);
		}//if
		else{
			ioport_set_pin_level(PE0,0);
		}//else
		mlDutyCycle = byte2;
		
		if(byte1 & MR_DIR_bm){
			ioport_set_pin_level(PE2,0);
		}//if
		else{
			ioport_set_pin_level(PE2,1);
		}//else
		mrDutyCycle = byte3;
		
	}//if
	else{
		if(byte1 & POS_GET){
			sendPositionFlag = true;	
		}//if
		else{
			if(byte1 & ML_POS_bm){
				CMDstate = Position;
				if(byte2 <= 192){
					mlDestination = byte2;
				}//if
			}//if
			if(byte1 & MR_POS_bm){
				CMDstate = Position;
				if(byte3 <= 192){
					mrDestination = byte3;
				}//if
			}//if
		}//else
	}//else
}//parseCommand
コード例 #18
0
ファイル: main.c プロジェクト: forkineye/FloodBrain_ASF
// setup the board instead of board_init() as recommended by ASF.. because christmas lights, that's why.
void init (void) {
	static usart_serial_options_t usart_options = {
		.baudrate = USART_SERIAL_BAUDRATE,
		.charlength = USART_SERIAL_CHAR_LENGTH,
		.paritytype = USART_SERIAL_PARITY,
		.stopbits = USART_SERIAL_STOP_BIT
	};
	
	// initialize ASF stuff
	board_init();
	sysclk_init();
	ioport_init();
	pmic_init();
	pmic_set_scheduling(PMIC_SCH_FIXED_PRIORITY);
	
	// remap, enable TX, and configure USART on PORT C
	PORTC.REMAP |= PR_USART0_bm;
	PORTC.DIR |= (1 << PIN7_bp);
		
	sysclk_enable_module(SYSCLK_PORT_C, PR_USART0_bm);
	usart_init_rs232(USART_SERIAL, &usart_options);
	
	// setup timer for PWM
	tc45_enable(&TCC4);
	tc45_set_overflow_interrupt_callback(&TCC4, pwm_callback);
	tc45_set_wgm(&TCC4, TC45_WG_NORMAL);
	tc45_write_period(&TCC4, 256);
	tc45_set_overflow_interrupt_level(&TCC4, TC45_INT_LVL_MED);
		
	// enable all channels and turn off (high)
	ioport_set_port_dir(IOPORT_PORTA, PORTA_MASK, IOPORT_DIR_OUTPUT);
	ioport_set_port_dir(IOPORT_PORTD, PORTD_MASK, IOPORT_DIR_OUTPUT);
	ioport_set_port_dir(IOPORT_PORTR, PORTR_MASK, IOPORT_DIR_OUTPUT);
	ioport_set_port_level(IOPORT_PORTA, PORTA_MASK, 0xFF);
	ioport_set_port_level(IOPORT_PORTD, PORTD_MASK, 0xFF);
	ioport_set_port_level(IOPORT_PORTR, PORTR_MASK, 0xFF);
	for (uint8_t i=0; i<NUM_CHANNELS; i++) {
		compare[i] = 0;
		compbuff[i] = 0;
	}
	
	// enable status LEDs and turn off
	ioport_set_pin_dir(LED_STATUS, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED_DATA, IOPORT_DIR_OUTPUT);
	ioport_set_pin_level(LED_STATUS, 1);
	ioport_set_pin_level(LED_DATA, 1);
	
	// enable interrupts and start timer for PWM
	cpu_irq_enable();
	tc45_write_clock_source(&TCC4, TC45_CLKSEL_DIV2_gc);	
}
コード例 #19
0
ファイル: sx1276-Hal.c プロジェクト: witc/Terminal_SX1276
void SX1276SetReset( uint8_t state )
{
    if( state == RADIO_RESET_ON )
    {
        // Set RESET pin to 1
        ioport_set_pin_level(SX1276_RESET_PIN, true);
        //ioport_set_pin_mode(SX1276_RESET_PIN, IOPORT_DIR_INPUT);
    }
    else
    {
        // Set RESET pin to 0
        ioport_set_pin_level(SX1276_RESET_PIN, false);
    }
}
コード例 #20
0
ファイル: switch.c プロジェクト: hkwi/ZodiacFX
/*
*	SPI interface IRQ handler
*	Used to receive data from the stacking interface
*
*/
void SPI_Handler(void)
{
	static uint16_t data;
	uint8_t uc_pcs;

	spi_read(SPI_SLAVE_BASE, &data, &uc_pcs);
	if (data == 5) ioport_set_pin_level(SPI_IRQ1, true);
	if (data == 8) ioport_set_pin_level(SPI_IRQ1, false);
	printf("%d", data);
	data += 1;
	spi_write(SPI_SLAVE_BASE,data, 0, 0);
	printf("\r");
	return;
}
コード例 #21
0
ファイル: leds.c プロジェクト: Nickiler531/AR-smart
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;
	}
}
コード例 #22
0
void vfd_init(void) {
	ioport_set_pin_level(VFD_NRST, true);
	delay_ms(100);
	ioport_set_pin_level(VFD_NRST, false);
	
	delay_ms(500);
	
	vfd_write(0x1B);
	delay_ms(100);
	vfd_write('@');
	delay_ms(100);

//	vfd_cursor_on();
	vfd_select_base_window();
}
コード例 #23
0
ファイル: I2C.c プロジェクト: rgharris/477grp3
int I2C_init( void ) {

  twi_options_t opt;
  twi_slave_fct_t twi_slave_fct;
  int status;
  double total = 0;

  // Initialize and enable interrupt
  irq_initialize_vectors();
  cpu_irq_enable();

  // TWI gpio pins configuration
  gpio_enable_module(TWI_GPIO_MAP, sizeof(TWI_GPIO_MAP) / sizeof(TWI_GPIO_MAP[0]));
  
  // initialize the interrupt flag for alerting the Pi of new data (TWI = Three Wire Interface for us)
  ioport_enable_pin(I2C_FLAG);
  ioport_set_pin_dir(I2C_FLAG,IOPORT_DIR_OUTPUT);
  ioport_set_pin_level(I2C_FLAG,false);

  // options settings
  opt.pba_hz = FOSC0;
  opt.speed = TWI_SPEED;
  opt.chip = EEPROM_ADDRESS;

  // initialize TWI driver with options
  twi_slave_fct.rx = &twi_slave_rx;
  twi_slave_fct.tx = &twi_slave_tx;
  twi_slave_fct.stop = &twi_slave_stop;
  status = twi_slave_init(&AVR32_TWI, &opt, &twi_slave_fct );
 
  return (&s_memory[0] );
}
コード例 #24
0
ファイル: init.c プロジェクト: alanvgreen/DirSpk1
static void initGpio(void) {
	ioport_init();
	
	// PIOB
	ioport_set_pin_level(LED0_GPIO, false);
	ioport_set_pin_dir(LED0_GPIO, IOPORT_DIR_OUTPUT);
}
コード例 #25
0
ファイル: hf_trace.c プロジェクト: HashFast/hashfast-uc
/**
 * Initialize tracing on A3BU
 */
void a3bu_trace_init() {
    ioport_configure_port_pin(&PORTB, PIN0_bm, IOPORT_DIR_OUTPUT);
    ioport_configure_port_pin(&PORTB, PIN1_bm, IOPORT_DIR_OUTPUT);
    ioport_configure_port_pin(&PORTB, PIN2_bm, IOPORT_DIR_OUTPUT);
    ioport_configure_port_pin(&PORTB, PIN3_bm, IOPORT_DIR_OUTPUT);
    ioport_set_pin_level(SPIN_0, 0);
}
コード例 #26
0
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);
	}
}
コード例 #27
0
void vfd_write(uint8_t data) {
	uint8_t i = 1;
	for (i = 0; i < 8; i++) {
		ioport_set_pin_level(VFD_SCK, true);
		delay_us(100);

		if (data & (1 << i)) {
			ioport_set_pin_level(VFD_MOSI, false);
			} else {
			ioport_set_pin_level(VFD_MOSI, true);
		}
		ioport_set_pin_level(VFD_SCK, false);
		delay_us(100);
	}
	delay_us(100);
}
コード例 #28
0
ファイル: iso7816.c プロジェクト: ddm/chipwhisperer
/**
 * \brief Initializes a ISO7816 interface device.
 *
 * \param p_usart_opt     Pointer to an ISO7816 instance.
 * \param ul_mck          USART module input clock frequency.
 * \param ul_rst_pin_idx  Control smart card RST pin index.
 */
unsigned int iso7816_init(const usart_iso7816_opt_t *p_usart_opt,
		uint32_t ul_mck, uint32_t ul_rst_pin_idx)
{
	/* Pin RST of ISO7816 initialize. */
	gs_ul_rst_pin_idx = ul_rst_pin_idx;
#if defined(SMART_CARD_USING_GPIO)
	gpio_set_pin_low(gs_ul_rst_pin_idx);
#elif defined(SMART_CARD_USING_IOPORT)
	ioport_set_pin_level(gs_ul_rst_pin_idx, IOPORT_PIN_LEVEL_LOW);
#endif
	/* Init the global variable for ISO7816. */
	g_ul_clk = ul_mck;

	if(usart_init_iso7816(ISO7816_USART, p_usart_opt, g_ul_clk)){
		return 1;
	}

	/* Disable interrupts. */
	usart_disable_interrupt(ISO7816_USART, 0xffffffff);

	/* Write the Timeguard Register. */
	usart_set_tx_timeguard(ISO7816_USART, 5);

	/* Enable TX and RX. */
	usart_enable_rx(ISO7816_USART);
	//usart_enable_tx(ISO7816_USART);
	
	return 0;
}
コード例 #29
0
void terminate(const char *s)
{
	rtc_disable_interrupt(RTC, RTC_IDR_ALRDIS);//disabilito interrupt RTC
	rtt_disable_interrupt(RTT, RTT_MR_RTTINCIEN);//disabilito interrupt RTT
	afec_disable(AFEC0);//disabilito convertitore A/D
	dacc_disable_channel(DACC_BASE, DACC_CHANNEL);//disabilito convertitore D/A
	write_record_syslog(s);
	write_record_syslog("Programma terminato!");
	close_logfile_SD(); //chiudo logfile
	f_close(&syslog_file_object); //chiudo file syslog
	dac_out=0;//azzero tensione in uscita
	ioport_set_pin_level(LED_SD_USE, IOPORT_PIN_LEVEL_HIGH); //spengo led SD_USE
	ioport_set_pin_level(LED_SYSTEM_READY, IOPORT_PIN_LEVEL_HIGH); //spengo led SD_PRESENT
	ioport_set_pin_level(LED_ERROR, IOPORT_PIN_LEVEL_LOW); //accendo led ERROR
	exit(EXIT_SUCCESS);
}
コード例 #30
0
//TODO: Remove for testing
static void alarm(uint32_t time)
{
	ioport_set_pin_level(LED_0_PIN,!ioport_get_pin_level(LED_0_PIN));
	//rtc_set_alarm_relative(1024);
	rtc_set_callback(alarm2);
	rtc_set_alarm_relative(32768*2);
}